… | |
… | |
16 | if (my $other = cf::player::find $args) { |
16 | if (my $other = cf::player::find $args) { |
17 | if ($other->ob->map->path eq $who->map->path |
17 | if ($other->ob->map->path eq $who->map->path |
18 | && abs ($other->ob->x - $who->x) <= 1 |
18 | && abs ($other->ob->x - $who->x) <= 1 |
19 | && abs ($other->ob->y - $who->y) <= 1) { |
19 | && abs ($other->ob->y - $who->y) <= 1) { |
20 | $who->message ("Following player '$args', to stop, type: 'follow"); |
20 | $who->message ("Following player '$args', to stop, type: 'follow"); |
|
|
21 | $other->ob->message ("$name is now following your every step..."); |
21 | $follow{$name} = [ |
22 | $follow{$name} = [ |
22 | $args, |
23 | $args, |
23 | [$other->ob->map->path, $other->ob->x, $other->ob->y], |
24 | [$other->ob->map->path, $other->ob->x, $other->ob->y], |
24 | [$who->map->path, $who->x, $who->y], |
25 | [$who->map->path, $who->x, $who->y], |
25 | ]; |
26 | ]; |
… | |
… | |
48 | |
49 | |
49 | $portal->set_slaying ($map); |
50 | $portal->set_slaying ($map); |
50 | $portal->set_hp ($x); |
51 | $portal->set_hp ($x); |
51 | $portal->set_sp ($y); |
52 | $portal->set_sp ($y); |
52 | |
53 | |
53 | $portal->apply ($pl->ob, 0); |
54 | $portal->apply ($pl->ob); |
54 | |
55 | |
55 | $portal->free; |
56 | $portal->free; |
56 | } |
57 | } |
57 | |
58 | |
58 | sub on_clock { |
59 | sub on_clock { |
… | |
… | |
62 | |
63 | |
63 | while (my ($name, $v) = each %follow) { |
64 | while (my ($name, $v) = each %follow) { |
64 | my ($target, $his, $mine) = @$v; |
65 | my ($target, $his, $mine) = @$v; |
65 | my ($who, $other) = (cf::player::find $name, cf::player::find $target); |
66 | my ($who, $other) = (cf::player::find $name, cf::player::find $target); |
66 | |
67 | |
67 | if ($who && $other) { |
68 | if ($who && $other && $other->ob->map) { |
68 | my ($map, $x, $y) = ($other->ob->map->path, $other->ob->x, $other->ob->y); |
69 | my ($map, $x, $y) = ($other->ob->map->path, $other->ob->x, $other->ob->y); |
69 | |
70 | |
70 | if ($map ne $his->[0] || $x != $his->[1] || $y != $his->[2]) { |
71 | if ($map ne $his->[0] || $x != $his->[1] || $y != $his->[2]) { |
71 | @$mine = @$his; |
72 | @$mine = @$his; |
72 | @$his = ($map, $x, $y); |
73 | @$his = ($map, $x, $y); |
73 | } |
74 | } |
74 | |
75 | |
75 | my $map; |
76 | my $map; |
76 | |
77 | |
77 | if ($map = cf::map::map $mine->[0] |
78 | if ($map = cf::map::map $mine->[0] |
78 | and !grep $_->flag (cf::FLAG_UNIQUE), $map->at ($mine->[1], $mine->[2])) { |
79 | and !grep $_->flag (cf::FLAG_UNIQUE) && $_->flag (cf::FLAG_IS_FLOOR), |
|
|
80 | $map->at ($mine->[1], $mine->[2])) { |
79 | teleport $who, @$mine; |
81 | teleport $who, @$mine; |
80 | } else { |
82 | } else { |
81 | delete $follow{$name}; |
83 | delete $follow{$name}; |
82 | $who->ob->message ("$target is gone where you can't follow..."); |
84 | $who->ob->message ("You can't follow $target anymore!"); |
83 | } |
85 | } |
84 | } else { |
86 | } else { |
85 | delete $follow{$name}; |
87 | delete $follow{$name}; |
86 | $who->ob->message ("$name or $target is gone..."); |
88 | $who->ob->message ("$target is gone..."); |
87 | } |
89 | } |
88 | } |
90 | } |
89 | } |
91 | } |
90 | |
92 | |
91 | |
93 | |