Stendhal Quest Coding - Part 2: Difference between revisions
Content deleted Content added
imported>Hendrik Brummermann No edit summary |
imported>Kribbel m replace old link |
||
| (65 intermediate revisions by 6 users not shown) | |||
Line 1:
{{Navigation for Stendhal Top|Contributing}}
{{Navigation for Stendhal Contributors}}
Line 28:
[[Image:npc simple.png]]
Currently our NPC knows two states: IDLE for walking around and ATTENDING for talking to a player. You can change between states by talking to the NPC. So if the NPC is IDLE, it will accept "hi" and move on to the
So, lets return to our example. We want the NPC to reply to "yes" and "no" but only after the quest question was asked. So we add a third state called QUEST_OFFERED. When the player says "quest", the NPC goes to that state. On "yes" or "no" it returns to ATTENDING.
Line 74:
</source>
As you can see, we now have to use "add()" instead of "addReply()" and that
We have predefined a number of states in the class [
===Graphical representation===
There is one last thing that makes your life easier: If you are using Linux, have the graphviz package installed and you are an admin in game, you can select
== Conditions And Actions ==
Line 91 ⟶ 92:
new LevelLessThanCondition(6),
ConversationStates.IDLE,
"Oh sorry,
null);
</source>
Line 113 ⟶ 114:
== 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
The long term memory is called "quest slot". It is basically a hash table
<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
Having said that, let us make Hayunn check the quest state and reply accordingly:
Line 152 ⟶ 153:
</source>
Note that
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:
Line 175 ⟶ 176:
== Third Part of this Tutorial ==
Congratulations if you made it this far. You are now able to process basic conditions and actions. And you can handle both short and long term memory. The third and last part of this tutorial will explain how you accept the quest item and reward the player. It
[[Category:Stendhal]]
| |||