… | |
… | |
62 | prio => -1000, |
62 | prio => -1000, |
63 | on_login => sub { |
63 | on_login => sub { |
64 | my ($pl) = @_; |
64 | my ($pl) = @_; |
65 | |
65 | |
66 | clean_timeouts $pl->ob; |
66 | clean_timeouts $pl->ob; |
|
|
67 | |
67 | $pl->ns->send_msg ($SAY_CHANNEL); |
68 | $pl->send_msg ($SAY_CHANNEL); |
68 | $pl->ns->send_msg ($CHAT_CHANNEL); |
69 | $pl->send_msg ($CHAT_CHANNEL); |
69 | }, |
70 | }, |
70 | ); |
71 | ); |
71 | |
72 | |
72 | cf::register_command listen => sub { |
73 | cf::register_command listen => sub { |
73 | my ($pl, $msg) = @_; |
74 | my ($pl, $msg) = @_; |
… | |
… | |
94 | my $pl = $ob->contr; |
95 | my $pl = $ob->contr; |
95 | my $name = $ob->name; |
96 | my $name = $ob->name; |
96 | |
97 | |
97 | my $coin = int rand 2 ? "Heads" : "Tails"; |
98 | my $coin = int rand 2 ? "Heads" : "Tails"; |
98 | |
99 | |
99 | $_->ns->send_msg ($SAY_CHANNEL => "$name flips a coin.... $coin!", cf::NDI_GREY) |
100 | $_->send_msg ($SAY_CHANNEL => "$name flips a coin.... $coin!", cf::NDI_GREY) |
100 | for grep { $ob->on_same_map_as ($_->ob) && $_ != $pl} cf::player::list; |
101 | for grep { $ob->on_same_map_as ($_->ob) && $_ != $pl} cf::player::list; |
101 | |
102 | |
102 | $pl->ns->send_msg ($SAY_CHANNEL => "You flip a coin.... $coin!", cf::NDI_GREY | cf::NDI_REPLY); |
103 | $pl->send_msg ($SAY_CHANNEL => "You flip a coin.... $coin!", cf::NDI_GREY | cf::NDI_REPLY); |
103 | }; |
104 | }; |
104 | |
105 | |
105 | cf::register_command orcknuckle => sub { |
106 | cf::register_command orcknuckle => sub { |
106 | my ($ob, $msg) = @_; |
107 | my ($ob, $msg) = @_; |
107 | |
108 | |
… | |
… | |
110 | |
111 | |
111 | my @orcknuckle = ("beholder", "ghost", "knight", "princess", "dragon", "orc"); |
112 | my @orcknuckle = ("beholder", "ghost", "knight", "princess", "dragon", "orc"); |
112 | my ($i, $j, $k, $l) = (rand 5, rand 5, rand 5, rand 6); |
113 | my ($i, $j, $k, $l) = (rand 5, rand 5, rand 5, rand 6); |
113 | my $result = "$orcknuckle[$i], $orcknuckle[$j], $orcknuckle[$k], $orcknuckle[$l]"; |
114 | my $result = "$orcknuckle[$i], $orcknuckle[$j], $orcknuckle[$k], $orcknuckle[$l]"; |
114 | |
115 | |
115 | $_->ns->send_msg ($SAY_CHANNEL => "$name throws his orc-knuckles and rolls $result!", cf::NDI_GREY) |
116 | $_->send_msg ($SAY_CHANNEL => "$name throws his orc-knuckles and rolls $result!", cf::NDI_GREY) |
116 | for grep { $ob->on_same_map_as ($_->ob) && $_ != $pl} cf::player::list; |
117 | for grep { $ob->on_same_map_as ($_->ob) && $_ != $pl} cf::player::list; |
117 | |
118 | |
118 | $pl->ns->send_msg ($SAY_CHANNEL => "You roll $result!", cf::NDI_GREY | cf::NDI_REPLY); |
119 | $pl->send_msg ($SAY_CHANNEL => "You roll $result!", cf::NDI_GREY | cf::NDI_REPLY); |
119 | }; |
120 | }; |
120 | |
121 | |
121 | my $emotes = { |
122 | my $emotes = { |
122 | growl => { |
123 | growl => { |
123 | noparams => { |
124 | noparams => { |
… | |
… | |
715 | $emote{other} ||= "You look away from <self>."; |
716 | $emote{other} ||= "You look away from <self>."; |
716 | $emote{self} ||= "My god! Is that LEGAL?"; |
717 | $emote{self} ||= "My god! Is that LEGAL?"; |
717 | |
718 | |
718 | $emote{other} =~ s/<self>/$name/; |
719 | $emote{other} =~ s/<self>/$name/; |
719 | |
720 | |
720 | $_->ns->send_msg ($CHAT_CHANNEL, $emote{other}, cf::NDI_GREY) |
721 | $_->send_msg ($CHAT_CHANNEL, $emote{other}, cf::NDI_GREY) |
721 | for grep { $ob->on_same_map_as ($_->ob) && $_ != $ob} cf::player::list; |
722 | for grep { $ob->on_same_map_as ($_->ob) && $_ != $ob} cf::player::list; |
722 | |
723 | |
723 | $pl->ns->send_msg ($emote{self}, cf::NDI_GREY | cf::NDI_REPLY); |
724 | $pl->send_msg ($emote{self}, cf::NDI_GREY | cf::NDI_REPLY); |
724 | } elsif ($tname) { |
725 | } elsif ($tname) { |
725 | my $target = cf::player::find $tname |
726 | my $target = cf::player::find $tname |
726 | or return $pl->ns->send_msg (tell_channel $tname, "$tname is not around.", cf::NDI_DK_ORANGE | cf::NDI_REPLY); |
727 | or return $pl->send_msg (tell_channel $tname, "$tname is not around.", cf::NDI_DK_ORANGE | cf::NDI_REPLY); |
727 | |
728 | |
728 | my %emote = %{ $emotes->{$emotion}->{params} || {} }; |
729 | my %emote = %{ $emotes->{$emotion}->{params} || {} }; |
729 | |
730 | |
730 | $emote{other} ||= "<self> is eyeing <other> quizzically."; |
731 | $emote{other} ||= "<self> is eyeing <other> quizzically."; |
731 | $emote{self} ||= "You are still nuts."; |
732 | $emote{self} ||= "You are still nuts."; |
… | |
… | |
734 | $emote{self} =~ s/<other>/$tname/; |
735 | $emote{self} =~ s/<other>/$tname/; |
735 | $emote{target} =~ s/<self>/$name/; |
736 | $emote{target} =~ s/<self>/$name/; |
736 | $emote{other} =~ s/<other>/$tname/; |
737 | $emote{other} =~ s/<other>/$tname/; |
737 | $emote{other} =~ s/<self>/$name/; |
738 | $emote{other} =~ s/<self>/$name/; |
738 | |
739 | |
739 | $_->ns->send_msg ($CHAT_CHANNEL, $emote{other}, cf::NDI_GREY) |
740 | $_->send_msg ($CHAT_CHANNEL, $emote{other}, cf::NDI_GREY) |
740 | for grep { $_ != $pl && $_ != $target && $ob->on_same_map_as ($_->ob) } cf::player::list; |
741 | for grep { $_ != $pl && $_ != $target && $ob->on_same_map_as ($_->ob) } cf::player::list; |
741 | |
742 | |
742 | $target->ns->send_msg (tell_channel $name, $emote{target}, cf::NDI_GREY); |
743 | $target->send_msg (tell_channel $name, $emote{target}, cf::NDI_GREY); |
743 | $pl->ns->send_msg (tell_channel $tname, $emote{self}, cf::NDI_GREY | cf::NDI_REPLY); |
744 | $pl->send_msg (tell_channel $tname, $emote{self}, cf::NDI_GREY | cf::NDI_REPLY); |
744 | } else { |
745 | } else { |
745 | my %emote = %{ $emotes->{$emotion}->{noparams} || {} }; |
746 | my %emote = %{ $emotes->{$emotion}->{noparams} || {} }; |
746 | |
747 | |
747 | $emote{other} ||= "<self> dances with glee."; |
748 | $emote{other} ||= "<self> dances with glee."; |
748 | $emote{self} ||= "You are a nut."; |
749 | $emote{self} ||= "You are a nut."; |
749 | |
750 | |
750 | $emote{other} =~ s/<self>/$name/; |
751 | $emote{other} =~ s/<self>/$name/; |
751 | |
752 | |
752 | $_->ns->send_msg ($CHAT_CHANNEL, $emote{other}, cf::NDI_GREY) |
753 | $_->send_msg ($CHAT_CHANNEL, $emote{other}, cf::NDI_GREY) |
753 | for grep { $ob->on_same_map_as ($_->ob) && $_ != $pl } cf::player::list; |
754 | for grep { $ob->on_same_map_as ($_->ob) && $_ != $pl } cf::player::list; |
754 | |
755 | |
755 | $pl->ns->send_msg ($CHAT_CHANNEL, $emote{self}, cf::NDI_GREY | cf::NDI_REPLY); |
756 | $pl->send_msg ($CHAT_CHANNEL, $emote{self}, cf::NDI_GREY | cf::NDI_REPLY); |
756 | } |
757 | } |
757 | }; |
758 | }; |
758 | }; |
759 | }; |
759 | } |
760 | } |
760 | |
761 | |
761 | cf::register_command me => sub { |
762 | cf::register_command me => sub { |
762 | my ($pl, $msg) = @_; |
763 | my ($pl, $msg) = @_; |
763 | |
764 | |
764 | my $name = $pl->name; |
765 | my $name = $pl->name; |
765 | |
766 | |
766 | $_->ns->send_msg ($SAY_CHANNEL => "* $name $msg", cf::NDI_GREY | cf::NDI_DEF | ($_ == $pl ? cf::NDI_REPLY : 0)) |
767 | $_->send_msg ($SAY_CHANNEL => "* $name $msg", cf::NDI_GREY | cf::NDI_DEF | ($_ == $pl ? cf::NDI_REPLY : 0)) |
767 | for grep $pl->on_same_map_as ($_->ob), cf::player::list; |
768 | for grep $pl->on_same_map_as ($_->ob), cf::player::list; |
768 | }; |
769 | }; |
769 | |
770 | |
770 | cf::register_command say => sub { |
771 | cf::register_command say => sub { |
771 | my ($ob, $msg) = @_; |
772 | my ($ob, $msg) = @_; |
… | |
… | |
776 | |
777 | |
777 | if ($msg) { |
778 | if ($msg) { |
778 | my $name = $ob->name; |
779 | my $name = $ob->name; |
779 | my @plonmap = grep $ob->on_same_map_as ($_->ob), cf::player::list; |
780 | my @plonmap = grep $ob->on_same_map_as ($_->ob), cf::player::list; |
780 | |
781 | |
781 | $_->ns->send_msg ($SAY_CHANNEL => "$name says: $msg", cf::NDI_GREY | ($_ == $ob ? cf::NDI_REPLY : 0)) |
782 | $_->send_msg ($SAY_CHANNEL => "$name says: $msg", cf::NDI_GREY | ($_ == $ob->contr ? cf::NDI_REPLY : 0)) |
782 | for @plonmap; |
783 | for @plonmap; |
783 | |
784 | |
784 | # npcs, magic_ears etc. |
785 | # npcs, magic_ears etc. |
785 | # first find all objects and their first-level inventories |
786 | # first find all objects and their first-level inventories |
786 | # within a 5x5 square that have something resembling |
787 | # within a 5x5 square that have something resembling |
… | |
… | |
801 | my ($reply, @kw) = $dialog->tell ($msg); |
802 | my ($reply, @kw) = $dialog->tell ($msg); |
802 | |
803 | |
803 | if (defined $reply) { |
804 | if (defined $reply) { |
804 | if ($npc->type == cf::MAGIC_EAR) { |
805 | if ($npc->type == cf::MAGIC_EAR) { |
805 | if (length $reply) { |
806 | if (length $reply) { |
806 | $_->ns->send_msg ($SAY_CHANNEL => $reply, cf::NDI_BROWN) |
807 | $_->send_msg ($SAY_CHANNEL => $reply, cf::NDI_BROWN) |
807 | for @plonmap; |
808 | for @plonmap; |
808 | } |
809 | } |
809 | $npc->use_trigger; |
810 | $npc->use_trigger; |
810 | } else { |
811 | } else { |
811 | if (length $reply) { |
812 | if (length $reply) { |
812 | $_->ns->send_msg ($SAY_CHANNEL => $npc->name . " says: $reply", cf::NDI_BROWN) |
813 | $_->send_msg ($SAY_CHANNEL => $npc->name . " says: $reply", cf::NDI_BROWN) |
813 | for @plonmap; |
814 | for @plonmap; |
814 | } |
815 | } |
815 | } |
816 | } |
816 | } |
817 | } |
817 | |
818 | |
818 | if (@kw) { |
819 | if (@kw) { |
819 | $_->ns->send_msg ($SAY_CHANNEL => "[further topics: " . (join ", ", @kw) . "]", cf::NDI_BROWN) |
820 | $_->send_msg ($SAY_CHANNEL => "[further topics: " . (join ", ", @kw) . "]", cf::NDI_BROWN) |
820 | for @plonmap; |
821 | for @plonmap; |
821 | } |
822 | } |
822 | } |
823 | } |
823 | |
824 | |
824 | } else { |
825 | } else { |
825 | $ob->contr->ns->send_msg ($SAY_CHANNEL => "What do you want to say?", cf::NDI_GREY | cf::NDI_REPLY); |
826 | $ob->send_msg ($SAY_CHANNEL => "What do you want to say?", cf::NDI_GREY | cf::NDI_REPLY); |
826 | } |
827 | } |
827 | }; |
828 | }; |
828 | |
829 | |
829 | cf::register_command chat => sub { |
830 | cf::register_command chat => sub { |
830 | my ($ob, $msg) = @_; |
831 | my ($ob, $msg) = @_; |
… | |
… | |
840 | my $NOW = time; |
841 | my $NOW = time; |
841 | |
842 | |
842 | cf::LOG cf::llevDebug, sprintf "QBERT [%s] %s\n", $name, $msg; |
843 | cf::LOG cf::llevDebug, sprintf "QBERT [%s] %s\n", $name, $msg; |
843 | send_irc ("[%s] %s", $name, $msg); |
844 | send_irc ("[%s] %s", $name, $msg); |
844 | |
845 | |
845 | $_->ns->send_msg ($CHAT_CHANNEL => "$name chats: $msg", cf::NDI_BLUE | cf::NDI_DEF | ($_ == $pl ? cf::NDI_REPLY : 0)) |
846 | $_->send_msg ($CHAT_CHANNEL => "$name chats: $msg", cf::NDI_BLUE | cf::NDI_DEF | ($_ == $pl ? cf::NDI_REPLY : 0)) |
846 | for grep { $_->ob->{ext_ignore_shout}{$name} < $NOW && $_->listening >= 10 } cf::player::list; |
847 | for grep { $_->ob->{ext_ignore_shout}{$name} < $NOW && $_->listening >= 10 } cf::player::list; |
847 | |
848 | |
848 | } else { |
849 | } else { |
849 | $pl->ns->send_msg ($CHAT_CHANNEL => "Chat what?", cf::NDI_BLUE | cf::NDI_DEF | cf::NDI_REPLY); |
850 | $pl->send_msg ($CHAT_CHANNEL => "Chat what?", cf::NDI_BLUE | cf::NDI_DEF | cf::NDI_REPLY); |
850 | } |
851 | } |
851 | }; |
852 | }; |
852 | |
853 | |
853 | cf::register_command shout => sub { |
854 | cf::register_command shout => sub { |
854 | my ($ob, $msg) = @_; |
855 | my ($ob, $msg) = @_; |
… | |
… | |
864 | my $name = $ob->name; |
865 | my $name = $ob->name; |
865 | |
866 | |
866 | cf::LOG cf::llevDebug, sprintf "QBERT {%s} %s\n", $name, $msg; |
867 | cf::LOG cf::llevDebug, sprintf "QBERT {%s} %s\n", $name, $msg; |
867 | send_irc ("\007\0034{%s} %s\n", $name, $msg); |
868 | send_irc ("\007\0034{%s} %s\n", $name, $msg); |
868 | |
869 | |
869 | $_->ns->send_msg ($CHAT_CHANNEL => "$name shouts: $msg", cf::NDI_RED | cf::NDI_DEF | ($_ == $pl ? cf::NDI_REPLY : 0)) |
870 | $_->send_msg ($CHAT_CHANNEL => "$name shouts: $msg", cf::NDI_RED | cf::NDI_DEF | ($_ == $pl ? cf::NDI_REPLY : 0)) |
870 | for grep { $_->ob->{ext_ignore_shout}{$name} < $NOW && $_->listening >= 2 } cf::player::list; |
871 | for grep { $_->ob->{ext_ignore_shout}{$name} < $NOW && $_->listening >= 2 } cf::player::list; |
871 | |
872 | |
872 | } else { |
873 | } else { |
873 | $pl->ns->send_msg ($CHAT_CHANNEL => "Shout what?", cf::NDI_RED | cf::NDI_DEF | cf::NDI_REPLY); |
874 | $pl->send_msg ($CHAT_CHANNEL => "Shout what?", cf::NDI_RED | cf::NDI_DEF | cf::NDI_REPLY); |
874 | } |
875 | } |
875 | }; |
876 | }; |
876 | |
877 | |
877 | cf::register_command tell => sub { |
878 | cf::register_command tell => sub { |
878 | my ($ob, $args) = @_; |
879 | my ($ob, $args) = @_; |
… | |
… | |
905 | } else { |
906 | } else { |
906 | return if $other->invoke (cf::EVENT_PLAYER_TOLD, $pl, $msg); |
907 | return if $other->invoke (cf::EVENT_PLAYER_TOLD, $pl, $msg); |
907 | cf::LOG cf::llevDebug, sprintf "TELL [%s>%s] %s\n", $name, $target, $msg; |
908 | cf::LOG cf::llevDebug, sprintf "TELL [%s>%s] %s\n", $name, $target, $msg; |
908 | |
909 | |
909 | $ns->send_msg ($pl_channel => "You tell $target: $msg", cf::NDI_DK_ORANGE | cf::NDI_DEF | cf::NDI_REPLY); |
910 | $ns->send_msg ($pl_channel => "You tell $target: $msg", cf::NDI_DK_ORANGE | cf::NDI_DEF | cf::NDI_REPLY); |
910 | $other->ns->send_msg ($other_channel => "$name tells you: $msg", cf::NDI_DK_ORANGE | cf::NDI_DEF); |
911 | $other->send_msg ($other_channel => "$name tells you: $msg", cf::NDI_DK_ORANGE | cf::NDI_DEF); |
911 | } |
912 | } |
912 | } else { |
913 | } else { |
913 | $ns->send_msg ($pl_channel => "What do you want to tell $target?", cf::NDI_DK_ORANGE | cf::NDI_DEF | cf::NDI_REPLY); |
914 | $ns->send_msg ($pl_channel => "What do you want to tell $target?", cf::NDI_DK_ORANGE | cf::NDI_DEF | cf::NDI_REPLY); |
914 | } |
915 | } |
915 | |
916 | |