| 1 |
/* |
| 2 |
$Id$ |
| 3 |
|
| 4 |
Copyright (C) 1999/2000/2001/2002 Kai Sterker <[email protected]> |
| 5 |
Part of the Adonthell Project http://adonthell.linuxgames.com |
| 6 |
|
| 7 |
This program is free software; you can redistribute it and/or modify |
| 8 |
it under the terms of the GNU General Public License. |
| 9 |
This program is distributed in the hope that it will be useful, |
| 10 |
but WITHOUT ANY WARRANTY. |
| 11 |
|
| 12 |
See the COPYING file for more details. |
| 13 |
*/ |
| 14 |
|
| 15 |
|
| 16 |
/*! \mainpage The Adonthell Dialogue Editor |
| 17 |
|
| 18 |
This document is a part of the Adonthell Developer's Reference. It |
| 19 |
describes the usage of the dialogue editor (<tt>dlgedit</tt>) and |
| 20 |
gives a few hints for writing well designed dialogues. |
| 21 |
|
| 22 |
<h2>Contents</h2> |
| 23 |
|
| 24 |
-# \ref page1 |
| 25 |
-# \ref page2 |
| 26 |
-# \ref sec21 |
| 27 |
-# \ref sec22 |
| 28 |
-# \ref sec23 |
| 29 |
-# \ref page3 |
| 30 |
-# \ref sec30 |
| 31 |
-# \ref sec31 |
| 32 |
-# \ref sec32 |
| 33 |
-# \ref sec33 |
| 34 |
-# \ref sec34 |
| 35 |
-# \ref page4 |
| 36 |
-# \ref sec41 |
| 37 |
-# \ref sec42 |
| 38 |
-# \ref sec43 |
| 39 |
-# \ref page5 |
| 40 |
|
| 41 |
*/ |
| 42 |
|
| 43 |
/*! \page page1 Understanding the Dialogue Engine |
| 44 |
|
| 45 |
Before we start designing our first dialogues, lets have a look |
| 46 |
behind the concept of the dialogue engine. Understanding the |
| 47 |
basics will allow you to use the editor more efficiently and |
| 48 |
prevent you from trying to accomplish the impossible. |
| 49 |
|
| 50 |
First of all, what exactly is a dialogue? In our case, a |
| 51 |
dialogue is the conversation between the player and at least |
| 52 |
one NPC. The NPCs speech is usually followed by a number of |
| 53 |
replies for the player to chose from. The NPC will then |
| 54 |
react according to the choice. After that it is the player's |
| 55 |
turn again, and so on. |
| 56 |
|
| 57 |
Apart from player and NPC there is a third entity: the Narrator. |
| 58 |
Technically, it behaves like a NPC, but it has a completely |
| 59 |
different role. Usually it will decribe matters that are of |
| 60 |
importance to the player, but cannot be depicted by the game |
| 61 |
engine. |
| 62 |
|
| 63 |
Now that we've seen who may take part in a dialogue, we'll |
| 64 |
have a look at its organization. It will usually start with |
| 65 |
NPC or Narrator speech, to give the player something to react |
| 66 |
to. However, there is no need for a player reaction. Instead, |
| 67 |
the Narrator and various NPCs could go on and on (in which case |
| 68 |
the dialogue would either degenerate into a monologue or into a |
| 69 |
conversation between different NPCs). |
| 70 |
|
| 71 |
Player speech however will \b always be followed by either |
| 72 |
NPC or Narrator text, unless it ends the dialogue. |
| 73 |
|
| 74 |
Dialogues following the scheme above will remain rather |
| 75 |
static. The player may chose from a list of replies whenever |
| 76 |
it is his turn, but other than that everything remains the |
| 77 |
same in all circumstances. Therefore, the dialogue engine |
| 78 |
provides a few mechanisms to make dialogues more dynamic |
| 79 |
and adaptive to different situations. |
| 80 |
|
| 81 |
For one, NPCs and Narrator can have choises too. Whenever they |
| 82 |
have several options, they will randomly pick one. That may |
| 83 |
liven up the dialogue somewhat, but it also means a total |
| 84 |
loss of control. Therefore, each choice can be combined with |
| 85 |
a condition. Player, NPC and Narrator will only be able to |
| 86 |
chose those alternatives whose conditions evaluated true. As |
| 87 |
practically every aspect of gameworld and characters can be |
| 88 |
queried in a condition, it is possible to create dialogues |
| 89 |
that can adapt to many different situations. |
| 90 |
|
| 91 |
Such dialogues require lots of writing, of course. Therefore, |
| 92 |
<tt>dlgedit</tt>'s main aim is assisting you with the complex |
| 93 |
structure of dialogues, so you can fully concentrate on the |
| 94 |
actual writing. As it tries to get as little in the way as |
| 95 |
possible, its usage is not always intuitive. However, the |
| 96 |
brief tutorial that follows should make you comfortable with |
| 97 |
most of its controls. |
| 98 |
|
| 99 |
\htmlonly |
| 100 |
<hr> |
| 101 |
<center> |
| 102 |
<< <a href="index.html">Main Page</a> |
| 103 |
<a href="index.html">Contents</a> |
| 104 |
<a href="page2.html">An Example</a> >> |
| 105 |
</center> |
| 106 |
\endhtmlonly |
| 107 |
|
| 108 |
*/ |
| 109 |
|
| 110 |
/*! \page page2 An Example |
| 111 |
|
| 112 |
After the theory, something more practical now. |
| 113 |
|
| 114 |
\subsection sec21 The Dialogue |
| 115 |
|
| 116 |
This is a very simplistic Dialogue we want to model, but |
| 117 |
you will see that it is sufficient to demonstrate the basic |
| 118 |
functionality of the Dialogue Editor. |
| 119 |
|
| 120 |
\verbatim |
| 121 |
Npc: "Hello, I am Eric." |
| 122 |
Player: "I am Kai." or "Goodbye!" |
| 123 |
Npc: "Nice to meet you." "Fare well." |
| 124 |
Player: "Goodbye!" |
| 125 |
Npc: "Fare well." |
| 126 |
\endverbatim |
| 127 |
|
| 128 |
\subsection sec22 Creating the Dialogue |
| 129 |
|
| 130 |
Dialogues start with a NPC line, so that is what we add first. |
| 131 |
Simply left-click on the dialogue area of the Editor. A |
| 132 |
dialog window pops up that allows you to enter the text of the |
| 133 |
node. As you see, NPC is the default, so simply enter the |
| 134 |
line of dialogue (<i>"Hello, I am Eric."</i>) and press OK. |
| 135 |
What you will see when moving the cursor over the newly created |
| 136 |
node is the following: |
| 137 |
|
| 138 |
<center> |
| 139 |
\image latex step1.eps |
| 140 |
\image html step1.png |
| 141 |
</center> |
| 142 |
|
| 143 |
Now we add the player's response. To do this, left-click on |
| 144 |
the circle. It will appear in red to signal that it is the |
| 145 |
selected node. Now left-click on a location a bit further |
| 146 |
down. Again the Text Input Window pops up, this time with |
| 147 |
Player preselected, just as we want it. Enter the text |
| 148 |
(<i>"I am Kai."</i>) and press OK. |
| 149 |
|
| 150 |
<center> |
| 151 |
\image latex step2.eps |
| 152 |
\image html step2.png |
| 153 |
</center> |
| 154 |
|
| 155 |
Your screen should look like this. The NPC node is still |
| 156 |
selected, therefore drawn red, and the Player node is drawn |
| 157 |
blue, to distinguish it from NPC nodes. The arrow between |
| 158 |
them symbolises the flow of the dialogue . |
| 159 |
|
| 160 |
Since the player shall have two possible responses, we have |
| 161 |
to create another Player node, somewhere next to the first |
| 162 |
one. (<i>"Goodbye!"</i>) Voila, the first two lines of dialogue |
| 163 |
are already done. |
| 164 |
Now right-click on an empty spot to deselect the NPC |
| 165 |
node and then select the first Player node. You see that |
| 166 |
it appears orange, so you know at the first glance that |
| 167 |
it is a selected Player node. Left-click somewhere below |
| 168 |
it, enter the appropriate text (<i>"Nice to meet you."</i>), |
| 169 |
confirm with OK and repeat the same for the second Player node. |
| 170 |
(<i>"Fare well."</i>) |
| 171 |
|
| 172 |
<center> |
| 173 |
\image latex step3.eps |
| 174 |
\image html step3.png |
| 175 |
</center> |
| 176 |
|
| 177 |
If your display shows something similar, you've done it :-). |
| 178 |
Now lines 4 and 5 of the Dialogue have to follow, but, as |
| 179 |
you have already noticed, they are just the same as a part |
| 180 |
of the existing dialogue. Would be nice if we could reuse |
| 181 |
that part, eh? Well, we can. All we need to do is linking |
| 182 |
the right nodes. |
| 183 |
|
| 184 |
Okay, lets dot it: Deselect the Player node and select the |
| 185 |
bottom left NPC node (or the node correspondenting to that |
| 186 |
one in your work). Then simply left-click on the Player node |
| 187 |
that needs to follow. And this is the complete dialogue: |
| 188 |
|
| 189 |
<center> |
| 190 |
\image latex step4.eps |
| 191 |
\image html step4.png |
| 192 |
</center> |
| 193 |
|
| 194 |
Of course this is a most minimalistic example, and there |
| 195 |
are many advanced techniques yet to be explored, like |
| 196 |
\ref page4 to your dialogue. But at least you should have |
| 197 |
learned how to operate the program. For detailed descriptions |
| 198 |
of the remaining features refer to the following chapters. |
| 199 |
|
| 200 |
\subsection sec23 The Result |
| 201 |
|
| 202 |
Now save (<tt>File->Save</tt>) and compile (<tt>Dialogue->Compile</tt>) |
| 203 |
the dialogue. You'll get a .py file, the Python dialogue script. |
| 204 |
In our example it will look similar to the following: |
| 205 |
|
| 206 |
\verbatim |
| 207 |
import dialogue |
| 208 |
# -- pygettext support |
| 209 |
def _(message): return message |
| 210 |
|
| 211 |
class untitled (dialogue.base): |
| 212 |
text = [None,\ |
| 213 |
_("Hello, I am Eric."),\ |
| 214 |
_("I am Kai."),\ |
| 215 |
_("Goodbye!"),\ |
| 216 |
_("Nice to meet you."),\ |
| 217 |
_("Fare well.")] |
| 218 |
|
| 219 |
# -- (speaker, code, ((text, operation, condition), ...)) |
| 220 |
dlg = [\ |
| 221 |
(None, -1, ((1, 0, -1), )),\ |
| 222 |
("Default", -1, ((2, 0, -1), (3, 0, -1), )),\ |
| 223 |
(None, -1, ((4, 0, -1), )),\ |
| 224 |
(None, -1, ((5, 0, -1), )),\ |
| 225 |
("Default", -1, ((3, 0, -1), )),\ |
| 226 |
("Default", -1, ())] |
| 227 |
|
| 228 |
|
| 229 |
def __init__(self, p, n): |
| 230 |
self.namespace = globals () |
| 231 |
self.the_player = p |
| 232 |
self.the_npc = n |
| 233 |
\endverbatim |
| 234 |
|
| 235 |
You see, its a lot easier to use the Dialogue Editor than |
| 236 |
writing that code by hand. Of course, if you know what you |
| 237 |
are doing, you can edit this file afterwards. But usually, |
| 238 |
you should do any editing in the editor only. (See http://www.python.org |
| 239 |
for an extensive documentation of the Python scripting language.) |
| 240 |
|
| 241 |
\htmlonly |
| 242 |
<hr> |
| 243 |
<center> |
| 244 |
<< <a href="page1.html">Understanding the Dialogue Engine</a> |
| 245 |
<a href="index.html">Contents</a> |
| 246 |
<a href="page3.html">The Dialogue Editor</a> >> |
| 247 |
</center> |
| 248 |
\endhtmlonly |
| 249 |
|
| 250 |
*/ |
| 251 |
|
| 252 |
/*! \page page3 The Dialogue Editor |
| 253 |
|
| 254 |
After above example you should be able to start designing |
| 255 |
Dialogues right away. But for your convenience, and because |
| 256 |
some of the advanced editor features are not described yet, |
| 257 |
this section contains the complete reference guide. |
| 258 |
|
| 259 |
\subsection sec30 Command line Switches |
| 260 |
|
| 261 |
Although dlgedit is a graphical editor, there are a few |
| 262 |
commandline options for convenience. |
| 263 |
|
| 264 |
\par -c |
| 265 |
<b>compile all SOURCES and exit</b><br> |
| 266 |
If the <b>-c</b> option is specified with a list of dialogue |
| 267 |
source files (recognizable by their <i>.adlg</i> suffix), |
| 268 |
these sources are turned into python dialogue scripts without |
| 269 |
invoking the graphical editor. |
| 270 |
|
| 271 |
\par -d |
| 272 |
<b>print project directory and exit</b><br> |
| 273 |
A dialogue is usually assigned to a certain project, i.e a game. |
| 274 |
The project directory tells dlgedit where to search for things |
| 275 |
like character and quest data needed to compile dialogues. |
| 276 |
|
| 277 |
\par -j project |
| 278 |
<b>specify a default project</b><br> |
| 279 |
Assigns the given project to new dialogues, or to dialogues that |
| 280 |
do not belong to a project yet. To properly compile dialogues, |
| 281 |
they usually need to belong to a project. Works in combination |
| 282 |
with the <b>-c</b> option. |
| 283 |
|
| 284 |
\par -p path |
| 285 |
<b>specify a custom project directory</b><br> |
| 286 |
If your project/game does not reside in the default project |
| 287 |
directory (which can be queried with the <b>-d</b> option), |
| 288 |
you can specify an alternative path with this option. |
| 289 |
|
| 290 |
\par -v |
| 291 |
<b>print version number and exit</b> |
| 292 |
|
| 293 |
You may specify a list of dialogue sources on the command line. |
| 294 |
Unless the <b>-c</b> switch is used, all of them will be opened |
| 295 |
in the editor. If no sources are given, it will start with a |
| 296 |
new, blank dialogue. |
| 297 |
|
| 298 |
\subsection sec31 The Main Window |
| 299 |
\anchor diaare |
| 300 |
|
| 301 |
<center> |
| 302 |
\image latex dlgedit_main.eps "The main interface" |
| 303 |
\image html dlgedit_main.png "The main interface" |
| 304 |
</center> |
| 305 |
|
| 306 |
\par 1. The Dialogue Area |
| 307 |
This is where you create the outline of the dialogue; what |
| 308 |
lines of text exist and how they are linked to each other. |
| 309 |
Most of the work is done with the mouse, but there are also |
| 310 |
a few shortcuts on the keyboard and some functionality is |
| 311 |
only available through the keyboard. |
| 312 |
|
| 313 |
\par |
| 314 |
The actions taken when a mouse- or keypress occurs depend |
| 315 |
on the current selection (none, circle, arrow) and the position |
| 316 |
of the cursor. The table below shows all possible constellations: |
| 317 |
|
| 318 |
<center> |
| 319 |
<table> |
| 320 |
<tr> |
| 321 |
<td>\b Left-click </td> |
| 322 |
<td>\e Nothing \e selected </td> |
| 323 |
<td>\e Circle \e selected </td> |
| 324 |
<td>\e Arrow \e selected </td> |
| 325 |
</tr> |
| 326 |
<tr> |
| 327 |
<td>\e on \e empty \e space </td> |
| 328 |
<td>Create new Circle </td> |
| 329 |
<td>Create new Circle \& link with selected </td> |
| 330 |
<td>-</td> |
| 331 |
</tr> |
| 332 |
<tr> |
| 333 |
<td>\e on \e Circle </td> |
| 334 |
<td>Select Circle</td> |
| 335 |
<td>Link with selected</td> |
| 336 |
<td>-</td> |
| 337 |
</tr> |
| 338 |
<tr> |
| 339 |
<td>\e on \e Arrow </td> |
| 340 |
<td>Select Arrow </td> |
| 341 |
<td>-</td> |
| 342 |
<td>-</td> |
| 343 |
</tr> |
| 344 |
\htmlonly |
| 345 |
<tr><td colspan="4"></td></tr> |
| 346 |
\endhtmlonly |
| 347 |
<tr> |
| 348 |
<td> |
| 349 |
\latexonly |
| 350 |
\hline\hline |
| 351 |
\endlatexonly |
| 352 |
\b Middle-click </td> |
| 353 |
<td>\e Nothing \e selected </td> |
| 354 |
<td>\e Circle \e selected </td> |
| 355 |
<td>\e Arrow \e selected </td> |
| 356 |
</tr> |
| 357 |
<tr> |
| 358 |
<td>\e on \e empty \e space </td> |
| 359 |
<td>-</td> |
| 360 |
<td>Edit selected Circle</td> |
| 361 |
<td>-</td> |
| 362 |
</tr> |
| 363 |
<tr> |
| 364 |
<td>\e on \e Circle </td> |
| 365 |
<td>Select \& edit Circle</td> |
| 366 |
<td>Edit selected Circle</td> |
| 367 |
<td>-</td> |
| 368 |
</tr> |
| 369 |
<tr> |
| 370 |
<td>\e on \e Arrow </td> |
| 371 |
<td>Select Arrow </td> |
| 372 |
<td>Edit selected Circle</td> |
| 373 |
<td>-</td> |
| 374 |
</tr> |
| 375 |
\htmlonly |
| 376 |
<tr><td colspan="4"></td></tr> |
| 377 |
\endhtmlonly |
| 378 |
<tr> |
| 379 |
<td> |
| 380 |
\latexonly |
| 381 |
\hline\hline |
| 382 |
\endlatexonly |
| 383 |
\b Right-click </td> |
| 384 |
<td>\e Nothing \e selected </td> |
| 385 |
<td>\e Circle \e selected </td> |
| 386 |
<td>\e Arrow \e selected </td> |
| 387 |
</tr> |
| 388 |
<tr> |
| 389 |
<td>\e on \e empty \e space </td> |
| 390 |
<td>-</td> |
| 391 |
<td>Deselect Circle </td> |
| 392 |
<td>Deselect Arrow </td> |
| 393 |
</tr> |
| 394 |
<tr> |
| 395 |
<td>\e on \e Circle </td> |
| 396 |
<td>-</td> |
| 397 |
<td>Deselect Circle</td> |
| 398 |
<td>Deselect Arrow</td> |
| 399 |
</tr> |
| 400 |
<tr> |
| 401 |
<td>\e on \e Arrow </td> |
| 402 |
<td>-</td> |
| 403 |
<td>Deselect Circle </td> |
| 404 |
<td>Deselect Arrow </td> |
| 405 |
</tr> |
| 406 |
\htmlonly |
| 407 |
<tr><td colspan="4"></td></tr> |
| 408 |
\endhtmlonly |
| 409 |
<tr> |
| 410 |
<td> |
| 411 |
\latexonly |
| 412 |
\hline\hline |
| 413 |
\endlatexonly |
| 414 |
\b Return </td> |
| 415 |
<td>\e Nothing \e selected </td> |
| 416 |
<td>\e Circle \e selected </td> |
| 417 |
<td>\e Arrow \e selected </td> |
| 418 |
</tr> |
| 419 |
<tr> |
| 420 |
<td>\e wherever </td> |
| 421 |
<td>-</td> |
| 422 |
<td>Edit Circle</td> |
| 423 |
<td>-</td> |
| 424 |
</tr> |
| 425 |
\htmlonly |
| 426 |
<tr><td colspan="4"></td></tr> |
| 427 |
\endhtmlonly |
| 428 |
<tr> |
| 429 |
<td> |
| 430 |
\latexonly |
| 431 |
\hline\hline |
| 432 |
\endlatexonly |
| 433 |
\b Del </td> |
| 434 |
<td>\e Nothing \e selected </td> |
| 435 |
<td>\e Circle \e selected </td> |
| 436 |
<td>\e Arrow \e selected </td> |
| 437 |
</tr> |
| 438 |
<tr> |
| 439 |
<td>\e wherever </td> |
| 440 |
<td>-</td> |
| 441 |
<td>Delete Circle and its Links</td> |
| 442 |
<td>Delete Arrow</td> |
| 443 |
</tr> |
| 444 |
\htmlonly |
| 445 |
<tr><td colspan="4"></td></tr> |
| 446 |
\endhtmlonly |
| 447 |
<tr> |
| 448 |
<td> |
| 449 |
\latexonly |
| 450 |
\hline\hline |
| 451 |
\endlatexonly |
| 452 |
\b Esc </td> |
| 453 |
<td>\e Nothing \e selected </td> |
| 454 |
<td>\e Circle \e selected </td> |
| 455 |
<td>\e Arrow \e selected </td> |
| 456 |
</tr> |
| 457 |
<tr> |
| 458 |
<td>\e wherever </td> |
| 459 |
<td>-</td> |
| 460 |
<td>Deselect Circle</td> |
| 461 |
<td>Deselect Arrow</td> |
| 462 |
</tr> |
| 463 |
</table> |
| 464 |
</center> |
| 465 |
|
| 466 |
\par |
| 467 |
Further key-commands are \b c, which centers the view on the |
| 468 |
selected Node if it lies in the outer 20% of the Dialogue |
| 469 |
Area, the \b Cursor \b Keys and the \b Numpad to scroll the dialogue |
| 470 |
and finally \b Tab to select the next Node (That is, the next |
| 471 |
node in the editors internal data representation, not the |
| 472 |
next node on the screen!). Moving the mouse close to the |
| 473 |
Dialogue Areas border will also scroll the dialogue, and |
| 474 |
when dragging the mouse with left button pressed, you can |
| 475 |
select multiple Circles, for example to delete all of them |
| 476 |
at once. |
| 477 |
|
| 478 |
\par 2. A Node with additional code |
| 479 |
An exclamation mark (!) inside a circle means that the node |
| 480 |
contains commands other than just a line of text. What commands |
| 481 |
that may be in detail is explained in the \ref edit "Edit Dialog" |
| 482 |
description. |
| 483 |
\anchor indlin |
| 484 |
|
| 485 |
\par 3. An indirect Link |
| 486 |
Whenever a node with indirect links is \ref selcir "selected", |
| 487 |
they are highlighted in purple. Indirect links are equivalent to |
| 488 |
a normal link between selected node and the node the indirect link |
| 489 |
points at, but to avoid arrows criss-crossing over the whole |
| 490 |
Dialogue Area, it's often better to use an indirect link. The |
| 491 |
number inside Circles tells how many indirect links they have. |
| 492 |
\note This feature is deprecated and will be removed soon. Full |
| 493 |
downwards compatibility will be remained by automatically converting |
| 494 |
indirect links when loading old dialogues. |
| 495 |
|
| 496 |
\par 4. Highlighted Node |
| 497 |
Nodes below the mousepointer appear in green to give you |
| 498 |
some feedback what action a click will start at this point. |
| 499 |
\anchor selcir |
| 500 |
|
| 501 |
\par 5. Selected Node |
| 502 |
Selected Player nodes are drawn orange, NPC nodes red. Furthermore, |
| 503 |
the \ref inspre "Instant preview" shows their text as well as that |
| 504 |
of their predecessors and followers. |
| 505 |
|
| 506 |
\par 6. Tooltip |
| 507 |
Whenever a Circle is below the mousepointer, a tooltip with |
| 508 |
its text appears to make it easier for you to find a certain |
| 509 |
position in the dialogue. |
| 510 |
\anchor prenod |
| 511 |
|
| 512 |
\par 7. Text of preceding Nodes |
| 513 |
All the different lines of text that may preceed the |
| 514 |
\ref selcir "selected circle". The colour of the entries gives |
| 515 |
some information of the type: Blue text denotes lines of the Player, |
| 516 |
black text lines of the NPC; the Narrator appears green. Somewhat dimmed |
| 517 |
lines mean that the Circles are connected by \ref indlin "indirect links". |
| 518 |
\anchor inspre |
| 519 |
|
| 520 |
\par 8. The Instant preview |
| 521 |
This shall give a first impression of what the Dialogue will |
| 522 |
look like in the game. Basically it displays the text of |
| 523 |
the selected circle, together with all preceeding and following |
| 524 |
text. With this you should be able to judge whether all the |
| 525 |
combinations of text fit well together. Furthermore, by |
| 526 |
clicking on a line of text, the attached Circle is selected, |
| 527 |
meaning you can browse through the whole dialogue. Note |
| 528 |
that additional code of Nodes won't be taken into account, |
| 529 |
so in the game, the dialogue might be slightly different. |
| 530 |
|
| 531 |
\par 9. Text of selected node |
| 532 |
Again this is colour-coded: as in the \ref diaare "Dialogue Area", |
| 533 |
orange text means a Player line, red text a NPC line and green |
| 534 |
is the Narrator. |
| 535 |
|
| 536 |
\par 10. Text following the selected node |
| 537 |
Text following the selected Node. The colours are the same |
| 538 |
as for the \ref prenod "preceding nodes". |
| 539 |
|
| 540 |
\latexonly |
| 541 |
\newpage |
| 542 |
\endlatexonly |
| 543 |
|
| 544 |
\subsection sec32 The Edit Dialog |
| 545 |
|
| 546 |
<center> |
| 547 |
\image latex dlgedit_edit.eps "The Edit dialog" |
| 548 |
\image html dlgedit_edit.png "The Edit dialog" |
| 549 |
</center> |
| 550 |
|
| 551 |
\par 1. Edit Circle's Text |
| 552 |
When you create a new Circle, you should attach some text |
| 553 |
to it. This is done on this page. Simply type the text into |
| 554 |
the entry. Player text will be displayed blue, NPC text |
| 555 |
black and Narrator text in green. You can switch between |
| 556 |
the three with the \ref radbut "radiobuttons". |
| 557 |
\anchor edit |
| 558 |
|
| 559 |
\par 2. Conditions for the Node |
| 560 |
On this page, you can specify a condition which then decides |
| 561 |
whether this line of text will be available in the game |
| 562 |
or not. In fact you may enter any valid Python code, but |
| 563 |
the result may be unpredictable; so to be on the safe side, |
| 564 |
the code you write here should be a single (but not necessarily |
| 565 |
simple) if statement, like |
| 566 |
|
| 567 |
\par |
| 568 |
\verbatim |
| 569 |
if condition_1 == 1 and (flag_1 + flag_2) <= 10: |
| 570 |
\endverbatim |
| 571 |
|
| 572 |
\par |
| 573 |
You may also use <tt>elif</tt> and <tt>else</tt> statements, |
| 574 |
but again the results might be unpredictable, unless you |
| 575 |
restrict yourself to a single <tt>if</tt> and <tt>else</tt>. |
| 576 |
\anchor variab |
| 577 |
|
| 578 |
\par 3. Set and/or change Variables |
| 579 |
Here you can enter a variety of Python code. In contrast |
| 580 |
to the Condition code, where your code decides whether text |
| 581 |
is displayed or not, this code is executed if the line of |
| 582 |
text is displayed (in case of NPC text) or selected as response |
| 583 |
(in case of Player text). Use the code you enter here to |
| 584 |
change quest objects, NPC or Player attributes, etc. See the |
| 585 |
section about additional \ref page4 "Python code" for a |
| 586 |
description. |
| 587 |
|
| 588 |
\par |
| 589 |
The green page label tells you at a glance that this Circle |
| 590 |
contains some variable code, but neither Conditions nor |
| 591 |
miscellaneous Commands. The Text-page's label will always |
| 592 |
be black, as text isn't really optional. |
| 593 |
|
| 594 |
\par 4. Actions |
| 595 |
Here are just a few shortcuts that create code as you can |
| 596 |
enter in the \ref variab "Variables Tab". Currently, only the |
| 597 |
Loop command works. When activated, the Node will not be |
| 598 |
marked as used once it appears in the conversation, and thus |
| 599 |
may occur several times. |
| 600 |
\anchor radbut |
| 601 |
|
| 602 |
\par 5. Assign text to Narrator, NPC or Player |
| 603 |
Use the Radiobuttons to assign the Circle either to the Player, |
| 604 |
the Narrator or to a NPC. The Editor tries its best to guess |
| 605 |
to whom this line of text shall belong, but as long as it |
| 606 |
can't read your thoughts, you'll have to correct it sometimes. |
| 607 |
|
| 608 |
\par 6. Set NPC |
| 609 |
You can select the NPC who shall speak here. When using default, |
| 610 |
this will be the NPC this dialogue is assigned to. In case |
| 611 |
of a conversation between multiple NPC's, you might want |
| 612 |
to chose somebody else though. Note that only those NPC's |
| 613 |
are available that are currently in the character.data file |
| 614 |
in your adonthell-data directory. Use charedit to change |
| 615 |
this file. |
| 616 |
|
| 617 |
\par 7. Set NPC's mood |
| 618 |
Here you can specify what picture of the selected NPC the |
| 619 |
player gets to see. This feature needs to be implemented |
| 620 |
yet. |
| 621 |
|
| 622 |
\par 8. Annotation |
| 623 |
Here is some room for personal notes of all kind. Since a |
| 624 |
dialogue can get quite complex, you really should add some |
| 625 |
comments, so that other people as well as you can easier |
| 626 |
understand what is going on. |
| 627 |
|
| 628 |
\latexonly |
| 629 |
\newpage |
| 630 |
\endlatexonly |
| 631 |
|
| 632 |
\subsection sec33 The Run Dialog |
| 633 |
|
| 634 |
<center> |
| 635 |
\image latex dlgedit_run.eps "The Run dialog" |
| 636 |
\image html dlgedit_run.png "The Run dialog" |
| 637 |
</center> |
| 638 |
|
| 639 |
\par 1. The conversation so far |
| 640 |
The top part of the Dialogue test window will display the |
| 641 |
conversation you had so far. As known from the Editor, Player |
| 642 |
lines are displayed blue, NPC lines black. |
| 643 |
|
| 644 |
\par 2. The current NPC line |
| 645 |
The NPC's reaction to your last speech is displayed in red. |
| 646 |
If no responses of the player are available, click on this |
| 647 |
line to continue the conversation. |
| 648 |
|
| 649 |
\par 3. Your possible responses |
| 650 |
Usually, a line of NPC text will be followed by one or more |
| 651 |
responses, the player can chose from. Simply click on the |
| 652 |
text you wish to say and the dialogue will continue. |
| 653 |
|
| 654 |
\par 4. Restart this conversation |
| 655 |
Runs the dialogue from the beginning. This will also reload |
| 656 |
the dialogue in case it has changed on disk. |
| 657 |
|
| 658 |
\par 5. Debug this dialogue |
| 659 |
Opens the debug window if it is not already open. |
| 660 |
|
| 661 |
|
| 662 |
\subsection sec34 The Debug Dialog |
| 663 |
|
| 664 |
<center> |
| 665 |
\image latex dlgedit_debug.eps "The Debug dialog" |
| 666 |
\image html dlgedit_debug.png "The Debug dialog" |
| 667 |
</center> |
| 668 |
|
| 669 |
\par 1. Display local variables |
| 670 |
This tab shows the current dialogue's local variables, if |
| 671 |
that dialogue was compiled with debugging enabled and is |
| 672 |
currently running. Local variables are only available as |
| 673 |
long as the Run window is open. Further they are reinitialised |
| 674 |
when restarting the dialogue. |
| 675 |
|
| 676 |
\par 2. Display character attributes |
| 677 |
Here you can browse through all characters (and their attributes) |
| 678 |
in the character.data file in your adonthell-data directory. |
| 679 |
Unlike local variables, character attributes remain valid |
| 680 |
as long as the dialogue editor is running. Changes made |
| 681 |
to them will survive until the end of the editing session. |
| 682 |
In a future version of dlgedit, it should be possible to |
| 683 |
revert the attribute to those of the character.data. |
| 684 |
|
| 685 |
\par 3. Display quest attributes |
| 686 |
This tab shows all quests available in the quest.data file |
| 687 |
of you adonthell-data directory. The same rules as for the |
| 688 |
character attributes apply here. |
| 689 |
|
| 690 |
\par 4. The debug tree |
| 691 |
The actual attributes are shown in a tree. Unchanged attributes |
| 692 |
are displayed black, changed ones in green and deleted ones |
| 693 |
in red colour. You can change an attributes value by leftclicking |
| 694 |
on the attribute's name. To delete an attribute, assign |
| 695 |
a value of zero to it. To add a new attribute, simply click |
| 696 |
on the parent you want to add the attribute to. |
| 697 |
|
| 698 |
\par 5. Run dialogue |
| 699 |
Click here to run the current dialogue. This opens the Run |
| 700 |
Dialogue window in case it isn't open already. |
| 701 |
|
| 702 |
\htmlonly |
| 703 |
<hr> |
| 704 |
<center> |
| 705 |
<< <a href="page2.html">An Example</a> |
| 706 |
<a href="index.html">Contents</a> |
| 707 |
<a href="page4.html">Adding Python Code</a> >> |
| 708 |
</center> |
| 709 |
\endhtmlonly |
| 710 |
|
| 711 |
*/ |
| 712 |
|
| 713 |
/*! \page page4 Adding Python Code |
| 714 |
|
| 715 |
From the \ref sec23 "tutorial" you might have seen that each dialogue |
| 716 |
gets compiled into a python class which then is fed into |
| 717 |
Adonthell's Python interpreter to execute it step by step. |
| 718 |
Given the flexibility of Python, it is only sensible to |
| 719 |
use it to achieve more than simple static dialogues. In |
| 720 |
brief, Python makes it possible to reflect the gameworld's |
| 721 |
current state in a dialogue, and also to change that state |
| 722 |
depending on the player's behaviour throughout the dialogue. |
| 723 |
As you have learned above, you can enter additional Python |
| 724 |
code at various places of the dialogue: |
| 725 |
|
| 726 |
- into the constructor and destructor of the dialogue class. |
| 727 |
- directly into the text. This code has to be enclosed in |
| 728 |
braces {} and should return a string. |
| 729 |
- as a condition that decides whether a chunk of dialogue |
| 730 |
is displayed or not, |
| 731 |
- and finally you can add code that is executed after a piece |
| 732 |
of dialogue has been displayed. |
| 733 |
|
| 734 |
This section tries to give an overview of the possibilities |
| 735 |
additional Python code offers for the conversation with |
| 736 |
NPC's. One day there'll be some document discussing the |
| 737 |
Python scripting abilities of Adonthell in general. |
| 738 |
|
| 739 |
\subsection sec41 Embedded Code |
| 740 |
|
| 741 |
The dialogue engine allows to embed a function call into |
| 742 |
a line of text and will insert whatever string this function |
| 743 |
returns in place of the function. This only works for methods |
| 744 |
defined in the custom function window (Dialogue->Functions |
| 745 |
or \b Ctrl+F). It mustn't take any arguments and should return |
| 746 |
a string. For example, the method |
| 747 |
|
| 748 |
\verbatim |
| 749 |
def hello_world (self): |
| 750 |
return "Hello world!" |
| 751 |
\endverbatim |
| 752 |
|
| 753 |
can be used in the text <i>"This will |
| 754 |
print: {hello_world}"</i> to produce <i>"This |
| 755 |
will print: Hello world!"</i>. Of course |
| 756 |
for this to make sense, such a method should return one |
| 757 |
of several strings according to the current situation. |
| 758 |
Note that this code is always evaluated whenever the line |
| 759 |
of text is displayed, no matter whether it gets selected |
| 760 |
by the player or not |
| 761 |
|
| 762 |
Apart from that, there are the <tt>\$name</tt> and |
| 763 |
<tt>\$fm{text_a/text_b}</tt> macros. <tt>\$name</tt> will |
| 764 |
be replaced with the player's name at runtime, whereas |
| 765 |
<tt>\$fm{/}</tt> will cause <i>text_a</i> to be displayed |
| 766 |
if the player is female or <i>text_b</i> in case the player is |
| 767 |
male. |
| 768 |
|
| 769 |
\subsection sec42 Local Variables |
| 770 |
|
| 771 |
For more advanced dialogues it might be necessary to define |
| 772 |
local variables. They belong to the dialogue class and are |
| 773 |
addressed as <tt>self.variable</tt>. Local variables are only |
| 774 |
accessible from within the dialogue itself and thus are only |
| 775 |
available as long as the dialogue is running. They are freed |
| 776 |
at the end of the dialogue. |
| 777 |
|
| 778 |
What for are they then? Basically they can be used to track |
| 779 |
the player's path through the dialogue. Information he may |
| 780 |
or may not have received could enable or disable additional |
| 781 |
choices at a later point in the same dialogue, but how does |
| 782 |
the dialogue engine learn about that. The solution is to |
| 783 |
use local variables. So when the player receives the special |
| 784 |
information you'd add the following variable code |
| 785 |
|
| 786 |
\verbatim |
| 787 |
self.special_info_gained = 1 |
| 788 |
\endverbatim |
| 789 |
|
| 790 |
and later on, you base the special choice on following condition: |
| 791 |
|
| 792 |
\verbatim |
| 793 |
if self.special_info_gained == 1: |
| 794 |
\endverbatim |
| 795 |
|
| 796 |
Note that you need not define a variable before you use it. |
| 797 |
Undefined variables are assumed to have the value 0, so |
| 798 |
in above example you needn't do anything about the case |
| 799 |
where the player doesn't get that special information. |
| 800 |
|
| 801 |
In many situations, it will be necessary that information |
| 802 |
survives an individual dialogue. That is where persistent |
| 803 |
variables come into play: |
| 804 |
|
| 805 |
\subsection sec43 Persistent Variables |
| 806 |
|
| 807 |
The state of the gameworld, of each NPC and the player are also |
| 808 |
accessible from a dialogue script. The full details should be |
| 809 |
discussed in a general scripting doc, but unless this has happened, |
| 810 |
here are the bits relevant for the dialogue engine. |
| 811 |
|
| 812 |
The state of the gameworld is conserved in the various quests. |
| 813 |
All quests are stored in the global <tt>data::quests</tt> dictionary. |
| 814 |
To retrieve a certain quest you'd write |
| 815 |
|
| 816 |
\verbatim |
| 817 |
myquest = adonthell.gamedata_get_quest("quest_name") |
| 818 |
\endverbatim |
| 819 |
|
| 820 |
Particular attributes of <tt>myquest</tt> are retrieved/set via |
| 821 |
|
| 822 |
\verbatim |
| 823 |
myattribute = myquest.get_val ("attribute_name") |
| 824 |
myquest.set_val ("attribute_name", <expression>) |
| 825 |
\endverbatim |
| 826 |
|
| 827 |
To save you some writing, dlgedit recognises the following shortcuts: |
| 828 |
|
| 829 |
\verbatim |
| 830 |
myattribute = quest_name.attribute_name |
| 831 |
quest_name.attribute_name = <expression> |
| 832 |
\endverbatim |
| 833 |
|
| 834 |
Characters are treated in the same way. They are retrieved with |
| 835 |
<tt>adonthell.gamedata_get_character()</tt> and their attributes |
| 836 |
are also changed via the <tt>get_val()</tt>/<tt>set_val()</tt> |
| 837 |
functions. Even the shortcuts are the same. Instead of <tt>quest_name</tt> |
| 838 |
you'll have to give the character's name, e.g. |
| 839 |
|
| 840 |
\verbatim |
| 841 |
# character names containing blanks work too! |
| 842 |
Bjarn Fingolson.attribute_name = <expression> |
| 843 |
\endverbatim |
| 844 |
|
| 845 |
As an addition, the member variable <tt>the_player</tt> always points |
| 846 |
to the player character and <tt>the_npc</tt> to the npc the dialogue |
| 847 |
is assigned to. |
| 848 |
|
| 849 |
Of course you can do more than just read or change character and quest |
| 850 |
attributes. For example, you could change an NPC's schedule, or assign |
| 851 |
a different dialogue: |
| 852 |
|
| 853 |
\verbatim |
| 854 |
# you can access any character you want ... |
| 855 |
bjarn = gamedata_get_character ("Bjarn Fingolson") |
| 856 |
|
| 857 |
# .. and completely change his behaviour |
| 858 |
bjarn.set_schedule ("new_schedule") |
| 859 |
bjarn.set_dialogue ("new_dialogue") |
| 860 |
\endverbatim |
| 861 |
|
| 862 |
In fact, you have access to almost the complete Adonthell API, so |
| 863 |
there is much more you can influence than just the characters. |
| 864 |
Take a look at the Developer Documentation for the numerous functions |
| 865 |
you have at your command. |
| 866 |
|
| 867 |
\htmlonly |
| 868 |
<hr> |
| 869 |
<center> |
| 870 |
<< <a href="page3.html">The Dialogue Editor</a> |
| 871 |
<a href="index.html">Contents</a> |
| 872 |
<a href="page5.html">A Guideline for writing Dialogues</a> >> |
| 873 |
</center> |
| 874 |
\endhtmlonly |
| 875 |
|
| 876 |
*/ |
| 877 |
|
| 878 |
|
| 879 |
/*! \page page5 A Guideline for writing Dialogues |
| 880 |
|
| 881 |
After taking a look at the technical side, it's about time |
| 882 |
to give some hints on the actual dialogue creation. Although |
| 883 |
it might take a little while to get used to the editor itself, |
| 884 |
the real difficulty lies in the writing of high-quality |
| 885 |
dialogues. What follows are mainly personal experiences |
| 886 |
not the ultimate wisdom, but for the sake of consistency |
| 887 |
you should keep these points in mind when doing dialogues |
| 888 |
for Adonthell. You shouldn't consider them as strict rules, |
| 889 |
though. If you have a good reason to break them here and |
| 890 |
there, feel free to do so. |
| 891 |
|
| 892 |
\par Describe the NPC |
| 893 |
At the beginning of the dialogue, a short description of the |
| 894 |
NPC's mood or other features that would be obvious to their |
| 895 |
counterpart but cannot be portrayed by the game engine can give the |
| 896 |
player an idea how to deal with that character. It also |
| 897 |
enables us to give each NPC an individual touch thus adding |
| 898 |
more flavour to the game world. |
| 899 |
|
| 900 |
\par Leave the thinking to the player |
| 901 |
All the information contained in a dialogue should be |
| 902 |
kept in the NPC's part, whereas the player's part should |
| 903 |
contain as little hints as possible, and no information |
| 904 |
the person in front of the screen cannot deduce from previous |
| 905 |
dialogue(s). After all, part of the fun of playing the |
| 906 |
game comes from making connections between information |
| 907 |
given by various NPC's. Therefore, a player's answer may |
| 908 |
reveal the correct result of the thinking process, but |
| 909 |
it shouldn't give any (lengthy) explanations. |
| 910 |
|
| 911 |
\par Avoid single choices |
| 912 |
A single choice is no choice and rather boring. The reason for |
| 913 |
writing dlgedit is exactly this point. Adonthell is no self-running |
| 914 |
demo, but an interactive game, and interactivity requires that |
| 915 |
the player can choose from different alternatives. That |
| 916 |
doesn't mean that you can't have lengthy monologues of |
| 917 |
the NPC. However, if there is only one choice for the |
| 918 |
player, you might as well leave it away and let the NPC |
| 919 |
go on without interruption. |
| 920 |
|
| 921 |
\par Keep the player's text neutral |
| 922 |
Bear in mind that different players will have different |
| 923 |
feelings in the same situation. And unless you don't give |
| 924 |
the player the chance to chose an answer that comes close |
| 925 |
to his or her own personality, you should try to leave |
| 926 |
(strong) feelings away. Of course, depending on the underlying |
| 927 |
role playing system, you might present players with choices |
| 928 |
according to their alignment or behaviour in previous |
| 929 |
situations. |
| 930 |
|
| 931 |
\par Keep the text short |
| 932 |
Since there is only limited space in the game's dialogue window, |
| 933 |
you should limit the amount of text displayed a time. NPC |
| 934 |
text should fit entirely into the window, meaning it should |
| 935 |
not exceed 4 lines in the \ref sec32 "edit dialog". Longer text |
| 936 |
can be distributed over several nodes. Player text should |
| 937 |
take a single line, 2 at most, so that several choices |
| 938 |
fit into the dialogue window. |
| 939 |
|
| 940 |
\htmlonly |
| 941 |
<hr> |
| 942 |
<center> |
| 943 |
<< <a href="page4.html">Adding Python Code</a> |
| 944 |
<a href="index.html">Contents</a> |
| 945 |
</center> |
| 946 |
\endhtmlonly |
| 947 |
|
| 948 |
*/ |
| 949 |
|