… | |
… | |
190 | my ($pl) = @_; |
190 | my ($pl) = @_; |
191 | |
191 | |
192 | delete $pl->{npc_dialog}; |
192 | delete $pl->{npc_dialog}; |
193 | $pl->detach ("npc_dialog_active"); |
193 | $pl->detach ("npc_dialog_active"); |
194 | }, |
194 | }, |
|
|
195 | on_map_change => sub { |
|
|
196 | my ($pl) = @_; |
|
|
197 | |
|
|
198 | my $dialog = delete $pl->{npc_dialog} |
|
|
199 | or return; |
|
|
200 | |
|
|
201 | $pl->ext_msg ($dialog->{id} => error => "out of range"); |
|
|
202 | $pl->detach ("npc_dialog_active"); |
|
|
203 | }, |
195 | on_move => sub { |
204 | on_move => sub { |
196 | my ($pl, $dir) = @_; |
205 | my ($pl, $dir) = @_; |
197 | |
206 | |
198 | # must delay a bit :/ |
207 | # must delay a bit :/ |
199 | my $delay; $delay = EV::timer 0, 0, sub { |
208 | my $delay; $delay = EV::timer 0, 0, sub { |
… | |
… | |
202 | if (my $dialog = $pl->{npc_dialog}) { |
211 | if (my $dialog = $pl->{npc_dialog}) { |
203 | my (undef, $dx, $dy) = $pl->ob->rangevector ($dialog->{npc}); |
212 | my (undef, $dx, $dy) = $pl->ob->rangevector ($dialog->{npc}); |
204 | |
213 | |
205 | return if (abs $dx) <= 2 && (abs $dy) <= 2; |
214 | return if (abs $dx) <= 2 && (abs $dy) <= 2; |
206 | |
215 | |
|
|
216 | delete $pl->{npc_dialog}; |
207 | $pl->ext_msg ($dialog->{id} => error => "out of range"); |
217 | $pl->ext_msg ($dialog->{id} => error => "out of range"); |
|
|
218 | $pl->detach ("npc_dialog_active"); |
208 | } |
219 | } |
209 | |
|
|
210 | delete $pl->{npc_dialog}; |
|
|
211 | $pl->detach ("npc_dialog_active"); |
|
|
212 | }; |
220 | }; |
213 | }, |
221 | }, |
214 | ; |
222 | ; |
215 | |
223 | |
216 | cf::player->attach ( |
224 | cf::player->attach ( |