--- deliantra/server/ext/chat.ext 2007/09/19 21:56:30 1.33 +++ deliantra/server/ext/chat.ext 2007/10/20 05:07:19 1.34 @@ -31,6 +31,13 @@ } } +sub send_msg($$$$$) { + my ($pl, $channel, $msg, $flags, $sound) = @_; + $pl->play_sound (cf::sound::find $sound) if defined $sound; + $pl->send_msg ($channel, $msg, $flags); + () +} + sub clean_timeouts($) { my ($player) = @_; my $NOW = time; @@ -97,7 +104,7 @@ my $coin = int rand 2 ? "Heads" : "Tails"; - $_->send_msg ($SAY_CHANNEL => "$name flips a coin.... $coin!", cf::NDI_GREY) + send_msg $_, $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); @@ -113,7 +120,7 @@ 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) + send_msg $_, $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); @@ -719,13 +726,13 @@ $emote{other} =~ s//$name/; - $_->send_msg ($CHAT_CHANNEL, $emote{other}, cf::NDI_GREY) + send_msg $_, $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); } elsif ($tname) { my $target = cf::player::find $tname - or return $pl->send_msg (tell_channel $tname, "$tname is not around.", cf::NDI_DK_ORANGE | cf::NDI_REPLY); + or return send_msg $pl, tell_channel $tname, "$tname is not around.", cf::NDI_DK_ORANGE | cf::NDI_REPLY, "msg_chat"; my %emote = %{ $emotes->{$emotion}->{params} || {} }; @@ -738,10 +745,10 @@ $emote{other} =~ s//$tname/; $emote{other} =~ s//$name/; - $_->send_msg ($CHAT_CHANNEL, $emote{other}, cf::NDI_GREY) + send_msg $_, $CHAT_CHANNEL, $emote{other}, cf::NDI_GREY, "msg_chat" for grep { $_ != $pl && $_ != $target && $ob->on_same_map_as ($_->ob) } cf::player::list; - $target->send_msg (tell_channel $name, $emote{target}, cf::NDI_GREY); + 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); } else { my %emote = %{ $emotes->{$emotion}->{noparams} || {} }; @@ -751,7 +758,7 @@ $emote{other} =~ s//$name/; - $_->send_msg ($CHAT_CHANNEL, $emote{other}, cf::NDI_GREY) + send_msg $_, $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); @@ -765,7 +772,7 @@ my $name = $pl->name; - $_->send_msg ($SAY_CHANNEL => "* $name $msg", cf::NDI_GREY | cf::NDI_DEF | ($_ == $pl ? cf::NDI_REPLY : 0)) + send_msg $pl, $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; }; @@ -780,7 +787,7 @@ 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 | ($_ == $ob->contr ? cf::NDI_REPLY : 0)) + send_msg $_, $SAY_CHANNEL => "$name says: $msg", cf::NDI_GREY | ($_ == $ob->contr ? cf::NDI_REPLY : 0), "msg_say" for @plonmap; # npcs, magic_ears etc. @@ -805,13 +812,13 @@ if (defined $reply) { if ($npc->type == cf::MAGIC_EAR) { if (length $reply) { - $_->send_msg ($SAY_CHANNEL => $reply, cf::NDI_BROWN) + send_msg $_, $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) + send_msg $_, $SAY_CHANNEL => $npc->name . " says: $reply", cf::NDI_BROWN, "msg_say" for @plonmap; } } @@ -844,7 +851,7 @@ 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)) + 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; } else { @@ -868,7 +875,7 @@ 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)) + 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; } else { @@ -909,7 +916,7 @@ cf::LOG cf::llevDebug, sprintf "TELL [%s>%s] %s\n", $name, $target, $msg; $ns->send_msg ($pl_channel => "You tell $target: $msg", cf::NDI_DK_ORANGE | cf::NDI_DEF | cf::NDI_REPLY); - $other->send_msg ($other_channel => "$name tells you: $msg", cf::NDI_DK_ORANGE | cf::NDI_DEF); + send_msg $other, $other_channel => "$name tells you: $msg", cf::NDI_DK_ORANGE | cf::NDI_DEF, "msg_tell"; } } else { $ns->send_msg ($pl_channel => "What do you want to tell $target?", cf::NDI_DK_ORANGE | cf::NDI_DEF | cf::NDI_REPLY);