1 | #! perl |
1 | #! perl # depends=irc mandatory |
2 | #CONVERSION: PARTIAL |
|
|
3 | |
2 | |
4 | # implement a replacement for the built-in say/chat/shout/tell/reply commands |
3 | # implement a replacement for the built-in say/chat/shout/tell/reply commands |
5 | # adds ignore/unignore functionality |
4 | # adds ignore/unignore functionality |
6 | |
5 | |
7 | use NPC_Dialogue; |
6 | use NPC_Dialogue; |
8 | use POSIX (); # for strftime only |
7 | use POSIX (); # for strftime only |
|
|
8 | |
|
|
9 | our $SAY_CHANNEL = { |
|
|
10 | id => "say", |
|
|
11 | title => "Map", |
|
|
12 | reply => "say ", |
|
|
13 | tooltip => "Things said to and replied from npcs near you and other players on the same map only.", |
|
|
14 | }; |
|
|
15 | |
|
|
16 | our $CHAT_CHANNEL = { |
|
|
17 | id => "chat", |
|
|
18 | title => "Chat", |
|
|
19 | reply => "chat ", |
|
|
20 | tooltip => "Player chat and shouts, global to the server.", |
|
|
21 | }; |
|
|
22 | |
|
|
23 | sub tell_channel($) { |
|
|
24 | my ($target) = @_; |
|
|
25 | |
|
|
26 | { |
|
|
27 | id => "tell-$target", |
|
|
28 | title => "$target", |
|
|
29 | reply => "tell $target ", |
|
|
30 | tooltip => "Private messages from/to $target", |
|
|
31 | } |
|
|
32 | } |
|
|
33 | |
|
|
34 | sub send_msg($$$$$) { |
|
|
35 | my ($pl, $channel, $msg, $flags, $sound) = @_; |
|
|
36 | $pl->play_sound (cf::sound::find $sound) if defined $sound; |
|
|
37 | $pl->send_msg ($channel, $msg, $flags); |
|
|
38 | () |
|
|
39 | } |
9 | |
40 | |
10 | sub clean_timeouts($) { |
41 | sub clean_timeouts($) { |
11 | my ($player) = @_; |
42 | my ($player) = @_; |
12 | my $NOW = time; |
43 | my $NOW = time; |
13 | |
44 | |
14 | for my $hash (@$player{qw(ext_ignore_shout ext_ignore_tell)}) { |
45 | for my $hash (@$player{qw(ext_ignore_shout ext_ignore_tell)}) { |
15 | while (my ($k, $v) = each %$hash) { |
46 | while (my ($k, $v) = each %$hash) { |
16 | if ($v < $NOW) { |
47 | if ($v < $NOW) { |
17 | $player->message ("Your ignore on $k has expired.", cf::NDI_GREEN | cf::NDI_UNIQUE); |
48 | $player->message ("Your ignore on $k has expired.", cf::NDI_GREEN); |
18 | delete $hash->{$k}; |
49 | delete $hash->{$k}; |
19 | } elsif (!cf::player::exists $k) { |
50 | } elsif (!cf::player::exists $k) { |
20 | $player->message ("Your ignore on $k is no longer valid (no such user).", cf::NDI_GREEN | cf::NDI_UNIQUE); |
51 | $player->message ("Your ignore on $k is no longer valid (no such user).", cf::NDI_GREEN); |
21 | delete $hash->{$k}; |
52 | delete $hash->{$k}; |
22 | } |
53 | } |
23 | } |
54 | } |
24 | } |
55 | } |
25 | } |
56 | } |
26 | |
57 | |
27 | cf::attach_to_players |
58 | # send_irc ($format, @args, $msg) |
|
|
59 | # make sure the last argument is the message! |
|
|
60 | sub send_irc { |
|
|
61 | my ($format, @args) = @_; |
|
|
62 | my $msg = pop @args; |
|
|
63 | for (split /\n/, $msg) { |
|
|
64 | ext::irc::do_notice (sprintf $format, @args, $_) |
|
|
65 | } |
|
|
66 | } |
|
|
67 | |
|
|
68 | cf::player->attach ( |
28 | prio => -1000, |
69 | prio => -1000, |
29 | on_login => sub { |
70 | on_login => sub { |
30 | my ($pl) = @_; |
71 | my ($pl) = @_; |
31 | |
72 | |
32 | clean_timeouts $pl->ob; |
73 | clean_timeouts $pl->ob; |
|
|
74 | |
|
|
75 | $pl->send_msg ($SAY_CHANNEL); |
|
|
76 | $pl->send_msg ($CHAT_CHANNEL); |
33 | }, |
77 | }, |
34 | ; |
78 | ); |
35 | |
79 | |
36 | cf::register_command listen => sub { |
80 | cf::register_command listen => sub { |
37 | my ($who, $msg) = @_; |
81 | my ($pl, $msg) = @_; |
38 | my $player = cf::player::find $who->name; |
82 | my $player = cf::player::find_active $pl->name; |
39 | |
83 | |
40 | if ($msg ne "") { |
84 | if ($msg ne "") { |
|
|
85 | $msg = 10 if $msg > 10; |
|
|
86 | |
41 | my $prev_listen = $player->listening; |
87 | my $prev_listen = $player->listening; |
42 | $player->listening ($msg); |
88 | $player->listening ($msg); |
43 | if ($prev_listen == $player->listening) { |
89 | if ($prev_listen == $player->listening) { |
44 | $who->message ("Your verbose level stayed $prev_listen.", cf::NDI_UNIQUE); |
90 | $pl->message ("Your verbose level stays at $prev_listen.", cf::NDI_REPLY); |
45 | } else { |
91 | } else { |
46 | $who->message ("Your verbose level is now " . $player->listening . ". (previously: $prev_listen)", cf::NDI_UNIQUE); |
92 | $pl->message ("Your verbose level is now " . $player->listening . ". (previously: $prev_listen)", cf::NDI_REPLY); |
47 | } |
93 | } |
48 | } else { |
94 | } else { |
49 | $who->message ("Your verbose level is " . $player->listening . ".", cf::NDI_UNIQUE); |
95 | $pl->message ("Your verbose level is " . $player->listening . ".", cf::NDI_REPLY); |
50 | } |
96 | } |
51 | }; |
97 | }; |
52 | |
98 | |
|
|
99 | cf::register_command cointoss => sub { |
|
|
100 | my ($ob, $msg) = @_; |
|
|
101 | |
|
|
102 | my $pl = $ob->contr; |
|
|
103 | my $name = $ob->name; |
|
|
104 | |
|
|
105 | my $coin = int rand 2 ? "Heads" : "Tails"; |
|
|
106 | |
|
|
107 | send_msg $_, $SAY_CHANNEL => "$name flips a coin.... $coin!", cf::NDI_GREY, "msg_say" |
|
|
108 | for grep { $ob->on_same_map_as ($_->ob) && $_ != $pl} cf::player::list; |
|
|
109 | |
|
|
110 | $pl->send_msg ($SAY_CHANNEL => "You flip a coin.... $coin!", cf::NDI_GREY | cf::NDI_REPLY); |
|
|
111 | }; |
|
|
112 | |
|
|
113 | cf::register_command orcknuckle => sub { |
|
|
114 | my ($ob, $msg) = @_; |
|
|
115 | |
|
|
116 | my $pl = $ob->contr; |
|
|
117 | my $name = $ob->name; |
|
|
118 | |
|
|
119 | my @orcknuckle = ("beholder", "ghost", "knight", "princess", "dragon", "orc"); |
|
|
120 | my ($i, $j, $k, $l) = (rand 5, rand 5, rand 5, rand 6); |
|
|
121 | my $result = "$orcknuckle[$i], $orcknuckle[$j], $orcknuckle[$k], $orcknuckle[$l]"; |
|
|
122 | |
|
|
123 | send_msg $_, $SAY_CHANNEL => "$name throws his orc-knuckles and rolls $result!", cf::NDI_GREY, "msg_say" |
|
|
124 | for grep { $ob->on_same_map_as ($_->ob) && $_ != $pl} cf::player::list; |
|
|
125 | |
|
|
126 | $pl->send_msg ($SAY_CHANNEL => "You roll $result!", cf::NDI_GREY | cf::NDI_REPLY); |
|
|
127 | }; |
|
|
128 | |
|
|
129 | my $emotes = { |
|
|
130 | growl => { |
|
|
131 | noparams => { |
|
|
132 | other => "<self> growls.", |
|
|
133 | self => "Grrrrrrrrr....", |
|
|
134 | }, |
|
|
135 | params => { |
|
|
136 | }, |
|
|
137 | self => { |
|
|
138 | }, |
|
|
139 | }, |
|
|
140 | giggle => { |
|
|
141 | noparams => { |
|
|
142 | other => "<self> giggles.", |
|
|
143 | self => "You giggle.", |
|
|
144 | }, |
|
|
145 | params => { |
|
|
146 | }, |
|
|
147 | self => { |
|
|
148 | }, |
|
|
149 | }, |
|
|
150 | shiver => { |
|
|
151 | noparams => { |
|
|
152 | other => "<self> shivers uncomfortably.", |
|
|
153 | self => "Brrrrrrrrr.", |
|
|
154 | }, |
|
|
155 | params => { |
|
|
156 | }, |
|
|
157 | self => { |
|
|
158 | }, |
|
|
159 | }, |
|
|
160 | chuckle => { |
|
|
161 | noparams => { |
|
|
162 | other => "<self> chuckles politely.", |
|
|
163 | self => "You chuckle politely", |
|
|
164 | }, |
|
|
165 | params => { |
|
|
166 | }, |
|
|
167 | self => { |
|
|
168 | }, |
|
|
169 | }, |
|
|
170 | sigh => { |
|
|
171 | noparams => { |
|
|
172 | other => "<self> sighs loudly.", |
|
|
173 | self => "You sigh.", |
|
|
174 | }, |
|
|
175 | params => { |
|
|
176 | }, |
|
|
177 | self => { |
|
|
178 | }, |
|
|
179 | }, |
|
|
180 | scream => { |
|
|
181 | noparams => { |
|
|
182 | other => "<self> screams at the top of his lungs!", |
|
|
183 | self => "ARRRRRRRRRRGH!!!!!", |
|
|
184 | }, |
|
|
185 | params => { |
|
|
186 | }, |
|
|
187 | self => { |
|
|
188 | }, |
|
|
189 | }, |
|
|
190 | puke => { |
|
|
191 | noparams => { |
|
|
192 | other => "<self> pukes.", |
|
|
193 | self => "Bleaaaaaghhhhhhh!", |
|
|
194 | }, |
|
|
195 | params => { |
|
|
196 | target => "<self> pukes on your clothes!", |
|
|
197 | other => "<self> pukes on <other>.", |
|
|
198 | self => "You puke on <other>.", |
|
|
199 | }, |
|
|
200 | self => { |
|
|
201 | other => "<self> pukes on his clothes.", |
|
|
202 | self => "You puke on yourself.", |
|
|
203 | }, |
|
|
204 | }, |
|
|
205 | strut => { |
|
|
206 | noparams => { |
|
|
207 | other => "<self> struts proudly.", |
|
|
208 | self => "Strut your stuff.", |
|
|
209 | }, |
|
|
210 | params => { |
|
|
211 | }, |
|
|
212 | self => { |
|
|
213 | }, |
|
|
214 | }, |
|
|
215 | cringe => { |
|
|
216 | noparams => { |
|
|
217 | other => "<self> cringes in terror!", |
|
|
218 | self => "You cringe in terror.", |
|
|
219 | }, |
|
|
220 | params => { |
|
|
221 | target => "<self> cringes away from <other> in mortal terror.", |
|
|
222 | self => "You cringe away from <other>.", |
|
|
223 | }, |
|
|
224 | self => { |
|
|
225 | }, |
|
|
226 | }, |
|
|
227 | hiccup => { |
|
|
228 | noparams => { |
|
|
229 | other => "<self> hiccups.", |
|
|
230 | self => "*HIC*", |
|
|
231 | }, |
|
|
232 | params => { |
|
|
233 | }, |
|
|
234 | self => { |
|
|
235 | }, |
|
|
236 | }, |
|
|
237 | clap => { |
|
|
238 | noparams => { |
|
|
239 | other => "<self> gives a round of applause.", |
|
|
240 | self => "Clap, clap, clap.", |
|
|
241 | }, |
|
|
242 | params => { |
|
|
243 | }, |
|
|
244 | self => { |
|
|
245 | }, |
|
|
246 | }, |
|
|
247 | kiss => { |
|
|
248 | noparams => { |
|
|
249 | other => "<self> makes a weird facial contortion", |
|
|
250 | self => "All the lonely people..", |
|
|
251 | }, |
|
|
252 | params => { |
|
|
253 | target => "<self> kisses you.", |
|
|
254 | other => "<self> kisses <other>.", |
|
|
255 | self => "You kiss <other>.", |
|
|
256 | }, |
|
|
257 | self => { |
|
|
258 | }, |
|
|
259 | }, |
|
|
260 | smother => { |
|
|
261 | noparams => { |
|
|
262 | other => "<self> makes weird facial contortions", |
|
|
263 | self => "All the lonely people..", |
|
|
264 | }, |
|
|
265 | params => { |
|
|
266 | target => "<self> smothers you with kisses.", |
|
|
267 | other => "<self> smothers <other> with kisses.", |
|
|
268 | self => "You smother <other> with kisses.", |
|
|
269 | }, |
|
|
270 | self => { |
|
|
271 | }, |
|
|
272 | }, |
|
|
273 | wink => { |
|
|
274 | noparams => { |
|
|
275 | other => "<self> winks suggestively.", |
|
|
276 | self => "Have you got something in your eye?", |
|
|
277 | }, |
|
|
278 | params => { |
|
|
279 | target => "<self> winks at you.", |
|
|
280 | other => "<self> winks at <other>.", |
|
|
281 | self => "You wink suggestively at <other>.", |
|
|
282 | }, |
|
|
283 | self => { |
|
|
284 | other => "<self> winks at himself - something strange is going on...", |
|
|
285 | self => "You wink at yourself?? What are you up to?", |
|
|
286 | }, |
|
|
287 | }, |
|
|
288 | pout => { |
|
|
289 | noparams => { |
|
|
290 | other => "<self> pouts.", |
|
|
291 | self => "Aww, don't take it so hard.", |
|
|
292 | }, |
|
|
293 | params => { |
|
|
294 | }, |
|
|
295 | self => { |
|
|
296 | }, |
|
|
297 | }, |
|
|
298 | cackle => { |
|
|
299 | noparams => { |
|
|
300 | other => "<self> throws back his head and cackles with insane glee!", |
|
|
301 | self => "You cackle gleefully.", |
|
|
302 | }, |
|
|
303 | params => { |
|
|
304 | }, |
|
|
305 | self => { |
|
|
306 | }, |
|
|
307 | }, |
|
|
308 | sniff => { |
|
|
309 | noparams => { |
|
|
310 | other => "<self> sniffs sadly.", |
|
|
311 | self => "You sniff sadly. *SNIFF*", |
|
|
312 | }, |
|
|
313 | params => { |
|
|
314 | target => "<self> sniffs you.", |
|
|
315 | other => "<self> sniffs <other>", |
|
|
316 | self => "You sniff <other>.", |
|
|
317 | }, |
|
|
318 | self => { |
|
|
319 | other => "<self> sniffs himself.", |
|
|
320 | self => "You sniff yourself.", |
|
|
321 | }, |
|
|
322 | }, |
|
|
323 | nod => { |
|
|
324 | noparams => { |
|
|
325 | other => "<self> nods solemnly.", |
|
|
326 | self => "You nod solemnly.", |
|
|
327 | }, |
|
|
328 | params => { |
|
|
329 | target => "<self> nods solemnly to you.", |
|
|
330 | other => "<self> nods solemnly to <other>.", |
|
|
331 | self => "You nod solemnly to <other>.", |
|
|
332 | }, |
|
|
333 | self => { |
|
|
334 | }, |
|
|
335 | }, |
|
|
336 | frown => { |
|
|
337 | noparams => { |
|
|
338 | other => "<self> frowns.", |
|
|
339 | self => "What's bothering you?", |
|
|
340 | }, |
|
|
341 | params => { |
|
|
342 | target => "<self> frowns darkly at you.", |
|
|
343 | other => "<self> frowns darkly at <other>.", |
|
|
344 | self => "You frown darkly at <other>.", |
|
|
345 | }, |
|
|
346 | self => { |
|
|
347 | other => "<self> frowns at himself.", |
|
|
348 | self => "You frown at yourself.", |
|
|
349 | }, |
|
|
350 | }, |
|
|
351 | snicker => { |
|
|
352 | noparams => { |
|
|
353 | other => "<self> snickers softly.", |
|
|
354 | self => "You snicker softly.", |
|
|
355 | }, |
|
|
356 | params => { |
|
|
357 | }, |
|
|
358 | self => { |
|
|
359 | }, |
|
|
360 | }, |
|
|
361 | shrug => { |
|
|
362 | noparams => { |
|
|
363 | other => "<self> shrugs helplessly.", |
|
|
364 | self => "You shrug.", |
|
|
365 | }, |
|
|
366 | params => { |
|
|
367 | target => "<self> shrugs at you.", |
|
|
368 | other => "<self> shrugs at <other>.", |
|
|
369 | self => "You shrug at <other>.", |
|
|
370 | }, |
|
|
371 | self => { |
|
|
372 | }, |
|
|
373 | }, |
|
|
374 | bleed => { |
|
|
375 | noparams => { |
|
|
376 | other => "<self> is bleeding all over the carpet - got a spare tourniquet?", |
|
|
377 | self => "You bleed all over your nice new armour.", |
|
|
378 | }, |
|
|
379 | params => { |
|
|
380 | target => "<self> slashes his wrist and bleeds all over you.", |
|
|
381 | other => "<self> slashes his wrist and bleeds all over <other>.", |
|
|
382 | self => "You slash your wrist and bleed all over <other>", |
|
|
383 | }, |
|
|
384 | self => { |
|
|
385 | other => "<self> performs some satanic ritual while wiping his blood on himself.", |
|
|
386 | self => "Very impressive! You wipe your blood all over yourself.", |
|
|
387 | }, |
|
|
388 | }, |
|
|
389 | twiddle => { |
|
|
390 | noparams => { |
|
|
391 | other => "<self> patiently twiddles his thumbs.", |
|
|
392 | self => "You patiently twiddle your thumbs.", |
|
|
393 | }, |
|
|
394 | params => { |
|
|
395 | }, |
|
|
396 | self => { |
|
|
397 | }, |
|
|
398 | }, |
|
|
399 | spit => { |
|
|
400 | noparams => { |
|
|
401 | other => "<self> spits over his left shoulder.", |
|
|
402 | self => "You spit over your left shoulder.", |
|
|
403 | }, |
|
|
404 | params => { |
|
|
405 | target => "<self> spits in your face!", |
|
|
406 | other => "<self> spits in <other>'s face.", |
|
|
407 | self => "You spit on <other>.", |
|
|
408 | }, |
|
|
409 | self => { |
|
|
410 | other => "<self> drools all over himself.", |
|
|
411 | self => "You drool all over yourself.", |
|
|
412 | }, |
|
|
413 | }, |
|
|
414 | glare => { |
|
|
415 | noparams => { |
|
|
416 | other => "<self> glares around him.", |
|
|
417 | self => "You glare at nothing in particular.", |
|
|
418 | }, |
|
|
419 | params => { |
|
|
420 | target => "<self> glares icily at you, you feel cold to your bones.", |
|
|
421 | other => "<self> glares at <other>.", |
|
|
422 | self => "You glare icily at <other>.", |
|
|
423 | }, |
|
|
424 | self => { |
|
|
425 | other => "<self> glares at his feet, what is bothering him?", |
|
|
426 | self => "You glare icily at your feet, they are suddenly very cold.", |
|
|
427 | }, |
|
|
428 | }, |
|
|
429 | bow => { |
|
|
430 | noparams => { |
|
|
431 | other => "<self> bows deeply.", |
|
|
432 | self => "You bow deeply.", |
|
|
433 | }, |
|
|
434 | params => { |
|
|
435 | target => "<self> bows before you.", |
|
|
436 | other => "<self> bows before <other>.", |
|
|
437 | self => "You bow before <other>.", |
|
|
438 | }, |
|
|
439 | self => { |
|
|
440 | other => "<self> folds up like a jackknife and kisses his own toes.", |
|
|
441 | self => "You kiss your toes.", |
|
|
442 | }, |
|
|
443 | }, |
|
|
444 | dance => { |
|
|
445 | noparams => { |
|
|
446 | other => "<self> expresses himself through interpretive dance.", |
|
|
447 | self => "You dance with glee.", |
|
|
448 | }, |
|
|
449 | params => { |
|
|
450 | target => "<self> grabs you, and begins dancing!", |
|
|
451 | other => "Yipe! <self> and <other> are doing the Macarena!", |
|
|
452 | self => "You grab <other> and begin doing the Cha-Cha!", |
|
|
453 | }, |
|
|
454 | self => { |
|
|
455 | other => "<self> embraces himself and begins to dance!", |
|
|
456 | self => "You skip and dance around by yourself.", |
|
|
457 | }, |
|
|
458 | }, |
|
|
459 | snore => { |
|
|
460 | noparams => { |
|
|
461 | other => "<self> snores loudly.", |
|
|
462 | self => "Zzzzzzzzzzzzzzz.", |
|
|
463 | }, |
|
|
464 | params => { |
|
|
465 | }, |
|
|
466 | self => { |
|
|
467 | }, |
|
|
468 | }, |
|
|
469 | blush => { |
|
|
470 | noparams => { |
|
|
471 | other => "<self> blushes.", |
|
|
472 | self => "Your cheeks are burning.", |
|
|
473 | }, |
|
|
474 | params => { |
|
|
475 | }, |
|
|
476 | self => { |
|
|
477 | }, |
|
|
478 | }, |
|
|
479 | snap => { |
|
|
480 | noparams => { |
|
|
481 | other => "<self> snaps his fingers.", |
|
|
482 | self => "PRONTO! you snap your fingers.", |
|
|
483 | }, |
|
|
484 | params => { |
|
|
485 | }, |
|
|
486 | self => { |
|
|
487 | }, |
|
|
488 | }, |
|
|
489 | wave => { |
|
|
490 | noparams => { |
|
|
491 | other => "<self> waves happily.", |
|
|
492 | self => "You wave.", |
|
|
493 | }, |
|
|
494 | params => { |
|
|
495 | target => "<self> waves goodbye to you. Have a good journey.", |
|
|
496 | other => "<self> waves goodbye to <other>.", |
|
|
497 | self => "You wave goodbye to <other>.", |
|
|
498 | }, |
|
|
499 | self => { |
|
|
500 | other => "<self> waves goodbye to himself.", |
|
|
501 | self => "Are you going on adventures as well??", |
|
|
502 | }, |
|
|
503 | }, |
|
|
504 | smile => { |
|
|
505 | noparams => { |
|
|
506 | other => "<self> smiles happily.", |
|
|
507 | self => "You smile happily.", |
|
|
508 | }, |
|
|
509 | params => { |
|
|
510 | target => "<self> smiles at you.", |
|
|
511 | other => "<self> beams a smile at <other>.", |
|
|
512 | self => "You smile at <other>.", |
|
|
513 | }, |
|
|
514 | self => { |
|
|
515 | }, |
|
|
516 | }, |
|
|
517 | sneeze => { |
|
|
518 | noparams => { |
|
|
519 | other => "<self> sneezes.", |
|
|
520 | self => "Gesundheit!", |
|
|
521 | }, |
|
|
522 | params => { |
|
|
523 | target => "<self> sneezes on you, you feel the snot cover you. EEEEEEW.", |
|
|
524 | other => "<self> sneezes on <other> and a film of snot covers him.", |
|
|
525 | self => "You sneeze at <other> and a film of snot shoots onto him.", |
|
|
526 | }, |
|
|
527 | self => { |
|
|
528 | other => "<self> sneezes, and covers himself in a slimy substance.", |
|
|
529 | self => "You sneeze on yourself, what a mess!", |
|
|
530 | }, |
|
|
531 | }, |
|
|
532 | bounce => { |
|
|
533 | noparams => { |
|
|
534 | other => "<self> bounces around.", |
|
|
535 | self => "BOIINNNNNNGG!", |
|
|
536 | }, |
|
|
537 | params => { |
|
|
538 | target => "<self> bounces around the room with you.", |
|
|
539 | other => "<self> bounces around the room with <other>.", |
|
|
540 | self => "You bounce around the room with <other>.", |
|
|
541 | }, |
|
|
542 | self => { |
|
|
543 | }, |
|
|
544 | }, |
|
|
545 | shake => { |
|
|
546 | noparams => { |
|
|
547 | other => "<self> shakes his head.", |
|
|
548 | self => "You shake your head.", |
|
|
549 | }, |
|
|
550 | params => { |
|
|
551 | target => "<self> shakes your hand.", |
|
|
552 | other => "<self> shakes <other>'s hand.", |
|
|
553 | self => "You shake <other>'s hand.", |
|
|
554 | }, |
|
|
555 | self => { |
|
|
556 | other => "<self> shakes and quivers like a bowlful of jelly.", |
|
|
557 | self => "You are shaken by yourself.", |
|
|
558 | }, |
|
|
559 | }, |
|
|
560 | lick => { |
|
|
561 | noparams => { |
|
|
562 | other => "<self> licks his mouth and smiles.", |
|
|
563 | self => "You lick your mouth and smile.", |
|
|
564 | }, |
|
|
565 | params => { |
|
|
566 | target => "<self> licks you.", |
|
|
567 | other => "<self> licks <other>.", |
|
|
568 | self => "You lick <other>.", |
|
|
569 | }, |
|
|
570 | self => { |
|
|
571 | other => "<self> licks himself - YUCK.", |
|
|
572 | self => "You lick yourself.", |
|
|
573 | }, |
|
|
574 | }, |
|
|
575 | flip => { |
|
|
576 | noparams => { |
|
|
577 | other => "<self> flips head over heels.", |
|
|
578 | self => "You flip head over heels.", |
|
|
579 | }, |
|
|
580 | params => { |
|
|
581 | }, |
|
|
582 | self => { |
|
|
583 | }, |
|
|
584 | }, |
|
|
585 | think => { |
|
|
586 | noparams => { |
|
|
587 | other => "<self> closes his eyes and thinks really hard.", |
|
|
588 | self => "Anything in particular that you'd care to think about?", |
|
|
589 | }, |
|
|
590 | params => { |
|
|
591 | }, |
|
|
592 | self => { |
|
|
593 | }, |
|
|
594 | }, |
|
|
595 | yawn => { |
|
|
596 | noparams => { |
|
|
597 | other => "<self> yawns sleepily.", |
|
|
598 | self => "You open up your yap and let out a big breeze of stale air.", |
|
|
599 | }, |
|
|
600 | params => { |
|
|
601 | }, |
|
|
602 | self => { |
|
|
603 | }, |
|
|
604 | }, |
|
|
605 | laugh => { |
|
|
606 | noparams => { |
|
|
607 | other => "<self> falls down laughing.", |
|
|
608 | self => "You fall down laughing.", |
|
|
609 | }, |
|
|
610 | params => { |
|
|
611 | target => "<self> looks at you and falls down on the ground laughing.", |
|
|
612 | other => "<self> looks at <other> and falls down on the ground laughing.", |
|
|
613 | self => "You take one look at <other> and fall down laughing.", |
|
|
614 | }, |
|
|
615 | self => { |
|
|
616 | other => "<self> is laughing at something.", |
|
|
617 | self => "Laugh at yourself all you want, the others won't understand.", |
|
|
618 | }, |
|
|
619 | }, |
|
|
620 | burp => { |
|
|
621 | noparams => { |
|
|
622 | other => "<self> burps loudly.", |
|
|
623 | self => "You burp loudly.", |
|
|
624 | }, |
|
|
625 | params => { |
|
|
626 | }, |
|
|
627 | self => { |
|
|
628 | }, |
|
|
629 | }, |
|
|
630 | gasp => { |
|
|
631 | noparams => { |
|
|
632 | other => "<self> gasps in astonishment.", |
|
|
633 | self => "You gasp in astonishment.", |
|
|
634 | }, |
|
|
635 | params => { |
|
|
636 | }, |
|
|
637 | self => { |
|
|
638 | }, |
|
|
639 | }, |
|
|
640 | smirk => { |
|
|
641 | noparams => { |
|
|
642 | other => "<self> smirks.", |
|
|
643 | self => "You smirk.", |
|
|
644 | }, |
|
|
645 | params => { |
|
|
646 | }, |
|
|
647 | self => { |
|
|
648 | }, |
|
|
649 | }, |
|
|
650 | cry => { |
|
|
651 | noparams => { |
|
|
652 | other => "<self> bursts into tears.", |
|
|
653 | self => "Waaaaaaahhh..", |
|
|
654 | }, |
|
|
655 | params => { |
|
|
656 | target => "<self> cries on your shoulder.", |
|
|
657 | other => "<self> cries on <other>'s shoulder.", |
|
|
658 | self => "You cry on <other>'s shoulder.", |
|
|
659 | }, |
|
|
660 | self => { |
|
|
661 | other => "<self> sobs quietly to himself.", |
|
|
662 | self => "You cry to yourself.", |
|
|
663 | }, |
|
|
664 | }, |
|
|
665 | sulk => { |
|
|
666 | noparams => { |
|
|
667 | other => "<self> sulks in the corner.", |
|
|
668 | self => "You sulk.", |
|
|
669 | }, |
|
|
670 | params => { |
|
|
671 | }, |
|
|
672 | self => { |
|
|
673 | }, |
|
|
674 | }, |
|
|
675 | whistle => { |
|
|
676 | noparams => { |
|
|
677 | other => "<self> whistles appreciatively.", |
|
|
678 | self => "You whistle appreciatively.", |
|
|
679 | }, |
|
|
680 | params => { |
|
|
681 | target => "<self> whistles at <other>.", |
|
|
682 | self => "You whistle at <other>.", |
|
|
683 | }, |
|
|
684 | self => { |
|
|
685 | other => "<self> whistles to himself in boredom.", |
|
|
686 | self => "You whistle while you work.", |
|
|
687 | }, |
|
|
688 | }, |
|
|
689 | groan => { |
|
|
690 | noparams => { |
|
|
691 | other => "<self> groans loudly.", |
|
|
692 | self => "You groan loudly.", |
|
|
693 | }, |
|
|
694 | params => { |
|
|
695 | }, |
|
|
696 | self => { |
|
|
697 | }, |
|
|
698 | }, |
|
|
699 | cough => { |
|
|
700 | noparams => { |
|
|
701 | other => "<self> coughs loudly.", |
|
|
702 | self => "Yuck, try to cover your mouth next time!", |
|
|
703 | }, |
|
|
704 | params => { |
|
|
705 | }, |
|
|
706 | self => { |
|
|
707 | }, |
|
|
708 | }, |
|
|
709 | grin => { |
|
|
710 | noparams => { |
|
|
711 | other => "<self> grins evilly.", |
|
|
712 | self => "You grin evilly.", |
|
|
713 | }, |
|
|
714 | params => { |
|
|
715 | target => "<self> grins evilly at you.", |
|
|
716 | other => "<self> grins evilly at <other>.", |
|
|
717 | self => "You grin at <other>.", |
|
|
718 | }, |
|
|
719 | self => { |
|
|
720 | }, |
|
|
721 | }, |
|
|
722 | }; |
|
|
723 | |
|
|
724 | for my $emotion (keys %$emotes) { |
|
|
725 | cf::register_command $emotion => sub { |
|
|
726 | my ($ob, $tname) = @_; |
|
|
727 | |
|
|
728 | my $pl = $ob->contr; |
|
|
729 | |
|
|
730 | cf::async { |
|
|
731 | my $name = $ob->name; |
|
|
732 | $Coro::current->{desc} = "emote handler for $name"; |
|
|
733 | |
|
|
734 | if ($tname eq $name) { |
|
|
735 | my %emote = %{ $emotes->{$emotion}->{self} || {} }; |
|
|
736 | |
|
|
737 | $emote{other} ||= "You look away from <self>."; |
|
|
738 | $emote{self} ||= "My god! Is that LEGAL?"; |
|
|
739 | |
|
|
740 | $emote{other} =~ s/<self>/$name/; |
|
|
741 | |
|
|
742 | send_msg $_, $CHAT_CHANNEL, $emote{other}, cf::NDI_GREY, "msg_chat" |
|
|
743 | for grep { $ob->on_same_map_as ($_->ob) && $_ != $ob} cf::player::list; |
|
|
744 | |
|
|
745 | $pl->send_msg ($emote{self}, cf::NDI_GREY | cf::NDI_REPLY); |
|
|
746 | } elsif ($tname) { |
|
|
747 | my $target = cf::player::find $tname |
|
|
748 | or return send_msg $pl, tell_channel $tname, "$tname is not around.", cf::NDI_DK_ORANGE | cf::NDI_REPLY, "msg_chat"; |
|
|
749 | |
|
|
750 | my %emote = %{ $emotes->{$emotion}->{params} || {} }; |
|
|
751 | |
|
|
752 | $emote{other} ||= "<self> is eyeing <other> quizzically."; |
|
|
753 | $emote{self} ||= "You are still nuts."; |
|
|
754 | $emote{target} ||= "You get the distinct feeling that <other> is nuts."; |
|
|
755 | |
|
|
756 | $emote{self} =~ s/<other>/$tname/; |
|
|
757 | $emote{target} =~ s/<self>/$name/; |
|
|
758 | $emote{other} =~ s/<other>/$tname/; |
|
|
759 | $emote{other} =~ s/<self>/$name/; |
|
|
760 | |
|
|
761 | send_msg $_, $CHAT_CHANNEL, $emote{other}, cf::NDI_GREY, "msg_chat" |
|
|
762 | for grep { $_ != $pl && $_ != $target && $ob->on_same_map_as ($_->ob) } cf::player::list; |
|
|
763 | |
|
|
764 | send_msg $target, tell_channel $name, $emote{target}, cf::NDI_GREY, "msg_shout"; |
|
|
765 | $pl->send_msg (tell_channel $tname, $emote{self}, cf::NDI_GREY | cf::NDI_REPLY); |
|
|
766 | } else { |
|
|
767 | my %emote = %{ $emotes->{$emotion}->{noparams} || {} }; |
|
|
768 | |
|
|
769 | $emote{other} ||= "<self> dances with glee."; |
|
|
770 | $emote{self} ||= "You are a nut."; |
|
|
771 | |
|
|
772 | $emote{other} =~ s/<self>/$name/; |
|
|
773 | |
|
|
774 | send_msg $_, $CHAT_CHANNEL, $emote{other}, cf::NDI_GREY, "msg_chat" |
|
|
775 | for grep { $ob->on_same_map_as ($_->ob) && $_ != $pl } cf::player::list; |
|
|
776 | |
|
|
777 | $pl->send_msg ($CHAT_CHANNEL, $emote{self}, cf::NDI_GREY | cf::NDI_REPLY); |
|
|
778 | } |
|
|
779 | }; |
|
|
780 | }; |
|
|
781 | } |
|
|
782 | |
|
|
783 | cf::register_command me => sub { |
|
|
784 | my ($pl, $msg) = @_; |
|
|
785 | |
|
|
786 | my $name = $pl->name; |
|
|
787 | |
|
|
788 | send_msg $_, $SAY_CHANNEL => "* $name $msg", cf::NDI_GREY | cf::NDI_DEF | ($_ == $pl ? cf::NDI_REPLY : 0), "msg_say" |
|
|
789 | for grep $pl->on_same_map_as ($_->ob), cf::player::list; |
|
|
790 | }; |
|
|
791 | |
53 | cf::register_command say => sub { |
792 | cf::register_command say => sub { |
54 | my ($who, $msg) = @_; |
793 | my ($ob, $msg) = @_; |
55 | |
794 | |
56 | utf8::decode $msg; |
795 | utf8::decode $msg; |
57 | |
796 | |
58 | return if $who->contr->invoke (cf::EVENT_PLAYER_SAY, $msg); |
797 | return if $ob->contr->invoke (cf::EVENT_PLAYER_SAY, $msg); |
59 | |
798 | |
60 | if ($msg) { |
799 | if ($msg) { |
61 | my $name = $who->name; |
800 | my $name = $ob->name; |
62 | |
|
|
63 | utf8::encode $msg; # ->message not yet utf8-ified |
|
|
64 | $_->ob->message ("$name says: $msg", cf::NDI_GREY | cf::NDI_UNIQUE) |
|
|
65 | for grep $who->on_same_map_as ($_->ob), cf::player::list; |
801 | my @plonmap = grep $ob->on_same_map_as ($_->ob), cf::player::list; |
66 | utf8::decode $msg; |
802 | |
|
|
803 | send_msg $_, $SAY_CHANNEL => "$name says: $msg", cf::NDI_GREY, "msg_say" |
|
|
804 | for grep $_ != $ob->contr, @plonmap; |
|
|
805 | $ob->contr->send_msg ($SAY_CHANNEL => "$name says: $msg", cf::NDI_GREY | cf::NDI_REPLY); |
67 | |
806 | |
68 | # npcs, magic_ears etc. |
807 | # npcs, magic_ears etc. |
69 | # first find all objects and theirt-level inventories |
808 | # first find all objects and their first-level inventories |
70 | # within a 5x5 square # that have something resembling |
809 | # within a 5x5 square that have something resembling |
71 | # dialogue or support on_say. |
810 | # dialogue or support on_say. |
72 | my ($map, $x, $y) = ($who->map, $who->x - 2, $who->y - 2); |
811 | my ($map, $x, $y) = ($ob->map, $ob->x - 2, $ob->y - 2); |
73 | |
812 | |
74 | for my $npc ( |
813 | for my $npc ( |
75 | grep +($_->invoke (cf::EVENT_OBJECT_SAY, $who->contr, $msg) && return) || NPC_Dialogue::has_dialogue $_, |
814 | grep +($_->invoke (cf::EVENT_OBJECT_SAY, $ob->contr, $msg) && return) || NPC_Dialogue::has_dialogue $_, |
76 | map +($_, $_->inv), |
815 | map +($_, $_->inv), |
77 | grep $_, |
816 | grep $_, |
78 | map $map->at ($x + $_ % 5, $y + (int $_ / 5)), |
817 | map $map->at ($x + $_ % 5, $y + (int $_ / 5)), |
79 | 0..24 |
818 | 0..24 |
80 | ) { |
819 | ) { |
81 | # if some listener teleported us somewhere else, stop right here |
820 | # if some listener teleported us somewhere else, stop right here |
82 | last unless $map->path == $who->map->path; |
821 | last unless $map->path == $ob->map->path; |
83 | |
822 | |
84 | my $dialog = new NPC_Dialogue ob => $who, npc => $npc; |
823 | my $dialog = new NPC_Dialogue pl => $ob->contr, npc => $npc; |
85 | my ($reply, @kw) = $dialog->tell ($msg); |
824 | my ($reply, @kw) = $dialog->tell ($msg); |
86 | |
825 | |
87 | if (defined $reply) { |
826 | if (defined $reply) { |
88 | if ($npc->type == cf::MAGIC_EAR) { |
827 | if ($npc->type == cf::MAGIC_EAR) { |
89 | if (length $reply) { |
828 | if (length $reply) { |
90 | $_->ob->message ($reply, cf::NDI_BROWN | cf::NDI_UNIQUE) |
829 | send_msg $_, $SAY_CHANNEL => $reply, cf::NDI_BROWN, "msg_say" |
91 | for grep $who->on_same_map_as ($_->ob), cf::player::list; |
830 | for @plonmap; |
92 | } |
831 | } |
93 | $npc->use_trigger; |
832 | $npc->use_trigger; |
94 | } else { |
833 | } else { |
95 | if (length $reply) { |
834 | if (length $reply) { |
96 | $_->ob->message ($npc->name . " says: $reply", cf::NDI_BROWN | cf::NDI_UNIQUE) |
835 | send_msg $_, $SAY_CHANNEL => $npc->name . " says: $reply", cf::NDI_BROWN, "msg_say" |
97 | for grep $who->on_same_map_as ($_->ob), cf::player::list; |
836 | for @plonmap; |
98 | } |
837 | } |
99 | } |
838 | } |
100 | } |
839 | } |
101 | |
840 | |
102 | if (@kw) { |
841 | if (@kw) { |
103 | $_->ob->message ("[further topics: " . (join ", ", @kw) . "]", cf::NDI_BROWN | cf::NDI_UNIQUE) |
842 | $_->send_msg ($SAY_CHANNEL => "[further topics: " . (join ", ", @kw) . "]", cf::NDI_BROWN) |
104 | for grep $who->on_same_map_as ($_->ob), cf::player::list; |
843 | for @plonmap; |
105 | } |
844 | } |
106 | } |
845 | } |
107 | |
846 | |
108 | } else { |
847 | } else { |
109 | $who->message ("What do you want to say?", cf::NDI_UNIQUE); |
848 | $ob->send_msg ($SAY_CHANNEL => "What do you want to say?", cf::NDI_GREY | cf::NDI_REPLY); |
110 | } |
849 | } |
111 | }; |
850 | }; |
112 | |
851 | |
113 | cf::register_command chat => sub { |
852 | cf::register_command chat => sub { |
114 | my ($who, $msg) = @_; |
853 | my ($ob, $msg) = @_; |
115 | |
854 | |
116 | utf8::decode $msg; |
855 | utf8::decode $msg; |
117 | |
856 | |
|
|
857 | my $pl = $ob->contr; |
|
|
858 | |
118 | return if $who->contr->invoke (cf::EVENT_PLAYER_CHAT, $msg); |
859 | return if $pl->invoke (cf::EVENT_PLAYER_CHAT, $msg); |
119 | |
860 | |
120 | if ($msg) { |
861 | if ($msg) { |
121 | my $name = $who->name; |
862 | my $name = $ob->name; |
122 | my $NOW = time; |
863 | my $NOW = time; |
123 | |
864 | |
124 | utf8::encode $msg; # ->message not yet utf8-ified |
|
|
125 | cf::LOG cf::llevDebug, sprintf "QBERT [%s] %s\n", $name, $msg; |
865 | cf::LOG cf::llevDebug, sprintf "QBERT [%s] %s\n", $name, $msg; |
126 | ext::schmorp_irc::do_notice (sprintf "[%s] %s", $name, $msg); |
866 | send_irc ("[%s] %s", $name, $msg); |
127 | |
867 | |
128 | $_->ob->message ("$name chats: $msg", cf::NDI_BLUE) |
868 | send_msg $_, $CHAT_CHANNEL => "$name chats: $msg", cf::NDI_BLUE | cf::NDI_DEF | ($_ == $pl ? cf::NDI_REPLY : 0), "msg_chat" |
129 | for grep { $_->ob->{ext_ignore_shout}{$name} < $NOW && $_->listening >= 10 } cf::player::list; |
869 | for grep { $_->ob->{ext_ignore_shout}{$name} < $NOW && $_->listening >= 10 } cf::player::list; |
130 | |
870 | |
131 | } else { |
871 | } else { |
132 | $who->message ("Chat what?", cf::NDI_UNIQUE); |
872 | $pl->send_msg ($CHAT_CHANNEL => "Chat what?", cf::NDI_BLUE | cf::NDI_DEF | cf::NDI_REPLY); |
133 | } |
873 | } |
134 | }; |
874 | }; |
135 | |
875 | |
136 | cf::register_command shout => sub { |
876 | cf::register_command shout => sub { |
137 | my ($who, $msg) = @_; |
877 | my ($ob, $msg) = @_; |
138 | |
878 | |
139 | utf8::decode $msg; |
879 | utf8::decode $msg; |
140 | |
880 | |
|
|
881 | my $pl = $ob->contr; |
|
|
882 | |
141 | return if $who->contr->invoke (cf::EVENT_PLAYER_SHOUT, $msg); |
883 | return if $pl->invoke (cf::EVENT_PLAYER_SHOUT, $msg); |
142 | |
884 | |
143 | if ($msg) { |
885 | if ($msg) { |
144 | my $NOW = time; |
886 | my $NOW = time; |
145 | my $name = $who->name; |
887 | my $name = $ob->name; |
146 | |
888 | |
147 | cf::LOG cf::llevDebug, sprintf "QBERT {%s} %s\n", $name, $msg; |
889 | cf::LOG cf::llevDebug, sprintf "QBERT {%s} %s\n", $name, $msg; |
148 | ext::schmorp_irc::do_notice (sprintf "\007\0034{%s} %s\n", $name, $msg); |
890 | send_irc ("\007\0034{%s} %s\n", $name, $msg); |
149 | |
891 | |
150 | utf8::encode $msg; # ->message not yet utf8-ified |
892 | send_msg $_, $CHAT_CHANNEL => "$name shouts: $msg", cf::NDI_RED | cf::NDI_DEF | ($_ == $pl ? cf::NDI_REPLY : 0), "msg_shout" |
151 | $_->ob->message ("$name shouts: $msg", cf::NDI_RED) |
|
|
152 | for grep { $_->ob->{ext_ignore_shout}{$name} < $NOW && $_->listening >= 2 } cf::player::list; |
893 | for grep { $_->ob->{ext_ignore_shout}{$name} < $NOW && $_->listening >= 2 } cf::player::list; |
153 | |
894 | |
154 | } else { |
895 | } else { |
155 | $who->message ("Shout what?", cf::NDI_UNIQUE); |
896 | $pl->send_msg ($CHAT_CHANNEL => "Shout what?", cf::NDI_RED | cf::NDI_DEF | cf::NDI_REPLY); |
156 | } |
897 | } |
157 | |
|
|
158 | }; |
898 | }; |
159 | |
899 | |
160 | cf::register_command tell => sub { |
900 | cf::register_command tell => sub { |
161 | my ($who, $args) = @_; |
901 | my ($ob, $args) = @_; |
162 | my ($target, $msg) = split /\s+/, $args, 2; |
902 | my ($target, $msg) = split /\s+/, $args, 2; |
163 | |
903 | |
164 | utf8::decode $msg; |
904 | utf8::decode $msg; |
165 | |
905 | |
166 | return if $who->contr->invoke (cf::EVENT_PLAYER_TELL, $target, $msg); |
906 | my $pl = $ob->contr; |
167 | |
907 | my $ns = $pl->ns |
|
|
908 | or return; |
168 | my $name = $who->name; |
909 | my $name = $ob->name; |
|
|
910 | |
|
|
911 | return if $pl->invoke (cf::EVENT_PLAYER_TELL, $target, $msg); |
|
|
912 | |
|
|
913 | my $pl_channel = tell_channel $target; |
169 | |
914 | |
170 | if ($target =~ /irc\//) { |
915 | if ($target =~ /irc\//) { |
171 | my (undef, $nick) = split /\//, $target, 2; |
916 | my (undef, $nick) = split /\//, $target, 2; |
172 | $who->message ("You tell $target: $args"); |
917 | $ns->send_msg ($pl_channel => "You tell $target: $args", cf::NDI_DK_ORANGE | cf::NDI_DEF | cf::NDI_REPLY); |
173 | ext::schmorp_irc::do_notice (sprintf "(%s) %s: %s\n", $name, $nick, $msg); |
918 | send_irc ("(%s) %s: %s\n", $name, $nick, $msg); |
|
|
919 | |
174 | } elsif (my $other = cf::player::find $target) { |
920 | } elsif (my $other = cf::player::find_active $target) { |
|
|
921 | my $other_channel = tell_channel $name; |
175 | |
922 | |
176 | if ($msg) { |
923 | if ($msg) { |
177 | if ($target eq $name) { |
924 | if ($target eq $name) { |
178 | $who->message ("You are talking to yourself, you freak!", cf::NDI_UNIQUE); |
925 | $ns->send_msg ($pl_channel => "You are talking to yourself, you freak!", cf::NDI_DK_ORANGE | cf::NDI_DEF | cf::NDI_REPLY); |
179 | } elsif ($other->ob->{ext_ignore_tell}{$name} >= time) { |
926 | } elsif ($other->ob->{ext_ignore_tell}{$name} >= time) { |
180 | $who->message ("$target ignores what you say. Give up on it.", cf::NDI_UNIQUE); |
927 | $ns->send_msg ($pl_channel => "$target ignores what you say. Give up on it.", cf::NDI_DK_ORANGE | cf::NDI_DEF | cf::NDI_REPLY); |
181 | } else { |
928 | } else { |
182 | utf8::encode $msg; # ->message not yet utf8-ified |
929 | return if $other->invoke (cf::EVENT_PLAYER_TOLD, $pl, $msg); |
183 | cf::LOG cf::llevDebug, sprintf "TELL [%s>%s] %s\n", $name, $target, $msg; |
930 | cf::LOG cf::llevDebug, sprintf "TELL [%s>%s] %s\n", $name, $target, $msg; |
184 | |
931 | |
185 | $who->message ("You tell $target: $msg"); |
932 | $ns->send_msg ($pl_channel => "You tell $target: $msg", cf::NDI_DK_ORANGE | cf::NDI_DEF | cf::NDI_REPLY); |
186 | $other->ob->message ("$name tells you: $msg"); |
933 | send_msg $other, $other_channel => "$name tells you: $msg", cf::NDI_DK_ORANGE | cf::NDI_DEF, "msg_tell"; |
187 | $other->ob->{ext_last_tell} = $name; |
|
|
188 | } |
934 | } |
189 | } else { |
935 | } else { |
190 | $who->message ("What do you want to tell $target?", cf::NDI_UNIQUE); |
936 | $ns->send_msg ($pl_channel => "What do you want to tell $target?", cf::NDI_DK_ORANGE | cf::NDI_DEF | cf::NDI_REPLY); |
191 | } |
937 | } |
192 | |
938 | |
193 | } else { |
939 | } else { |
194 | $who->message ("No such player. Your message: $msg", cf::NDI_UNIQUE); |
940 | $ns->send_msg ($pl_channel => "No such player. Your message: $msg", cf::NDI_DK_ORANGE | cf::NDI_DEF | cf::NDI_REPLY); |
195 | } |
941 | } |
196 | }; |
942 | }; |
197 | |
943 | |
198 | cf::register_command reply => sub { |
944 | cf::register_command ignore => sub { |
199 | my ($who, $args) = @_; |
945 | my ($pl, $args) = @_; |
200 | my $name = $who->name; |
946 | my ($target, $type, $timeout) = split /\s+/, $args; |
201 | |
947 | |
202 | utf8::decode $args; |
948 | if ($args eq "list") { |
|
|
949 | clean_timeouts $pl; |
203 | |
950 | |
204 | return if $who->contr->invoke (cf::EVENT_PLAYER_TELL, $who->{ext_last_tell}, $args); |
951 | if ((my @ignored_tell = sort keys %{$pl->{ext_ignore_tell}}) |
|
|
952 | + (my @ignored_shout = sort keys %{$pl->{ext_ignore_shout}})) { |
|
|
953 | $pl->message ("Currently ignoring private messages from: ", cf::NDI_REPLY); |
|
|
954 | $pl->message ((join ", ", @ignored_tell), cf::NDI_REPLY); |
|
|
955 | $pl->message ("Currently ignoring shouts from: ", cf::NDI_REPLY); |
|
|
956 | $pl->message ((join ", ", @ignored_shout), cf::NDI_REPLY); |
|
|
957 | $pl->message ("To stop ignoring one, use unignore.", cf::NDI_REPLY); |
|
|
958 | } else { |
|
|
959 | $pl->message ("Not ignoring anyone", cf::NDI_REPLY); |
|
|
960 | } |
205 | |
961 | |
206 | if ($who->{ext_last_tell} =~ /irc\//) { |
962 | } elsif ($target && $type) { |
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); |
|
|
210 | } elsif (my $other = cf::player::find $who->{ext_last_tell}) { |
|
|
211 | |
963 | |
212 | if ($args) { |
964 | $timeout ne "" or $timeout = 24; |
213 | $other->ob->{ext_ignore_tell}{$name} >= time |
965 | my $absolute_timeout = time + $timeout * 3600; |
214 | or delete $other->ob->{ext_ignore_tell}{$name}; |
|
|
215 | |
966 | |
216 | if ($other->ob->{ext_ignore_tell}{$name} < time) { |
967 | if (cf::player::exists $target) { |
217 | utf8::encode $args; # ->message not yet utf8-ified |
968 | if ($type eq "tell") { |
218 | cf::LOG cf::llevDebug, sprintf "TELL [%s>%s] %s\n", $name, $other->ob->name, $args; |
969 | $pl->message ("Now ignoring private messages from $target for $timeout hours.", cf::NDI_REPLY); |
219 | |
970 | $pl->{ext_ignore_tell}{$target} = $absolute_timeout; |
220 | $who->message ("You tell " . $other->ob->name . ": $args"); |
971 | } elsif ($type eq "shout") { |
221 | $other->ob->message ("$name tells you: $args"); |
972 | $pl->message ("Now ignoring shouts from $target for $timeout hours.", cf::NDI_REPLY); |
222 | $who->{ext_last_tell} = $other->ob->name; |
973 | $pl->{ext_ignore_shout}{$target} = $absolute_timeout; |
|
|
974 | } elsif ($type eq "all") { |
|
|
975 | $pl->message ("Now ignoring everything from $target for $timeout hours.", cf::NDI_REPLY); |
|
|
976 | $pl->{ext_ignore_tell}{$target} = $absolute_timeout; |
|
|
977 | $pl->{ext_ignore_shout}{$target} = $absolute_timeout; |
223 | } else { |
978 | } else { |
224 | $who->message ($other->ob->name . " ignores what you say. Give up on it.", cf::NDI_UNIQUE); |
979 | $pl->message ("You need to specify tell, shout or all.", cf::NDI_REPLY); |
225 | } |
980 | } |
226 | } else { |
981 | } else { |
227 | $who->message ("What do you want to tell ".$other->ob->name."?", cf::NDI_UNIQUE); |
982 | $pl->message ("No such player: $target", cf::NDI_REPLY); |
228 | } |
983 | } |
229 | |
984 | |
230 | } else { |
985 | } else { |
231 | $who->message ("Can't reply, player left. Your message: $args".$who->{ext_last_tell}, cf::NDI_UNIQUE); |
|
|
232 | } |
|
|
233 | }; |
|
|
234 | |
|
|
235 | cf::register_command ignore => sub { |
|
|
236 | my ($who, $args) = @_; |
|
|
237 | my ($target, $type, $timeout) = split /\s+/, $args; |
|
|
238 | |
|
|
239 | if ($args eq "list") { |
|
|
240 | clean_timeouts $who; |
|
|
241 | |
|
|
242 | if ((my @ignored_tell = sort keys %{$who->{ext_ignore_tell}}) |
|
|
243 | + (my @ignored_shout = sort keys %{$who->{ext_ignore_shout}})) { |
|
|
244 | $who->message ("Currently ignoring private messages from: ", cf::NDI_UNIQUE); |
|
|
245 | $who->message ((join ", ", @ignored_tell), cf::NDI_UNIQUE); |
|
|
246 | $who->message ("Currently ignoring shouts from: ", cf::NDI_UNIQUE); |
|
|
247 | $who->message ((join ", ", @ignored_shout), cf::NDI_UNIQUE); |
|
|
248 | $who->message ("To stop ignoring one, use unignore.", cf::NDI_UNIQUE); |
|
|
249 | } else { |
|
|
250 | $who->message ("Not ignoring anyone", cf::NDI_UNIQUE); |
|
|
251 | } |
|
|
252 | |
|
|
253 | } elsif ($target && $type) { |
|
|
254 | |
|
|
255 | $timeout ne "" or $timeout = 24; |
|
|
256 | my $absolute_timeout = time + $timeout * 3600; |
|
|
257 | |
|
|
258 | if (cf::player::exists $target) { |
|
|
259 | if ($type eq "tell") { |
|
|
260 | $who->message ("Now ignoring private messages from $target for $timeout hours.", cf::NDI_UNIQUE); |
|
|
261 | $who->{ext_ignore_tell}{$target} = $absolute_timeout; |
|
|
262 | } elsif ($type eq "shout") { |
|
|
263 | $who->message ("Now ignoring shouts from $target for $timeout hours.", cf::NDI_UNIQUE); |
|
|
264 | $who->{ext_ignore_shout}{$target} = $absolute_timeout; |
|
|
265 | } elsif ($type eq "all") { |
|
|
266 | $who->message ("Now ignoring everything from $target for $timeout hours.", cf::NDI_UNIQUE); |
|
|
267 | $who->{ext_ignore_tell}{$target} = $absolute_timeout; |
|
|
268 | $who->{ext_ignore_shout}{$target} = $absolute_timeout; |
|
|
269 | } else { |
|
|
270 | $who->message ("You need to specify tell, shout or all.", cf::NDI_UNIQUE); |
|
|
271 | } |
|
|
272 | } else { |
|
|
273 | $who->message ("No such player: $target", cf::NDI_UNIQUE); |
|
|
274 | } |
|
|
275 | |
|
|
276 | } else { |
|
|
277 | $who->message ("Usage: ignore <player> <tell|shout|all> <timeout>\n" |
986 | $pl->message ("Usage: ignore <player> <tell|shout|all> <timeout>\n" |
278 | . "will ignore a player for <timeout> hours.\n" |
987 | . "will ignore a player for <timeout> hours.\n" |
279 | . "Usage: ignore list\n" |
988 | . "Usage: ignore list\n" |
280 | . "will show you a list of players currently ignored.", cf::NDI_UNIQUE); |
989 | . "will show you a list of players currently ignored.", cf::NDI_REPLY); |
281 | } |
990 | } |
282 | }; |
991 | }; |
283 | |
992 | |
284 | cf::register_command unignore => sub { |
993 | cf::register_command unignore => sub { |
285 | my ($who, $args) = @_; |
994 | my ($pl, $args) = @_; |
286 | my ($target, $type) = split /\s+/, $args; |
995 | my ($target, $type) = split /\s+/, $args; |
287 | |
996 | |
288 | if ($args eq "") { |
997 | if ($args eq "") { |
289 | if ($who->{ext_ignore_tell}) { |
998 | if ($pl->{ext_ignore_tell}) { |
290 | $who->message ("Currently ignoring private messages from: ", cf::NDI_UNIQUE); |
999 | $pl->message ("Currently ignoring private messages from: ", cf::NDI_REPLY); |
291 | $who->message ((join ", ", sort keys %{ $who->{ext_ignore_tell} }), cf::NDI_UNIQUE); |
1000 | $pl->message ((join ", ", sort keys %{ $pl->{ext_ignore_tell} }), cf::NDI_REPLY); |
292 | $who->message ("Currently ignoring shouts from: ", cf::NDI_UNIQUE); |
1001 | $pl->message ("Currently ignoring shouts from: ", cf::NDI_REPLY); |
293 | $who->message ((join ", ", sort keys %{ $who->{ext_ignore_shout} }), cf::NDI_UNIQUE); |
1002 | $pl->message ((join ", ", sort keys %{ $pl->{ext_ignore_shout} }), cf::NDI_REPLY); |
294 | } else { |
1003 | } else { |
295 | $who->message ("Not ignoring anyone", cf::NDI_UNIQUE); |
1004 | $pl->message ("Not ignoring anyone", cf::NDI_REPLY); |
296 | } |
1005 | } |
297 | } else { |
1006 | } else { |
298 | if (cf::player::exists $target) { |
1007 | if (cf::player::exists $target) { |
299 | if ($type eq "tell") { |
1008 | if ($type eq "tell") { |
300 | $who->message ("Not ignoring private messages from $target anymore.", cf::NDI_UNIQUE); |
1009 | $pl->message ("Not ignoring private messages from $target anymore.", cf::NDI_REPLY); |
301 | delete $who->{ext_ignore_tell} {$target}; |
1010 | delete $pl->{ext_ignore_tell} {$target}; |
302 | } elsif ($type eq "shout") { |
1011 | } elsif ($type eq "shout") { |
303 | $who->message ("Not ignoring shouts from $target anymore.", cf::NDI_UNIQUE); |
1012 | $pl->message ("Not ignoring shouts from $target anymore.", cf::NDI_REPLY); |
304 | delete $who->{ext_ignore_shout}{$target}; |
1013 | delete $pl->{ext_ignore_shout}{$target}; |
305 | } elsif ($type eq "all") { |
1014 | } elsif ($type eq "all") { |
306 | $who->message ("Not ignoring anything from $target anymore.", cf::NDI_UNIQUE); |
1015 | $pl->message ("Not ignoring anything from $target anymore.", cf::NDI_REPLY); |
307 | delete $who->{ext_ignore_tell} {$target}; |
1016 | delete $pl->{ext_ignore_tell} {$target}; |
308 | delete $who->{ext_ignore_shout}{$target}; |
1017 | delete $pl->{ext_ignore_shout}{$target}; |
309 | } else { |
1018 | } else { |
310 | $who->message ("You need to specify tell, shout or all.", cf::NDI_UNIQUE); |
1019 | $pl->message ("You need to specify tell, shout or all.", cf::NDI_REPLY); |
311 | } |
1020 | } |
312 | } else { |
1021 | } else { |
313 | $who->message ("No such player or ambiguous name: $target", cf::NDI_UNIQUE); |
1022 | $pl->message ("No such player or ambiguous name: $target", cf::NDI_REPLY); |
314 | } |
1023 | } |
315 | } |
1024 | } |
316 | }; |
1025 | }; |
317 | |
1026 | |
318 | cf::register_command seen => sub { |
|
|
319 | my ($who, $args) = @_; |
|
|
320 | |
|
|
321 | if (my ($login) = $args =~ /(\S+)/) { |
|
|
322 | if ($login eq $who->name) { |
|
|
323 | $who->message ("Very funny, $login. Ha. Ha.", cf::NDI_UNIQUE); |
|
|
324 | } elsif (cf::player::find $login) { |
|
|
325 | $who->message ("$login is right here on this server!", cf::NDI_UNIQUE); |
|
|
326 | } elsif (cf::player::exists $login |
|
|
327 | and stat sprintf "%s/%s/%s/%s.pl", cf::localdir, cf::playerdir, ($login) x 2) { |
|
|
328 | my $time = (stat _)[9]; |
|
|
329 | |
|
|
330 | $who->message ("$login was last seen here " |
|
|
331 | . (POSIX::strftime "%Y-%m-%d %H:%M:%S +0000", gmtime $time) |
|
|
332 | . " which was " . (int +(time - $time) / 3600) . " hours ago.", cf::NDI_UNIQUE); |
|
|
333 | } else { |
|
|
334 | $who->message ("No player named $login is known to me.", cf::NDI_UNIQUE); |
|
|
335 | } |
|
|
336 | } else { |
|
|
337 | $who->message ("Usage: seen <player>", cf::NDI_UNIQUE); |
|
|
338 | } |
|
|
339 | }; |
|
|
340 | |
|
|