1 |
#! perl # mandatory |
2 |
|
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 |
}; |
27 |
|
28 |
cf::register_command goto => sub { |
29 |
my ($ob, $arg) = @_; |
30 |
|
31 |
return unless $ob->may ("command_goto"); |
32 |
|
33 |
my ($path, $x, $y) = split /\s+/, $arg, 3; |
34 |
|
35 |
$ob->goto ($path, $x, $y); |
36 |
|
37 |
1 |
38 |
}; |
39 |
|
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 |
}; |
53 |
|
54 |
1 |
55 |
}; |
56 |
|
57 |
cf::register_command wizpass => sub { |
58 |
my ($ob, $arg) = @_; |
59 |
|
60 |
return unless $ob->may ("command_wizpass"); |
61 |
|
62 |
my $new_val = length $arg ? $arg * 1 : !$ob->flag (cf::FLAG_WIZPASS); |
63 |
|
64 |
$ob->flag (cf::FLAG_WIZPASS, $new_val); |
65 |
|
66 |
$ob->reply (undef, |
67 |
$new_val |
68 |
? "You will now walk through walls.\n" |
69 |
: "You will now be stopped by walls.\n", |
70 |
); |
71 |
|
72 |
1 |
73 |
}; |
74 |
|
75 |
cf::register_command wizcast => sub { |
76 |
my ($ob, $arg) = @_; |
77 |
|
78 |
return unless $ob->may ("command_wizcast"); |
79 |
|
80 |
my $new_val = length $arg ? $arg * 1 : !$ob->flag (cf::FLAG_WIZCAST); |
81 |
|
82 |
$ob->flag (cf::FLAG_WIZCAST, $new_val); |
83 |
|
84 |
$ob->reply (undef, |
85 |
$new_val |
86 |
? "You can now cast spells anywhere." |
87 |
: "You now cannot cast spells in no-magic areas.", |
88 |
); |
89 |
|
90 |
1 |
91 |
}; |
92 |
|
93 |
cf::register_command wizlook => sub { |
94 |
my ($ob, $arg) = @_; |
95 |
|
96 |
return unless $ob->may ("command_wizlook"); |
97 |
|
98 |
my $new_val = length $arg ? $arg * 1 : !$ob->flag (cf::FLAG_WIZLOOK); |
99 |
|
100 |
$ob->flag (cf::FLAG_WIZLOOK, $new_val); |
101 |
|
102 |
$ob->contr->do_los (1); |
103 |
|
104 |
$ob->reply (undef, |
105 |
$new_val |
106 |
? "You can now look through walls." |
107 |
: "You will now see the same thing as you would normally.", |
108 |
); |
109 |
|
110 |
1 |
111 |
}; |
112 |
|
113 |
cf::register_command reset => sub { |
114 |
my ($ob, $arg) = @_; |
115 |
|
116 |
return unless $ob->may ("command_reset"); |
117 |
|
118 |
my $map = $ob->map; |
119 |
|
120 |
my @pl = $map->players; |
121 |
$_->enter_link for @pl; |
122 |
cf::async { |
123 |
my $name = $map->visible_name; |
124 |
$Coro::current->{desc} = "reset $name"; |
125 |
|
126 |
$map->reset; |
127 |
$_->leave_link for @pl; |
128 |
|
129 |
$ob->reply (undef, "$name was reset."); |
130 |
}; |
131 |
|
132 |
1 |
133 |
}; |
134 |
|
135 |
cf::register_command observe => sub { |
136 |
my ($ob, $arg) = @_; |
137 |
|
138 |
return unless $ob->may ("command_observe"); |
139 |
|
140 |
my $other = cf::player::find_active $arg; |
141 |
$ob->contr->set_observe ($other ? $other->ob : undef); |
142 |
|
143 |
1 |
144 |
}; |
145 |
|
146 |
for my $command (qw(summon arrest banish)) { |
147 |
my $method = "command_$command"; |
148 |
|
149 |
cf::register_command $command => sub { |
150 |
my ($ob, $arg) = @_; |
151 |
|
152 |
return unless $ob->may ($method); |
153 |
|
154 |
$ob->$method ($arg) |
155 |
}; |
156 |
} |
157 |
|