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