… | |
… | |
54 | cf::player->attach ( |
54 | cf::player->attach ( |
55 | prio => -1000, |
55 | prio => -1000, |
56 | on_login => sub { |
56 | on_login => sub { |
57 | my ($pl) = @_; |
57 | my ($pl) = @_; |
58 | |
58 | |
|
|
59 | cf::async { |
59 | clean_timeouts $pl->ob; |
60 | clean_timeouts $pl->ob; |
|
|
61 | }; |
60 | |
62 | |
61 | $pl->send_msg ($cf::SAY_CHANNEL); |
63 | $pl->send_msg ($cf::SAY_CHANNEL); |
62 | $pl->send_msg ($cf::CHAT_CHANNEL); |
64 | $pl->send_msg ($cf::CHAT_CHANNEL); |
63 | }, |
65 | }, |
64 | ); |
66 | ); |
… | |
… | |
216 | }, |
218 | }, |
217 | }, |
219 | }, |
218 | kiss => { |
220 | kiss => { |
219 | noparams => { |
221 | noparams => { |
220 | other => "<self> makes a weird facial contortion", |
222 | other => "<self> makes a weird facial contortion", |
221 | self => "All the lonely people..", |
223 | self => "All the lonely people...", |
222 | }, |
224 | }, |
223 | params => { |
225 | params => { |
224 | target => "<self> kisses you.", |
226 | target => "<self> kisses you.", |
225 | other => "<self> kisses <other>.", |
227 | other => "<self> kisses <other>.", |
226 | self => "You kiss <other>.", |
228 | self => "You kiss <other>.", |
227 | }, |
229 | }, |
228 | self => { |
230 | self => { |
229 | }, |
231 | }, |
230 | }, |
232 | }, |
|
|
233 | hug => { |
|
|
234 | noparams => { |
|
|
235 | other => "<self> makes weird body movements.", |
|
|
236 | self => "All the lonely people...", |
|
|
237 | }, |
|
|
238 | params => { |
|
|
239 | target => "<self> suddenly grabs you and gives you a bear hug.", |
|
|
240 | other => "<self> hugs <other>.", |
|
|
241 | self => "You hug <other>.", |
|
|
242 | }, |
|
|
243 | self => { |
|
|
244 | other => "<self> tries to hug G<himself|herself>, but stumbles and now feels stupid.", |
|
|
245 | self => "You try and fail to hug yourself.", |
|
|
246 | }, |
|
|
247 | }, |
231 | smother => { |
248 | smother => { |
232 | noparams => { |
249 | noparams => { |
233 | other => "<self> makes weird facial contortions", |
250 | other => "<self> makes weird facial contortions", |
234 | self => "All the lonely people..", |
251 | self => "All the lonely people...", |
235 | }, |
252 | }, |
236 | params => { |
253 | params => { |
237 | target => "<self> smothers you with kisses.", |
254 | target => "<self> smothers you with kisses.", |
238 | other => "<self> smothers <other> with kisses.", |
255 | other => "<self> smothers <other> with kisses.", |
239 | self => "You smother <other> with kisses.", |
256 | self => "You smother <other> with kisses.", |
… | |
… | |
757 | $pl->send_msg ($cf::CHAT_CHANNEL, $emote{self}, cf::NDI_GREY | cf::NDI_REPLY | cf::NDI_VERBATIM); |
774 | $pl->send_msg ($cf::CHAT_CHANNEL, $emote{self}, cf::NDI_GREY | cf::NDI_REPLY | cf::NDI_VERBATIM); |
758 | } |
775 | } |
759 | }; |
776 | }; |
760 | }; |
777 | }; |
761 | } |
778 | } |
762 | |
|
|
763 | cf::register_command me => sub { |
|
|
764 | my ($pl, $msg) = @_; |
|
|
765 | |
|
|
766 | my $name = $pl->name; |
|
|
767 | |
|
|
768 | send_msg $_, $cf::SAY_CHANNEL => "* $name $msg", cf::NDI_GREY | cf::NDI_DEF | ($_ == $pl ? cf::NDI_REPLY : 0), "msg_say" |
|
|
769 | for grep $pl->on_same_map_as ($_->ob), cf::player::list; |
|
|
770 | }; |
|
|
771 | |
779 | |
772 | cf::register_command say => sub { |
780 | cf::register_command say => sub { |
773 | my ($ob, $msg) = @_; |
781 | my ($ob, $msg) = @_; |
774 | |
782 | |
775 | utf8::decode $msg; |
783 | utf8::decode $msg; |
… | |
… | |
803 | my $dialog = new NPC_Dialogue pl => $ob->contr, npc => $npc; |
811 | my $dialog = new NPC_Dialogue pl => $ob->contr, npc => $npc; |
804 | my ($reply, @kw) = $dialog->tell ($msg); |
812 | my ($reply, @kw) = $dialog->tell ($msg); |
805 | |
813 | |
806 | if (defined $reply) { |
814 | if (defined $reply) { |
807 | if ($npc->type == cf::MAGIC_EAR) { |
815 | if ($npc->type == cf::MAGIC_EAR) { |
808 | if (length $reply) { |
|
|
809 | send_msg $_, $cf::SAY_CHANNEL => $reply, cf::NDI_BROWN, "msg_say" |
816 | send_msg $_, $cf::SAY_CHANNEL => $reply, cf::NDI_BROWN, "msg_say" |
810 | for @plonmap; |
817 | for @plonmap; |
811 | } |
|
|
812 | $npc->use_trigger; |
|
|
813 | } else { |
818 | } else { |
814 | if (length $reply) { |
|
|
815 | send_msg $_, $cf::SAY_CHANNEL => $npc->name . " says: $reply", cf::NDI_BROWN, "msg_say" |
819 | send_msg $_, $cf::SAY_CHANNEL => $npc->name . " says: $reply", cf::NDI_BROWN, "msg_say" |
816 | for @plonmap; |
820 | for @plonmap; |
817 | } |
|
|
818 | } |
821 | } |
819 | } |
822 | } |
820 | |
823 | |
821 | if (@kw) { |
824 | if (@kw) { |
822 | $_->send_msg ($cf::SAY_CHANNEL => "[further topics: " . (join ", ", @kw) . "]", cf::NDI_BROWN) |
825 | $_->send_msg ($cf::SAY_CHANNEL => "[further topics: " . (join ", ", @kw) . "]", cf::NDI_BROWN) |
… | |
… | |
827 | } else { |
830 | } else { |
828 | $ob->send_msg ($cf::SAY_CHANNEL => "What do you want to say?", cf::NDI_GREY | cf::NDI_REPLY); |
831 | $ob->send_msg ($cf::SAY_CHANNEL => "What do you want to say?", cf::NDI_GREY | cf::NDI_REPLY); |
829 | } |
832 | } |
830 | }; |
833 | }; |
831 | |
834 | |
832 | cf::register_command chat => sub { |
835 | |
|
|
836 | sub _chat { |
833 | my ($ob, $msg) = @_; |
837 | my ($ob, $msg) = @_; |
834 | |
|
|
835 | utf8::decode $msg; |
|
|
836 | |
838 | |
837 | my $pl = $ob->contr; |
839 | my $pl = $ob->contr; |
838 | |
840 | |
839 | return if $pl->invoke (cf::EVENT_PLAYER_CHAT, $msg); |
841 | return if $pl->invoke (cf::EVENT_PLAYER_CHAT, $msg); |
840 | |
842 | |
841 | if ($msg) { |
843 | if ($msg) { |
842 | my $name = $ob->name; |
844 | my $name = $ob->name; |
843 | my $NOW = time; |
845 | my $NOW = time; |
844 | |
846 | |
845 | cf::LOG cf::llevDebug, sprintf "QBERT [%s] %s\n", $name, $msg; |
847 | cf::LOG cf::llevDebug, sprintf "QBERT %s\n", $msg; |
846 | send_irc ("[%s] %s", $name, $msg); |
848 | send_irc ("%s", $msg); |
847 | |
849 | |
848 | send_msg $_, $cf::CHAT_CHANNEL => "$name chats: $msg", cf::NDI_BLUE | cf::NDI_DEF | ($_ == $pl ? cf::NDI_REPLY : 0), "msg_chat" |
850 | send_msg $_, $cf::CHAT_CHANNEL => $msg, cf::NDI_BLUE | cf::NDI_DEF | ($_ == $pl ? cf::NDI_REPLY : 0), "msg_chat" |
849 | for grep { $_->ob->{ext_ignore_shout}{$name} < $NOW } cf::player::list; |
851 | for grep { $_->ob->{ext_ignore_shout}{$name} < $NOW } cf::player::list; |
850 | |
852 | |
851 | } else { |
853 | } else { |
852 | $pl->send_msg ($cf::CHAT_CHANNEL => "Chat what?", cf::NDI_BLUE | cf::NDI_DEF | cf::NDI_REPLY); |
854 | $pl->send_msg ($cf::CHAT_CHANNEL => "Chat what?", cf::NDI_BLUE | cf::NDI_DEF | cf::NDI_REPLY); |
853 | } |
855 | } |
|
|
856 | } |
|
|
857 | |
|
|
858 | cf::register_command chat => sub { |
|
|
859 | my ($ob, $msg) = @_; |
|
|
860 | |
|
|
861 | utf8::decode $msg; |
|
|
862 | _chat $ob, $ob->name . " chats: $msg"; |
|
|
863 | }; |
|
|
864 | |
|
|
865 | cf::register_command me => sub { |
|
|
866 | my ($ob, $msg) = @_; |
|
|
867 | |
|
|
868 | utf8::decode $msg; |
|
|
869 | _chat $ob, "* " . $ob->name . " $msg"; |
854 | }; |
870 | }; |
855 | |
871 | |
856 | cf::register_command shout => sub { |
872 | cf::register_command shout => sub { |
857 | my ($ob, $msg) = @_; |
873 | my ($ob, $msg) = @_; |
858 | |
874 | |
… | |
… | |
923 | |
939 | |
924 | cf::register_command ignore => sub { |
940 | cf::register_command ignore => sub { |
925 | my ($pl, $args) = @_; |
941 | my ($pl, $args) = @_; |
926 | my ($target, $type, $timeout) = split /\s+/, $args; |
942 | my ($target, $type, $timeout) = split /\s+/, $args; |
927 | |
943 | |
|
|
944 | cf::async { |
928 | if ($args eq "list") { |
945 | if ($args eq "list") { |
929 | clean_timeouts $pl; |
946 | clean_timeouts $pl; |
930 | |
947 | |
931 | if ((my @ignored_tell = sort keys %{$pl->{ext_ignore_tell}}) |
948 | if ((my @ignored_tell = sort keys %{$pl->{ext_ignore_tell}}) |
932 | + (my @ignored_shout = sort keys %{$pl->{ext_ignore_shout}})) { |
949 | + (my @ignored_shout = sort keys %{$pl->{ext_ignore_shout}})) { |
933 | $pl->message ("Currently ignoring private messages from: ", cf::NDI_REPLY); |
950 | $pl->message ("Currently ignoring private messages from: ", cf::NDI_REPLY); |
934 | $pl->message ((join ", ", @ignored_tell), cf::NDI_REPLY); |
951 | $pl->message ((join ", ", @ignored_tell), cf::NDI_REPLY); |
935 | $pl->message ("Currently ignoring shouts from: ", cf::NDI_REPLY); |
952 | $pl->message ("Currently ignoring shouts from: ", cf::NDI_REPLY); |
936 | $pl->message ((join ", ", @ignored_shout), cf::NDI_REPLY); |
953 | $pl->message ((join ", ", @ignored_shout), cf::NDI_REPLY); |
937 | $pl->message ("To stop ignoring one, use unignore.", cf::NDI_REPLY); |
954 | $pl->message ("To stop ignoring one, use unignore.", cf::NDI_REPLY); |
|
|
955 | } else { |
|
|
956 | $pl->message ("Not ignoring anyone", cf::NDI_REPLY); |
|
|
957 | } |
|
|
958 | |
|
|
959 | } elsif ($target && $type) { |
|
|
960 | $timeout ne "" or $timeout = 24; |
|
|
961 | my $absolute_timeout = time + $timeout * 3600; |
|
|
962 | |
|
|
963 | if (cf::player::exists $target) { |
|
|
964 | if ($type eq "tell") { |
|
|
965 | $pl->message ("Now ignoring private messages from $target for $timeout hours.", cf::NDI_REPLY); |
|
|
966 | $pl->{ext_ignore_tell}{$target} = $absolute_timeout; |
|
|
967 | } elsif ($type eq "shout") { |
|
|
968 | $pl->message ("Now ignoring shouts from $target for $timeout hours.", cf::NDI_REPLY); |
|
|
969 | $pl->{ext_ignore_shout}{$target} = $absolute_timeout; |
|
|
970 | } elsif ($type eq "all") { |
|
|
971 | $pl->message ("Now ignoring everything from $target for $timeout hours.", cf::NDI_REPLY); |
|
|
972 | $pl->{ext_ignore_tell}{$target} = $absolute_timeout; |
|
|
973 | $pl->{ext_ignore_shout}{$target} = $absolute_timeout; |
|
|
974 | } else { |
|
|
975 | $pl->message ("You need to specify tell, shout or all.", cf::NDI_REPLY); |
|
|
976 | } |
|
|
977 | } else { |
|
|
978 | $pl->message ("No such player: $target", cf::NDI_REPLY); |
|
|
979 | } |
|
|
980 | |
938 | } else { |
981 | } else { |
939 | $pl->message ("Not ignoring anyone", cf::NDI_REPLY); |
982 | $pl->message ("Usage: ignore <player> <tell|shout|all> <timeout>\n" |
|
|
983 | . "will ignore a player for <timeout> hours.\n" |
|
|
984 | . "Usage: ignore list\n" |
|
|
985 | . "will show you a list of players currently ignored.", cf::NDI_REPLY); |
940 | } |
986 | } |
941 | |
|
|
942 | } elsif ($target && $type) { |
|
|
943 | |
|
|
944 | $timeout ne "" or $timeout = 24; |
|
|
945 | my $absolute_timeout = time + $timeout * 3600; |
|
|
946 | |
|
|
947 | if (cf::player::exists $target) { |
|
|
948 | if ($type eq "tell") { |
|
|
949 | $pl->message ("Now ignoring private messages from $target for $timeout hours.", cf::NDI_REPLY); |
|
|
950 | $pl->{ext_ignore_tell}{$target} = $absolute_timeout; |
|
|
951 | } elsif ($type eq "shout") { |
|
|
952 | $pl->message ("Now ignoring shouts from $target for $timeout hours.", cf::NDI_REPLY); |
|
|
953 | $pl->{ext_ignore_shout}{$target} = $absolute_timeout; |
|
|
954 | } elsif ($type eq "all") { |
|
|
955 | $pl->message ("Now ignoring everything from $target for $timeout hours.", cf::NDI_REPLY); |
|
|
956 | $pl->{ext_ignore_tell}{$target} = $absolute_timeout; |
|
|
957 | $pl->{ext_ignore_shout}{$target} = $absolute_timeout; |
|
|
958 | } else { |
|
|
959 | $pl->message ("You need to specify tell, shout or all.", cf::NDI_REPLY); |
|
|
960 | } |
|
|
961 | } else { |
|
|
962 | $pl->message ("No such player: $target", cf::NDI_REPLY); |
|
|
963 | } |
|
|
964 | |
|
|
965 | } else { |
|
|
966 | $pl->message ("Usage: ignore <player> <tell|shout|all> <timeout>\n" |
|
|
967 | . "will ignore a player for <timeout> hours.\n" |
|
|
968 | . "Usage: ignore list\n" |
|
|
969 | . "will show you a list of players currently ignored.", cf::NDI_REPLY); |
|
|
970 | } |
987 | }; |
971 | }; |
988 | }; |
972 | |
989 | |
973 | cf::register_command unignore => sub { |
990 | cf::register_command unignore => sub { |
974 | my ($pl, $args) = @_; |
991 | my ($pl, $args) = @_; |
975 | my ($target, $type) = split /\s+/, $args; |
992 | my ($target, $type) = split /\s+/, $args; |
976 | |
993 | |
|
|
994 | cf::async { |
977 | if ($args eq "") { |
995 | if ($args eq "") { |
978 | if ($pl->{ext_ignore_tell}) { |
996 | if ($pl->{ext_ignore_tell}) { |
979 | $pl->message ("Currently ignoring private messages from: ", cf::NDI_REPLY); |
997 | $pl->message ("Currently ignoring private messages from: ", cf::NDI_REPLY); |
980 | $pl->message ((join ", ", sort keys %{ $pl->{ext_ignore_tell} }), cf::NDI_REPLY); |
998 | $pl->message ((join ", ", sort keys %{ $pl->{ext_ignore_tell} }), cf::NDI_REPLY); |
981 | $pl->message ("Currently ignoring shouts from: ", cf::NDI_REPLY); |
999 | $pl->message ("Currently ignoring shouts from: ", cf::NDI_REPLY); |
982 | $pl->message ((join ", ", sort keys %{ $pl->{ext_ignore_shout} }), cf::NDI_REPLY); |
1000 | $pl->message ((join ", ", sort keys %{ $pl->{ext_ignore_shout} }), cf::NDI_REPLY); |
983 | } else { |
|
|
984 | $pl->message ("Not ignoring anyone", cf::NDI_REPLY); |
|
|
985 | } |
|
|
986 | } else { |
|
|
987 | if (cf::player::exists $target) { |
|
|
988 | if ($type eq "tell") { |
|
|
989 | $pl->message ("Not ignoring private messages from $target anymore.", cf::NDI_REPLY); |
|
|
990 | delete $pl->{ext_ignore_tell} {$target}; |
|
|
991 | } elsif ($type eq "shout") { |
|
|
992 | $pl->message ("Not ignoring shouts from $target anymore.", cf::NDI_REPLY); |
|
|
993 | delete $pl->{ext_ignore_shout}{$target}; |
|
|
994 | } elsif ($type eq "all") { |
|
|
995 | $pl->message ("Not ignoring anything from $target anymore.", cf::NDI_REPLY); |
|
|
996 | delete $pl->{ext_ignore_tell} {$target}; |
|
|
997 | delete $pl->{ext_ignore_shout}{$target}; |
|
|
998 | } else { |
1001 | } else { |
999 | $pl->message ("You need to specify tell, shout or all.", cf::NDI_REPLY); |
1002 | $pl->message ("Not ignoring anyone", cf::NDI_REPLY); |
1000 | } |
1003 | } |
1001 | } else { |
1004 | } else { |
|
|
1005 | if (cf::player::exists $target) { |
|
|
1006 | if ($type eq "tell") { |
|
|
1007 | $pl->message ("Not ignoring private messages from $target anymore.", cf::NDI_REPLY); |
|
|
1008 | delete $pl->{ext_ignore_tell} {$target}; |
|
|
1009 | } elsif ($type eq "shout") { |
|
|
1010 | $pl->message ("Not ignoring shouts from $target anymore.", cf::NDI_REPLY); |
|
|
1011 | delete $pl->{ext_ignore_shout}{$target}; |
|
|
1012 | } elsif ($type eq "all") { |
|
|
1013 | $pl->message ("Not ignoring anything from $target anymore.", cf::NDI_REPLY); |
|
|
1014 | delete $pl->{ext_ignore_tell} {$target}; |
|
|
1015 | delete $pl->{ext_ignore_shout}{$target}; |
|
|
1016 | } else { |
|
|
1017 | $pl->message ("You need to specify tell, shout or all.", cf::NDI_REPLY); |
|
|
1018 | } |
|
|
1019 | } else { |
1002 | $pl->message ("No such player or ambiguous name: $target", cf::NDI_REPLY); |
1020 | $pl->message ("No such player or ambiguous name: $target", cf::NDI_REPLY); |
|
|
1021 | } |
1003 | } |
1022 | } |
1004 | } |
1023 | }; |
1005 | }; |
1024 | }; |
1006 | |
1025 | |