|
package games.stendhal.server.maps.quests;
public class LookBookforCeryl implementsextends IQuestAbstractQuest {
{
public LookBookforCeryl(StendhalRPWorld w, StendhalRPRuleProcessor rules)
{
}
}
</pre>
The constructor '''ALWAYS''' has two parameters: World object and Rules object.
Then let see how to add a quest by example.
<pre>
package games.stendhal.server.maps.quests;
import games.stendhal.server.*;
import games.stendhal.server.maps.*;
import games.stendhal.server.entity.Player;
import games.stendhal.server.entity.item.Item;
import games.stendhal.server.entity.item.StackableItem;
import games.stendhal.server.entity.creature.Sheep;
import games.stendhal.server.entity.npc.Behaviours;
import games.stendhal.server.entity.npc.NPC;
import games.stendhal.server.entity.npc.SpeakerNPC;
import games.stendhal.server.pathfinder.Path;
import java.util.*;
import marauroa.common.game.IRPZone;
</pre>
Just java wording. Import whatever you need.
It is an accept good practique to import only what you really need.
<pre>
</pre>
This is mandatory! Describe the quest to your best at the top of the class so others can read it and spot bugs or test it completlycompletely. This way you ease the development of the whole game.
Many of you think content shouldn't be open source because it removed the fun of discovering. Well, we, on Arianne, don't agree with that statement, and we think that Stendhal is as fun as any other closed source code.
<pre>
public class LookBookforCeryl implements IQuest {
@Override
{
public void addToWorld() {
private StendhalRPWorld world;
super.addToWorld();
private NPCList npcs;
step1LearnAboutQuest();
public LookBookforCeryl(StendhalRPWorld w, StendhalRPRuleProcessor rules)
step2getBook();
{
this.npcs=NPCList.get step3returnBook();
this.world=w;
step_1();
step_2();
step_3();
}
</pre>
TheThis constructormethod is called by the Quest system to create the quest.
So instead of writtingwriting the quest inside thethis constructormethod we have split it in steps.
Think of your quests as a set of steps that need to be done in order for it to be completed.
<pre>
private void step_1step1LearnAboutQuest() {
{
StendhalRPZone zone=(StendhalRPZone)world.getRPZone(new IRPZone.ID("int_semos_library"));
</pre>
We need to get the zonenpc-object werepresenting are"Ceryl" goingin order to be able to work in.with it:
Ceryl lives at Library so we get library.
<pre>
</pre>
This works because in games/stendhal/server/maps/Semossemos/library/LibrarianNPC.java we have already defined Ceryl NPC.
== Creating dialoguesdialogs ==
Now we simply get it to start adding dialoguesdialogs to it.
=== Simple dialoguesdialogs ===
There two ways of adding chat to a NPC. The first and simpler one is using a named add''XXX'' method of the SpeakerNPC class.
<pre>
addGreeting("hi")
Behaviours.addQuest(npc,"I am looking for a very special #book");
</pre>
There two ways of adding chat to a NPC.
The first and simpler one is using the Behaviour class.
This class has a set of predefined triggers that you can use:
* npc.addGreeting(npc, text)<br>Replies to anyone that greet this NPC with the given text.<br>The trigger condition is ''hi'', ''hello'', ''hola''. To start any conversation with a NPC the player '''MUST''' first greet the NPC.
* npc.addGoodbye(npc, text)<br>It is what NPC writes when listen to '''bye''' or '''adios'''.
* npc.addReply(npc, trigger, text)<br>Reply the attended player with text when NPC listen the keyword trigger or a word that contains the keyword.
* npc.addQuest(npc, text)<br>Show text to player when NPC listen the keyword ''quest'' or ''task''
* npc.addJob(npc, text)<br>Show NPC job explained in text when listen the keyword ''job'' or ''work''
* npc.addHelp(npc, text)<br>When NPC listen to ''help'' or ''ayuda'' it says text.
* addSeller
* addBuyer
* addHealer<br>These three tasks are so common among our NPC that we have promoted the code to a method. Just add the items it sells or it buys or how much it charges for healing.
We use a very simple method to denote special keywords by placing a '''#''' before it.
The client renders the next word in a blue color.
=== Advanced dialoguesdialog ===
{{AddMissing|towhat = guide |toadd = the newer methods}}
----
NOTE: THE STUFF BELOW THIS LINE IS OUTDATED AND NEEDS TO BE ADJUSTED
----
The other way of creating a NPC dialogue is by adding states to the [http://en.wikipedia.org/wiki/Finite_state_machine Finite state machine] (FSM). Have a look at the link to make sure you understand the idea.
We add a hi event
addaddGreating(0, "hi", null, 1, "Welcome player!", null)
State 0 is the initial state, so once NPC is in that state and listen "hi",
|