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.37 by root, Mon Nov 12 23:27:51 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 {
70 on_login => sub { 56 on_login => sub {
71 my ($pl) = @_; 57 my ($pl) = @_;
72 58
73 clean_timeouts $pl->ob; 59 clean_timeouts $pl->ob;
74 60
75 $pl->send_msg ($SAY_CHANNEL); 61 $pl->send_msg ($cf::SAY_CHANNEL);
76 $pl->send_msg ($CHAT_CHANNEL); 62 $pl->send_msg ($cf::CHAT_CHANNEL);
77 }, 63 },
78); 64);
79 65
66# TODO: remove once safe
80cf::register_command listen => sub { 67cf::register_command listen => sub {
81 my ($pl, $msg) = @_;
82 my $player = cf::player::find_active $pl->name;
83
84 if ($msg ne "") {
85 $msg = 10 if $msg > 10;
86
87 my $prev_listen = $player->listening;
88 $player->listening ($msg);
89 if ($prev_listen == $player->listening) {
90 $pl->message ("Your verbose level stays at $prev_listen.", cf::NDI_REPLY);
91 } else {
92 $pl->message ("Your verbose level is now " . $player->listening . ". (previously: $prev_listen)", cf::NDI_REPLY);
93 }
94 } else {
95 $pl->message ("Your verbose level is " . $player->listening . ".", cf::NDI_REPLY);
96 }
97}; 68};
98 69
99cf::register_command cointoss => sub { 70cf::register_command cointoss => sub {
100 my ($ob, $msg) = @_; 71 my ($ob, $msg) = @_;
101 72
102 my $pl = $ob->contr; 73 my $pl = $ob->contr;
103 my $name = $ob->name; 74 my $name = $ob->name;
104 75
105 my $coin = int rand 2 ? "Heads" : "Tails"; 76 my $coin = int rand 2 ? "Heads" : "Tails";
106 77
107 send_msg $_, $SAY_CHANNEL => "$name flips a coin.... $coin!", cf::NDI_GREY, "msg_say" 78 send_msg $_, $cf::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; 79 for grep { $ob->on_same_map_as ($_->ob) && $_ != $pl} cf::player::list;
109 80
110 $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);
111}; 82};
112 83
113cf::register_command orcknuckle => sub { 84cf::register_command orcknuckle => sub {
114 my ($ob, $msg) = @_; 85 my ($ob, $msg) = @_;
115 86
118 89
119 my @orcknuckle = ("beholder", "ghost", "knight", "princess", "dragon", "orc"); 90 my @orcknuckle = ("beholder", "ghost", "knight", "princess", "dragon", "orc");
120 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);
121 my $result = "$orcknuckle[$i], $orcknuckle[$j], $orcknuckle[$k], $orcknuckle[$l]"; 92 my $result = "$orcknuckle[$i], $orcknuckle[$j], $orcknuckle[$k], $orcknuckle[$l]";
122 93
123 send_msg $_, $SAY_CHANNEL => "$name throws his orc-knuckles and rolls $result!", cf::NDI_GREY, "msg_say" 94 send_msg $_, $cf::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; 95 for grep { $ob->on_same_map_as ($_->ob) && $_ != $pl} cf::player::list;
125 96
126 $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);
127}; 98};
128 99
129my $emotes = { 100my $emotes = {
130 growl => { 101 growl => {
131 noparams => { 102 noparams => {
177 self => { 148 self => {
178 }, 149 },
179 }, 150 },
180 scream => { 151 scream => {
181 noparams => { 152 noparams => {
182 other => "<self> screams at the top of his lungs!", 153 other => "<self> screams at the top of G<his|her> lungs!",
183 self => "ARRRRRRRRRRGH!!!!!", 154 self => "ARRRRRRRRRRGH!!!!!",
184 }, 155 },
185 params => { 156 params => {
186 }, 157 },
187 self => { 158 self => {
196 target => "<self> pukes on your clothes!", 167 target => "<self> pukes on your clothes!",
197 other => "<self> pukes on <other>.", 168 other => "<self> pukes on <other>.",
198 self => "You puke on <other>.", 169 self => "You puke on <other>.",
199 }, 170 },
200 self => { 171 self => {
201 other => "<self> pukes on his clothes.", 172 other => "<self> pukes on G<his|her> clothes.",
202 self => "You puke on yourself.", 173 self => "You puke on yourself.",
203 }, 174 },
204 }, 175 },
205 strut => { 176 strut => {
206 noparams => { 177 noparams => {
279 target => "<self> winks at you.", 250 target => "<self> winks at you.",
280 other => "<self> winks at <other>.", 251 other => "<self> winks at <other>.",
281 self => "You wink suggestively at <other>.", 252 self => "You wink suggestively at <other>.",
282 }, 253 },
283 self => { 254 self => {
284 other => "<self> winks at himself - something strange is going on...", 255 other => "<self> winks at G<him|her>self - something strange is going on...",
285 self => "You wink at yourself?? What are you up to?", 256 self => "You wink at yourself?? What are you up to?",
286 }, 257 },
287 }, 258 },
288 pout => { 259 pout => {
289 noparams => { 260 noparams => {
295 self => { 266 self => {
296 }, 267 },
297 }, 268 },
298 cackle => { 269 cackle => {
299 noparams => { 270 noparams => {
300 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!",
301 self => "You cackle gleefully.", 272 self => "You cackle gleefully.",
302 }, 273 },
303 params => { 274 params => {
304 }, 275 },
305 self => { 276 self => {
314 target => "<self> sniffs you.", 285 target => "<self> sniffs you.",
315 other => "<self> sniffs <other>", 286 other => "<self> sniffs <other>",
316 self => "You sniff <other>.", 287 self => "You sniff <other>.",
317 }, 288 },
318 self => { 289 self => {
319 other => "<self> sniffs himself.", 290 other => "<self> sniffs G<him|her>self.",
320 self => "You sniff yourself.", 291 self => "You sniff yourself.",
321 }, 292 },
322 }, 293 },
323 nod => { 294 nod => {
324 noparams => { 295 noparams => {
325 other => "<self> nods solemnly.", 296 other => "<self> nods solemnly.",
326 self => "You nod solemnly.", 297 self => "You nod solemnly.",
327 }, 298 },
328 params => { 299 params => {
329 target => "<self> nods solemnly to you.", 300 target => "<self> nods solemnly at you.",
330 other => "<self> nods solemnly to <other>.", 301 other => "<self> nods solemnly at <other>.",
331 self => "You nod solemnly to <other>.", 302 self => "You nod solemnly at <other>.",
332 }, 303 },
333 self => { 304 self => {
334 }, 305 },
335 }, 306 },
336 frown => { 307 frown => {
342 target => "<self> frowns darkly at you.", 313 target => "<self> frowns darkly at you.",
343 other => "<self> frowns darkly at <other>.", 314 other => "<self> frowns darkly at <other>.",
344 self => "You frown darkly at <other>.", 315 self => "You frown darkly at <other>.",
345 }, 316 },
346 self => { 317 self => {
347 other => "<self> frowns at himself.", 318 other => "<self> frowns at G<him|her>self.",
348 self => "You frown at yourself.", 319 self => "You frown at yourself.",
349 }, 320 },
350 }, 321 },
351 snicker => { 322 snicker => {
352 noparams => { 323 noparams => {
375 noparams => { 346 noparams => {
376 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?",
377 self => "You bleed all over your nice new armour.", 348 self => "You bleed all over your nice new armour.",
378 }, 349 },
379 params => { 350 params => {
380 target => "<self> slashes his wrist and bleeds all over you.", 351 target => "<self> slashes G<his|her> wrist and bleeds all over you.",
381 other => "<self> slashes his wrist and bleeds all over <other>.", 352 other => "<self> slashes G<his|her> wrist and bleeds all over <other>.",
382 self => "You slash your wrist and bleed all over <other>", 353 self => "You slash your wrist and bleed all over <other>",
383 }, 354 },
384 self => { 355 self => {
385 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.",
386 self => "Very impressive! You wipe your blood all over yourself.", 357 self => "Very impressive! You wipe your blood all over yourself.",
387 }, 358 },
388 }, 359 },
389 twiddle => { 360 twiddle => {
390 noparams => { 361 noparams => {
391 other => "<self> patiently twiddles his thumbs.", 362 other => "<self> patiently twiddles G<his|her> thumbs.",
392 self => "You patiently twiddle your thumbs.", 363 self => "You patiently twiddle your thumbs.",
393 }, 364 },
394 params => { 365 params => {
395 }, 366 },
396 self => { 367 self => {
397 }, 368 },
398 }, 369 },
399 spit => { 370 spit => {
400 noparams => { 371 noparams => {
401 other => "<self> spits over his left shoulder.", 372 other => "<self> spits over G<his|her> left shoulder.",
402 self => "You spit over your left shoulder.", 373 self => "You spit over your left shoulder.",
403 }, 374 },
404 params => { 375 params => {
405 target => "<self> spits in your face!", 376 target => "<self> spits in your face!",
406 other => "<self> spits in <other>'s face.", 377 other => "<self> spits in <other>'s face.",
407 self => "You spit on <other>.", 378 self => "You spit on <other>.",
408 }, 379 },
409 self => { 380 self => {
410 other => "<self> drools all over himself.", 381 other => "<self> drools all over G<him|her>self.",
411 self => "You drool all over yourself.", 382 self => "You drool all over yourself.",
412 }, 383 },
413 }, 384 },
414 glare => { 385 glare => {
415 noparams => { 386 noparams => {
416 other => "<self> glares around him.", 387 other => "<self> glares around G<him|her>.",
417 self => "You glare at nothing in particular.", 388 self => "You glare at nothing in particular.",
418 }, 389 },
419 params => { 390 params => {
420 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.",
421 other => "<self> glares at <other>.", 392 other => "<self> glares at <other>.",
422 self => "You glare icily at <other>.", 393 self => "You glare icily at <other>.",
423 }, 394 },
424 self => { 395 self => {
425 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>?",
426 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.",
427 }, 398 },
428 }, 399 },
429 bow => { 400 bow => {
430 noparams => { 401 noparams => {
435 target => "<self> bows before you.", 406 target => "<self> bows before you.",
436 other => "<self> bows before <other>.", 407 other => "<self> bows before <other>.",
437 self => "You bow before <other>.", 408 self => "You bow before <other>.",
438 }, 409 },
439 self => { 410 self => {
440 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.",
441 self => "You kiss your toes.", 412 self => "You kiss your toes.",
442 }, 413 },
443 }, 414 },
444 dance => { 415 dance => {
445 noparams => { 416 noparams => {
446 other => "<self> expresses himself through interpretive dance.", 417 other => "<self> expresses G<him|her>self through interpretive dance.",
447 self => "You dance with glee.", 418 self => "You dance with glee.",
448 }, 419 },
449 params => { 420 params => {
450 target => "<self> grabs you, and begins dancing!", 421 target => "<self> grabs you, and begins dancing!",
451 other => "Yipe! <self> and <other> are doing the Macarena!", 422 other => "Yipe! <self> and <other> are doing the Macarena!",
452 self => "You grab <other> and begin doing the Cha-Cha!", 423 self => "You grab <other> and begin doing the Cha-Cha!",
453 }, 424 },
454 self => { 425 self => {
455 other => "<self> embraces himself and begins to dance!", 426 other => "<self> embraces G<him|her>self and begins to dance!",
456 self => "You skip and dance around by yourself.", 427 self => "You skip and dance around by yourself.",
457 }, 428 },
458 }, 429 },
459 snore => { 430 snore => {
460 noparams => { 431 noparams => {
476 self => { 447 self => {
477 }, 448 },
478 }, 449 },
479 snap => { 450 snap => {
480 noparams => { 451 noparams => {
481 other => "<self> snaps his fingers.", 452 other => "<self> snaps G<his|her> fingers.",
482 self => "PRONTO! you snap your fingers.", 453 self => "PRONTO! you snap your fingers.",
483 }, 454 },
484 params => { 455 params => {
485 }, 456 },
486 self => { 457 self => {
495 target => "<self> waves goodbye to you. Have a good journey.", 466 target => "<self> waves goodbye to you. Have a good journey.",
496 other => "<self> waves goodbye to <other>.", 467 other => "<self> waves goodbye to <other>.",
497 self => "You wave goodbye to <other>.", 468 self => "You wave goodbye to <other>.",
498 }, 469 },
499 self => { 470 self => {
500 other => "<self> waves goodbye to himself.", 471 other => "<self> waves goodbye to G<him|her>self.",
501 self => "Are you going on adventures as well??", 472 self => "Are you going on adventures as well??",
502 }, 473 },
503 }, 474 },
504 smile => { 475 smile => {
505 noparams => { 476 noparams => {
519 other => "<self> sneezes.", 490 other => "<self> sneezes.",
520 self => "Gesundheit!", 491 self => "Gesundheit!",
521 }, 492 },
522 params => { 493 params => {
523 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.",
524 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>.",
525 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>.",
526 }, 497 },
527 self => { 498 self => {
528 other => "<self> sneezes, and covers himself in a slimy substance.", 499 other => "<self> sneezes, and covers G<him|her>self in a slimy substance.",
529 self => "You sneeze on yourself, what a mess!", 500 self => "You sneeze on yourself, what a mess!",
530 }, 501 },
531 }, 502 },
532 bounce => { 503 bounce => {
533 noparams => { 504 noparams => {
542 self => { 513 self => {
543 }, 514 },
544 }, 515 },
545 shake => { 516 shake => {
546 noparams => { 517 noparams => {
547 other => "<self> shakes his head.", 518 other => "<self> shakes G<his|her> head.",
548 self => "You shake your head.", 519 self => "You shake your head.",
549 }, 520 },
550 params => { 521 params => {
551 target => "<self> shakes your hand.", 522 target => "<self> shakes your hand.",
552 other => "<self> shakes <other>'s hand.", 523 other => "<self> shakes <other>'s hand.",
557 self => "You are shaken by yourself.", 528 self => "You are shaken by yourself.",
558 }, 529 },
559 }, 530 },
560 lick => { 531 lick => {
561 noparams => { 532 noparams => {
562 other => "<self> licks his mouth and smiles.", 533 other => "<self> licks G<his|her> mouth and smiles.",
563 self => "You lick your mouth and smile.", 534 self => "You lick your mouth and smile.",
564 }, 535 },
565 params => { 536 params => {
566 target => "<self> licks you.", 537 target => "<self> licks you.",
567 other => "<self> licks <other>.", 538 other => "<self> licks <other>.",
568 self => "You lick <other>.", 539 self => "You lick <other>.",
569 }, 540 },
570 self => { 541 self => {
571 other => "<self> licks himself - YUCK.", 542 other => "<self> licks G<him|her>self - YUCK.",
572 self => "You lick yourself.", 543 self => "You lick yourself.",
573 }, 544 },
574 }, 545 },
575 flip => { 546 flip => {
576 noparams => { 547 noparams => {
582 self => { 553 self => {
583 }, 554 },
584 }, 555 },
585 think => { 556 think => {
586 noparams => { 557 noparams => {
587 other => "<self> closes his eyes and thinks really hard.", 558 other => "<self> closes G<his|her> eyes and thinks really hard.",
588 self => "Anything in particular that you'd care to think about?", 559 self => "Anything in particular that you'd care to think about?",
589 }, 560 },
590 params => { 561 params => {
591 }, 562 },
592 self => { 563 self => {
656 target => "<self> cries on your shoulder.", 627 target => "<self> cries on your shoulder.",
657 other => "<self> cries on <other>'s shoulder.", 628 other => "<self> cries on <other>'s shoulder.",
658 self => "You cry on <other>'s shoulder.", 629 self => "You cry on <other>'s shoulder.",
659 }, 630 },
660 self => { 631 self => {
661 other => "<self> sobs quietly to himself.", 632 other => "<self> sobs quietly to G<him|her>self.",
662 self => "You cry to yourself.", 633 self => "You cry to yourself.",
663 }, 634 },
664 }, 635 },
665 sulk => { 636 sulk => {
666 noparams => { 637 noparams => {
680 params => { 651 params => {
681 target => "<self> whistles at <other>.", 652 target => "<self> whistles at <other>.",
682 self => "You whistle at <other>.", 653 self => "You whistle at <other>.",
683 }, 654 },
684 self => { 655 self => {
685 other => "<self> whistles to himself in boredom.", 656 other => "<self> whistles to G<him|her>self in boredom.",
686 self => "You whistle while you work.", 657 self => "You whistle while you work.",
687 }, 658 },
688 }, 659 },
689 groan => { 660 groan => {
690 noparams => { 661 noparams => {
736 707
737 $emote{other} ||= "You look away from <self>."; 708 $emote{other} ||= "You look away from <self>.";
738 $emote{self} ||= "My god! Is that LEGAL?"; 709 $emote{self} ||= "My god! Is that LEGAL?";
739 710
740 $emote{other} =~ s/<self>/$name/; 711 $emote{other} =~ s/<self>/$name/;
712
713 $_ = $pl->expand_cfpod ($_)
714 for values %emote;
741 715
742 send_msg $_, $CHAT_CHANNEL, $emote{other}, cf::NDI_GREY, "msg_chat" 716 send_msg $_, $cf::CHAT_CHANNEL, $emote{other}, cf::NDI_GREY | cf::NDI_VERBATIM, "msg_chat"
743 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;
744 718
745 $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);
746 } elsif ($tname) { 720 } elsif ($tname) {
747 my $target = cf::player::find $tname 721 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"; 722 or return send_msg $pl, tell_channel $tname, "$tname is not around.", cf::NDI_DK_ORANGE | cf::NDI_REPLY, "msg_chat";
749 723
750 my %emote = %{ $emotes->{$emotion}->{params} || {} }; 724 my %emote = %{ $emotes->{$emotion}->{params} || {} };
751 725
752 $emote{other} ||= "<self> is eyeing <other> quizzically."; 726 $emote{other} ||= "<self> is eyeing <other> quizzically.";
753 $emote{self} ||= "You are still nuts."; 727 $emote{self} ||= "You are still nuts.";
754 $emote{target} ||= "You get the distinct feeling that <other> is nuts."; 728 $emote{target} ||= "You get the distinct feeling that <self> is nuts.";
755 729
756 $emote{self} =~ s/<other>/$tname/; 730 $emote{self} =~ s/<other>/$tname/;
757 $emote{target} =~ s/<self>/$name/; 731 $emote{target} =~ s/<self>/$name/;
758 $emote{other} =~ s/<other>/$tname/; 732 $emote{other} =~ s/<other>/$tname/;
759 $emote{other} =~ s/<self>/$name/; 733 $emote{other} =~ s/<self>/$name/;
760 734
735 $_ = $pl->expand_cfpod ($_)
736 for values %emote;
737
761 send_msg $_, $CHAT_CHANNEL, $emote{other}, cf::NDI_GREY, "msg_chat" 738 send_msg $_, $cf::CHAT_CHANNEL, $emote{other}, cf::NDI_GREY | cf::NDI_VERBATIM, "msg_chat"
762 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;
763 740
764 send_msg $target, tell_channel $name, $emote{target}, cf::NDI_GREY, "msg_shout"; 741 send_msg $target, tell_channel $name, $emote{target}, cf::NDI_GREY | cf::NDI_VERBATIM, "msg_shout";
765 $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);
766 } else { 743 } else {
767 my %emote = %{ $emotes->{$emotion}->{noparams} || {} }; 744 my %emote = %{ $emotes->{$emotion}->{noparams} || {} };
768 745
769 $emote{other} ||= "<self> dances with glee."; 746 $emote{other} ||= "<self> dances with glee.";
770 $emote{self} ||= "You are a nut."; 747 $emote{self} ||= "You are a nut.";
771 748
772 $emote{other} =~ s/<self>/$name/; 749 $emote{other} =~ s/<self>/$name/;
773 750
751 $_ = $pl->expand_cfpod ($_)
752 for values %emote;
753
774 send_msg $_, $CHAT_CHANNEL, $emote{other}, cf::NDI_GREY, "msg_chat" 754 send_msg $_, $cf::CHAT_CHANNEL, $emote{other}, cf::NDI_GREY | cf::NDI_VERBATIM, "msg_chat"
775 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;
776 756
777 $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);
778 } 758 }
779 }; 759 };
780 }; 760 };
781} 761}
782 762
783cf::register_command me => sub { 763cf::register_command me => sub {
784 my ($pl, $msg) = @_; 764 my ($pl, $msg) = @_;
785 765
786 my $name = $pl->name; 766 my $name = $pl->name;
787 767
788 send_msg $_, $SAY_CHANNEL => "* $name $msg", cf::NDI_GREY | cf::NDI_DEF | ($_ == $pl ? cf::NDI_REPLY : 0), "msg_say" 768 send_msg $_, $cf::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; 769 for grep $pl->on_same_map_as ($_->ob), cf::player::list;
790}; 770};
791 771
792cf::register_command say => sub { 772cf::register_command say => sub {
793 my ($ob, $msg) = @_; 773 my ($ob, $msg) = @_;
798 778
799 if ($msg) { 779 if ($msg) {
800 my $name = $ob->name; 780 my $name = $ob->name;
801 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;
802 782
803 send_msg $_, $SAY_CHANNEL => "$name says: $msg", cf::NDI_GREY, "msg_say" 783 send_msg $_, $cf::SAY_CHANNEL => "$name says: $msg", cf::NDI_GREY, "msg_say"
804 for grep $_ != $ob->contr, @plonmap; 784 for grep $_ != $ob->contr, @plonmap;
805 $ob->contr->send_msg ($SAY_CHANNEL => "$name says: $msg", cf::NDI_GREY | cf::NDI_REPLY); 785 $ob->contr->send_msg ($cf::SAY_CHANNEL => "$name says: $msg", cf::NDI_GREY | cf::NDI_REPLY);
806 786
807 # npcs, magic_ears etc. 787 # npcs, magic_ears etc.
808 # first find all objects and their first-level inventories 788 # first find all objects and their first-level inventories
809 # within a 5x5 square that have something resembling 789 # within a 5x5 square that have something resembling
810 # dialogue or support on_say. 790 # dialogue or support on_say.
811 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);
812 792
813 for my $npc ( 793 for my $npc (
814 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,
815 map +($_, $_->inv), 795 map +($_, $_->inv),
816 grep $_, 796 grep $_,
817 map $map->at ($x + $_ % 5, $y + (int $_ / 5)), 797 map $map->at ($x + $_ % 5, $y + (int $_ / 5)),
818 0..24 798 0..24
819 ) { 799 ) {
824 my ($reply, @kw) = $dialog->tell ($msg); 804 my ($reply, @kw) = $dialog->tell ($msg);
825 805
826 if (defined $reply) { 806 if (defined $reply) {
827 if ($npc->type == cf::MAGIC_EAR) { 807 if ($npc->type == cf::MAGIC_EAR) {
828 if (length $reply) { 808 if (length $reply) {
829 send_msg $_, $SAY_CHANNEL => $reply, cf::NDI_BROWN, "msg_say" 809 send_msg $_, $cf::SAY_CHANNEL => $reply, cf::NDI_BROWN, "msg_say"
830 for @plonmap; 810 for @plonmap;
831 } 811 }
832 $npc->use_trigger; 812 $npc->use_trigger;
833 } else { 813 } else {
834 if (length $reply) { 814 if (length $reply) {
835 send_msg $_, $SAY_CHANNEL => $npc->name . " says: $reply", cf::NDI_BROWN, "msg_say" 815 send_msg $_, $cf::SAY_CHANNEL => $npc->name . " says: $reply", cf::NDI_BROWN, "msg_say"
836 for @plonmap; 816 for @plonmap;
837 } 817 }
838 } 818 }
839 } 819 }
840 820
841 if (@kw) { 821 if (@kw) {
842 $_->send_msg ($SAY_CHANNEL => "[further topics: " . (join ", ", @kw) . "]", cf::NDI_BROWN) 822 $_->send_msg ($cf::SAY_CHANNEL => "[further topics: " . (join ", ", @kw) . "]", cf::NDI_BROWN)
843 for @plonmap; 823 for @plonmap;
844 } 824 }
845 } 825 }
846 826
847 } else { 827 } else {
848 $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);
849 } 829 }
850}; 830};
851 831
852cf::register_command chat => sub { 832cf::register_command chat => sub {
853 my ($ob, $msg) = @_; 833 my ($ob, $msg) = @_;
863 my $NOW = time; 843 my $NOW = time;
864 844
865 cf::LOG cf::llevDebug, sprintf "QBERT [%s] %s\n", $name, $msg; 845 cf::LOG cf::llevDebug, sprintf "QBERT [%s] %s\n", $name, $msg;
866 send_irc ("[%s] %s", $name, $msg); 846 send_irc ("[%s] %s", $name, $msg);
867 847
868 send_msg $_, $CHAT_CHANNEL => "$name chats: $msg", cf::NDI_BLUE | cf::NDI_DEF | ($_ == $pl ? cf::NDI_REPLY : 0), "msg_chat" 848 send_msg $_, $cf::CHAT_CHANNEL => "$name chats: $msg", cf::NDI_BLUE | cf::NDI_DEF | ($_ == $pl ? cf::NDI_REPLY : 0), "msg_chat"
869 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;
870 850
871 } else { 851 } else {
872 $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);
873 } 853 }
874}; 854};
875 855
876cf::register_command shout => sub { 856cf::register_command shout => sub {
877 my ($ob, $msg) = @_; 857 my ($ob, $msg) = @_;
887 my $name = $ob->name; 867 my $name = $ob->name;
888 868
889 cf::LOG cf::llevDebug, sprintf "QBERT {%s} %s\n", $name, $msg; 869 cf::LOG cf::llevDebug, sprintf "QBERT {%s} %s\n", $name, $msg;
890 send_irc ("\007\0034{%s} %s\n", $name, $msg); 870 send_irc ("\007\0034{%s} %s\n", $name, $msg);
891 871
892 send_msg $_, $CHAT_CHANNEL => "$name shouts: $msg", cf::NDI_RED | cf::NDI_DEF | ($_ == $pl ? cf::NDI_REPLY : 0), "msg_shout" 872 send_msg $_, $cf::CHAT_CHANNEL => "$name shouts: $msg", cf::NDI_RED | cf::NDI_DEF | ($_ == $pl ? cf::NDI_REPLY : 0), "msg_shout"
893 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;
894 874
895 } else { 875 } else {
896 $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);
897 } 877 }
898}; 878};
899 879
900cf::register_command tell => sub { 880cf::register_command tell => sub {
901 my ($ob, $args) = @_; 881 my ($ob, $args) = @_;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines