I have edit this code to make buff bots in the guild lobby. The cleric one I made will cast temperance on players but I cant see to get this one to cast kei on a player... it cast it on itself... any suggestion why this is happening or how to fix it?
Code:
#A buff bot script.
#Buffs a player for pp.
#SpellList Is the array containing the names of the spells. SpellCost Is the amount in pp for each spell. SpellID Is the spell that Is cast by the npc.
#Note these are 3 arrays. each position in the array corosponds to the same position in the other arrays.
#So I have this set so that if you say 'Spirit of Wolf' and pay 2 pp, then the npc will cast spell 278 on you.
#I am setting the amounts to pp just because they can be any amount you wish, this requires changing the EVENT_ITEM Function to handle the other money types.
@SpellList = ("Bind Affinity","”See Invisible","Serpent Sight","Intellectual Advancement","Rune I","Breeze","Quickness","Intellectual Superiority","Alacrity","Rune II","Clarity","Augmentation","Ward of Alendar","Radiant Visage","Clarity II","Rune III","Gift of Magic","Insight","Celerity","Rune IV","Brilliance","Guard of Alendar","Adorning Grace","Swift Like the wind","Improved Invisibility","Rune V","Aanya's Quickening","Gift of Insight","Protection of Alendar","Overwhelming Splendor","Augment","Wonderous Rapidity","Gift of Brilliance","KEI");
@SpellCost = ("2","2","1","2","3","3","2","3","5","6","5","7"," 4","5","7","9","5","5","5","12","7","6","8","8","1 0","15","10","8","10","10","10","12","12","25") ;
@SpellID = ("35","80","276","2561","481","697","39","2562","1 70","482","174","10","4073","646","1693","483","14 08","175","171","184","33","4074","647","172","140 6","1689","1708","1403","4075","1701","1729","1709 ","1410","2570");
sub EVENT_SPAWN
{
quest::settimer("buffy", 90);
quest::ooc("Mind buffs in Guild Lobby");
quest::settimer("despawnbuffy", 1300)
}
sub EVENT_TIMER
{
#$npc->SetAppearance(1);
if($timer eq "buffy")
{
my $random_number = int(rand(4));
if ($random_number == 0)
{
quest::shout("I have the buffs you're looking for...");
}
elsif ($random_number == 1)
{
quest::shout("Clarity, Clarity II, KEI, and Haste in Guild Lobby");
}
elsif ($random_number == 2)
{
quest::shout("Buffing for Platinum! Proceedes go to Arcane Scholarship funds");
}
elsif ($random_number == 3)
{
quest::say("Terran, Please stop touching me.");
}
$npc->SetAppearance(int(rand(2)));
}
if($timer eq "despawnbuffy")
{
quest::say ("I'm off to shower. This place makes my skin crawl");
quest::depop();
}
}
sub EVENT_SAY
{
my $all = quest::saylink("List", 1);
my $buffs = quest::saylink("Buffs",1);
#Spacer between Text messages to make them easier to read
$client->Message(7, "-");
my $NPCName = $npc->GetCleanName();
if ($text =~/Hail/i)
{
$npc->SetAppearance(0);
$client->Message(315, "$NPCName whispers to you, 'Please let me know what [$buffs] you'd like, or I can list them [$all] for you. '");
}
#Counts each row for the while
my $count = 1;
#Counts each element in the Array for the while
my $n = 0;
if ($text !~ /Hail/i)
{
while ($SpellList[$n])
{
#This searches the list to find possible matches. The lc() command makes all text lowercase.
#It Is easier to make all text lower case for comparison, if the user types uppercase it will still match.
if ((lc($SpellList[$n]) =~ lc($text) && lc($SpellList[$n]) ne lc($text)) || ($text =~ /^List$/i))
{
my $SpellList = quest::saylink($SpellList[$n]);
my $SpellCost = $SpellCost[$n];
$client->Message(315, "$NPCName whispers to you, 'Possible match is: $SpellList and it costs $SpellCost pp");
}
if ((lc($SpellList[$n]) =~ lc($text) && lc($SpellList[$n]) ne lc($text)) || (($text =~ /Buffs/i) && ($SpellList[$n] !~ /Port to/i)))
{
my $SpellList = quest::saylink($SpellList[$n]);
my $SpellCost = $SpellCost[$n];
$client->Message(315, "$NPCName whispers to you, 'Possible match is: $SpellList and it costs $SpellCost pp");
}
if ((lc($SpellList[$n]) =~ lc($text) && lc($SpellList[$n]) ne lc($text)) || (($text =~ /Ports/i) && ($SpellList[$n] =~ /Port to/i)) )
{
my $SpellList = quest::saylink($SpellList[$n]);
my $SpellCost = $SpellCost[$n];
$client->Message(315, "$NPCName whispers to you, 'Possible match is: $SpellList and it costs $SpellCost pp");
}
#This Is the command that Is executed when a the user enters a spell.
if (lc($SpellList[$n]) eq lc($text) && $text !~ /^List$/i)
{
#Creates a global variable. You must set the qgolbal field in the npc_types table to 1 for each npc you wish to handle global variables.
#buff Is the name, $text Is what the varible should be eq too, 0 only this npc, char, And zone apply to the variable, M5 Is 5 minutes.
quest::setglobal("buff", $text, 0, "M5");
#I'm not sure why I need the next line, the line above should set the $qglobals{buff}, but it wouldn't work for me.
$qglobals{buff} = $text;
$client->Message(315, "Please give me $SpellCost[$n]pp, and I'll cast $qglobals{buff} for you!");
}
$n++;
$count++;
}
}
}
sub EVENT_ITEM
{
my $correctmoney = 0;
#Counts each row for the while
my $count = 1;
#Counts each element in the Array for the while
my $n = 0;
#Cycles through each spell in the array until it matches the requested spell, And the amount pp required.
while ($SpellList[$n])
{
if(($SpellList[$n] eq $qglobals{buff}) && ($platinum == $SpellCost[$n]))
{
$client->Message(315, "Thank you for the $SpellCost[$n]pp, prepare for $qglobals{buff}!");
if ($SpellList[$n] =~ /Port to/i)
{
quest::selfcast($SpellID[$n])
}
else
{
$npc->CastSpell($SpellID[$n], $userid);
}
#set this to 1 so that we don't return money we shouldn't.
$correctmoney = 1;
}
$n++;
$count++;
}
#Returns the money if it Is Not the correct amount.
if ($correctmoney == 0 )
{
if(($copper > 0) || ($silver > 0) || ($gold > 0) || ($platinum > 0))
{
$client->Message(315, "I don't need these coins, you may have them back.");
quest::givecash($copper,$silver,$gold,$platinum);
}
}
#deletes the $qglobals{buff} variable.
quest::delglobal("buff");
}