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

Comparing deliantra/maps/perl/follow.ext (file contents):
Revision 1.7 by root, Tue Feb 7 01:03:44 2006 UTC vs.
Revision 1.10 by root, Thu Feb 9 01:15:25 2006 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines