1 | #! perl |
1 | #! perl |
2 | |
2 | |
3 | # wizard commands |
3 | # wizard commands |
|
|
4 | |
|
|
5 | cf::register_command kick => sub { |
|
|
6 | my ($ob, $arg) = @_; |
|
|
7 | return unless $ob->flag (cf::FLAG_WIZ); |
|
|
8 | |
|
|
9 | my $other = cf::player::find_active $arg |
|
|
10 | or return 0; |
|
|
11 | $other->kick ($ob); |
|
|
12 | $ob->reply (undef, "$arg is kicked out of the game.", cf::NDI_UNIQUE | cf::NDI_ALL | cf::NDI_RED); |
|
|
13 | |
|
|
14 | 1 |
|
|
15 | }; |
4 | |
16 | |
5 | cf::register_command goto => sub { |
17 | cf::register_command goto => sub { |
6 | my ($ob, $arg) = @_; |
18 | my ($ob, $arg) = @_; |
7 | |
19 | |
8 | return unless $ob->may ("command_goto"); |
20 | return unless $ob->may ("command_goto"); |
9 | |
21 | |
10 | my $portal = cf::object::new "exit"; |
22 | my ($path, $x, $y) = split /\s+/, $arg, 3; |
11 | |
23 | |
12 | $portal->slaying ($arg); |
24 | $ob->goto ($path, $x, $y); |
13 | $portal->stats->hp (0); |
|
|
14 | $portal->stats->sp (0); |
|
|
15 | |
25 | |
16 | $portal->apply ($ob); |
26 | 1 |
|
|
27 | }; |
17 | |
28 | |
18 | $portal->destroy; |
29 | cf::register_command teleport => sub { |
|
|
30 | my ($ob, $arg) = @_; |
|
|
31 | |
|
|
32 | return unless $ob->may ("command_teleport"); |
|
|
33 | |
|
|
34 | cf::async { |
|
|
35 | my $other = cf::player::find $arg |
|
|
36 | or return $ob->reply (undef, "$arg: no such player."); |
|
|
37 | |
|
|
38 | $ob->goto ($other->maplevel, $other->ob->x, $other->ob->y); |
|
|
39 | }; |
19 | |
40 | |
20 | 1 |
41 | 1 |
21 | }; |
42 | }; |
22 | |
43 | |
23 | cf::register_command wizpass => sub { |
44 | cf::register_command wizpass => sub { |
… | |
… | |
75 | |
96 | |
76 | my $map = $ob->map; |
97 | my $map = $ob->map; |
77 | |
98 | |
78 | my @pl = $map->players; |
99 | my @pl = $map->players; |
79 | $_->enter_link for @pl; |
100 | $_->enter_link for @pl; |
80 | Coro::async { |
101 | cf::async { |
|
|
102 | my $name = $map->visible_name; |
|
|
103 | |
81 | $map->reset; |
104 | $map->reset; |
82 | $_->leave_link for @pl; |
105 | $_->leave_link for @pl; |
83 | |
106 | |
84 | $ob->reply (undef, $map->{path}->as_string . " was reset."); |
107 | $ob->reply (undef, "$name was reset."); |
85 | }; |
108 | }; |
86 | |
109 | |
87 | 1 |
110 | 1 |
88 | }; |
111 | }; |
89 | |
112 | |
90 | for my $command (qw(teleport summon arrest kick banish)) { |
113 | for my $command (qw(summon arrest banish)) { |
91 | my $method = "command_$command"; |
114 | my $method = "command_$command"; |
92 | |
115 | |
93 | cf::register_command $command => sub { |
116 | cf::register_command $command => sub { |
94 | my ($ob, $arg) = @_; |
117 | my ($ob, $arg) = @_; |
95 | |
118 | |