Stendhal Quest Coding: Difference between revisions

Jump to navigation Jump to search
Content deleted Content added
imported>MiguelAngelBlanchLardin
No edit summary
imported>MiguelAngelBlanchLardin
No edit summary
Line 118: Line 118:
</pre>
</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:
<pre>
* 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:
* addReply(npc, trigger, text)<br>Reply the attended player with text when NPC listen the keyword trigger or a word that contains the keyword.
* addQuest(npc, text)<br>Show text to player when NPC listen the keyword ''quest'' or ''task''
* addJob(npc, text)<br>Show NPC job explained in text when listen the keyword ''job'' or ''work''
* 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 ours NPC that we havew promoted the code to a method. Just add the items it sell or it buy or how much does it charge 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 bold color.


The other way of creating a NPC dialog is by adding states to the FSM.
<pre>
/** In case Quest is completed */
/** In case Quest is completed */
npc.add(1,"book",new SpeakerNPC.ChatCondition()
npc.add(1,"book",new SpeakerNPC.ChatCondition()