… | |
… | |
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; |
… | |
… | |
62 | prio => -1000, |
69 | prio => -1000, |
63 | on_login => sub { |
70 | on_login => sub { |
64 | my ($pl) = @_; |
71 | my ($pl) = @_; |
65 | |
72 | |
66 | clean_timeouts $pl->ob; |
73 | clean_timeouts $pl->ob; |
|
|
74 | |
67 | $pl->send_msg ($SAY_CHANNEL); |
75 | $pl->send_msg ($SAY_CHANNEL); |
68 | $pl->send_msg ($CHAT_CHANNEL); |
76 | $pl->send_msg ($CHAT_CHANNEL); |
69 | }, |
77 | }, |
70 | ); |
78 | ); |
71 | |
79 | |
… | |
… | |
94 | my $pl = $ob->contr; |
102 | my $pl = $ob->contr; |
95 | my $name = $ob->name; |
103 | my $name = $ob->name; |
96 | |
104 | |
97 | my $coin = int rand 2 ? "Heads" : "Tails"; |
105 | my $coin = int rand 2 ? "Heads" : "Tails"; |
98 | |
106 | |
99 | $_->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" |
100 | 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; |
101 | |
109 | |
102 | $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); |
103 | }; |
111 | }; |
104 | |
112 | |
… | |
… | |
110 | |
118 | |
111 | my @orcknuckle = ("beholder", "ghost", "knight", "princess", "dragon", "orc"); |
119 | my @orcknuckle = ("beholder", "ghost", "knight", "princess", "dragon", "orc"); |
112 | 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); |
113 | my $result = "$orcknuckle[$i], $orcknuckle[$j], $orcknuckle[$k], $orcknuckle[$l]"; |
121 | my $result = "$orcknuckle[$i], $orcknuckle[$j], $orcknuckle[$k], $orcknuckle[$l]"; |
114 | |
122 | |
115 | $_->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" |
116 | 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; |
117 | |
125 | |
118 | $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); |
119 | }; |
127 | }; |
120 | |
128 | |
… | |
… | |
706 | |
714 | |
707 | my $pl = $ob->contr; |
715 | my $pl = $ob->contr; |
708 | |
716 | |
709 | cf::async { |
717 | cf::async { |
710 | my $name = $ob->name; |
718 | my $name = $ob->name; |
|
|
719 | $Coro::current->{desc} = "emote handler for $name"; |
711 | |
720 | |
712 | if ($tname eq $name) { |
721 | if ($tname eq $name) { |
713 | my %emote = %{ $emotes->{$emotion}->{self} || {} }; |
722 | my %emote = %{ $emotes->{$emotion}->{self} || {} }; |
714 | |
723 | |
715 | $emote{other} ||= "You look away from <self>."; |
724 | $emote{other} ||= "You look away from <self>."; |
716 | $emote{self} ||= "My god! Is that LEGAL?"; |
725 | $emote{self} ||= "My god! Is that LEGAL?"; |
717 | |
726 | |
718 | $emote{other} =~ s/<self>/$name/; |
727 | $emote{other} =~ s/<self>/$name/; |
719 | |
728 | |
720 | $_->send_msg ($CHAT_CHANNEL, $emote{other}, cf::NDI_GREY) |
729 | send_msg $_, $CHAT_CHANNEL, $emote{other}, cf::NDI_GREY, "msg_chat" |
721 | 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; |
722 | |
731 | |
723 | $pl->send_msg ($emote{self}, cf::NDI_GREY | cf::NDI_REPLY); |
732 | $pl->send_msg ($emote{self}, cf::NDI_GREY | cf::NDI_REPLY); |
724 | } elsif ($tname) { |
733 | } elsif ($tname) { |
725 | my $target = cf::player::find $tname |
734 | my $target = cf::player::find $tname |
726 | 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"; |
727 | |
736 | |
728 | my %emote = %{ $emotes->{$emotion}->{params} || {} }; |
737 | my %emote = %{ $emotes->{$emotion}->{params} || {} }; |
729 | |
738 | |
730 | $emote{other} ||= "<self> is eyeing <other> quizzically."; |
739 | $emote{other} ||= "<self> is eyeing <other> quizzically."; |
731 | $emote{self} ||= "You are still nuts."; |
740 | $emote{self} ||= "You are still nuts."; |
… | |
… | |
734 | $emote{self} =~ s/<other>/$tname/; |
743 | $emote{self} =~ s/<other>/$tname/; |
735 | $emote{target} =~ s/<self>/$name/; |
744 | $emote{target} =~ s/<self>/$name/; |
736 | $emote{other} =~ s/<other>/$tname/; |
745 | $emote{other} =~ s/<other>/$tname/; |
737 | $emote{other} =~ s/<self>/$name/; |
746 | $emote{other} =~ s/<self>/$name/; |
738 | |
747 | |
739 | $_->send_msg ($CHAT_CHANNEL, $emote{other}, cf::NDI_GREY) |
748 | send_msg $_, $CHAT_CHANNEL, $emote{other}, cf::NDI_GREY, "msg_chat" |
740 | 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; |
741 | |
750 | |
742 | $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"; |
743 | $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); |
744 | } else { |
753 | } else { |
745 | my %emote = %{ $emotes->{$emotion}->{noparams} || {} }; |
754 | my %emote = %{ $emotes->{$emotion}->{noparams} || {} }; |
746 | |
755 | |
747 | $emote{other} ||= "<self> dances with glee."; |
756 | $emote{other} ||= "<self> dances with glee."; |
748 | $emote{self} ||= "You are a nut."; |
757 | $emote{self} ||= "You are a nut."; |
749 | |
758 | |
750 | $emote{other} =~ s/<self>/$name/; |
759 | $emote{other} =~ s/<self>/$name/; |
751 | |
760 | |
752 | $_->send_msg ($CHAT_CHANNEL, $emote{other}, cf::NDI_GREY) |
761 | send_msg $_, $CHAT_CHANNEL, $emote{other}, cf::NDI_GREY, "msg_chat" |
753 | 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; |
754 | |
763 | |
755 | $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); |
756 | } |
765 | } |
757 | }; |
766 | }; |
… | |
… | |
761 | cf::register_command me => sub { |
770 | cf::register_command me => sub { |
762 | my ($pl, $msg) = @_; |
771 | my ($pl, $msg) = @_; |
763 | |
772 | |
764 | my $name = $pl->name; |
773 | my $name = $pl->name; |
765 | |
774 | |
766 | $_->send_msg ($SAY_CHANNEL => "* $name $msg", cf::NDI_GREY | cf::NDI_DEF | ($_ == $pl ? cf::NDI_REPLY : 0)) |
775 | send_msg $_, $SAY_CHANNEL => "* $name $msg", cf::NDI_GREY | cf::NDI_DEF | ($_ == $pl ? cf::NDI_REPLY : 0), "msg_say" |
767 | for grep $pl->on_same_map_as ($_->ob), cf::player::list; |
776 | for grep $pl->on_same_map_as ($_->ob), cf::player::list; |
768 | }; |
777 | }; |
769 | |
778 | |
770 | cf::register_command say => sub { |
779 | cf::register_command say => sub { |
771 | my ($ob, $msg) = @_; |
780 | my ($ob, $msg) = @_; |
… | |
… | |
776 | |
785 | |
777 | if ($msg) { |
786 | if ($msg) { |
778 | my $name = $ob->name; |
787 | my $name = $ob->name; |
779 | 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; |
780 | |
789 | |
|
|
790 | send_msg $_, $SAY_CHANNEL => "$name says: $msg", cf::NDI_GREY, "msg_say" |
|
|
791 | for grep $_ != $ob->contr, @plonmap; |
781 | $_->send_msg ($SAY_CHANNEL => "$name says: $msg", cf::NDI_GREY | ($_ == $ob ? cf::NDI_REPLY : 0)) |
792 | $ob->contr->send_msg ($SAY_CHANNEL => "$name says: $msg", cf::NDI_GREY | cf::NDI_REPLY); |
782 | for @plonmap; |
|
|
783 | |
793 | |
784 | # npcs, magic_ears etc. |
794 | # npcs, magic_ears etc. |
785 | # first find all objects and their first-level inventories |
795 | # first find all objects and their first-level inventories |
786 | # within a 5x5 square that have something resembling |
796 | # within a 5x5 square that have something resembling |
787 | # dialogue or support on_say. |
797 | # dialogue or support on_say. |
… | |
… | |
801 | my ($reply, @kw) = $dialog->tell ($msg); |
811 | my ($reply, @kw) = $dialog->tell ($msg); |
802 | |
812 | |
803 | if (defined $reply) { |
813 | if (defined $reply) { |
804 | if ($npc->type == cf::MAGIC_EAR) { |
814 | if ($npc->type == cf::MAGIC_EAR) { |
805 | if (length $reply) { |
815 | if (length $reply) { |
806 | $_->send_msg ($SAY_CHANNEL => $reply, cf::NDI_BROWN) |
816 | send_msg $_, $SAY_CHANNEL => $reply, cf::NDI_BROWN, "msg_say" |
807 | for @plonmap; |
817 | for @plonmap; |
808 | } |
818 | } |
809 | $npc->use_trigger; |
819 | $npc->use_trigger; |
810 | } else { |
820 | } else { |
811 | if (length $reply) { |
821 | if (length $reply) { |
812 | $_->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" |
813 | for @plonmap; |
823 | for @plonmap; |
814 | } |
824 | } |
815 | } |
825 | } |
816 | } |
826 | } |
817 | |
827 | |
… | |
… | |
840 | my $NOW = time; |
850 | my $NOW = time; |
841 | |
851 | |
842 | cf::LOG cf::llevDebug, sprintf "QBERT [%s] %s\n", $name, $msg; |
852 | cf::LOG cf::llevDebug, sprintf "QBERT [%s] %s\n", $name, $msg; |
843 | send_irc ("[%s] %s", $name, $msg); |
853 | send_irc ("[%s] %s", $name, $msg); |
844 | |
854 | |
845 | $_->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" |
846 | 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; |
847 | |
857 | |
848 | } else { |
858 | } else { |
849 | $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); |
850 | } |
860 | } |
… | |
… | |
864 | my $name = $ob->name; |
874 | my $name = $ob->name; |
865 | |
875 | |
866 | cf::LOG cf::llevDebug, sprintf "QBERT {%s} %s\n", $name, $msg; |
876 | cf::LOG cf::llevDebug, sprintf "QBERT {%s} %s\n", $name, $msg; |
867 | send_irc ("\007\0034{%s} %s\n", $name, $msg); |
877 | send_irc ("\007\0034{%s} %s\n", $name, $msg); |
868 | |
878 | |
869 | $_->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" |
870 | 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; |
871 | |
881 | |
872 | } else { |
882 | } else { |
873 | $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); |
874 | } |
884 | } |
… | |
… | |
905 | } else { |
915 | } else { |
906 | return if $other->invoke (cf::EVENT_PLAYER_TOLD, $pl, $msg); |
916 | return if $other->invoke (cf::EVENT_PLAYER_TOLD, $pl, $msg); |
907 | 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; |
908 | |
918 | |
909 | $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); |
910 | $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"; |
911 | } |
921 | } |
912 | } else { |
922 | } else { |
913 | $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); |
914 | } |
924 | } |
915 | |
925 | |