Main { questname "Skywonder Rescue" version 1.0 }
State Begin { } State TalkToWolfLeader { }
State Begin { desc "Talk to Jessica" } State TalkToWolfLeader { desc "Talk to the Wolf Leader" }
State Begin { desc "Talk to Jessica" action AddNpcText(13, "Hello, as you can see I live peacefully with the blobsies in the wonderful sky, then one day the wolfman and the foxes got into a fight and all the foxes moved to here"); } State TalkToWolfLeader { desc "Talk to the Wolf Leader" action AddNpcText(13, "Go talk to the wolfman first im sure he's willing to compromise so we can all live in peace again."); action AddNpcText( 14, "Hello there, i see Jessica sent you, what do you want?"); }
State Begin { desc "Talk to Jessica" action AddNpcText(13, "Hello, as you can see I live peacefully with the blobsies in the wonderful sky, then one day the wolfman and the foxes got into a fight and all the foxes moved to here"); } State TalkToWolfLeader { desc "Talk to the Wolf Leader" action AddNpcText(13, "Go talk to the wolfman first im sure he's willing to compromise so we can all live in peace again."); action AddNpcText( 14, "Hello there, i see Jessica sent you, what do you want?"); action AddNpcInput( 14, 1, "I come in peace"); action AddNpcInput( 14, 2, "Nothing, bye"); }
State Begin { desc "Talk to Jessica" action AddNpcText(13, "Hello, as you can see I live peacefully with the blobsies in the wonderful sky, then one day the wolfman and the foxes got into a fight and all the foxes moved to here"); rule TalkedToNpc(13) goto TalkToWolfLeader } State TalkToWolfLeader { desc "Talk to the Wolf Leader" action AddNpcText(13, "Go talk to the wolfman first im sure he's willing to compromise so we can all live in peace again."); action AddNpcText( 14, "Hello there, i see Jessica sent you, what do you want?"); action AddNpcInput( 14, 1, "I come in peace"); action AddNpcInput( 14, 2, "Nothing, bye"); }
State Begin { desc "Talk to Jessica" action AddNpcText(13, "Hello, as you can see I live peacefully with the blobsies in the wonderful sky, then one day the wolfman and the foxes got into a fight and all the foxes moved to here"); rule TalkedToNpc(13) goto TalkToWolfLeader } State TalkToWolfLeader { desc "Talk to the Wolf Leader" action AddNpcText(13, "Go talk to the wolfman first im sure he's willing to compromise so we can all live in peace again."); action AddNpcText( 14, "Hello there, i see Jessica sent you, what do you want?"); action AddNpcInput( 14, 1, "I come in peace"); action AddNpcInput( 14, 2, "Nothing, bye"); rule InputNpc(1) goto GetBirdFeathers } State GetBirdFeathers { desc "Find 10 bird feathers" action AddNpcText( 14, "We are currently at war with the birdmans on the other mountain. I am currently too busy to talk about peace with the foxes."); action AddNpcText( 14, "You know i hate those annoying birdmans, if you help us fight the birdmans and bring me 10 bird feathers I will think about your offer." ); } State GiveFeathers { desc "Give 10 bird feathers" action AddNpcText(14, "Hi again, i can see you have been fighting with the birdmans, your help is greatly appreciated!"); action AddNpcText(14, "Will you give me those bird feathers?"); action AddNpcInput(14, 2, "Ok, here you are"); action AddNpcInput(14, 1, "No, these are mine"); rule InputNpc(2) goto TalkToJessica }
State Begin { desc "Talk to Jessica" action AddNpcText(13, "Hello, as you can see I live peacefully with the blobsies in the wonderful sky, then one day the wolfman and the foxes got into a fight and all the foxes moved to here"); rule TalkedToNpc(13) goto TalkToWolfLeader } State TalkToWolfLeader { desc "Talk to the Wolf Leader" action AddNpcText(13, "Go talk to the wolfman first im sure he's willing to compromise so we can all live in peace again."); action AddNpcText( 14, "Hello there, i see Jessica sent you, what do you want?"); action AddNpcInput( 14, 1, "I come in peace"); action AddNpcInput( 14, 2, "Nothing, bye"); rule InputNpc(1) goto GetBirdFeathers } State GetBirdFeathers { desc "Find 10 bird feathers" action AddNpcText( 14, "We are currently at war with the birdmans on the other mountain. I am currently too busy to talk about peace with the foxes."); action AddNpcText( 14, "You know i hate those annoying birdmans, if you help us fight the birdmans and bring me 10 bird feathers I will think about your offer." ); rule GotItems(299,10) goto GiveFeathers } State GiveFeathers { desc "Give 10 bird feathers" action AddNpcText(14, "Hi again, i can see you have been fighting with the birdmans, your help is greatly appreciated!"); action AddNpcText(14, "Will you give me those bird feathers?"); action AddNpcInput(14, 2, "Ok, here you are"); action AddNpcInput(14, 1, "No, these are mine"); rule InputNpc(2) goto TalkToJessica rule LostItems(299,10) goto GetBirdFeathers }
State TalkToJessica { desc "Go see Jessica for your reward" action RemoveItem(299,10); action AddNpcText(14, "Go tell Jessica we shall make peace with the Foxes"); action AddNpcText(13, "Thank you so much for your help, please accept this reward"); rule TalkedToNpc(13) goto Reward } State Reward { }
State Reward { action GiveExp(500); action GiveItem(1, 500); }
State Reward { action GiveExp(500); action GiveItem(1, 500); action Reset(); }
Main { questname "Wiseman Quest" version 1.0 } State Begin { } State KillRats { } State Wiseman1 { } State TileStep { } State Wiseman2 { } State GetPenguinMeat { } State Wiseman3 { } State TalkToPigFarmer { } State Wiseman4 { } State KillPlayer { } State ClassMenu { } State Priest { } State Magician { } State Rogue { } State Archer { } State Warrior { }
Main { questname "Wiseman Quest" version 1.0 } State Begin { } State KillRats { desc "Kill 5 Rats" } State Wiseman1 { desc "Talk to Wiseman" } State TileStep { desc "Check the Boat Door" } State Wiseman2 { desc "Talk to Wiseman" } State GetPenguinMeat { desc "Find 5 Penguin Meat" } State Wiseman3 { desc "Talk to Wiseman" } State TalkToPigFarmer { desc "Talk to Pig Farmer" } State Wiseman4 { desc "Talk to Wiseman" } State KillPlayer { desc "Kill 1 Player in PK" } State ClassMenu { desc "Talk to Wiseman" } State Priest { } State Magician { } State Rogue { } State Archer { } State Warrior { }
Main { questname "Wiseman Quest" version 1.0 } State Begin { action AddNpcText(4, "Hellow there, I am tired of changing classes for just anyone"); } State KillRats { desc "Kill 5 Rats" action AddNpcText(4, "Prove you aren't lazy, Kill 5 Rats."); } State Wiseman1 { desc "Talk to Wiseman" action AddNpcText(4, "Ok, but I have a request of you"); } State TileStep { desc "Check the Boat Door" action AddNpcText(4, "Check that boat that sails to Newb Land to ensure the door to the captain's chamber is locked"); } State Wiseman2 { desc "Talk to Wiseman" action AddNpcText(4, "Good, now I am hungry. Go fetch about 5 Penguin meat for my dinner"); } State GetPenguinMeat { desc "Find 5 Penguin Meat" } State Wiseman3 { desc "Talk to Wiseman" action AddNpcText(4, "Did you get 5 penguin meat?"); } State TalkToPigFarmer { desc "Talk to Pig Farmer" action AddNpcText(4, "Invite the Pig Farmer to Town Square to share this meal with me"); action AddNpcText(24, "Wiseman, eh? Tell that old fart I am fat enough. I will pass"); } State Wiseman4 { desc "Talk to Wiseman" action AddNpcText(4, "He refused? How rude! Go take out my anger on another player"); } State KillPlayer { desc "Kill 1 Player in PK" } State ClassMenu { desc "Talk to Wiseman" action AddNpcText(4, "You look like you could use a class change. What class would you like?"); } State Priest { } State Magician { } State Rogue { } State Archer { } State Warrior { }
Main { questname "Wiseman Quest" version 1.0 } State Begin { action AddNpcText(4, "Hellow there, I am tired of changing classes for just anyone"); rule TalkedToNpc(4) goto KillRats } State KillRats { desc "Kill 5 Rats" action AddNpcText(4, "Prove you aren't lazy, Kill 5 Rats."); rule KilledNpcs(2, 5) goto Wiseman1 } State Wiseman1 { desc "Talk to Wiseman" action AddNpcText(4, "Ok, but I have a request of you"); rule TalkedToNpc(4) goto TileStep } State TileStep { desc "Check the Boat Door" action AddNpcText(4, "Check that boat that sails to Newb Land to ensure the door to the captain's chamber is locked"); rule EnterCoord(1,6,21) goto Wiseman2 } State Wiseman2 { desc "Talk to Wiseman" action AddNpcText(4, "Good, now I am hungry. Go fetch about 5 Penguin meat for my dinner"); rule TalkedToNpc(4) goto GetPenguinMeat } State GetPenguinMeat { desc "Find 5 Penguin Meat" rule GotItems(259,5) goto Wiseman 3 } State Wiseman3 { desc "Talk to Wiseman" action AddNpcText(4, "Did you get 5 penquin meat?"); rule LostItems(259,5) goto Wiseman2 rule TalkedToNpc(4) goto TalkToPigFarmer } State TalkToPigFarmer { desc "Talk to Pig Farmer" action AddNpcText(4, "Invite the Pig Farmer to Town Square to share this meal with me"); action AddNpcText(24, "Wiseman, eh? Tell that old fart I am fat enough. I will pass"); rule TalkedToNpc(24) goto Wiseman4 } State Wiseman4 { desc "Talk to Wiseman" action AddNpcText(4, "He refused? How rude! Go take out my anger on another player"); rule TalkedToNpc(4) goto KillPlayer } State KillPlayer { desc "Kill 1 Player in PK" rule KilledPlayers(1) goto ClassMenu } State ClassMenu { desc "Talk to Wiseman" action AddNpcText(4, "You look like you could use a class change. What class would you like?"); action AddNpcInput(2, "Priest"); action AddNpcInput(3, "Magician"); action AddNpcInput(4, "Rogue"); action AddNpcInput(5, "Archer"); action AddNpcInput(6, "Warrior"); rule InputNpc(2) goto Priest rule InputNpc(3) goto Magician rule InputNpc(4) goto Rogue rule InputNpc(5) goto Archer rule InputNpc(6) goto Warrior } State Priest { } State Magician { } State Rogue { } State Archer { } State Warrior { }
Main { questname "Wiseman Quest" version 1.0 } State Begin { action AddNpcText(4, "Hellow there, I am tired of changing classes for just anyone"); rule TalkedToNpc(4) goto KillRats } State KillRats { desc "Kill 5 Rats" action AddNpcText(4, "Prove you aren't lazy, Kill 5 Rats."); rule KilledNpcs(2, 5) goto Wiseman1 } State Wiseman1 { desc "Talk to Wiseman" action AddNpcText(4, "Ok, but I have a request of you"); rule TalkedToNpc(4) goto TileStep } State TileStep { desc "Check the Boat Door" action AddNpcText(4, "Check that boat that sails to Newb Land to ensure the door to the captain's chamber is locked"); rule EnterCoord(1,6,21) goto Wiseman2 } State Wiseman2 { desc "Talk to Wiseman" action ShowHint("Door is locked! Check back with Wiseman"); action AddNpcText(4, "Good, now I am hungry. Go fetch about 5 Penguin meat for my dinner"); rule TalkedToNpc(4) goto GetPenguinMeat } State GetPenguinMeat { desc "Find 5 Penguin Meat" rule GotItems(259,5) goto Wiseman 3 } State Wiseman3 { desc "Talk to Wiseman" action AddNpcText(4, "Did you get 5 penquin meat?"); rule LostItems(259,5) goto Wiseman2 rule TalkedToNpc(4) goto TalkToPigFarmer } State TalkToPigFarmer { desc "Talk to Pig Farmer" action AddNpcText(4, "Invite the Pig Farmer to Town Square to share this meal with me"); action AddNpcText(24, "Wiseman, eh? Tell that old fart I am fat enough. I will pass"); rule TalkedToNpc(24) goto Wiseman4 } State Wiseman4 { desc "Talk to Wiseman" action AddNpcText(4, "He refused? How rude! Go take out my anger on another player"); rule TalkedToNpc(4) goto KillPlayer } State KillPlayer { desc "Kill 1 Player in PK" rule KilledPlayers(1) goto ClassMenu } State ClassMenu { desc "Talk to Wiseman" action AddNpcText(4, "You look like you could use a class change. What class would you like?"); action AddNpcInput(4, 2, "Priest"); action AddNpcInput(4, 3, "Magician"); action AddNpcInput(4, 4, "Rogue"); action AddNpcInput(4, 5, "Archer"); action AddNpcInput(4, 6, "Warrior"); rule InputNpc(2) goto Priest rule InputNpc(3) goto Magician rule InputNpc(4) goto Rogue rule InputNpc(5) goto Archer rule InputNpc(6) goto Warrior } State Priest { action SetClass(2); action SetState("ClassMenu"); } State Magician { action SetClass(3); action SetState("ClassMenu"); } State Rogue { action SetClass(4); action SetState("ClassMenu"); } State Archer { action SetClass(5); action SetState("ClassMenu"); } State Warrior { action SetClass(6); action SetState("ClassMenu"); }
Main { }
State StateName { }
Creating actions is actually the easiest of them all. You only have to edit two files. First file to edit is the Character::PerformQuestActions function in character.cpp. Where you see all the "else if (...)"'s is where you need to add your new code.
else if (action->name.compare("actionname") == 0) { //Code what that action should do when called }
The next thing you have to do is tell the server that the action name is valid when it loads the quest. Which is in quest.cpp. It is around line 241 to 271; you have a bunch of "else if" statements that include the action names.
else if (action->name.compare("actionname") == 0 && action->args.size() != RequiredParameters) SyntaxError("actionname requires RequiredParameters parameters");
Rules are a bit more difficult to add, since I haven't came up with a function that can do it all :(. So to add a function, first you must think of where it should check it it's true. GotItems/LostItems is checked in AddItem/DelItem. KilledNpcs is checked in Damage. KilledPlayers in checked in AttackPK. You get the point. Once you have figured out where, you can add this code and edit where necessary.
Quest *temp_quest = 0; State *state = 0; UTIL_PTR_LIST_FOREACH(this->quests, Character_Quest, quest) { temp_quest = this->world->GetQuest(quest->id); if (!temp_quest) continue; state = temp_quest->GetState(quest->state); if (!state) continue; UTIL_PTR_VECTOR_FOREACH(state->rules, Rule, rule) { if (rule->name.compare("rulename") == 0 && ((int)(*rule->args[parameter_id])) == whatever_it_should_be && ((int)(*rule->args[parameter_id])) == whatever_it_should_be) { quest->state = rule->goto_state; this->PerformQuestActions(quest->id); break; } } }
If you want to add more than one check in the same place, place parantheses around the first rule to the last argument check and add a || and 1 more set of parantheses. Inside the parantheses add the same thing in first one but with different parameters and rulename. If you don't understand what I mean, check EnterMap & LeaveMap for an example
The next thing you have to do is tell the server that the rule name is valid when it loads the quest. Which is in quest.cpp. It is around line 317 to 336; you have a bunch of "else if" statements that include the rule names.
else if (rule->name.compare("rulename") == 0 && rule->args.size() != RequiredParameters) SyntaxError("rulename requires RequiredParameters parameter");