ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/cf.schmorp.de/maps/perl/follow.ext
(Generate patch)

Comparing cf.schmorp.de/maps/perl/follow.ext (file contents):
Revision 1.7 by root, Tue Feb 7 01:03:44 2006 UTC vs.
Revision 1.8 by root, Tue Feb 7 02:08:22 2006 UTC

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 ];
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);
78 and !grep $_->flag (cf::FLAG_UNIQUE) && $_->flag (cf::FLAG_IS_FLOOR), 79 and !grep $_->flag (cf::FLAG_UNIQUE) && $_->flag (cf::FLAG_IS_FLOOR),
79 $map->at ($mine->[1], $mine->[2])) { 80 $map->at ($mine->[1], $mine->[2])) {
80 teleport $who, @$mine; 81 teleport $who, @$mine;
81 } else { 82 } else {
82 delete $follow{$name}; 83 delete $follow{$name};
83 $who->ob->message ("$target is gone where you can't follow..."); 84 $who->ob->message ("You can't follow $target anymore!");
84 } 85 }
85 } else { 86 } else {
86 delete $follow{$name}; 87 delete $follow{$name};
87 $who->ob->message ("$name or $target is gone..."); 88 $who->ob->message ("$target is gone...");
88 } 89 }
89 } 90 }
90} 91}
91 92
92 93

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines