… | |
… | |
11 | =cut |
11 | =cut |
12 | |
12 | |
13 | package NPC_Dialogue; |
13 | package NPC_Dialogue; |
14 | |
14 | |
15 | use strict; |
15 | use strict; |
16 | |
|
|
17 | sub has_dialogue($) { |
|
|
18 | my ($ob) = @_; |
|
|
19 | |
|
|
20 | $ob->msg =~ /^\@match /; |
|
|
21 | } |
|
|
22 | |
16 | |
23 | sub parse_message($) { |
17 | sub parse_message($) { |
24 | map [split /\n/, $_, 2], |
18 | map [split /\n/, $_, 2], |
25 | grep length, |
19 | grep length, |
26 | split /^\@match /m, |
20 | split /^\@match /m, |
… | |
… | |
125 | |
119 | |
126 | =item B<matching for an item name and removing the matched item> |
120 | =item B<matching for an item name and removing the matched item> |
127 | |
121 | |
128 | @match found earhorn |
122 | @match found earhorn |
129 | @cond grep $_->slaying =~ /Gramp's walking stick/, $who->inv |
123 | @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); |
124 | @eval my @g = grep { $_->slaying =~ /Gramp's walking stick/ } $who->inv; $g[0]->decrease; |
131 | Thanks for the earhorn! |
125 | Thanks for the earhorn! |
132 | |
126 | |
133 | This example is a bit more complex. The C<@eval> statement will search |
127 | This example is a bit more complex. The C<@eval> statement will search |
134 | the players inventory for the same term as the C<@cond> and then |
128 | the players inventory for the same term as the C<@cond> and then |
135 | decreases the number of objects used there. |
129 | decreases the number of objects used there. |
… | |
… | |
212 | When a state argument is given it should be either 0 or 1. 1 will 'push' the connection |
206 | When a state argument is given it should be either 0 or 1. 1 will 'push' the connection |
213 | and 0 will 'release' the connection. This is useful for example when you want to |
207 | and 0 will 'release' the connection. This is useful for example when you want to |
214 | let a npc control a door. |
208 | let a npc control a door. |
215 | |
209 | |
216 | Trigger all objects with the given connected-id by 'releasing' the connection. |
210 | Trigger all objects with the given connected-id by 'releasing' the connection. |
|
|
211 | |
|
|
212 | =item @playersound face-name |
|
|
213 | |
|
|
214 | Plays the given sound face (either an alias or sound file path) so that |
|
|
215 | only the player talking to the npc can hear it. |
|
|
216 | |
|
|
217 | =item @npcsound face-name |
|
|
218 | |
|
|
219 | Plays the given sound face (either an alias or sound file path) as if |
|
|
220 | the npc had made that sound, i.e. it will be located at the npc and all |
|
|
221 | players near enough can hear it. |
217 | |
222 | |
218 | =item @addtopic topic |
223 | =item @addtopic topic |
219 | |
224 | |
220 | Adds the given topic names (separated by C<|>) to the list of topics |
225 | Adds the given topic names (separated by C<|>) to the list of topics |
221 | returned. |
226 | returned. |
… | |
… | |
262 | @match = $msg =~ /$args/i |
267 | @match = $msg =~ /$args/i |
263 | or next topic; |
268 | or next topic; |
264 | |
269 | |
265 | } elsif ($cmd eq "comment") { |
270 | } elsif ($cmd eq "comment") { |
266 | # nop |
271 | # nop |
|
|
272 | |
|
|
273 | } elsif ($cmd eq "playersound") { |
|
|
274 | $self->{ob}->contr->play_sound (cf::sound::find $args); |
|
|
275 | |
|
|
276 | } elsif ($cmd eq "npcsound") { |
|
|
277 | $self->{npc}->play_sound (cf::sound::find $args); |
267 | |
278 | |
268 | } elsif ($cmd eq "cond") { |
279 | } elsif ($cmd eq "cond") { |
269 | cf::safe_eval $args, %vars |
280 | cf::safe_eval $args, %vars |
270 | or next topic; |
281 | or next topic; |
271 | |
282 | |