… | |
… | |
5 | # miscellaneous commands |
5 | # miscellaneous commands |
6 | |
6 | |
7 | sub rename_to($$$) { |
7 | sub rename_to($$$) { |
8 | my ($ob, $from, $to) = @_; |
8 | my ($ob, $from, $to) = @_; |
9 | |
9 | |
10 | $to =~ /^[a-zA-Z0-9.,=#\/%$!^]*$/ |
10 | $to =~ /^[a-zA-Z0-9.,=#\/%$!^ ]*$/ |
11 | or return $ob->message ("rename: name must consist only of letters, digits, spaces and a few other things."); |
11 | or return $ob->message ("rename: name must consist only of letters, digits, spaces and a few other things."); |
12 | |
12 | |
13 | 127 >= length $to |
13 | 127 >= length $to |
14 | or return $ob->message ("rename: new name must be <= 127 characters."); |
14 | or return $ob->message ("rename: new name must be <= 127 characters."); |
15 | |
15 | |
… | |
… | |
68 | "* " . $ob->name . "/" . $ob->level . " " . (length $pl->own_title ? $pl->own_title : "the " . $pl->title) |
68 | "* " . $ob->name . "/" . $ob->level . " " . (length $pl->own_title ? $pl->own_title : "the " . $pl->title) |
69 | . ($pl->peaceful ? " [peaceful]" : " [HOSTILE]") |
69 | . ($pl->peaceful ? " [peaceful]" : " [HOSTILE]") |
70 | . ($ns->afk ? " [AFK]" : "") |
70 | . ($ns->afk ? " [AFK]" : "") |
71 | . ($ob->flag (cf::FLAG_WIZ) ? " [WIZ]" : "") |
71 | . ($ob->flag (cf::FLAG_WIZ) ? " [WIZ]" : "") |
72 | . " [" . $pl->ns->version . "]" |
72 | . " [" . $pl->ns->version . "]" |
73 | . " [" . ($pl->peaceful || $privileged ? $ob->map->{path}->visible_name : $ob->map->region ? $ob->map->region->name : "the unknown") . "]" |
73 | . " [" . ($pl->peaceful || $privileged ? $ob->map->visible_name : $ob->region->name) . "]" |
74 | . (sprintf " [rtt %.3fs]", $pl->ns->rtt * 1e-6) |
74 | . (sprintf " [rtt %.3fs]", $pl->ns->rtt * 1e-6) |
75 | . ($privileged ? " " . $pl->ns->host : "") |
75 | . ($privileged ? " " . $pl->ns->host : "") |
76 | } sort { (lc $a->ob->name) cmp (lc $b->ob->name) } @pl |
76 | } sort { (lc $a->ob->name) cmp (lc $b->ob->name) } @pl |
77 | ), |
77 | ), |
78 | eval { "* IRC: " . join ", ", ext::schmorp_irc::users }, |
78 | eval { "* IRC: " . join ", ", ext::schmorp_irc::users }, |
… | |
… | |
86 | |
86 | |
87 | $ob->reply (undef, (join "\n", who_listing $ob->may ("extended_who")), cf::NDI_UNIQUE | cf::NDI_DK_ORANGE); |
87 | $ob->reply (undef, (join "\n", who_listing $ob->may ("extended_who")), cf::NDI_UNIQUE | cf::NDI_DK_ORANGE); |
88 | |
88 | |
89 | 1 |
89 | 1 |
90 | }; |
90 | }; |
|
|
91 | |
|
|
92 | cf::register_command usekeys => sub { |
|
|
93 | my ($ob, $arg) = @_; |
|
|
94 | my @types = ("inventory", "keyrings", "containers"); |
|
|
95 | my $mapping = { |
|
|
96 | inventory => 1, |
|
|
97 | keyrings => 2, |
|
|
98 | containers => 3, |
|
|
99 | }; |
|
|
100 | |
|
|
101 | my $oldtype = $ob->contr->usekeys; |
|
|
102 | my $oldtype_name = $types[$oldtype]; |
|
|
103 | |
|
|
104 | return $ob->reply (undef, "usekeys is set to $oldtype_name") |
|
|
105 | unless $arg; |
|
|
106 | |
|
|
107 | return $ob->reply (undef, "usekeys: Unknown options '$arg', valid options are inventory, keyrings, containers") |
|
|
108 | unless $mapping->{$arg}; |
|
|
109 | |
|
|
110 | $ob->contr->usekeys ($mapping->{$arg} - 1); # HACK: because of the $mapping->{$arg} check before, where $arg should not be 0 |
|
|
111 | # but $arg would be 0 if a user enters an incorrect value |
|
|
112 | $ob->reply (undef, "usekeys" . ($oldtype == $ob->contr->usekeys ? "" : " now") . " set to " . $types[$ob->contr->usekeys]); |
|
|
113 | }; |
|
|
114 | |
|
|
115 | cf::register_command afk => sub { |
|
|
116 | my ($ob, $arg) = @_; |
|
|
117 | |
|
|
118 | $ob->contr->ns->afk ($ob->contr->ns->afk ? 0 : 1); |
|
|
119 | $ob->reply (undef, $ob->contr->ns->afk ? "You are now AFK" : "You are no longer AFK"); |
|
|
120 | }; |
|
|
121 | |
|
|
122 | cf::register_command sound => sub { |
|
|
123 | my ($ob, $arg) = @_; |
|
|
124 | |
|
|
125 | $ob->contr->ns->sound ($ob->contr->ns->sound ? 0 : 1); |
|
|
126 | $ob->reply (undef, $ob->contr->ns->sound ? "The sounds are enabled." : "Silence is golden..."); |
|
|
127 | }; |
|
|
128 | |
|
|
129 | cf::register_command brace => sub { |
|
|
130 | my ($ob, $arg) = @_; |
|
|
131 | |
|
|
132 | $ob->contr->braced ($ob->contr->braced ? 0 : 1); |
|
|
133 | $ob->reply (undef, $ob->contr->braced ? "You are braced." : "Not braced."); |
|
|
134 | }; |
|
|
135 | |
|
|
136 | # XXX: This has a bug. After one sets his wimpy level to 0 and resets it to |
|
|
137 | # some other level (which may also be 0), this does not get echoed, |
|
|
138 | # but it does get set. |
|
|
139 | cf::register_command wimpy => sub { |
|
|
140 | my ($ob, $arg) = @_; |
|
|
141 | |
|
|
142 | my $wimpy = $ob->run_away; |
|
|
143 | return $ob->reply (undef, "Your current wimpy level is $wimpy.") |
|
|
144 | if $arg eq ""; |
|
|
145 | |
|
|
146 | return $ob->run_away ($arg) && $ob->reply (undef, "Your new wimpy level is $arg.") |
|
|
147 | if $arg =~ /^\d+$/ and $arg <= 100; |
|
|
148 | |
|
|
149 | $ob->reply (undef, "Incorrect parameters for wimpy: $arg"); |
|
|
150 | }; |
|
|
151 | |
|
|
152 | cf::register_command peaceful => sub { |
|
|
153 | my ($ob, $arg) = @_; |
|
|
154 | |
|
|
155 | $ob->reply (undef, "You cannot change your peaceful setting with this command." |
|
|
156 | ." Please speak to the priest in the temple of Gorokh" |
|
|
157 | ." if you want to become hostile or in temple of Valriel" |
|
|
158 | ." if you want to become peaceful again."); |
|
|
159 | |
|
|
160 | #$ob->contr->peaceful ($ob->contr->peaceful ? 0 : 1); |
|
|
161 | #$ob->reply (undef, $ob->contr->peaceful ? "You will attack other players." : "You will not attack other players."); |
|
|
162 | }; |
|
|
163 | |
91 | |
164 | |
92 | cf::register_command rename => sub { |
165 | cf::register_command rename => sub { |
93 | my ($ob, $arg) = @_; |
166 | my ($ob, $arg) = @_; |
94 | |
167 | |
95 | $ob->speed_left ($ob->speed_left - 0.25); |
168 | $ob->speed_left ($ob->speed_left - 0.25); |
… | |
… | |
134 | cf::register_command maps => sub { |
207 | cf::register_command maps => sub { |
135 | my ($ob, $arg) = @_; |
208 | my ($ob, $arg) = @_; |
136 | |
209 | |
137 | no re 'eval'; $arg = qr<$arg>; |
210 | no re 'eval'; $arg = qr<$arg>; |
138 | |
211 | |
139 | my $format = "%2s %1s %5s %-60.60s\n"; |
212 | my $format = "%2s %1s %3s %5s %.60s\n"; |
140 | |
213 | |
141 | my $msg = sprintf $format, "Pl", "I", "Reset", "Name"; |
214 | $ob->reply (undef, (sprintf $format, "Pl", "I", "Svd", "Reset", "Name"), cf::NDI_BLACK | cf::NDI_UNIQUE); |
142 | |
215 | |
143 | for (sort keys %cf::MAP) { |
216 | for (sort keys %cf::MAP) { |
144 | my $map = $cf::MAP{$_} |
217 | my $map = $cf::MAP{$_} |
145 | or next; |
218 | or next; |
146 | |
219 | |
147 | next unless $map->path =~ $arg; |
220 | next unless $map->path =~ $arg; |
|
|
221 | next if $map->{deny_list}; |
148 | |
222 | |
149 | $msg .= sprintf $format, |
223 | my $svd = int $cf::RUNTIME - $map->{last_save}; |
|
|
224 | $svd = "++" if $svd > 99; |
|
|
225 | |
|
|
226 | $ob->reply (undef, |
|
|
227 | (sprintf $format, |
150 | (scalar $map->players), |
228 | (scalar $map->players), |
151 | $IN_MEMORY{$map->in_memory} || "?", |
229 | $IN_MEMORY{$map->in_memory} || "?", |
|
|
230 | $svd, |
152 | (int $map->reset_at - $cf::RUNTIME), |
231 | (int $map->reset_at - $cf::RUNTIME), |
153 | $map->{path}->visible_name; |
232 | $map->visible_name), |
154 | } |
233 | cf::NDI_BLACK | cf::NDI_UNIQUE); |
155 | |
|
|
156 | $ob->reply (undef, $msg); |
|
|
157 | |
|
|
158 | 1 |
234 | } |
159 | }; |
|
|
160 | |
235 | |
|
|
236 | 1 |
|
|
237 | }; |
|
|
238 | |