ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/ext/chat.ext
(Generate patch)

Comparing deliantra/server/ext/chat.ext (file contents):
Revision 1.45 by root, Tue Sep 23 00:24:52 2008 UTC vs.
Revision 1.53 by root, Wed Apr 21 06:11:37 2010 UTC

218 }, 218 },
219 }, 219 },
220 kiss => { 220 kiss => {
221 noparams => { 221 noparams => {
222 other => "<self> makes a weird facial contortion", 222 other => "<self> makes a weird facial contortion",
223 self => "All the lonely people..", 223 self => "All the lonely people...",
224 }, 224 },
225 params => { 225 params => {
226 target => "<self> kisses you.", 226 target => "<self> kisses you.",
227 other => "<self> kisses <other>.", 227 other => "<self> kisses <other>.",
228 self => "You kiss <other>.", 228 self => "You kiss <other>.",
229 }, 229 },
230 self => { 230 self => {
231 }, 231 },
232 }, 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 },
233 smother => { 248 smother => {
234 noparams => { 249 noparams => {
235 other => "<self> makes weird facial contortions", 250 other => "<self> makes weird facial contortions",
236 self => "All the lonely people..", 251 self => "All the lonely people...",
237 }, 252 },
238 params => { 253 params => {
239 target => "<self> smothers you with kisses.", 254 target => "<self> smothers you with kisses.",
240 other => "<self> smothers <other> with kisses.", 255 other => "<self> smothers <other> with kisses.",
241 self => "You smother <other> with kisses.", 256 self => "You smother <other> with kisses.",
760 } 775 }
761 }; 776 };
762 }; 777 };
763} 778}
764 779
765cf::register_command me => sub {
766 my ($pl, $msg) = @_;
767
768 my $name = $pl->name;
769
770 send_msg $_, $cf::SAY_CHANNEL => "* $name $msg", cf::NDI_GREY | cf::NDI_DEF | ($_ == $pl ? cf::NDI_REPLY : 0), "msg_say"
771 for grep $pl->on_same_map_as ($_->ob), cf::player::list;
772};
773
774cf::register_command say => sub { 780cf::register_command say => sub {
775 my ($ob, $msg) = @_; 781 my ($ob, $msg) = @_;
776 782
777 utf8::decode $msg; 783 utf8::decode $msg;
778 784
783 my @plonmap = grep $ob->on_same_map_as ($_->ob), cf::player::list; 789 my @plonmap = grep $ob->on_same_map_as ($_->ob), cf::player::list;
784 790
785 send_msg $_, $cf::SAY_CHANNEL => "$name says: $msg", cf::NDI_GREY, "msg_say" 791 send_msg $_, $cf::SAY_CHANNEL => "$name says: $msg", cf::NDI_GREY, "msg_say"
786 for grep $_ != $ob->contr, @plonmap; 792 for grep $_ != $ob->contr, @plonmap;
787 $ob->contr->send_msg ($cf::SAY_CHANNEL => "$name says: $msg", cf::NDI_GREY | cf::NDI_REPLY); 793 $ob->contr->send_msg ($cf::SAY_CHANNEL => "$name says: $msg", cf::NDI_GREY | cf::NDI_REPLY);
794
795 my @npc;
788 796
789 # npcs, magic_ears etc. 797 # npcs, magic_ears etc.
790 # first find all objects and their first-level inventories 798 # first find all objects and their first-level inventories
791 # within a 5x5 square that have something resembling 799 # within a 5x5 square that have something resembling
792 # dialogue or support on_say. 800 # dialogue or support on_say.
801 # we prefer the nearest items NOT in the player, otherwise in player.
793 my ($map, $x, $y) = ($ob->map, $ob->x - 2, $ob->y - 2); 802 my ($map, $x, $y) = ($ob->map, $ob->x, $ob->y);
794 803
795 for my $npc ( 804 for my $dir (
796 grep +($_->invoke (cf::EVENT_OBJECT_SAY, $ob->contr, $msg) && return) || $_->has_dialogue, 805 0,
797 map +($_, $_->inv), 806 1, 3, 5, 7,
798 grep $_, 807 2, 4, 6, 8,
799 map $map->at ($x + $_ % 5, $y + (int $_ / 5)), 808 9 .. cf::SIZEOFFREE2
800 0..24
801 ) { 809 ) {
810 @npc = grep $_->should_invoke (cf::EVENT_OBJECT_SAY) || $_->has_dialogue,
811 map +($_, $_->inv),
812 grep $_ != $ob,
813 $map->at ($x, $y, $dir)
814 and last;
815 }
816
817 unless (@npc) {
818 # nothing found, try the player inventory
819 @npc = grep $_->should_invoke (cf::EVENT_OBJECT_SAY) || $_->has_dialogue,
820 $ob->inv;
821 }
822
823 for my $npc (@npc) {
824 return if $npc->invoke (cf::EVENT_OBJECT_SAY);
825
802 # if some listener teleported us somewhere else, stop right here 826 # if some listener teleported us somewhere else, stop right here
803 last unless $map->path == $ob->map->path; 827 last unless $map->path == $ob->map->path;
804 828
829 if ($npc->has_dialogue) {
805 my $dialog = new NPC_Dialogue pl => $ob->contr, npc => $npc; 830 my $dialog = new NPC_Dialogue pl => $ob->contr, npc => $npc;
806 my ($reply, @kw) = $dialog->tell ($msg); 831 my ($reply, @kw) = $dialog->tell ($msg);
807 832
808 if (defined $reply) { 833 if (defined $reply) {
809 if ($npc->type == cf::MAGIC_EAR) { 834 if ($npc->type == cf::MAGIC_EAR) {
810 if (length $reply) {
811 send_msg $_, $cf::SAY_CHANNEL => $reply, cf::NDI_BROWN, "msg_say" 835 send_msg $_, $cf::SAY_CHANNEL => $reply, cf::NDI_BROWN, "msg_say"
812 for @plonmap; 836 for @plonmap;
813 }
814 $npc->use_trigger;
815 } else { 837 } else {
816 if (length $reply) {
817 send_msg $_, $cf::SAY_CHANNEL => $npc->name . " says: $reply", cf::NDI_BROWN, "msg_say" 838 send_msg $_, $cf::SAY_CHANNEL => $npc->name . " says: $reply", cf::NDI_BROWN, "msg_say"
818 for @plonmap; 839 for @plonmap;
819 } 840 }
820 } 841 }
821 }
822 842
823 if (@kw) { 843 if (@kw) {
824 $_->send_msg ($cf::SAY_CHANNEL => "[further topics: " . (join ", ", @kw) . "]", cf::NDI_BROWN) 844 $_->send_msg ($cf::SAY_CHANNEL => "[further topics: " . (join ", ", @kw) . "]", cf::NDI_BROWN)
825 for @plonmap; 845 for @plonmap;
846 }
826 } 847 }
827 } 848 }
828 849
829 } else { 850 } else {
830 $ob->send_msg ($cf::SAY_CHANNEL => "What do you want to say?", cf::NDI_GREY | cf::NDI_REPLY); 851 $ob->send_msg ($cf::SAY_CHANNEL => "What do you want to say?", cf::NDI_GREY | cf::NDI_REPLY);
831 } 852 }
832}; 853};
833 854
834cf::register_command chat => sub { 855
856sub _chat {
835 my ($ob, $msg) = @_; 857 my ($ob, $msg) = @_;
836
837 utf8::decode $msg;
838 858
839 my $pl = $ob->contr; 859 my $pl = $ob->contr;
840 860
841 return if $pl->invoke (cf::EVENT_PLAYER_CHAT, $msg); 861 return if $pl->invoke (cf::EVENT_PLAYER_CHAT, $msg);
842 862
843 if ($msg) { 863 if ($msg) {
844 my $name = $ob->name; 864 my $name = $ob->name;
845 my $NOW = time; 865 my $NOW = time;
846 866
847 cf::LOG cf::llevDebug, sprintf "QBERT [%s] %s\n", $name, $msg; 867 cf::LOG cf::llevDebug, sprintf "QBERT %s\n", $msg;
848 send_irc ("[%s] %s", $name, $msg); 868 send_irc ("%s", $msg);
849 869
850 send_msg $_, $cf::CHAT_CHANNEL => "$name chats: $msg", cf::NDI_BLUE | cf::NDI_DEF | ($_ == $pl ? cf::NDI_REPLY : 0), "msg_chat" 870 send_msg $_, $cf::CHAT_CHANNEL => $msg, cf::NDI_BLUE | cf::NDI_DEF | ($_ == $pl ? cf::NDI_REPLY : 0), "msg_chat"
851 for grep { $_->ob->{ext_ignore_shout}{$name} < $NOW } cf::player::list; 871 for grep { $_->ob->{ext_ignore_shout}{$name} < $NOW } cf::player::list;
852 872
853 } else { 873 } else {
854 $pl->send_msg ($cf::CHAT_CHANNEL => "Chat what?", cf::NDI_BLUE | cf::NDI_DEF | cf::NDI_REPLY); 874 $pl->send_msg ($cf::CHAT_CHANNEL => "Chat what?", cf::NDI_BLUE | cf::NDI_DEF | cf::NDI_REPLY);
855 } 875 }
876}
877
878cf::register_command chat => sub {
879 my ($ob, $msg) = @_;
880
881 utf8::decode $msg;
882 _chat $ob, $ob->name . " chats: $msg";
883};
884
885cf::register_command me => sub {
886 my ($ob, $msg) = @_;
887
888 utf8::decode $msg;
889 _chat $ob, "* " . $ob->name . " $msg";
856}; 890};
857 891
858cf::register_command shout => sub { 892cf::register_command shout => sub {
859 my ($ob, $msg) = @_; 893 my ($ob, $msg) = @_;
860 894

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines