I added a new chance field to the script I posted above as well as simplified them a bit.
Code:
###Usage: plugin::RandomSay(chance(1-100), "message1","message2", etc..);
# Example: plugin::RandomSay(50, "I'll get you!", "Get over here!", "That's it!");
sub RandomSay {
my $chance = $_[0];
# First roll to see if a message will be sent or not depending on chance
my $RandomNum = plugin::RandomRange(1, 100);
# Choose the random message to send and send it
if ($RandomNum <= $chance)
{
$MessageCount = @_;
my $RandMessage = plugin::RandomRange(1, $MessageCount - 1);
quest::say($_[$RandMessage]);
}
}
###Usage: plugin::RandomEmote(chance(1-100), "message1","message2", etc..);
# Example: plugin::RandomEmote(50, "dies", "falls to the ground", "keels over dead");
sub RandomEmote {
my $chance = $_[0];
# First roll to see if a message will be sent or not depending on chance
my $RandomNum = plugin::RandomRange(1, 100);
# Choose the random message to send and send it
if ($RandomNum <= $chance)
{
$MessageCount = @_;
my $RandMessage = plugin::RandomRange(1, $MessageCount - 1);
quest::emote($_[$RandMessage]);
}
}