… | |
… | |
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->hp ($x); |
20 | $portal->set_sp ($y); |
20 | $portal->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, cb => sub { |
30 | warn "follow\n";#d# |
|
|
31 | |
|
|
32 | while (my ($name, $v) = each %follow) { |
30 | while (my ($name, $v) = each %follow) { |
33 | my ($target, $his, $mine) = @$v; |
31 | my ($target, $his, $mine) = @$v; |
34 | my ($who, $other) = (cf::player::find $name, cf::player::find $target); |
32 | my ($who, $other) = (cf::player::find $name, cf::player::find $target); |
35 | |
33 | |
36 | if ($who && $other && $other->ob->map) { |
34 | if ($who && $other && $other->ob->map) { |
… | |
… | |
41 | @$his = ($map, $x, $y); |
39 | @$his = ($map, $x, $y); |
42 | } |
40 | } |
43 | |
41 | |
44 | my $map; |
42 | my $map; |
45 | |
43 | |
46 | if ($map = cf::map::map $mine->[0] |
44 | if ($map = cf::map::find $mine->[0] |
47 | and !grep $_->flag (cf::FLAG_UNIQUE) && $_->flag (cf::FLAG_IS_FLOOR), |
45 | and !grep $_->flag (cf::FLAG_UNIQUE) && $_->flag (cf::FLAG_IS_FLOOR), |
48 | $map->at ($mine->[1], $mine->[2])) { |
46 | $map->at ($mine->[1], $mine->[2])) { |
49 | teleport $who, @$mine; |
47 | teleport $who, @$mine; |
50 | } else { |
48 | } else { |
51 | delete $follow{$name}; |
49 | delete $follow{$name}; |
… | |
… | |
90 | $who->message ("follow mode off"); |
88 | $who->message ("follow mode off"); |
91 | delete $follow{$name}; |
89 | delete $follow{$name}; |
92 | } |
90 | } |
93 | }; |
91 | }; |
94 | |
92 | |
95 | sub on_player_death { |
93 | cf::attach_to_players |
|
|
94 | on_death => sub { |
96 | my ($ob) = @_; |
95 | my ($pl) = @_; |
97 | |
96 | |
98 | my $name = $ob->name; |
97 | my $name = $pl->ob->name; |
99 | |
98 | |
100 | delete $follow{$name}; |
99 | delete $follow{$name}; |
101 | |
100 | |
102 | while (my ($k, $v) = each %follow) { |
101 | while (my ($k, $v) = each %follow) { |
103 | if ($v->[0] eq $name) { |
102 | if ($v->[0] eq $name) { |
104 | delete $follow{$k}; |
103 | delete $follow{$k}; |
|
|
104 | } |
105 | } |
105 | } |
106 | } |
106 | }, |
107 | |
107 | ; |
108 | 0 |
|
|
109 | } |
|
|
110 | |
108 | |
111 | |
109 | |
112 | |
110 | |
113 | |
111 | |
114 | |
|
|