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.27 by root, Tue Jul 24 16:42:35 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->ns->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 ($ob, $msg) = @_;
837 837
838 utf8::decode $msg; 838 utf8::decode $msg;
839 839
840 my $pl = $ob->contr;
841
840 return if $pl->contr->invoke (cf::EVENT_PLAYER_CHAT, $msg); 842 return if $pl->invoke (cf::EVENT_PLAYER_CHAT, $msg);
841 843
842 if ($msg) { 844 if ($msg) {
843 my $name = $pl->name; 845 my $name = $pl->name;
844 my $NOW = time; 846 my $NOW = time;
845 847
857cf::register_command shout => sub { 859cf::register_command shout => sub {
858 my ($pl, $msg) = @_; 860 my ($pl, $msg) = @_;
859 861
860 utf8::decode $msg; 862 utf8::decode $msg;
861 863
864 my $pl = $ob->contr;
865
862 return if $pl->contr->invoke (cf::EVENT_PLAYER_SHOUT, $msg); 866 return if $pl->invoke (cf::EVENT_PLAYER_SHOUT, $msg);
863 867
864 if ($msg) { 868 if ($msg) {
865 my $NOW = time; 869 my $NOW = time;
866 my $name = $pl->name; 870 my $name = $pl->name;
867 871
868 cf::LOG cf::llevDebug, sprintf "QBERT {%s} %s\n", $name, $msg; 872 cf::LOG cf::llevDebug, sprintf "QBERT {%s} %s\n", $name, $msg;
869 send_irc ("\007\0034{%s} %s\n", $name, $msg); 873 send_irc ("\007\0034{%s} %s\n", $name, $msg);
870 874
871 $_->ns->send_msg ($CHAT_CHANNEL => "$name shouts: $msg", cf::NDI_BLUE, $_ == $pl ? (reply => 1) : ()) 875 $_->ns->send_msg ($CHAT_CHANNEL => "$name shouts: $msg", cf::NDI_RED, $_ == $pl ? (reply => 1) : ())
872 for grep { $_->ob->{ext_ignore_shout}{$name} < $NOW && $_->listening >= 2 } cf::player::list; 876 for grep { $_->ob->{ext_ignore_shout}{$name} < $NOW && $_->listening >= 2 } cf::player::list;
873 877
874 } else { 878 } else {
875 $pl->ns->send_msg ($CHAT_CHANNEL => "Shout what?"); 879 $pl->ns->send_msg ($CHAT_CHANNEL => "Shout what?");
876 } 880 }
912 if ($target eq $name) { 916 if ($target eq $name) {
913 $ns->send_msg ($pl_channel => "You are talking to yourself, you freak!", reply => 1); 917 $ns->send_msg ($pl_channel => "You are talking to yourself, you freak!", reply => 1);
914 } elsif ($other->ob->{ext_ignore_tell}{$name} >= time) { 918 } elsif ($other->ob->{ext_ignore_tell}{$name} >= time) {
915 $ns->send_msg ($pl_channel => "$target ignores what you say. Give up on it.", reply => 1); 919 $ns->send_msg ($pl_channel => "$target ignores what you say. Give up on it.", reply => 1);
916 } else { 920 } else {
917 return if $other->invoke (cf::EVENT_PLAYER_TOLD, $pl->contr, $msg); 921 return if $other->invoke (cf::EVENT_PLAYER_TOLD, $pl, $msg);
918 cf::LOG cf::llevDebug, sprintf "TELL [%s>%s] %s\n", $name, $target, $msg; 922 cf::LOG cf::llevDebug, sprintf "TELL [%s>%s] %s\n", $name, $target, $msg;
919 923
920 $ns->send_msg ($pl_channel => "You tell $target: $msg", reply => 1); 924 $ns->send_msg ($pl_channel => "You tell $target: $msg", reply => 1);
921 $other->ns->send_msg ($other_channel => "$name tells you: $msg"); 925 $other->ns->send_msg ($other_channel => "$name tells you: $msg");
922 } 926 }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines