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.33 by root, Wed Sep 19 21:56:30 2007 UTC vs.
Revision 1.34 by root, Sat Oct 20 05:07:19 2007 UTC

27 id => "tell-$target", 27 id => "tell-$target",
28 title => "$target", 28 title => "$target",
29 reply => "tell $target ", 29 reply => "tell $target ",
30 tooltip => "Private messages from/to $target", 30 tooltip => "Private messages from/to $target",
31 } 31 }
32}
33
34sub send_msg($$$$$) {
35 my ($pl, $channel, $msg, $flags, $sound) = @_;
36 $pl->play_sound (cf::sound::find $sound) if defined $sound;
37 $pl->send_msg ($channel, $msg, $flags);
38 ()
32} 39}
33 40
34sub clean_timeouts($) { 41sub clean_timeouts($) {
35 my ($player) = @_; 42 my ($player) = @_;
36 my $NOW = time; 43 my $NOW = time;
95 my $pl = $ob->contr; 102 my $pl = $ob->contr;
96 my $name = $ob->name; 103 my $name = $ob->name;
97 104
98 my $coin = int rand 2 ? "Heads" : "Tails"; 105 my $coin = int rand 2 ? "Heads" : "Tails";
99 106
100 $_->send_msg ($SAY_CHANNEL => "$name flips a coin.... $coin!", cf::NDI_GREY) 107 send_msg $_, $SAY_CHANNEL => "$name flips a coin.... $coin!", cf::NDI_GREY, "msg_say"
101 for grep { $ob->on_same_map_as ($_->ob) && $_ != $pl} cf::player::list; 108 for grep { $ob->on_same_map_as ($_->ob) && $_ != $pl} cf::player::list;
102 109
103 $pl->send_msg ($SAY_CHANNEL => "You flip a coin.... $coin!", cf::NDI_GREY | cf::NDI_REPLY); 110 $pl->send_msg ($SAY_CHANNEL => "You flip a coin.... $coin!", cf::NDI_GREY | cf::NDI_REPLY);
104}; 111};
105 112
111 118
112 my @orcknuckle = ("beholder", "ghost", "knight", "princess", "dragon", "orc"); 119 my @orcknuckle = ("beholder", "ghost", "knight", "princess", "dragon", "orc");
113 my ($i, $j, $k, $l) = (rand 5, rand 5, rand 5, rand 6); 120 my ($i, $j, $k, $l) = (rand 5, rand 5, rand 5, rand 6);
114 my $result = "$orcknuckle[$i], $orcknuckle[$j], $orcknuckle[$k], $orcknuckle[$l]"; 121 my $result = "$orcknuckle[$i], $orcknuckle[$j], $orcknuckle[$k], $orcknuckle[$l]";
115 122
116 $_->send_msg ($SAY_CHANNEL => "$name throws his orc-knuckles and rolls $result!", cf::NDI_GREY) 123 send_msg $_, $SAY_CHANNEL => "$name throws his orc-knuckles and rolls $result!", cf::NDI_GREY, "msg_say"
117 for grep { $ob->on_same_map_as ($_->ob) && $_ != $pl} cf::player::list; 124 for grep { $ob->on_same_map_as ($_->ob) && $_ != $pl} cf::player::list;
118 125
119 $pl->send_msg ($SAY_CHANNEL => "You roll $result!", cf::NDI_GREY | cf::NDI_REPLY); 126 $pl->send_msg ($SAY_CHANNEL => "You roll $result!", cf::NDI_GREY | cf::NDI_REPLY);
120}; 127};
121 128
717 $emote{other} ||= "You look away from <self>."; 724 $emote{other} ||= "You look away from <self>.";
718 $emote{self} ||= "My god! Is that LEGAL?"; 725 $emote{self} ||= "My god! Is that LEGAL?";
719 726
720 $emote{other} =~ s/<self>/$name/; 727 $emote{other} =~ s/<self>/$name/;
721 728
722 $_->send_msg ($CHAT_CHANNEL, $emote{other}, cf::NDI_GREY) 729 send_msg $_, $CHAT_CHANNEL, $emote{other}, cf::NDI_GREY, "msg_chat"
723 for grep { $ob->on_same_map_as ($_->ob) && $_ != $ob} cf::player::list; 730 for grep { $ob->on_same_map_as ($_->ob) && $_ != $ob} cf::player::list;
724 731
725 $pl->send_msg ($emote{self}, cf::NDI_GREY | cf::NDI_REPLY); 732 $pl->send_msg ($emote{self}, cf::NDI_GREY | cf::NDI_REPLY);
726 } elsif ($tname) { 733 } elsif ($tname) {
727 my $target = cf::player::find $tname 734 my $target = cf::player::find $tname
728 or return $pl->send_msg (tell_channel $tname, "$tname is not around.", cf::NDI_DK_ORANGE | cf::NDI_REPLY); 735 or return send_msg $pl, tell_channel $tname, "$tname is not around.", cf::NDI_DK_ORANGE | cf::NDI_REPLY, "msg_chat";
729 736
730 my %emote = %{ $emotes->{$emotion}->{params} || {} }; 737 my %emote = %{ $emotes->{$emotion}->{params} || {} };
731 738
732 $emote{other} ||= "<self> is eyeing <other> quizzically."; 739 $emote{other} ||= "<self> is eyeing <other> quizzically.";
733 $emote{self} ||= "You are still nuts."; 740 $emote{self} ||= "You are still nuts.";
736 $emote{self} =~ s/<other>/$tname/; 743 $emote{self} =~ s/<other>/$tname/;
737 $emote{target} =~ s/<self>/$name/; 744 $emote{target} =~ s/<self>/$name/;
738 $emote{other} =~ s/<other>/$tname/; 745 $emote{other} =~ s/<other>/$tname/;
739 $emote{other} =~ s/<self>/$name/; 746 $emote{other} =~ s/<self>/$name/;
740 747
741 $_->send_msg ($CHAT_CHANNEL, $emote{other}, cf::NDI_GREY) 748 send_msg $_, $CHAT_CHANNEL, $emote{other}, cf::NDI_GREY, "msg_chat"
742 for grep { $_ != $pl && $_ != $target && $ob->on_same_map_as ($_->ob) } cf::player::list; 749 for grep { $_ != $pl && $_ != $target && $ob->on_same_map_as ($_->ob) } cf::player::list;
743 750
744 $target->send_msg (tell_channel $name, $emote{target}, cf::NDI_GREY); 751 send_msg $target, tell_channel $name, $emote{target}, cf::NDI_GREY, "msg_shout";
745 $pl->send_msg (tell_channel $tname, $emote{self}, cf::NDI_GREY | cf::NDI_REPLY); 752 $pl->send_msg (tell_channel $tname, $emote{self}, cf::NDI_GREY | cf::NDI_REPLY);
746 } else { 753 } else {
747 my %emote = %{ $emotes->{$emotion}->{noparams} || {} }; 754 my %emote = %{ $emotes->{$emotion}->{noparams} || {} };
748 755
749 $emote{other} ||= "<self> dances with glee."; 756 $emote{other} ||= "<self> dances with glee.";
750 $emote{self} ||= "You are a nut."; 757 $emote{self} ||= "You are a nut.";
751 758
752 $emote{other} =~ s/<self>/$name/; 759 $emote{other} =~ s/<self>/$name/;
753 760
754 $_->send_msg ($CHAT_CHANNEL, $emote{other}, cf::NDI_GREY) 761 send_msg $_, $CHAT_CHANNEL, $emote{other}, cf::NDI_GREY, "msg_chat"
755 for grep { $ob->on_same_map_as ($_->ob) && $_ != $pl } cf::player::list; 762 for grep { $ob->on_same_map_as ($_->ob) && $_ != $pl } cf::player::list;
756 763
757 $pl->send_msg ($CHAT_CHANNEL, $emote{self}, cf::NDI_GREY | cf::NDI_REPLY); 764 $pl->send_msg ($CHAT_CHANNEL, $emote{self}, cf::NDI_GREY | cf::NDI_REPLY);
758 } 765 }
759 }; 766 };
763cf::register_command me => sub { 770cf::register_command me => sub {
764 my ($pl, $msg) = @_; 771 my ($pl, $msg) = @_;
765 772
766 my $name = $pl->name; 773 my $name = $pl->name;
767 774
768 $_->send_msg ($SAY_CHANNEL => "* $name $msg", cf::NDI_GREY | cf::NDI_DEF | ($_ == $pl ? cf::NDI_REPLY : 0)) 775 send_msg $pl, $SAY_CHANNEL => "* $name $msg", cf::NDI_GREY | cf::NDI_DEF | ($_ == $pl ? cf::NDI_REPLY : 0), "msg_say"
769 for grep $pl->on_same_map_as ($_->ob), cf::player::list; 776 for grep $pl->on_same_map_as ($_->ob), cf::player::list;
770}; 777};
771 778
772cf::register_command say => sub { 779cf::register_command say => sub {
773 my ($ob, $msg) = @_; 780 my ($ob, $msg) = @_;
778 785
779 if ($msg) { 786 if ($msg) {
780 my $name = $ob->name; 787 my $name = $ob->name;
781 my @plonmap = grep $ob->on_same_map_as ($_->ob), cf::player::list; 788 my @plonmap = grep $ob->on_same_map_as ($_->ob), cf::player::list;
782 789
783 $_->send_msg ($SAY_CHANNEL => "$name says: $msg", cf::NDI_GREY | ($_ == $ob->contr ? cf::NDI_REPLY : 0)) 790 send_msg $_, $SAY_CHANNEL => "$name says: $msg", cf::NDI_GREY | ($_ == $ob->contr ? cf::NDI_REPLY : 0), "msg_say"
784 for @plonmap; 791 for @plonmap;
785 792
786 # npcs, magic_ears etc. 793 # npcs, magic_ears etc.
787 # first find all objects and their first-level inventories 794 # first find all objects and their first-level inventories
788 # within a 5x5 square that have something resembling 795 # within a 5x5 square that have something resembling
803 my ($reply, @kw) = $dialog->tell ($msg); 810 my ($reply, @kw) = $dialog->tell ($msg);
804 811
805 if (defined $reply) { 812 if (defined $reply) {
806 if ($npc->type == cf::MAGIC_EAR) { 813 if ($npc->type == cf::MAGIC_EAR) {
807 if (length $reply) { 814 if (length $reply) {
808 $_->send_msg ($SAY_CHANNEL => $reply, cf::NDI_BROWN) 815 send_msg $_, $SAY_CHANNEL => $reply, cf::NDI_BROWN, "msg_say"
809 for @plonmap; 816 for @plonmap;
810 } 817 }
811 $npc->use_trigger; 818 $npc->use_trigger;
812 } else { 819 } else {
813 if (length $reply) { 820 if (length $reply) {
814 $_->send_msg ($SAY_CHANNEL => $npc->name . " says: $reply", cf::NDI_BROWN) 821 send_msg $_, $SAY_CHANNEL => $npc->name . " says: $reply", cf::NDI_BROWN, "msg_say"
815 for @plonmap; 822 for @plonmap;
816 } 823 }
817 } 824 }
818 } 825 }
819 826
842 my $NOW = time; 849 my $NOW = time;
843 850
844 cf::LOG cf::llevDebug, sprintf "QBERT [%s] %s\n", $name, $msg; 851 cf::LOG cf::llevDebug, sprintf "QBERT [%s] %s\n", $name, $msg;
845 send_irc ("[%s] %s", $name, $msg); 852 send_irc ("[%s] %s", $name, $msg);
846 853
847 $_->send_msg ($CHAT_CHANNEL => "$name chats: $msg", cf::NDI_BLUE | cf::NDI_DEF | ($_ == $pl ? cf::NDI_REPLY : 0)) 854 send_msg $_, $CHAT_CHANNEL => "$name chats: $msg", cf::NDI_BLUE | cf::NDI_DEF | ($_ == $pl ? cf::NDI_REPLY : 0), "msg_chat"
848 for grep { $_->ob->{ext_ignore_shout}{$name} < $NOW && $_->listening >= 10 } cf::player::list; 855 for grep { $_->ob->{ext_ignore_shout}{$name} < $NOW && $_->listening >= 10 } cf::player::list;
849 856
850 } else { 857 } else {
851 $pl->send_msg ($CHAT_CHANNEL => "Chat what?", cf::NDI_BLUE | cf::NDI_DEF | cf::NDI_REPLY); 858 $pl->send_msg ($CHAT_CHANNEL => "Chat what?", cf::NDI_BLUE | cf::NDI_DEF | cf::NDI_REPLY);
852 } 859 }
866 my $name = $ob->name; 873 my $name = $ob->name;
867 874
868 cf::LOG cf::llevDebug, sprintf "QBERT {%s} %s\n", $name, $msg; 875 cf::LOG cf::llevDebug, sprintf "QBERT {%s} %s\n", $name, $msg;
869 send_irc ("\007\0034{%s} %s\n", $name, $msg); 876 send_irc ("\007\0034{%s} %s\n", $name, $msg);
870 877
871 $_->send_msg ($CHAT_CHANNEL => "$name shouts: $msg", cf::NDI_RED | cf::NDI_DEF | ($_ == $pl ? cf::NDI_REPLY : 0)) 878 send_msg $_, $CHAT_CHANNEL => "$name shouts: $msg", cf::NDI_RED | cf::NDI_DEF | ($_ == $pl ? cf::NDI_REPLY : 0), "msg_shout"
872 for grep { $_->ob->{ext_ignore_shout}{$name} < $NOW && $_->listening >= 2 } cf::player::list; 879 for grep { $_->ob->{ext_ignore_shout}{$name} < $NOW && $_->listening >= 2 } cf::player::list;
873 880
874 } else { 881 } else {
875 $pl->send_msg ($CHAT_CHANNEL => "Shout what?", cf::NDI_RED | cf::NDI_DEF | cf::NDI_REPLY); 882 $pl->send_msg ($CHAT_CHANNEL => "Shout what?", cf::NDI_RED | cf::NDI_DEF | cf::NDI_REPLY);
876 } 883 }
907 } else { 914 } else {
908 return if $other->invoke (cf::EVENT_PLAYER_TOLD, $pl, $msg); 915 return if $other->invoke (cf::EVENT_PLAYER_TOLD, $pl, $msg);
909 cf::LOG cf::llevDebug, sprintf "TELL [%s>%s] %s\n", $name, $target, $msg; 916 cf::LOG cf::llevDebug, sprintf "TELL [%s>%s] %s\n", $name, $target, $msg;
910 917
911 $ns->send_msg ($pl_channel => "You tell $target: $msg", cf::NDI_DK_ORANGE | cf::NDI_DEF | cf::NDI_REPLY); 918 $ns->send_msg ($pl_channel => "You tell $target: $msg", cf::NDI_DK_ORANGE | cf::NDI_DEF | cf::NDI_REPLY);
912 $other->send_msg ($other_channel => "$name tells you: $msg", cf::NDI_DK_ORANGE | cf::NDI_DEF); 919 send_msg $other, $other_channel => "$name tells you: $msg", cf::NDI_DK_ORANGE | cf::NDI_DEF, "msg_tell";
913 } 920 }
914 } else { 921 } else {
915 $ns->send_msg ($pl_channel => "What do you want to tell $target?", cf::NDI_DK_ORANGE | cf::NDI_DEF | cf::NDI_REPLY); 922 $ns->send_msg ($pl_channel => "What do you want to tell $target?", cf::NDI_DK_ORANGE | cf::NDI_DEF | cf::NDI_REPLY);
916 } 923 }
917 924

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines