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.22 by root, Sun Jul 22 14:17:57 2007 UTC vs.
Revision 1.23 by root, Sun Jul 22 17:10:05 2007 UTC

772 $_->ns->send_msg ($SAY_CHANNEL => "* $name $msg", cf::NDI_GREY, $_ == $pl ? (reply => 1) : ()) 772 $_->ns->send_msg ($SAY_CHANNEL => "* $name $msg", cf::NDI_GREY, $_ == $pl ? (reply => 1) : ())
773 for grep $pl->on_same_map_as ($_->ob), cf::player::list; 773 for grep $pl->on_same_map_as ($_->ob), cf::player::list;
774}; 774};
775 775
776cf::register_command say => sub { 776cf::register_command say => sub {
777 my ($pl, $msg) = @_; 777 my ($ob, $msg) = @_;
778 778
779 utf8::decode $msg; 779 utf8::decode $msg;
780 780
781 return if $pl->contr->invoke (cf::EVENT_PLAYER_SAY, $msg); 781 return if $ob->contr->invoke (cf::EVENT_PLAYER_SAY, $msg);
782 782
783 if ($msg) { 783 if ($msg) {
784 my $name = $pl->name; 784 my $name = $ob->name;
785 my @plonmap = grep $pl->on_same_map_as ($_->ob), cf::player::list; 785 my @plonmap = grep $ob->on_same_map_as ($_->ob), cf::player::list;
786 786
787 $_->ns->send_msg ($SAY_CHANNEL => "$name says: $msg", cf::NDI_GREY, $_ == $pl ? (reply => 1) : ()) 787 $_->ns->send_msg ($SAY_CHANNEL => "$name says: $msg", cf::NDI_GREY, $_ == $ob ? (reply => 1) : ())
788 for @plonmap; 788 for @plonmap;
789 789
790 # npcs, magic_ears etc. 790 # npcs, magic_ears etc.
791 # first find all objects and their first-level inventories 791 # first find all objects and their first-level inventories
792 # within a 5x5 square that have something resembling 792 # within a 5x5 square that have something resembling
793 # dialogue or support on_say. 793 # dialogue or support on_say.
794 my ($map, $x, $y) = ($pl->map, $pl->x - 2, $pl->y - 2); 794 my ($map, $x, $y) = ($ob->map, $ob->x - 2, $ob->y - 2);
795 795
796 for my $npc ( 796 for my $npc (
797 grep +($_->invoke (cf::EVENT_OBJECT_SAY, $pl->contr, $msg) && return) || NPC_Dialogue::has_dialogue $_, 797 grep +($_->invoke (cf::EVENT_OBJECT_SAY, $ob->contr, $msg) && return) || NPC_Dialogue::has_dialogue $_,
798 map +($_, $_->inv), 798 map +($_, $_->inv),
799 grep $_, 799 grep $_,
800 map $map->at ($x + $_ % 5, $y + (int $_ / 5)), 800 map $map->at ($x + $_ % 5, $y + (int $_ / 5)),
801 0..24 801 0..24
802 ) { 802 ) {
803 # if some listener teleported us somewhere else, stop right here 803 # if some listener teleported us somewhere else, stop right here
804 last unless $map->path == $pl->map->path; 804 last unless $map->path == $ob->map->path;
805 805
806 my $dialog = new NPC_Dialogue pl => $pl->contr, npc => $npc; 806 my $dialog = new NPC_Dialogue pl => $ob->contr, npc => $npc;
807 my ($reply, @kw) = $dialog->tell ($msg); 807 my ($reply, @kw) = $dialog->tell ($msg);
808 808
809 if (defined $reply) { 809 if (defined $reply) {
810 if ($npc->type == cf::MAGIC_EAR) { 810 if ($npc->type == cf::MAGIC_EAR) {
811 if (length $reply) { 811 if (length $reply) {
812 $_->contr->send_msg ($SAY_CHANNEL => $reply, cf::NDI_BROWN) 812 $_->ns->send_msg ($SAY_CHANNEL => $reply, cf::NDI_BROWN)
813 for @plonmap; 813 for @plonmap;
814 } 814 }
815 $npc->use_trigger; 815 $npc->use_trigger;
816 } else { 816 } else {
817 if (length $reply) { 817 if (length $reply) {
818 $_->contr->send_msg ($SAY_CHANNEL => $npc->name . " says: $reply", cf::NDI_BROWN) 818 $_->ns->send_msg ($SAY_CHANNEL => $npc->name . " says: $reply", cf::NDI_BROWN)
819 for @plonmap; 819 for @plonmap;
820 } 820 }
821 } 821 }
822 } 822 }
823 823
824 if (@kw) { 824 if (@kw) {
825 $_->contr->send_msg ($SAY_CHANNEL => "[further topics: " . (join ", ", @kw) . "]", cf::NDI_BROWN) 825 $_->ns->send_msg ($SAY_CHANNEL => "[further topics: " . (join ", ", @kw) . "]", cf::NDI_BROWN)
826 for @plonmap; 826 for @plonmap;
827 } 827 }
828 } 828 }
829 829
830 } else { 830 } else {
831 $pl->contr->send_msg ($SAY_CHANNEL => "What do you want to say?", 0, reply => 1); 831 $ob->contr->send_msg ($SAY_CHANNEL => "What do you want to say?", 0, reply => 1);
832 } 832 }
833}; 833};
834 834
835cf::register_command chat => sub { 835cf::register_command chat => sub {
836 my ($pl, $msg) = @_; 836 my ($pl, $msg) = @_;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines