Stendhal Quest Coding: Difference between revisions

Jump to navigation Jump to search
Content deleted Content added
imported>Kymara
finish an unfinished sentence and correct a typo. add another suggestion to teach
imported>Hendrik Brummermann
ConversationPhrases
Line 5: Line 5:
__TOC__
__TOC__


If you have ideas for new quests or are interested in helping to refine quest ideas, please have a look at the Quest [[Stendhal Quest Contribution|Contributor's Guide]] or the [[Stendhal Quest Ideas]].
If you have ideas for new quests or are interested in helping to refine quest ideas, please have a look at the [[Stendhal Quest Contribution|Quest Contributor's Guide]] or the [[Stendhal Quest Ideas]].




Line 103: Line 103:
== Trigger phrases ==
== Trigger phrases ==


Good, Hayunn now replies to the trigger "quest". He does not, however, reply to "task". All other NPCs accept both words as synonym. A simple solution would be to add a second ''npc.addReply'' line. But there is a better way which makes it very easy to add additional synonyms later. We predefined lists of commonly used [http://arianne.cvs.sf.net/viewvc/arianne/stendhal/src/games/stendhal/server/entity/npc/ConversationPhrases.java?view=markup ConversationPhrases].

If there are already conversation phrases defined for the triggers that you would like to add, you should use the phrases. Let's adjust the above sample by using ''ConversationPhrases.QUEST_MESSAGES'' instead of the hard coded word "quest":

<source lang="java">
public void prepareQuestStep() {

// get a reference to the Hayunn npc
SpeakerNPC npc = npcs.get("Hayunn Naratha");

// add a reply on quest related trigger phrases to Hayunn
npc.addReply(ConversationPhrases.QUEST_MESSAGES, "My mouth is dry, but I can't be seen to abandon this teaching room!");
}
</source>

Please compile and restart your server. Hayunn should not respond to "quest", "task", and "favor", after you started the talk by saying "hi".

{{TODO|
As you probably know NPCs can say words in blue, words that they expect to be repeated by the player.
* #beer
* #beer
}}
* using predefined trigger sets like YES_MESSAGES

Congratulations if you made it this far. You are now able to code basic dialogs with NPCs. The next section of this tutorial will describe advanced technics. Please make sure the steps on this page work before continuing to the next part.


----
Please make sure this works before advancing to the next section of this tutorial:


== Teaching the NPC to ask the players whether they will do the quest ==
== Teaching the NPC to ask the players whether they will do the quest ==