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.1 by root, Fri Feb 3 21:22:53 2006 UTC vs.
Revision 1.4 by root, Sat Feb 4 05:28:41 2006 UTC

1#! perl 1#! perl
2
3# TODO: skip arena
4# TODO: check for player leaving
2 5
3# implement a 'follow' command 6# implement a 'follow' command
4 7
5my %follow; 8my %follow;
6 9
20 $who->message ("follow mode off"); 23 $who->message ("follow mode off");
21 delete $follow{$name}; 24 delete $follow{$name};
22 } 25 }
23}; 26};
24 27
28sub teleport {
29 my ($pl, $map, $x, $y) = @_;
30
31 my $portal = cf::object::new ("exit");
32
33 $portal->set_slaying ($map->path);
34 $portal->set_hp ($x);
35 $portal->set_sp ($y);
36
37 $portal->apply ($pl->ob, 0);
38
39 $portal->free;
40}
41
25sub on_clock { 42sub on_clock {
26 my ($event) = @_; 43 my ($event) = @_;
27 44
28 return unless %follow; 45 return unless %follow;
29 46
30 while (my ($name, $target) = each %follow) { 47 while (my ($name, $target) = each %follow) {
31 my ($who, $other) = (cf::player::find $name, cf::player::find $target); 48 my ($who, $other) = (cf::player::find $name, cf::player::find $target);
32 if ($who && $other) { 49 if ($who && $other) {
33 $who->ob->teleport ($other->ob->map, $other->ob->x, $other->ob->y); 50 teleport $who, $other->ob->map, $other->ob->x, $other->ob->y
51 if $who->ob->map->path ne $other->ob->map->path;
34 } else { 52 } else {
35 warn "follow: $name or $target is gone, removing from follow list\n"; 53 warn "follow: $name or $target is gone, removing from follow list\n";
36 delete $follow{$name}; 54 delete $follow{$name};
37 } 55 }
38 } 56 }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines