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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines