… | |
… | |
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 | |
8 | my %follow; |
9 | my %follow; |
9 | |
10 | |
10 | cf::register_command follow => 0, sub { |
11 | cf::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); |
55 | $portal->apply ($pl->ob); |
55 | |
56 | |
56 | $portal->free; |
57 | $portal->free; |
|
|
58 | } |
|
|
59 | |
|
|
60 | sub on_player_death { |
|
|
61 | my ($event) = @_; |
|
|
62 | |
|
|
63 | my $ob = $event->{who}; |
|
|
64 | my $name = $ob->name; |
|
|
65 | |
|
|
66 | delete $follow->{$name}; |
|
|
67 | |
|
|
68 | while (my ($name, $v) = each %follow) { |
|
|
69 | if ($v->[0] eq $name) { |
|
|
70 | delete $follow{$name}; |
|
|
71 | } |
|
|
72 | } |
|
|
73 | |
|
|
74 | 0 |
57 | } |
75 | } |
58 | |
76 | |
59 | sub on_clock { |
77 | sub on_clock { |
60 | my ($event) = @_; |
78 | my ($event) = @_; |
61 | |
79 | |