… | |
… | |
31 | |
31 | |
32 | clean_timeouts $pl->ob; |
32 | clean_timeouts $pl->ob; |
33 | }, |
33 | }, |
34 | ; |
34 | ; |
35 | |
35 | |
36 | cf::register_command listen => 0, sub { |
36 | cf::register_command listen => sub { |
37 | my ($who, $msg) = @_; |
37 | my ($who, $msg) = @_; |
38 | my $player = cf::player::find $who->name; |
38 | my $player = cf::player::find $who->name; |
39 | |
39 | |
40 | if ($msg ne "") { |
40 | if ($msg ne "") { |
41 | my $prev_listen = $player->listening; |
41 | my $prev_listen = $player->listening; |
… | |
… | |
48 | } else { |
48 | } else { |
49 | $who->message ("Your verbose level is " . $player->listening . ".", cf::NDI_UNIQUE); |
49 | $who->message ("Your verbose level is " . $player->listening . ".", cf::NDI_UNIQUE); |
50 | } |
50 | } |
51 | }; |
51 | }; |
52 | |
52 | |
53 | cf::register_command say => 0, sub { |
53 | cf::register_command say => sub { |
54 | my ($who, $msg) = @_; |
54 | my ($who, $msg) = @_; |
55 | |
55 | |
56 | utf8::decode $msg; |
56 | utf8::decode $msg; |
|
|
57 | |
|
|
58 | return if $who->contr->invoke (cf::EVENT_PLAYER_SAY, $msg); |
57 | |
59 | |
58 | if ($msg) { |
60 | if ($msg) { |
59 | my $name = $who->name; |
61 | my $name = $who->name; |
60 | |
62 | |
61 | utf8::encode $msg; # ->message not yet utf8-ified |
63 | utf8::encode $msg; # ->message not yet utf8-ified |
62 | $_->ob->message ("$name says: $msg", cf::NDI_GREY | cf::NDI_UNIQUE) |
64 | $_->ob->message ("$name says: $msg", cf::NDI_GREY | cf::NDI_UNIQUE) |
63 | for grep $who->on_same_map_as ($_->ob), cf::player::list; |
65 | for grep $who->on_same_map_as ($_->ob), cf::player::list; |
64 | utf8::decode $msg; |
66 | utf8::decode $msg; |
65 | |
67 | |
66 | # npcs, magic_ears etc. |
68 | # npcs, magic_ears etc. |
67 | # first find all objects and their inventories within a 5x5 square |
69 | # first find all objects and theirt-level inventories |
68 | # that have something resembling dialogue |
70 | # within a 5x5 square # that have something resembling |
|
|
71 | # dialogue or support on_say. |
69 | my ($map, $x, $y) = ($who->map, $who->x - 2, $who->y - 2); |
72 | my ($map, $x, $y) = ($who->map, $who->x - 2, $who->y - 2); |
70 | |
73 | |
71 | for my $npc ( |
74 | for my $npc ( |
72 | grep NPC_Dialogue::has_dialogue $_, |
75 | grep +($_->invoke (cf::EVENT_OBJECT_SAY, $who->contr, $msg) && return) || NPC_Dialogue::has_dialogue $_, |
73 | map +($_, $_->inv), |
76 | map +($_, $_->inv), |
74 | grep $_, |
77 | grep $_, |
75 | map $map->at ($x + $_ % 5, $y + (int $_ / 5)), |
78 | map $map->at ($x + $_ % 5, $y + (int $_ / 5)), |
76 | 0..24 |
79 | 0..24 |
77 | ) { |
80 | ) { |
… | |
… | |
105 | } else { |
108 | } else { |
106 | $who->message ("What do you want to say?", cf::NDI_UNIQUE); |
109 | $who->message ("What do you want to say?", cf::NDI_UNIQUE); |
107 | } |
110 | } |
108 | }; |
111 | }; |
109 | |
112 | |
110 | cf::register_command chat => 0, sub { |
113 | cf::register_command chat => sub { |
111 | my ($who, $msg) = @_; |
114 | my ($who, $msg) = @_; |
112 | |
115 | |
113 | utf8::decode $msg; |
116 | utf8::decode $msg; |
|
|
117 | |
|
|
118 | return if $who->contr->invoke (cf::EVENT_PLAYER_CHAT, $msg); |
114 | |
119 | |
115 | if ($msg) { |
120 | if ($msg) { |
116 | my $name = $who->name; |
121 | my $name = $who->name; |
117 | my $NOW = time; |
122 | my $NOW = time; |
118 | |
123 | |
119 | utf8::encode $msg; # ->message not yet utf8-ified |
124 | utf8::encode $msg; # ->message not yet utf8-ified |
120 | # cf::LOG cf::llevDebug, sprintf "QBERT [%s] %s\n", $name, $msg; |
125 | cf::LOG cf::llevDebug, sprintf "QBERT [%s] %s\n", $name, $msg; |
121 | cf::ext::schmorp_irc::do_notice (sprintf "[%s] %s", $name, $msg); |
126 | ext::schmorp_irc::do_notice (sprintf "[%s] %s", $name, $msg); |
122 | |
127 | |
123 | $_->ob->message ("$name chats: $msg", cf::NDI_BLUE) |
128 | $_->ob->message ("$name chats: $msg", cf::NDI_BLUE) |
124 | for grep { $_->ob->{ext_ignore_shout}{$name} < $NOW && $_->listening >= 10 } cf::player::list; |
129 | for grep { $_->ob->{ext_ignore_shout}{$name} < $NOW && $_->listening >= 10 } cf::player::list; |
125 | |
130 | |
126 | } else { |
131 | } else { |
127 | $who->message ("Chat what?", cf::NDI_UNIQUE); |
132 | $who->message ("Chat what?", cf::NDI_UNIQUE); |
128 | } |
133 | } |
129 | }; |
134 | }; |
130 | |
135 | |
131 | cf::register_command shout => 0, sub { |
136 | cf::register_command shout => sub { |
132 | my ($who, $msg) = @_; |
137 | my ($who, $msg) = @_; |
133 | |
138 | |
134 | utf8::decode $msg; |
139 | utf8::decode $msg; |
|
|
140 | |
|
|
141 | return if $who->contr->invoke (cf::EVENT_PLAYER_SHOUT, $msg); |
135 | |
142 | |
136 | if ($msg) { |
143 | if ($msg) { |
137 | my $NOW = time; |
144 | my $NOW = time; |
138 | my $name = $who->name; |
145 | my $name = $who->name; |
139 | |
146 | |
140 | # cf::LOG cf::llevDebug, sprintf "QBERT {%s} %s\n", $name, $msg; |
147 | cf::LOG cf::llevDebug, sprintf "QBERT {%s} %s\n", $name, $msg; |
141 | cf::ext::schmorp_irc::do_notice (sprintf "{%s} %s\n", $name, $msg); |
148 | ext::schmorp_irc::do_notice (sprintf "\007\0034{%s} %s\n", $name, $msg); |
142 | |
149 | |
143 | utf8::encode $msg; # ->message not yet utf8-ified |
150 | utf8::encode $msg; # ->message not yet utf8-ified |
144 | $_->ob->message ("$name shouts: $msg", cf::NDI_RED) |
151 | $_->ob->message ("$name shouts: $msg", cf::NDI_RED) |
145 | for grep { $_->ob->{ext_ignore_shout}{$name} < $NOW && $_->listening >= 2 } cf::player::list; |
152 | for grep { $_->ob->{ext_ignore_shout}{$name} < $NOW && $_->listening >= 2 } cf::player::list; |
146 | |
153 | |
… | |
… | |
148 | $who->message ("Shout what?", cf::NDI_UNIQUE); |
155 | $who->message ("Shout what?", cf::NDI_UNIQUE); |
149 | } |
156 | } |
150 | |
157 | |
151 | }; |
158 | }; |
152 | |
159 | |
153 | cf::register_command tell => 0, sub { |
160 | cf::register_command tell => sub { |
154 | my ($who, $args) = @_; |
161 | my ($who, $args) = @_; |
155 | my ($target, $msg) = split /\s+/, $args, 2; |
162 | my ($target, $msg) = split /\s+/, $args, 2; |
156 | |
163 | |
157 | utf8::decode $msg; |
164 | utf8::decode $msg; |
158 | |
165 | |
|
|
166 | return if $who->contr->invoke (cf::EVENT_PLAYER_TELL, $target, $msg); |
|
|
167 | |
159 | my $name = $who->name; |
168 | my $name = $who->name; |
160 | |
169 | |
|
|
170 | if ($target =~ /irc\//) { |
|
|
171 | my (undef, $nick) = split /\//, $target, 2; |
|
|
172 | $who->message ("You tell $target: $args"); |
|
|
173 | ext::schmorp_irc::do_notice (sprintf "(%s) %s: %s\n", $name, $nick, $msg); |
161 | if (my $other = cf::player::find $target) { |
174 | } elsif (my $other = cf::player::find $target) { |
162 | |
175 | |
163 | if ($msg) { |
176 | if ($msg) { |
164 | if ($target eq $name) { |
177 | if ($target eq $name) { |
165 | $who->message ("You are talking to yourself, you freak!", cf::NDI_UNIQUE); |
178 | $who->message ("You are talking to yourself, you freak!", cf::NDI_UNIQUE); |
166 | } elsif ($other->ob->{ext_ignore_tell}{$name} >= time) { |
179 | } elsif ($other->ob->{ext_ignore_tell}{$name} >= time) { |
… | |
… | |
180 | } else { |
193 | } else { |
181 | $who->message ("No such player. Your message: $msg", cf::NDI_UNIQUE); |
194 | $who->message ("No such player. Your message: $msg", cf::NDI_UNIQUE); |
182 | } |
195 | } |
183 | }; |
196 | }; |
184 | |
197 | |
185 | cf::register_command reply => 0, sub { |
198 | cf::register_command reply => sub { |
186 | my ($who, $args) = @_; |
199 | my ($who, $args) = @_; |
187 | my $name = $who->name; |
200 | my $name = $who->name; |
188 | |
201 | |
189 | utf8::decode $args; |
202 | utf8::decode $args; |
190 | |
203 | |
|
|
204 | return if $who->contr->invoke (cf::EVENT_PLAYER_TELL, $who->{ext_last_tell}, $args); |
|
|
205 | |
|
|
206 | if ($who->{ext_last_tell} =~ /irc\//) { |
|
|
207 | my (undef, $nick) = split /\//, $who->{ext_last_tell}, 2; |
|
|
208 | $who->message ("You tell " . $who->{ext_last_tell} . ": $args"); |
|
|
209 | ext::schmorp_irc::do_notice (sprintf "(%s) %s: %s\n", $name, $nick, $args); |
191 | if (my $other = cf::player::find $who->{ext_last_tell}) { |
210 | } elsif (my $other = cf::player::find $who->{ext_last_tell}) { |
|
|
211 | |
192 | if ($args) { |
212 | if ($args) { |
193 | |
|
|
194 | $other->ob->{ext_ignore_tell}{$name} >= time |
213 | $other->ob->{ext_ignore_tell}{$name} >= time |
195 | or delete $other->ob->{ext_ignore_tell}{$name}; |
214 | or delete $other->ob->{ext_ignore_tell}{$name}; |
196 | |
215 | |
197 | if ($other->ob->{ext_ignore_tell}{$name} < time) { |
216 | if ($other->ob->{ext_ignore_tell}{$name} < time) { |
198 | utf8::encode $args; # ->message not yet utf8-ified |
217 | utf8::encode $args; # ->message not yet utf8-ified |
… | |
… | |
207 | } else { |
226 | } else { |
208 | $who->message ("What do you want to tell ".$other->ob->name."?", cf::NDI_UNIQUE); |
227 | $who->message ("What do you want to tell ".$other->ob->name."?", cf::NDI_UNIQUE); |
209 | } |
228 | } |
210 | |
229 | |
211 | } else { |
230 | } else { |
212 | $who->message ("Can't reply, player left. Your message: $args", cf::NDI_UNIQUE); |
231 | $who->message ("Can't reply, player left. Your message: $args".$who->{ext_last_tell}, cf::NDI_UNIQUE); |
213 | } |
232 | } |
214 | }; |
233 | }; |
215 | |
234 | |
216 | cf::register_command ignore => 0, sub { |
235 | cf::register_command ignore => sub { |
217 | my ($who, $args) = @_; |
236 | my ($who, $args) = @_; |
218 | my ($target, $type, $timeout) = split /\s+/, $args; |
237 | my ($target, $type, $timeout) = split /\s+/, $args; |
219 | |
238 | |
220 | if ($args eq "list") { |
239 | if ($args eq "list") { |
221 | clean_timeouts $who; |
240 | clean_timeouts $who; |
… | |
… | |
260 | . "Usage: ignore list\n" |
279 | . "Usage: ignore list\n" |
261 | . "will show you a list of players currently ignored.", cf::NDI_UNIQUE); |
280 | . "will show you a list of players currently ignored.", cf::NDI_UNIQUE); |
262 | } |
281 | } |
263 | }; |
282 | }; |
264 | |
283 | |
265 | cf::register_command unignore => 0, sub { |
284 | cf::register_command unignore => sub { |
266 | my ($who, $args) = @_; |
285 | my ($who, $args) = @_; |
267 | my ($target, $type) = split /\s+/, $args; |
286 | my ($target, $type) = split /\s+/, $args; |
268 | |
287 | |
269 | if ($args eq "") { |
288 | if ($args eq "") { |
270 | if ($who->{ext_ignore_tell}) { |
289 | if ($who->{ext_ignore_tell}) { |
… | |
… | |
294 | $who->message ("No such player or ambiguous name: $target", cf::NDI_UNIQUE); |
313 | $who->message ("No such player or ambiguous name: $target", cf::NDI_UNIQUE); |
295 | } |
314 | } |
296 | } |
315 | } |
297 | }; |
316 | }; |
298 | |
317 | |
299 | cf::register_command seen => 0, sub { |
318 | cf::register_command seen => sub { |
300 | my ($who, $args) = @_; |
319 | my ($who, $args) = @_; |
301 | |
320 | |
302 | if (my ($login) = $args =~ /(\S+)/) { |
321 | if (my ($login) = $args =~ /(\S+)/) { |
303 | if ($login eq $who->name) { |
322 | if ($login eq $who->name) { |
304 | $who->message ("Very funny, $login. Ha. Ha.", cf::NDI_UNIQUE); |
323 | $who->message ("Very funny, $login. Ha. Ha.", cf::NDI_UNIQUE); |