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.8 by root, Tue Feb 7 02:08:22 2006 UTC vs.
Revision 1.16 by root, Tue Mar 28 16:08:19 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) = @_;
43 44
44 return if $pl->ob->map->path eq $map 45 return if $pl->ob->map->path eq $map
45 && abs ($pl->ob->x - $x) <= 1 46 && abs ($pl->ob->x - $x) <= 1
46 && abs ($pl->ob->y - $y) <= 1; 47 && abs ($pl->ob->y - $y) <= 1;
47 48
48 my $portal = cf::object::new ("exit"); 49 my $portal = cf::object::new "exit";
49 50
50 $portal->set_slaying ($map); 51 $portal->set_slaying ($map);
51 $portal->set_hp ($x); 52 $portal->set_hp ($x);
52 $portal->set_sp ($y); 53 $portal->set_sp ($y);
53 54
54 $portal->apply ($pl->ob, 0); 55 $portal->apply ($pl->ob);
55 56
56 $portal->free; 57 $portal->free;
57} 58}
58 59
60sub on_player_death {
61 my ($ob) = @_;
62
63 my $name = $ob->name;
64
65 delete $follow{$name};
66
67 while (my ($k, $v) = each %follow) {
68 if ($v->[0] eq $name) {
69 delete $follow{$k};
70 }
71 }
72
73 0
74}
75
59sub on_clock { 76sub on_clock {
60 my ($event) = @_;
61
62 return unless %follow; 77 return 0 unless %follow;
63 78
64 while (my ($name, $v) = each %follow) { 79 while (my ($name, $v) = each %follow) {
65 my ($target, $his, $mine) = @$v; 80 my ($target, $his, $mine) = @$v;
66 my ($who, $other) = (cf::player::find $name, cf::player::find $target); 81 my ($who, $other) = (cf::player::find $name, cf::player::find $target);
67 82

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines