[Crossfire-wiki] [Crossfire DokuWiki] page changed: cfdialog
no-reply_wiki at metalforge.org
no-reply_wiki at metalforge.org
Thu Nov 13 21:13:33 CST 2008
A page in your DokuWiki was added or changed. Here are the details:
Date : 2008/11/13 21:13
User :
Edit Summary: Document CFDialog derivative script npc_dialog.py and in-game examples.
@@ -1,15 +1,15 @@
====== CFDialog Helper Classes ======
- ==== What is this about ? ====
+ ===== What is this about ? =====
+
This is a small set of [[cfpython|Python]] utility classes, to help you creating
complex dialogs. It is made for those who do not want to
bother about complex programming, but just want to make a few
dialogs that are better than the @match system used in the
server.
-
- ==== How to use this. ====
+ ===== How to use this. =====
First, you need to import DialogRule and Dialog classes. Add the
following line at the beginning of your script:
@@ -37,9 +37,9 @@
Typically, the "one who triggers" will be the player, and the "one who answers" is an NPC the player was taking to. You are free to chose whatever you want for the dialog name, as long as it contains no space or special characters, and is not used by another dialog. You can then add the rules you created to the dialog. Rules are parsed in a given order, so you must add the most generic answer last.
Like the @match system, CFDialog converts both match strings and the things the player says to lowercase before checking for a match.
- ==== A simple example ====
+ ===== A simple example =====
I want to create a dialog for an old man. If I say "hello" or "hi" for the first time, grandpa will greet me. If I say it for the second time, he'll grumble (because he's like that, you know :)). I also need a generic answer if I say whatever else.
To illustrate the setup and use of this plugin, a previously inanimate NPC in Goths Tavern will be modified. The order of the following steps is not important, but they will take you through every step required to get an NPC that uses the plugin.
@@ -121,4 +121,82 @@
* The conversation state is stored in your player file. For example:
$ grep -ri test_grandpa var
var/crossfire/players/Player/Player.pl:dialog_test_grandpa_01 hello:1
+
+ ====== Derivative CFDialog Scripts ======
+
+ CFDialog Helper Classes provide basic functionality that can be used in scripts. Some CFDialog derivatives are:
+
+ =====NPC Dialog=====
+
+ This is a simple script that make use of CFDialog.py and receives parameters from a [[http://www.json.org/|JSON]] inside the event message. Alternatively, the JSON parameters, if >= 4096 characters, can be stored in a separate file. Use the 'name' script parameter to specify relative location to the dialog file.
+
+ ====Map Example====
+
+ An example of a map file entry is:
+
+ arch guildmaster
+ name Sigmund
+ msg
+
+ endmsg
+ x 11
+ y 7
+ resist_physical 100
+ resist_magic 100
+ weight 50000000
+ friendly 1
+ stand_still 1
+ arch event_say
+ name start/sigmund.msg
+ title Python
+ slaying /python/misc/npc_dialog.py
+ end
+ end
+
+ ====Dialog Example====
+
+ An example of a JSON dialog similar to the one described [[cfdialog#A simple example|above]] is:
+
+ {
+ "location" : "test_grandpa_01",
+ "rules": [
+ {
+ "match" : "hello|hi",
+ "pre" : [["hello","0"]],
+ "post" : [["hello","1"]],
+ "msg" : ["Hello, lad!","Hi, young fellow!","Howdy!"]
+ },
+ {
+ "match": "hello|hi",
+ "pre" :[["hello","1"]],
+ "post" :[["hello", "*"]],
+ "msg" : ["I've heard, you know, I'm not deaf *grmbl*"]
+ },
+ {
+ "match" : "*",
+ "pre" : [["hello","*"]],
+ "post" : [["hello", "*"]],
+ "msg" : ["What ?", "Huh ?", "What do you want ?"]
+ }
+ ]}
+
+ **match** is what CFDialog describes as a //keyword//, and corresponds with what the player/character says that the dialog will respond to.
+
+ **pre** is a list of CFDialog //preconditions// that identifies flags that must be set to a particular value in order to trigger a response if a match is detected.
+
+ **post** is a list of CFDialog //postconditions// that specify flags that are to be set if a response is triggered.
+
+ Above, the first rule is applied if the player/character says ''hello'' or ''hi'' and if the __//hello//__ flag is set to __//0//__ (default). When the rule is applied, the __//hello//__ flag is then set to __//1//__.
+
+ The double square braces <nowiki>([[]])</nowiki> around **pre** and **post** are required. **pre** and **post** are arrays of arrays. Each item in **pre** and **post** is an array of [variable,value].
+
+ **msg** defines one or more responses that will be given if the rule triggers. When more than one **msg** value is set up, the NPC randomly selects which one to say each time the rule is applied.
+
+ ====Related Resources====
+
+ * [[http://crossfire.svn.sourceforge.net/viewvc/crossfire/maps/trunk/python/misc/npc_dialog.py?view=log|npc_dialog.py]] in SVN.
+ * Some actual in-game dialogs supported by npc_dialog.py are:
+ - Mork and Gork mini-quest in Scorn
+ - Sigmund in Newbies House
+
IP-Address : 68.88.122.208
Old Revision: http://wiki.metalforge.net/doku.php/cfdialog?rev=1226628630
New Revision: http://wiki.metalforge.net/doku.php/cfdialog
--
This mail was generated by DokuWiki at
http://wiki.metalforge.net/
More information about the crossfire-wiki
mailing list