1 | #! perl |
1 | #! perl # mandatory |
2 | |
2 | |
3 | # wizard commands |
3 | # wizard commands |
|
|
4 | |
|
|
5 | cf::register_command shutdown => sub { |
|
|
6 | my ($ob, $arg) = @_; |
|
|
7 | return $ob->reply (undef, "Sorry, you can't shutdown the server.") |
|
|
8 | unless $ob->flag (cf::FLAG_WIZ); |
|
|
9 | |
|
|
10 | my $name = $ob->name; |
|
|
11 | cf::cleanup ("dm '$name' initiated shutdown" . ($arg ? " with reason: $arg" : "."), 0); |
|
|
12 | |
|
|
13 | 1 |
|
|
14 | }; |
|
|
15 | |
|
|
16 | cf::register_command kick => sub { |
|
|
17 | my ($ob, $arg) = @_; |
|
|
18 | return unless $ob->flag (cf::FLAG_WIZ); |
|
|
19 | |
|
|
20 | my $other = cf::player::find_active $arg |
|
|
21 | or return 0; |
|
|
22 | $other->kick ($ob); |
|
|
23 | $ob->reply (undef, "$arg is kicked out of the game.", cf::NDI_UNIQUE | cf::NDI_ALL | cf::NDI_RED); |
|
|
24 | |
|
|
25 | 1 |
|
|
26 | }; |
4 | |
27 | |
5 | cf::register_command goto => sub { |
28 | cf::register_command goto => sub { |
6 | my ($ob, $arg) = @_; |
29 | my ($ob, $arg) = @_; |
7 | |
30 | |
8 | return unless $ob->may ("command_goto"); |
31 | return unless $ob->may ("command_goto"); |
9 | |
32 | |
10 | my $portal = cf::object::new "exit"; |
33 | my ($path, $x, $y) = split /\s+/, $arg, 3; |
11 | |
34 | |
12 | $portal->slaying ($arg); |
35 | $ob->goto ($path, $x, $y); |
13 | $portal->stats->hp (0); |
|
|
14 | $portal->stats->sp (0); |
|
|
15 | |
36 | |
16 | $portal->apply ($ob); |
37 | 1 |
|
|
38 | }; |
17 | |
39 | |
18 | $portal->destroy; |
40 | cf::register_command teleport => sub { |
|
|
41 | my ($ob, $arg) = @_; |
|
|
42 | |
|
|
43 | return unless $ob->may ("command_teleport"); |
|
|
44 | |
|
|
45 | cf::async { |
|
|
46 | $Coro::current->{desc} = "teleport $arg"; |
|
|
47 | |
|
|
48 | my $other = cf::player::find $arg |
|
|
49 | or return $ob->reply (undef, "$arg: no such player."); |
|
|
50 | |
|
|
51 | $ob->goto ($other->maplevel, $other->ob->x, $other->ob->y); |
|
|
52 | }; |
19 | |
53 | |
20 | 1 |
54 | 1 |
21 | }; |
55 | }; |
22 | |
56 | |
23 | cf::register_command wizpass => sub { |
57 | cf::register_command wizpass => sub { |
… | |
… | |
59 | cf::register_command wizlook => sub { |
93 | cf::register_command wizlook => sub { |
60 | my ($ob, $arg) = @_; |
94 | my ($ob, $arg) = @_; |
61 | |
95 | |
62 | return unless $ob->may ("command_wizlook"); |
96 | return unless $ob->may ("command_wizlook"); |
63 | |
97 | |
64 | $ob->clear_los; |
98 | $ob->contr->clear_los (0); |
65 | |
99 | |
66 | $ob->reply (undef, "You can temporarily see through walls."); |
100 | $ob->reply (undef, "You can temporarily see through walls."); |
67 | |
101 | |
68 | 1 |
102 | 1 |
69 | }; |
103 | }; |
… | |
… | |
76 | my $map = $ob->map; |
110 | my $map = $ob->map; |
77 | |
111 | |
78 | my @pl = $map->players; |
112 | my @pl = $map->players; |
79 | $_->enter_link for @pl; |
113 | $_->enter_link for @pl; |
80 | cf::async { |
114 | cf::async { |
81 | my $name = $map->{path}->as_string; |
115 | my $name = $map->visible_name; |
|
|
116 | $Coro::current->{desc} = "reset $name"; |
82 | |
117 | |
83 | $map->reset; |
118 | $map->reset; |
84 | $_->leave_link for @pl; |
119 | $_->leave_link for @pl; |
85 | |
120 | |
86 | $ob->reply (undef, "$name was reset."); |
121 | $ob->reply (undef, "$name was reset."); |
87 | }; |
122 | }; |
88 | |
123 | |
89 | 1 |
124 | 1 |
90 | }; |
125 | }; |
91 | |
126 | |
|
|
127 | cf::register_command observe => sub { |
|
|
128 | my ($ob, $arg) = @_; |
|
|
129 | |
|
|
130 | return unless $ob->may ("command_observe"); |
|
|
131 | |
|
|
132 | my $other = cf::player::find_active $arg; |
|
|
133 | $ob->contr->set_observe ($other ? $other->ob : undef); |
|
|
134 | |
|
|
135 | 1 |
|
|
136 | }; |
|
|
137 | |
92 | for my $command (qw(teleport summon arrest kick banish)) { |
138 | for my $command (qw(summon arrest banish)) { |
93 | my $method = "command_$command"; |
139 | my $method = "command_$command"; |
94 | |
140 | |
95 | cf::register_command $command => sub { |
141 | cf::register_command $command => sub { |
96 | my ($ob, $arg) = @_; |
142 | my ($ob, $arg) = @_; |
97 | |
143 | |