ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/ext/NPC_Dialogue.pm
(Generate patch)

Comparing deliantra/server/ext/NPC_Dialogue.pm (file contents):
Revision 1.16 by root, Mon Oct 26 02:48:02 2009 UTC vs.
Revision 1.20 by root, Fri Mar 19 21:40:39 2010 UTC

96 96
97=item $flag - A hashref that stores flags associated with the player and 97=item $flag - A hashref that stores flags associated with the player and
98can be seen by all NPCs (so better name your flags uniquely). This is 98can be seen by all NPCs (so better name your flags uniquely). This is
99useful for storing e.g. quest information. See C<@setflag> and C<@ifflag>. 99useful for storing e.g. quest information. See C<@setflag> and C<@ifflag>.
100 100
101=item @find - see @find, below. 101=item $find - see @find, below.
102 102
103=back 103=back
104 104
105The environment is that standard "map scripting environment", which is 105The environment is that standard "map scripting environment", which is
106limited in the type of constructs allowed (no loops, for example). 106limited in the type of constructs allowed (no loops, for example).
156If the check fails, the match is skipped. 156If the check fails, the match is skipped.
157 157
158=item @find match expression 158=item @find match expression
159 159
160Like C<@check> in that it executes a match expression, but instead of 160Like C<@check> in that it executes a match expression, but instead of
161failing, it gathers all objects matched into the C<@find> array variable. 161failing, it gathers all objects into an array and provides a reference to
162the array in the C<$find> variable.
162 163
163When you want to skip the match when no objects have been found, combine 164When you want to skip the match when no objects have been found, combine
164C<@find> with C<@cond>: 165C<@find> with C<@cond>:
165 166
166 @match see my spellbook 167 @match see my spellbook
167 @find type=SPELLBOOK in inv 168 @find type=SPELLBOOK in inv
168 @cond @find 169 @cond @$find
169 It looks dirty. 170 It looks dirty.
170 @match see my spellbook 171 @match see my spellbook
171 I can't see any, where do you have it? 172 I can't see any, where do you have it?
172 173
173=item @setstate state value 174=item @setstate state value
181See C<@ifstate> for an example. 182See C<@ifstate> for an example.
182 183
183=item @ifstate state value 184=item @ifstate state value
184 185
185Requires that the named C<state> has the given C<value>, otherwise this 186Requires that the named C<state> has the given C<value>, otherwise this
186topic is skipped. For more complex comparisons, see C<@cond> with 187topic is skipped. For more complex comparisons, see C<@cond> with
187C<$state>. Example: 188C<$state>. Example:
188 189
189 @match quest 190 @match quest
190 @setstate question quest 191 @setstate question quest
191 Do you really want to help find the magic amulet of Beeblebrox? 192 Do you really want to help find the magic amulet of Beeblebrox?
291 npc => $self->{npc}, 292 npc => $self->{npc},
292 state => $state, 293 state => $state,
293 flag => $flag, 294 flag => $flag,
294 msg => $msg, 295 msg => $msg,
295 match => \@match, 296 match => \@match,
297 find => \@find,
296 ); 298 );
297 299
298 local $self->{ob}{record_replies} = \@replies; 300 local $self->{ob}{record_replies} = \@replies;
299 301
300 # now execute @-commands (which can result in a no-match) 302 # now execute @-commands (which can result in a no-match)
339 } elsif ($cmd eq "msg") { 341 } elsif ($cmd eq "msg") {
340 push @replies, [$self->{npc}, (scalar cf::safe_eval $args, %vars)]; 342 push @replies, [$self->{npc}, (scalar cf::safe_eval $args, %vars)];
341 343
342 } elsif ($cmd eq "setflag") { 344 } elsif ($cmd eq "setflag") {
343 my ($name, $value) = split /\s+/, $args, 2; 345 my ($name, $value) = split /\s+/, $args, 2;
344 $value ? $flag->{$name} = $value 346 defined $value ? $flag->{$name} = $value
345 : delete $flag->{$name}; 347 : delete $flag->{$name};
346 348
347 } elsif ($cmd eq "setstate") { 349 } elsif ($cmd eq "setstate") {
348 my ($name, $value) = split /\s+/, $args, 2; 350 my ($name, $value) = split /\s+/, $args, 2;
349 $value ? $state->{$name} = $value 351 defined $value ? $state->{$name} = $value
350 : delete $state->{$name}; 352 : delete $state->{$name};
351 353
352 } elsif ($cmd eq "ifflag") { 354 } elsif ($cmd eq "ifflag") {
353 my ($name, $value) = split /\s+/, $args, 2; 355 my ($name, $value) = split /\s+/, $args, 2;
354 $flag->{$name} eq $value 356 defined $value ? $flag->{$name} eq $value
357 : $flag->{$name}
355 or next topic; 358 or next topic;
356 359
357 } elsif ($cmd eq "ifstate") { 360 } elsif ($cmd eq "ifstate") {
358 my ($name, $value) = split /\s+/, $args, 2; 361 my ($name, $value) = split /\s+/, $args, 2;
359 $state->{$name} eq $value 362 defined $value ? $state->{$name} eq $value
363 : $state->{$name}
360 or next topic; 364 or next topic;
361 365
362 } elsif ($cmd eq "trigger") { 366 } elsif ($cmd eq "trigger") {
363 my ($con, $state) = split /\s+/, $args, 2; 367 my ($con, $state) = split /\s+/, $args, 2;
364 368

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines