… | |
… | |
5 | cf::register_command goto => sub { |
5 | cf::register_command goto => sub { |
6 | my ($ob, $arg) = @_; |
6 | my ($ob, $arg) = @_; |
7 | |
7 | |
8 | return unless $ob->may ("command_goto"); |
8 | return unless $ob->may ("command_goto"); |
9 | |
9 | |
10 | my $portal = cf::object::new "exit"; |
10 | my ($path, $x, $y) = split /\s+/, $arg, 3; |
11 | |
11 | |
12 | $portal->slaying ($arg); |
12 | $ob->goto ($path, $x, $y); |
13 | $portal->stats->hp (0); |
|
|
14 | $portal->stats->sp (0); |
|
|
15 | |
13 | |
16 | $portal->apply ($ob); |
14 | 1 |
|
|
15 | }; |
17 | |
16 | |
18 | $portal->destroy; |
17 | cf::register_command teleport => sub { |
|
|
18 | my ($ob, $arg) = @_; |
|
|
19 | |
|
|
20 | return unless $ob->may ("command_teleport"); |
|
|
21 | |
|
|
22 | cf::async { |
|
|
23 | my $other = cf::player::find $arg |
|
|
24 | or return $ob->reply (undef, "$arg: no such player."); |
|
|
25 | |
|
|
26 | $ob->goto ($other->maplevel, $other->ob->x, $other->ob->y); |
|
|
27 | }; |
19 | |
28 | |
20 | 1 |
29 | 1 |
21 | }; |
30 | }; |
22 | |
31 | |
23 | cf::register_command wizpass => sub { |
32 | cf::register_command wizpass => sub { |
… | |
… | |
73 | |
82 | |
74 | return unless $ob->may ("command_reset"); |
83 | return unless $ob->may ("command_reset"); |
75 | |
84 | |
76 | my $map = $ob->map; |
85 | my $map = $ob->map; |
77 | |
86 | |
78 | cf::sync_job { |
|
|
79 | my @pl = $map->players; |
87 | my @pl = $map->players; |
|
|
88 | $_->enter_link for @pl; |
|
|
89 | cf::async { |
|
|
90 | my $name = $map->visible_name; |
80 | |
91 | |
81 | $_->enter_link for @pl; |
|
|
82 | $map->reset; |
92 | $map->reset; |
83 | $_->leave_link for @pl; |
93 | $_->leave_link for @pl; |
|
|
94 | |
|
|
95 | $ob->reply (undef, "$name was reset."); |
84 | }; |
96 | }; |
85 | |
|
|
86 | $ob->reply (undef, $map->{path}->as_string . " was reset."); |
|
|
87 | |
97 | |
88 | 1 |
98 | 1 |
89 | }; |
99 | }; |
90 | |
100 | |
91 | for my $command (qw(teleport summon arrest kick banish)) { |
101 | for my $command (qw(summon arrest kick banish)) { |
92 | my $method = "command_$command"; |
102 | my $method = "command_$command"; |
93 | |
103 | |
94 | cf::register_command $command => sub { |
104 | cf::register_command $command => sub { |
95 | my ($ob, $arg) = @_; |
105 | my ($ob, $arg) = @_; |
96 | |
106 | |