Code:
#!/usr/bin/perl
# Level => (Cost, Buff set)
# Hash is iterated over, and as soon as player level is >= to hash level,
# cost is applied
# offers same buffs regardless of level
my %pbuffs =
(
65 => { cost => 1000, set => 'high' },
55 => { cost => 500, set => 'general' },
45 => { cost => 450, set => 'general' },
30 => { cost => 300, set => 'general' },
15 => { cost => 150, set => 'general' },
0 => { cost => 0, set => 'general' }
);
# Buff sets. Referenced by pbuffs, changed for donator zone
my %buffset =
(
general => [1598, 1776, 1693, 1939, 3692, 356, 3299, 13],
high => [2112, 2517, 2570, 1939, 3467, 5317, 3299, 13]
);
# Returns pbuff value for level
# Args: level
sub getpb
{
my $level = shift;
foreach $key (reverse sort keys %pbuffs)
{
if ($level >= $key)
{
return $pbuffs{$key};
}
}
}
# Casts buffs given a name
# Args: array of spells
sub castspells
{
foreach $spell (@_)
{
quest::selfcast($spell);
}
}
# Returns buff set for level
sub getbuffset
{
return @{$buffset{getpb(shift)->{'set'}}};
}
sub EVENT_SAY
{
my $saylink1 = quest::saylink("buffs");
my @buffs = getbuffset($ulevel);
if ($text =~ /hail/i)
{
quest::say("If you want some [$saylink1] just let me know.");
}
elsif ($text =~ /buffs/i)
{
castspells(@buffs);
quest::say("Here you go $name!");
}
}
I didn't bother changing half the things here from my old buffbot on x5, but... yeah.