1 |
root |
1.19 |
#! perl # MANDATORY |
2 |
root |
1.1 |
|
3 |
|
|
# wizard commands |
4 |
|
|
|
5 |
pippijn |
1.18 |
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 |
pippijn |
1.17 |
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 |
root |
1.1 |
cf::register_command goto => sub { |
29 |
|
|
my ($ob, $arg) = @_; |
30 |
|
|
|
31 |
|
|
return unless $ob->may ("command_goto"); |
32 |
|
|
|
33 |
root |
1.13 |
my ($path, $x, $y) = split /\s+/, $arg, 3; |
34 |
root |
1.1 |
|
35 |
root |
1.13 |
$ob->goto ($path, $x, $y); |
36 |
root |
1.1 |
|
37 |
root |
1.13 |
1 |
38 |
|
|
}; |
39 |
|
|
|
40 |
|
|
cf::register_command teleport => sub { |
41 |
|
|
my ($ob, $arg) = @_; |
42 |
root |
1.1 |
|
43 |
root |
1.13 |
return unless $ob->may ("command_teleport"); |
44 |
|
|
|
45 |
|
|
cf::async { |
46 |
pippijn |
1.16 |
my $other = cf::player::find $arg |
47 |
pippijn |
1.14 |
or return $ob->reply (undef, "$arg: no such player."); |
48 |
root |
1.13 |
|
49 |
|
|
$ob->goto ($other->maplevel, $other->ob->x, $other->ob->y); |
50 |
|
|
}; |
51 |
root |
1.1 |
|
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 |
root |
1.21 |
$ob->contr->clear_los; |
97 |
root |
1.1 |
|
98 |
|
|
$ob->reply (undef, "You can temporarily see through walls."); |
99 |
|
|
|
100 |
|
|
1 |
101 |
|
|
}; |
102 |
|
|
|
103 |
root |
1.2 |
cf::register_command reset => sub { |
104 |
|
|
my ($ob, $arg) = @_; |
105 |
|
|
|
106 |
|
|
return unless $ob->may ("command_reset"); |
107 |
|
|
|
108 |
root |
1.4 |
my $map = $ob->map; |
109 |
|
|
|
110 |
root |
1.6 |
my @pl = $map->players; |
111 |
|
|
$_->enter_link for @pl; |
112 |
root |
1.11 |
cf::async { |
113 |
root |
1.12 |
my $name = $map->visible_name; |
114 |
root |
1.9 |
|
115 |
root |
1.4 |
$map->reset; |
116 |
|
|
$_->leave_link for @pl; |
117 |
root |
1.5 |
|
118 |
root |
1.9 |
$ob->reply (undef, "$name was reset."); |
119 |
root |
1.4 |
}; |
120 |
|
|
|
121 |
root |
1.2 |
1 |
122 |
|
|
}; |
123 |
|
|
|
124 |
root |
1.20 |
cf::register_command observe => sub { |
125 |
|
|
my ($ob, $arg) = @_; |
126 |
|
|
|
127 |
|
|
return unless $ob->may ("command_observe"); |
128 |
|
|
|
129 |
|
|
my $other = cf::player::find_active $arg; |
130 |
|
|
$ob->contr->set_observe ($other ? $other->ob : undef); |
131 |
|
|
|
132 |
|
|
1 |
133 |
|
|
}; |
134 |
|
|
|
135 |
pippijn |
1.17 |
for my $command (qw(summon arrest banish)) { |
136 |
root |
1.1 |
my $method = "command_$command"; |
137 |
|
|
|
138 |
|
|
cf::register_command $command => sub { |
139 |
|
|
my ($ob, $arg) = @_; |
140 |
|
|
|
141 |
|
|
return unless $ob->may ($method); |
142 |
|
|
|
143 |
|
|
$ob->$method ($arg) |
144 |
|
|
}; |
145 |
|
|
} |
146 |
|
|
|