--- deliantra/server/ext/chat.ext 2007/10/20 05:16:44 1.35 +++ deliantra/server/ext/chat.ext 2008/09/19 01:39:45 1.44 @@ -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 = { @@ -179,7 +150,7 @@ }, scream => { noparams => { - other => " screams at the top of his lungs!", + other => " screams at the top of G lungs!", self => "ARRRRRRRRRRGH!!!!!", }, params => { @@ -198,7 +169,7 @@ self => "You puke on .", }, self => { - other => " pukes on his clothes.", + other => " pukes on G clothes.", self => "You puke on yourself.", }, }, @@ -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.", @@ -268,7 +252,7 @@ self => "You wink suggestively at .", }, self => { - other => " winks at himself - something strange is going on...", + other => " winks at Gself - something strange is going on...", self => "You wink at yourself?? What are you up to?", }, }, @@ -284,7 +268,7 @@ }, cackle => { noparams => { - other => " throws back his head and cackles with insane glee!", + other => " throws back G head and cackles with insane glee!", self => "You cackle gleefully.", }, params => { @@ -303,7 +287,7 @@ self => "You sniff .", }, self => { - other => " sniffs himself.", + other => " sniffs Gself.", self => "You sniff yourself.", }, }, @@ -313,9 +297,9 @@ self => "You nod solemnly.", }, params => { - target => " nods solemnly to you.", - other => " nods solemnly to .", - self => "You nod solemnly to .", + target => " nods solemnly at you.", + other => " nods solemnly at .", + self => "You nod solemnly at .", }, self => { }, @@ -331,7 +315,7 @@ self => "You frown darkly at .", }, self => { - other => " frowns at himself.", + other => " frowns at Gself.", self => "You frown at yourself.", }, }, @@ -364,18 +348,18 @@ self => "You bleed all over your nice new armour.", }, params => { - target => " slashes his wrist and bleeds all over you.", - other => " slashes his wrist and bleeds all over .", + target => " slashes G wrist and bleeds all over you.", + other => " slashes G wrist and bleeds all over .", self => "You slash your wrist and bleed all over ", }, self => { - other => " performs some satanic ritual while wiping his blood on himself.", + other => " performs some satanic ritual while wiping G blood on Gself.", self => "Very impressive! You wipe your blood all over yourself.", }, }, twiddle => { noparams => { - other => " patiently twiddles his thumbs.", + other => " patiently twiddles G thumbs.", self => "You patiently twiddle your thumbs.", }, params => { @@ -385,7 +369,7 @@ }, spit => { noparams => { - other => " spits over his left shoulder.", + other => " spits over G left shoulder.", self => "You spit over your left shoulder.", }, params => { @@ -394,13 +378,13 @@ self => "You spit on .", }, self => { - other => " drools all over himself.", + other => " drools all over Gself.", self => "You drool all over yourself.", }, }, glare => { noparams => { - other => " glares around him.", + other => " glares around G.", self => "You glare at nothing in particular.", }, params => { @@ -409,7 +393,7 @@ self => "You glare icily at .", }, self => { - other => " glares at his feet, what is bothering him?", + other => " glares at G feet, what is bothering G?", self => "You glare icily at your feet, they are suddenly very cold.", }, }, @@ -424,13 +408,13 @@ self => "You bow before .", }, self => { - other => " folds up like a jackknife and kisses his own toes.", + other => " folds up like a jackknife and kisses G own toes.", self => "You kiss your toes.", }, }, dance => { noparams => { - other => " expresses himself through interpretive dance.", + other => " expresses Gself through interpretive dance.", self => "You dance with glee.", }, params => { @@ -439,7 +423,7 @@ self => "You grab and begin doing the Cha-Cha!", }, self => { - other => " embraces himself and begins to dance!", + other => " embraces Gself and begins to dance!", self => "You skip and dance around by yourself.", }, }, @@ -465,7 +449,7 @@ }, snap => { noparams => { - other => " snaps his fingers.", + other => " snaps G fingers.", self => "PRONTO! you snap your fingers.", }, params => { @@ -484,7 +468,7 @@ self => "You wave goodbye to .", }, self => { - other => " waves goodbye to himself.", + other => " waves goodbye to Gself.", self => "Are you going on adventures as well??", }, }, @@ -508,11 +492,11 @@ }, params => { target => " sneezes on you, you feel the snot cover you. EEEEEEW.", - other => " sneezes on and a film of snot covers him.", - self => "You sneeze at and a film of snot shoots onto him.", + other => " sneezes on and a film of snot covers G.", + self => "You sneeze at and a film of snot shoots onto G.", }, self => { - other => " sneezes, and covers himself in a slimy substance.", + other => " sneezes, and covers Gself in a slimy substance.", self => "You sneeze on yourself, what a mess!", }, }, @@ -531,7 +515,7 @@ }, shake => { noparams => { - other => " shakes his head.", + other => " shakes G head.", self => "You shake your head.", }, params => { @@ -546,7 +530,7 @@ }, lick => { noparams => { - other => " licks his mouth and smiles.", + other => " licks G mouth and smiles.", self => "You lick your mouth and smile.", }, params => { @@ -555,7 +539,7 @@ self => "You lick .", }, self => { - other => " licks himself - YUCK.", + other => " licks Gself - YUCK.", self => "You lick yourself.", }, }, @@ -571,7 +555,7 @@ }, think => { noparams => { - other => " closes his eyes and thinks really hard.", + other => " closes G eyes and thinks really hard.", self => "Anything in particular that you'd care to think about?", }, params => { @@ -645,7 +629,7 @@ self => "You cry on 's shoulder.", }, self => { - other => " sobs quietly to himself.", + other => " sobs quietly to Gself.", self => "You cry to yourself.", }, }, @@ -669,7 +653,7 @@ self => "You whistle at .", }, self => { - other => " whistles to himself in boredom.", + other => " whistles to Gself in boredom.", self => "You whistle while you work.", }, }, @@ -725,11 +709,14 @@ $emote{self} ||= "My god! Is that LEGAL?"; $emote{other} =~ s//$name/; + + $_ = $pl->expand_cfpod ($_) + for values %emote; - send_msg $_, $CHAT_CHANNEL, $emote{other}, cf::NDI_GREY, "msg_chat" + send_msg $_, $cf::CHAT_CHANNEL, $emote{other}, cf::NDI_GREY | cf::NDI_VERBATIM, "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); + $pl->send_msg ($emote{self}, cf::NDI_GREY | cf::NDI_REPLY | cf::NDI_VERBATIM); } elsif ($tname) { my $target = cf::player::find $tname or return send_msg $pl, tell_channel $tname, "$tname is not around.", cf::NDI_DK_ORANGE | cf::NDI_REPLY, "msg_chat"; @@ -738,18 +725,21 @@ $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" + $_ = $pl->expand_cfpod ($_) + for values %emote; + + send_msg $_, $cf::CHAT_CHANNEL, $emote{other}, cf::NDI_GREY | cf::NDI_VERBATIM, "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"; - $pl->send_msg (tell_channel $tname, $emote{self}, cf::NDI_GREY | cf::NDI_REPLY); + send_msg $target, tell_channel $name, $emote{target}, cf::NDI_GREY | cf::NDI_VERBATIM, "msg_shout"; + $pl->send_msg (tell_channel $tname, $emote{self}, cf::NDI_GREY | cf::NDI_REPLY | cf::NDI_VERBATIM); } else { my %emote = %{ $emotes->{$emotion}->{noparams} || {} }; @@ -758,10 +748,13 @@ $emote{other} =~ s//$name/; - send_msg $_, $CHAT_CHANNEL, $emote{other}, cf::NDI_GREY, "msg_chat" + $_ = $pl->expand_cfpod ($_) + for values %emote; + + send_msg $_, $cf::CHAT_CHANNEL, $emote{other}, cf::NDI_GREY | cf::NDI_VERBATIM, "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 | cf::NDI_VERBATIM); } }; }; @@ -772,7 +765,7 @@ my $name = $pl->name; - send_msg $pl, $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 +780,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 +791,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 +806,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 +845,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" - for grep { $_->ob->{ext_ignore_shout}{$name} < $NOW && $_->listening >= 10 } cf::player::list; + 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 } 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 +869,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" - for grep { $_->ob->{ext_ignore_shout}{$name} < $NOW && $_->listening >= 2 } cf::player::list; + 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 } 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); } };