ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/ext/chat.ext
(Generate patch)

Comparing deliantra/server/ext/chat.ext (file contents):
Revision 1.33 by root, Wed Sep 19 21:56:30 2007 UTC vs.
Revision 1.44 by root, Fri Sep 19 01:39:45 2008 UTC

1#! perl # depends=irc mandatory 1#! perl # depends=irc mandatory
2 2
3# 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 commands
4# adds ignore/unignore functionality 4# adds ignore/unignore functionality
5 5
6use NPC_Dialogue; 6use NPC_Dialogue;
7use POSIX (); # for strftime only 7use POSIX (); # for strftime only
8
9our $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
16our $CHAT_CHANNEL = {
17 id => "chat",
18 title => "Chat",
19 reply => "chat ",
20 tooltip => "Player chat and shouts, global to the server.",
21};
22 8
23sub tell_channel($) { 9sub tell_channel($) {
24 my ($target) = @_; 10 my ($target) = @_;
25 11
26 { 12 {
27 id => "tell-$target", 13 id => "tell-$target",
28 title => "$target", 14 title => "$target",
29 reply => "tell $target ", 15 reply => "tell $target ",
30 tooltip => "Private messages from/to $target", 16 tooltip => "Private messages from/to $target",
31 } 17 }
18}
19
20sub 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 ()
32} 25}
33 26
34sub clean_timeouts($) { 27sub clean_timeouts($) {
35 my ($player) = @_; 28 my ($player) = @_;
36 my $NOW = time; 29 my $NOW = time;
63 on_login => sub { 56 on_login => sub {
64 my ($pl) = @_; 57 my ($pl) = @_;
65 58
66 clean_timeouts $pl->ob; 59 clean_timeouts $pl->ob;
67 60
68 $pl->send_msg ($SAY_CHANNEL); 61 $pl->send_msg ($cf::SAY_CHANNEL);
69 $pl->send_msg ($CHAT_CHANNEL); 62 $pl->send_msg ($cf::CHAT_CHANNEL);
70 }, 63 },
71); 64);
72 65
66# TODO: remove once safe
73cf::register_command listen => sub { 67cf::register_command listen => sub {
74 my ($pl, $msg) = @_;
75 my $player = cf::player::find_active $pl->name;
76
77 if ($msg ne "") {
78 $msg = 10 if $msg > 10;
79
80 my $prev_listen = $player->listening;
81 $player->listening ($msg);
82 if ($prev_listen == $player->listening) {
83 $pl->message ("Your verbose level stays at $prev_listen.", cf::NDI_REPLY);
84 } else {
85 $pl->message ("Your verbose level is now " . $player->listening . ". (previously: $prev_listen)", cf::NDI_REPLY);
86 }
87 } else {
88 $pl->message ("Your verbose level is " . $player->listening . ".", cf::NDI_REPLY);
89 }
90}; 68};
91 69
92cf::register_command cointoss => sub { 70cf::register_command cointoss => sub {
93 my ($ob, $msg) = @_; 71 my ($ob, $msg) = @_;
94 72
95 my $pl = $ob->contr; 73 my $pl = $ob->contr;
96 my $name = $ob->name; 74 my $name = $ob->name;
97 75
98 my $coin = int rand 2 ? "Heads" : "Tails"; 76 my $coin = int rand 2 ? "Heads" : "Tails";
99 77
100 $_->send_msg ($SAY_CHANNEL => "$name flips a coin.... $coin!", cf::NDI_GREY) 78 send_msg $_, $cf::SAY_CHANNEL => "$name flips a coin.... $coin!", cf::NDI_GREY, "msg_say"
101 for grep { $ob->on_same_map_as ($_->ob) && $_ != $pl} cf::player::list; 79 for grep { $ob->on_same_map_as ($_->ob) && $_ != $pl} cf::player::list;
102 80
103 $pl->send_msg ($SAY_CHANNEL => "You flip a coin.... $coin!", cf::NDI_GREY | cf::NDI_REPLY); 81 $pl->send_msg ($cf::SAY_CHANNEL => "You flip a coin.... $coin!", cf::NDI_GREY | cf::NDI_REPLY);
104}; 82};
105 83
106cf::register_command orcknuckle => sub { 84cf::register_command orcknuckle => sub {
107 my ($ob, $msg) = @_; 85 my ($ob, $msg) = @_;
108 86
111 89
112 my @orcknuckle = ("beholder", "ghost", "knight", "princess", "dragon", "orc"); 90 my @orcknuckle = ("beholder", "ghost", "knight", "princess", "dragon", "orc");
113 my ($i, $j, $k, $l) = (rand 5, rand 5, rand 5, rand 6); 91 my ($i, $j, $k, $l) = (rand 5, rand 5, rand 5, rand 6);
114 my $result = "$orcknuckle[$i], $orcknuckle[$j], $orcknuckle[$k], $orcknuckle[$l]"; 92 my $result = "$orcknuckle[$i], $orcknuckle[$j], $orcknuckle[$k], $orcknuckle[$l]";
115 93
116 $_->send_msg ($SAY_CHANNEL => "$name throws his orc-knuckles and rolls $result!", cf::NDI_GREY) 94 send_msg $_, $cf::SAY_CHANNEL => "$name throws his orc-knuckles and rolls $result!", cf::NDI_GREY, "msg_say"
117 for grep { $ob->on_same_map_as ($_->ob) && $_ != $pl} cf::player::list; 95 for grep { $ob->on_same_map_as ($_->ob) && $_ != $pl} cf::player::list;
118 96
119 $pl->send_msg ($SAY_CHANNEL => "You roll $result!", cf::NDI_GREY | cf::NDI_REPLY); 97 $pl->send_msg ($cf::SAY_CHANNEL => "You roll $result!", cf::NDI_GREY | cf::NDI_REPLY);
120}; 98};
121 99
122my $emotes = { 100my $emotes = {
123 growl => { 101 growl => {
124 noparams => { 102 noparams => {
170 self => { 148 self => {
171 }, 149 },
172 }, 150 },
173 scream => { 151 scream => {
174 noparams => { 152 noparams => {
175 other => "<self> screams at the top of his lungs!", 153 other => "<self> screams at the top of G<his|her> lungs!",
176 self => "ARRRRRRRRRRGH!!!!!", 154 self => "ARRRRRRRRRRGH!!!!!",
177 }, 155 },
178 params => { 156 params => {
179 }, 157 },
180 self => { 158 self => {
189 target => "<self> pukes on your clothes!", 167 target => "<self> pukes on your clothes!",
190 other => "<self> pukes on <other>.", 168 other => "<self> pukes on <other>.",
191 self => "You puke on <other>.", 169 self => "You puke on <other>.",
192 }, 170 },
193 self => { 171 self => {
194 other => "<self> pukes on his clothes.", 172 other => "<self> pukes on G<his|her> clothes.",
195 self => "You puke on yourself.", 173 self => "You puke on yourself.",
196 }, 174 },
197 }, 175 },
198 strut => { 176 strut => {
199 noparams => { 177 noparams => {
248 self => "You kiss <other>.", 226 self => "You kiss <other>.",
249 }, 227 },
250 self => { 228 self => {
251 }, 229 },
252 }, 230 },
231 smother => {
232 noparams => {
233 other => "<self> makes weird facial contortions",
234 self => "All the lonely people..",
235 },
236 params => {
237 target => "<self> smothers you with kisses.",
238 other => "<self> smothers <other> with kisses.",
239 self => "You smother <other> with kisses.",
240 },
241 self => {
242 },
243 },
253 wink => { 244 wink => {
254 noparams => { 245 noparams => {
255 other => "<self> winks suggestively.", 246 other => "<self> winks suggestively.",
256 self => "Have you got something in your eye?", 247 self => "Have you got something in your eye?",
257 }, 248 },
259 target => "<self> winks at you.", 250 target => "<self> winks at you.",
260 other => "<self> winks at <other>.", 251 other => "<self> winks at <other>.",
261 self => "You wink suggestively at <other>.", 252 self => "You wink suggestively at <other>.",
262 }, 253 },
263 self => { 254 self => {
264 other => "<self> winks at himself - something strange is going on...", 255 other => "<self> winks at G<him|her>self - something strange is going on...",
265 self => "You wink at yourself?? What are you up to?", 256 self => "You wink at yourself?? What are you up to?",
266 }, 257 },
267 }, 258 },
268 pout => { 259 pout => {
269 noparams => { 260 noparams => {
275 self => { 266 self => {
276 }, 267 },
277 }, 268 },
278 cackle => { 269 cackle => {
279 noparams => { 270 noparams => {
280 other => "<self> throws back his head and cackles with insane glee!", 271 other => "<self> throws back G<his|her> head and cackles with insane glee!",
281 self => "You cackle gleefully.", 272 self => "You cackle gleefully.",
282 }, 273 },
283 params => { 274 params => {
284 }, 275 },
285 self => { 276 self => {
294 target => "<self> sniffs you.", 285 target => "<self> sniffs you.",
295 other => "<self> sniffs <other>", 286 other => "<self> sniffs <other>",
296 self => "You sniff <other>.", 287 self => "You sniff <other>.",
297 }, 288 },
298 self => { 289 self => {
299 other => "<self> sniffs himself.", 290 other => "<self> sniffs G<him|her>self.",
300 self => "You sniff yourself.", 291 self => "You sniff yourself.",
301 }, 292 },
302 }, 293 },
303 nod => { 294 nod => {
304 noparams => { 295 noparams => {
305 other => "<self> nods solemnly.", 296 other => "<self> nods solemnly.",
306 self => "You nod solemnly.", 297 self => "You nod solemnly.",
307 }, 298 },
308 params => { 299 params => {
309 target => "<self> nods solemnly to you.", 300 target => "<self> nods solemnly at you.",
310 other => "<self> nods solemnly to <other>.", 301 other => "<self> nods solemnly at <other>.",
311 self => "You nod solemnly to <other>.", 302 self => "You nod solemnly at <other>.",
312 }, 303 },
313 self => { 304 self => {
314 }, 305 },
315 }, 306 },
316 frown => { 307 frown => {
322 target => "<self> frowns darkly at you.", 313 target => "<self> frowns darkly at you.",
323 other => "<self> frowns darkly at <other>.", 314 other => "<self> frowns darkly at <other>.",
324 self => "You frown darkly at <other>.", 315 self => "You frown darkly at <other>.",
325 }, 316 },
326 self => { 317 self => {
327 other => "<self> frowns at himself.", 318 other => "<self> frowns at G<him|her>self.",
328 self => "You frown at yourself.", 319 self => "You frown at yourself.",
329 }, 320 },
330 }, 321 },
331 snicker => { 322 snicker => {
332 noparams => { 323 noparams => {
355 noparams => { 346 noparams => {
356 other => "<self> is bleeding all over the carpet - got a spare tourniquet?", 347 other => "<self> is bleeding all over the carpet - got a spare tourniquet?",
357 self => "You bleed all over your nice new armour.", 348 self => "You bleed all over your nice new armour.",
358 }, 349 },
359 params => { 350 params => {
360 target => "<self> slashes his wrist and bleeds all over you.", 351 target => "<self> slashes G<his|her> wrist and bleeds all over you.",
361 other => "<self> slashes his wrist and bleeds all over <other>.", 352 other => "<self> slashes G<his|her> wrist and bleeds all over <other>.",
362 self => "You slash your wrist and bleed all over <other>", 353 self => "You slash your wrist and bleed all over <other>",
363 }, 354 },
364 self => { 355 self => {
365 other => "<self> performs some satanic ritual while wiping his blood on himself.", 356 other => "<self> performs some satanic ritual while wiping G<his|her> blood on G<him|her>self.",
366 self => "Very impressive! You wipe your blood all over yourself.", 357 self => "Very impressive! You wipe your blood all over yourself.",
367 }, 358 },
368 }, 359 },
369 twiddle => { 360 twiddle => {
370 noparams => { 361 noparams => {
371 other => "<self> patiently twiddles his thumbs.", 362 other => "<self> patiently twiddles G<his|her> thumbs.",
372 self => "You patiently twiddle your thumbs.", 363 self => "You patiently twiddle your thumbs.",
373 }, 364 },
374 params => { 365 params => {
375 }, 366 },
376 self => { 367 self => {
377 }, 368 },
378 }, 369 },
379 spit => { 370 spit => {
380 noparams => { 371 noparams => {
381 other => "<self> spits over his left shoulder.", 372 other => "<self> spits over G<his|her> left shoulder.",
382 self => "You spit over your left shoulder.", 373 self => "You spit over your left shoulder.",
383 }, 374 },
384 params => { 375 params => {
385 target => "<self> spits in your face!", 376 target => "<self> spits in your face!",
386 other => "<self> spits in <other>'s face.", 377 other => "<self> spits in <other>'s face.",
387 self => "You spit on <other>.", 378 self => "You spit on <other>.",
388 }, 379 },
389 self => { 380 self => {
390 other => "<self> drools all over himself.", 381 other => "<self> drools all over G<him|her>self.",
391 self => "You drool all over yourself.", 382 self => "You drool all over yourself.",
392 }, 383 },
393 }, 384 },
394 glare => { 385 glare => {
395 noparams => { 386 noparams => {
396 other => "<self> glares around him.", 387 other => "<self> glares around G<him|her>.",
397 self => "You glare at nothing in particular.", 388 self => "You glare at nothing in particular.",
398 }, 389 },
399 params => { 390 params => {
400 target => "<self> glares icily at you, you feel cold to your bones.", 391 target => "<self> glares icily at you, you feel cold to your bones.",
401 other => "<self> glares at <other>.", 392 other => "<self> glares at <other>.",
402 self => "You glare icily at <other>.", 393 self => "You glare icily at <other>.",
403 }, 394 },
404 self => { 395 self => {
405 other => "<self> glares at his feet, what is bothering him?", 396 other => "<self> glares at G<his|her> feet, what is bothering G<him|her>?",
406 self => "You glare icily at your feet, they are suddenly very cold.", 397 self => "You glare icily at your feet, they are suddenly very cold.",
407 }, 398 },
408 }, 399 },
409 bow => { 400 bow => {
410 noparams => { 401 noparams => {
415 target => "<self> bows before you.", 406 target => "<self> bows before you.",
416 other => "<self> bows before <other>.", 407 other => "<self> bows before <other>.",
417 self => "You bow before <other>.", 408 self => "You bow before <other>.",
418 }, 409 },
419 self => { 410 self => {
420 other => "<self> folds up like a jackknife and kisses his own toes.", 411 other => "<self> folds up like a jackknife and kisses G<his|her> own toes.",
421 self => "You kiss your toes.", 412 self => "You kiss your toes.",
422 }, 413 },
423 }, 414 },
424 dance => { 415 dance => {
425 noparams => { 416 noparams => {
426 other => "<self> expresses himself through interpretive dance.", 417 other => "<self> expresses G<him|her>self through interpretive dance.",
427 self => "You dance with glee.", 418 self => "You dance with glee.",
428 }, 419 },
429 params => { 420 params => {
430 target => "<self> grabs you, and begins dancing!", 421 target => "<self> grabs you, and begins dancing!",
431 other => "Yipe! <self> and <other> are doing the Macarena!", 422 other => "Yipe! <self> and <other> are doing the Macarena!",
432 self => "You grab <other> and begin doing the Cha-Cha!", 423 self => "You grab <other> and begin doing the Cha-Cha!",
433 }, 424 },
434 self => { 425 self => {
435 other => "<self> embraces himself and begins to dance!", 426 other => "<self> embraces G<him|her>self and begins to dance!",
436 self => "You skip and dance around by yourself.", 427 self => "You skip and dance around by yourself.",
437 }, 428 },
438 }, 429 },
439 snore => { 430 snore => {
440 noparams => { 431 noparams => {
456 self => { 447 self => {
457 }, 448 },
458 }, 449 },
459 snap => { 450 snap => {
460 noparams => { 451 noparams => {
461 other => "<self> snaps his fingers.", 452 other => "<self> snaps G<his|her> fingers.",
462 self => "PRONTO! you snap your fingers.", 453 self => "PRONTO! you snap your fingers.",
463 }, 454 },
464 params => { 455 params => {
465 }, 456 },
466 self => { 457 self => {
475 target => "<self> waves goodbye to you. Have a good journey.", 466 target => "<self> waves goodbye to you. Have a good journey.",
476 other => "<self> waves goodbye to <other>.", 467 other => "<self> waves goodbye to <other>.",
477 self => "You wave goodbye to <other>.", 468 self => "You wave goodbye to <other>.",
478 }, 469 },
479 self => { 470 self => {
480 other => "<self> waves goodbye to himself.", 471 other => "<self> waves goodbye to G<him|her>self.",
481 self => "Are you going on adventures as well??", 472 self => "Are you going on adventures as well??",
482 }, 473 },
483 }, 474 },
484 smile => { 475 smile => {
485 noparams => { 476 noparams => {
499 other => "<self> sneezes.", 490 other => "<self> sneezes.",
500 self => "Gesundheit!", 491 self => "Gesundheit!",
501 }, 492 },
502 params => { 493 params => {
503 target => "<self> sneezes on you, you feel the snot cover you. EEEEEEW.", 494 target => "<self> sneezes on you, you feel the snot cover you. EEEEEEW.",
504 other => "<self> sneezes on <other> and a film of snot covers him.", 495 other => "<self> sneezes on <other> and a film of snot covers G<him|her>.",
505 self => "You sneeze at <other> and a film of snot shoots onto him.", 496 self => "You sneeze at <other> and a film of snot shoots onto G<him|her>.",
506 }, 497 },
507 self => { 498 self => {
508 other => "<self> sneezes, and covers himself in a slimy substance.", 499 other => "<self> sneezes, and covers G<him|her>self in a slimy substance.",
509 self => "You sneeze on yourself, what a mess!", 500 self => "You sneeze on yourself, what a mess!",
510 }, 501 },
511 }, 502 },
512 bounce => { 503 bounce => {
513 noparams => { 504 noparams => {
522 self => { 513 self => {
523 }, 514 },
524 }, 515 },
525 shake => { 516 shake => {
526 noparams => { 517 noparams => {
527 other => "<self> shakes his head.", 518 other => "<self> shakes G<his|her> head.",
528 self => "You shake your head.", 519 self => "You shake your head.",
529 }, 520 },
530 params => { 521 params => {
531 target => "<self> shakes your hand.", 522 target => "<self> shakes your hand.",
532 other => "<self> shakes <other>'s hand.", 523 other => "<self> shakes <other>'s hand.",
537 self => "You are shaken by yourself.", 528 self => "You are shaken by yourself.",
538 }, 529 },
539 }, 530 },
540 lick => { 531 lick => {
541 noparams => { 532 noparams => {
542 other => "<self> licks his mouth and smiles.", 533 other => "<self> licks G<his|her> mouth and smiles.",
543 self => "You lick your mouth and smile.", 534 self => "You lick your mouth and smile.",
544 }, 535 },
545 params => { 536 params => {
546 target => "<self> licks you.", 537 target => "<self> licks you.",
547 other => "<self> licks <other>.", 538 other => "<self> licks <other>.",
548 self => "You lick <other>.", 539 self => "You lick <other>.",
549 }, 540 },
550 self => { 541 self => {
551 other => "<self> licks himself - YUCK.", 542 other => "<self> licks G<him|her>self - YUCK.",
552 self => "You lick yourself.", 543 self => "You lick yourself.",
553 }, 544 },
554 }, 545 },
555 flip => { 546 flip => {
556 noparams => { 547 noparams => {
562 self => { 553 self => {
563 }, 554 },
564 }, 555 },
565 think => { 556 think => {
566 noparams => { 557 noparams => {
567 other => "<self> closes his eyes and thinks really hard.", 558 other => "<self> closes G<his|her> eyes and thinks really hard.",
568 self => "Anything in particular that you'd care to think about?", 559 self => "Anything in particular that you'd care to think about?",
569 }, 560 },
570 params => { 561 params => {
571 }, 562 },
572 self => { 563 self => {
636 target => "<self> cries on your shoulder.", 627 target => "<self> cries on your shoulder.",
637 other => "<self> cries on <other>'s shoulder.", 628 other => "<self> cries on <other>'s shoulder.",
638 self => "You cry on <other>'s shoulder.", 629 self => "You cry on <other>'s shoulder.",
639 }, 630 },
640 self => { 631 self => {
641 other => "<self> sobs quietly to himself.", 632 other => "<self> sobs quietly to G<him|her>self.",
642 self => "You cry to yourself.", 633 self => "You cry to yourself.",
643 }, 634 },
644 }, 635 },
645 sulk => { 636 sulk => {
646 noparams => { 637 noparams => {
660 params => { 651 params => {
661 target => "<self> whistles at <other>.", 652 target => "<self> whistles at <other>.",
662 self => "You whistle at <other>.", 653 self => "You whistle at <other>.",
663 }, 654 },
664 self => { 655 self => {
665 other => "<self> whistles to himself in boredom.", 656 other => "<self> whistles to G<him|her>self in boredom.",
666 self => "You whistle while you work.", 657 self => "You whistle while you work.",
667 }, 658 },
668 }, 659 },
669 groan => { 660 groan => {
670 noparams => { 661 noparams => {
716 707
717 $emote{other} ||= "You look away from <self>."; 708 $emote{other} ||= "You look away from <self>.";
718 $emote{self} ||= "My god! Is that LEGAL?"; 709 $emote{self} ||= "My god! Is that LEGAL?";
719 710
720 $emote{other} =~ s/<self>/$name/; 711 $emote{other} =~ s/<self>/$name/;
712
713 $_ = $pl->expand_cfpod ($_)
714 for values %emote;
721 715
722 $_->send_msg ($CHAT_CHANNEL, $emote{other}, cf::NDI_GREY) 716 send_msg $_, $cf::CHAT_CHANNEL, $emote{other}, cf::NDI_GREY | cf::NDI_VERBATIM, "msg_chat"
723 for grep { $ob->on_same_map_as ($_->ob) && $_ != $ob} cf::player::list; 717 for grep { $ob->on_same_map_as ($_->ob) && $_ != $ob} cf::player::list;
724 718
725 $pl->send_msg ($emote{self}, cf::NDI_GREY | cf::NDI_REPLY); 719 $pl->send_msg ($emote{self}, cf::NDI_GREY | cf::NDI_REPLY | cf::NDI_VERBATIM);
726 } elsif ($tname) { 720 } elsif ($tname) {
727 my $target = cf::player::find $tname 721 my $target = cf::player::find $tname
728 or return $pl->send_msg (tell_channel $tname, "$tname is not around.", cf::NDI_DK_ORANGE | cf::NDI_REPLY); 722 or return send_msg $pl, tell_channel $tname, "$tname is not around.", cf::NDI_DK_ORANGE | cf::NDI_REPLY, "msg_chat";
729 723
730 my %emote = %{ $emotes->{$emotion}->{params} || {} }; 724 my %emote = %{ $emotes->{$emotion}->{params} || {} };
731 725
732 $emote{other} ||= "<self> is eyeing <other> quizzically."; 726 $emote{other} ||= "<self> is eyeing <other> quizzically.";
733 $emote{self} ||= "You are still nuts."; 727 $emote{self} ||= "You are still nuts.";
734 $emote{target} ||= "You get the distinct feeling that <other> is nuts."; 728 $emote{target} ||= "You get the distinct feeling that <self> is nuts.";
735 729
736 $emote{self} =~ s/<other>/$tname/; 730 $emote{self} =~ s/<other>/$tname/;
737 $emote{target} =~ s/<self>/$name/; 731 $emote{target} =~ s/<self>/$name/;
738 $emote{other} =~ s/<other>/$tname/; 732 $emote{other} =~ s/<other>/$tname/;
739 $emote{other} =~ s/<self>/$name/; 733 $emote{other} =~ s/<self>/$name/;
740 734
741 $_->send_msg ($CHAT_CHANNEL, $emote{other}, cf::NDI_GREY) 735 $_ = $pl->expand_cfpod ($_)
736 for values %emote;
737
738 send_msg $_, $cf::CHAT_CHANNEL, $emote{other}, cf::NDI_GREY | cf::NDI_VERBATIM, "msg_chat"
742 for grep { $_ != $pl && $_ != $target && $ob->on_same_map_as ($_->ob) } cf::player::list; 739 for grep { $_ != $pl && $_ != $target && $ob->on_same_map_as ($_->ob) } cf::player::list;
743 740
744 $target->send_msg (tell_channel $name, $emote{target}, cf::NDI_GREY); 741 send_msg $target, tell_channel $name, $emote{target}, cf::NDI_GREY | cf::NDI_VERBATIM, "msg_shout";
745 $pl->send_msg (tell_channel $tname, $emote{self}, cf::NDI_GREY | cf::NDI_REPLY); 742 $pl->send_msg (tell_channel $tname, $emote{self}, cf::NDI_GREY | cf::NDI_REPLY | cf::NDI_VERBATIM);
746 } else { 743 } else {
747 my %emote = %{ $emotes->{$emotion}->{noparams} || {} }; 744 my %emote = %{ $emotes->{$emotion}->{noparams} || {} };
748 745
749 $emote{other} ||= "<self> dances with glee."; 746 $emote{other} ||= "<self> dances with glee.";
750 $emote{self} ||= "You are a nut."; 747 $emote{self} ||= "You are a nut.";
751 748
752 $emote{other} =~ s/<self>/$name/; 749 $emote{other} =~ s/<self>/$name/;
753 750
754 $_->send_msg ($CHAT_CHANNEL, $emote{other}, cf::NDI_GREY) 751 $_ = $pl->expand_cfpod ($_)
752 for values %emote;
753
754 send_msg $_, $cf::CHAT_CHANNEL, $emote{other}, cf::NDI_GREY | cf::NDI_VERBATIM, "msg_chat"
755 for grep { $ob->on_same_map_as ($_->ob) && $_ != $pl } cf::player::list; 755 for grep { $ob->on_same_map_as ($_->ob) && $_ != $pl } cf::player::list;
756 756
757 $pl->send_msg ($CHAT_CHANNEL, $emote{self}, cf::NDI_GREY | cf::NDI_REPLY); 757 $pl->send_msg ($cf::CHAT_CHANNEL, $emote{self}, cf::NDI_GREY | cf::NDI_REPLY | cf::NDI_VERBATIM);
758 } 758 }
759 }; 759 };
760 }; 760 };
761} 761}
762 762
763cf::register_command me => sub { 763cf::register_command me => sub {
764 my ($pl, $msg) = @_; 764 my ($pl, $msg) = @_;
765 765
766 my $name = $pl->name; 766 my $name = $pl->name;
767 767
768 $_->send_msg ($SAY_CHANNEL => "* $name $msg", cf::NDI_GREY | cf::NDI_DEF | ($_ == $pl ? cf::NDI_REPLY : 0)) 768 send_msg $_, $cf::SAY_CHANNEL => "* $name $msg", cf::NDI_GREY | cf::NDI_DEF | ($_ == $pl ? cf::NDI_REPLY : 0), "msg_say"
769 for grep $pl->on_same_map_as ($_->ob), cf::player::list; 769 for grep $pl->on_same_map_as ($_->ob), cf::player::list;
770}; 770};
771 771
772cf::register_command say => sub { 772cf::register_command say => sub {
773 my ($ob, $msg) = @_; 773 my ($ob, $msg) = @_;
778 778
779 if ($msg) { 779 if ($msg) {
780 my $name = $ob->name; 780 my $name = $ob->name;
781 my @plonmap = grep $ob->on_same_map_as ($_->ob), cf::player::list; 781 my @plonmap = grep $ob->on_same_map_as ($_->ob), cf::player::list;
782 782
783 send_msg $_, $cf::SAY_CHANNEL => "$name says: $msg", cf::NDI_GREY, "msg_say"
784 for grep $_ != $ob->contr, @plonmap;
783 $_->send_msg ($SAY_CHANNEL => "$name says: $msg", cf::NDI_GREY | ($_ == $ob->contr ? cf::NDI_REPLY : 0)) 785 $ob->contr->send_msg ($cf::SAY_CHANNEL => "$name says: $msg", cf::NDI_GREY | cf::NDI_REPLY);
784 for @plonmap;
785 786
786 # npcs, magic_ears etc. 787 # npcs, magic_ears etc.
787 # first find all objects and their first-level inventories 788 # first find all objects and their first-level inventories
788 # within a 5x5 square that have something resembling 789 # within a 5x5 square that have something resembling
789 # dialogue or support on_say. 790 # dialogue or support on_say.
790 my ($map, $x, $y) = ($ob->map, $ob->x - 2, $ob->y - 2); 791 my ($map, $x, $y) = ($ob->map, $ob->x - 2, $ob->y - 2);
791 792
792 for my $npc ( 793 for my $npc (
793 grep +($_->invoke (cf::EVENT_OBJECT_SAY, $ob->contr, $msg) && return) || NPC_Dialogue::has_dialogue $_, 794 grep +($_->invoke (cf::EVENT_OBJECT_SAY, $ob->contr, $msg) && return) || $_->has_dialogue,
794 map +($_, $_->inv), 795 map +($_, $_->inv),
795 grep $_, 796 grep $_,
796 map $map->at ($x + $_ % 5, $y + (int $_ / 5)), 797 map $map->at ($x + $_ % 5, $y + (int $_ / 5)),
797 0..24 798 0..24
798 ) { 799 ) {
803 my ($reply, @kw) = $dialog->tell ($msg); 804 my ($reply, @kw) = $dialog->tell ($msg);
804 805
805 if (defined $reply) { 806 if (defined $reply) {
806 if ($npc->type == cf::MAGIC_EAR) { 807 if ($npc->type == cf::MAGIC_EAR) {
807 if (length $reply) { 808 if (length $reply) {
808 $_->send_msg ($SAY_CHANNEL => $reply, cf::NDI_BROWN) 809 send_msg $_, $cf::SAY_CHANNEL => $reply, cf::NDI_BROWN, "msg_say"
809 for @plonmap; 810 for @plonmap;
810 } 811 }
811 $npc->use_trigger; 812 $npc->use_trigger;
812 } else { 813 } else {
813 if (length $reply) { 814 if (length $reply) {
814 $_->send_msg ($SAY_CHANNEL => $npc->name . " says: $reply", cf::NDI_BROWN) 815 send_msg $_, $cf::SAY_CHANNEL => $npc->name . " says: $reply", cf::NDI_BROWN, "msg_say"
815 for @plonmap; 816 for @plonmap;
816 } 817 }
817 } 818 }
818 } 819 }
819 820
820 if (@kw) { 821 if (@kw) {
821 $_->send_msg ($SAY_CHANNEL => "[further topics: " . (join ", ", @kw) . "]", cf::NDI_BROWN) 822 $_->send_msg ($cf::SAY_CHANNEL => "[further topics: " . (join ", ", @kw) . "]", cf::NDI_BROWN)
822 for @plonmap; 823 for @plonmap;
823 } 824 }
824 } 825 }
825 826
826 } else { 827 } else {
827 $ob->send_msg ($SAY_CHANNEL => "What do you want to say?", cf::NDI_GREY | cf::NDI_REPLY); 828 $ob->send_msg ($cf::SAY_CHANNEL => "What do you want to say?", cf::NDI_GREY | cf::NDI_REPLY);
828 } 829 }
829}; 830};
830 831
831cf::register_command chat => sub { 832cf::register_command chat => sub {
832 my ($ob, $msg) = @_; 833 my ($ob, $msg) = @_;
842 my $NOW = time; 843 my $NOW = time;
843 844
844 cf::LOG cf::llevDebug, sprintf "QBERT [%s] %s\n", $name, $msg; 845 cf::LOG cf::llevDebug, sprintf "QBERT [%s] %s\n", $name, $msg;
845 send_irc ("[%s] %s", $name, $msg); 846 send_irc ("[%s] %s", $name, $msg);
846 847
847 $_->send_msg ($CHAT_CHANNEL => "$name chats: $msg", cf::NDI_BLUE | cf::NDI_DEF | ($_ == $pl ? cf::NDI_REPLY : 0)) 848 send_msg $_, $cf::CHAT_CHANNEL => "$name chats: $msg", cf::NDI_BLUE | cf::NDI_DEF | ($_ == $pl ? cf::NDI_REPLY : 0), "msg_chat"
848 for grep { $_->ob->{ext_ignore_shout}{$name} < $NOW && $_->listening >= 10 } cf::player::list; 849 for grep { $_->ob->{ext_ignore_shout}{$name} < $NOW } cf::player::list;
849 850
850 } else { 851 } else {
851 $pl->send_msg ($CHAT_CHANNEL => "Chat what?", cf::NDI_BLUE | cf::NDI_DEF | cf::NDI_REPLY); 852 $pl->send_msg ($cf::CHAT_CHANNEL => "Chat what?", cf::NDI_BLUE | cf::NDI_DEF | cf::NDI_REPLY);
852 } 853 }
853}; 854};
854 855
855cf::register_command shout => sub { 856cf::register_command shout => sub {
856 my ($ob, $msg) = @_; 857 my ($ob, $msg) = @_;
866 my $name = $ob->name; 867 my $name = $ob->name;
867 868
868 cf::LOG cf::llevDebug, sprintf "QBERT {%s} %s\n", $name, $msg; 869 cf::LOG cf::llevDebug, sprintf "QBERT {%s} %s\n", $name, $msg;
869 send_irc ("\007\0034{%s} %s\n", $name, $msg); 870 send_irc ("\007\0034{%s} %s\n", $name, $msg);
870 871
871 $_->send_msg ($CHAT_CHANNEL => "$name shouts: $msg", cf::NDI_RED | cf::NDI_DEF | ($_ == $pl ? cf::NDI_REPLY : 0)) 872 send_msg $_, $cf::CHAT_CHANNEL => "$name shouts: $msg", cf::NDI_RED | cf::NDI_DEF | ($_ == $pl ? cf::NDI_REPLY : 0), "msg_shout"
872 for grep { $_->ob->{ext_ignore_shout}{$name} < $NOW && $_->listening >= 2 } cf::player::list; 873 for grep { $_->ob->{ext_ignore_shout}{$name} < $NOW } cf::player::list;
873 874
874 } else { 875 } else {
875 $pl->send_msg ($CHAT_CHANNEL => "Shout what?", cf::NDI_RED | cf::NDI_DEF | cf::NDI_REPLY); 876 $pl->send_msg ($cf::CHAT_CHANNEL => "Shout what?", cf::NDI_RED | cf::NDI_DEF | cf::NDI_REPLY);
876 } 877 }
877}; 878};
878 879
879cf::register_command tell => sub { 880cf::register_command tell => sub {
880 my ($ob, $args) = @_; 881 my ($ob, $args) = @_;
907 } else { 908 } else {
908 return if $other->invoke (cf::EVENT_PLAYER_TOLD, $pl, $msg); 909 return if $other->invoke (cf::EVENT_PLAYER_TOLD, $pl, $msg);
909 cf::LOG cf::llevDebug, sprintf "TELL [%s>%s] %s\n", $name, $target, $msg; 910 cf::LOG cf::llevDebug, sprintf "TELL [%s>%s] %s\n", $name, $target, $msg;
910 911
911 $ns->send_msg ($pl_channel => "You tell $target: $msg", cf::NDI_DK_ORANGE | cf::NDI_DEF | cf::NDI_REPLY); 912 $ns->send_msg ($pl_channel => "You tell $target: $msg", cf::NDI_DK_ORANGE | cf::NDI_DEF | cf::NDI_REPLY);
912 $other->send_msg ($other_channel => "$name tells you: $msg", cf::NDI_DK_ORANGE | cf::NDI_DEF); 913 send_msg $other, $other_channel => "$name tells you: $msg", cf::NDI_DK_ORANGE | cf::NDI_DEF, "msg_tell";
913 } 914 }
914 } else { 915 } else {
915 $ns->send_msg ($pl_channel => "What do you want to tell $target?", cf::NDI_DK_ORANGE | cf::NDI_DEF | cf::NDI_REPLY); 916 $ns->send_msg ($pl_channel => "What do you want to tell $target?", cf::NDI_DK_ORANGE | cf::NDI_DEF | cf::NDI_REPLY);
916 } 917 }
917 918

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines