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.6 by pippijn, Wed Feb 28 19:25:27 2007 UTC vs.
Revision 1.12 by pippijn, Fri Mar 2 00:29:08 2007 UTC

29 on_login => sub { 29 on_login => sub {
30 my ($pl) = @_; 30 my ($pl) = @_;
31 31
32 clean_timeouts $pl->ob; 32 clean_timeouts $pl->ob;
33 }, 33 },
34
35 1
36); 34);
37 35
38cf::register_command listen => sub { 36cf::register_command listen => sub {
39 my ($who, $msg) = @_; 37 my ($pl, $msg) = @_;
40 my $player = cf::player::find_active $who->name; 38 my $player = cf::player::find_active $pl->name;
41 39
42 if ($msg ne "") { 40 if ($msg ne "") {
43 my $prev_listen = $player->listening; 41 my $prev_listen = $player->listening;
44 $player->listening ($msg); 42 $player->listening ($msg);
45 if ($prev_listen == $player->listening) { 43 if ($prev_listen == $player->listening) {
46 $who->message ("Your verbose level stayed $prev_listen.", cf::NDI_UNIQUE); 44 $pl->message ("Your verbose level stayed $prev_listen.", cf::NDI_UNIQUE);
47 } else { 45 } else {
48 $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);
49 } 47 }
50 } else { 48 } else {
51 $who->message ("Your verbose level is " . $player->listening . ".", cf::NDI_UNIQUE); 49 $pl->message ("Your verbose level is " . $player->listening . ".", cf::NDI_UNIQUE);
52 }
53
54 1 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);
55}; 93};
56 94
57my $emotes = { 95my $emotes = {
58 growl => { 96 growl => {
59 noparams => { 97 noparams => {
189 noparams => { 227 noparams => {
190 other => "<self> winks suggestively.", 228 other => "<self> winks suggestively.",
191 self => "Have you got something in your eye?", 229 self => "Have you got something in your eye?",
192 }, 230 },
193 params => { 231 params => {
232 target => "<self> winks at you.",
194 target => "<self> winks at <other>.", 233 other => "<self> winks at <other>.",
195 self => "You wink suggestively at <other>.", 234 self => "You wink suggestively at <other>.",
196 }, 235 },
197 self => { 236 self => {
198 other => "<self> winks at himself - something strange is going on...", 237 other => "<self> winks at himself - something strange is going on...",
199 self => "You wink at yourself?? What are you up to?", 238 self => "You wink at yourself?? What are you up to?",
289 noparams => { 328 noparams => {
290 other => "<self> is bleeding all over the carpet - got a spare tourniquet?", 329 other => "<self> is bleeding all over the carpet - got a spare tourniquet?",
291 self => "You bleed all over your nice new armour.", 330 self => "You bleed all over your nice new armour.",
292 }, 331 },
293 params => { 332 params => {
333 target => "<self> slashes his wrist and bleeds all over you.",
294 target => "<self> slashes his wrist and bleeds all over <other>.", 334 other => "<self> slashes his wrist and bleeds all over <other>.",
295 self => "You slash your wrist and bleed all over <other>", 335 self => "You slash your wrist and bleed all over <other>",
296 }, 336 },
297 self => { 337 self => {
298 other => "<self> performs some satanic ritual while wiping his blood on himself.", 338 other => "<self> performs some satanic ritual while wiping his blood on himself.",
299 self => "Very impressive! You wipe your blood all over yourself.", 339 self => "Very impressive! You wipe your blood all over yourself.",
631 }, 671 },
632 self => { 672 self => {
633 }, 673 },
634 }, 674 },
635}; 675};
676
636for my $emotion (keys %$emotes) { 677for my $emotion (keys %$emotes) {
637 cf::register_command $emotion => sub { 678 cf::register_command $emotion => sub {
638 my ($ob, $tname) = @_; 679 my ($pl, $tname) = @_;
639 680
640 cf::async { 681 cf::async {
641 my $name = $ob->name; 682 my $name = $pl->name;
642 683
643 if ($tname eq $name) { 684 if ($tname eq $name) {
644 my $emote = $emotes->{$emotion}->{self}; 685 my $emote = $emotes->{$emotion}->{self};
686
687 $emote->{other} = "You look away from <self>."
688 if !$emote->{other};
689 $emote->{self} = "My god! Is that LEGAL?"
690 if !$emote->{self};
691
645 $emote->{other} =~ s/<self>/$name/; 692 $emote->{other} =~ s/<self>/$name/;
646 693
647 for my $other ( grep { $ob->on_same_map_as ($_->ob) } cf::player::list ) { 694 for my $other ( grep { $pl->on_same_map_as ($_->ob) } cf::player::list ) {
648 next 695 next
649 if $other->ob == $ob; 696 if $other->ob == $pl;
650 $other->ob->message ($emote->{other}, cf::NDI_GREY | cf::NDI_UNIQUE); 697 $other->ob->message ($emote->{other}, cf::NDI_GREY | cf::NDI_UNIQUE);
651 } 698 }
652 699
653 $ob->message ($emote->{self}, cf::NDI_GREY | cf::NDI_UNIQUE); 700 $pl->message ($emote->{self}, cf::NDI_GREY | cf::NDI_UNIQUE);
654 } elsif ($tname) { 701 } elsif ($tname) {
655 my $target = cf::player::find $tname 702 my $target = cf::player::find $tname
656 or return $ob->reply (undef, "$tname is not around."); 703 or return $pl->reply (undef, "$tname is not around.");
657 704
658 my $emote = $emotes->{$emotion}->{params}; 705 my $emote = $emotes->{$emotion}->{params};
706
707 $emote->{other} = "<self> is eyeing <other> quizzically."
708 if !$emote->{other};
709 $emote->{self} = "You are still nuts."
710 if !$emote->{self};
711 $emote->{target} = "You get the distinct feeling that <other> is nuts."
712 if !$emote->{target};
713
659 $emote->{self} =~ s/<other>/$tname/; 714 $emote->{self} =~ s/<other>/$tname/;
660 $emote->{target} =~ s/<self>/$name/; 715 $emote->{target} =~ s/<self>/$name/;
661 $emote->{other} =~ s/<other>/$tname/; 716 $emote->{other} =~ s/<other>/$tname/;
662 $emote->{other} =~ s/<self>/$name/; 717 $emote->{other} =~ s/<self>/$name/;
663 718
664 for my $other ( grep { $ob->on_same_map_as ($_->ob) } cf::player::list ) { 719 for my $other ( grep { $pl->on_same_map_as ($_->ob) } cf::player::list ) {
665 next 720 next
666 if $other->ob == $ob or $other == $target; 721 if $other->ob == $pl or $other == $target;
667 $other->ob->message ($emote->{other}, cf::NDI_GREY | cf::NDI_UNIQUE); 722 $other->ob->message ($emote->{other}, cf::NDI_GREY | cf::NDI_UNIQUE);
668 } 723 }
669 724
670 $target->ob->message ($emote->{target}, cf::NDI_GREY | cf::NDI_UNIQUE); 725 $target->ob->message ($emote->{target}, cf::NDI_GREY | cf::NDI_UNIQUE);
671 $ob->message ($emote->{self}, cf::NDI_GREY | cf::NDI_UNIQUE); 726 $pl->message ($emote->{self}, cf::NDI_GREY | cf::NDI_UNIQUE);
672 } else { 727 } else {
673 my $emote = $emotes->{$emotion}->{noparams}; 728 my $emote = $emotes->{$emotion}->{noparams};
674 $emote->{other} =~ s/<self>/$name/; 729 $emote->{other} =~ s/<self>/$name/;
730
731 $emote->{other} = "<self> dances with glee."
732 if !$emote->{other};
733 $emote->{self} = "You are a nut."
734 if !$emote->{self};
675 735
676 for my $other ( grep { $ob->on_same_map_as ($_->ob) } cf::player::list ) { 736 for my $other ( grep { $pl->on_same_map_as ($_->ob) } cf::player::list ) {
677 next 737 next
678 if $other->ob == $ob; 738 if $other->ob == $pl;
679 $other->ob->message ($emote->{other}, cf::NDI_GREY | cf::NDI_UNIQUE); 739 $other->ob->message ($emote->{other}, cf::NDI_GREY | cf::NDI_UNIQUE);
680 } 740 }
681 741
682 $ob->message ($emote->{self}, cf::NDI_GREY | cf::NDI_UNIQUE); 742 $pl->message ($emote->{self}, cf::NDI_GREY | cf::NDI_UNIQUE);
683 } 743 }
684 }; 744 };
685 }; 745 };
686} 746}
687 747
748cf::register_command me => sub {
749 my ($pl, $msg) = @_;
750
751 my $name = $pl->name;
752
753 $_->ob->message ("* $name $msg", cf::NDI_GREY | cf::NDI_UNIQUE)
754 for grep $pl->on_same_map_as ($_->ob), cf::player::list;
755};
756
688cf::register_command say => sub { 757cf::register_command say => sub {
689 my ($who, $msg) = @_; 758 my ($pl, $msg) = @_;
690 759
691 utf8::decode $msg; 760 utf8::decode $msg;
692 761
693 return if $who->contr->invoke (cf::EVENT_PLAYER_SAY, $msg); 762 return if $pl->contr->invoke (cf::EVENT_PLAYER_SAY, $msg);
694 763
695 if ($msg) { 764 if ($msg) {
696 my $name = $who->name; 765 my $name = $pl->name;
697 766
698 utf8::encode $msg; # ->message not yet utf8-ified 767 utf8::encode $msg; # ->message not yet utf8-ified
699 $_->ob->message ("$name says: $msg", cf::NDI_GREY | cf::NDI_UNIQUE) 768 $_->ob->message ("$name says: $msg", cf::NDI_GREY | cf::NDI_UNIQUE)
700 for grep $who->on_same_map_as ($_->ob), cf::player::list; 769 for grep $pl->on_same_map_as ($_->ob), cf::player::list;
701 utf8::decode $msg; 770 utf8::decode $msg;
702 771
703 # npcs, magic_ears etc. 772 # npcs, magic_ears etc.
704 # first find all objects and theirt-level inventories 773 # first find all objects and theirt-level inventories
705 # within a 5x5 square # that have something resembling 774 # within a 5x5 square # that have something resembling
706 # dialogue or support on_say. 775 # dialogue or support on_say.
707 my ($map, $x, $y) = ($who->map, $who->x - 2, $who->y - 2); 776 my ($map, $x, $y) = ($pl->map, $pl->x - 2, $pl->y - 2);
708 777
709 for my $npc ( 778 for my $npc (
710 grep +($_->invoke (cf::EVENT_OBJECT_SAY, $who->contr, $msg) && return) || NPC_Dialogue::has_dialogue $_, 779 grep +($_->invoke (cf::EVENT_OBJECT_SAY, $pl->contr, $msg) && return) || NPC_Dialogue::has_dialogue $_,
711 map +($_, $_->inv), 780 map +($_, $_->inv),
712 grep $_, 781 grep $_,
713 map $map->at ($x + $_ % 5, $y + (int $_ / 5)), 782 map $map->at ($x + $_ % 5, $y + (int $_ / 5)),
714 0..24 783 0..24
715 ) { 784 ) {
716 # if some listener teleported us somewhere else, stop right here 785 # if some listener teleported us somewhere else, stop right here
717 last unless $map->path == $who->map->path; 786 last unless $map->path == $pl->map->path;
718 787
719 my $dialog = new NPC_Dialogue ob => $who, npc => $npc; 788 my $dialog = new NPC_Dialogue ob => $pl, npc => $npc;
720 my ($reply, @kw) = $dialog->tell ($msg); 789 my ($reply, @kw) = $dialog->tell ($msg);
721 790
722 if (defined $reply) { 791 if (defined $reply) {
723 if ($npc->type == cf::MAGIC_EAR) { 792 if ($npc->type == cf::MAGIC_EAR) {
724 if (length $reply) { 793 if (length $reply) {
725 $_->ob->message ($reply, cf::NDI_BROWN | cf::NDI_UNIQUE) 794 $_->ob->message ($reply, cf::NDI_BROWN | cf::NDI_UNIQUE)
726 for grep $who->on_same_map_as ($_->ob), cf::player::list; 795 for grep $pl->on_same_map_as ($_->ob), cf::player::list;
727 } 796 }
728 $npc->use_trigger; 797 $npc->use_trigger;
729 } else { 798 } else {
730 if (length $reply) { 799 if (length $reply) {
731 $_->ob->message ($npc->name . " says: $reply", cf::NDI_BROWN | cf::NDI_UNIQUE) 800 $_->ob->message ($npc->name . " says: $reply", cf::NDI_BROWN | cf::NDI_UNIQUE)
732 for grep $who->on_same_map_as ($_->ob), cf::player::list; 801 for grep $pl->on_same_map_as ($_->ob), cf::player::list;
733 } 802 }
734 } 803 }
735 } 804 }
736 805
737 if (@kw) { 806 if (@kw) {
738 $_->ob->message ("[further topics: " . (join ", ", @kw) . "]", cf::NDI_BROWN | cf::NDI_UNIQUE) 807 $_->ob->message ("[further topics: " . (join ", ", @kw) . "]", cf::NDI_BROWN | cf::NDI_UNIQUE)
739 for grep $who->on_same_map_as ($_->ob), cf::player::list; 808 for grep $pl->on_same_map_as ($_->ob), cf::player::list;
740 } 809 }
741 } 810 }
742 811
743 } else { 812 } else {
744 $who->message ("What do you want to say?", cf::NDI_UNIQUE); 813 $pl->message ("What do you want to say?", cf::NDI_UNIQUE);
745 }
746
747 1 814 }
748}; 815};
749 816
750cf::register_command chat => sub { 817cf::register_command chat => sub {
751 my ($who, $msg) = @_; 818 my ($pl, $msg) = @_;
752 819
753 utf8::decode $msg; 820 utf8::decode $msg;
754 821
755 return if $who->contr->invoke (cf::EVENT_PLAYER_CHAT, $msg); 822 return if $pl->contr->invoke (cf::EVENT_PLAYER_CHAT, $msg);
756 823
757 if ($msg) { 824 if ($msg) {
758 my $name = $who->name; 825 my $name = $pl->name;
759 my $NOW = time; 826 my $NOW = time;
760 827
761 utf8::encode $msg; # ->message not yet utf8-ified 828 utf8::encode $msg; # ->message not yet utf8-ified
762 cf::LOG cf::llevDebug, sprintf "QBERT [%s] %s\n", $name, $msg; 829 cf::LOG cf::llevDebug, sprintf "QBERT [%s] %s\n", $name, $msg;
763 ext::schmorp_irc::do_notice (sprintf "[%s] %s", $name, $msg); 830 ext::schmorp_irc::do_notice (sprintf "[%s] %s", $name, $msg);
764 831
765 $_->ob->message ("$name chats: $msg", cf::NDI_BLUE) 832 $_->ob->message ("$name chats: $msg", cf::NDI_BLUE)
766 for grep { $_->ob->{ext_ignore_shout}{$name} < $NOW && $_->listening >= 10 } cf::player::list; 833 for grep { $_->ob->{ext_ignore_shout}{$name} < $NOW && $_->listening >= 10 } cf::player::list;
767 834
768 } else { 835 } else {
769 $who->message ("Chat what?", cf::NDI_UNIQUE); 836 $pl->message ("Chat what?", cf::NDI_UNIQUE);
770 }
771
772 1 837 }
773}; 838};
774 839
775cf::register_command shout => sub { 840cf::register_command shout => sub {
776 my ($who, $msg) = @_; 841 my ($pl, $msg) = @_;
777 842
778 utf8::decode $msg; 843 utf8::decode $msg;
779 844
780 return if $who->contr->invoke (cf::EVENT_PLAYER_SHOUT, $msg); 845 return if $pl->contr->invoke (cf::EVENT_PLAYER_SHOUT, $msg);
781 846
782 if ($msg) { 847 if ($msg) {
783 my $NOW = time; 848 my $NOW = time;
784 my $name = $who->name; 849 my $name = $pl->name;
785 850
786 cf::LOG cf::llevDebug, sprintf "QBERT {%s} %s\n", $name, $msg; 851 cf::LOG cf::llevDebug, sprintf "QBERT {%s} %s\n", $name, $msg;
787 ext::schmorp_irc::do_notice (sprintf "\007\0034{%s} %s\n", $name, $msg); 852 ext::schmorp_irc::do_notice (sprintf "\007\0034{%s} %s\n", $name, $msg);
788 853
789 utf8::encode $msg; # ->message not yet utf8-ified 854 utf8::encode $msg; # ->message not yet utf8-ified
790 $_->ob->message ("$name shouts: $msg", cf::NDI_RED) 855 $_->ob->message ("$name shouts: $msg", cf::NDI_RED)
791 for grep { $_->ob->{ext_ignore_shout}{$name} < $NOW && $_->listening >= 2 } cf::player::list; 856 for grep { $_->ob->{ext_ignore_shout}{$name} < $NOW && $_->listening >= 2 } cf::player::list;
792 857
793 } else { 858 } else {
794 $who->message ("Shout what?", cf::NDI_UNIQUE); 859 $pl->message ("Shout what?", cf::NDI_UNIQUE);
795 }
796
797 1 860 }
798}; 861};
799 862
800cf::register_command tell => sub { 863cf::register_command tell => sub {
801 my ($who, $args) = @_; 864 my ($pl, $args) = @_;
802 my ($target, $msg) = split /\s+/, $args, 2; 865 my ($target, $msg) = split /\s+/, $args, 2;
803 866
804 utf8::decode $msg; 867 utf8::decode $msg;
805 868
806 return if $who->contr->invoke (cf::EVENT_PLAYER_TELL, $target, $msg); 869 return if $pl->contr->invoke (cf::EVENT_PLAYER_TELL, $target, $msg);
807 870
808 my $name = $who->name; 871 my $name = $pl->name;
809 872
810 if ($target =~ /irc\//) { 873 if ($target =~ /irc\//) {
811 my (undef, $nick) = split /\//, $target, 2; 874 my (undef, $nick) = split /\//, $target, 2;
812 $who->message ("You tell $target: $args"); 875 $pl->message ("You tell $target: $args");
813 ext::schmorp_irc::do_notice (sprintf "(%s) %s: %s\n", $name, $nick, $msg); 876 ext::schmorp_irc::do_notice (sprintf "(%s) %s: %s\n", $name, $nick, $msg);
814 } elsif (my $other = cf::player::find_active $target) { 877 } elsif (my $other = cf::player::find_active $target) {
815 878
816 if ($msg) { 879 if ($msg) {
817 if ($target eq $name) { 880 if ($target eq $name) {
818 $who->message ("You are talking to yourself, you freak!", cf::NDI_UNIQUE); 881 $pl->message ("You are talking to yourself, you freak!", cf::NDI_UNIQUE);
819 } elsif ($other->ob->{ext_ignore_tell}{$name} >= time) { 882 } elsif ($other->ob->{ext_ignore_tell}{$name} >= time) {
820 $who->message ("$target ignores what you say. Give up on it.", cf::NDI_UNIQUE); 883 $pl->message ("$target ignores what you say. Give up on it.", cf::NDI_UNIQUE);
821 } else { 884 } else {
885 return if $other->invoke (cf::EVENT_PLAYER_TOLD, $pl->contr, $msg);
822 utf8::encode $msg; # ->message not yet utf8-ified 886 utf8::encode $msg; # ->message not yet utf8-ified
823 cf::LOG cf::llevDebug, sprintf "TELL [%s>%s] %s\n", $name, $target, $msg; 887 cf::LOG cf::llevDebug, sprintf "TELL [%s>%s] %s\n", $name, $target, $msg;
824 888
825 $who->message ("You tell $target: $msg"); 889 $pl->message ("You tell $target: $msg");
826 $other->ob->message ("$name tells you: $msg"); 890 $other->ob->message ("$name tells you: $msg");
827 $other->ob->{ext_last_tell} = $name; 891 $other->ob->{ext_last_tell} = $name;
828 } 892 }
829 } else { 893 } else {
830 $who->message ("What do you want to tell $target?", cf::NDI_UNIQUE); 894 $pl->message ("What do you want to tell $target?", cf::NDI_UNIQUE);
831 } 895 }
832 896
833 } else { 897 } else {
834 $who->message ("No such player. Your message: $msg", cf::NDI_UNIQUE); 898 $pl->message ("No such player. Your message: $msg", cf::NDI_UNIQUE);
835 }
836
837 1 899 }
838}; 900};
839 901
840cf::register_command reply => sub { 902cf::register_command reply => sub {
841 my ($who, $args) = @_; 903 my ($pl, $args) = @_;
842 my $name = $who->name; 904 my $name = $pl->name;
843 905
844 utf8::decode $args; 906 utf8::decode $args;
845 907
846 return if $who->contr->invoke (cf::EVENT_PLAYER_TELL, $who->{ext_last_tell}, $args); 908 return if $pl->contr->invoke (cf::EVENT_PLAYER_TELL, $pl->{ext_last_tell}, $args);
847 909
848 if ($who->{ext_last_tell} =~ /irc\//) { 910 if ($pl->{ext_last_tell} =~ /irc\//) {
849 my (undef, $nick) = split /\//, $who->{ext_last_tell}, 2; 911 my (undef, $nick) = split /\//, $pl->{ext_last_tell}, 2;
850 $who->message ("You tell " . $who->{ext_last_tell} . ": $args"); 912 $pl->message ("You tell " . $pl->{ext_last_tell} . ": $args");
851 ext::schmorp_irc::do_notice (sprintf "(%s) %s: %s\n", $name, $nick, $args); 913 ext::schmorp_irc::do_notice (sprintf "(%s) %s: %s\n", $name, $nick, $args);
852 } elsif (my $other = cf::player::find_active $who->{ext_last_tell}) { 914 } elsif (my $other = cf::player::find_active $pl->{ext_last_tell}) {
853 915
854 if ($args) { 916 if ($args) {
855 $other->ob->{ext_ignore_tell}{$name} >= time 917 $other->ob->{ext_ignore_tell}{$name} >= time
856 or delete $other->ob->{ext_ignore_tell}{$name}; 918 or delete $other->ob->{ext_ignore_tell}{$name};
857 919
858 if ($other->ob->{ext_ignore_tell}{$name} < time) { 920 if ($other->ob->{ext_ignore_tell}{$name} < time) {
859 utf8::encode $args; # ->message not yet utf8-ified 921 utf8::encode $args; # ->message not yet utf8-ified
860 cf::LOG cf::llevDebug, sprintf "TELL [%s>%s] %s\n", $name, $other->ob->name, $args; 922 cf::LOG cf::llevDebug, sprintf "TELL [%s>%s] %s\n", $name, $other->ob->name, $args;
861 923
862 $who->message ("You tell " . $other->ob->name . ": $args"); 924 $pl->message ("You tell " . $other->ob->name . ": $args");
863 $other->ob->message ("$name tells you: $args"); 925 $other->ob->message ("$name tells you: $args");
864 $who->{ext_last_tell} = $other->ob->name; 926 $pl->{ext_last_tell} = $other->ob->name;
865 } else { 927 } else {
866 $who->message ($other->ob->name . " ignores what you say. Give up on it.", cf::NDI_UNIQUE); 928 $pl->message ($other->ob->name . " ignores what you say. Give up on it.", cf::NDI_UNIQUE);
867 } 929 }
868 } else { 930 } else {
869 $who->message ("What do you want to tell ".$other->ob->name."?", cf::NDI_UNIQUE); 931 $pl->message ("What do you want to tell ".$other->ob->name."?", cf::NDI_UNIQUE);
870 } 932 }
871 933
872 } else { 934 } else {
873 $who->message ("Can't reply, player left. Your message: $args".$who->{ext_last_tell}, cf::NDI_UNIQUE); 935 $pl->message ("Can't reply, player left. Your message: $args".$pl->{ext_last_tell}, cf::NDI_UNIQUE);
874 }
875
876 1 936 }
877}; 937};
878 938
879cf::register_command ignore => sub { 939cf::register_command ignore => sub {
880 my ($who, $args) = @_; 940 my ($pl, $args) = @_;
881 my ($target, $type, $timeout) = split /\s+/, $args; 941 my ($target, $type, $timeout) = split /\s+/, $args;
882 942
883 if ($args eq "list") { 943 if ($args eq "list") {
884 clean_timeouts $who; 944 clean_timeouts $pl;
885 945
886 if ((my @ignored_tell = sort keys %{$who->{ext_ignore_tell}}) 946 if ((my @ignored_tell = sort keys %{$pl->{ext_ignore_tell}})
887 + (my @ignored_shout = sort keys %{$who->{ext_ignore_shout}})) { 947 + (my @ignored_shout = sort keys %{$pl->{ext_ignore_shout}})) {
888 $who->message ("Currently ignoring private messages from: ", cf::NDI_UNIQUE); 948 $pl->message ("Currently ignoring private messages from: ", cf::NDI_UNIQUE);
889 $who->message ((join ", ", @ignored_tell), cf::NDI_UNIQUE); 949 $pl->message ((join ", ", @ignored_tell), cf::NDI_UNIQUE);
890 $who->message ("Currently ignoring shouts from: ", cf::NDI_UNIQUE); 950 $pl->message ("Currently ignoring shouts from: ", cf::NDI_UNIQUE);
891 $who->message ((join ", ", @ignored_shout), cf::NDI_UNIQUE); 951 $pl->message ((join ", ", @ignored_shout), cf::NDI_UNIQUE);
892 $who->message ("To stop ignoring one, use unignore.", cf::NDI_UNIQUE); 952 $pl->message ("To stop ignoring one, use unignore.", cf::NDI_UNIQUE);
893 } else { 953 } else {
894 $who->message ("Not ignoring anyone", cf::NDI_UNIQUE); 954 $pl->message ("Not ignoring anyone", cf::NDI_UNIQUE);
895 } 955 }
896 956
897 } elsif ($target && $type) { 957 } elsif ($target && $type) {
898 958
899 $timeout ne "" or $timeout = 24; 959 $timeout ne "" or $timeout = 24;
900 my $absolute_timeout = time + $timeout * 3600; 960 my $absolute_timeout = time + $timeout * 3600;
901 961
902 if (cf::player::exists $target) { 962 if (cf::player::exists $target) {
903 if ($type eq "tell") { 963 if ($type eq "tell") {
904 $who->message ("Now ignoring private messages from $target for $timeout hours.", cf::NDI_UNIQUE); 964 $pl->message ("Now ignoring private messages from $target for $timeout hours.", cf::NDI_UNIQUE);
905 $who->{ext_ignore_tell}{$target} = $absolute_timeout; 965 $pl->{ext_ignore_tell}{$target} = $absolute_timeout;
906 } elsif ($type eq "shout") { 966 } elsif ($type eq "shout") {
907 $who->message ("Now ignoring shouts from $target for $timeout hours.", cf::NDI_UNIQUE); 967 $pl->message ("Now ignoring shouts from $target for $timeout hours.", cf::NDI_UNIQUE);
908 $who->{ext_ignore_shout}{$target} = $absolute_timeout; 968 $pl->{ext_ignore_shout}{$target} = $absolute_timeout;
909 } elsif ($type eq "all") { 969 } elsif ($type eq "all") {
910 $who->message ("Now ignoring everything from $target for $timeout hours.", cf::NDI_UNIQUE); 970 $pl->message ("Now ignoring everything from $target for $timeout hours.", cf::NDI_UNIQUE);
911 $who->{ext_ignore_tell}{$target} = $absolute_timeout; 971 $pl->{ext_ignore_tell}{$target} = $absolute_timeout;
912 $who->{ext_ignore_shout}{$target} = $absolute_timeout; 972 $pl->{ext_ignore_shout}{$target} = $absolute_timeout;
913 } else { 973 } else {
914 $who->message ("You need to specify tell, shout or all.", cf::NDI_UNIQUE); 974 $pl->message ("You need to specify tell, shout or all.", cf::NDI_UNIQUE);
915 } 975 }
916 } else { 976 } else {
917 $who->message ("No such player: $target", cf::NDI_UNIQUE); 977 $pl->message ("No such player: $target", cf::NDI_UNIQUE);
918 } 978 }
919 979
920 } else { 980 } else {
921 $who->message ("Usage: ignore <player> <tell|shout|all> <timeout>\n" 981 $pl->message ("Usage: ignore <player> <tell|shout|all> <timeout>\n"
922 . "will ignore a player for <timeout> hours.\n" 982 . "will ignore a player for <timeout> hours.\n"
923 . "Usage: ignore list\n" 983 . "Usage: ignore list\n"
924 . "will show you a list of players currently ignored.", cf::NDI_UNIQUE); 984 . "will show you a list of players currently ignored.", cf::NDI_UNIQUE);
925 } 985 }
926
927 1
928}; 986};
929 987
930cf::register_command unignore => sub { 988cf::register_command unignore => sub {
931 my ($who, $args) = @_; 989 my ($pl, $args) = @_;
932 my ($target, $type) = split /\s+/, $args; 990 my ($target, $type) = split /\s+/, $args;
933 991
934 if ($args eq "") { 992 if ($args eq "") {
935 if ($who->{ext_ignore_tell}) { 993 if ($pl->{ext_ignore_tell}) {
936 $who->message ("Currently ignoring private messages from: ", cf::NDI_UNIQUE); 994 $pl->message ("Currently ignoring private messages from: ", cf::NDI_UNIQUE);
937 $who->message ((join ", ", sort keys %{ $who->{ext_ignore_tell} }), cf::NDI_UNIQUE); 995 $pl->message ((join ", ", sort keys %{ $pl->{ext_ignore_tell} }), cf::NDI_UNIQUE);
938 $who->message ("Currently ignoring shouts from: ", cf::NDI_UNIQUE); 996 $pl->message ("Currently ignoring shouts from: ", cf::NDI_UNIQUE);
939 $who->message ((join ", ", sort keys %{ $who->{ext_ignore_shout} }), cf::NDI_UNIQUE); 997 $pl->message ((join ", ", sort keys %{ $pl->{ext_ignore_shout} }), cf::NDI_UNIQUE);
940 } else { 998 } else {
941 $who->message ("Not ignoring anyone", cf::NDI_UNIQUE); 999 $pl->message ("Not ignoring anyone", cf::NDI_UNIQUE);
942 } 1000 }
943 } else { 1001 } else {
944 if (cf::player::exists $target) { 1002 if (cf::player::exists $target) {
945 if ($type eq "tell") { 1003 if ($type eq "tell") {
946 $who->message ("Not ignoring private messages from $target anymore.", cf::NDI_UNIQUE); 1004 $pl->message ("Not ignoring private messages from $target anymore.", cf::NDI_UNIQUE);
947 delete $who->{ext_ignore_tell} {$target}; 1005 delete $pl->{ext_ignore_tell} {$target};
948 } elsif ($type eq "shout") { 1006 } elsif ($type eq "shout") {
949 $who->message ("Not ignoring shouts from $target anymore.", cf::NDI_UNIQUE); 1007 $pl->message ("Not ignoring shouts from $target anymore.", cf::NDI_UNIQUE);
950 delete $who->{ext_ignore_shout}{$target}; 1008 delete $pl->{ext_ignore_shout}{$target};
951 } elsif ($type eq "all") { 1009 } elsif ($type eq "all") {
952 $who->message ("Not ignoring anything from $target anymore.", cf::NDI_UNIQUE); 1010 $pl->message ("Not ignoring anything from $target anymore.", cf::NDI_UNIQUE);
953 delete $who->{ext_ignore_tell} {$target}; 1011 delete $pl->{ext_ignore_tell} {$target};
954 delete $who->{ext_ignore_shout}{$target}; 1012 delete $pl->{ext_ignore_shout}{$target};
955 } else { 1013 } else {
956 $who->message ("You need to specify tell, shout or all.", cf::NDI_UNIQUE); 1014 $pl->message ("You need to specify tell, shout or all.", cf::NDI_UNIQUE);
957 } 1015 }
958 } else { 1016 } else {
959 $who->message ("No such player or ambiguous name: $target", cf::NDI_UNIQUE); 1017 $pl->message ("No such player or ambiguous name: $target", cf::NDI_UNIQUE);
960 } 1018 }
961 }
962
963 1 1019 }
964}; 1020};
965 1021
966cf::register_command seen => sub { 1022cf::register_command seen => sub {
967 my ($who, $args) = @_; 1023 my ($pl, $args) = @_;
968 1024
969 if (my ($login) = $args =~ /(\S+)/) { 1025 if (my ($login) = $args =~ /(\S+)/) {
970 if ($login eq $who->name) { 1026 if ($login eq $pl->name) {
971 $who->message ("Very funny, $login. Ha. Ha.", cf::NDI_UNIQUE); 1027 $pl->message ("Very funny, $login. Ha. Ha.", cf::NDI_UNIQUE);
972 } elsif (cf::player::find_active $login) { 1028 } elsif (cf::player::find_active $login) {
973 $who->message ("$login is right here on this server!", cf::NDI_UNIQUE); 1029 $pl->message ("$login is right here on this server!", cf::NDI_UNIQUE);
974 } elsif (cf::player::exists $login 1030 } elsif (cf::player::exists $login
975 and stat sprintf "%s/%s/%s/%s.pl", cf::localdir, cf::playerdir, ($login) x 2) { 1031 and stat sprintf "%s/%s/%s/%s.pl", cf::localdir, cf::playerdir, ($login) x 2) {
976 my $time = (stat _)[9]; 1032 my $time = (stat _)[9];
977 1033
978 $who->message ("$login was last seen here " 1034 $pl->message ("$login was last seen here "
979 . (POSIX::strftime "%Y-%m-%d %H:%M:%S +0000", gmtime $time) 1035 . (POSIX::strftime "%Y-%m-%d %H:%M:%S +0000", gmtime $time)
980 . " which was " . (int +(time - $time) / 3600) . " hours ago.", cf::NDI_UNIQUE); 1036 . " which was " . (int +(time - $time) / 3600) . " hours ago.", cf::NDI_UNIQUE);
981 } else { 1037 } else {
982 $who->message ("No player named $login is known to me.", cf::NDI_UNIQUE); 1038 $pl->message ("No player named $login is known to me.", cf::NDI_UNIQUE);
983 } 1039 }
984 } else { 1040 } else {
985 $who->message ("Usage: seen <player>", cf::NDI_UNIQUE); 1041 $pl->message ("Usage: seen <player>", cf::NDI_UNIQUE);
986 }
987
988 1 1042 }
989}; 1043};
990 1044

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines