… | |
… | |
164 | |
164 | |
165 | @match hi |
165 | @match hi |
166 | @ifflag kings_quest |
166 | @ifflag kings_quest |
167 | Hi, I was told you want to do the kings quest? |
167 | Hi, I was told you want to do the kings quest? |
168 | |
168 | |
169 | =item @trigger connected-id |
169 | =item @trigger connected-id [state] |
170 | |
170 | |
171 | Trigger all objects with the given connected-id. The trigger is stateful |
171 | Trigger all objects with the given connected-id. |
172 | and retains state per connected-id. |
172 | |
|
|
173 | When the state argument is omitted the trigger is stateful and retains an |
|
|
174 | internal state per connected-id. There is a limitation to the use of this: The |
|
|
175 | state won't be changed when the connection is triggered by other triggers. So |
|
|
176 | be careful when triggering the connection from other objects. |
|
|
177 | |
|
|
178 | When a state argument is given it should be either 0 or 1. 1 will 'push' the connection |
|
|
179 | and 0 will 'release' the connection. This is useful for example when you want to |
|
|
180 | let a npc control a door. |
|
|
181 | |
|
|
182 | Trigger all objects with the given connected-id by 'releasing' the connection. |
173 | |
183 | |
174 | =item @addtopic topic |
184 | =item @addtopic topic |
175 | |
185 | |
176 | Adds the given topic names (separated by C<|>) to the list of topics |
186 | Adds the given topic names (separated by C<|>) to the list of topics |
177 | returned. |
187 | returned. |
… | |
… | |
251 | my ($name, $value) = split /\s+/, $args, 2; |
261 | my ($name, $value) = split /\s+/, $args, 2; |
252 | $state->{$name} eq $value |
262 | $state->{$name} eq $value |
253 | or next topic; |
263 | or next topic; |
254 | |
264 | |
255 | } elsif ($cmd eq "trigger") { |
265 | } elsif ($cmd eq "trigger") { |
|
|
266 | my ($con, $state) = split /\s+/, $args, 2; |
|
|
267 | $con = $con * 1; |
|
|
268 | |
|
|
269 | if (defined $state) { |
|
|
270 | $self->{npc}->map->trigger ($args, $state); |
|
|
271 | } else { |
256 | my $rvalue = \$self->{npc}{dialog_trigger}{$args*1}; |
272 | my $rvalue = \$self->{npc}{dialog_trigger}{$con}; |
257 | $self->{npc}->map->trigger ($args, $$rvalue = !$$rvalue); |
273 | $self->{npc}->map->trigger ($con, $$rvalue = !$$rvalue); |
|
|
274 | } |
258 | |
275 | |
259 | } elsif ($cmd eq "addtopic") { |
276 | } elsif ($cmd eq "addtopic") { |
260 | push @kw, split /\|/, $args; |
277 | push @kw, split /\|/, $args; |
261 | $self->{add_topic}->(split /\s*\|\s*/, $args) if $self->{add_topic}; |
278 | $self->{add_topic}->(split /\s*\|\s*/, $args) if $self->{add_topic}; |
262 | |
279 | |