Stendhal Quest Coding: Difference between revisions
Jump to navigation
Jump to search
Content deleted Content added
imported>Hendrik Brummermann m layout |
imported>Hendrik Brummermann Teaching the NPC to talk |
||
| Line 68: | Line 68: | ||
</source> |
</source> |
||
Of course in the case of this tutorial the two lines for BeerForHayunn are alrady there. |
|||
== Teaching the NPC to talk == |
== Teaching the NPC to talk == |
||
Okay, we have now completed the preparation. Our first task is to get Hayunn to reply to the word "quest". |
|||
* addReplay |
|||
Therefore we add a new method called prepareQuestStep() at the end of the file BeerForHayunn, just above the last closing "}". This method will |
|||
| ⚫ | |||
<source lang="java"> |
|||
public void prepareQuestStep() { |
|||
// get a reference to the Hayunn npc |
|||
SpeakerNPC npc = npcs.get("Hayunn Naratha"); |
|||
// add a reply on the trigger phrase "quest" to Hayunn |
|||
npc.addReply("quest", "My mouth is dry, but I can't be seen to abandon this teaching room!"); |
|||
} |
|||
</source> |
|||
There is one little step left before we can test it: We need to tell the server to execute our new method. There is already a method called "addToWorld" which will be executed on server start. So we add a call to our method in "addToWorld": |
|||
<source lang="java"> |
|||
@Override |
|||
public void addToWorld() { |
|||
super.addToWorld(); |
|||
prepareQuestStep(); |
|||
} |
|||
</source> |
|||
Okay, all done? Please start the server (depending on whether you are using an IDE or not you might have to compile or build first). Go to Hayunn and say "quest", after starting the conversation with "hi". He should now respond with the sentence "My mouth is dry, but I can't be seen to abandon this teaching room!". |
|||
== Trigger phrases == |
|||
* #beer |
|||
Please make sure this works before advancing to the next section of this tutorial: |
|||
| ⚫ | |||
* add with states |
* add with states |
||
| Line 86: | Line 120: | ||
* MultiAction |
* MultiAction |
||
== Further Reading |
== Further Reading == |
||
[[Category:Stendhal]] |
[[Category:Stendhal]] |
||