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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines