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.5 by root, Sat Jun 16 23:22:59 2007 UTC vs.
Revision 1.8 by root, Sun Aug 26 04:07:40 2007 UTC

106 106
107=back 107=back
108 108
109The environment is that standard "map scripting environment", which is 109The environment is that standard "map scripting environment", which is
110limited in the type of constructs allowed (no loops, for example). 110limited in the type of constructs allowed (no loops, for example).
111
112Here is a example:
113
114=over 4
115
116=item B<matching for an item name>
117
118 @match hi
119 @cond grep $_->name =~ /royalty/, $who->inv
120 You got royalties there! Wanna have!
121
122You may want to change the C<name> method there to something like C<title>,
123C<slaying> or any other method that is allowed to be called on a
124C<cf::object> here.
125
126=item B<matching for an item name and removing the matched item>
127
128 @match found earhorn
129 @cond grep $_->slaying =~ /Gramp's walking stick/, $who->inv
130 @eval my @g = grep { $_->slaying =~ /Gramp's walking stick/ } $who->inv; $g[0]->decrease_ob_nr (1);
131 Thanks for the earhorn!
132
133This example is a bit more complex. The C<@eval> statement will search
134the players inventory for the same term as the C<@cond> and then
135decreases the number of objects used there.
136
137(See also the map: C<scorn/houses/cornerbrook.map> for an example how this is
138used in the real world :-)
139
140=back
111 141
112=item @eval perl 142=item @eval perl
113 143
114Like C<@cond>, but proceed regardless of the outcome. 144Like C<@cond>, but proceed regardless of the outcome.
115 145
182When a state argument is given it should be either 0 or 1. 1 will 'push' the connection 212When a state argument is given it should be either 0 or 1. 1 will 'push' the connection
183and 0 will 'release' the connection. This is useful for example when you want to 213and 0 will 'release' the connection. This is useful for example when you want to
184let a npc control a door. 214let a npc control a door.
185 215
186Trigger all objects with the given connected-id by 'releasing' the connection. 216Trigger all objects with the given connected-id by 'releasing' the connection.
217
218=item @playersound face-name
219
220Plays the given sound face (either an alias or sound file path) so that
221only the player talking to the npc can hear it.
222
223=item @npcsound face-name
224
225Plays the given sound face (either an alias or sound file path) as if
226the npc had made that sound, i.e. it will be located at the npc and all
227players near enough can hear it.
187 228
188=item @addtopic topic 229=item @addtopic topic
189 230
190Adds the given topic names (separated by C<|>) to the list of topics 231Adds the given topic names (separated by C<|>) to the list of topics
191returned. 232returned.
232 @match = $msg =~ /$args/i 273 @match = $msg =~ /$args/i
233 or next topic; 274 or next topic;
234 275
235 } elsif ($cmd eq "comment") { 276 } elsif ($cmd eq "comment") {
236 # nop 277 # nop
278
279 } elsif ($cmd eq "playersound") {
280 $self->{ob}->contr->play_sound (cf::sound::find $args);
281
282 } elsif ($cmd eq "npcsound") {
283 $self->{npc}->play_sound (cf::sound::find $args);
237 284
238 } elsif ($cmd eq "cond") { 285 } elsif ($cmd eq "cond") {
239 cf::safe_eval $args, %vars 286 cf::safe_eval $args, %vars
240 or next topic; 287 or next topic;
241 288

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines