… | |
… | |
27 | id => "tell-$target", |
27 | id => "tell-$target", |
28 | title => "$target", |
28 | title => "$target", |
29 | reply => "tell $target ", |
29 | reply => "tell $target ", |
30 | tooltip => "Private messages from/to $target", |
30 | tooltip => "Private messages from/to $target", |
31 | } |
31 | } |
|
|
32 | } |
|
|
33 | |
|
|
34 | sub send_msg($$$$$) { |
|
|
35 | my ($pl, $channel, $msg, $flags, $sound) = @_; |
|
|
36 | $pl->play_sound (cf::sound::find $sound) if defined $sound; |
|
|
37 | $pl->send_msg ($channel, $msg, $flags); |
|
|
38 | () |
32 | } |
39 | } |
33 | |
40 | |
34 | sub clean_timeouts($) { |
41 | sub clean_timeouts($) { |
35 | my ($player) = @_; |
42 | my ($player) = @_; |
36 | my $NOW = time; |
43 | my $NOW = time; |
… | |
… | |
95 | my $pl = $ob->contr; |
102 | my $pl = $ob->contr; |
96 | my $name = $ob->name; |
103 | my $name = $ob->name; |
97 | |
104 | |
98 | my $coin = int rand 2 ? "Heads" : "Tails"; |
105 | my $coin = int rand 2 ? "Heads" : "Tails"; |
99 | |
106 | |
100 | $_->send_msg ($SAY_CHANNEL => "$name flips a coin.... $coin!", cf::NDI_GREY) |
107 | send_msg $_, $SAY_CHANNEL => "$name flips a coin.... $coin!", cf::NDI_GREY, "msg_say" |
101 | for grep { $ob->on_same_map_as ($_->ob) && $_ != $pl} cf::player::list; |
108 | for grep { $ob->on_same_map_as ($_->ob) && $_ != $pl} cf::player::list; |
102 | |
109 | |
103 | $pl->send_msg ($SAY_CHANNEL => "You flip a coin.... $coin!", cf::NDI_GREY | cf::NDI_REPLY); |
110 | $pl->send_msg ($SAY_CHANNEL => "You flip a coin.... $coin!", cf::NDI_GREY | cf::NDI_REPLY); |
104 | }; |
111 | }; |
105 | |
112 | |
… | |
… | |
111 | |
118 | |
112 | my @orcknuckle = ("beholder", "ghost", "knight", "princess", "dragon", "orc"); |
119 | my @orcknuckle = ("beholder", "ghost", "knight", "princess", "dragon", "orc"); |
113 | my ($i, $j, $k, $l) = (rand 5, rand 5, rand 5, rand 6); |
120 | my ($i, $j, $k, $l) = (rand 5, rand 5, rand 5, rand 6); |
114 | my $result = "$orcknuckle[$i], $orcknuckle[$j], $orcknuckle[$k], $orcknuckle[$l]"; |
121 | my $result = "$orcknuckle[$i], $orcknuckle[$j], $orcknuckle[$k], $orcknuckle[$l]"; |
115 | |
122 | |
116 | $_->send_msg ($SAY_CHANNEL => "$name throws his orc-knuckles and rolls $result!", cf::NDI_GREY) |
123 | send_msg $_, $SAY_CHANNEL => "$name throws his orc-knuckles and rolls $result!", cf::NDI_GREY, "msg_say" |
117 | for grep { $ob->on_same_map_as ($_->ob) && $_ != $pl} cf::player::list; |
124 | for grep { $ob->on_same_map_as ($_->ob) && $_ != $pl} cf::player::list; |
118 | |
125 | |
119 | $pl->send_msg ($SAY_CHANNEL => "You roll $result!", cf::NDI_GREY | cf::NDI_REPLY); |
126 | $pl->send_msg ($SAY_CHANNEL => "You roll $result!", cf::NDI_GREY | cf::NDI_REPLY); |
120 | }; |
127 | }; |
121 | |
128 | |
… | |
… | |
707 | |
714 | |
708 | my $pl = $ob->contr; |
715 | my $pl = $ob->contr; |
709 | |
716 | |
710 | cf::async { |
717 | cf::async { |
711 | my $name = $ob->name; |
718 | my $name = $ob->name; |
|
|
719 | $Coro::current->{desc} = "emote handler for $name"; |
712 | |
720 | |
713 | if ($tname eq $name) { |
721 | if ($tname eq $name) { |
714 | my %emote = %{ $emotes->{$emotion}->{self} || {} }; |
722 | my %emote = %{ $emotes->{$emotion}->{self} || {} }; |
715 | |
723 | |
716 | $emote{other} ||= "You look away from <self>."; |
724 | $emote{other} ||= "You look away from <self>."; |
717 | $emote{self} ||= "My god! Is that LEGAL?"; |
725 | $emote{self} ||= "My god! Is that LEGAL?"; |
718 | |
726 | |
719 | $emote{other} =~ s/<self>/$name/; |
727 | $emote{other} =~ s/<self>/$name/; |
720 | |
728 | |
721 | $_->send_msg ($CHAT_CHANNEL, $emote{other}, cf::NDI_GREY) |
729 | send_msg $_, $CHAT_CHANNEL, $emote{other}, cf::NDI_GREY, "msg_chat" |
722 | for grep { $ob->on_same_map_as ($_->ob) && $_ != $ob} cf::player::list; |
730 | for grep { $ob->on_same_map_as ($_->ob) && $_ != $ob} cf::player::list; |
723 | |
731 | |
724 | $pl->send_msg ($emote{self}, cf::NDI_GREY | cf::NDI_REPLY); |
732 | $pl->send_msg ($emote{self}, cf::NDI_GREY | cf::NDI_REPLY); |
725 | } elsif ($tname) { |
733 | } elsif ($tname) { |
726 | my $target = cf::player::find $tname |
734 | my $target = cf::player::find $tname |
727 | or return $pl->send_msg (tell_channel $tname, "$tname is not around.", cf::NDI_DK_ORANGE | cf::NDI_REPLY); |
735 | or return send_msg $pl, tell_channel $tname, "$tname is not around.", cf::NDI_DK_ORANGE | cf::NDI_REPLY, "msg_chat"; |
728 | |
736 | |
729 | my %emote = %{ $emotes->{$emotion}->{params} || {} }; |
737 | my %emote = %{ $emotes->{$emotion}->{params} || {} }; |
730 | |
738 | |
731 | $emote{other} ||= "<self> is eyeing <other> quizzically."; |
739 | $emote{other} ||= "<self> is eyeing <other> quizzically."; |
732 | $emote{self} ||= "You are still nuts."; |
740 | $emote{self} ||= "You are still nuts."; |
… | |
… | |
735 | $emote{self} =~ s/<other>/$tname/; |
743 | $emote{self} =~ s/<other>/$tname/; |
736 | $emote{target} =~ s/<self>/$name/; |
744 | $emote{target} =~ s/<self>/$name/; |
737 | $emote{other} =~ s/<other>/$tname/; |
745 | $emote{other} =~ s/<other>/$tname/; |
738 | $emote{other} =~ s/<self>/$name/; |
746 | $emote{other} =~ s/<self>/$name/; |
739 | |
747 | |
740 | $_->send_msg ($CHAT_CHANNEL, $emote{other}, cf::NDI_GREY) |
748 | send_msg $_, $CHAT_CHANNEL, $emote{other}, cf::NDI_GREY, "msg_chat" |
741 | for grep { $_ != $pl && $_ != $target && $ob->on_same_map_as ($_->ob) } cf::player::list; |
749 | for grep { $_ != $pl && $_ != $target && $ob->on_same_map_as ($_->ob) } cf::player::list; |
742 | |
750 | |
743 | $target->send_msg (tell_channel $name, $emote{target}, cf::NDI_GREY); |
751 | send_msg $target, tell_channel $name, $emote{target}, cf::NDI_GREY, "msg_shout"; |
744 | $pl->send_msg (tell_channel $tname, $emote{self}, cf::NDI_GREY | cf::NDI_REPLY); |
752 | $pl->send_msg (tell_channel $tname, $emote{self}, cf::NDI_GREY | cf::NDI_REPLY); |
745 | } else { |
753 | } else { |
746 | my %emote = %{ $emotes->{$emotion}->{noparams} || {} }; |
754 | my %emote = %{ $emotes->{$emotion}->{noparams} || {} }; |
747 | |
755 | |
748 | $emote{other} ||= "<self> dances with glee."; |
756 | $emote{other} ||= "<self> dances with glee."; |
749 | $emote{self} ||= "You are a nut."; |
757 | $emote{self} ||= "You are a nut."; |
750 | |
758 | |
751 | $emote{other} =~ s/<self>/$name/; |
759 | $emote{other} =~ s/<self>/$name/; |
752 | |
760 | |
753 | $_->send_msg ($CHAT_CHANNEL, $emote{other}, cf::NDI_GREY) |
761 | send_msg $_, $CHAT_CHANNEL, $emote{other}, cf::NDI_GREY, "msg_chat" |
754 | for grep { $ob->on_same_map_as ($_->ob) && $_ != $pl } cf::player::list; |
762 | for grep { $ob->on_same_map_as ($_->ob) && $_ != $pl } cf::player::list; |
755 | |
763 | |
756 | $pl->send_msg ($CHAT_CHANNEL, $emote{self}, cf::NDI_GREY | cf::NDI_REPLY); |
764 | $pl->send_msg ($CHAT_CHANNEL, $emote{self}, cf::NDI_GREY | cf::NDI_REPLY); |
757 | } |
765 | } |
758 | }; |
766 | }; |
… | |
… | |
762 | cf::register_command me => sub { |
770 | cf::register_command me => sub { |
763 | my ($pl, $msg) = @_; |
771 | my ($pl, $msg) = @_; |
764 | |
772 | |
765 | my $name = $pl->name; |
773 | my $name = $pl->name; |
766 | |
774 | |
767 | $_->send_msg ($SAY_CHANNEL => "* $name $msg", cf::NDI_GREY | cf::NDI_DEF | ($_ == $pl ? cf::NDI_REPLY : 0)) |
775 | send_msg $pl, $SAY_CHANNEL => "* $name $msg", cf::NDI_GREY | cf::NDI_DEF | ($_ == $pl ? cf::NDI_REPLY : 0), "msg_say" |
768 | for grep $pl->on_same_map_as ($_->ob), cf::player::list; |
776 | for grep $pl->on_same_map_as ($_->ob), cf::player::list; |
769 | }; |
777 | }; |
770 | |
778 | |
771 | cf::register_command say => sub { |
779 | cf::register_command say => sub { |
772 | my ($ob, $msg) = @_; |
780 | my ($ob, $msg) = @_; |
… | |
… | |
777 | |
785 | |
778 | if ($msg) { |
786 | if ($msg) { |
779 | my $name = $ob->name; |
787 | my $name = $ob->name; |
780 | my @plonmap = grep $ob->on_same_map_as ($_->ob), cf::player::list; |
788 | my @plonmap = grep $ob->on_same_map_as ($_->ob), cf::player::list; |
781 | |
789 | |
|
|
790 | send_msg $_, $SAY_CHANNEL => "$name says: $msg", cf::NDI_GREY, "msg_say" |
|
|
791 | for grep $_ != $ob->contr, @plonmap; |
782 | $_->send_msg ($SAY_CHANNEL => "$name says: $msg", cf::NDI_GREY | ($_ == $ob->contr ? cf::NDI_REPLY : 0)) |
792 | $ob->contr->send_msg ($SAY_CHANNEL => "$name says: $msg", cf::NDI_GREY | cf::NDI_REPLY); |
783 | for @plonmap; |
|
|
784 | |
793 | |
785 | # npcs, magic_ears etc. |
794 | # npcs, magic_ears etc. |
786 | # first find all objects and their first-level inventories |
795 | # first find all objects and their first-level inventories |
787 | # within a 5x5 square that have something resembling |
796 | # within a 5x5 square that have something resembling |
788 | # dialogue or support on_say. |
797 | # dialogue or support on_say. |
… | |
… | |
802 | my ($reply, @kw) = $dialog->tell ($msg); |
811 | my ($reply, @kw) = $dialog->tell ($msg); |
803 | |
812 | |
804 | if (defined $reply) { |
813 | if (defined $reply) { |
805 | if ($npc->type == cf::MAGIC_EAR) { |
814 | if ($npc->type == cf::MAGIC_EAR) { |
806 | if (length $reply) { |
815 | if (length $reply) { |
807 | $_->send_msg ($SAY_CHANNEL => $reply, cf::NDI_BROWN) |
816 | send_msg $_, $SAY_CHANNEL => $reply, cf::NDI_BROWN, "msg_say" |
808 | for @plonmap; |
817 | for @plonmap; |
809 | } |
818 | } |
810 | $npc->use_trigger; |
819 | $npc->use_trigger; |
811 | } else { |
820 | } else { |
812 | if (length $reply) { |
821 | if (length $reply) { |
813 | $_->send_msg ($SAY_CHANNEL => $npc->name . " says: $reply", cf::NDI_BROWN) |
822 | send_msg $_, $SAY_CHANNEL => $npc->name . " says: $reply", cf::NDI_BROWN, "msg_say" |
814 | for @plonmap; |
823 | for @plonmap; |
815 | } |
824 | } |
816 | } |
825 | } |
817 | } |
826 | } |
818 | |
827 | |
… | |
… | |
841 | my $NOW = time; |
850 | my $NOW = time; |
842 | |
851 | |
843 | cf::LOG cf::llevDebug, sprintf "QBERT [%s] %s\n", $name, $msg; |
852 | cf::LOG cf::llevDebug, sprintf "QBERT [%s] %s\n", $name, $msg; |
844 | send_irc ("[%s] %s", $name, $msg); |
853 | send_irc ("[%s] %s", $name, $msg); |
845 | |
854 | |
846 | $_->send_msg ($CHAT_CHANNEL => "$name chats: $msg", cf::NDI_BLUE | cf::NDI_DEF | ($_ == $pl ? cf::NDI_REPLY : 0)) |
855 | send_msg $_, $CHAT_CHANNEL => "$name chats: $msg", cf::NDI_BLUE | cf::NDI_DEF | ($_ == $pl ? cf::NDI_REPLY : 0), "msg_chat" |
847 | for grep { $_->ob->{ext_ignore_shout}{$name} < $NOW && $_->listening >= 10 } cf::player::list; |
856 | for grep { $_->ob->{ext_ignore_shout}{$name} < $NOW && $_->listening >= 10 } cf::player::list; |
848 | |
857 | |
849 | } else { |
858 | } else { |
850 | $pl->send_msg ($CHAT_CHANNEL => "Chat what?", cf::NDI_BLUE | cf::NDI_DEF | cf::NDI_REPLY); |
859 | $pl->send_msg ($CHAT_CHANNEL => "Chat what?", cf::NDI_BLUE | cf::NDI_DEF | cf::NDI_REPLY); |
851 | } |
860 | } |
… | |
… | |
865 | my $name = $ob->name; |
874 | my $name = $ob->name; |
866 | |
875 | |
867 | cf::LOG cf::llevDebug, sprintf "QBERT {%s} %s\n", $name, $msg; |
876 | cf::LOG cf::llevDebug, sprintf "QBERT {%s} %s\n", $name, $msg; |
868 | send_irc ("\007\0034{%s} %s\n", $name, $msg); |
877 | send_irc ("\007\0034{%s} %s\n", $name, $msg); |
869 | |
878 | |
870 | $_->send_msg ($CHAT_CHANNEL => "$name shouts: $msg", cf::NDI_RED | cf::NDI_DEF | ($_ == $pl ? cf::NDI_REPLY : 0)) |
879 | send_msg $_, $CHAT_CHANNEL => "$name shouts: $msg", cf::NDI_RED | cf::NDI_DEF | ($_ == $pl ? cf::NDI_REPLY : 0), "msg_shout" |
871 | for grep { $_->ob->{ext_ignore_shout}{$name} < $NOW && $_->listening >= 2 } cf::player::list; |
880 | for grep { $_->ob->{ext_ignore_shout}{$name} < $NOW && $_->listening >= 2 } cf::player::list; |
872 | |
881 | |
873 | } else { |
882 | } else { |
874 | $pl->send_msg ($CHAT_CHANNEL => "Shout what?", cf::NDI_RED | cf::NDI_DEF | cf::NDI_REPLY); |
883 | $pl->send_msg ($CHAT_CHANNEL => "Shout what?", cf::NDI_RED | cf::NDI_DEF | cf::NDI_REPLY); |
875 | } |
884 | } |
… | |
… | |
906 | } else { |
915 | } else { |
907 | return if $other->invoke (cf::EVENT_PLAYER_TOLD, $pl, $msg); |
916 | return if $other->invoke (cf::EVENT_PLAYER_TOLD, $pl, $msg); |
908 | cf::LOG cf::llevDebug, sprintf "TELL [%s>%s] %s\n", $name, $target, $msg; |
917 | cf::LOG cf::llevDebug, sprintf "TELL [%s>%s] %s\n", $name, $target, $msg; |
909 | |
918 | |
910 | $ns->send_msg ($pl_channel => "You tell $target: $msg", cf::NDI_DK_ORANGE | cf::NDI_DEF | cf::NDI_REPLY); |
919 | $ns->send_msg ($pl_channel => "You tell $target: $msg", cf::NDI_DK_ORANGE | cf::NDI_DEF | cf::NDI_REPLY); |
911 | $other->send_msg ($other_channel => "$name tells you: $msg", cf::NDI_DK_ORANGE | cf::NDI_DEF); |
920 | send_msg $other, $other_channel => "$name tells you: $msg", cf::NDI_DK_ORANGE | cf::NDI_DEF, "msg_tell"; |
912 | } |
921 | } |
913 | } else { |
922 | } else { |
914 | $ns->send_msg ($pl_channel => "What do you want to tell $target?", cf::NDI_DK_ORANGE | cf::NDI_DEF | cf::NDI_REPLY); |
923 | $ns->send_msg ($pl_channel => "What do you want to tell $target?", cf::NDI_DK_ORANGE | cf::NDI_DEF | cf::NDI_REPLY); |
915 | } |
924 | } |
916 | |
925 | |