Stendhal Quest Coding - Part 2: Difference between revisions
Jump to navigation
Jump to search
Content deleted Content added
imported>Kymara |
imported>Kymara |
||
| Line 113: | Line 113: | ||
== Teaching the NPC to remember the player == |
== 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 |
Okay, lets get back to the topic: Hayunn needs a long term memory in order to only accept one beer 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 |
The long term memory is called "quest slot". It is basically a hash table with 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"> |
<source lang="java"> |
||
public static final String QUEST_SLOT = "beer_hayunn"; |
public static final String QUEST_SLOT = "beer_hayunn"; |
||
</source> |
</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 |
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 are 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: |
Having said that, let us make Hayunn check the quest state and reply accordingly: |
||
| Line 152: | Line 152: | ||
</source> |
</source> |
||
Note that |
Note that if the quest is already completed, Hayunn stays in ATTENDING 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: |
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: |
||