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.14 by root, Tue Apr 24 18:24:31 2007 UTC vs.
Revision 1.18 by root, Mon Jun 11 22:18:03 2007 UTC

1#! perl 1#! perl # depends=irc
2#CONVERSION: PARTIAL 2#CONVERSION: PARTIAL
3 3
4# implement a replacement for the built-in say/chat/shout/tell/reply commands 4# implement a replacement for the built-in say/chat/shout/tell/reply commands
5# adds ignore/unignore functionality 5# adds ignore/unignore functionality
6 6
764 return if $pl->contr->invoke (cf::EVENT_PLAYER_SAY, $msg); 764 return if $pl->contr->invoke (cf::EVENT_PLAYER_SAY, $msg);
765 765
766 if ($msg) { 766 if ($msg) {
767 my $name = $pl->name; 767 my $name = $pl->name;
768 768
769 utf8::encode $msg; # ->message not yet utf8-ified
770 $_->ob->message ("$name says: $msg", cf::NDI_GREY | cf::NDI_UNIQUE) 769 $_->ob->message ("$name says: $msg", cf::NDI_GREY | cf::NDI_UNIQUE)
771 for grep $pl->on_same_map_as ($_->ob), cf::player::list; 770 for grep $pl->on_same_map_as ($_->ob), cf::player::list;
772 utf8::decode $msg;
773 771
774 # npcs, magic_ears etc. 772 # npcs, magic_ears etc.
775 # first find all objects and theirt-level inventories 773 # first find all objects and their first-level inventories
776 # within a 5x5 square # that have something resembling 774 # within a 5x5 square that have something resembling
777 # dialogue or support on_say. 775 # dialogue or support on_say.
778 my ($map, $x, $y) = ($pl->map, $pl->x - 2, $pl->y - 2); 776 my ($map, $x, $y) = ($pl->map, $pl->x - 2, $pl->y - 2);
779 777
780 for my $npc ( 778 for my $npc (
781 grep +($_->invoke (cf::EVENT_OBJECT_SAY, $pl->contr, $msg) && return) || NPC_Dialogue::has_dialogue $_, 779 grep +($_->invoke (cf::EVENT_OBJECT_SAY, $pl->contr, $msg) && return) || NPC_Dialogue::has_dialogue $_,
825 823
826 if ($msg) { 824 if ($msg) {
827 my $name = $pl->name; 825 my $name = $pl->name;
828 my $NOW = time; 826 my $NOW = time;
829 827
830 utf8::encode $msg; # ->message not yet utf8-ified
831 cf::LOG cf::llevDebug, sprintf "QBERT [%s] %s\n", $name, $msg; 828 cf::LOG cf::llevDebug, sprintf "QBERT [%s] %s\n", $name, $msg;
832 ext::schmorp_irc::do_notice (sprintf "[%s] %s", $name, $msg); 829 ext::irc::do_notice (sprintf "[%s] %s", $name, $msg);
833 830
834 $_->ob->message ("$name chats: $msg", cf::NDI_BLUE) 831 $_->ob->message ("$name chats: $msg", cf::NDI_BLUE)
835 for grep { $_->ob->{ext_ignore_shout}{$name} < $NOW && $_->listening >= 10 } cf::player::list; 832 for grep { $_->ob->{ext_ignore_shout}{$name} < $NOW && $_->listening >= 10 } cf::player::list;
836 833
837 } else { 834 } else {
849 if ($msg) { 846 if ($msg) {
850 my $NOW = time; 847 my $NOW = time;
851 my $name = $pl->name; 848 my $name = $pl->name;
852 849
853 cf::LOG cf::llevDebug, sprintf "QBERT {%s} %s\n", $name, $msg; 850 cf::LOG cf::llevDebug, sprintf "QBERT {%s} %s\n", $name, $msg;
854 ext::schmorp_irc::do_notice (sprintf "\007\0034{%s} %s\n", $name, $msg); 851 ext::irc::do_notice (sprintf "\007\0034{%s} %s\n", $name, $msg);
855 852
856 utf8::encode $msg; # ->message not yet utf8-ified
857 $_->ob->message ("$name shouts: $msg", cf::NDI_RED) 853 $_->ob->message ("$name shouts: $msg", cf::NDI_RED)
858 for grep { $_->ob->{ext_ignore_shout}{$name} < $NOW && $_->listening >= 2 } cf::player::list; 854 for grep { $_->ob->{ext_ignore_shout}{$name} < $NOW && $_->listening >= 2 } cf::player::list;
859 855
860 } else { 856 } else {
861 $pl->message ("Shout what?", cf::NDI_UNIQUE); 857 $pl->message ("Shout what?", cf::NDI_UNIQUE);
873 my $name = $pl->name; 869 my $name = $pl->name;
874 870
875 if ($target =~ /irc\//) { 871 if ($target =~ /irc\//) {
876 my (undef, $nick) = split /\//, $target, 2; 872 my (undef, $nick) = split /\//, $target, 2;
877 $pl->message ("You tell $target: $args"); 873 $pl->message ("You tell $target: $args");
878 ext::schmorp_irc::do_notice (sprintf "(%s) %s: %s\n", $name, $nick, $msg); 874 ext::irc::do_notice (sprintf "(%s) %s: %s\n", $name, $nick, $msg);
879 } elsif (my $other = cf::player::find_active $target) { 875 } elsif (my $other = cf::player::find_active $target) {
880 876
881 if ($msg) { 877 if ($msg) {
882 if ($target eq $name) { 878 if ($target eq $name) {
883 $pl->message ("You are talking to yourself, you freak!", cf::NDI_UNIQUE); 879 $pl->message ("You are talking to yourself, you freak!", cf::NDI_UNIQUE);
884 } elsif ($other->ob->{ext_ignore_tell}{$name} >= time) { 880 } elsif ($other->ob->{ext_ignore_tell}{$name} >= time) {
885 $pl->message ("$target ignores what you say. Give up on it.", cf::NDI_UNIQUE); 881 $pl->message ("$target ignores what you say. Give up on it.", cf::NDI_UNIQUE);
886 } else { 882 } else {
887 return if $other->invoke (cf::EVENT_PLAYER_TOLD, $pl->contr, $msg); 883 return if $other->invoke (cf::EVENT_PLAYER_TOLD, $pl->contr, $msg);
888 utf8::encode $msg; # ->message not yet utf8-ified
889 cf::LOG cf::llevDebug, sprintf "TELL [%s>%s] %s\n", $name, $target, $msg; 884 cf::LOG cf::llevDebug, sprintf "TELL [%s>%s] %s\n", $name, $target, $msg;
890 885
891 $pl->message ("You tell $target: $msg"); 886 $pl->message ("You tell $target: $msg");
892 $other->ob->message ("$name tells you: $msg"); 887 $other->ob->message ("$name tells you: $msg");
893 $other->ob->{ext_last_tell} = $name; 888 $other->ob->{ext_last_tell} = $name;
910 return if $pl->contr->invoke (cf::EVENT_PLAYER_TELL, $pl->{ext_last_tell}, $args); 905 return if $pl->contr->invoke (cf::EVENT_PLAYER_TELL, $pl->{ext_last_tell}, $args);
911 906
912 if ($pl->{ext_last_tell} =~ /irc\//) { 907 if ($pl->{ext_last_tell} =~ /irc\//) {
913 my (undef, $nick) = split /\//, $pl->{ext_last_tell}, 2; 908 my (undef, $nick) = split /\//, $pl->{ext_last_tell}, 2;
914 $pl->message ("You tell " . $pl->{ext_last_tell} . ": $args"); 909 $pl->message ("You tell " . $pl->{ext_last_tell} . ": $args");
915 ext::schmorp_irc::do_notice (sprintf "(%s) %s: %s\n", $name, $nick, $args); 910 ext::irc::do_notice (sprintf "(%s) %s: %s\n", $name, $nick, $args);
916 } elsif (my $other = cf::player::find_active $pl->{ext_last_tell}) { 911 } elsif (my $other = cf::player::find_active $pl->{ext_last_tell}) {
917 912
918 if ($args) { 913 if ($args) {
919 $other->ob->{ext_ignore_tell}{$name} >= time 914 $other->ob->{ext_ignore_tell}{$name} >= time
920 or delete $other->ob->{ext_ignore_tell}{$name}; 915 or delete $other->ob->{ext_ignore_tell}{$name};
921 916
922 if ($other->ob->{ext_ignore_tell}{$name} < time) { 917 if ($other->ob->{ext_ignore_tell}{$name} < time) {
923 utf8::encode $args; # ->message not yet utf8-ified
924 cf::LOG cf::llevDebug, sprintf "TELL [%s>%s] %s\n", $name, $other->ob->name, $args; 918 cf::LOG cf::llevDebug, sprintf "TELL [%s>%s] %s\n", $name, $other->ob->name, $args;
925 919
926 $pl->message ("You tell " . $other->ob->name . ": $args"); 920 $pl->message ("You tell " . $other->ob->name . ": $args");
927 $other->ob->message ("$name tells you: $args"); 921 $other->ob->message ("$name tells you: $args");
928 $pl->{ext_last_tell} = $other->ob->name; 922 $pl->{ext_last_tell} = $other->ob->name;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines