… | |
… | |
36 | cf::register_command listen => sub { |
36 | cf::register_command listen => sub { |
37 | my ($pl, $msg) = @_; |
37 | my ($pl, $msg) = @_; |
38 | my $player = cf::player::find_active $pl->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 | $pl->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 { |
… | |
… | |
72 | |
74 | |
73 | $pl->message ("You flip a coin.... Tails!", cf::NDI_GREY | cf::NDI_UNIQUE); |
75 | $pl->message ("You flip a coin.... Tails!", cf::NDI_GREY | cf::NDI_UNIQUE); |
74 | } |
76 | } |
75 | }; |
77 | }; |
76 | |
78 | |
|
|
79 | cf::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 | |
77 | my $emotes = { |
97 | my $emotes = { |
78 | growl => { |
98 | growl => { |
79 | noparams => { |
99 | noparams => { |
80 | other => "<self> growls.", |
100 | other => "<self> growls.", |
81 | self => "Grrrrrrrrr....", |
101 | self => "Grrrrrrrrr....", |
… | |
… | |
209 | noparams => { |
229 | noparams => { |
210 | other => "<self> winks suggestively.", |
230 | other => "<self> winks suggestively.", |
211 | self => "Have you got something in your eye?", |
231 | self => "Have you got something in your eye?", |
212 | }, |
232 | }, |
213 | params => { |
233 | params => { |
|
|
234 | target => "<self> winks at you.", |
214 | target => "<self> winks at <other>.", |
235 | other => "<self> winks at <other>.", |
215 | self => "You wink suggestively at <other>.", |
236 | self => "You wink suggestively at <other>.", |
216 | }, |
237 | }, |
217 | self => { |
238 | self => { |
218 | other => "<self> winks at himself - something strange is going on...", |
239 | other => "<self> winks at himself - something strange is going on...", |
219 | self => "You wink at yourself?? What are you up to?", |
240 | self => "You wink at yourself?? What are you up to?", |
… | |
… | |
309 | noparams => { |
330 | noparams => { |
310 | 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?", |
311 | self => "You bleed all over your nice new armour.", |
332 | self => "You bleed all over your nice new armour.", |
312 | }, |
333 | }, |
313 | params => { |
334 | params => { |
|
|
335 | target => "<self> slashes his wrist and bleeds all over you.", |
314 | target => "<self> slashes his wrist and bleeds all over <other>.", |
336 | other => "<self> slashes his wrist and bleeds all over <other>.", |
315 | self => "You slash your wrist and bleed all over <other>", |
337 | self => "You slash your wrist and bleed all over <other>", |
316 | }, |
338 | }, |
317 | self => { |
339 | self => { |
318 | 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.", |
319 | self => "Very impressive! You wipe your blood all over yourself.", |
341 | self => "Very impressive! You wipe your blood all over yourself.", |
… | |
… | |
742 | return if $pl->contr->invoke (cf::EVENT_PLAYER_SAY, $msg); |
764 | return if $pl->contr->invoke (cf::EVENT_PLAYER_SAY, $msg); |
743 | |
765 | |
744 | if ($msg) { |
766 | if ($msg) { |
745 | my $name = $pl->name; |
767 | my $name = $pl->name; |
746 | |
768 | |
747 | utf8::encode $msg; # ->message not yet utf8-ified |
|
|
748 | $_->ob->message ("$name says: $msg", cf::NDI_GREY | cf::NDI_UNIQUE) |
769 | $_->ob->message ("$name says: $msg", cf::NDI_GREY | cf::NDI_UNIQUE) |
749 | for grep $pl->on_same_map_as ($_->ob), cf::player::list; |
770 | for grep $pl->on_same_map_as ($_->ob), cf::player::list; |
750 | utf8::decode $msg; |
|
|
751 | |
771 | |
752 | # npcs, magic_ears etc. |
772 | # npcs, magic_ears etc. |
753 | # first find all objects and theirt-level inventories |
773 | # first find all objects and their first-level inventories |
754 | # within a 5x5 square # that have something resembling |
774 | # within a 5x5 square that have something resembling |
755 | # dialogue or support on_say. |
775 | # dialogue or support on_say. |
756 | my ($map, $x, $y) = ($pl->map, $pl->x - 2, $pl->y - 2); |
776 | my ($map, $x, $y) = ($pl->map, $pl->x - 2, $pl->y - 2); |
757 | |
777 | |
758 | for my $npc ( |
778 | for my $npc ( |
759 | grep +($_->invoke (cf::EVENT_OBJECT_SAY, $pl->contr, $msg) && return) || NPC_Dialogue::has_dialogue $_, |
779 | grep +($_->invoke (cf::EVENT_OBJECT_SAY, $pl->contr, $msg) && return) || NPC_Dialogue::has_dialogue $_, |
… | |
… | |
803 | |
823 | |
804 | if ($msg) { |
824 | if ($msg) { |
805 | my $name = $pl->name; |
825 | my $name = $pl->name; |
806 | my $NOW = time; |
826 | my $NOW = time; |
807 | |
827 | |
808 | utf8::encode $msg; # ->message not yet utf8-ified |
|
|
809 | cf::LOG cf::llevDebug, sprintf "QBERT [%s] %s\n", $name, $msg; |
828 | cf::LOG cf::llevDebug, sprintf "QBERT [%s] %s\n", $name, $msg; |
810 | ext::schmorp_irc::do_notice (sprintf "[%s] %s", $name, $msg); |
829 | ext::irc::do_notice (sprintf "[%s] %s", $name, $msg); |
811 | |
830 | |
812 | $_->ob->message ("$name chats: $msg", cf::NDI_BLUE) |
831 | $_->ob->message ("$name chats: $msg", cf::NDI_BLUE) |
813 | 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; |
814 | |
833 | |
815 | } else { |
834 | } else { |
… | |
… | |
827 | if ($msg) { |
846 | if ($msg) { |
828 | my $NOW = time; |
847 | my $NOW = time; |
829 | my $name = $pl->name; |
848 | my $name = $pl->name; |
830 | |
849 | |
831 | cf::LOG cf::llevDebug, sprintf "QBERT {%s} %s\n", $name, $msg; |
850 | cf::LOG cf::llevDebug, sprintf "QBERT {%s} %s\n", $name, $msg; |
832 | 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); |
833 | |
852 | |
834 | utf8::encode $msg; # ->message not yet utf8-ified |
|
|
835 | $_->ob->message ("$name shouts: $msg", cf::NDI_RED) |
853 | $_->ob->message ("$name shouts: $msg", cf::NDI_RED) |
836 | 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; |
837 | |
855 | |
838 | } else { |
856 | } else { |
839 | $pl->message ("Shout what?", cf::NDI_UNIQUE); |
857 | $pl->message ("Shout what?", cf::NDI_UNIQUE); |
… | |
… | |
851 | my $name = $pl->name; |
869 | my $name = $pl->name; |
852 | |
870 | |
853 | if ($target =~ /irc\//) { |
871 | if ($target =~ /irc\//) { |
854 | my (undef, $nick) = split /\//, $target, 2; |
872 | my (undef, $nick) = split /\//, $target, 2; |
855 | $pl->message ("You tell $target: $args"); |
873 | $pl->message ("You tell $target: $args"); |
856 | 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); |
857 | } elsif (my $other = cf::player::find_active $target) { |
875 | } elsif (my $other = cf::player::find_active $target) { |
858 | |
876 | |
859 | if ($msg) { |
877 | if ($msg) { |
860 | if ($target eq $name) { |
878 | if ($target eq $name) { |
861 | $pl->message ("You are talking to yourself, you freak!", cf::NDI_UNIQUE); |
879 | $pl->message ("You are talking to yourself, you freak!", cf::NDI_UNIQUE); |
862 | } elsif ($other->ob->{ext_ignore_tell}{$name} >= time) { |
880 | } elsif ($other->ob->{ext_ignore_tell}{$name} >= time) { |
863 | $pl->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); |
864 | } else { |
882 | } else { |
865 | utf8::encode $msg; # ->message not yet utf8-ified |
883 | return if $other->invoke (cf::EVENT_PLAYER_TOLD, $pl->contr, $msg); |
866 | 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; |
867 | |
885 | |
868 | $pl->message ("You tell $target: $msg"); |
886 | $pl->message ("You tell $target: $msg"); |
869 | $other->ob->message ("$name tells you: $msg"); |
887 | $other->ob->message ("$name tells you: $msg"); |
870 | $other->ob->{ext_last_tell} = $name; |
888 | $other->ob->{ext_last_tell} = $name; |
… | |
… | |
887 | return if $pl->contr->invoke (cf::EVENT_PLAYER_TELL, $pl->{ext_last_tell}, $args); |
905 | return if $pl->contr->invoke (cf::EVENT_PLAYER_TELL, $pl->{ext_last_tell}, $args); |
888 | |
906 | |
889 | if ($pl->{ext_last_tell} =~ /irc\//) { |
907 | if ($pl->{ext_last_tell} =~ /irc\//) { |
890 | my (undef, $nick) = split /\//, $pl->{ext_last_tell}, 2; |
908 | my (undef, $nick) = split /\//, $pl->{ext_last_tell}, 2; |
891 | $pl->message ("You tell " . $pl->{ext_last_tell} . ": $args"); |
909 | $pl->message ("You tell " . $pl->{ext_last_tell} . ": $args"); |
892 | 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); |
893 | } elsif (my $other = cf::player::find_active $pl->{ext_last_tell}) { |
911 | } elsif (my $other = cf::player::find_active $pl->{ext_last_tell}) { |
894 | |
912 | |
895 | if ($args) { |
913 | if ($args) { |
896 | $other->ob->{ext_ignore_tell}{$name} >= time |
914 | $other->ob->{ext_ignore_tell}{$name} >= time |
897 | or delete $other->ob->{ext_ignore_tell}{$name}; |
915 | or delete $other->ob->{ext_ignore_tell}{$name}; |
898 | |
916 | |
899 | if ($other->ob->{ext_ignore_tell}{$name} < time) { |
917 | if ($other->ob->{ext_ignore_tell}{$name} < time) { |
900 | utf8::encode $args; # ->message not yet utf8-ified |
|
|
901 | 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; |
902 | |
919 | |
903 | $pl->message ("You tell " . $other->ob->name . ": $args"); |
920 | $pl->message ("You tell " . $other->ob->name . ": $args"); |
904 | $other->ob->message ("$name tells you: $args"); |
921 | $other->ob->message ("$name tells you: $args"); |
905 | $pl->{ext_last_tell} = $other->ob->name; |
922 | $pl->{ext_last_tell} = $other->ob->name; |
… | |
… | |
996 | $pl->message ("No such player or ambiguous name: $target", cf::NDI_UNIQUE); |
1013 | $pl->message ("No such player or ambiguous name: $target", cf::NDI_UNIQUE); |
997 | } |
1014 | } |
998 | } |
1015 | } |
999 | }; |
1016 | }; |
1000 | |
1017 | |
1001 | cf::register_command seen => sub { |
|
|
1002 | my ($pl, $args) = @_; |
|
|
1003 | |
|
|
1004 | if (my ($login) = $args =~ /(\S+)/) { |
|
|
1005 | if ($login eq $pl->name) { |
|
|
1006 | $pl->message ("Very funny, $login. Ha. Ha.", cf::NDI_UNIQUE); |
|
|
1007 | } elsif (cf::player::find_active $login) { |
|
|
1008 | $pl->message ("$login is right here on this server!", cf::NDI_UNIQUE); |
|
|
1009 | } elsif (cf::player::exists $login |
|
|
1010 | and stat sprintf "%s/%s/%s/%s.pl", cf::localdir, cf::playerdir, ($login) x 2) { |
|
|
1011 | my $time = (stat _)[9]; |
|
|
1012 | |
|
|
1013 | $pl->message ("$login was last seen here " |
|
|
1014 | . (POSIX::strftime "%Y-%m-%d %H:%M:%S +0000", gmtime $time) |
|
|
1015 | . " which was " . (int +(time - $time) / 3600) . " hours ago.", cf::NDI_UNIQUE); |
|
|
1016 | } else { |
|
|
1017 | $pl->message ("No player named $login is known to me.", cf::NDI_UNIQUE); |
|
|
1018 | } |
|
|
1019 | } else { |
|
|
1020 | $pl->message ("Usage: seen <player>", cf::NDI_UNIQUE); |
|
|
1021 | } |
|
|
1022 | }; |
|
|
1023 | |
|
|