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.49 by root, Mon Jan 26 00:10:38 2009 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;
61cf::player->attach ( 54cf::player->attach (
62 prio => -1000, 55 prio => -1000,
63 on_login => sub { 56 on_login => sub {
64 my ($pl) = @_; 57 my ($pl) = @_;
65 58
59 cf::async {
66 clean_timeouts $pl->ob; 60 clean_timeouts $pl->ob;
61 };
67 62
68 $pl->send_msg ($SAY_CHANNEL); 63 $pl->send_msg ($cf::SAY_CHANNEL);
69 $pl->send_msg ($CHAT_CHANNEL); 64 $pl->send_msg ($cf::CHAT_CHANNEL);
70 }, 65 },
71); 66);
72 67
68# TODO: remove once safe
73cf::register_command listen => sub { 69cf::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}; 70};
91 71
92cf::register_command cointoss => sub { 72cf::register_command cointoss => sub {
93 my ($ob, $msg) = @_; 73 my ($ob, $msg) = @_;
94 74
95 my $pl = $ob->contr; 75 my $pl = $ob->contr;
96 my $name = $ob->name; 76 my $name = $ob->name;
97 77
98 my $coin = int rand 2 ? "Heads" : "Tails"; 78 my $coin = int rand 2 ? "Heads" : "Tails";
99 79
100 $_->send_msg ($SAY_CHANNEL => "$name flips a coin.... $coin!", cf::NDI_GREY) 80 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; 81 for grep { $ob->on_same_map_as ($_->ob) && $_ != $pl} cf::player::list;
102 82
103 $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);
104}; 84};
105 85
106cf::register_command orcknuckle => sub { 86cf::register_command orcknuckle => sub {
107 my ($ob, $msg) = @_; 87 my ($ob, $msg) = @_;
108 88
111 91
112 my @orcknuckle = ("beholder", "ghost", "knight", "princess", "dragon", "orc"); 92 my @orcknuckle = ("beholder", "ghost", "knight", "princess", "dragon", "orc");
113 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);
114 my $result = "$orcknuckle[$i], $orcknuckle[$j], $orcknuckle[$k], $orcknuckle[$l]"; 94 my $result = "$orcknuckle[$i], $orcknuckle[$j], $orcknuckle[$k], $orcknuckle[$l]";
115 95
116 $_->send_msg ($SAY_CHANNEL => "$name throws his orc-knuckles and rolls $result!", cf::NDI_GREY) 96 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; 97 for grep { $ob->on_same_map_as ($_->ob) && $_ != $pl} cf::player::list;
118 98
119 $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);
120}; 100};
121 101
122my $emotes = { 102my $emotes = {
123 growl => { 103 growl => {
124 noparams => { 104 noparams => {
170 self => { 150 self => {
171 }, 151 },
172 }, 152 },
173 scream => { 153 scream => {
174 noparams => { 154 noparams => {
175 other => "<self> screams at the top of his lungs!", 155 other => "<self> screams at the top of G<his|her> lungs!",
176 self => "ARRRRRRRRRRGH!!!!!", 156 self => "ARRRRRRRRRRGH!!!!!",
177 }, 157 },
178 params => { 158 params => {
179 }, 159 },
180 self => { 160 self => {
189 target => "<self> pukes on your clothes!", 169 target => "<self> pukes on your clothes!",
190 other => "<self> pukes on <other>.", 170 other => "<self> pukes on <other>.",
191 self => "You puke on <other>.", 171 self => "You puke on <other>.",
192 }, 172 },
193 self => { 173 self => {
194 other => "<self> pukes on his clothes.", 174 other => "<self> pukes on G<his|her> clothes.",
195 self => "You puke on yourself.", 175 self => "You puke on yourself.",
196 }, 176 },
197 }, 177 },
198 strut => { 178 strut => {
199 noparams => { 179 noparams => {
248 self => "You kiss <other>.", 228 self => "You kiss <other>.",
249 }, 229 },
250 self => { 230 self => {
251 }, 231 },
252 }, 232 },
233 smother => {
234 noparams => {
235 other => "<self> makes weird facial contortions",
236 self => "All the lonely people..",
237 },
238 params => {
239 target => "<self> smothers you with kisses.",
240 other => "<self> smothers <other> with kisses.",
241 self => "You smother <other> with kisses.",
242 },
243 self => {
244 },
245 },
253 wink => { 246 wink => {
254 noparams => { 247 noparams => {
255 other => "<self> winks suggestively.", 248 other => "<self> winks suggestively.",
256 self => "Have you got something in your eye?", 249 self => "Have you got something in your eye?",
257 }, 250 },
259 target => "<self> winks at you.", 252 target => "<self> winks at you.",
260 other => "<self> winks at <other>.", 253 other => "<self> winks at <other>.",
261 self => "You wink suggestively at <other>.", 254 self => "You wink suggestively at <other>.",
262 }, 255 },
263 self => { 256 self => {
264 other => "<self> winks at himself - something strange is going on...", 257 other => "<self> winks at G<him|her>self - something strange is going on...",
265 self => "You wink at yourself?? What are you up to?", 258 self => "You wink at yourself?? What are you up to?",
266 }, 259 },
267 }, 260 },
268 pout => { 261 pout => {
269 noparams => { 262 noparams => {
275 self => { 268 self => {
276 }, 269 },
277 }, 270 },
278 cackle => { 271 cackle => {
279 noparams => { 272 noparams => {
280 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!",
281 self => "You cackle gleefully.", 274 self => "You cackle gleefully.",
282 }, 275 },
283 params => { 276 params => {
284 }, 277 },
285 self => { 278 self => {
294 target => "<self> sniffs you.", 287 target => "<self> sniffs you.",
295 other => "<self> sniffs <other>", 288 other => "<self> sniffs <other>",
296 self => "You sniff <other>.", 289 self => "You sniff <other>.",
297 }, 290 },
298 self => { 291 self => {
299 other => "<self> sniffs himself.", 292 other => "<self> sniffs G<him|her>self.",
300 self => "You sniff yourself.", 293 self => "You sniff yourself.",
301 }, 294 },
302 }, 295 },
303 nod => { 296 nod => {
304 noparams => { 297 noparams => {
305 other => "<self> nods solemnly.", 298 other => "<self> nods solemnly.",
306 self => "You nod solemnly.", 299 self => "You nod solemnly.",
307 }, 300 },
308 params => { 301 params => {
309 target => "<self> nods solemnly to you.", 302 target => "<self> nods solemnly at you.",
310 other => "<self> nods solemnly to <other>.", 303 other => "<self> nods solemnly at <other>.",
311 self => "You nod solemnly to <other>.", 304 self => "You nod solemnly at <other>.",
312 }, 305 },
313 self => { 306 self => {
314 }, 307 },
315 }, 308 },
316 frown => { 309 frown => {
322 target => "<self> frowns darkly at you.", 315 target => "<self> frowns darkly at you.",
323 other => "<self> frowns darkly at <other>.", 316 other => "<self> frowns darkly at <other>.",
324 self => "You frown darkly at <other>.", 317 self => "You frown darkly at <other>.",
325 }, 318 },
326 self => { 319 self => {
327 other => "<self> frowns at himself.", 320 other => "<self> frowns at G<him|her>self.",
328 self => "You frown at yourself.", 321 self => "You frown at yourself.",
329 }, 322 },
330 }, 323 },
331 snicker => { 324 snicker => {
332 noparams => { 325 noparams => {
355 noparams => { 348 noparams => {
356 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?",
357 self => "You bleed all over your nice new armour.", 350 self => "You bleed all over your nice new armour.",
358 }, 351 },
359 params => { 352 params => {
360 target => "<self> slashes his wrist and bleeds all over you.", 353 target => "<self> slashes G<his|her> wrist and bleeds all over you.",
361 other => "<self> slashes his wrist and bleeds all over <other>.", 354 other => "<self> slashes G<his|her> wrist and bleeds all over <other>.",
362 self => "You slash your wrist and bleed all over <other>", 355 self => "You slash your wrist and bleed all over <other>",
363 }, 356 },
364 self => { 357 self => {
365 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.",
366 self => "Very impressive! You wipe your blood all over yourself.", 359 self => "Very impressive! You wipe your blood all over yourself.",
367 }, 360 },
368 }, 361 },
369 twiddle => { 362 twiddle => {
370 noparams => { 363 noparams => {
371 other => "<self> patiently twiddles his thumbs.", 364 other => "<self> patiently twiddles G<his|her> thumbs.",
372 self => "You patiently twiddle your thumbs.", 365 self => "You patiently twiddle your thumbs.",
373 }, 366 },
374 params => { 367 params => {
375 }, 368 },
376 self => { 369 self => {
377 }, 370 },
378 }, 371 },
379 spit => { 372 spit => {
380 noparams => { 373 noparams => {
381 other => "<self> spits over his left shoulder.", 374 other => "<self> spits over G<his|her> left shoulder.",
382 self => "You spit over your left shoulder.", 375 self => "You spit over your left shoulder.",
383 }, 376 },
384 params => { 377 params => {
385 target => "<self> spits in your face!", 378 target => "<self> spits in your face!",
386 other => "<self> spits in <other>'s face.", 379 other => "<self> spits in <other>'s face.",
387 self => "You spit on <other>.", 380 self => "You spit on <other>.",
388 }, 381 },
389 self => { 382 self => {
390 other => "<self> drools all over himself.", 383 other => "<self> drools all over G<him|her>self.",
391 self => "You drool all over yourself.", 384 self => "You drool all over yourself.",
392 }, 385 },
393 }, 386 },
394 glare => { 387 glare => {
395 noparams => { 388 noparams => {
396 other => "<self> glares around him.", 389 other => "<self> glares around G<him|her>.",
397 self => "You glare at nothing in particular.", 390 self => "You glare at nothing in particular.",
398 }, 391 },
399 params => { 392 params => {
400 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.",
401 other => "<self> glares at <other>.", 394 other => "<self> glares at <other>.",
402 self => "You glare icily at <other>.", 395 self => "You glare icily at <other>.",
403 }, 396 },
404 self => { 397 self => {
405 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>?",
406 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.",
407 }, 400 },
408 }, 401 },
409 bow => { 402 bow => {
410 noparams => { 403 noparams => {
415 target => "<self> bows before you.", 408 target => "<self> bows before you.",
416 other => "<self> bows before <other>.", 409 other => "<self> bows before <other>.",
417 self => "You bow before <other>.", 410 self => "You bow before <other>.",
418 }, 411 },
419 self => { 412 self => {
420 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.",
421 self => "You kiss your toes.", 414 self => "You kiss your toes.",
422 }, 415 },
423 }, 416 },
424 dance => { 417 dance => {
425 noparams => { 418 noparams => {
426 other => "<self> expresses himself through interpretive dance.", 419 other => "<self> expresses G<him|her>self through interpretive dance.",
427 self => "You dance with glee.", 420 self => "You dance with glee.",
428 }, 421 },
429 params => { 422 params => {
430 target => "<self> grabs you, and begins dancing!", 423 target => "<self> grabs you, and begins dancing!",
431 other => "Yipe! <self> and <other> are doing the Macarena!", 424 other => "Yipe! <self> and <other> are doing the Macarena!",
432 self => "You grab <other> and begin doing the Cha-Cha!", 425 self => "You grab <other> and begin doing the Cha-Cha!",
433 }, 426 },
434 self => { 427 self => {
435 other => "<self> embraces himself and begins to dance!", 428 other => "<self> embraces G<him|her>self and begins to dance!",
436 self => "You skip and dance around by yourself.", 429 self => "You skip and dance around by yourself.",
437 }, 430 },
438 }, 431 },
439 snore => { 432 snore => {
440 noparams => { 433 noparams => {
456 self => { 449 self => {
457 }, 450 },
458 }, 451 },
459 snap => { 452 snap => {
460 noparams => { 453 noparams => {
461 other => "<self> snaps his fingers.", 454 other => "<self> snaps G<his|her> fingers.",
462 self => "PRONTO! you snap your fingers.", 455 self => "PRONTO! you snap your fingers.",
463 }, 456 },
464 params => { 457 params => {
465 }, 458 },
466 self => { 459 self => {
475 target => "<self> waves goodbye to you. Have a good journey.", 468 target => "<self> waves goodbye to you. Have a good journey.",
476 other => "<self> waves goodbye to <other>.", 469 other => "<self> waves goodbye to <other>.",
477 self => "You wave goodbye to <other>.", 470 self => "You wave goodbye to <other>.",
478 }, 471 },
479 self => { 472 self => {
480 other => "<self> waves goodbye to himself.", 473 other => "<self> waves goodbye to G<him|her>self.",
481 self => "Are you going on adventures as well??", 474 self => "Are you going on adventures as well??",
482 }, 475 },
483 }, 476 },
484 smile => { 477 smile => {
485 noparams => { 478 noparams => {
499 other => "<self> sneezes.", 492 other => "<self> sneezes.",
500 self => "Gesundheit!", 493 self => "Gesundheit!",
501 }, 494 },
502 params => { 495 params => {
503 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.",
504 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>.",
505 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>.",
506 }, 499 },
507 self => { 500 self => {
508 other => "<self> sneezes, and covers himself in a slimy substance.", 501 other => "<self> sneezes, and covers G<him|her>self in a slimy substance.",
509 self => "You sneeze on yourself, what a mess!", 502 self => "You sneeze on yourself, what a mess!",
510 }, 503 },
511 }, 504 },
512 bounce => { 505 bounce => {
513 noparams => { 506 noparams => {
522 self => { 515 self => {
523 }, 516 },
524 }, 517 },
525 shake => { 518 shake => {
526 noparams => { 519 noparams => {
527 other => "<self> shakes his head.", 520 other => "<self> shakes G<his|her> head.",
528 self => "You shake your head.", 521 self => "You shake your head.",
529 }, 522 },
530 params => { 523 params => {
531 target => "<self> shakes your hand.", 524 target => "<self> shakes your hand.",
532 other => "<self> shakes <other>'s hand.", 525 other => "<self> shakes <other>'s hand.",
537 self => "You are shaken by yourself.", 530 self => "You are shaken by yourself.",
538 }, 531 },
539 }, 532 },
540 lick => { 533 lick => {
541 noparams => { 534 noparams => {
542 other => "<self> licks his mouth and smiles.", 535 other => "<self> licks G<his|her> mouth and smiles.",
543 self => "You lick your mouth and smile.", 536 self => "You lick your mouth and smile.",
544 }, 537 },
545 params => { 538 params => {
546 target => "<self> licks you.", 539 target => "<self> licks you.",
547 other => "<self> licks <other>.", 540 other => "<self> licks <other>.",
548 self => "You lick <other>.", 541 self => "You lick <other>.",
549 }, 542 },
550 self => { 543 self => {
551 other => "<self> licks himself - YUCK.", 544 other => "<self> licks G<him|her>self - YUCK.",
552 self => "You lick yourself.", 545 self => "You lick yourself.",
553 }, 546 },
554 }, 547 },
555 flip => { 548 flip => {
556 noparams => { 549 noparams => {
562 self => { 555 self => {
563 }, 556 },
564 }, 557 },
565 think => { 558 think => {
566 noparams => { 559 noparams => {
567 other => "<self> closes his eyes and thinks really hard.", 560 other => "<self> closes G<his|her> eyes and thinks really hard.",
568 self => "Anything in particular that you'd care to think about?", 561 self => "Anything in particular that you'd care to think about?",
569 }, 562 },
570 params => { 563 params => {
571 }, 564 },
572 self => { 565 self => {
636 target => "<self> cries on your shoulder.", 629 target => "<self> cries on your shoulder.",
637 other => "<self> cries on <other>'s shoulder.", 630 other => "<self> cries on <other>'s shoulder.",
638 self => "You cry on <other>'s shoulder.", 631 self => "You cry on <other>'s shoulder.",
639 }, 632 },
640 self => { 633 self => {
641 other => "<self> sobs quietly to himself.", 634 other => "<self> sobs quietly to G<him|her>self.",
642 self => "You cry to yourself.", 635 self => "You cry to yourself.",
643 }, 636 },
644 }, 637 },
645 sulk => { 638 sulk => {
646 noparams => { 639 noparams => {
660 params => { 653 params => {
661 target => "<self> whistles at <other>.", 654 target => "<self> whistles at <other>.",
662 self => "You whistle at <other>.", 655 self => "You whistle at <other>.",
663 }, 656 },
664 self => { 657 self => {
665 other => "<self> whistles to himself in boredom.", 658 other => "<self> whistles to G<him|her>self in boredom.",
666 self => "You whistle while you work.", 659 self => "You whistle while you work.",
667 }, 660 },
668 }, 661 },
669 groan => { 662 groan => {
670 noparams => { 663 noparams => {
716 709
717 $emote{other} ||= "You look away from <self>."; 710 $emote{other} ||= "You look away from <self>.";
718 $emote{self} ||= "My god! Is that LEGAL?"; 711 $emote{self} ||= "My god! Is that LEGAL?";
719 712
720 $emote{other} =~ s/<self>/$name/; 713 $emote{other} =~ s/<self>/$name/;
714
715 $_ = $pl->expand_cfpod ($_)
716 for values %emote;
721 717
722 $_->send_msg ($CHAT_CHANNEL, $emote{other}, cf::NDI_GREY) 718 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; 719 for grep { $ob->on_same_map_as ($_->ob) && $_ != $ob} cf::player::list;
724 720
725 $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);
726 } elsif ($tname) { 722 } elsif ($tname) {
727 my $target = cf::player::find $tname 723 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); 724 or return send_msg $pl, tell_channel $tname, "$tname is not around.", cf::NDI_DK_ORANGE | cf::NDI_REPLY, "msg_chat";
729 725
730 my %emote = %{ $emotes->{$emotion}->{params} || {} }; 726 my %emote = %{ $emotes->{$emotion}->{params} || {} };
731 727
732 $emote{other} ||= "<self> is eyeing <other> quizzically."; 728 $emote{other} ||= "<self> is eyeing <other> quizzically.";
733 $emote{self} ||= "You are still nuts."; 729 $emote{self} ||= "You are still nuts.";
734 $emote{target} ||= "You get the distinct feeling that <other> is nuts."; 730 $emote{target} ||= "You get the distinct feeling that <self> is nuts.";
735 731
736 $emote{self} =~ s/<other>/$tname/; 732 $emote{self} =~ s/<other>/$tname/;
737 $emote{target} =~ s/<self>/$name/; 733 $emote{target} =~ s/<self>/$name/;
738 $emote{other} =~ s/<other>/$tname/; 734 $emote{other} =~ s/<other>/$tname/;
739 $emote{other} =~ s/<self>/$name/; 735 $emote{other} =~ s/<self>/$name/;
740 736
741 $_->send_msg ($CHAT_CHANNEL, $emote{other}, cf::NDI_GREY) 737 $_ = $pl->expand_cfpod ($_)
738 for values %emote;
739
740 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; 741 for grep { $_ != $pl && $_ != $target && $ob->on_same_map_as ($_->ob) } cf::player::list;
743 742
744 $target->send_msg (tell_channel $name, $emote{target}, cf::NDI_GREY); 743 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); 744 $pl->send_msg (tell_channel $tname, $emote{self}, cf::NDI_GREY | cf::NDI_REPLY | cf::NDI_VERBATIM);
746 } else { 745 } else {
747 my %emote = %{ $emotes->{$emotion}->{noparams} || {} }; 746 my %emote = %{ $emotes->{$emotion}->{noparams} || {} };
748 747
749 $emote{other} ||= "<self> dances with glee."; 748 $emote{other} ||= "<self> dances with glee.";
750 $emote{self} ||= "You are a nut."; 749 $emote{self} ||= "You are a nut.";
751 750
752 $emote{other} =~ s/<self>/$name/; 751 $emote{other} =~ s/<self>/$name/;
753 752
754 $_->send_msg ($CHAT_CHANNEL, $emote{other}, cf::NDI_GREY) 753 $_ = $pl->expand_cfpod ($_)
754 for values %emote;
755
756 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; 757 for grep { $ob->on_same_map_as ($_->ob) && $_ != $pl } cf::player::list;
756 758
757 $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);
758 } 760 }
759 }; 761 };
760 }; 762 };
761} 763}
762 764
763cf::register_command me => sub {
764 my ($pl, $msg) = @_;
765
766 my $name = $pl->name;
767
768 $_->send_msg ($SAY_CHANNEL => "* $name $msg", cf::NDI_GREY | cf::NDI_DEF | ($_ == $pl ? cf::NDI_REPLY : 0))
769 for grep $pl->on_same_map_as ($_->ob), cf::player::list;
770};
771
772cf::register_command say => sub { 765cf::register_command say => sub {
773 my ($ob, $msg) = @_; 766 my ($ob, $msg) = @_;
774 767
775 utf8::decode $msg; 768 utf8::decode $msg;
776 769
778 771
779 if ($msg) { 772 if ($msg) {
780 my $name = $ob->name; 773 my $name = $ob->name;
781 my @plonmap = grep $ob->on_same_map_as ($_->ob), cf::player::list; 774 my @plonmap = grep $ob->on_same_map_as ($_->ob), cf::player::list;
782 775
776 send_msg $_, $cf::SAY_CHANNEL => "$name says: $msg", cf::NDI_GREY, "msg_say"
777 for grep $_ != $ob->contr, @plonmap;
783 $_->send_msg ($SAY_CHANNEL => "$name says: $msg", cf::NDI_GREY | ($_ == $ob->contr ? cf::NDI_REPLY : 0)) 778 $ob->contr->send_msg ($cf::SAY_CHANNEL => "$name says: $msg", cf::NDI_GREY | cf::NDI_REPLY);
784 for @plonmap;
785 779
786 # npcs, magic_ears etc. 780 # npcs, magic_ears etc.
787 # first find all objects and their first-level inventories 781 # first find all objects and their first-level inventories
788 # within a 5x5 square that have something resembling 782 # within a 5x5 square that have something resembling
789 # dialogue or support on_say. 783 # dialogue or support on_say.
790 my ($map, $x, $y) = ($ob->map, $ob->x - 2, $ob->y - 2); 784 my ($map, $x, $y) = ($ob->map, $ob->x - 2, $ob->y - 2);
791 785
792 for my $npc ( 786 for my $npc (
793 grep +($_->invoke (cf::EVENT_OBJECT_SAY, $ob->contr, $msg) && return) || NPC_Dialogue::has_dialogue $_, 787 grep +($_->invoke (cf::EVENT_OBJECT_SAY, $ob->contr, $msg) && return) || $_->has_dialogue,
794 map +($_, $_->inv), 788 map +($_, $_->inv),
795 grep $_, 789 grep $_,
796 map $map->at ($x + $_ % 5, $y + (int $_ / 5)), 790 map $map->at ($x + $_ % 5, $y + (int $_ / 5)),
797 0..24 791 0..24
798 ) { 792 ) {
802 my $dialog = new NPC_Dialogue pl => $ob->contr, npc => $npc; 796 my $dialog = new NPC_Dialogue pl => $ob->contr, npc => $npc;
803 my ($reply, @kw) = $dialog->tell ($msg); 797 my ($reply, @kw) = $dialog->tell ($msg);
804 798
805 if (defined $reply) { 799 if (defined $reply) {
806 if ($npc->type == cf::MAGIC_EAR) { 800 if ($npc->type == cf::MAGIC_EAR) {
807 if (length $reply) {
808 $_->send_msg ($SAY_CHANNEL => $reply, cf::NDI_BROWN) 801 send_msg $_, $cf::SAY_CHANNEL => $reply, cf::NDI_BROWN, "msg_say"
809 for @plonmap; 802 for @plonmap;
810 }
811 $npc->use_trigger;
812 } else { 803 } else {
813 if (length $reply) {
814 $_->send_msg ($SAY_CHANNEL => $npc->name . " says: $reply", cf::NDI_BROWN) 804 send_msg $_, $cf::SAY_CHANNEL => $npc->name . " says: $reply", cf::NDI_BROWN, "msg_say"
815 for @plonmap; 805 for @plonmap;
816 }
817 } 806 }
818 } 807 }
819 808
820 if (@kw) { 809 if (@kw) {
821 $_->send_msg ($SAY_CHANNEL => "[further topics: " . (join ", ", @kw) . "]", cf::NDI_BROWN) 810 $_->send_msg ($cf::SAY_CHANNEL => "[further topics: " . (join ", ", @kw) . "]", cf::NDI_BROWN)
822 for @plonmap; 811 for @plonmap;
823 } 812 }
824 } 813 }
825 814
826 } else { 815 } else {
827 $ob->send_msg ($SAY_CHANNEL => "What do you want to say?", cf::NDI_GREY | cf::NDI_REPLY); 816 $ob->send_msg ($cf::SAY_CHANNEL => "What do you want to say?", cf::NDI_GREY | cf::NDI_REPLY);
828 } 817 }
829}; 818};
830 819
831cf::register_command chat => sub { 820
821sub _chat {
832 my ($ob, $msg) = @_; 822 my ($ob, $msg) = @_;
833
834 utf8::decode $msg;
835 823
836 my $pl = $ob->contr; 824 my $pl = $ob->contr;
837 825
838 return if $pl->invoke (cf::EVENT_PLAYER_CHAT, $msg); 826 return if $pl->invoke (cf::EVENT_PLAYER_CHAT, $msg);
839 827
840 if ($msg) { 828 if ($msg) {
841 my $name = $ob->name; 829 my $name = $ob->name;
842 my $NOW = time; 830 my $NOW = time;
843 831
844 cf::LOG cf::llevDebug, sprintf "QBERT [%s] %s\n", $name, $msg; 832 cf::LOG cf::llevDebug, sprintf "QBERT %s\n", $msg;
845 send_irc ("[%s] %s", $name, $msg); 833 send_irc ("%s", $msg);
846 834
847 $_->send_msg ($CHAT_CHANNEL => "$name chats: $msg", cf::NDI_BLUE | cf::NDI_DEF | ($_ == $pl ? cf::NDI_REPLY : 0)) 835 send_msg $_, $cf::CHAT_CHANNEL => $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; 836 for grep { $_->ob->{ext_ignore_shout}{$name} < $NOW } cf::player::list;
849 837
850 } else { 838 } else {
851 $pl->send_msg ($CHAT_CHANNEL => "Chat what?", cf::NDI_BLUE | cf::NDI_DEF | cf::NDI_REPLY); 839 $pl->send_msg ($cf::CHAT_CHANNEL => "Chat what?", cf::NDI_BLUE | cf::NDI_DEF | cf::NDI_REPLY);
852 } 840 }
841}
842
843cf::register_command chat => sub {
844 my ($ob, $msg) = @_;
845
846 utf8::decode $msg;
847 _chat $ob, $ob->name . " chats: $msg";
848};
849
850cf::register_command me => sub {
851 my ($ob, $msg) = @_;
852
853 utf8::decode $msg;
854 _chat $ob, "* " . $ob->name . " $msg";
853}; 855};
854 856
855cf::register_command shout => sub { 857cf::register_command shout => sub {
856 my ($ob, $msg) = @_; 858 my ($ob, $msg) = @_;
857 859
866 my $name = $ob->name; 868 my $name = $ob->name;
867 869
868 cf::LOG cf::llevDebug, sprintf "QBERT {%s} %s\n", $name, $msg; 870 cf::LOG cf::llevDebug, sprintf "QBERT {%s} %s\n", $name, $msg;
869 send_irc ("\007\0034{%s} %s\n", $name, $msg); 871 send_irc ("\007\0034{%s} %s\n", $name, $msg);
870 872
871 $_->send_msg ($CHAT_CHANNEL => "$name shouts: $msg", cf::NDI_RED | cf::NDI_DEF | ($_ == $pl ? cf::NDI_REPLY : 0)) 873 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; 874 for grep { $_->ob->{ext_ignore_shout}{$name} < $NOW } cf::player::list;
873 875
874 } else { 876 } else {
875 $pl->send_msg ($CHAT_CHANNEL => "Shout what?", cf::NDI_RED | cf::NDI_DEF | cf::NDI_REPLY); 877 $pl->send_msg ($cf::CHAT_CHANNEL => "Shout what?", cf::NDI_RED | cf::NDI_DEF | cf::NDI_REPLY);
876 } 878 }
877}; 879};
878 880
879cf::register_command tell => sub { 881cf::register_command tell => sub {
880 my ($ob, $args) = @_; 882 my ($ob, $args) = @_;
907 } else { 909 } else {
908 return if $other->invoke (cf::EVENT_PLAYER_TOLD, $pl, $msg); 910 return if $other->invoke (cf::EVENT_PLAYER_TOLD, $pl, $msg);
909 cf::LOG cf::llevDebug, sprintf "TELL [%s>%s] %s\n", $name, $target, $msg; 911 cf::LOG cf::llevDebug, sprintf "TELL [%s>%s] %s\n", $name, $target, $msg;
910 912
911 $ns->send_msg ($pl_channel => "You tell $target: $msg", cf::NDI_DK_ORANGE | cf::NDI_DEF | cf::NDI_REPLY); 913 $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); 914 send_msg $other, $other_channel => "$name tells you: $msg", cf::NDI_DK_ORANGE | cf::NDI_DEF, "msg_tell";
913 } 915 }
914 } else { 916 } else {
915 $ns->send_msg ($pl_channel => "What do you want to tell $target?", cf::NDI_DK_ORANGE | cf::NDI_DEF | cf::NDI_REPLY); 917 $ns->send_msg ($pl_channel => "What do you want to tell $target?", cf::NDI_DK_ORANGE | cf::NDI_DEF | cf::NDI_REPLY);
916 } 918 }
917 919
922 924
923cf::register_command ignore => sub { 925cf::register_command ignore => sub {
924 my ($pl, $args) = @_; 926 my ($pl, $args) = @_;
925 my ($target, $type, $timeout) = split /\s+/, $args; 927 my ($target, $type, $timeout) = split /\s+/, $args;
926 928
929 cf::async {
927 if ($args eq "list") { 930 if ($args eq "list") {
928 clean_timeouts $pl; 931 clean_timeouts $pl;
929 932
930 if ((my @ignored_tell = sort keys %{$pl->{ext_ignore_tell}}) 933 if ((my @ignored_tell = sort keys %{$pl->{ext_ignore_tell}})
931 + (my @ignored_shout = sort keys %{$pl->{ext_ignore_shout}})) { 934 + (my @ignored_shout = sort keys %{$pl->{ext_ignore_shout}})) {
932 $pl->message ("Currently ignoring private messages from: ", cf::NDI_REPLY); 935 $pl->message ("Currently ignoring private messages from: ", cf::NDI_REPLY);
933 $pl->message ((join ", ", @ignored_tell), cf::NDI_REPLY); 936 $pl->message ((join ", ", @ignored_tell), cf::NDI_REPLY);
934 $pl->message ("Currently ignoring shouts from: ", cf::NDI_REPLY); 937 $pl->message ("Currently ignoring shouts from: ", cf::NDI_REPLY);
935 $pl->message ((join ", ", @ignored_shout), cf::NDI_REPLY); 938 $pl->message ((join ", ", @ignored_shout), cf::NDI_REPLY);
936 $pl->message ("To stop ignoring one, use unignore.", cf::NDI_REPLY); 939 $pl->message ("To stop ignoring one, use unignore.", cf::NDI_REPLY);
940 } else {
941 $pl->message ("Not ignoring anyone", cf::NDI_REPLY);
942 }
943
944 } elsif ($target && $type) {
945 $timeout ne "" or $timeout = 24;
946 my $absolute_timeout = time + $timeout * 3600;
947
948 if (cf::player::exists $target) {
949 if ($type eq "tell") {
950 $pl->message ("Now ignoring private messages from $target for $timeout hours.", cf::NDI_REPLY);
951 $pl->{ext_ignore_tell}{$target} = $absolute_timeout;
952 } elsif ($type eq "shout") {
953 $pl->message ("Now ignoring shouts from $target for $timeout hours.", cf::NDI_REPLY);
954 $pl->{ext_ignore_shout}{$target} = $absolute_timeout;
955 } elsif ($type eq "all") {
956 $pl->message ("Now ignoring everything from $target for $timeout hours.", cf::NDI_REPLY);
957 $pl->{ext_ignore_tell}{$target} = $absolute_timeout;
958 $pl->{ext_ignore_shout}{$target} = $absolute_timeout;
959 } else {
960 $pl->message ("You need to specify tell, shout or all.", cf::NDI_REPLY);
961 }
962 } else {
963 $pl->message ("No such player: $target", cf::NDI_REPLY);
964 }
965
937 } else { 966 } else {
938 $pl->message ("Not ignoring anyone", cf::NDI_REPLY); 967 $pl->message ("Usage: ignore <player> <tell|shout|all> <timeout>\n"
968 . "will ignore a player for <timeout> hours.\n"
969 . "Usage: ignore list\n"
970 . "will show you a list of players currently ignored.", cf::NDI_REPLY);
939 } 971 }
940
941 } elsif ($target && $type) {
942
943 $timeout ne "" or $timeout = 24;
944 my $absolute_timeout = time + $timeout * 3600;
945
946 if (cf::player::exists $target) {
947 if ($type eq "tell") {
948 $pl->message ("Now ignoring private messages from $target for $timeout hours.", cf::NDI_REPLY);
949 $pl->{ext_ignore_tell}{$target} = $absolute_timeout;
950 } elsif ($type eq "shout") {
951 $pl->message ("Now ignoring shouts from $target for $timeout hours.", cf::NDI_REPLY);
952 $pl->{ext_ignore_shout}{$target} = $absolute_timeout;
953 } elsif ($type eq "all") {
954 $pl->message ("Now ignoring everything from $target for $timeout hours.", cf::NDI_REPLY);
955 $pl->{ext_ignore_tell}{$target} = $absolute_timeout;
956 $pl->{ext_ignore_shout}{$target} = $absolute_timeout;
957 } else {
958 $pl->message ("You need to specify tell, shout or all.", cf::NDI_REPLY);
959 }
960 } else {
961 $pl->message ("No such player: $target", cf::NDI_REPLY);
962 }
963
964 } else {
965 $pl->message ("Usage: ignore <player> <tell|shout|all> <timeout>\n"
966 . "will ignore a player for <timeout> hours.\n"
967 . "Usage: ignore list\n"
968 . "will show you a list of players currently ignored.", cf::NDI_REPLY);
969 } 972 };
970}; 973};
971 974
972cf::register_command unignore => sub { 975cf::register_command unignore => sub {
973 my ($pl, $args) = @_; 976 my ($pl, $args) = @_;
974 my ($target, $type) = split /\s+/, $args; 977 my ($target, $type) = split /\s+/, $args;
975 978
979 cf::async {
976 if ($args eq "") { 980 if ($args eq "") {
977 if ($pl->{ext_ignore_tell}) { 981 if ($pl->{ext_ignore_tell}) {
978 $pl->message ("Currently ignoring private messages from: ", cf::NDI_REPLY); 982 $pl->message ("Currently ignoring private messages from: ", cf::NDI_REPLY);
979 $pl->message ((join ", ", sort keys %{ $pl->{ext_ignore_tell} }), cf::NDI_REPLY); 983 $pl->message ((join ", ", sort keys %{ $pl->{ext_ignore_tell} }), cf::NDI_REPLY);
980 $pl->message ("Currently ignoring shouts from: ", cf::NDI_REPLY); 984 $pl->message ("Currently ignoring shouts from: ", cf::NDI_REPLY);
981 $pl->message ((join ", ", sort keys %{ $pl->{ext_ignore_shout} }), cf::NDI_REPLY); 985 $pl->message ((join ", ", sort keys %{ $pl->{ext_ignore_shout} }), cf::NDI_REPLY);
982 } else {
983 $pl->message ("Not ignoring anyone", cf::NDI_REPLY);
984 }
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 { 986 } else {
998 $pl->message ("You need to specify tell, shout or all.", cf::NDI_REPLY); 987 $pl->message ("Not ignoring anyone", cf::NDI_REPLY);
999 } 988 }
1000 } else { 989 } else {
990 if (cf::player::exists $target) {
991 if ($type eq "tell") {
992 $pl->message ("Not ignoring private messages from $target anymore.", cf::NDI_REPLY);
993 delete $pl->{ext_ignore_tell} {$target};
994 } elsif ($type eq "shout") {
995 $pl->message ("Not ignoring shouts from $target anymore.", cf::NDI_REPLY);
996 delete $pl->{ext_ignore_shout}{$target};
997 } elsif ($type eq "all") {
998 $pl->message ("Not ignoring anything from $target anymore.", cf::NDI_REPLY);
999 delete $pl->{ext_ignore_tell} {$target};
1000 delete $pl->{ext_ignore_shout}{$target};
1001 } else {
1002 $pl->message ("You need to specify tell, shout or all.", cf::NDI_REPLY);
1003 }
1004 } else {
1001 $pl->message ("No such player or ambiguous name: $target", cf::NDI_REPLY); 1005 $pl->message ("No such player or ambiguous name: $target", cf::NDI_REPLY);
1006 }
1002 } 1007 }
1003 } 1008 };
1004}; 1009};
1005 1010

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines