Writing Dialog and Quests
Simple Quests
One Line Dialog
In this example, we'll give Guard Andarry just a one line response for when a player attempts to interact with him. His spawn was created in the NPC and Monster Tutorial.
1. Load the Torque MMO Kit IDE and open the file ~\test.game\genesis\zone\zoneone\quests.py
2. First, we must create a dialog prototype:
dialog = DBDialog()
3. Then we give the dialog a unique name. This name cannot be used to name any other dialogs.
dialog.name = "Guard Andarry Dialog"
4. Next, we must add a dialog line prototype:
dialog.greeting = DBDialogLine()
5. Add his greeting which appears in the player's combat window when they interact with him:
dialog.greeting.text = "I'm too busy to talk to you!"
6. Finally, we must add this dialog to Guard Andarry's spawn. Open ~\test.game\genesis\zone\zoneone\spawns.py and remove the pound sign (#) we used to comment out his dialog in the NPC and Monster Tutorial.
7. Save the file, select World -> Compile World and verify that there are no errors in the message window.
8. Select World -> Edit Zone and load zoneone. Double-click Guard Andarry to interact with him and verify that this dialog appears in your combat window.
Short Quest
Now let's add some choices to Guard Andarry's dialog to send the player out on a short quest.
1. First, we are going to assign 2 possible actions to this quest. Add the following text to the quests.py file (above the dialog prototype) and save:
action = DBDialogAction() action.endInteraction = True action2 = DBDialogAction() action2.addTakeItem("Wolf Fang") action2.giveXP = 100 action2.giveTin = 90
The first action simple ends the conversation and closes the dialog window. The second action takes one Wolf Fang from the player and gives them 100 experience points and 100 tin pieces.
2. Now, let's create the choices that lead to these actions. Add the following text beneath the actions from above and save:
choice = DBDialogChoice(text = "Can I help with anything?") choice.successLine = DBDialogLine(text = "Bring me Wolf Fangs!") choice.successLine.addAction(action) choice2 = DBDialogChoice(text = "Hand over a Wolf Fang.") choice2.successLine = DBDialogLine(text = "\\nWonderful! I hope that solves my problem!\\n") choice2.successLine.addAction(action2)
In the first choice, we ask Guard Andarry if he needs help and he responds in our combat window, and the dialog window closes.
In the second choice we offer to give him the Wolf Fang that he requested. He replies and gives us our money and experience. Note: this choice will only show up in the dialog window as an option if the player has at least one Wolf Fang.
3. Now we need to add these choices to the dialog. To do so, the dialog choices must be after the greeting text and in the order we want them to appear in the dialog window. So, add them as follows and save:
dialog.greeting.addChoice(choice2) dialog.greeting.addChoice(choice)
Your quest dialog should look like this:
#--- Guard Andarry Dialog action = DBDialogAction() action.endInteraction = True action2 = DBDialogAction() action2.addTakeItem("Wolf Fang") action2.giveXP = 100 action2.giveTin = 90 choice2 = DBDialogChoice(text = "Hand over a Wolf Fang.") choice2.successLine = DBDialogLine(text = "\\nWonderful! I hope that solves my problem!\\n") choice2.successLine.addAction(action2) choice = DBDialogChoice(text = "Can I help with anything?") choice.successLine = DBDialogLine(text = "Bring me Wolf Fangs!") choice.successLine.addAction(action) dialog = DBDialog() dialog.name = "Guard Andarry Dialog" dialog.greeting = DBDialogLine() dialog.greeting.text = "I'm too busy to talk to you!\\n" dialog.greeting.addChoice(choice2) dialog.greeting.addChoice(choice)
4. Save the file, select World -> Compile World and verify that there are no errors in the message window.
5. Select World -> Edit Zone and load zoneone. Talk to Guard Andarry to receive your quest. Kill some wolves and return to him with their fangs to verify that the dialog is set up properly.
Note: the use of \\n inside of dialog text adds a hard return to the text, this helps with keeping paragraphs separate inside of the dialog window.
Intermediate Quests
We are going to build upon the quest created in the previous steps by adding a level requirement, journal text, and a max time limit.
1. First, we are going to add a level requirement of 10 to the quest. So we must set up the requirement by adding the following text above the action lines of the dialog:
req = DBDialogRequirement() req.requireLevel = 10
Now, we need to add the requirement to the 2 choices in the quest. This way a player cannot accept the quest and find out later that they cannot hand the items in because they are not of a high enough level. Add the following text under each of the respective choices:
choice2.addRequirement(req)
choice.addRequirement(req)
In the previous quest example, we did not have to add failLine text because if the player did not have the Wolf Fang in their inventory, they did not receive the dialog choice. Now that we have a requirement added, it is possible for the player not to be able to complete the actions assigned to those choices, so next we'll add failLine text to each of the 2 choices like this:
choice2.failLine = DBDialogLine(text = "I cannot accept that from you.") choice2.failLine.addAction(action3)
choice.failLine = DBDialogLine(text = "No, you can't!") choice.failLine.addAction(action3)
I added a new action to the above choices, so we'll create that next:
action3 = DBDialogAction() action3.endInteraction = True
You may note that action3 looks identical to action, we'll change that in the next step.
2. Now, let's add journal text so the player will remember the quest that they received.
After the player asks if they can help with anything, they should receive an update in their journal which needs to be assigned to action. Add the following text to action:
action.journalTopic = "Zone One" action.journalEntry = "Wolf Fangs" action.journalText = "Bring me Wolf Fangs!"
3. Finally, we'll add a max time limit to this quest so that the player can only hand in a total of 10 Wolf Fangs.
There are 3 components necessary to record this:
- identifier: this must be a unique name
- maxTimes: this is the maximum number of times that a player can complete this quest as noted by the identifier.
- maxBump: this is the step of the quest where the number of times a step is completed gets recorded.
So, we need to add the following text to choice2:
choice2.identifier = "Guard Andarry Dialog I" choice2.maxTimes = 10 choice2.maxBump = True
We don't want the player to be able to accept the quest again by clicking on the first choice only to find out after they bring back more Wolf Fangs that they have done this as many times as they can, so we need to add the following text to the first choice:
choice.identifier = "Guard Andarry Dialog I" choice.maxTimes = 10
Notice in the above example we removed the maxBump. Now, after a player has handed in 10 Wolf Fangs and they attempt to select the choice 'Can I help with anything?', they will receive a message stating that they have completed this the maximum number of times.
Your complete quest dialog should now look like this:
#--- Guard Andarry Dialog req = DBDialogRequirement() req.requireLevel = 10 action = DBDialogAction() action.endInteraction = True action.journalTopic = "Zone One" action.journalEntry = "Wolf Fangs" action.journalText = "Bring me Wolf Fangs!" action2 = DBDialogAction() action2.addTakeItem("Wolf Fang") action2.giveXP = 100 action2.giveTin = 90 action3 = DBDialogAction() action3.endInteraction = True choice2 = DBDialogChoice(text = "Hand over a Wolf Fang.") choice2.successLine = DBDialogLine(text = "\\nWonderful! I hope that solves my problem!\\n") choice2.successLine.addAction(action2) choice2.addRequirement(req) choice2.failLine = DBDialogLine(text = "I cannot accept that from you.") choice2.failLine.addAction(action3) choice2.identifier = "Guard Andarry Dialog I" choice2.maxTimes = 10 choice2.maxBump = True choice = DBDialogChoice(text = "Can I help with anything?") choice.successLine = DBDialogLine(text = "Bring me Wolf Fangs!") choice.successLine.addAction(action) choice.addRequirement(req) choice.failLine = DBDialogLine(text = "No, you can't!") choice.failLine.addAction(action3) choice.identifier = "Guard Andarry Dialog I" choice.maxTimes = 10 dialog = DBDialog() dialog.name = "Guard Andarry Dialog" dialog.greeting = DBDialogLine() dialog.greeting.text = "I'm too busy to talk to you!\\n" dialog.greeting.addChoice(choice2) dialog.greeting.addChoice(choice)
Note: the 2 fail lines are a bit generic sounding. The reason for this is that a choice can fail either because the player does not meet the required level or because they have completed the quest the maximum number of times already.
4. Save the file, select World -> Compile World and verify that there are no errors in the message window.
5. Select World -> Edit Zone and load zoneone. Talk to Guard Andarry to receive your quest. Kill some wolves and return to him with their fangs to verify that the dialog is set up properly.
Complex Quests
We are going to build upon the quest created in the previous steps by adding multiple journal entries, more dialog choices, and take/check/give items to prevent skipping steps in the quest.
********* this step needs to be written ********** Addition by Spartikus 9-15-08
Caveat Emptor: Please note that the following is pseudo code and I do not have a Guard andarry to test this on. It should work but really was just meant to illustrate the correct useage and syntax for the addItemRequirement and hideOnFailure mechanisms. Please test and adjust this as needed.
I'll add more of the advanced syntax as I utilize it and make sure it's functioning. For now here is a very handy method of checking if a player has an item before he is given access to a dialog choice and an optional feature of being able to completely hide the dialog unless the item is present.
Working from our example above, our requirement for turning in the wolf fang to Guard Andarry is simply our level. Now we want to make sure that the wolf fang actually exists. To do this we will add another requirement below the existing level requirment:
#--- Guard Andarry Dialog req = DBDialogRequirement() req.requireLevel = 10 req.addItemRequirement(True, "Wolf Fang", 1)
Now this may not seem like a big deal all by itself but using the optional hideOnFailure check we can have the choice not even show up for the player if they do not have the correct item in their inventory.
#--- Guard Andarry Dialog req = DBDialogRequirement() req.requireLevel = 10 req.addItemRequirement(True, "Wolf Fang", 1) req.hideOnFailure = True
And voila! Now if you do not have a Wolf Fang in your inventory you will not recieve the dialog option to turn it in. A real big help in tidying up your quest dialogs.
Next you might want to restrict the choice to only a particular class of player. This uses the addClassRequirement define. As a quick example, if you wanted only warriors to be able to turn in wolf fangs you would add this line between the additemrequirement and the hideonfailure setting:
req.addClassRequirement(True, "Warrior")
The True means that this class must be true in order to have success. In theory ( I have not tested this) by placing a False there it would exclude the warrior class from handing in the quest but allow all other classes to do so. The "Warrior" disgnation is obviously the Class that you wish to mark the quest requirement for.
Return to Tutorials

