… | |
… | |
13 | && abs ($pl->ob->x - $x) <= 1 |
13 | && abs ($pl->ob->x - $x) <= 1 |
14 | && abs ($pl->ob->y - $y) <= 1; |
14 | && abs ($pl->ob->y - $y) <= 1; |
15 | |
15 | |
16 | my $portal = cf::object::new "exit"; |
16 | my $portal = cf::object::new "exit"; |
17 | |
17 | |
18 | $portal->set_slaying ($map); |
18 | $portal->slaying ($map); |
19 | $portal->set_hp ($x); |
19 | $portal->stats->hp ($x); |
20 | $portal->set_sp ($y); |
20 | $portal->stats->sp ($y); |
21 | |
21 | |
22 | $portal->apply ($pl->ob); |
22 | $portal->apply ($pl->ob); |
23 | |
23 | |
24 | $portal->free; |
24 | $portal->free; |
25 | } |
25 | } |
26 | |
26 | |
27 | my %follow; |
27 | my %follow; |
28 | |
28 | |
29 | my $timer = Event->timer (interval => 0.2, parked => 1, cb => sub { |
29 | my $timer = Event->timer (interval => 0.2, parked => 1, data => cf::WF_AUTOCANCEL, cb => sub { |
30 | while (my ($name, $v) = each %follow) { |
30 | while (my ($name, $v) = each %follow) { |
31 | my ($target, $his, $mine) = @$v; |
31 | my ($target, $his, $mine) = @$v; |
32 | my ($who, $other) = (cf::player::find $name, cf::player::find $target); |
32 | my ($who, $other) = (cf::player::find $name, cf::player::find $target); |
33 | |
33 | |
34 | if ($who && $other && $other->ob->map) { |
34 | if ($who && $other && $other->ob->map) { |
… | |
… | |
39 | @$his = ($map, $x, $y); |
39 | @$his = ($map, $x, $y); |
40 | } |
40 | } |
41 | |
41 | |
42 | my $map; |
42 | my $map; |
43 | |
43 | |
44 | if ($map = cf::map::map $mine->[0] |
44 | if ($map = cf::map::find $mine->[0] |
45 | and !grep $_->flag (cf::FLAG_UNIQUE) && $_->flag (cf::FLAG_IS_FLOOR), |
45 | and !grep $_->flag (cf::FLAG_UNIQUE) && $_->flag (cf::FLAG_IS_FLOOR), |
46 | $map->at ($mine->[1], $mine->[2])) { |
46 | $map->at ($mine->[1], $mine->[2])) { |
47 | teleport $who, @$mine; |
47 | teleport $who, @$mine; |
48 | } else { |
48 | } else { |
49 | delete $follow{$name}; |
49 | delete $follow{$name}; |
… | |
… | |
56 | } |
56 | } |
57 | |
57 | |
58 | $_[0]->w->stop unless keys %follow; |
58 | $_[0]->w->stop unless keys %follow; |
59 | }); |
59 | }); |
60 | |
60 | |
61 | cf::register_command follow => 0, sub { |
61 | cf::register_command follow => sub { |
62 | my ($who, $args) = @_; |
62 | my ($who, $args) = @_; |
63 | |
63 | |
64 | my $name = $who->name; |
64 | my $name = $who->name; |
65 | |
65 | |
66 | if ($args ne "" && $name ne $args) { |
66 | if ($args ne "" && $name ne $args) { |