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 |
my $other = cf::player::find $arg |
47 |
or return $ob->reply (undef, "$arg: no such player."); |
48 |
|
49 |
$ob->goto ($other->maplevel, $other->ob->x, $other->ob->y); |
50 |
}; |
51 |
|
52 |
1 |
53 |
}; |
54 |
|
55 |
cf::register_command wizpass => sub { |
56 |
my ($ob, $arg) = @_; |
57 |
|
58 |
return unless $ob->may ("command_wizpass"); |
59 |
|
60 |
my $new_val = length $arg ? $arg * 1 : !$ob->flag (cf::FLAG_WIZPASS); |
61 |
|
62 |
$ob->flag (cf::FLAG_WIZPASS, $new_val); |
63 |
|
64 |
$ob->reply (undef, |
65 |
$new_val |
66 |
? "You will now walk through walls.\n" |
67 |
: "You will now be stopped by walls.\n", |
68 |
); |
69 |
|
70 |
1 |
71 |
}; |
72 |
|
73 |
cf::register_command wizcast => sub { |
74 |
my ($ob, $arg) = @_; |
75 |
|
76 |
return unless $ob->may ("command_wizcast"); |
77 |
|
78 |
my $new_val = length $arg ? $arg * 1 : !$ob->flag (cf::FLAG_WIZCAST); |
79 |
|
80 |
$ob->flag (cf::FLAG_WIZCAST, $new_val); |
81 |
|
82 |
$ob->reply (undef, |
83 |
$new_val |
84 |
? "You can now cast spells anywhere." |
85 |
: "You now cannot cast spells in no-magic areas.", |
86 |
); |
87 |
|
88 |
1 |
89 |
}; |
90 |
|
91 |
cf::register_command wizlook => sub { |
92 |
my ($ob, $arg) = @_; |
93 |
|
94 |
return unless $ob->may ("command_wizlook"); |
95 |
|
96 |
$ob->clear_los; |
97 |
|
98 |
$ob->reply (undef, "You can temporarily see through walls."); |
99 |
|
100 |
1 |
101 |
}; |
102 |
|
103 |
cf::register_command reset => sub { |
104 |
my ($ob, $arg) = @_; |
105 |
|
106 |
return unless $ob->may ("command_reset"); |
107 |
|
108 |
my $map = $ob->map; |
109 |
|
110 |
my @pl = $map->players; |
111 |
$_->enter_link for @pl; |
112 |
cf::async { |
113 |
my $name = $map->visible_name; |
114 |
|
115 |
$map->reset; |
116 |
$_->leave_link for @pl; |
117 |
|
118 |
$ob->reply (undef, "$name was reset."); |
119 |
}; |
120 |
|
121 |
1 |
122 |
}; |
123 |
|
124 |
for my $command (qw(summon arrest banish)) { |
125 |
my $method = "command_$command"; |
126 |
|
127 |
cf::register_command $command => sub { |
128 |
my ($ob, $arg) = @_; |
129 |
|
130 |
return unless $ob->may ($method); |
131 |
|
132 |
$ob->$method ($arg) |
133 |
}; |
134 |
} |
135 |
|