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.2 by root, Thu Dec 21 22:41:34 2006 UTC vs.
Revision 1.10 by pippijn, Thu Mar 1 13:14:10 2007 UTC

32 clean_timeouts $pl->ob; 32 clean_timeouts $pl->ob;
33 }, 33 },
34); 34);
35 35
36cf::register_command listen => sub { 36cf::register_command listen => sub {
37 my ($who, $msg) = @_; 37 my ($pl, $msg) = @_;
38 my $player = cf::player::find $who->name; 38 my $player = cf::player::find_active $pl->name;
39 39
40 if ($msg ne "") { 40 if ($msg ne "") {
41 my $prev_listen = $player->listening; 41 my $prev_listen = $player->listening;
42 $player->listening ($msg); 42 $player->listening ($msg);
43 if ($prev_listen == $player->listening) { 43 if ($prev_listen == $player->listening) {
44 $who->message ("Your verbose level stayed $prev_listen.", cf::NDI_UNIQUE); 44 $pl->message ("Your verbose level stayed $prev_listen.", cf::NDI_UNIQUE);
45 } else { 45 } else {
46 $who->message ("Your verbose level is now " . $player->listening . ". (previously: $prev_listen)", cf::NDI_UNIQUE); 46 $pl->message ("Your verbose level is now " . $player->listening . ". (previously: $prev_listen)", cf::NDI_UNIQUE);
47 } 47 }
48 } else { 48 } else {
49 $who->message ("Your verbose level is " . $player->listening . ".", cf::NDI_UNIQUE); 49 $pl->message ("Your verbose level is " . $player->listening . ".", cf::NDI_UNIQUE);
50 }
51};
52
53cf::register_command cointoss => sub {
54 my ($pl, $msg) = @_;
55
56 my $name = $pl->name;
57
58 if (int rand 2) {
59 for my $other ( grep { $pl->on_same_map_as ($_->ob) } cf::player::list ) {
60 next
61 if $other->ob == $pl;
62 $other->ob->message ("$name flips a coin.... Heads!", cf::NDI_GREY | cf::NDI_UNIQUE);
63 }
64
65 $pl->message ("You flip a coin.... Heads!", cf::NDI_GREY | cf::NDI_UNIQUE);
66 } else {
67 for my $other ( grep { $pl->on_same_map_as ($_->ob) } cf::player::list ) {
68 next
69 if $other->ob == $pl;
70 $other->ob->message ("$name flips a coin.... Tails!", cf::NDI_GREY | cf::NDI_UNIQUE);
71 }
72
73 $pl->message ("You flip a coin.... Tails!", cf::NDI_GREY | cf::NDI_UNIQUE);
74 }
75};
76
77cf::register_command orcknuckle => sub {
78 my ($pl, $msg) = @_;
79 my @orcknuckle = ("none", "beholder", "ghost", "knight", "princess", "dragon", "orc");
80
81 my $name = $pl->name;
82
83 my ($i, $j, $k, $l) = ((int rand 5) + 1, (int rand 5) + 1, (int rand 5) + 1, (int rand 6) + 1);
84 my $result = "$orcknuckle[$i], $orcknuckle[$j], $orcknuckle[$k], $orcknuckle[$l]";
85
86 for my $other ( grep { $pl->on_same_map_as ($_->ob) } cf::player::list ) {
87 next
88 if $other->ob == $pl;
89 $other->ob->message ("$name rolls $result!", cf::NDI_GREY | cf::NDI_UNIQUE);
90 }
91
92 $pl->message ("You roll $result!", cf::NDI_GREY | cf::NDI_UNIQUE);
93};
94
95my $emotes = {
96 growl => {
97 noparams => {
98 other => "<self> growls.",
99 self => "Grrrrrrrrr....",
100 },
101 params => {
102 },
103 self => {
104 },
50 } 105 },
106 giggle => {
107 noparams => {
108 other => "<self> giggles.",
109 self => "You giggle.",
110 },
111 params => {
112 },
113 self => {
114 },
115 },
116 shiver => {
117 noparams => {
118 other => "<self> shivers uncomfortably.",
119 self => "Brrrrrrrrr.",
120 },
121 params => {
122 },
123 self => {
124 },
125 },
126 chuckle => {
127 noparams => {
128 other => "<self> chuckles politely.",
129 self => "You chuckle politely",
130 },
131 params => {
132 },
133 self => {
134 },
135 },
136 sigh => {
137 noparams => {
138 other => "<self> sighs loudly.",
139 self => "You sigh.",
140 },
141 params => {
142 },
143 self => {
144 },
145 },
146 scream => {
147 noparams => {
148 other => "<self> screams at the top of his lungs!",
149 self => "ARRRRRRRRRRGH!!!!!",
150 },
151 params => {
152 },
153 self => {
154 },
155 },
156 puke => {
157 noparams => {
158 other => "<self> pukes.",
159 self => "Bleaaaaaghhhhhhh!",
160 },
161 params => {
162 target => "<self> pukes on your clothes!",
163 other => "<self> pukes on <other>.",
164 self => "You puke on <other>.",
165 },
166 self => {
167 other => "<self> pukes on his clothes.",
168 self => "You puke on yourself.",
169 },
170 },
171 strut => {
172 noparams => {
173 other => "<self> struts proudly.",
174 self => "Strut your stuff.",
175 },
176 params => {
177 },
178 self => {
179 },
180 },
181 cringe => {
182 noparams => {
183 other => "<self> cringes in terror!",
184 self => "You cringe in terror.",
185 },
186 params => {
187 target => "<self> cringes away from <other> in mortal terror.",
188 self => "You cringe away from <other>.",
189 },
190 self => {
191 },
192 },
193 hiccup => {
194 noparams => {
195 other => "<self> hiccups.",
196 self => "*HIC*",
197 },
198 params => {
199 },
200 self => {
201 },
202 },
203 clap => {
204 noparams => {
205 other => "<self> gives a round of applause.",
206 self => "Clap, clap, clap.",
207 },
208 params => {
209 },
210 self => {
211 },
212 },
213 kiss => {
214 noparams => {
215 other => "<self> makes a weird facial contortion",
216 self => "All the lonely people..",
217 },
218 params => {
219 target => "<self> kisses you.",
220 other => "<self> kisses <other>.",
221 self => "You kiss <other>.",
222 },
223 self => {
224 },
225 },
226 wink => {
227 noparams => {
228 other => "<self> winks suggestively.",
229 self => "Have you got something in your eye?",
230 },
231 params => {
232 target => "<self> winks at <other>.",
233 self => "You wink suggestively at <other>.",
234 },
235 self => {
236 other => "<self> winks at himself - something strange is going on...",
237 self => "You wink at yourself?? What are you up to?",
238 },
239 },
240 pout => {
241 noparams => {
242 other => "<self> pouts.",
243 self => "Aww, don't take it so hard.",
244 },
245 params => {
246 },
247 self => {
248 },
249 },
250 cackle => {
251 noparams => {
252 other => "<self> throws back his head and cackles with insane glee!",
253 self => "You cackle gleefully.",
254 },
255 params => {
256 },
257 self => {
258 },
259 },
260 sniff => {
261 noparams => {
262 other => "<self> sniffs sadly.",
263 self => "You sniff sadly. *SNIFF*",
264 },
265 params => {
266 target => "<self> sniffs you.",
267 other => "<self> sniffs <other>",
268 self => "You sniff <other>.",
269 },
270 self => {
271 other => "<self> sniffs himself.",
272 self => "You sniff yourself.",
273 },
274 },
275 nod => {
276 noparams => {
277 other => "<self> nods solemnly.",
278 self => "You nod solemnly.",
279 },
280 params => {
281 target => "<self> nods solemnly to you.",
282 other => "<self> nods solemnly to <other>.",
283 self => "You nod solemnly to <other>.",
284 },
285 self => {
286 },
287 },
288 frown => {
289 noparams => {
290 other => "<self> frowns.",
291 self => "What's bothering you?",
292 },
293 params => {
294 target => "<self> frowns darkly at you.",
295 other => "<self> frowns darkly at <other>.",
296 self => "You frown darkly at <other>.",
297 },
298 self => {
299 other => "<self> frowns at himself.",
300 self => "You frown at yourself.",
301 },
302 },
303 snicker => {
304 noparams => {
305 other => "<self> snickers softly.",
306 self => "You snicker softly.",
307 },
308 params => {
309 },
310 self => {
311 },
312 },
313 shrug => {
314 noparams => {
315 other => "<self> shrugs helplessly.",
316 self => "You shrug.",
317 },
318 params => {
319 target => "<self> shrugs at you.",
320 other => "<self> shrugs at <other>.",
321 self => "You shrug at <other>.",
322 },
323 self => {
324 },
325 },
326 bleed => {
327 noparams => {
328 other => "<self> is bleeding all over the carpet - got a spare tourniquet?",
329 self => "You bleed all over your nice new armour.",
330 },
331 params => {
332 target => "<self> slashes his wrist and bleeds all over <other>.",
333 self => "You slash your wrist and bleed all over <other>",
334 },
335 self => {
336 other => "<self> performs some satanic ritual while wiping his blood on himself.",
337 self => "Very impressive! You wipe your blood all over yourself.",
338 },
339 },
340 twiddle => {
341 noparams => {
342 other => "<self> patiently twiddles his thumbs.",
343 self => "You patiently twiddle your thumbs.",
344 },
345 params => {
346 },
347 self => {
348 },
349 },
350 spit => {
351 noparams => {
352 other => "<self> spits over his left shoulder.",
353 self => "You spit over your left shoulder.",
354 },
355 params => {
356 target => "<self> spits in your face!",
357 other => "<self> spits in <other>'s face.",
358 self => "You spit on <other>.",
359 },
360 self => {
361 other => "<self> drools all over himself.",
362 self => "You drool all over yourself.",
363 },
364 },
365 glare => {
366 noparams => {
367 other => "<self> glares around him.",
368 self => "You glare at nothing in particular.",
369 },
370 params => {
371 target => "<self> glares icily at you, you feel cold to your bones.",
372 other => "<self> glares at <other>.",
373 self => "You glare icily at <other>.",
374 },
375 self => {
376 other => "<self> glares at his feet, what is bothering him?",
377 self => "You glare icily at your feet, they are suddenly very cold.",
378 },
379 },
380 bow => {
381 noparams => {
382 other => "<self> bows deeply.",
383 self => "You bow deeply.",
384 },
385 params => {
386 target => "<self> bows before you.",
387 other => "<self> bows before <other>.",
388 self => "You bow before <other>.",
389 },
390 self => {
391 other => "<self> folds up like a jackknife and kisses his own toes.",
392 self => "You kiss your toes.",
393 },
394 },
395 dance => {
396 noparams => {
397 other => "<self> expresses himself through interpretive dance.",
398 self => "You dance with glee.",
399 },
400 params => {
401 target => "<self> grabs you, and begins dancing!",
402 other => "Yipe! <self> and <other> are doing the Macarena!",
403 self => "You grab <other> and begin doing the Cha-Cha!",
404 },
405 self => {
406 other => "<self> embraces himself and begins to dance!",
407 self => "You skip and dance around by yourself.",
408 },
409 },
410 snore => {
411 noparams => {
412 other => "<self> snores loudly.",
413 self => "Zzzzzzzzzzzzzzz.",
414 },
415 params => {
416 },
417 self => {
418 },
419 },
420 blush => {
421 noparams => {
422 other => "<self> blushes.",
423 self => "Your cheeks are burning.",
424 },
425 params => {
426 },
427 self => {
428 },
429 },
430 snap => {
431 noparams => {
432 other => "<self> snaps his fingers.",
433 self => "PRONTO! you snap your fingers.",
434 },
435 params => {
436 },
437 self => {
438 },
439 },
440 wave => {
441 noparams => {
442 other => "<self> waves happily.",
443 self => "You wave.",
444 },
445 params => {
446 target => "<self> waves goodbye to you. Have a good journey.",
447 other => "<self> waves goodbye to <other>.",
448 self => "You wave goodbye to <other>.",
449 },
450 self => {
451 other => "<self> waves goodbye to himself.",
452 self => "Are you going on adventures as well??",
453 },
454 },
455 smile => {
456 noparams => {
457 other => "<self> smiles happily.",
458 self => "You smile happily.",
459 },
460 params => {
461 target => "<self> smiles at you.",
462 other => "<self> beams a smile at <other>.",
463 self => "You smile at <other>.",
464 },
465 self => {
466 },
467 },
468 sneeze => {
469 noparams => {
470 other => "<self> sneezes.",
471 self => "Gesundheit!",
472 },
473 params => {
474 target => "<self> sneezes on you, you feel the snot cover you. EEEEEEW.",
475 other => "<self> sneezes on <other> and a film of snot covers him.",
476 self => "You sneeze at <other> and a film of snot shoots onto him.",
477 },
478 self => {
479 other => "<self> sneezes, and covers himself in a slimy substance.",
480 self => "You sneeze on yourself, what a mess!",
481 },
482 },
483 bounce => {
484 noparams => {
485 other => "<self> bounces around.",
486 self => "BOIINNNNNNGG!",
487 },
488 params => {
489 target => "<self> bounces around the room with you.",
490 other => "<self> bounces around the room with <other>.",
491 self => "You bounce around the room with <other>.",
492 },
493 self => {
494 },
495 },
496 shake => {
497 noparams => {
498 other => "<self> shakes his head.",
499 self => "You shake your head.",
500 },
501 params => {
502 target => "<self> shakes your hand.",
503 other => "<self> shakes <other>'s hand.",
504 self => "You shake <other>'s hand.",
505 },
506 self => {
507 other => "<self> shakes and quivers like a bowlful of jelly.",
508 self => "You are shaken by yourself.",
509 },
510 },
511 lick => {
512 noparams => {
513 other => "<self> licks his mouth and smiles.",
514 self => "You lick your mouth and smile.",
515 },
516 params => {
517 target => "<self> licks you.",
518 other => "<self> licks <other>.",
519 self => "You lick <other>.",
520 },
521 self => {
522 other => "<self> licks himself - YUCK.",
523 self => "You lick yourself.",
524 },
525 },
526 flip => {
527 noparams => {
528 other => "<self> flips head over heels.",
529 self => "You flip head over heels.",
530 },
531 params => {
532 },
533 self => {
534 },
535 },
536 think => {
537 noparams => {
538 other => "<self> closes his eyes and thinks really hard.",
539 self => "Anything in particular that you'd care to think about?",
540 },
541 params => {
542 },
543 self => {
544 },
545 },
546 yawn => {
547 noparams => {
548 other => "<self> yawns sleepily.",
549 self => "You open up your yap and let out a big breeze of stale air.",
550 },
551 params => {
552 },
553 self => {
554 },
555 },
556 laugh => {
557 noparams => {
558 other => "<self> falls down laughing.",
559 self => "You fall down laughing.",
560 },
561 params => {
562 target => "<self> looks at you and falls down on the ground laughing.",
563 other => "<self> looks at <other> and falls down on the ground laughing.",
564 self => "You take one look at <other> and fall down laughing.",
565 },
566 self => {
567 other => "<self> is laughing at something.",
568 self => "Laugh at yourself all you want, the others won't understand.",
569 },
570 },
571 burp => {
572 noparams => {
573 other => "<self> burps loudly.",
574 self => "You burp loudly.",
575 },
576 params => {
577 },
578 self => {
579 },
580 },
581 gasp => {
582 noparams => {
583 other => "<self> gasps in astonishment.",
584 self => "You gasp in astonishment.",
585 },
586 params => {
587 },
588 self => {
589 },
590 },
591 smirk => {
592 noparams => {
593 other => "<self> smirks.",
594 self => "You smirk.",
595 },
596 params => {
597 },
598 self => {
599 },
600 },
601 cry => {
602 noparams => {
603 other => "<self> bursts into tears.",
604 self => "Waaaaaaahhh..",
605 },
606 params => {
607 target => "<self> cries on your shoulder.",
608 other => "<self> cries on <other>'s shoulder.",
609 self => "You cry on <other>'s shoulder.",
610 },
611 self => {
612 other => "<self> sobs quietly to himself.",
613 self => "You cry to yourself.",
614 },
615 },
616 sulk => {
617 noparams => {
618 other => "<self> sulks in the corner.",
619 self => "You sulk.",
620 },
621 params => {
622 },
623 self => {
624 },
625 },
626 whistle => {
627 noparams => {
628 other => "<self> whistles appreciatively.",
629 self => "You whistle appreciatively.",
630 },
631 params => {
632 target => "<self> whistles at <other>.",
633 self => "You whistle at <other>.",
634 },
635 self => {
636 other => "<self> whistles to himself in boredom.",
637 self => "You whistle while you work.",
638 },
639 },
640 groan => {
641 noparams => {
642 other => "<self> groans loudly.",
643 self => "You groan loudly.",
644 },
645 params => {
646 },
647 self => {
648 },
649 },
650 cough => {
651 noparams => {
652 other => "<self> coughs loudly.",
653 self => "Yuck, try to cover your mouth next time!",
654 },
655 params => {
656 },
657 self => {
658 },
659 },
660 grin => {
661 noparams => {
662 other => "<self> grins evilly.",
663 self => "You grin evilly.",
664 },
665 params => {
666 target => "<self> grins evilly at you.",
667 other => "<self> grins evilly at <other>.",
668 self => "You grin at <other>.",
669 },
670 self => {
671 },
672 },
673};
674
675for my $emotion (keys %$emotes) {
676 cf::register_command $emotion => sub {
677 my ($pl, $tname) = @_;
678
679 cf::async {
680 my $name = $pl->name;
681
682 if ($tname eq $name) {
683 my $emote = $emotes->{$emotion}->{self};
684
685 $emote->{other} = "You look away from <self>."
686 if !$emote->{other};
687 $emote->{self} = "My god! Is that LEGAL?"
688 if !$emote->{self};
689
690 $emote->{other} =~ s/<self>/$name/;
691
692 for my $other ( grep { $pl->on_same_map_as ($_->ob) } cf::player::list ) {
693 next
694 if $other->ob == $pl;
695 $other->ob->message ($emote->{other}, cf::NDI_GREY | cf::NDI_UNIQUE);
696 }
697
698 $pl->message ($emote->{self}, cf::NDI_GREY | cf::NDI_UNIQUE);
699 } elsif ($tname) {
700 my $target = cf::player::find $tname
701 or return $pl->reply (undef, "$tname is not around.");
702
703 my $emote = $emotes->{$emotion}->{params};
704
705 $emote->{other} = "<self> is eyeing <other> quizzically."
706 if !$emote->{other};
707 $emote->{self} = "You are still nuts."
708 if !$emote->{self};
709 $emote->{target} = "You get the distinct feeling that <other> is nuts."
710 if !$emote->{target};
711
712 $emote->{self} =~ s/<other>/$tname/;
713 $emote->{target} =~ s/<self>/$name/;
714 $emote->{other} =~ s/<other>/$tname/;
715 $emote->{other} =~ s/<self>/$name/;
716
717 for my $other ( grep { $pl->on_same_map_as ($_->ob) } cf::player::list ) {
718 next
719 if $other->ob == $pl or $other == $target;
720 $other->ob->message ($emote->{other}, cf::NDI_GREY | cf::NDI_UNIQUE);
721 }
722
723 $target->ob->message ($emote->{target}, cf::NDI_GREY | cf::NDI_UNIQUE);
724 $pl->message ($emote->{self}, cf::NDI_GREY | cf::NDI_UNIQUE);
725 } else {
726 my $emote = $emotes->{$emotion}->{noparams};
727 $emote->{other} =~ s/<self>/$name/;
728
729 $emote->{other} = "<self> dances with glee."
730 if !$emote->{other};
731 $emote->{self} = "You are a nut."
732 if !$emote->{self};
733
734 for my $other ( grep { $pl->on_same_map_as ($_->ob) } cf::player::list ) {
735 next
736 if $other->ob == $pl;
737 $other->ob->message ($emote->{other}, cf::NDI_GREY | cf::NDI_UNIQUE);
738 }
739
740 $pl->message ($emote->{self}, cf::NDI_GREY | cf::NDI_UNIQUE);
741 }
742 };
743 };
744}
745
746cf::register_command me => sub {
747 my ($pl, $msg) = @_;
748
749 my $name = $pl->name;
750
751 $_->ob->message ("* $name $msg", cf::NDI_GREY | cf::NDI_UNIQUE)
752 for grep $pl->on_same_map_as ($_->ob), cf::player::list;
51}; 753};
52 754
53cf::register_command say => sub { 755cf::register_command say => sub {
54 my ($who, $msg) = @_; 756 my ($pl, $msg) = @_;
55 757
56 utf8::decode $msg; 758 utf8::decode $msg;
57 759
58 return if $who->contr->invoke (cf::EVENT_PLAYER_SAY, $msg); 760 return if $pl->contr->invoke (cf::EVENT_PLAYER_SAY, $msg);
59 761
60 if ($msg) { 762 if ($msg) {
61 my $name = $who->name; 763 my $name = $pl->name;
62 764
63 utf8::encode $msg; # ->message not yet utf8-ified 765 utf8::encode $msg; # ->message not yet utf8-ified
64 $_->ob->message ("$name says: $msg", cf::NDI_GREY | cf::NDI_UNIQUE) 766 $_->ob->message ("$name says: $msg", cf::NDI_GREY | cf::NDI_UNIQUE)
65 for grep $who->on_same_map_as ($_->ob), cf::player::list; 767 for grep $pl->on_same_map_as ($_->ob), cf::player::list;
66 utf8::decode $msg; 768 utf8::decode $msg;
67 769
68 # npcs, magic_ears etc. 770 # npcs, magic_ears etc.
69 # first find all objects and theirt-level inventories 771 # first find all objects and theirt-level inventories
70 # within a 5x5 square # that have something resembling 772 # within a 5x5 square # that have something resembling
71 # dialogue or support on_say. 773 # dialogue or support on_say.
72 my ($map, $x, $y) = ($who->map, $who->x - 2, $who->y - 2); 774 my ($map, $x, $y) = ($pl->map, $pl->x - 2, $pl->y - 2);
73 775
74 for my $npc ( 776 for my $npc (
75 grep +($_->invoke (cf::EVENT_OBJECT_SAY, $who->contr, $msg) && return) || NPC_Dialogue::has_dialogue $_, 777 grep +($_->invoke (cf::EVENT_OBJECT_SAY, $pl->contr, $msg) && return) || NPC_Dialogue::has_dialogue $_,
76 map +($_, $_->inv), 778 map +($_, $_->inv),
77 grep $_, 779 grep $_,
78 map $map->at ($x + $_ % 5, $y + (int $_ / 5)), 780 map $map->at ($x + $_ % 5, $y + (int $_ / 5)),
79 0..24 781 0..24
80 ) { 782 ) {
81 # if some listener teleported us somewhere else, stop right here 783 # if some listener teleported us somewhere else, stop right here
82 last unless $map->path == $who->map->path; 784 last unless $map->path == $pl->map->path;
83 785
84 my $dialog = new NPC_Dialogue ob => $who, npc => $npc; 786 my $dialog = new NPC_Dialogue ob => $pl, npc => $npc;
85 my ($reply, @kw) = $dialog->tell ($msg); 787 my ($reply, @kw) = $dialog->tell ($msg);
86 788
87 if (defined $reply) { 789 if (defined $reply) {
88 if ($npc->type == cf::MAGIC_EAR) { 790 if ($npc->type == cf::MAGIC_EAR) {
89 if (length $reply) { 791 if (length $reply) {
90 $_->ob->message ($reply, cf::NDI_BROWN | cf::NDI_UNIQUE) 792 $_->ob->message ($reply, cf::NDI_BROWN | cf::NDI_UNIQUE)
91 for grep $who->on_same_map_as ($_->ob), cf::player::list; 793 for grep $pl->on_same_map_as ($_->ob), cf::player::list;
92 } 794 }
93 $npc->use_trigger; 795 $npc->use_trigger;
94 } else { 796 } else {
95 if (length $reply) { 797 if (length $reply) {
96 $_->ob->message ($npc->name . " says: $reply", cf::NDI_BROWN | cf::NDI_UNIQUE) 798 $_->ob->message ($npc->name . " says: $reply", cf::NDI_BROWN | cf::NDI_UNIQUE)
97 for grep $who->on_same_map_as ($_->ob), cf::player::list; 799 for grep $pl->on_same_map_as ($_->ob), cf::player::list;
98 } 800 }
99 } 801 }
100 } 802 }
101 803
102 if (@kw) { 804 if (@kw) {
103 $_->ob->message ("[further topics: " . (join ", ", @kw) . "]", cf::NDI_BROWN | cf::NDI_UNIQUE) 805 $_->ob->message ("[further topics: " . (join ", ", @kw) . "]", cf::NDI_BROWN | cf::NDI_UNIQUE)
104 for grep $who->on_same_map_as ($_->ob), cf::player::list; 806 for grep $pl->on_same_map_as ($_->ob), cf::player::list;
105 } 807 }
106 } 808 }
107 809
108 } else { 810 } else {
109 $who->message ("What do you want to say?", cf::NDI_UNIQUE); 811 $pl->message ("What do you want to say?", cf::NDI_UNIQUE);
110 } 812 }
111}; 813};
112 814
113cf::register_command chat => sub { 815cf::register_command chat => sub {
114 my ($who, $msg) = @_; 816 my ($pl, $msg) = @_;
115 817
116 utf8::decode $msg; 818 utf8::decode $msg;
117 819
118 return if $who->contr->invoke (cf::EVENT_PLAYER_CHAT, $msg); 820 return if $pl->contr->invoke (cf::EVENT_PLAYER_CHAT, $msg);
119 821
120 if ($msg) { 822 if ($msg) {
121 my $name = $who->name; 823 my $name = $pl->name;
122 my $NOW = time; 824 my $NOW = time;
123 825
124 utf8::encode $msg; # ->message not yet utf8-ified 826 utf8::encode $msg; # ->message not yet utf8-ified
125 cf::LOG cf::llevDebug, sprintf "QBERT [%s] %s\n", $name, $msg; 827 cf::LOG cf::llevDebug, sprintf "QBERT [%s] %s\n", $name, $msg;
126 ext::schmorp_irc::do_notice (sprintf "[%s] %s", $name, $msg); 828 ext::schmorp_irc::do_notice (sprintf "[%s] %s", $name, $msg);
127 829
128 $_->ob->message ("$name chats: $msg", cf::NDI_BLUE) 830 $_->ob->message ("$name chats: $msg", cf::NDI_BLUE)
129 for grep { $_->ob->{ext_ignore_shout}{$name} < $NOW && $_->listening >= 10 } cf::player::list; 831 for grep { $_->ob->{ext_ignore_shout}{$name} < $NOW && $_->listening >= 10 } cf::player::list;
130 832
131 } else { 833 } else {
132 $who->message ("Chat what?", cf::NDI_UNIQUE); 834 $pl->message ("Chat what?", cf::NDI_UNIQUE);
133 } 835 }
134}; 836};
135 837
136cf::register_command shout => sub { 838cf::register_command shout => sub {
137 my ($who, $msg) = @_; 839 my ($pl, $msg) = @_;
138 840
139 utf8::decode $msg; 841 utf8::decode $msg;
140 842
141 return if $who->contr->invoke (cf::EVENT_PLAYER_SHOUT, $msg); 843 return if $pl->contr->invoke (cf::EVENT_PLAYER_SHOUT, $msg);
142 844
143 if ($msg) { 845 if ($msg) {
144 my $NOW = time; 846 my $NOW = time;
145 my $name = $who->name; 847 my $name = $pl->name;
146 848
147 cf::LOG cf::llevDebug, sprintf "QBERT {%s} %s\n", $name, $msg; 849 cf::LOG cf::llevDebug, sprintf "QBERT {%s} %s\n", $name, $msg;
148 ext::schmorp_irc::do_notice (sprintf "\007\0034{%s} %s\n", $name, $msg); 850 ext::schmorp_irc::do_notice (sprintf "\007\0034{%s} %s\n", $name, $msg);
149 851
150 utf8::encode $msg; # ->message not yet utf8-ified 852 utf8::encode $msg; # ->message not yet utf8-ified
151 $_->ob->message ("$name shouts: $msg", cf::NDI_RED) 853 $_->ob->message ("$name shouts: $msg", cf::NDI_RED)
152 for grep { $_->ob->{ext_ignore_shout}{$name} < $NOW && $_->listening >= 2 } cf::player::list; 854 for grep { $_->ob->{ext_ignore_shout}{$name} < $NOW && $_->listening >= 2 } cf::player::list;
153 855
154 } else { 856 } else {
155 $who->message ("Shout what?", cf::NDI_UNIQUE); 857 $pl->message ("Shout what?", cf::NDI_UNIQUE);
156 } 858 }
157
158}; 859};
159 860
160cf::register_command tell => sub { 861cf::register_command tell => sub {
161 my ($who, $args) = @_; 862 my ($pl, $args) = @_;
162 my ($target, $msg) = split /\s+/, $args, 2; 863 my ($target, $msg) = split /\s+/, $args, 2;
163 864
164 utf8::decode $msg; 865 utf8::decode $msg;
165 866
166 return if $who->contr->invoke (cf::EVENT_PLAYER_TELL, $target, $msg); 867 return if $pl->contr->invoke (cf::EVENT_PLAYER_TELL, $target, $msg);
167 868
168 my $name = $who->name; 869 my $name = $pl->name;
169 870
170 if ($target =~ /irc\//) { 871 if ($target =~ /irc\//) {
171 my (undef, $nick) = split /\//, $target, 2; 872 my (undef, $nick) = split /\//, $target, 2;
172 $who->message ("You tell $target: $args"); 873 $pl->message ("You tell $target: $args");
173 ext::schmorp_irc::do_notice (sprintf "(%s) %s: %s\n", $name, $nick, $msg); 874 ext::schmorp_irc::do_notice (sprintf "(%s) %s: %s\n", $name, $nick, $msg);
174 } elsif (my $other = cf::player::find $target) { 875 } elsif (my $other = cf::player::find_active $target) {
175 876
176 if ($msg) { 877 if ($msg) {
177 if ($target eq $name) { 878 if ($target eq $name) {
178 $who->message ("You are talking to yourself, you freak!", cf::NDI_UNIQUE); 879 $pl->message ("You are talking to yourself, you freak!", cf::NDI_UNIQUE);
179 } elsif ($other->ob->{ext_ignore_tell}{$name} >= time) { 880 } elsif ($other->ob->{ext_ignore_tell}{$name} >= time) {
180 $who->message ("$target ignores what you say. Give up on it.", cf::NDI_UNIQUE); 881 $pl->message ("$target ignores what you say. Give up on it.", cf::NDI_UNIQUE);
181 } else { 882 } else {
182 utf8::encode $msg; # ->message not yet utf8-ified 883 utf8::encode $msg; # ->message not yet utf8-ified
183 cf::LOG cf::llevDebug, sprintf "TELL [%s>%s] %s\n", $name, $target, $msg; 884 cf::LOG cf::llevDebug, sprintf "TELL [%s>%s] %s\n", $name, $target, $msg;
184 885
185 $who->message ("You tell $target: $msg"); 886 $pl->message ("You tell $target: $msg");
186 $other->ob->message ("$name tells you: $msg"); 887 $other->ob->message ("$name tells you: $msg");
187 $other->ob->{ext_last_tell} = $name; 888 $other->ob->{ext_last_tell} = $name;
188 } 889 }
189 } else { 890 } else {
190 $who->message ("What do you want to tell $target?", cf::NDI_UNIQUE); 891 $pl->message ("What do you want to tell $target?", cf::NDI_UNIQUE);
191 } 892 }
192 893
193 } else { 894 } else {
194 $who->message ("No such player. Your message: $msg", cf::NDI_UNIQUE); 895 $pl->message ("No such player. Your message: $msg", cf::NDI_UNIQUE);
195 } 896 }
196}; 897};
197 898
198cf::register_command reply => sub { 899cf::register_command reply => sub {
199 my ($who, $args) = @_; 900 my ($pl, $args) = @_;
200 my $name = $who->name; 901 my $name = $pl->name;
201 902
202 utf8::decode $args; 903 utf8::decode $args;
203 904
204 return if $who->contr->invoke (cf::EVENT_PLAYER_TELL, $who->{ext_last_tell}, $args); 905 return if $pl->contr->invoke (cf::EVENT_PLAYER_TELL, $pl->{ext_last_tell}, $args);
205 906
206 if ($who->{ext_last_tell} =~ /irc\//) { 907 if ($pl->{ext_last_tell} =~ /irc\//) {
207 my (undef, $nick) = split /\//, $who->{ext_last_tell}, 2; 908 my (undef, $nick) = split /\//, $pl->{ext_last_tell}, 2;
208 $who->message ("You tell " . $who->{ext_last_tell} . ": $args"); 909 $pl->message ("You tell " . $pl->{ext_last_tell} . ": $args");
209 ext::schmorp_irc::do_notice (sprintf "(%s) %s: %s\n", $name, $nick, $args); 910 ext::schmorp_irc::do_notice (sprintf "(%s) %s: %s\n", $name, $nick, $args);
210 } elsif (my $other = cf::player::find $who->{ext_last_tell}) { 911 } elsif (my $other = cf::player::find_active $pl->{ext_last_tell}) {
211 912
212 if ($args) { 913 if ($args) {
213 $other->ob->{ext_ignore_tell}{$name} >= time 914 $other->ob->{ext_ignore_tell}{$name} >= time
214 or delete $other->ob->{ext_ignore_tell}{$name}; 915 or delete $other->ob->{ext_ignore_tell}{$name};
215 916
216 if ($other->ob->{ext_ignore_tell}{$name} < time) { 917 if ($other->ob->{ext_ignore_tell}{$name} < time) {
217 utf8::encode $args; # ->message not yet utf8-ified 918 utf8::encode $args; # ->message not yet utf8-ified
218 cf::LOG cf::llevDebug, sprintf "TELL [%s>%s] %s\n", $name, $other->ob->name, $args; 919 cf::LOG cf::llevDebug, sprintf "TELL [%s>%s] %s\n", $name, $other->ob->name, $args;
219 920
220 $who->message ("You tell " . $other->ob->name . ": $args"); 921 $pl->message ("You tell " . $other->ob->name . ": $args");
221 $other->ob->message ("$name tells you: $args"); 922 $other->ob->message ("$name tells you: $args");
222 $who->{ext_last_tell} = $other->ob->name; 923 $pl->{ext_last_tell} = $other->ob->name;
223 } else { 924 } else {
224 $who->message ($other->ob->name . " ignores what you say. Give up on it.", cf::NDI_UNIQUE); 925 $pl->message ($other->ob->name . " ignores what you say. Give up on it.", cf::NDI_UNIQUE);
225 } 926 }
226 } else { 927 } else {
227 $who->message ("What do you want to tell ".$other->ob->name."?", cf::NDI_UNIQUE); 928 $pl->message ("What do you want to tell ".$other->ob->name."?", cf::NDI_UNIQUE);
228 } 929 }
229 930
230 } else { 931 } else {
231 $who->message ("Can't reply, player left. Your message: $args".$who->{ext_last_tell}, cf::NDI_UNIQUE); 932 $pl->message ("Can't reply, player left. Your message: $args".$pl->{ext_last_tell}, cf::NDI_UNIQUE);
232 } 933 }
233}; 934};
234 935
235cf::register_command ignore => sub { 936cf::register_command ignore => sub {
236 my ($who, $args) = @_; 937 my ($pl, $args) = @_;
237 my ($target, $type, $timeout) = split /\s+/, $args; 938 my ($target, $type, $timeout) = split /\s+/, $args;
238 939
239 if ($args eq "list") { 940 if ($args eq "list") {
240 clean_timeouts $who; 941 clean_timeouts $pl;
241 942
242 if ((my @ignored_tell = sort keys %{$who->{ext_ignore_tell}}) 943 if ((my @ignored_tell = sort keys %{$pl->{ext_ignore_tell}})
243 + (my @ignored_shout = sort keys %{$who->{ext_ignore_shout}})) { 944 + (my @ignored_shout = sort keys %{$pl->{ext_ignore_shout}})) {
244 $who->message ("Currently ignoring private messages from: ", cf::NDI_UNIQUE); 945 $pl->message ("Currently ignoring private messages from: ", cf::NDI_UNIQUE);
245 $who->message ((join ", ", @ignored_tell), cf::NDI_UNIQUE); 946 $pl->message ((join ", ", @ignored_tell), cf::NDI_UNIQUE);
246 $who->message ("Currently ignoring shouts from: ", cf::NDI_UNIQUE); 947 $pl->message ("Currently ignoring shouts from: ", cf::NDI_UNIQUE);
247 $who->message ((join ", ", @ignored_shout), cf::NDI_UNIQUE); 948 $pl->message ((join ", ", @ignored_shout), cf::NDI_UNIQUE);
248 $who->message ("To stop ignoring one, use unignore.", cf::NDI_UNIQUE); 949 $pl->message ("To stop ignoring one, use unignore.", cf::NDI_UNIQUE);
249 } else { 950 } else {
250 $who->message ("Not ignoring anyone", cf::NDI_UNIQUE); 951 $pl->message ("Not ignoring anyone", cf::NDI_UNIQUE);
251 } 952 }
252 953
253 } elsif ($target && $type) { 954 } elsif ($target && $type) {
254 955
255 $timeout ne "" or $timeout = 24; 956 $timeout ne "" or $timeout = 24;
256 my $absolute_timeout = time + $timeout * 3600; 957 my $absolute_timeout = time + $timeout * 3600;
257 958
258 if (cf::player::exists $target) { 959 if (cf::player::exists $target) {
259 if ($type eq "tell") { 960 if ($type eq "tell") {
260 $who->message ("Now ignoring private messages from $target for $timeout hours.", cf::NDI_UNIQUE); 961 $pl->message ("Now ignoring private messages from $target for $timeout hours.", cf::NDI_UNIQUE);
261 $who->{ext_ignore_tell}{$target} = $absolute_timeout; 962 $pl->{ext_ignore_tell}{$target} = $absolute_timeout;
262 } elsif ($type eq "shout") { 963 } elsif ($type eq "shout") {
263 $who->message ("Now ignoring shouts from $target for $timeout hours.", cf::NDI_UNIQUE); 964 $pl->message ("Now ignoring shouts from $target for $timeout hours.", cf::NDI_UNIQUE);
264 $who->{ext_ignore_shout}{$target} = $absolute_timeout; 965 $pl->{ext_ignore_shout}{$target} = $absolute_timeout;
265 } elsif ($type eq "all") { 966 } elsif ($type eq "all") {
266 $who->message ("Now ignoring everything from $target for $timeout hours.", cf::NDI_UNIQUE); 967 $pl->message ("Now ignoring everything from $target for $timeout hours.", cf::NDI_UNIQUE);
267 $who->{ext_ignore_tell}{$target} = $absolute_timeout; 968 $pl->{ext_ignore_tell}{$target} = $absolute_timeout;
268 $who->{ext_ignore_shout}{$target} = $absolute_timeout; 969 $pl->{ext_ignore_shout}{$target} = $absolute_timeout;
269 } else { 970 } else {
270 $who->message ("You need to specify tell, shout or all.", cf::NDI_UNIQUE); 971 $pl->message ("You need to specify tell, shout or all.", cf::NDI_UNIQUE);
271 } 972 }
272 } else { 973 } else {
273 $who->message ("No such player: $target", cf::NDI_UNIQUE); 974 $pl->message ("No such player: $target", cf::NDI_UNIQUE);
274 } 975 }
275 976
276 } else { 977 } else {
277 $who->message ("Usage: ignore <player> <tell|shout|all> <timeout>\n" 978 $pl->message ("Usage: ignore <player> <tell|shout|all> <timeout>\n"
278 . "will ignore a player for <timeout> hours.\n" 979 . "will ignore a player for <timeout> hours.\n"
279 . "Usage: ignore list\n" 980 . "Usage: ignore list\n"
280 . "will show you a list of players currently ignored.", cf::NDI_UNIQUE); 981 . "will show you a list of players currently ignored.", cf::NDI_UNIQUE);
281 } 982 }
282}; 983};
283 984
284cf::register_command unignore => sub { 985cf::register_command unignore => sub {
285 my ($who, $args) = @_; 986 my ($pl, $args) = @_;
286 my ($target, $type) = split /\s+/, $args; 987 my ($target, $type) = split /\s+/, $args;
287 988
288 if ($args eq "") { 989 if ($args eq "") {
289 if ($who->{ext_ignore_tell}) { 990 if ($pl->{ext_ignore_tell}) {
290 $who->message ("Currently ignoring private messages from: ", cf::NDI_UNIQUE); 991 $pl->message ("Currently ignoring private messages from: ", cf::NDI_UNIQUE);
291 $who->message ((join ", ", sort keys %{ $who->{ext_ignore_tell} }), cf::NDI_UNIQUE); 992 $pl->message ((join ", ", sort keys %{ $pl->{ext_ignore_tell} }), cf::NDI_UNIQUE);
292 $who->message ("Currently ignoring shouts from: ", cf::NDI_UNIQUE); 993 $pl->message ("Currently ignoring shouts from: ", cf::NDI_UNIQUE);
293 $who->message ((join ", ", sort keys %{ $who->{ext_ignore_shout} }), cf::NDI_UNIQUE); 994 $pl->message ((join ", ", sort keys %{ $pl->{ext_ignore_shout} }), cf::NDI_UNIQUE);
294 } else { 995 } else {
295 $who->message ("Not ignoring anyone", cf::NDI_UNIQUE); 996 $pl->message ("Not ignoring anyone", cf::NDI_UNIQUE);
296 } 997 }
297 } else { 998 } else {
298 if (cf::player::exists $target) { 999 if (cf::player::exists $target) {
299 if ($type eq "tell") { 1000 if ($type eq "tell") {
300 $who->message ("Not ignoring private messages from $target anymore.", cf::NDI_UNIQUE); 1001 $pl->message ("Not ignoring private messages from $target anymore.", cf::NDI_UNIQUE);
301 delete $who->{ext_ignore_tell} {$target}; 1002 delete $pl->{ext_ignore_tell} {$target};
302 } elsif ($type eq "shout") { 1003 } elsif ($type eq "shout") {
303 $who->message ("Not ignoring shouts from $target anymore.", cf::NDI_UNIQUE); 1004 $pl->message ("Not ignoring shouts from $target anymore.", cf::NDI_UNIQUE);
304 delete $who->{ext_ignore_shout}{$target}; 1005 delete $pl->{ext_ignore_shout}{$target};
305 } elsif ($type eq "all") { 1006 } elsif ($type eq "all") {
306 $who->message ("Not ignoring anything from $target anymore.", cf::NDI_UNIQUE); 1007 $pl->message ("Not ignoring anything from $target anymore.", cf::NDI_UNIQUE);
307 delete $who->{ext_ignore_tell} {$target}; 1008 delete $pl->{ext_ignore_tell} {$target};
308 delete $who->{ext_ignore_shout}{$target}; 1009 delete $pl->{ext_ignore_shout}{$target};
309 } else { 1010 } else {
310 $who->message ("You need to specify tell, shout or all.", cf::NDI_UNIQUE); 1011 $pl->message ("You need to specify tell, shout or all.", cf::NDI_UNIQUE);
311 } 1012 }
312 } else { 1013 } else {
313 $who->message ("No such player or ambiguous name: $target", cf::NDI_UNIQUE); 1014 $pl->message ("No such player or ambiguous name: $target", cf::NDI_UNIQUE);
314 } 1015 }
315 } 1016 }
316}; 1017};
317 1018
318cf::register_command seen => sub { 1019cf::register_command seen => sub {
319 my ($who, $args) = @_; 1020 my ($pl, $args) = @_;
320 1021
321 if (my ($login) = $args =~ /(\S+)/) { 1022 if (my ($login) = $args =~ /(\S+)/) {
322 if ($login eq $who->name) { 1023 if ($login eq $pl->name) {
323 $who->message ("Very funny, $login. Ha. Ha.", cf::NDI_UNIQUE); 1024 $pl->message ("Very funny, $login. Ha. Ha.", cf::NDI_UNIQUE);
324 } elsif (cf::player::find $login) { 1025 } elsif (cf::player::find_active $login) {
325 $who->message ("$login is right here on this server!", cf::NDI_UNIQUE); 1026 $pl->message ("$login is right here on this server!", cf::NDI_UNIQUE);
326 } elsif (cf::player::exists $login 1027 } elsif (cf::player::exists $login
327 and stat sprintf "%s/%s/%s/%s.pl", cf::localdir, cf::playerdir, ($login) x 2) { 1028 and stat sprintf "%s/%s/%s/%s.pl", cf::localdir, cf::playerdir, ($login) x 2) {
328 my $time = (stat _)[9]; 1029 my $time = (stat _)[9];
329 1030
330 $who->message ("$login was last seen here " 1031 $pl->message ("$login was last seen here "
331 . (POSIX::strftime "%Y-%m-%d %H:%M:%S +0000", gmtime $time) 1032 . (POSIX::strftime "%Y-%m-%d %H:%M:%S +0000", gmtime $time)
332 . " which was " . (int +(time - $time) / 3600) . " hours ago.", cf::NDI_UNIQUE); 1033 . " which was " . (int +(time - $time) / 3600) . " hours ago.", cf::NDI_UNIQUE);
333 } else { 1034 } else {
334 $who->message ("No player named $login is known to me.", cf::NDI_UNIQUE); 1035 $pl->message ("No player named $login is known to me.", cf::NDI_UNIQUE);
335 } 1036 }
336 } else { 1037 } else {
337 $who->message ("Usage: seen <player>", cf::NDI_UNIQUE); 1038 $pl->message ("Usage: seen <player>", cf::NDI_UNIQUE);
338 } 1039 }
339}; 1040};
340 1041

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines