1 | #! perl # MANDATORY |
1 | #! perl # mandatory |
2 | |
2 | |
3 | # wizard commands |
3 | # wizard commands |
|
|
4 | |
|
|
5 | sub dm($) { |
|
|
6 | my ($ob) = @_; |
|
|
7 | |
|
|
8 | if ($ob->flag (cf::FLAG_WIZ)) { |
|
|
9 | $ob->reply (undef, "You are already the Dungeon Master!"); |
|
|
10 | return 0; |
|
|
11 | |
|
|
12 | } else { |
|
|
13 | $ob->flag (cf::FLAG_WIZ , 1); |
|
|
14 | $ob->flag (cf::FLAG_WIZPASS, 1); |
|
|
15 | $ob->flag (cf::FLAG_WIZCAST, 1); |
|
|
16 | $ob->flag (cf::FLAG_WIZLOOK, 1); |
|
|
17 | |
|
|
18 | $ob->contr->do_los (1); |
|
|
19 | $ob->contr->ns->update_command_faces; |
|
|
20 | |
|
|
21 | $ob->reply (undef, "Ok, you are the Dungeon Master!"); |
|
|
22 | |
|
|
23 | return 1; |
|
|
24 | } |
|
|
25 | } |
|
|
26 | |
|
|
27 | sub hide($) { |
|
|
28 | my ($ob) = @_; |
|
|
29 | |
|
|
30 | if ($ob->contr->hidden) { |
|
|
31 | $ob->contr->hidden (0); |
|
|
32 | # $ob->invisible (1); |
|
|
33 | |
|
|
34 | $ob->reply (undef, "You are no longer hidden!"); |
|
|
35 | } else { |
|
|
36 | $ob->contr->hidden (1); |
|
|
37 | |
|
|
38 | $ob->reply (undef, "You are now hidden!"); |
|
|
39 | } |
|
|
40 | } |
|
|
41 | |
|
|
42 | cf::register_command dm => sub { |
|
|
43 | my ($ob, $arg) = @_; |
|
|
44 | |
|
|
45 | return unless $ob->may ("command_dm"); |
|
|
46 | |
|
|
47 | dm $ob |
|
|
48 | and $ob->reply (undef, "The Dungeon Master has arrived!", cf::NDI_UNIQUE | cf::NDI_ALL | cf::NDI_LT_GREEN); |
|
|
49 | |
|
|
50 | 1 |
|
|
51 | }; |
|
|
52 | |
|
|
53 | cf::register_command dmhide => sub { |
|
|
54 | my ($ob, $arg) = @_; |
|
|
55 | |
|
|
56 | return unless $ob->may ("command_dm"); |
|
|
57 | |
|
|
58 | dm $ob |
|
|
59 | and hide $ob; |
|
|
60 | |
|
|
61 | 1 |
|
|
62 | }; |
|
|
63 | |
|
|
64 | cf::register_command hide => sub { |
|
|
65 | my ($ob, $arg) = @_; |
|
|
66 | return $ob->reply (undef, "Sorry, you are not the DM!") |
|
|
67 | unless $ob->flag (cf::FLAG_WIZ); |
|
|
68 | |
|
|
69 | hide $ob; |
|
|
70 | |
|
|
71 | 1 |
|
|
72 | }; |
|
|
73 | |
|
|
74 | cf::register_command nodm => sub { |
|
|
75 | my ($ob, $arg) = @_; |
|
|
76 | return $ob->reply (undef, "Sorry, you are not the DM!") |
|
|
77 | unless $ob->flag (cf::FLAG_WIZ); |
|
|
78 | |
|
|
79 | $ob->contr->hidden |
|
|
80 | and hide $ob; |
|
|
81 | |
|
|
82 | $ob->flag (cf::FLAG_WIZ , 0); |
|
|
83 | $ob->flag (cf::FLAG_WIZPASS, 0); |
|
|
84 | $ob->flag (cf::FLAG_WIZCAST, 0); |
|
|
85 | $ob->flag (cf::FLAG_WIZLOOK, 0); |
|
|
86 | |
|
|
87 | $ob->contr->do_los (1); |
|
|
88 | $ob->contr->ns->update_command_faces; |
|
|
89 | |
|
|
90 | 1 |
|
|
91 | }; |
4 | |
92 | |
5 | cf::register_command shutdown => sub { |
93 | cf::register_command shutdown => sub { |
6 | my ($ob, $arg) = @_; |
94 | my ($ob, $arg) = @_; |
7 | return $ob->reply (undef, "Sorry, you can't shutdown the server.") |
95 | return $ob->reply (undef, "Sorry, you can't shutdown the server.") |
8 | unless $ob->flag (cf::FLAG_WIZ); |
96 | unless $ob->flag (cf::FLAG_WIZ); |
… | |
… | |
41 | my ($ob, $arg) = @_; |
129 | my ($ob, $arg) = @_; |
42 | |
130 | |
43 | return unless $ob->may ("command_teleport"); |
131 | return unless $ob->may ("command_teleport"); |
44 | |
132 | |
45 | cf::async { |
133 | cf::async { |
|
|
134 | $Coro::current->{desc} = "teleport $arg"; |
|
|
135 | |
46 | my $other = cf::player::find $arg |
136 | my $other = cf::player::find $arg |
47 | or return $ob->reply (undef, "$arg: no such player."); |
137 | or return $ob->reply (undef, "$arg: no such player."); |
48 | |
138 | |
49 | $ob->goto ($other->maplevel, $other->ob->x, $other->ob->y); |
139 | $ob->goto ($other->maplevel, $other->ob->x, $other->ob->y); |
50 | }; |
140 | }; |
… | |
… | |
91 | cf::register_command wizlook => sub { |
181 | cf::register_command wizlook => sub { |
92 | my ($ob, $arg) = @_; |
182 | my ($ob, $arg) = @_; |
93 | |
183 | |
94 | return unless $ob->may ("command_wizlook"); |
184 | return unless $ob->may ("command_wizlook"); |
95 | |
185 | |
96 | $ob->clear_los; |
186 | my $new_val = length $arg ? $arg * 1 : !$ob->flag (cf::FLAG_WIZLOOK); |
97 | |
187 | |
98 | $ob->reply (undef, "You can temporarily see through walls."); |
188 | $ob->flag (cf::FLAG_WIZLOOK, $new_val); |
|
|
189 | |
|
|
190 | $ob->contr->do_los (1); |
|
|
191 | |
|
|
192 | $ob->reply (undef, |
|
|
193 | $new_val |
|
|
194 | ? "You can now look through walls." |
|
|
195 | : "You will now see the same thing as you would normally.", |
|
|
196 | ); |
99 | |
197 | |
100 | 1 |
198 | 1 |
101 | }; |
199 | }; |
102 | |
200 | |
103 | cf::register_command reset => sub { |
201 | cf::register_command reset => sub { |
… | |
… | |
109 | |
207 | |
110 | my @pl = $map->players; |
208 | my @pl = $map->players; |
111 | $_->enter_link for @pl; |
209 | $_->enter_link for @pl; |
112 | cf::async { |
210 | cf::async { |
113 | my $name = $map->visible_name; |
211 | my $name = $map->visible_name; |
|
|
212 | $Coro::current->{desc} = "reset $name"; |
114 | |
213 | |
115 | $map->reset; |
214 | $map->reset; |
116 | $_->leave_link for @pl; |
215 | $_->leave_link for @pl; |
117 | |
216 | |
118 | $ob->reply (undef, "$name was reset."); |
217 | $ob->reply (undef, "$name was reset."); |
119 | }; |
218 | }; |
|
|
219 | |
|
|
220 | 1 |
|
|
221 | }; |
|
|
222 | |
|
|
223 | cf::register_command observe => sub { |
|
|
224 | my ($ob, $arg) = @_; |
|
|
225 | |
|
|
226 | return unless $ob->may ("command_observe"); |
|
|
227 | |
|
|
228 | my $other = cf::player::find_active $arg; |
|
|
229 | $ob->contr->set_observe ($other ? $other->ob : undef); |
120 | |
230 | |
121 | 1 |
231 | 1 |
122 | }; |
232 | }; |
123 | |
233 | |
124 | for my $command (qw(summon arrest banish)) { |
234 | for my $command (qw(summon arrest banish)) { |