Stendhal Quest Coding - Part 2: Difference between revisions

Content deleted Content added
imported>Kymara
imported>Kymara
Line 113:
== Teaching the NPC to remember the player ==
 
Okay, lets get back to the topic: Hayunn needs a long term memory in order to only accept one bearbeer per player. After all he is on duty and a totally drunken teacher is no good...
 
The long term memory is called "quest slot". It is basically a hash table whichwith one row per quest. You might remember that the following line in the template we added at the very beginning of this tutorial:
<source lang="java">
public static final String QUEST_SLOT = "beer_hayunn";
</source>
 
That's the name of the slot we are using. It has to be unique, but other than that, we can write anything we want in there. There are, however, two conventions that make things a lot easier: Multiple values are separated by an ";" without space. And the terms "done" and "rejected" are used to denote a complete or rejected quest. There isare a number of predefined chat conditions and actions that work based on those conventions.
 
Having said that, let us make Hayunn check the quest state and reply accordingly:
Line 152:
</source>
 
Note that in caseif the quest is already completed, Hayunn staystays in ATTENINGATTENDING state.
 
The next step is to save that the quest was completed. We take a simple approach for the moment and only check that the player owns a beer: