KingMort |
02-05-2010 06:25 PM |
Here is the Quest
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
my %pbuffs =
(
65 => { cost => 1000, set => 'high' },
55 => { cost => 500, set => 'general' },
45 => { cost => 450, set => 'general' },
30 => { cost => 300, set => 'general' },
20 => { cost => 150, set => 'general' },
0 => { cost => 0, set => 'general' }
);
# Buff sets. Referenced by pbuffs
my %buffset =
(
general => [2112, 2517, 8199, 1939, 2517],
high => [2112, 2517, 278, 13, 5257, 5396, 1939]
);
# Returns pbuff value for level
# Args: level
sub getpb
{
my $level = shift;
foreach $key (reverse sort keys %pbuffs)
{
if ($level >= $key)
{
return $pbuffs{$key};
}
}
}
# Returns buff cost for level
# Args: level
sub getbuffcost
{
return getpb(shift)->{'cost'};
}
# 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_SPAWN
{
quest::settimer(1,1);
}
sub EVENT_SAY
{
my $saylink1 = quest::saylink("buffs");
my $saylink2 = quest::saylink("pay");
my $cost = getbuffcost($ulevel);
my @buffs = getbuffset($ulevel);
my $credit = $qglobals{buffcredit} ? $qglobals{buffcredit} : 0;
if (defined $qglobals{hkchinese})
{
if ($text =~ /hail/i)
{
quest::say("Ru guo nin xu yao yi xie buff [$saylink1], gao shu wo, dang ran, nin ke
neng xu yao fu dian dai jia [$saylink2].");
$npc->SetAppearance(0);
quest::settimer(1,10);
}
elsif ($text =~ /buffs/i)
{
if ($credit < $cost)
{
quest::say("Xiao gui, ni xiang pian guo wo ma? mei na me rong yi! ni xu yao zhi shao"
. ($cost - $credit) . " PP.");
}
else
{
castspells(@buffs);
# Only record and say this stuff if there was a cost
if ($cost > 0)
{
$credit -= $cost;
quest::setglobal('buffcredit', "$credit", 5, 'F');
quest::say("Xie xie nin, $name! zai wo zhe li, nin hai sheng xia $credit PP ke yi
buff.");
}
}
}
elsif ($text =~ /pay/i)
{
if ($cost > 0)
{
quest::say("Rang wo kan kan, $race.. nin zui shao xu yao $cost PP, bu neng zai
jiang jia le.");
quest::say("Nin hai you $credit PP zai wo zhe li, ru guo nin da suan zai cun yi
xie,"
. " zhi jie ba PP gei wo jiu ke yi le");
}
else
{
quest::say("Nin kan shang qu xiang ge nian qing ren, $name. mian fei!");
}
}
}
else
{
if ($text =~ /hail/i)
{
quest::say("If you want some [$saylink1] just let me know. Of course you may have to [$saylink2].");
$npc->SetAppearance(0);
quest::settimer(1,10);
}
elsif ($text =~ /buffs/i)
{
if ($credit < $cost)
{
quest::say("Phuh! Are you trying to cheat me? You need "
. ($cost - $credit) . " more plat!");
}
else
{
castspells(@buffs);
# Only record and say this stuff if there was a cost
if ($cost > 0)
{
$credit -= $cost;
quest::setglobal('buffcredit', "$credit", 5, 'F');
quest::say("Thanks $name! You have $credit left in credit.");
}
}
}
elsif ($text =~ /pay/i)
{
if ($cost > 0)
{
quest::say("Let's see, $race.. For you? A lowly $cost plat!");
quest::say("You have $credit plat in credit. If you want more credit,"
. " just hand me some plat!");
}
else
{
quest::say("You look like a nice young $race, $name. No charge for you!");
}
}
}
}
sub EVENT_ITEM
{
my $credit = $qglobals{buffcredit} ? $qglobals{buffcredit} : 0;
if (defined $qglobals{hkchinese})
{
if ($platinum > 0)
{
$credit += $platinum;
quest::setglobal('buffcredit', "$credit", 5, 'F');
quest::say("Xie xie $name! nin xian zai you $credit PP zai wo zhe li!");
}
else
{
plugin::return_items(\%itemcount);
}
}
else
{
if ($platinum > 0)
{
$credit += $platinum;
quest::setglobal('buffcredit', "$credit", 5, 'F');
quest::say("Thank You $name! You now have $credit PP credit");
}
else
{
plugin::return_items(\%itemcount);
}
}
}
|