adding a function the bot will recognize
Posted: Fri Dec 25, 2009 12:51 pm
how /where would i place a function so the bot is able to use it
i would like to script something for a warden in the onleavecombat tags
they get a spells to summon/sacrifice a pet for buffs, i dont think the bot can handle that correctly as-is
so i want to use a custom function i found on the runes forums to check for that buff on leaving combat, and if not present, run the summon/sacrifice script
atm im using:
but sometimes it lags through, doesnt cast then waits 600seconds for the cooldown, or sometimes it regains agro and gets interrupted halfway through and then has to wait 600seconds, or sometimes even the fast looting seems to mess it up
so i think it would be much more effective to use a buff check after each kill, instead of a timer
function:
i tried adding the function into functions.lua but i get a error saying tried to call global UnitIsPlayer a nil value, i also tried adding it as its own lua file inside the scripts/rom folder and having bot.lua call it, but i get the same error
so i think the bot isnt set up to see the game function UnitIsPlayer, and im not sure how to set it as something the bot recognizes
i would like to script something for a warden in the onleavecombat tags
they get a spells to summon/sacrifice a pet for buffs, i dont think the bot can handle that correctly as-is
so i want to use a custom function i found on the runes forums to check for that buff on leaving combat, and if not present, run the summon/sacrifice script
atm im using:
Code: Select all
<onLeaveCombat><![CDATA[
if(player.free_counter2 == 0) then player.free_counter2 = os.time(); end;
if( os.difftime(os.time(), player.free_counter2) > 600 ) then
player.free_counter2 = os.time();
player:rest(1);
RoMScript("UseSkill(4,3)"); ---sumon skill
player:rest(9);
RoMScript("UseSkill(4,9)"); ---sacrifice skill
player:rest(1);
end
]]></onLeaveCombat>so i think it would be much more effective to use a buff check after each kill, instead of a timer
function:
Code: Select all
function ChkBuff(tgt, ...)
local counter = 1;
local friendly = UnitIsPlayer(tgt);
local currentbuff = "none";
while (currentbuff ~= nil) do
if friendly then
currentbuff = UnitBuff(tgt, counter);
else
currentbuff = UnitDebuff(tgt, counter);
end
for i,v in pairs(arg) do
if (currentbuff == tostring(v)) then
return true;
end
end
counter = counter + 1;
end
return false;
endso i think the bot isnt set up to see the game function UnitIsPlayer, and im not sure how to set it as something the bot recognizes