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