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.32 by root, Sun Sep 2 08:43:46 2007 UTC vs.
Revision 1.51 by root, Sun Jul 19 18:15:07 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 => {
238 }, 218 },
239 }, 219 },
240 kiss => { 220 kiss => {
241 noparams => { 221 noparams => {
242 other => "<self> makes a weird facial contortion", 222 other => "<self> makes a weird facial contortion",
243 self => "All the lonely people..", 223 self => "All the lonely people...",
244 }, 224 },
245 params => { 225 params => {
246 target => "<self> kisses you.", 226 target => "<self> kisses you.",
247 other => "<self> kisses <other>.", 227 other => "<self> kisses <other>.",
248 self => "You kiss <other>.", 228 self => "You kiss <other>.",
249 }, 229 },
250 self => { 230 self => {
251 }, 231 },
252 }, 232 },
233 hug => {
234 noparams => {
235 other => "<self> makes weird body movements.",
236 self => "All the lonely people...",
237 },
238 params => {
239 target => "<self> suddenly grabs you and gives you a bear hug.",
240 other => "<self> hugs <other>.",
241 self => "You hug <other>.",
242 },
243 self => {
244 other => "<self> tries to hug G<himself|herself>, but stumbles and now feels stupid.",
245 self => "You try and fail to hug yourself.",
246 },
247 },
248 smother => {
249 noparams => {
250 other => "<self> makes weird facial contortions",
251 self => "All the lonely people...",
252 },
253 params => {
254 target => "<self> smothers you with kisses.",
255 other => "<self> smothers <other> with kisses.",
256 self => "You smother <other> with kisses.",
257 },
258 self => {
259 },
260 },
253 wink => { 261 wink => {
254 noparams => { 262 noparams => {
255 other => "<self> winks suggestively.", 263 other => "<self> winks suggestively.",
256 self => "Have you got something in your eye?", 264 self => "Have you got something in your eye?",
257 }, 265 },
259 target => "<self> winks at you.", 267 target => "<self> winks at you.",
260 other => "<self> winks at <other>.", 268 other => "<self> winks at <other>.",
261 self => "You wink suggestively at <other>.", 269 self => "You wink suggestively at <other>.",
262 }, 270 },
263 self => { 271 self => {
264 other => "<self> winks at himself - something strange is going on...", 272 other => "<self> winks at G<him|her>self - something strange is going on...",
265 self => "You wink at yourself?? What are you up to?", 273 self => "You wink at yourself?? What are you up to?",
266 }, 274 },
267 }, 275 },
268 pout => { 276 pout => {
269 noparams => { 277 noparams => {
275 self => { 283 self => {
276 }, 284 },
277 }, 285 },
278 cackle => { 286 cackle => {
279 noparams => { 287 noparams => {
280 other => "<self> throws back his head and cackles with insane glee!", 288 other => "<self> throws back G<his|her> head and cackles with insane glee!",
281 self => "You cackle gleefully.", 289 self => "You cackle gleefully.",
282 }, 290 },
283 params => { 291 params => {
284 }, 292 },
285 self => { 293 self => {
294 target => "<self> sniffs you.", 302 target => "<self> sniffs you.",
295 other => "<self> sniffs <other>", 303 other => "<self> sniffs <other>",
296 self => "You sniff <other>.", 304 self => "You sniff <other>.",
297 }, 305 },
298 self => { 306 self => {
299 other => "<self> sniffs himself.", 307 other => "<self> sniffs G<him|her>self.",
300 self => "You sniff yourself.", 308 self => "You sniff yourself.",
301 }, 309 },
302 }, 310 },
303 nod => { 311 nod => {
304 noparams => { 312 noparams => {
305 other => "<self> nods solemnly.", 313 other => "<self> nods solemnly.",
306 self => "You nod solemnly.", 314 self => "You nod solemnly.",
307 }, 315 },
308 params => { 316 params => {
309 target => "<self> nods solemnly to you.", 317 target => "<self> nods solemnly at you.",
310 other => "<self> nods solemnly to <other>.", 318 other => "<self> nods solemnly at <other>.",
311 self => "You nod solemnly to <other>.", 319 self => "You nod solemnly at <other>.",
312 }, 320 },
313 self => { 321 self => {
314 }, 322 },
315 }, 323 },
316 frown => { 324 frown => {
322 target => "<self> frowns darkly at you.", 330 target => "<self> frowns darkly at you.",
323 other => "<self> frowns darkly at <other>.", 331 other => "<self> frowns darkly at <other>.",
324 self => "You frown darkly at <other>.", 332 self => "You frown darkly at <other>.",
325 }, 333 },
326 self => { 334 self => {
327 other => "<self> frowns at himself.", 335 other => "<self> frowns at G<him|her>self.",
328 self => "You frown at yourself.", 336 self => "You frown at yourself.",
329 }, 337 },
330 }, 338 },
331 snicker => { 339 snicker => {
332 noparams => { 340 noparams => {
355 noparams => { 363 noparams => {
356 other => "<self> is bleeding all over the carpet - got a spare tourniquet?", 364 other => "<self> is bleeding all over the carpet - got a spare tourniquet?",
357 self => "You bleed all over your nice new armour.", 365 self => "You bleed all over your nice new armour.",
358 }, 366 },
359 params => { 367 params => {
360 target => "<self> slashes his wrist and bleeds all over you.", 368 target => "<self> slashes G<his|her> wrist and bleeds all over you.",
361 other => "<self> slashes his wrist and bleeds all over <other>.", 369 other => "<self> slashes G<his|her> wrist and bleeds all over <other>.",
362 self => "You slash your wrist and bleed all over <other>", 370 self => "You slash your wrist and bleed all over <other>",
363 }, 371 },
364 self => { 372 self => {
365 other => "<self> performs some satanic ritual while wiping his blood on himself.", 373 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.", 374 self => "Very impressive! You wipe your blood all over yourself.",
367 }, 375 },
368 }, 376 },
369 twiddle => { 377 twiddle => {
370 noparams => { 378 noparams => {
371 other => "<self> patiently twiddles his thumbs.", 379 other => "<self> patiently twiddles G<his|her> thumbs.",
372 self => "You patiently twiddle your thumbs.", 380 self => "You patiently twiddle your thumbs.",
373 }, 381 },
374 params => { 382 params => {
375 }, 383 },
376 self => { 384 self => {
377 }, 385 },
378 }, 386 },
379 spit => { 387 spit => {
380 noparams => { 388 noparams => {
381 other => "<self> spits over his left shoulder.", 389 other => "<self> spits over G<his|her> left shoulder.",
382 self => "You spit over your left shoulder.", 390 self => "You spit over your left shoulder.",
383 }, 391 },
384 params => { 392 params => {
385 target => "<self> spits in your face!", 393 target => "<self> spits in your face!",
386 other => "<self> spits in <other>'s face.", 394 other => "<self> spits in <other>'s face.",
387 self => "You spit on <other>.", 395 self => "You spit on <other>.",
388 }, 396 },
389 self => { 397 self => {
390 other => "<self> drools all over himself.", 398 other => "<self> drools all over G<him|her>self.",
391 self => "You drool all over yourself.", 399 self => "You drool all over yourself.",
392 }, 400 },
393 }, 401 },
394 glare => { 402 glare => {
395 noparams => { 403 noparams => {
396 other => "<self> glares around him.", 404 other => "<self> glares around G<him|her>.",
397 self => "You glare at nothing in particular.", 405 self => "You glare at nothing in particular.",
398 }, 406 },
399 params => { 407 params => {
400 target => "<self> glares icily at you, you feel cold to your bones.", 408 target => "<self> glares icily at you, you feel cold to your bones.",
401 other => "<self> glares at <other>.", 409 other => "<self> glares at <other>.",
402 self => "You glare icily at <other>.", 410 self => "You glare icily at <other>.",
403 }, 411 },
404 self => { 412 self => {
405 other => "<self> glares at his feet, what is bothering him?", 413 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.", 414 self => "You glare icily at your feet, they are suddenly very cold.",
407 }, 415 },
408 }, 416 },
409 bow => { 417 bow => {
410 noparams => { 418 noparams => {
415 target => "<self> bows before you.", 423 target => "<self> bows before you.",
416 other => "<self> bows before <other>.", 424 other => "<self> bows before <other>.",
417 self => "You bow before <other>.", 425 self => "You bow before <other>.",
418 }, 426 },
419 self => { 427 self => {
420 other => "<self> folds up like a jackknife and kisses his own toes.", 428 other => "<self> folds up like a jackknife and kisses G<his|her> own toes.",
421 self => "You kiss your toes.", 429 self => "You kiss your toes.",
422 }, 430 },
423 }, 431 },
424 dance => { 432 dance => {
425 noparams => { 433 noparams => {
426 other => "<self> expresses himself through interpretive dance.", 434 other => "<self> expresses G<him|her>self through interpretive dance.",
427 self => "You dance with glee.", 435 self => "You dance with glee.",
428 }, 436 },
429 params => { 437 params => {
430 target => "<self> grabs you, and begins dancing!", 438 target => "<self> grabs you, and begins dancing!",
431 other => "Yipe! <self> and <other> are doing the Macarena!", 439 other => "Yipe! <self> and <other> are doing the Macarena!",
432 self => "You grab <other> and begin doing the Cha-Cha!", 440 self => "You grab <other> and begin doing the Cha-Cha!",
433 }, 441 },
434 self => { 442 self => {
435 other => "<self> embraces himself and begins to dance!", 443 other => "<self> embraces G<him|her>self and begins to dance!",
436 self => "You skip and dance around by yourself.", 444 self => "You skip and dance around by yourself.",
437 }, 445 },
438 }, 446 },
439 snore => { 447 snore => {
440 noparams => { 448 noparams => {
456 self => { 464 self => {
457 }, 465 },
458 }, 466 },
459 snap => { 467 snap => {
460 noparams => { 468 noparams => {
461 other => "<self> snaps his fingers.", 469 other => "<self> snaps G<his|her> fingers.",
462 self => "PRONTO! you snap your fingers.", 470 self => "PRONTO! you snap your fingers.",
463 }, 471 },
464 params => { 472 params => {
465 }, 473 },
466 self => { 474 self => {
475 target => "<self> waves goodbye to you. Have a good journey.", 483 target => "<self> waves goodbye to you. Have a good journey.",
476 other => "<self> waves goodbye to <other>.", 484 other => "<self> waves goodbye to <other>.",
477 self => "You wave goodbye to <other>.", 485 self => "You wave goodbye to <other>.",
478 }, 486 },
479 self => { 487 self => {
480 other => "<self> waves goodbye to himself.", 488 other => "<self> waves goodbye to G<him|her>self.",
481 self => "Are you going on adventures as well??", 489 self => "Are you going on adventures as well??",
482 }, 490 },
483 }, 491 },
484 smile => { 492 smile => {
485 noparams => { 493 noparams => {
499 other => "<self> sneezes.", 507 other => "<self> sneezes.",
500 self => "Gesundheit!", 508 self => "Gesundheit!",
501 }, 509 },
502 params => { 510 params => {
503 target => "<self> sneezes on you, you feel the snot cover you. EEEEEEW.", 511 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.", 512 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.", 513 self => "You sneeze at <other> and a film of snot shoots onto G<him|her>.",
506 }, 514 },
507 self => { 515 self => {
508 other => "<self> sneezes, and covers himself in a slimy substance.", 516 other => "<self> sneezes, and covers G<him|her>self in a slimy substance.",
509 self => "You sneeze on yourself, what a mess!", 517 self => "You sneeze on yourself, what a mess!",
510 }, 518 },
511 }, 519 },
512 bounce => { 520 bounce => {
513 noparams => { 521 noparams => {
522 self => { 530 self => {
523 }, 531 },
524 }, 532 },
525 shake => { 533 shake => {
526 noparams => { 534 noparams => {
527 other => "<self> shakes his head.", 535 other => "<self> shakes G<his|her> head.",
528 self => "You shake your head.", 536 self => "You shake your head.",
529 }, 537 },
530 params => { 538 params => {
531 target => "<self> shakes your hand.", 539 target => "<self> shakes your hand.",
532 other => "<self> shakes <other>'s hand.", 540 other => "<self> shakes <other>'s hand.",
537 self => "You are shaken by yourself.", 545 self => "You are shaken by yourself.",
538 }, 546 },
539 }, 547 },
540 lick => { 548 lick => {
541 noparams => { 549 noparams => {
542 other => "<self> licks his mouth and smiles.", 550 other => "<self> licks G<his|her> mouth and smiles.",
543 self => "You lick your mouth and smile.", 551 self => "You lick your mouth and smile.",
544 }, 552 },
545 params => { 553 params => {
546 target => "<self> licks you.", 554 target => "<self> licks you.",
547 other => "<self> licks <other>.", 555 other => "<self> licks <other>.",
548 self => "You lick <other>.", 556 self => "You lick <other>.",
549 }, 557 },
550 self => { 558 self => {
551 other => "<self> licks himself - YUCK.", 559 other => "<self> licks G<him|her>self - YUCK.",
552 self => "You lick yourself.", 560 self => "You lick yourself.",
553 }, 561 },
554 }, 562 },
555 flip => { 563 flip => {
556 noparams => { 564 noparams => {
562 self => { 570 self => {
563 }, 571 },
564 }, 572 },
565 think => { 573 think => {
566 noparams => { 574 noparams => {
567 other => "<self> closes his eyes and thinks really hard.", 575 other => "<self> closes G<his|her> eyes and thinks really hard.",
568 self => "Anything in particular that you'd care to think about?", 576 self => "Anything in particular that you'd care to think about?",
569 }, 577 },
570 params => { 578 params => {
571 }, 579 },
572 self => { 580 self => {
636 target => "<self> cries on your shoulder.", 644 target => "<self> cries on your shoulder.",
637 other => "<self> cries on <other>'s shoulder.", 645 other => "<self> cries on <other>'s shoulder.",
638 self => "You cry on <other>'s shoulder.", 646 self => "You cry on <other>'s shoulder.",
639 }, 647 },
640 self => { 648 self => {
641 other => "<self> sobs quietly to himself.", 649 other => "<self> sobs quietly to G<him|her>self.",
642 self => "You cry to yourself.", 650 self => "You cry to yourself.",
643 }, 651 },
644 }, 652 },
645 sulk => { 653 sulk => {
646 noparams => { 654 noparams => {
660 params => { 668 params => {
661 target => "<self> whistles at <other>.", 669 target => "<self> whistles at <other>.",
662 self => "You whistle at <other>.", 670 self => "You whistle at <other>.",
663 }, 671 },
664 self => { 672 self => {
665 other => "<self> whistles to himself in boredom.", 673 other => "<self> whistles to G<him|her>self in boredom.",
666 self => "You whistle while you work.", 674 self => "You whistle while you work.",
667 }, 675 },
668 }, 676 },
669 groan => { 677 groan => {
670 noparams => { 678 noparams => {
707 715
708 my $pl = $ob->contr; 716 my $pl = $ob->contr;
709 717
710 cf::async { 718 cf::async {
711 my $name = $ob->name; 719 my $name = $ob->name;
720 $Coro::current->{desc} = "emote handler for $name";
712 721
713 if ($tname eq $name) { 722 if ($tname eq $name) {
714 my %emote = %{ $emotes->{$emotion}->{self} || {} }; 723 my %emote = %{ $emotes->{$emotion}->{self} || {} };
715 724
716 $emote{other} ||= "You look away from <self>."; 725 $emote{other} ||= "You look away from <self>.";
717 $emote{self} ||= "My god! Is that LEGAL?"; 726 $emote{self} ||= "My god! Is that LEGAL?";
718 727
719 $emote{other} =~ s/<self>/$name/; 728 $emote{other} =~ s/<self>/$name/;
729
730 $_ = $pl->expand_cfpod ($_)
731 for values %emote;
720 732
721 $_->send_msg ($CHAT_CHANNEL, $emote{other}, cf::NDI_GREY) 733 send_msg $_, $cf::CHAT_CHANNEL, $emote{other}, cf::NDI_GREY | cf::NDI_VERBATIM, "msg_chat"
722 for grep { $ob->on_same_map_as ($_->ob) && $_ != $ob} cf::player::list; 734 for grep { $ob->on_same_map_as ($_->ob) && $_ != $ob} cf::player::list;
723 735
724 $pl->send_msg ($emote{self}, cf::NDI_GREY | cf::NDI_REPLY); 736 $pl->send_msg ($emote{self}, cf::NDI_GREY | cf::NDI_REPLY | cf::NDI_VERBATIM);
725 } elsif ($tname) { 737 } elsif ($tname) {
726 my $target = cf::player::find $tname 738 my $target = cf::player::find $tname
727 or return $pl->send_msg (tell_channel $tname, "$tname is not around.", cf::NDI_DK_ORANGE | cf::NDI_REPLY); 739 or return send_msg $pl, tell_channel $tname, "$tname is not around.", cf::NDI_DK_ORANGE | cf::NDI_REPLY, "msg_chat";
728 740
729 my %emote = %{ $emotes->{$emotion}->{params} || {} }; 741 my %emote = %{ $emotes->{$emotion}->{params} || {} };
730 742
731 $emote{other} ||= "<self> is eyeing <other> quizzically."; 743 $emote{other} ||= "<self> is eyeing <other> quizzically.";
732 $emote{self} ||= "You are still nuts."; 744 $emote{self} ||= "You are still nuts.";
733 $emote{target} ||= "You get the distinct feeling that <other> is nuts."; 745 $emote{target} ||= "You get the distinct feeling that <self> is nuts.";
734 746
735 $emote{self} =~ s/<other>/$tname/; 747 $emote{self} =~ s/<other>/$tname/;
736 $emote{target} =~ s/<self>/$name/; 748 $emote{target} =~ s/<self>/$name/;
737 $emote{other} =~ s/<other>/$tname/; 749 $emote{other} =~ s/<other>/$tname/;
738 $emote{other} =~ s/<self>/$name/; 750 $emote{other} =~ s/<self>/$name/;
739 751
740 $_->send_msg ($CHAT_CHANNEL, $emote{other}, cf::NDI_GREY) 752 $_ = $pl->expand_cfpod ($_)
753 for values %emote;
754
755 send_msg $_, $cf::CHAT_CHANNEL, $emote{other}, cf::NDI_GREY | cf::NDI_VERBATIM, "msg_chat"
741 for grep { $_ != $pl && $_ != $target && $ob->on_same_map_as ($_->ob) } cf::player::list; 756 for grep { $_ != $pl && $_ != $target && $ob->on_same_map_as ($_->ob) } cf::player::list;
742 757
743 $target->send_msg (tell_channel $name, $emote{target}, cf::NDI_GREY); 758 send_msg $target, tell_channel $name, $emote{target}, cf::NDI_GREY | cf::NDI_VERBATIM, "msg_shout";
744 $pl->send_msg (tell_channel $tname, $emote{self}, cf::NDI_GREY | cf::NDI_REPLY); 759 $pl->send_msg (tell_channel $tname, $emote{self}, cf::NDI_GREY | cf::NDI_REPLY | cf::NDI_VERBATIM);
745 } else { 760 } else {
746 my %emote = %{ $emotes->{$emotion}->{noparams} || {} }; 761 my %emote = %{ $emotes->{$emotion}->{noparams} || {} };
747 762
748 $emote{other} ||= "<self> dances with glee."; 763 $emote{other} ||= "<self> dances with glee.";
749 $emote{self} ||= "You are a nut."; 764 $emote{self} ||= "You are a nut.";
750 765
751 $emote{other} =~ s/<self>/$name/; 766 $emote{other} =~ s/<self>/$name/;
752 767
753 $_->send_msg ($CHAT_CHANNEL, $emote{other}, cf::NDI_GREY) 768 $_ = $pl->expand_cfpod ($_)
769 for values %emote;
770
771 send_msg $_, $cf::CHAT_CHANNEL, $emote{other}, cf::NDI_GREY | cf::NDI_VERBATIM, "msg_chat"
754 for grep { $ob->on_same_map_as ($_->ob) && $_ != $pl } cf::player::list; 772 for grep { $ob->on_same_map_as ($_->ob) && $_ != $pl } cf::player::list;
755 773
756 $pl->send_msg ($CHAT_CHANNEL, $emote{self}, cf::NDI_GREY | cf::NDI_REPLY); 774 $pl->send_msg ($cf::CHAT_CHANNEL, $emote{self}, cf::NDI_GREY | cf::NDI_REPLY | cf::NDI_VERBATIM);
757 } 775 }
758 }; 776 };
759 }; 777 };
760} 778}
761 779
762cf::register_command me => sub {
763 my ($pl, $msg) = @_;
764
765 my $name = $pl->name;
766
767 $_->send_msg ($SAY_CHANNEL => "* $name $msg", cf::NDI_GREY | cf::NDI_DEF | ($_ == $pl ? cf::NDI_REPLY : 0))
768 for grep $pl->on_same_map_as ($_->ob), cf::player::list;
769};
770
771cf::register_command say => sub { 780cf::register_command say => sub {
772 my ($ob, $msg) = @_; 781 my ($ob, $msg) = @_;
773 782
774 utf8::decode $msg; 783 utf8::decode $msg;
775 784
777 786
778 if ($msg) { 787 if ($msg) {
779 my $name = $ob->name; 788 my $name = $ob->name;
780 my @plonmap = grep $ob->on_same_map_as ($_->ob), cf::player::list; 789 my @plonmap = grep $ob->on_same_map_as ($_->ob), cf::player::list;
781 790
791 send_msg $_, $cf::SAY_CHANNEL => "$name says: $msg", cf::NDI_GREY, "msg_say"
792 for grep $_ != $ob->contr, @plonmap;
782 $_->send_msg ($SAY_CHANNEL => "$name says: $msg", cf::NDI_GREY | ($_ == $ob->contr ? cf::NDI_REPLY : 0)) 793 $ob->contr->send_msg ($cf::SAY_CHANNEL => "$name says: $msg", cf::NDI_GREY | cf::NDI_REPLY);
783 for @plonmap;
784 794
785 # npcs, magic_ears etc. 795 # npcs, magic_ears etc.
786 # first find all objects and their first-level inventories 796 # first find all objects and their first-level inventories
787 # within a 5x5 square that have something resembling 797 # within a 5x5 square that have something resembling
788 # dialogue or support on_say. 798 # dialogue or support on_say.
789 my ($map, $x, $y) = ($ob->map, $ob->x - 2, $ob->y - 2); 799 my ($map, $x, $y) = ($ob->map, $ob->x - 2, $ob->y - 2);
790 800
791 for my $npc ( 801 for my $npc (
792 grep +($_->invoke (cf::EVENT_OBJECT_SAY, $ob->contr, $msg) && return) || NPC_Dialogue::has_dialogue $_, 802 grep +($_->invoke (cf::EVENT_OBJECT_SAY, $ob->contr, $msg) && return) || $_->has_dialogue,
793 map +($_, $_->inv), 803 map +($_, $_->inv),
794 grep $_, 804 grep $_,
795 map $map->at ($x + $_ % 5, $y + (int $_ / 5)), 805 map $map->at ($x + $_ % 5, $y + (int $_ / 5)),
796 0..24 806 0..24
797 ) { 807 ) {
801 my $dialog = new NPC_Dialogue pl => $ob->contr, npc => $npc; 811 my $dialog = new NPC_Dialogue pl => $ob->contr, npc => $npc;
802 my ($reply, @kw) = $dialog->tell ($msg); 812 my ($reply, @kw) = $dialog->tell ($msg);
803 813
804 if (defined $reply) { 814 if (defined $reply) {
805 if ($npc->type == cf::MAGIC_EAR) { 815 if ($npc->type == cf::MAGIC_EAR) {
806 if (length $reply) {
807 $_->send_msg ($SAY_CHANNEL => $reply, cf::NDI_BROWN) 816 send_msg $_, $cf::SAY_CHANNEL => $reply, cf::NDI_BROWN, "msg_say"
808 for @plonmap; 817 for @plonmap;
809 }
810 $npc->use_trigger;
811 } else { 818 } else {
812 if (length $reply) {
813 $_->send_msg ($SAY_CHANNEL => $npc->name . " says: $reply", cf::NDI_BROWN) 819 send_msg $_, $cf::SAY_CHANNEL => $npc->name . " says: $reply", cf::NDI_BROWN, "msg_say"
814 for @plonmap; 820 for @plonmap;
815 }
816 } 821 }
817 } 822 }
818 823
819 if (@kw) { 824 if (@kw) {
820 $_->send_msg ($SAY_CHANNEL => "[further topics: " . (join ", ", @kw) . "]", cf::NDI_BROWN) 825 $_->send_msg ($cf::SAY_CHANNEL => "[further topics: " . (join ", ", @kw) . "]", cf::NDI_BROWN)
821 for @plonmap; 826 for @plonmap;
822 } 827 }
823 } 828 }
824 829
825 } else { 830 } else {
826 $ob->send_msg ($SAY_CHANNEL => "What do you want to say?", cf::NDI_GREY | cf::NDI_REPLY); 831 $ob->send_msg ($cf::SAY_CHANNEL => "What do you want to say?", cf::NDI_GREY | cf::NDI_REPLY);
827 } 832 }
828}; 833};
829 834
830cf::register_command chat => sub { 835
836sub _chat {
831 my ($ob, $msg) = @_; 837 my ($ob, $msg) = @_;
832
833 utf8::decode $msg;
834 838
835 my $pl = $ob->contr; 839 my $pl = $ob->contr;
836 840
837 return if $pl->invoke (cf::EVENT_PLAYER_CHAT, $msg); 841 return if $pl->invoke (cf::EVENT_PLAYER_CHAT, $msg);
838 842
839 if ($msg) { 843 if ($msg) {
840 my $name = $ob->name; 844 my $name = $ob->name;
841 my $NOW = time; 845 my $NOW = time;
842 846
843 cf::LOG cf::llevDebug, sprintf "QBERT [%s] %s\n", $name, $msg; 847 cf::LOG cf::llevDebug, sprintf "QBERT %s\n", $msg;
844 send_irc ("[%s] %s", $name, $msg); 848 send_irc ("%s", $msg);
845 849
846 $_->send_msg ($CHAT_CHANNEL => "$name chats: $msg", cf::NDI_BLUE | cf::NDI_DEF | ($_ == $pl ? cf::NDI_REPLY : 0)) 850 send_msg $_, $cf::CHAT_CHANNEL => $msg, cf::NDI_BLUE | cf::NDI_DEF | ($_ == $pl ? cf::NDI_REPLY : 0), "msg_chat"
847 for grep { $_->ob->{ext_ignore_shout}{$name} < $NOW && $_->listening >= 10 } cf::player::list; 851 for grep { $_->ob->{ext_ignore_shout}{$name} < $NOW } cf::player::list;
848 852
849 } else { 853 } else {
850 $pl->send_msg ($CHAT_CHANNEL => "Chat what?", cf::NDI_BLUE | cf::NDI_DEF | cf::NDI_REPLY); 854 $pl->send_msg ($cf::CHAT_CHANNEL => "Chat what?", cf::NDI_BLUE | cf::NDI_DEF | cf::NDI_REPLY);
851 } 855 }
856}
857
858cf::register_command chat => sub {
859 my ($ob, $msg) = @_;
860
861 utf8::decode $msg;
862 _chat $ob, $ob->name . " chats: $msg";
863};
864
865cf::register_command me => sub {
866 my ($ob, $msg) = @_;
867
868 utf8::decode $msg;
869 _chat $ob, "* " . $ob->name . " $msg";
852}; 870};
853 871
854cf::register_command shout => sub { 872cf::register_command shout => sub {
855 my ($ob, $msg) = @_; 873 my ($ob, $msg) = @_;
856 874
865 my $name = $ob->name; 883 my $name = $ob->name;
866 884
867 cf::LOG cf::llevDebug, sprintf "QBERT {%s} %s\n", $name, $msg; 885 cf::LOG cf::llevDebug, sprintf "QBERT {%s} %s\n", $name, $msg;
868 send_irc ("\007\0034{%s} %s\n", $name, $msg); 886 send_irc ("\007\0034{%s} %s\n", $name, $msg);
869 887
870 $_->send_msg ($CHAT_CHANNEL => "$name shouts: $msg", cf::NDI_RED | cf::NDI_DEF | ($_ == $pl ? cf::NDI_REPLY : 0)) 888 send_msg $_, $cf::CHAT_CHANNEL => "$name shouts: $msg", cf::NDI_RED | cf::NDI_DEF | ($_ == $pl ? cf::NDI_REPLY : 0), "msg_shout"
871 for grep { $_->ob->{ext_ignore_shout}{$name} < $NOW && $_->listening >= 2 } cf::player::list; 889 for grep { $_->ob->{ext_ignore_shout}{$name} < $NOW } cf::player::list;
872 890
873 } else { 891 } else {
874 $pl->send_msg ($CHAT_CHANNEL => "Shout what?", cf::NDI_RED | cf::NDI_DEF | cf::NDI_REPLY); 892 $pl->send_msg ($cf::CHAT_CHANNEL => "Shout what?", cf::NDI_RED | cf::NDI_DEF | cf::NDI_REPLY);
875 } 893 }
876}; 894};
877 895
878cf::register_command tell => sub { 896cf::register_command tell => sub {
879 my ($ob, $args) = @_; 897 my ($ob, $args) = @_;
906 } else { 924 } else {
907 return if $other->invoke (cf::EVENT_PLAYER_TOLD, $pl, $msg); 925 return if $other->invoke (cf::EVENT_PLAYER_TOLD, $pl, $msg);
908 cf::LOG cf::llevDebug, sprintf "TELL [%s>%s] %s\n", $name, $target, $msg; 926 cf::LOG cf::llevDebug, sprintf "TELL [%s>%s] %s\n", $name, $target, $msg;
909 927
910 $ns->send_msg ($pl_channel => "You tell $target: $msg", cf::NDI_DK_ORANGE | cf::NDI_DEF | cf::NDI_REPLY); 928 $ns->send_msg ($pl_channel => "You tell $target: $msg", cf::NDI_DK_ORANGE | cf::NDI_DEF | cf::NDI_REPLY);
911 $other->send_msg ($other_channel => "$name tells you: $msg", cf::NDI_DK_ORANGE | cf::NDI_DEF); 929 send_msg $other, $other_channel => "$name tells you: $msg", cf::NDI_DK_ORANGE | cf::NDI_DEF, "msg_tell";
912 } 930 }
913 } else { 931 } else {
914 $ns->send_msg ($pl_channel => "What do you want to tell $target?", cf::NDI_DK_ORANGE | cf::NDI_DEF | cf::NDI_REPLY); 932 $ns->send_msg ($pl_channel => "What do you want to tell $target?", cf::NDI_DK_ORANGE | cf::NDI_DEF | cf::NDI_REPLY);
915 } 933 }
916 934
921 939
922cf::register_command ignore => sub { 940cf::register_command ignore => sub {
923 my ($pl, $args) = @_; 941 my ($pl, $args) = @_;
924 my ($target, $type, $timeout) = split /\s+/, $args; 942 my ($target, $type, $timeout) = split /\s+/, $args;
925 943
944 cf::async {
926 if ($args eq "list") { 945 if ($args eq "list") {
927 clean_timeouts $pl; 946 clean_timeouts $pl;
928 947
929 if ((my @ignored_tell = sort keys %{$pl->{ext_ignore_tell}}) 948 if ((my @ignored_tell = sort keys %{$pl->{ext_ignore_tell}})
930 + (my @ignored_shout = sort keys %{$pl->{ext_ignore_shout}})) { 949 + (my @ignored_shout = sort keys %{$pl->{ext_ignore_shout}})) {
931 $pl->message ("Currently ignoring private messages from: ", cf::NDI_REPLY); 950 $pl->message ("Currently ignoring private messages from: ", cf::NDI_REPLY);
932 $pl->message ((join ", ", @ignored_tell), cf::NDI_REPLY); 951 $pl->message ((join ", ", @ignored_tell), cf::NDI_REPLY);
933 $pl->message ("Currently ignoring shouts from: ", cf::NDI_REPLY); 952 $pl->message ("Currently ignoring shouts from: ", cf::NDI_REPLY);
934 $pl->message ((join ", ", @ignored_shout), cf::NDI_REPLY); 953 $pl->message ((join ", ", @ignored_shout), cf::NDI_REPLY);
935 $pl->message ("To stop ignoring one, use unignore.", cf::NDI_REPLY); 954 $pl->message ("To stop ignoring one, use unignore.", cf::NDI_REPLY);
955 } else {
956 $pl->message ("Not ignoring anyone", cf::NDI_REPLY);
957 }
958
959 } elsif ($target && $type) {
960 $timeout ne "" or $timeout = 24;
961 my $absolute_timeout = time + $timeout * 3600;
962
963 if (cf::player::exists $target) {
964 if ($type eq "tell") {
965 $pl->message ("Now ignoring private messages from $target for $timeout hours.", cf::NDI_REPLY);
966 $pl->{ext_ignore_tell}{$target} = $absolute_timeout;
967 } elsif ($type eq "shout") {
968 $pl->message ("Now ignoring shouts from $target for $timeout hours.", cf::NDI_REPLY);
969 $pl->{ext_ignore_shout}{$target} = $absolute_timeout;
970 } elsif ($type eq "all") {
971 $pl->message ("Now ignoring everything from $target for $timeout hours.", cf::NDI_REPLY);
972 $pl->{ext_ignore_tell}{$target} = $absolute_timeout;
973 $pl->{ext_ignore_shout}{$target} = $absolute_timeout;
974 } else {
975 $pl->message ("You need to specify tell, shout or all.", cf::NDI_REPLY);
976 }
977 } else {
978 $pl->message ("No such player: $target", cf::NDI_REPLY);
979 }
980
936 } else { 981 } else {
937 $pl->message ("Not ignoring anyone", cf::NDI_REPLY); 982 $pl->message ("Usage: ignore <player> <tell|shout|all> <timeout>\n"
983 . "will ignore a player for <timeout> hours.\n"
984 . "Usage: ignore list\n"
985 . "will show you a list of players currently ignored.", cf::NDI_REPLY);
938 } 986 }
939
940 } elsif ($target && $type) {
941
942 $timeout ne "" or $timeout = 24;
943 my $absolute_timeout = time + $timeout * 3600;
944
945 if (cf::player::exists $target) {
946 if ($type eq "tell") {
947 $pl->message ("Now ignoring private messages from $target for $timeout hours.", cf::NDI_REPLY);
948 $pl->{ext_ignore_tell}{$target} = $absolute_timeout;
949 } elsif ($type eq "shout") {
950 $pl->message ("Now ignoring shouts from $target for $timeout hours.", cf::NDI_REPLY);
951 $pl->{ext_ignore_shout}{$target} = $absolute_timeout;
952 } elsif ($type eq "all") {
953 $pl->message ("Now ignoring everything from $target for $timeout hours.", cf::NDI_REPLY);
954 $pl->{ext_ignore_tell}{$target} = $absolute_timeout;
955 $pl->{ext_ignore_shout}{$target} = $absolute_timeout;
956 } else {
957 $pl->message ("You need to specify tell, shout or all.", cf::NDI_REPLY);
958 }
959 } else {
960 $pl->message ("No such player: $target", cf::NDI_REPLY);
961 }
962
963 } else {
964 $pl->message ("Usage: ignore <player> <tell|shout|all> <timeout>\n"
965 . "will ignore a player for <timeout> hours.\n"
966 . "Usage: ignore list\n"
967 . "will show you a list of players currently ignored.", cf::NDI_REPLY);
968 } 987 };
969}; 988};
970 989
971cf::register_command unignore => sub { 990cf::register_command unignore => sub {
972 my ($pl, $args) = @_; 991 my ($pl, $args) = @_;
973 my ($target, $type) = split /\s+/, $args; 992 my ($target, $type) = split /\s+/, $args;
974 993
994 cf::async {
975 if ($args eq "") { 995 if ($args eq "") {
976 if ($pl->{ext_ignore_tell}) { 996 if ($pl->{ext_ignore_tell}) {
977 $pl->message ("Currently ignoring private messages from: ", cf::NDI_REPLY); 997 $pl->message ("Currently ignoring private messages from: ", cf::NDI_REPLY);
978 $pl->message ((join ", ", sort keys %{ $pl->{ext_ignore_tell} }), cf::NDI_REPLY); 998 $pl->message ((join ", ", sort keys %{ $pl->{ext_ignore_tell} }), cf::NDI_REPLY);
979 $pl->message ("Currently ignoring shouts from: ", cf::NDI_REPLY); 999 $pl->message ("Currently ignoring shouts from: ", cf::NDI_REPLY);
980 $pl->message ((join ", ", sort keys %{ $pl->{ext_ignore_shout} }), cf::NDI_REPLY); 1000 $pl->message ((join ", ", sort keys %{ $pl->{ext_ignore_shout} }), cf::NDI_REPLY);
981 } else {
982 $pl->message ("Not ignoring anyone", cf::NDI_REPLY);
983 }
984 } else {
985 if (cf::player::exists $target) {
986 if ($type eq "tell") {
987 $pl->message ("Not ignoring private messages from $target anymore.", cf::NDI_REPLY);
988 delete $pl->{ext_ignore_tell} {$target};
989 } elsif ($type eq "shout") {
990 $pl->message ("Not ignoring shouts from $target anymore.", cf::NDI_REPLY);
991 delete $pl->{ext_ignore_shout}{$target};
992 } elsif ($type eq "all") {
993 $pl->message ("Not ignoring anything from $target anymore.", cf::NDI_REPLY);
994 delete $pl->{ext_ignore_tell} {$target};
995 delete $pl->{ext_ignore_shout}{$target};
996 } else { 1001 } else {
997 $pl->message ("You need to specify tell, shout or all.", cf::NDI_REPLY); 1002 $pl->message ("Not ignoring anyone", cf::NDI_REPLY);
998 } 1003 }
999 } else { 1004 } else {
1005 if (cf::player::exists $target) {
1006 if ($type eq "tell") {
1007 $pl->message ("Not ignoring private messages from $target anymore.", cf::NDI_REPLY);
1008 delete $pl->{ext_ignore_tell} {$target};
1009 } elsif ($type eq "shout") {
1010 $pl->message ("Not ignoring shouts from $target anymore.", cf::NDI_REPLY);
1011 delete $pl->{ext_ignore_shout}{$target};
1012 } elsif ($type eq "all") {
1013 $pl->message ("Not ignoring anything from $target anymore.", cf::NDI_REPLY);
1014 delete $pl->{ext_ignore_tell} {$target};
1015 delete $pl->{ext_ignore_shout}{$target};
1016 } else {
1017 $pl->message ("You need to specify tell, shout or all.", cf::NDI_REPLY);
1018 }
1019 } else {
1000 $pl->message ("No such player or ambiguous name: $target", cf::NDI_REPLY); 1020 $pl->message ("No such player or ambiguous name: $target", cf::NDI_REPLY);
1021 }
1001 } 1022 }
1002 } 1023 };
1003}; 1024};
1004 1025

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines