--- deliantra/server/ext/chat.ext 2007/10/24 00:05:32 1.36 +++ deliantra/server/ext/chat.ext 2008/08/29 02:07:09 1.42 @@ -1,25 +1,11 @@ #! perl # depends=irc mandatory -# implement a replacement for the built-in say/chat/shout/tell/reply commands +# implement a replacement for the built-in say/chat/shout/tell commands # adds ignore/unignore functionality use NPC_Dialogue; use POSIX (); # for strftime only -our $SAY_CHANNEL = { - id => "say", - title => "Map", - reply => "say ", - tooltip => "Things said to and replied from npcs near you and other players on the same map only.", -}; - -our $CHAT_CHANNEL = { - id => "chat", - title => "Chat", - reply => "chat ", - tooltip => "Player chat and shouts, global to the server.", -}; - sub tell_channel($) { my ($target) = @_; @@ -72,28 +58,13 @@ clean_timeouts $pl->ob; - $pl->send_msg ($SAY_CHANNEL); - $pl->send_msg ($CHAT_CHANNEL); + $pl->send_msg ($cf::SAY_CHANNEL); + $pl->send_msg ($cf::CHAT_CHANNEL); }, ); +# TODO: remove once safe cf::register_command listen => sub { - my ($pl, $msg) = @_; - my $player = cf::player::find_active $pl->name; - - if ($msg ne "") { - $msg = 10 if $msg > 10; - - my $prev_listen = $player->listening; - $player->listening ($msg); - if ($prev_listen == $player->listening) { - $pl->message ("Your verbose level stays at $prev_listen.", cf::NDI_REPLY); - } else { - $pl->message ("Your verbose level is now " . $player->listening . ". (previously: $prev_listen)", cf::NDI_REPLY); - } - } else { - $pl->message ("Your verbose level is " . $player->listening . ".", cf::NDI_REPLY); - } }; cf::register_command cointoss => sub { @@ -104,10 +75,10 @@ my $coin = int rand 2 ? "Heads" : "Tails"; - send_msg $_, $SAY_CHANNEL => "$name flips a coin.... $coin!", cf::NDI_GREY, "msg_say" + send_msg $_, $cf::SAY_CHANNEL => "$name flips a coin.... $coin!", cf::NDI_GREY, "msg_say" for grep { $ob->on_same_map_as ($_->ob) && $_ != $pl} cf::player::list; - $pl->send_msg ($SAY_CHANNEL => "You flip a coin.... $coin!", cf::NDI_GREY | cf::NDI_REPLY); + $pl->send_msg ($cf::SAY_CHANNEL => "You flip a coin.... $coin!", cf::NDI_GREY | cf::NDI_REPLY); }; cf::register_command orcknuckle => sub { @@ -120,10 +91,10 @@ my ($i, $j, $k, $l) = (rand 5, rand 5, rand 5, rand 6); my $result = "$orcknuckle[$i], $orcknuckle[$j], $orcknuckle[$k], $orcknuckle[$l]"; - send_msg $_, $SAY_CHANNEL => "$name throws his orc-knuckles and rolls $result!", cf::NDI_GREY, "msg_say" + send_msg $_, $cf::SAY_CHANNEL => "$name throws his orc-knuckles and rolls $result!", cf::NDI_GREY, "msg_say" for grep { $ob->on_same_map_as ($_->ob) && $_ != $pl} cf::player::list; - $pl->send_msg ($SAY_CHANNEL => "You roll $result!", cf::NDI_GREY | cf::NDI_REPLY); + $pl->send_msg ($cf::SAY_CHANNEL => "You roll $result!", cf::NDI_GREY | cf::NDI_REPLY); }; my $emotes = { @@ -257,6 +228,19 @@ self => { }, }, + smother => { + noparams => { + other => " makes weird facial contortions", + self => "All the lonely people..", + }, + params => { + target => " smothers you with kisses.", + other => " smothers with kisses.", + self => "You smother with kisses.", + }, + self => { + }, + }, wink => { noparams => { other => " winks suggestively.", @@ -726,7 +710,7 @@ $emote{other} =~ s//$name/; - send_msg $_, $CHAT_CHANNEL, $emote{other}, cf::NDI_GREY, "msg_chat" + send_msg $_, $cf::CHAT_CHANNEL, $emote{other}, cf::NDI_GREY, "msg_chat" for grep { $ob->on_same_map_as ($_->ob) && $_ != $ob} cf::player::list; $pl->send_msg ($emote{self}, cf::NDI_GREY | cf::NDI_REPLY); @@ -738,14 +722,14 @@ $emote{other} ||= " is eyeing quizzically."; $emote{self} ||= "You are still nuts."; - $emote{target} ||= "You get the distinct feeling that is nuts."; + $emote{target} ||= "You get the distinct feeling that is nuts."; $emote{self} =~ s//$tname/; $emote{target} =~ s//$name/; $emote{other} =~ s//$tname/; $emote{other} =~ s//$name/; - send_msg $_, $CHAT_CHANNEL, $emote{other}, cf::NDI_GREY, "msg_chat" + send_msg $_, $cf::CHAT_CHANNEL, $emote{other}, cf::NDI_GREY, "msg_chat" for grep { $_ != $pl && $_ != $target && $ob->on_same_map_as ($_->ob) } cf::player::list; send_msg $target, tell_channel $name, $emote{target}, cf::NDI_GREY, "msg_shout"; @@ -758,10 +742,10 @@ $emote{other} =~ s//$name/; - send_msg $_, $CHAT_CHANNEL, $emote{other}, cf::NDI_GREY, "msg_chat" + send_msg $_, $cf::CHAT_CHANNEL, $emote{other}, cf::NDI_GREY, "msg_chat" for grep { $ob->on_same_map_as ($_->ob) && $_ != $pl } cf::player::list; - $pl->send_msg ($CHAT_CHANNEL, $emote{self}, cf::NDI_GREY | cf::NDI_REPLY); + $pl->send_msg ($cf::CHAT_CHANNEL, $emote{self}, cf::NDI_GREY | cf::NDI_REPLY); } }; }; @@ -772,7 +756,7 @@ my $name = $pl->name; - send_msg $_, $SAY_CHANNEL => "* $name $msg", cf::NDI_GREY | cf::NDI_DEF | ($_ == $pl ? cf::NDI_REPLY : 0), "msg_say" + send_msg $_, $cf::SAY_CHANNEL => "* $name $msg", cf::NDI_GREY | cf::NDI_DEF | ($_ == $pl ? cf::NDI_REPLY : 0), "msg_say" for grep $pl->on_same_map_as ($_->ob), cf::player::list; }; @@ -787,9 +771,9 @@ my $name = $ob->name; my @plonmap = grep $ob->on_same_map_as ($_->ob), cf::player::list; - send_msg $_, $SAY_CHANNEL => "$name says: $msg", cf::NDI_GREY, "msg_say" + send_msg $_, $cf::SAY_CHANNEL => "$name says: $msg", cf::NDI_GREY, "msg_say" for grep $_ != $ob->contr, @plonmap; - $ob->contr->send_msg ($SAY_CHANNEL => "$name says: $msg", cf::NDI_GREY | cf::NDI_REPLY); + $ob->contr->send_msg ($cf::SAY_CHANNEL => "$name says: $msg", cf::NDI_GREY | cf::NDI_REPLY); # npcs, magic_ears etc. # first find all objects and their first-level inventories @@ -798,7 +782,7 @@ my ($map, $x, $y) = ($ob->map, $ob->x - 2, $ob->y - 2); for my $npc ( - grep +($_->invoke (cf::EVENT_OBJECT_SAY, $ob->contr, $msg) && return) || NPC_Dialogue::has_dialogue $_, + grep +($_->invoke (cf::EVENT_OBJECT_SAY, $ob->contr, $msg) && return) || $_->has_dialogue, map +($_, $_->inv), grep $_, map $map->at ($x + $_ % 5, $y + (int $_ / 5)), @@ -813,26 +797,26 @@ if (defined $reply) { if ($npc->type == cf::MAGIC_EAR) { if (length $reply) { - send_msg $_, $SAY_CHANNEL => $reply, cf::NDI_BROWN, "msg_say" + send_msg $_, $cf::SAY_CHANNEL => $reply, cf::NDI_BROWN, "msg_say" for @plonmap; } $npc->use_trigger; } else { if (length $reply) { - send_msg $_, $SAY_CHANNEL => $npc->name . " says: $reply", cf::NDI_BROWN, "msg_say" + send_msg $_, $cf::SAY_CHANNEL => $npc->name . " says: $reply", cf::NDI_BROWN, "msg_say" for @plonmap; } } } if (@kw) { - $_->send_msg ($SAY_CHANNEL => "[further topics: " . (join ", ", @kw) . "]", cf::NDI_BROWN) + $_->send_msg ($cf::SAY_CHANNEL => "[further topics: " . (join ", ", @kw) . "]", cf::NDI_BROWN) for @plonmap; } } } else { - $ob->send_msg ($SAY_CHANNEL => "What do you want to say?", cf::NDI_GREY | cf::NDI_REPLY); + $ob->send_msg ($cf::SAY_CHANNEL => "What do you want to say?", cf::NDI_GREY | cf::NDI_REPLY); } }; @@ -852,11 +836,11 @@ cf::LOG cf::llevDebug, sprintf "QBERT [%s] %s\n", $name, $msg; send_irc ("[%s] %s", $name, $msg); - send_msg $_, $CHAT_CHANNEL => "$name chats: $msg", cf::NDI_BLUE | cf::NDI_DEF | ($_ == $pl ? cf::NDI_REPLY : 0), "msg_chat" + send_msg $_, $cf::CHAT_CHANNEL => "$name chats: $msg", cf::NDI_BLUE | cf::NDI_DEF | ($_ == $pl ? cf::NDI_REPLY : 0), "msg_chat" for grep { $_->ob->{ext_ignore_shout}{$name} < $NOW && $_->listening >= 10 } cf::player::list; } else { - $pl->send_msg ($CHAT_CHANNEL => "Chat what?", cf::NDI_BLUE | cf::NDI_DEF | cf::NDI_REPLY); + $pl->send_msg ($cf::CHAT_CHANNEL => "Chat what?", cf::NDI_BLUE | cf::NDI_DEF | cf::NDI_REPLY); } }; @@ -876,11 +860,11 @@ cf::LOG cf::llevDebug, sprintf "QBERT {%s} %s\n", $name, $msg; send_irc ("\007\0034{%s} %s\n", $name, $msg); - send_msg $_, $CHAT_CHANNEL => "$name shouts: $msg", cf::NDI_RED | cf::NDI_DEF | ($_ == $pl ? cf::NDI_REPLY : 0), "msg_shout" + send_msg $_, $cf::CHAT_CHANNEL => "$name shouts: $msg", cf::NDI_RED | cf::NDI_DEF | ($_ == $pl ? cf::NDI_REPLY : 0), "msg_shout" for grep { $_->ob->{ext_ignore_shout}{$name} < $NOW && $_->listening >= 2 } cf::player::list; } else { - $pl->send_msg ($CHAT_CHANNEL => "Shout what?", cf::NDI_RED | cf::NDI_DEF | cf::NDI_REPLY); + $pl->send_msg ($cf::CHAT_CHANNEL => "Shout what?", cf::NDI_RED | cf::NDI_DEF | cf::NDI_REPLY); } };