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.39 by root, Fri Apr 11 01:15:49 2008 UTC vs.
Revision 1.46 by root, Thu Dec 18 02:49:22 2008 UTC

3# implement a replacement for the built-in say/chat/shout/tell 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 {
68cf::player->attach ( 54cf::player->attach (
69 prio => -1000, 55 prio => -1000,
70 on_login => sub { 56 on_login => sub {
71 my ($pl) = @_; 57 my ($pl) = @_;
72 58
59 cf::async {
73 clean_timeouts $pl->ob; 60 clean_timeouts $pl->ob;
61 };
74 62
75 $pl->send_msg ($SAY_CHANNEL); 63 $pl->send_msg ($cf::SAY_CHANNEL);
76 $pl->send_msg ($CHAT_CHANNEL); 64 $pl->send_msg ($cf::CHAT_CHANNEL);
77 }, 65 },
78); 66);
79 67
68# TODO: remove once safe
80cf::register_command listen => sub { 69cf::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}; 70};
98 71
99cf::register_command cointoss => sub { 72cf::register_command cointoss => sub {
100 my ($ob, $msg) = @_; 73 my ($ob, $msg) = @_;
101 74
102 my $pl = $ob->contr; 75 my $pl = $ob->contr;
103 my $name = $ob->name; 76 my $name = $ob->name;
104 77
105 my $coin = int rand 2 ? "Heads" : "Tails"; 78 my $coin = int rand 2 ? "Heads" : "Tails";
106 79
107 send_msg $_, $SAY_CHANNEL => "$name flips a coin.... $coin!", cf::NDI_GREY, "msg_say" 80 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; 81 for grep { $ob->on_same_map_as ($_->ob) && $_ != $pl} cf::player::list;
109 82
110 $pl->send_msg ($SAY_CHANNEL => "You flip a coin.... $coin!", cf::NDI_GREY | cf::NDI_REPLY); 83 $pl->send_msg ($cf::SAY_CHANNEL => "You flip a coin.... $coin!", cf::NDI_GREY | cf::NDI_REPLY);
111}; 84};
112 85
113cf::register_command orcknuckle => sub { 86cf::register_command orcknuckle => sub {
114 my ($ob, $msg) = @_; 87 my ($ob, $msg) = @_;
115 88
118 91
119 my @orcknuckle = ("beholder", "ghost", "knight", "princess", "dragon", "orc"); 92 my @orcknuckle = ("beholder", "ghost", "knight", "princess", "dragon", "orc");
120 my ($i, $j, $k, $l) = (rand 5, rand 5, rand 5, rand 6); 93 my ($i, $j, $k, $l) = (rand 5, rand 5, rand 5, rand 6);
121 my $result = "$orcknuckle[$i], $orcknuckle[$j], $orcknuckle[$k], $orcknuckle[$l]"; 94 my $result = "$orcknuckle[$i], $orcknuckle[$j], $orcknuckle[$k], $orcknuckle[$l]";
122 95
123 send_msg $_, $SAY_CHANNEL => "$name throws his orc-knuckles and rolls $result!", cf::NDI_GREY, "msg_say" 96 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; 97 for grep { $ob->on_same_map_as ($_->ob) && $_ != $pl} cf::player::list;
125 98
126 $pl->send_msg ($SAY_CHANNEL => "You roll $result!", cf::NDI_GREY | cf::NDI_REPLY); 99 $pl->send_msg ($cf::SAY_CHANNEL => "You roll $result!", cf::NDI_GREY | cf::NDI_REPLY);
127}; 100};
128 101
129my $emotes = { 102my $emotes = {
130 growl => { 103 growl => {
131 noparams => { 104 noparams => {
177 self => { 150 self => {
178 }, 151 },
179 }, 152 },
180 scream => { 153 scream => {
181 noparams => { 154 noparams => {
182 other => "<self> screams at the top of his lungs!", 155 other => "<self> screams at the top of G<his|her> lungs!",
183 self => "ARRRRRRRRRRGH!!!!!", 156 self => "ARRRRRRRRRRGH!!!!!",
184 }, 157 },
185 params => { 158 params => {
186 }, 159 },
187 self => { 160 self => {
196 target => "<self> pukes on your clothes!", 169 target => "<self> pukes on your clothes!",
197 other => "<self> pukes on <other>.", 170 other => "<self> pukes on <other>.",
198 self => "You puke on <other>.", 171 self => "You puke on <other>.",
199 }, 172 },
200 self => { 173 self => {
201 other => "<self> pukes on his clothes.", 174 other => "<self> pukes on G<his|her> clothes.",
202 self => "You puke on yourself.", 175 self => "You puke on yourself.",
203 }, 176 },
204 }, 177 },
205 strut => { 178 strut => {
206 noparams => { 179 noparams => {
279 target => "<self> winks at you.", 252 target => "<self> winks at you.",
280 other => "<self> winks at <other>.", 253 other => "<self> winks at <other>.",
281 self => "You wink suggestively at <other>.", 254 self => "You wink suggestively at <other>.",
282 }, 255 },
283 self => { 256 self => {
284 other => "<self> winks at himself - something strange is going on...", 257 other => "<self> winks at G<him|her>self - something strange is going on...",
285 self => "You wink at yourself?? What are you up to?", 258 self => "You wink at yourself?? What are you up to?",
286 }, 259 },
287 }, 260 },
288 pout => { 261 pout => {
289 noparams => { 262 noparams => {
295 self => { 268 self => {
296 }, 269 },
297 }, 270 },
298 cackle => { 271 cackle => {
299 noparams => { 272 noparams => {
300 other => "<self> throws back his head and cackles with insane glee!", 273 other => "<self> throws back G<his|her> head and cackles with insane glee!",
301 self => "You cackle gleefully.", 274 self => "You cackle gleefully.",
302 }, 275 },
303 params => { 276 params => {
304 }, 277 },
305 self => { 278 self => {
314 target => "<self> sniffs you.", 287 target => "<self> sniffs you.",
315 other => "<self> sniffs <other>", 288 other => "<self> sniffs <other>",
316 self => "You sniff <other>.", 289 self => "You sniff <other>.",
317 }, 290 },
318 self => { 291 self => {
319 other => "<self> sniffs himself.", 292 other => "<self> sniffs G<him|her>self.",
320 self => "You sniff yourself.", 293 self => "You sniff yourself.",
321 }, 294 },
322 }, 295 },
323 nod => { 296 nod => {
324 noparams => { 297 noparams => {
325 other => "<self> nods solemnly.", 298 other => "<self> nods solemnly.",
326 self => "You nod solemnly.", 299 self => "You nod solemnly.",
327 }, 300 },
328 params => { 301 params => {
329 target => "<self> nods solemnly to you.", 302 target => "<self> nods solemnly at you.",
330 other => "<self> nods solemnly to <other>.", 303 other => "<self> nods solemnly at <other>.",
331 self => "You nod solemnly to <other>.", 304 self => "You nod solemnly at <other>.",
332 }, 305 },
333 self => { 306 self => {
334 }, 307 },
335 }, 308 },
336 frown => { 309 frown => {
342 target => "<self> frowns darkly at you.", 315 target => "<self> frowns darkly at you.",
343 other => "<self> frowns darkly at <other>.", 316 other => "<self> frowns darkly at <other>.",
344 self => "You frown darkly at <other>.", 317 self => "You frown darkly at <other>.",
345 }, 318 },
346 self => { 319 self => {
347 other => "<self> frowns at himself.", 320 other => "<self> frowns at G<him|her>self.",
348 self => "You frown at yourself.", 321 self => "You frown at yourself.",
349 }, 322 },
350 }, 323 },
351 snicker => { 324 snicker => {
352 noparams => { 325 noparams => {
375 noparams => { 348 noparams => {
376 other => "<self> is bleeding all over the carpet - got a spare tourniquet?", 349 other => "<self> is bleeding all over the carpet - got a spare tourniquet?",
377 self => "You bleed all over your nice new armour.", 350 self => "You bleed all over your nice new armour.",
378 }, 351 },
379 params => { 352 params => {
380 target => "<self> slashes his wrist and bleeds all over you.", 353 target => "<self> slashes G<his|her> wrist and bleeds all over you.",
381 other => "<self> slashes his wrist and bleeds all over <other>.", 354 other => "<self> slashes G<his|her> wrist and bleeds all over <other>.",
382 self => "You slash your wrist and bleed all over <other>", 355 self => "You slash your wrist and bleed all over <other>",
383 }, 356 },
384 self => { 357 self => {
385 other => "<self> performs some satanic ritual while wiping his blood on himself.", 358 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.", 359 self => "Very impressive! You wipe your blood all over yourself.",
387 }, 360 },
388 }, 361 },
389 twiddle => { 362 twiddle => {
390 noparams => { 363 noparams => {
391 other => "<self> patiently twiddles his thumbs.", 364 other => "<self> patiently twiddles G<his|her> thumbs.",
392 self => "You patiently twiddle your thumbs.", 365 self => "You patiently twiddle your thumbs.",
393 }, 366 },
394 params => { 367 params => {
395 }, 368 },
396 self => { 369 self => {
397 }, 370 },
398 }, 371 },
399 spit => { 372 spit => {
400 noparams => { 373 noparams => {
401 other => "<self> spits over his left shoulder.", 374 other => "<self> spits over G<his|her> left shoulder.",
402 self => "You spit over your left shoulder.", 375 self => "You spit over your left shoulder.",
403 }, 376 },
404 params => { 377 params => {
405 target => "<self> spits in your face!", 378 target => "<self> spits in your face!",
406 other => "<self> spits in <other>'s face.", 379 other => "<self> spits in <other>'s face.",
407 self => "You spit on <other>.", 380 self => "You spit on <other>.",
408 }, 381 },
409 self => { 382 self => {
410 other => "<self> drools all over himself.", 383 other => "<self> drools all over G<him|her>self.",
411 self => "You drool all over yourself.", 384 self => "You drool all over yourself.",
412 }, 385 },
413 }, 386 },
414 glare => { 387 glare => {
415 noparams => { 388 noparams => {
416 other => "<self> glares around him.", 389 other => "<self> glares around G<him|her>.",
417 self => "You glare at nothing in particular.", 390 self => "You glare at nothing in particular.",
418 }, 391 },
419 params => { 392 params => {
420 target => "<self> glares icily at you, you feel cold to your bones.", 393 target => "<self> glares icily at you, you feel cold to your bones.",
421 other => "<self> glares at <other>.", 394 other => "<self> glares at <other>.",
422 self => "You glare icily at <other>.", 395 self => "You glare icily at <other>.",
423 }, 396 },
424 self => { 397 self => {
425 other => "<self> glares at his feet, what is bothering him?", 398 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.", 399 self => "You glare icily at your feet, they are suddenly very cold.",
427 }, 400 },
428 }, 401 },
429 bow => { 402 bow => {
430 noparams => { 403 noparams => {
435 target => "<self> bows before you.", 408 target => "<self> bows before you.",
436 other => "<self> bows before <other>.", 409 other => "<self> bows before <other>.",
437 self => "You bow before <other>.", 410 self => "You bow before <other>.",
438 }, 411 },
439 self => { 412 self => {
440 other => "<self> folds up like a jackknife and kisses his own toes.", 413 other => "<self> folds up like a jackknife and kisses G<his|her> own toes.",
441 self => "You kiss your toes.", 414 self => "You kiss your toes.",
442 }, 415 },
443 }, 416 },
444 dance => { 417 dance => {
445 noparams => { 418 noparams => {
446 other => "<self> expresses himself through interpretive dance.", 419 other => "<self> expresses G<him|her>self through interpretive dance.",
447 self => "You dance with glee.", 420 self => "You dance with glee.",
448 }, 421 },
449 params => { 422 params => {
450 target => "<self> grabs you, and begins dancing!", 423 target => "<self> grabs you, and begins dancing!",
451 other => "Yipe! <self> and <other> are doing the Macarena!", 424 other => "Yipe! <self> and <other> are doing the Macarena!",
452 self => "You grab <other> and begin doing the Cha-Cha!", 425 self => "You grab <other> and begin doing the Cha-Cha!",
453 }, 426 },
454 self => { 427 self => {
455 other => "<self> embraces himself and begins to dance!", 428 other => "<self> embraces G<him|her>self and begins to dance!",
456 self => "You skip and dance around by yourself.", 429 self => "You skip and dance around by yourself.",
457 }, 430 },
458 }, 431 },
459 snore => { 432 snore => {
460 noparams => { 433 noparams => {
476 self => { 449 self => {
477 }, 450 },
478 }, 451 },
479 snap => { 452 snap => {
480 noparams => { 453 noparams => {
481 other => "<self> snaps his fingers.", 454 other => "<self> snaps G<his|her> fingers.",
482 self => "PRONTO! you snap your fingers.", 455 self => "PRONTO! you snap your fingers.",
483 }, 456 },
484 params => { 457 params => {
485 }, 458 },
486 self => { 459 self => {
495 target => "<self> waves goodbye to you. Have a good journey.", 468 target => "<self> waves goodbye to you. Have a good journey.",
496 other => "<self> waves goodbye to <other>.", 469 other => "<self> waves goodbye to <other>.",
497 self => "You wave goodbye to <other>.", 470 self => "You wave goodbye to <other>.",
498 }, 471 },
499 self => { 472 self => {
500 other => "<self> waves goodbye to himself.", 473 other => "<self> waves goodbye to G<him|her>self.",
501 self => "Are you going on adventures as well??", 474 self => "Are you going on adventures as well??",
502 }, 475 },
503 }, 476 },
504 smile => { 477 smile => {
505 noparams => { 478 noparams => {
519 other => "<self> sneezes.", 492 other => "<self> sneezes.",
520 self => "Gesundheit!", 493 self => "Gesundheit!",
521 }, 494 },
522 params => { 495 params => {
523 target => "<self> sneezes on you, you feel the snot cover you. EEEEEEW.", 496 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.", 497 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.", 498 self => "You sneeze at <other> and a film of snot shoots onto G<him|her>.",
526 }, 499 },
527 self => { 500 self => {
528 other => "<self> sneezes, and covers himself in a slimy substance.", 501 other => "<self> sneezes, and covers G<him|her>self in a slimy substance.",
529 self => "You sneeze on yourself, what a mess!", 502 self => "You sneeze on yourself, what a mess!",
530 }, 503 },
531 }, 504 },
532 bounce => { 505 bounce => {
533 noparams => { 506 noparams => {
542 self => { 515 self => {
543 }, 516 },
544 }, 517 },
545 shake => { 518 shake => {
546 noparams => { 519 noparams => {
547 other => "<self> shakes his head.", 520 other => "<self> shakes G<his|her> head.",
548 self => "You shake your head.", 521 self => "You shake your head.",
549 }, 522 },
550 params => { 523 params => {
551 target => "<self> shakes your hand.", 524 target => "<self> shakes your hand.",
552 other => "<self> shakes <other>'s hand.", 525 other => "<self> shakes <other>'s hand.",
557 self => "You are shaken by yourself.", 530 self => "You are shaken by yourself.",
558 }, 531 },
559 }, 532 },
560 lick => { 533 lick => {
561 noparams => { 534 noparams => {
562 other => "<self> licks his mouth and smiles.", 535 other => "<self> licks G<his|her> mouth and smiles.",
563 self => "You lick your mouth and smile.", 536 self => "You lick your mouth and smile.",
564 }, 537 },
565 params => { 538 params => {
566 target => "<self> licks you.", 539 target => "<self> licks you.",
567 other => "<self> licks <other>.", 540 other => "<self> licks <other>.",
568 self => "You lick <other>.", 541 self => "You lick <other>.",
569 }, 542 },
570 self => { 543 self => {
571 other => "<self> licks himself - YUCK.", 544 other => "<self> licks G<him|her>self - YUCK.",
572 self => "You lick yourself.", 545 self => "You lick yourself.",
573 }, 546 },
574 }, 547 },
575 flip => { 548 flip => {
576 noparams => { 549 noparams => {
582 self => { 555 self => {
583 }, 556 },
584 }, 557 },
585 think => { 558 think => {
586 noparams => { 559 noparams => {
587 other => "<self> closes his eyes and thinks really hard.", 560 other => "<self> closes G<his|her> eyes and thinks really hard.",
588 self => "Anything in particular that you'd care to think about?", 561 self => "Anything in particular that you'd care to think about?",
589 }, 562 },
590 params => { 563 params => {
591 }, 564 },
592 self => { 565 self => {
656 target => "<self> cries on your shoulder.", 629 target => "<self> cries on your shoulder.",
657 other => "<self> cries on <other>'s shoulder.", 630 other => "<self> cries on <other>'s shoulder.",
658 self => "You cry on <other>'s shoulder.", 631 self => "You cry on <other>'s shoulder.",
659 }, 632 },
660 self => { 633 self => {
661 other => "<self> sobs quietly to himself.", 634 other => "<self> sobs quietly to G<him|her>self.",
662 self => "You cry to yourself.", 635 self => "You cry to yourself.",
663 }, 636 },
664 }, 637 },
665 sulk => { 638 sulk => {
666 noparams => { 639 noparams => {
680 params => { 653 params => {
681 target => "<self> whistles at <other>.", 654 target => "<self> whistles at <other>.",
682 self => "You whistle at <other>.", 655 self => "You whistle at <other>.",
683 }, 656 },
684 self => { 657 self => {
685 other => "<self> whistles to himself in boredom.", 658 other => "<self> whistles to G<him|her>self in boredom.",
686 self => "You whistle while you work.", 659 self => "You whistle while you work.",
687 }, 660 },
688 }, 661 },
689 groan => { 662 groan => {
690 noparams => { 663 noparams => {
736 709
737 $emote{other} ||= "You look away from <self>."; 710 $emote{other} ||= "You look away from <self>.";
738 $emote{self} ||= "My god! Is that LEGAL?"; 711 $emote{self} ||= "My god! Is that LEGAL?";
739 712
740 $emote{other} =~ s/<self>/$name/; 713 $emote{other} =~ s/<self>/$name/;
714
715 $_ = $pl->expand_cfpod ($_)
716 for values %emote;
741 717
742 send_msg $_, $CHAT_CHANNEL, $emote{other}, cf::NDI_GREY, "msg_chat" 718 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; 719 for grep { $ob->on_same_map_as ($_->ob) && $_ != $ob} cf::player::list;
744 720
745 $pl->send_msg ($emote{self}, cf::NDI_GREY | cf::NDI_REPLY); 721 $pl->send_msg ($emote{self}, cf::NDI_GREY | cf::NDI_REPLY | cf::NDI_VERBATIM);
746 } elsif ($tname) { 722 } elsif ($tname) {
747 my $target = cf::player::find $tname 723 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"; 724 or return send_msg $pl, tell_channel $tname, "$tname is not around.", cf::NDI_DK_ORANGE | cf::NDI_REPLY, "msg_chat";
749 725
750 my %emote = %{ $emotes->{$emotion}->{params} || {} }; 726 my %emote = %{ $emotes->{$emotion}->{params} || {} };
756 $emote{self} =~ s/<other>/$tname/; 732 $emote{self} =~ s/<other>/$tname/;
757 $emote{target} =~ s/<self>/$name/; 733 $emote{target} =~ s/<self>/$name/;
758 $emote{other} =~ s/<other>/$tname/; 734 $emote{other} =~ s/<other>/$tname/;
759 $emote{other} =~ s/<self>/$name/; 735 $emote{other} =~ s/<self>/$name/;
760 736
737 $_ = $pl->expand_cfpod ($_)
738 for values %emote;
739
761 send_msg $_, $CHAT_CHANNEL, $emote{other}, cf::NDI_GREY, "msg_chat" 740 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; 741 for grep { $_ != $pl && $_ != $target && $ob->on_same_map_as ($_->ob) } cf::player::list;
763 742
764 send_msg $target, tell_channel $name, $emote{target}, cf::NDI_GREY, "msg_shout"; 743 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); 744 $pl->send_msg (tell_channel $tname, $emote{self}, cf::NDI_GREY | cf::NDI_REPLY | cf::NDI_VERBATIM);
766 } else { 745 } else {
767 my %emote = %{ $emotes->{$emotion}->{noparams} || {} }; 746 my %emote = %{ $emotes->{$emotion}->{noparams} || {} };
768 747
769 $emote{other} ||= "<self> dances with glee."; 748 $emote{other} ||= "<self> dances with glee.";
770 $emote{self} ||= "You are a nut."; 749 $emote{self} ||= "You are a nut.";
771 750
772 $emote{other} =~ s/<self>/$name/; 751 $emote{other} =~ s/<self>/$name/;
773 752
753 $_ = $pl->expand_cfpod ($_)
754 for values %emote;
755
774 send_msg $_, $CHAT_CHANNEL, $emote{other}, cf::NDI_GREY, "msg_chat" 756 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; 757 for grep { $ob->on_same_map_as ($_->ob) && $_ != $pl } cf::player::list;
776 758
777 $pl->send_msg ($CHAT_CHANNEL, $emote{self}, cf::NDI_GREY | cf::NDI_REPLY); 759 $pl->send_msg ($cf::CHAT_CHANNEL, $emote{self}, cf::NDI_GREY | cf::NDI_REPLY | cf::NDI_VERBATIM);
778 } 760 }
779 }; 761 };
780 }; 762 };
781} 763}
782 764
783cf::register_command me => sub { 765cf::register_command me => sub {
784 my ($pl, $msg) = @_; 766 my ($pl, $msg) = @_;
785 767
786 my $name = $pl->name; 768 my $name = $pl->name;
787 769
788 send_msg $_, $SAY_CHANNEL => "* $name $msg", cf::NDI_GREY | cf::NDI_DEF | ($_ == $pl ? cf::NDI_REPLY : 0), "msg_say" 770 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; 771 for grep $pl->on_same_map_as ($_->ob), cf::player::list;
790}; 772};
791 773
792cf::register_command say => sub { 774cf::register_command say => sub {
793 my ($ob, $msg) = @_; 775 my ($ob, $msg) = @_;
798 780
799 if ($msg) { 781 if ($msg) {
800 my $name = $ob->name; 782 my $name = $ob->name;
801 my @plonmap = grep $ob->on_same_map_as ($_->ob), cf::player::list; 783 my @plonmap = grep $ob->on_same_map_as ($_->ob), cf::player::list;
802 784
803 send_msg $_, $SAY_CHANNEL => "$name says: $msg", cf::NDI_GREY, "msg_say" 785 send_msg $_, $cf::SAY_CHANNEL => "$name says: $msg", cf::NDI_GREY, "msg_say"
804 for grep $_ != $ob->contr, @plonmap; 786 for grep $_ != $ob->contr, @plonmap;
805 $ob->contr->send_msg ($SAY_CHANNEL => "$name says: $msg", cf::NDI_GREY | cf::NDI_REPLY); 787 $ob->contr->send_msg ($cf::SAY_CHANNEL => "$name says: $msg", cf::NDI_GREY | cf::NDI_REPLY);
806 788
807 # npcs, magic_ears etc. 789 # npcs, magic_ears etc.
808 # first find all objects and their first-level inventories 790 # first find all objects and their first-level inventories
809 # within a 5x5 square that have something resembling 791 # within a 5x5 square that have something resembling
810 # dialogue or support on_say. 792 # dialogue or support on_say.
811 my ($map, $x, $y) = ($ob->map, $ob->x - 2, $ob->y - 2); 793 my ($map, $x, $y) = ($ob->map, $ob->x - 2, $ob->y - 2);
812 794
813 for my $npc ( 795 for my $npc (
814 grep +($_->invoke (cf::EVENT_OBJECT_SAY, $ob->contr, $msg) && return) || NPC_Dialogue::has_dialogue $_, 796 grep +($_->invoke (cf::EVENT_OBJECT_SAY, $ob->contr, $msg) && return) || $_->has_dialogue,
815 map +($_, $_->inv), 797 map +($_, $_->inv),
816 grep $_, 798 grep $_,
817 map $map->at ($x + $_ % 5, $y + (int $_ / 5)), 799 map $map->at ($x + $_ % 5, $y + (int $_ / 5)),
818 0..24 800 0..24
819 ) { 801 ) {
823 my $dialog = new NPC_Dialogue pl => $ob->contr, npc => $npc; 805 my $dialog = new NPC_Dialogue pl => $ob->contr, npc => $npc;
824 my ($reply, @kw) = $dialog->tell ($msg); 806 my ($reply, @kw) = $dialog->tell ($msg);
825 807
826 if (defined $reply) { 808 if (defined $reply) {
827 if ($npc->type == cf::MAGIC_EAR) { 809 if ($npc->type == cf::MAGIC_EAR) {
828 if (length $reply) {
829 send_msg $_, $SAY_CHANNEL => $reply, cf::NDI_BROWN, "msg_say" 810 send_msg $_, $cf::SAY_CHANNEL => $reply, cf::NDI_BROWN, "msg_say"
830 for @plonmap; 811 for @plonmap;
831 }
832 $npc->use_trigger;
833 } else { 812 } else {
834 if (length $reply) {
835 send_msg $_, $SAY_CHANNEL => $npc->name . " says: $reply", cf::NDI_BROWN, "msg_say" 813 send_msg $_, $cf::SAY_CHANNEL => $npc->name . " says: $reply", cf::NDI_BROWN, "msg_say"
836 for @plonmap; 814 for @plonmap;
837 }
838 } 815 }
839 } 816 }
840 817
841 if (@kw) { 818 if (@kw) {
842 $_->send_msg ($SAY_CHANNEL => "[further topics: " . (join ", ", @kw) . "]", cf::NDI_BROWN) 819 $_->send_msg ($cf::SAY_CHANNEL => "[further topics: " . (join ", ", @kw) . "]", cf::NDI_BROWN)
843 for @plonmap; 820 for @plonmap;
844 } 821 }
845 } 822 }
846 823
847 } else { 824 } else {
848 $ob->send_msg ($SAY_CHANNEL => "What do you want to say?", cf::NDI_GREY | cf::NDI_REPLY); 825 $ob->send_msg ($cf::SAY_CHANNEL => "What do you want to say?", cf::NDI_GREY | cf::NDI_REPLY);
849 } 826 }
850}; 827};
851 828
852cf::register_command chat => sub { 829cf::register_command chat => sub {
853 my ($ob, $msg) = @_; 830 my ($ob, $msg) = @_;
863 my $NOW = time; 840 my $NOW = time;
864 841
865 cf::LOG cf::llevDebug, sprintf "QBERT [%s] %s\n", $name, $msg; 842 cf::LOG cf::llevDebug, sprintf "QBERT [%s] %s\n", $name, $msg;
866 send_irc ("[%s] %s", $name, $msg); 843 send_irc ("[%s] %s", $name, $msg);
867 844
868 send_msg $_, $CHAT_CHANNEL => "$name chats: $msg", cf::NDI_BLUE | cf::NDI_DEF | ($_ == $pl ? cf::NDI_REPLY : 0), "msg_chat" 845 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; 846 for grep { $_->ob->{ext_ignore_shout}{$name} < $NOW } cf::player::list;
870 847
871 } else { 848 } else {
872 $pl->send_msg ($CHAT_CHANNEL => "Chat what?", cf::NDI_BLUE | cf::NDI_DEF | cf::NDI_REPLY); 849 $pl->send_msg ($cf::CHAT_CHANNEL => "Chat what?", cf::NDI_BLUE | cf::NDI_DEF | cf::NDI_REPLY);
873 } 850 }
874}; 851};
875 852
876cf::register_command shout => sub { 853cf::register_command shout => sub {
877 my ($ob, $msg) = @_; 854 my ($ob, $msg) = @_;
887 my $name = $ob->name; 864 my $name = $ob->name;
888 865
889 cf::LOG cf::llevDebug, sprintf "QBERT {%s} %s\n", $name, $msg; 866 cf::LOG cf::llevDebug, sprintf "QBERT {%s} %s\n", $name, $msg;
890 send_irc ("\007\0034{%s} %s\n", $name, $msg); 867 send_irc ("\007\0034{%s} %s\n", $name, $msg);
891 868
892 send_msg $_, $CHAT_CHANNEL => "$name shouts: $msg", cf::NDI_RED | cf::NDI_DEF | ($_ == $pl ? cf::NDI_REPLY : 0), "msg_shout" 869 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; 870 for grep { $_->ob->{ext_ignore_shout}{$name} < $NOW } cf::player::list;
894 871
895 } else { 872 } else {
896 $pl->send_msg ($CHAT_CHANNEL => "Shout what?", cf::NDI_RED | cf::NDI_DEF | cf::NDI_REPLY); 873 $pl->send_msg ($cf::CHAT_CHANNEL => "Shout what?", cf::NDI_RED | cf::NDI_DEF | cf::NDI_REPLY);
897 } 874 }
898}; 875};
899 876
900cf::register_command tell => sub { 877cf::register_command tell => sub {
901 my ($ob, $args) = @_; 878 my ($ob, $args) = @_;
943 920
944cf::register_command ignore => sub { 921cf::register_command ignore => sub {
945 my ($pl, $args) = @_; 922 my ($pl, $args) = @_;
946 my ($target, $type, $timeout) = split /\s+/, $args; 923 my ($target, $type, $timeout) = split /\s+/, $args;
947 924
925 cf::async {
948 if ($args eq "list") { 926 if ($args eq "list") {
949 clean_timeouts $pl; 927 clean_timeouts $pl;
950 928
951 if ((my @ignored_tell = sort keys %{$pl->{ext_ignore_tell}}) 929 if ((my @ignored_tell = sort keys %{$pl->{ext_ignore_tell}})
952 + (my @ignored_shout = sort keys %{$pl->{ext_ignore_shout}})) { 930 + (my @ignored_shout = sort keys %{$pl->{ext_ignore_shout}})) {
953 $pl->message ("Currently ignoring private messages from: ", cf::NDI_REPLY); 931 $pl->message ("Currently ignoring private messages from: ", cf::NDI_REPLY);
954 $pl->message ((join ", ", @ignored_tell), cf::NDI_REPLY); 932 $pl->message ((join ", ", @ignored_tell), cf::NDI_REPLY);
955 $pl->message ("Currently ignoring shouts from: ", cf::NDI_REPLY); 933 $pl->message ("Currently ignoring shouts from: ", cf::NDI_REPLY);
956 $pl->message ((join ", ", @ignored_shout), cf::NDI_REPLY); 934 $pl->message ((join ", ", @ignored_shout), cf::NDI_REPLY);
957 $pl->message ("To stop ignoring one, use unignore.", cf::NDI_REPLY); 935 $pl->message ("To stop ignoring one, use unignore.", cf::NDI_REPLY);
936 } else {
937 $pl->message ("Not ignoring anyone", cf::NDI_REPLY);
938 }
939
940 } elsif ($target && $type) {
941 $timeout ne "" or $timeout = 24;
942 my $absolute_timeout = time + $timeout * 3600;
943
944 if (cf::player::exists $target) {
945 if ($type eq "tell") {
946 $pl->message ("Now ignoring private messages from $target for $timeout hours.", cf::NDI_REPLY);
947 $pl->{ext_ignore_tell}{$target} = $absolute_timeout;
948 } elsif ($type eq "shout") {
949 $pl->message ("Now ignoring shouts from $target for $timeout hours.", cf::NDI_REPLY);
950 $pl->{ext_ignore_shout}{$target} = $absolute_timeout;
951 } elsif ($type eq "all") {
952 $pl->message ("Now ignoring everything from $target for $timeout hours.", cf::NDI_REPLY);
953 $pl->{ext_ignore_tell}{$target} = $absolute_timeout;
954 $pl->{ext_ignore_shout}{$target} = $absolute_timeout;
955 } else {
956 $pl->message ("You need to specify tell, shout or all.", cf::NDI_REPLY);
957 }
958 } else {
959 $pl->message ("No such player: $target", cf::NDI_REPLY);
960 }
961
958 } else { 962 } else {
959 $pl->message ("Not ignoring anyone", cf::NDI_REPLY); 963 $pl->message ("Usage: ignore <player> <tell|shout|all> <timeout>\n"
964 . "will ignore a player for <timeout> hours.\n"
965 . "Usage: ignore list\n"
966 . "will show you a list of players currently ignored.", cf::NDI_REPLY);
960 } 967 }
961
962 } elsif ($target && $type) {
963
964 $timeout ne "" or $timeout = 24;
965 my $absolute_timeout = time + $timeout * 3600;
966
967 if (cf::player::exists $target) {
968 if ($type eq "tell") {
969 $pl->message ("Now ignoring private messages from $target for $timeout hours.", cf::NDI_REPLY);
970 $pl->{ext_ignore_tell}{$target} = $absolute_timeout;
971 } elsif ($type eq "shout") {
972 $pl->message ("Now ignoring shouts from $target for $timeout hours.", cf::NDI_REPLY);
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;
978 } else {
979 $pl->message ("You need to specify tell, shout or all.", cf::NDI_REPLY);
980 }
981 } else {
982 $pl->message ("No such player: $target", cf::NDI_REPLY);
983 }
984
985 } else {
986 $pl->message ("Usage: ignore <player> <tell|shout|all> <timeout>\n"
987 . "will ignore a player for <timeout> hours.\n"
988 . "Usage: ignore list\n"
989 . "will show you a list of players currently ignored.", cf::NDI_REPLY);
990 } 968 };
991}; 969};
992 970
993cf::register_command unignore => sub { 971cf::register_command unignore => sub {
994 my ($pl, $args) = @_; 972 my ($pl, $args) = @_;
995 my ($target, $type) = split /\s+/, $args; 973 my ($target, $type) = split /\s+/, $args;
996 974
975 cf::async {
997 if ($args eq "") { 976 if ($args eq "") {
998 if ($pl->{ext_ignore_tell}) { 977 if ($pl->{ext_ignore_tell}) {
999 $pl->message ("Currently ignoring private messages from: ", cf::NDI_REPLY); 978 $pl->message ("Currently ignoring private messages from: ", cf::NDI_REPLY);
1000 $pl->message ((join ", ", sort keys %{ $pl->{ext_ignore_tell} }), cf::NDI_REPLY); 979 $pl->message ((join ", ", sort keys %{ $pl->{ext_ignore_tell} }), cf::NDI_REPLY);
1001 $pl->message ("Currently ignoring shouts from: ", cf::NDI_REPLY); 980 $pl->message ("Currently ignoring shouts from: ", cf::NDI_REPLY);
1002 $pl->message ((join ", ", sort keys %{ $pl->{ext_ignore_shout} }), cf::NDI_REPLY); 981 $pl->message ((join ", ", sort keys %{ $pl->{ext_ignore_shout} }), cf::NDI_REPLY);
1003 } else {
1004 $pl->message ("Not ignoring anyone", cf::NDI_REPLY);
1005 }
1006 } else {
1007 if (cf::player::exists $target) {
1008 if ($type eq "tell") {
1009 $pl->message ("Not ignoring private messages from $target anymore.", cf::NDI_REPLY);
1010 delete $pl->{ext_ignore_tell} {$target};
1011 } elsif ($type eq "shout") {
1012 $pl->message ("Not ignoring shouts from $target anymore.", cf::NDI_REPLY);
1013 delete $pl->{ext_ignore_shout}{$target};
1014 } elsif ($type eq "all") {
1015 $pl->message ("Not ignoring anything from $target anymore.", cf::NDI_REPLY);
1016 delete $pl->{ext_ignore_tell} {$target};
1017 delete $pl->{ext_ignore_shout}{$target};
1018 } else { 982 } else {
1019 $pl->message ("You need to specify tell, shout or all.", cf::NDI_REPLY); 983 $pl->message ("Not ignoring anyone", cf::NDI_REPLY);
1020 } 984 }
1021 } else { 985 } else {
986 if (cf::player::exists $target) {
987 if ($type eq "tell") {
988 $pl->message ("Not ignoring private messages from $target anymore.", cf::NDI_REPLY);
989 delete $pl->{ext_ignore_tell} {$target};
990 } elsif ($type eq "shout") {
991 $pl->message ("Not ignoring shouts from $target anymore.", cf::NDI_REPLY);
992 delete $pl->{ext_ignore_shout}{$target};
993 } elsif ($type eq "all") {
994 $pl->message ("Not ignoring anything from $target anymore.", cf::NDI_REPLY);
995 delete $pl->{ext_ignore_tell} {$target};
996 delete $pl->{ext_ignore_shout}{$target};
997 } else {
998 $pl->message ("You need to specify tell, shout or all.", cf::NDI_REPLY);
999 }
1000 } else {
1022 $pl->message ("No such player or ambiguous name: $target", cf::NDI_REPLY); 1001 $pl->message ("No such player or ambiguous name: $target", cf::NDI_REPLY);
1002 }
1023 } 1003 }
1024 } 1004 };
1025}; 1005};
1026 1006

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines