… | |
… | |
201 | When the state argument is omitted the trigger is stateful and retains an |
201 | When the state argument is omitted the trigger is stateful and retains an |
202 | internal state per connected-id. There is a limitation to the use of this: The |
202 | internal state per connected-id. There is a limitation to the use of this: The |
203 | state won't be changed when the connection is triggered by other triggers. So |
203 | state won't be changed when the connection is triggered by other triggers. So |
204 | be careful when triggering the connection from other objects. |
204 | be careful when triggering the connection from other objects. |
205 | |
205 | |
206 | 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 a positive integer. Any value |
207 | and 0 will 'release' the connection. This is useful for example when you want to |
207 | C<!= 0> will 'push' the connection (in general, you should specify C<1> |
208 | let a npc control a door. |
208 | for this) and C<0> will 'release' the connection. This is useful for |
|
|
209 | example when you want to let an NPC control a door. |
209 | |
210 | |
210 | Trigger all objects with the given connected-id by 'releasing' the connection. |
211 | Trigger all objects with the given connected-id by 'releasing' the connection. |
211 | |
212 | |
212 | =item @playersound face-name |
213 | =item @playersound face-name |
213 | |
214 | |
… | |
… | |
307 | $state->{$name} eq $value |
308 | $state->{$name} eq $value |
308 | or next topic; |
309 | or next topic; |
309 | |
310 | |
310 | } elsif ($cmd eq "trigger") { |
311 | } elsif ($cmd eq "trigger") { |
311 | my ($con, $state) = split /\s+/, $args, 2; |
312 | my ($con, $state) = split /\s+/, $args, 2; |
312 | $con = $con * 1; |
|
|
313 | |
313 | |
314 | if (defined $state) { |
314 | if (defined $state) { |
315 | $self->{npc}->map->trigger ($args, $state); |
315 | $self->{npc}->map->trigger ($con, $state, $self->{npc}, $self->{ob}); |
316 | } else { |
316 | } else { |
317 | my $rvalue = \$self->{npc}{dialog_trigger}{$con}; |
317 | my $rvalue = \$self->{npc}{dialog_trigger}{$con+0}; |
318 | $self->{npc}->map->trigger ($con, $$rvalue = !$$rvalue); |
318 | $self->{npc}->map->trigger ($con, $$rvalue = !$$rvalue, $self->{npc}, $self->{ob}); |
319 | } |
319 | } |
320 | |
320 | |
321 | } elsif ($cmd eq "addtopic") { |
321 | } elsif ($cmd eq "addtopic") { |
322 | push @kw, split /\|/, $args; |
322 | push @kw, split /\|/, $args; |
323 | $self->{add_topic}->(split /\s*\|\s*/, $args) if $self->{add_topic}; |
323 | $self->{add_topic}->(split /\s*\|\s*/, $args) if $self->{add_topic}; |
… | |
… | |
345 | last; |
345 | last; |
346 | } |
346 | } |
347 | } |
347 | } |
348 | } |
348 | } |
349 | |
349 | |
|
|
350 | $self->{npc}->use_trigger ($self->{ob}) |
350 | $self->{npc}->use_trigger if $self->{npc}->type == cf::MAGIC_EAR; |
351 | if $self->{npc}->type == cf::MAGIC_EAR; |
351 | |
352 | |
352 | return wantarray ? ($reply, @kw) : $reply; |
353 | return wantarray ? ($reply, @kw) : $reply; |
353 | } |
354 | } |
354 | } |
355 | } |
355 | } |
356 | } |