adding a function the bot will recognize

Runes of Magic/Radiant Arcana (http://www.runesofmagic.com)
Post Reply
Message
Author
j_schlott
Posts: 119
Joined: Tue Aug 18, 2009 11:42 pm

adding a function the bot will recognize

#1 Post by j_schlott » 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:

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>
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:

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;
end
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

j_schlott
Posts: 119
Joined: Tue Aug 18, 2009 11:42 pm

Re: adding a function the bot will recognize

#2 Post by j_schlott » Fri Dec 25, 2009 1:06 pm

it would look something like this:

Code: Select all

	<onLeaveCombat><![CDATA[
      local counter = 1;
      if ChkBuff("BUFFNAME") then
      counter = counter+1;
      else
      player:rest(1);
      RoMScript("UseSkill(4,3)");  ---sumon skill
      player:rest(9);
      RoMScript("UseSkill(4,9)");  ---sacrifice skill
      player:rest(1);
      end
	]]></onLeaveCombat>
Last edited by j_schlott on Fri Dec 25, 2009 1:51 pm, edited 1 time in total.

User avatar
Administrator
Site Admin
Posts: 5307
Joined: Sat Jan 05, 2008 4:21 pm

Re: adding a function the bot will recognize

#3 Post by Administrator » Fri Dec 25, 2009 1:34 pm

You can use this:

Code: Select all

local haveBuff = RoMScript("};a=false;for b=1,20 do if(UnitBuff('player',b)=='Buff Name') then a=true; end;");
Untested, but it should work.

j_schlott
Posts: 119
Joined: Tue Aug 18, 2009 11:42 pm

Re: adding a function the bot will recognize

#4 Post by j_schlott » Fri Dec 25, 2009 2:16 pm

hm im a nub, and i have no idea what that is going to return, the variables and crap is way over my coding head

do i change the 'Buff Name' section to my buff? and then it returns true or false?


i get a error on you code aswell, " unexpected symbol near '}' "

User avatar
Administrator
Site Admin
Posts: 5307
Joined: Sat Jan 05, 2008 4:21 pm

Re: adding a function the bot will recognize

#5 Post by Administrator » Fri Dec 25, 2009 11:14 pm

Oh, right, forgot to make the end brackets match up. Try this:

Code: Select all

local haveBuff = RoMScript("false};for b=1,20 do if(UnitBuff('player',b)=='Buff Name') then a[1]=true; end;b={");
The brackets are used kind of hackishly, but the general idea is to just complete the code segment that's put in there automatically with RoMScript(). Any values we place into variable 'a' will be returned by RoMScript. So, yes, it should now return true or false if the player has the buff named 'Buff Name' (which you should change to whatever you're searching for.

j_schlott
Posts: 119
Joined: Tue Aug 18, 2009 11:42 pm

Re: adding a function the bot will recognize

#6 Post by j_schlott » Mon Dec 28, 2009 8:22 am

hi, sorry i didnt get back sooner, holidays and all.

i get an error still with your script, a different one this time: end expected near eof

i started using this, it works pretty well
***edit2 i changed the buff time left to 20sec so potions/HoT wouldnt affect it:

Code: Select all

	<onLeaveCombat>
	local buff = RoMScript("GetPlayerBuffLeftTime(GetPlayerBuff(1, 'HELPFUL'))");
	if (buff < 20) then
		player:rest(1.2);
		keyboardPress(key.VK_6);
		player:rest(11);
	end
	</onLeaveCombat>
key 6 is a ingame macro that cast summons/waits/cast sacrifice
Last edited by j_schlott on Mon Dec 28, 2009 11:44 am, edited 1 time in total.

User avatar
Administrator
Site Admin
Posts: 5307
Joined: Sat Jan 05, 2008 4:21 pm

Re: adding a function the bot will recognize

#7 Post by Administrator » Mon Dec 28, 2009 10:20 am

Code: Select all

   <onLeaveCombat><![CDATA[
   local buff = RoMScript("GetPlayerBuffLeftTime(GetPlayerBuff(1, 'HELPFUL'))");
   if (buff < 20) then
      player:rest(1.2);
      keyboardPress(key.VK_6);
      player:rest(11);
   end
   ]]></onLeaveCombat>

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 7 guests