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.29 by root, Sat Jul 28 12:02:58 2007 UTC vs.
Revision 1.33 by root, Wed Sep 19 21:56:30 2007 UTC

62 prio => -1000, 62 prio => -1000,
63 on_login => sub { 63 on_login => sub {
64 my ($pl) = @_; 64 my ($pl) = @_;
65 65
66 clean_timeouts $pl->ob; 66 clean_timeouts $pl->ob;
67
67 $pl->ns->send_msg ($SAY_CHANNEL); 68 $pl->send_msg ($SAY_CHANNEL);
68 $pl->ns->send_msg ($CHAT_CHANNEL); 69 $pl->send_msg ($CHAT_CHANNEL);
69 }, 70 },
70); 71);
71 72
72cf::register_command listen => sub { 73cf::register_command listen => sub {
73 my ($pl, $msg) = @_; 74 my ($pl, $msg) = @_;
94 my $pl = $ob->contr; 95 my $pl = $ob->contr;
95 my $name = $ob->name; 96 my $name = $ob->name;
96 97
97 my $coin = int rand 2 ? "Heads" : "Tails"; 98 my $coin = int rand 2 ? "Heads" : "Tails";
98 99
99 $_->ns->send_msg ($SAY_CHANNEL => "$name flips a coin.... $coin!", cf::NDI_GREY) 100 $_->send_msg ($SAY_CHANNEL => "$name flips a coin.... $coin!", cf::NDI_GREY)
100 for grep { $ob->on_same_map_as ($_->ob) && $_ != $pl} cf::player::list; 101 for grep { $ob->on_same_map_as ($_->ob) && $_ != $pl} cf::player::list;
101 102
102 $pl->ns->send_msg ($SAY_CHANNEL => "You flip a coin.... $coin!", cf::NDI_GREY | cf::NDI_REPLY); 103 $pl->send_msg ($SAY_CHANNEL => "You flip a coin.... $coin!", cf::NDI_GREY | cf::NDI_REPLY);
103}; 104};
104 105
105cf::register_command orcknuckle => sub { 106cf::register_command orcknuckle => sub {
106 my ($ob, $msg) = @_; 107 my ($ob, $msg) = @_;
107 108
110 111
111 my @orcknuckle = ("beholder", "ghost", "knight", "princess", "dragon", "orc"); 112 my @orcknuckle = ("beholder", "ghost", "knight", "princess", "dragon", "orc");
112 my ($i, $j, $k, $l) = (rand 5, rand 5, rand 5, rand 6); 113 my ($i, $j, $k, $l) = (rand 5, rand 5, rand 5, rand 6);
113 my $result = "$orcknuckle[$i], $orcknuckle[$j], $orcknuckle[$k], $orcknuckle[$l]"; 114 my $result = "$orcknuckle[$i], $orcknuckle[$j], $orcknuckle[$k], $orcknuckle[$l]";
114 115
115 $_->ns->send_msg ($SAY_CHANNEL => "$name throws his orc-knuckles and rolls $result!", cf::NDI_GREY) 116 $_->send_msg ($SAY_CHANNEL => "$name throws his orc-knuckles and rolls $result!", cf::NDI_GREY)
116 for grep { $ob->on_same_map_as ($_->ob) && $_ != $pl} cf::player::list; 117 for grep { $ob->on_same_map_as ($_->ob) && $_ != $pl} cf::player::list;
117 118
118 $pl->ns->send_msg ($SAY_CHANNEL => "You roll $result!", cf::NDI_GREY | cf::NDI_REPLY); 119 $pl->send_msg ($SAY_CHANNEL => "You roll $result!", cf::NDI_GREY | cf::NDI_REPLY);
119}; 120};
120 121
121my $emotes = { 122my $emotes = {
122 growl => { 123 growl => {
123 noparams => { 124 noparams => {
706 707
707 my $pl = $ob->contr; 708 my $pl = $ob->contr;
708 709
709 cf::async { 710 cf::async {
710 my $name = $ob->name; 711 my $name = $ob->name;
712 $Coro::current->{desc} = "emote handler for $name";
711 713
712 if ($tname eq $name) { 714 if ($tname eq $name) {
713 my %emote = %{ $emotes->{$emotion}->{self} || {} }; 715 my %emote = %{ $emotes->{$emotion}->{self} || {} };
714 716
715 $emote{other} ||= "You look away from <self>."; 717 $emote{other} ||= "You look away from <self>.";
716 $emote{self} ||= "My god! Is that LEGAL?"; 718 $emote{self} ||= "My god! Is that LEGAL?";
717 719
718 $emote{other} =~ s/<self>/$name/; 720 $emote{other} =~ s/<self>/$name/;
719 721
720 $_->ns->send_msg ($CHAT_CHANNEL, $emote{other}, cf::NDI_GREY) 722 $_->send_msg ($CHAT_CHANNEL, $emote{other}, cf::NDI_GREY)
721 for grep { $ob->on_same_map_as ($_->ob) && $_ != $ob} cf::player::list; 723 for grep { $ob->on_same_map_as ($_->ob) && $_ != $ob} cf::player::list;
722 724
723 $pl->ns->send_msg ($emote{self}, cf::NDI_GREY | cf::NDI_REPLY); 725 $pl->send_msg ($emote{self}, cf::NDI_GREY | cf::NDI_REPLY);
724 } elsif ($tname) { 726 } elsif ($tname) {
725 my $target = cf::player::find $tname 727 my $target = cf::player::find $tname
726 or return $pl->ns->send_msg (tell_channel $tname, "$tname is not around.", cf::NDI_DK_ORANGE | cf::NDI_REPLY); 728 or return $pl->send_msg (tell_channel $tname, "$tname is not around.", cf::NDI_DK_ORANGE | cf::NDI_REPLY);
727 729
728 my %emote = %{ $emotes->{$emotion}->{params} || {} }; 730 my %emote = %{ $emotes->{$emotion}->{params} || {} };
729 731
730 $emote{other} ||= "<self> is eyeing <other> quizzically."; 732 $emote{other} ||= "<self> is eyeing <other> quizzically.";
731 $emote{self} ||= "You are still nuts."; 733 $emote{self} ||= "You are still nuts.";
734 $emote{self} =~ s/<other>/$tname/; 736 $emote{self} =~ s/<other>/$tname/;
735 $emote{target} =~ s/<self>/$name/; 737 $emote{target} =~ s/<self>/$name/;
736 $emote{other} =~ s/<other>/$tname/; 738 $emote{other} =~ s/<other>/$tname/;
737 $emote{other} =~ s/<self>/$name/; 739 $emote{other} =~ s/<self>/$name/;
738 740
739 $_->ns->send_msg ($CHAT_CHANNEL, $emote{other}, cf::NDI_GREY) 741 $_->send_msg ($CHAT_CHANNEL, $emote{other}, cf::NDI_GREY)
740 for grep { $_ != $pl && $_ != $target && $ob->on_same_map_as ($_->ob) } cf::player::list; 742 for grep { $_ != $pl && $_ != $target && $ob->on_same_map_as ($_->ob) } cf::player::list;
741 743
742 $target->ns->send_msg (tell_channel $name, $emote{target}, cf::NDI_GREY); 744 $target->send_msg (tell_channel $name, $emote{target}, cf::NDI_GREY);
743 $pl->ns->send_msg (tell_channel $tname, $emote{self}, cf::NDI_GREY | cf::NDI_REPLY); 745 $pl->send_msg (tell_channel $tname, $emote{self}, cf::NDI_GREY | cf::NDI_REPLY);
744 } else { 746 } else {
745 my %emote = %{ $emotes->{$emotion}->{noparams} || {} }; 747 my %emote = %{ $emotes->{$emotion}->{noparams} || {} };
746 748
747 $emote{other} ||= "<self> dances with glee."; 749 $emote{other} ||= "<self> dances with glee.";
748 $emote{self} ||= "You are a nut."; 750 $emote{self} ||= "You are a nut.";
749 751
750 $emote{other} =~ s/<self>/$name/; 752 $emote{other} =~ s/<self>/$name/;
751 753
752 $_->ns->send_msg ($CHAT_CHANNEL, $emote{other}, cf::NDI_GREY) 754 $_->send_msg ($CHAT_CHANNEL, $emote{other}, cf::NDI_GREY)
753 for grep { $ob->on_same_map_as ($_->ob) && $_ != $pl } cf::player::list; 755 for grep { $ob->on_same_map_as ($_->ob) && $_ != $pl } cf::player::list;
754 756
755 $pl->ns->send_msg ($CHAT_CHANNEL, $emote{self}, cf::NDI_GREY | cf::NDI_REPLY); 757 $pl->send_msg ($CHAT_CHANNEL, $emote{self}, cf::NDI_GREY | cf::NDI_REPLY);
756 } 758 }
757 }; 759 };
758 }; 760 };
759} 761}
760 762
761cf::register_command me => sub { 763cf::register_command me => sub {
762 my ($pl, $msg) = @_; 764 my ($pl, $msg) = @_;
763 765
764 my $name = $pl->name; 766 my $name = $pl->name;
765 767
766 $_->ns->send_msg ($SAY_CHANNEL => "* $name $msg", cf::NDI_GREY | cf::NDI_DEF | ($_ == $pl ? cf::NDI_REPLY : 0)) 768 $_->send_msg ($SAY_CHANNEL => "* $name $msg", cf::NDI_GREY | cf::NDI_DEF | ($_ == $pl ? cf::NDI_REPLY : 0))
767 for grep $pl->on_same_map_as ($_->ob), cf::player::list; 769 for grep $pl->on_same_map_as ($_->ob), cf::player::list;
768}; 770};
769 771
770cf::register_command say => sub { 772cf::register_command say => sub {
771 my ($ob, $msg) = @_; 773 my ($ob, $msg) = @_;
776 778
777 if ($msg) { 779 if ($msg) {
778 my $name = $ob->name; 780 my $name = $ob->name;
779 my @plonmap = grep $ob->on_same_map_as ($_->ob), cf::player::list; 781 my @plonmap = grep $ob->on_same_map_as ($_->ob), cf::player::list;
780 782
781 $_->ns->send_msg ($SAY_CHANNEL => "$name says: $msg", cf::NDI_GREY | ($_ == $ob ? cf::NDI_REPLY : 0)) 783 $_->send_msg ($SAY_CHANNEL => "$name says: $msg", cf::NDI_GREY | ($_ == $ob->contr ? cf::NDI_REPLY : 0))
782 for @plonmap; 784 for @plonmap;
783 785
784 # npcs, magic_ears etc. 786 # npcs, magic_ears etc.
785 # first find all objects and their first-level inventories 787 # first find all objects and their first-level inventories
786 # within a 5x5 square that have something resembling 788 # within a 5x5 square that have something resembling
801 my ($reply, @kw) = $dialog->tell ($msg); 803 my ($reply, @kw) = $dialog->tell ($msg);
802 804
803 if (defined $reply) { 805 if (defined $reply) {
804 if ($npc->type == cf::MAGIC_EAR) { 806 if ($npc->type == cf::MAGIC_EAR) {
805 if (length $reply) { 807 if (length $reply) {
806 $_->ns->send_msg ($SAY_CHANNEL => $reply, cf::NDI_BROWN) 808 $_->send_msg ($SAY_CHANNEL => $reply, cf::NDI_BROWN)
807 for @plonmap; 809 for @plonmap;
808 } 810 }
809 $npc->use_trigger; 811 $npc->use_trigger;
810 } else { 812 } else {
811 if (length $reply) { 813 if (length $reply) {
812 $_->ns->send_msg ($SAY_CHANNEL => $npc->name . " says: $reply", cf::NDI_BROWN) 814 $_->send_msg ($SAY_CHANNEL => $npc->name . " says: $reply", cf::NDI_BROWN)
813 for @plonmap; 815 for @plonmap;
814 } 816 }
815 } 817 }
816 } 818 }
817 819
818 if (@kw) { 820 if (@kw) {
819 $_->ns->send_msg ($SAY_CHANNEL => "[further topics: " . (join ", ", @kw) . "]", cf::NDI_BROWN) 821 $_->send_msg ($SAY_CHANNEL => "[further topics: " . (join ", ", @kw) . "]", cf::NDI_BROWN)
820 for @plonmap; 822 for @plonmap;
821 } 823 }
822 } 824 }
823 825
824 } else { 826 } else {
825 $ob->contr->ns->send_msg ($SAY_CHANNEL => "What do you want to say?", cf::NDI_GREY | cf::NDI_REPLY); 827 $ob->send_msg ($SAY_CHANNEL => "What do you want to say?", cf::NDI_GREY | cf::NDI_REPLY);
826 } 828 }
827}; 829};
828 830
829cf::register_command chat => sub { 831cf::register_command chat => sub {
830 my ($ob, $msg) = @_; 832 my ($ob, $msg) = @_;
840 my $NOW = time; 842 my $NOW = time;
841 843
842 cf::LOG cf::llevDebug, sprintf "QBERT [%s] %s\n", $name, $msg; 844 cf::LOG cf::llevDebug, sprintf "QBERT [%s] %s\n", $name, $msg;
843 send_irc ("[%s] %s", $name, $msg); 845 send_irc ("[%s] %s", $name, $msg);
844 846
845 $_->ns->send_msg ($CHAT_CHANNEL => "$name chats: $msg", cf::NDI_BLUE | cf::NDI_DEF | ($_ == $pl ? cf::NDI_REPLY : 0)) 847 $_->send_msg ($CHAT_CHANNEL => "$name chats: $msg", cf::NDI_BLUE | cf::NDI_DEF | ($_ == $pl ? cf::NDI_REPLY : 0))
846 for grep { $_->ob->{ext_ignore_shout}{$name} < $NOW && $_->listening >= 10 } cf::player::list; 848 for grep { $_->ob->{ext_ignore_shout}{$name} < $NOW && $_->listening >= 10 } cf::player::list;
847 849
848 } else { 850 } else {
849 $pl->ns->send_msg ($CHAT_CHANNEL => "Chat what?", cf::NDI_BLUE | cf::NDI_DEF | cf::NDI_REPLY); 851 $pl->send_msg ($CHAT_CHANNEL => "Chat what?", cf::NDI_BLUE | cf::NDI_DEF | cf::NDI_REPLY);
850 } 852 }
851}; 853};
852 854
853cf::register_command shout => sub { 855cf::register_command shout => sub {
854 my ($ob, $msg) = @_; 856 my ($ob, $msg) = @_;
864 my $name = $ob->name; 866 my $name = $ob->name;
865 867
866 cf::LOG cf::llevDebug, sprintf "QBERT {%s} %s\n", $name, $msg; 868 cf::LOG cf::llevDebug, sprintf "QBERT {%s} %s\n", $name, $msg;
867 send_irc ("\007\0034{%s} %s\n", $name, $msg); 869 send_irc ("\007\0034{%s} %s\n", $name, $msg);
868 870
869 $_->ns->send_msg ($CHAT_CHANNEL => "$name shouts: $msg", cf::NDI_RED | cf::NDI_DEF | ($_ == $pl ? cf::NDI_REPLY : 0)) 871 $_->send_msg ($CHAT_CHANNEL => "$name shouts: $msg", cf::NDI_RED | cf::NDI_DEF | ($_ == $pl ? cf::NDI_REPLY : 0))
870 for grep { $_->ob->{ext_ignore_shout}{$name} < $NOW && $_->listening >= 2 } cf::player::list; 872 for grep { $_->ob->{ext_ignore_shout}{$name} < $NOW && $_->listening >= 2 } cf::player::list;
871 873
872 } else { 874 } else {
873 $pl->ns->send_msg ($CHAT_CHANNEL => "Shout what?", cf::NDI_RED | cf::NDI_DEF | cf::NDI_REPLY); 875 $pl->send_msg ($CHAT_CHANNEL => "Shout what?", cf::NDI_RED | cf::NDI_DEF | cf::NDI_REPLY);
874 } 876 }
875}; 877};
876 878
877cf::register_command tell => sub { 879cf::register_command tell => sub {
878 my ($ob, $args) = @_; 880 my ($ob, $args) = @_;
905 } else { 907 } else {
906 return if $other->invoke (cf::EVENT_PLAYER_TOLD, $pl, $msg); 908 return if $other->invoke (cf::EVENT_PLAYER_TOLD, $pl, $msg);
907 cf::LOG cf::llevDebug, sprintf "TELL [%s>%s] %s\n", $name, $target, $msg; 909 cf::LOG cf::llevDebug, sprintf "TELL [%s>%s] %s\n", $name, $target, $msg;
908 910
909 $ns->send_msg ($pl_channel => "You tell $target: $msg", cf::NDI_DK_ORANGE | cf::NDI_DEF | cf::NDI_REPLY); 911 $ns->send_msg ($pl_channel => "You tell $target: $msg", cf::NDI_DK_ORANGE | cf::NDI_DEF | cf::NDI_REPLY);
910 $other->ns->send_msg ($other_channel => "$name tells you: $msg", cf::NDI_DK_ORANGE | cf::NDI_DEF); 912 $other->send_msg ($other_channel => "$name tells you: $msg", cf::NDI_DK_ORANGE | cf::NDI_DEF);
911 } 913 }
912 } else { 914 } else {
913 $ns->send_msg ($pl_channel => "What do you want to tell $target?", cf::NDI_DK_ORANGE | cf::NDI_DEF | cf::NDI_REPLY); 915 $ns->send_msg ($pl_channel => "What do you want to tell $target?", cf::NDI_DK_ORANGE | cf::NDI_DEF | cf::NDI_REPLY);
914 } 916 }
915 917

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines