Page 1 of 1

Get Skill cooldown to use in profile

Posted: Thu Aug 20, 2015 7:10 am
by Karkant
Hi all;

I want to chek the skills cooldown to make a good decision on "onPreskillCast" section fo the profile.

Return the boolean value depending on some skill cooldown, example:

if arg1.Name == "ROGUE_SHODOWSTAB" then
if (X)Skill.cooldown > 3 then
return false
end

How o which function can give this information? I want to compare the cooldown to a number to take the decision.

I found other information in forum, but nothing concrete.

Thanks

Re: Get Skill cooldown to use in profile

Posted: Thu Aug 20, 2015 1:06 pm
by Bill D Cat
You'd likely have to do something like this. It scans each tab of your skills looking for a match to the name you specify. Then it should get the max cooldown and remaining cooldown of the skill for you.

Code: Select all

skillToCheck = "Shadowstab"
for tab = 2 to 4
  numskills = RoMScript("GetNumSkill("..tab..")")
  if numskills then
    for slot = 1, numskills do
      skillname = RoMScript("GetSkillDetail("..tab..","..slot..")")
      if skillname == skillToCheck then
        skillMaxCD, remainingCD = RoMScript("GetSkillCooldown("..tab..","..slot..")")
      end
    end
  end
end

Re: Get Skill cooldown to use in profile

Posted: Thu Aug 20, 2015 1:30 pm
by Karkant
Super :)

But, I need to use this code as a function? Where I can declare it in profile?

Thanks for your support!

Re: Get Skill cooldown to use in profile

Posted: Thu Aug 20, 2015 2:29 pm
by noobbotter
You can have an onLoad section in your profile and declare the function in there:

Code: Select all

<onLoad><![CDATA[
		-- Additional Lua code to execute after loading the profile
		-- and before the bot starts. e.g. You could overwrite profile settings here
		-- like: changeProfileOption("HP_REST", 60);
		-- startGMDetect()
		-- loadPaths("FAmainclass");
		-- function doWhatever()
			-- do something
			-- do something else
		-- end
   	]]></onLoad>
Then in your onPreskillCast event, call the function.

Re: Get Skill cooldown to use in profile

Posted: Thu Aug 20, 2015 9:28 pm
by lisa
This is what I use on rogue

Code: Select all

   <onPreSkillCast><![CDATA[
		local target = player:getTarget();
		if arg1.Name == "ROGUE_WOUND_ATTACK"  then
			if target:hasBuff(620313) and target:hasBuff(620314) then
				return true
			else
				return false
			end
		elseif arg1.Name == "ROGUE_LOW_BLOW"  then
			if target:hasBuff(620313) then         	-- Bleed
				LBBuff = target:getBuff(620314)		-- Grevious Wound
				if LBBuff and LBBuff.TimeLeft >= 3 then
					if player.Energy >= 60 then 
						return true 
					else 
						return false 
					end
				end
			end
		elseif arg1.Name == "ROGUE_SHADOWSTAB"  then
			SSBuff = target:getBuff(620313)
			if SSBuff and SSBuff.TimeLeft >= 3 then
				return false
			end
		end
   ]]></onPreSkillCast>

Re: Get Skill cooldown to use in profile

Posted: Fri Aug 21, 2015 2:14 am
by Karkant
Thanks to all;

I will take your advices!

Re: Get Skill cooldown to use in profile

Posted: Tue Nov 03, 2015 3:01 am
by ThulsaDoom
I define the code for tab read in Onload section.
But I don't know how I can call these information (skillMaxCD, remainingCD) on "OnPreSkillcast", I do it in the traditional form: "if remainingCD > 4", but it doesn't work.

I'm missing something about variable declaration or calling.

Re: Get Skill cooldown to use in profile

Posted: Tue Nov 03, 2015 3:45 am
by lisa
The table of skill info is arg1 so you would need something like

Code: Select all

if arg1:getRemainingCooldown() > 4 then


end
untested and to be honest not sure if it will work or not.

to test just do

Code: Select all

print(arg1:getRemainingCooldown())
--=== Added ===--
Ahh I see you are talking about the code posted by Bill D Cat, when in doubt use prints, that is what I say.

Re: Get Skill cooldown to use in profile

Posted: Tue Nov 03, 2015 4:49 am
by ThulsaDoom
Yes (referring to Bill D Cat), I don't know how to link the code in onLoad section to onPresSkillCast.

But I will test what you propose.

Thanks

Re: Get Skill cooldown to use in profile

Posted: Tue Nov 03, 2015 7:32 am
by sauhard
lisa wrote:This is what I use on rogue

Code: Select all

   <onPreSkillCast><![CDATA[
		local target = player:getTarget();
		if arg1.Name == "ROGUE_WOUND_ATTACK"  then
			if target:hasBuff(620313) and target:hasBuff(620314) then
				return true
			else
				return false
			end
		elseif arg1.Name == "ROGUE_LOW_BLOW"  then
			if target:hasBuff(620313) then         	-- Bleed
				LBBuff = target:getBuff(620314)		-- Grevious Wound
				if LBBuff and LBBuff.TimeLeft >= 3 then
					if player.Energy >= 60 then 
						return true 
					else 
						return false 
					end
				end
			end
		elseif arg1.Name == "ROGUE_SHADOWSTAB"  then
			SSBuff = target:getBuff(620313)
			if SSBuff and SSBuff.TimeLeft >= 3 then
				return false
			end
		end
   ]]></onPreSkillCast>
Can you explain me what is actually happening. I understand that it checks for bleed for casting further attacks, but don't exactly know what's going on where :P

Re: Get Skill cooldown to use in profile

Posted: Tue Nov 03, 2015 11:19 am
by noobbotter
Here's an explanation of what's going on during that sequence (in the comments):

Code: Select all

<onPreSkillCast><![CDATA[
	local target = player:getTarget();
	if arg1.Name == "ROGUE_WOUND_ATTACK"  then 		-- if the skill getting ready to be used is Wound Attack:
		if target:hasBuff(620313) and target:hasBuff(620314) then -- if target has bleed and Grevious wound...
			return true 							-- if has both, then yes, use Wound Attack...
		else
			return false 							-- if does not have both, don't use wound attack.
		end
	elseif arg1.Name == "ROGUE_LOW_BLOW"  then		-- if skill getting ready to be used is Low Blow:
		if target:hasBuff(620313) then            	-- Only use Low Blow if target has a bleed on...
			LBBuff = target:getBuff(620314)      	-- Let's see how much time is left on the Grevious Wound:
			if LBBuff and LBBuff.TimeLeft >= 3 then	-- if 3 or more seconds of Greivous Wound remain...
				if player.Energy >= 60 then 		-- and we have 60 or more energy...
					return true 					-- then yes, use the Low Blow
				else 	
					return false 					-- otherwise, don't Low Blow yet.
				end
			end
		end
	elseif arg1.Name == "ROGUE_SHADOWSTAB"  then	-- If getting ready to do a Shadowstab...
		SSBuff = target:getBuff(620313)				-- Does target already have a bleed effect?
		if SSBuff and SSBuff.TimeLeft >= 3 then		-- how much time is reamaining on the bleed? If 3 or more seconds remaining on it...
			return false							-- then don't use Shadowstab.
		end											-- (otherwise it will use the shadowstab)
	end
]]></onPreSkillCast>
So, the bot is taking it's turns attempting to use it's applicable skills. The onPreSkillCast section is what ensures that it only uses those skills at the right times. For instance, If the bot is trying to use a Low Blow, it will see if there is already a bleed on the target, because it's best to always use Shadowstab before the low blow.

Re: Get Skill cooldown to use in profile

Posted: Tue Nov 03, 2015 11:49 pm
by lisa
ThulsaDoom wrote:Yes (referring to Bill D Cat), I don't know how to link the code in onLoad section to onPresSkillCast.

But I will test what you propose.

Thanks
Ok what I posted won't do what you want because you aren't after the cooldown of the skill trying to be used, I am making a few assumptions here because you haven't actually said what you are really trying to do.

Code: Select all

<onLoad><![CDATA[
function getcooldown(skillname)
for k,v in pairs(settings.profile.skills) do  -- go through skills you have in profile
if v.Name == skillname then -- look for the skill name you want, as it is listed in profile
 local tmp = CSkill(v)  -- this gets the skill info from memory
 print(tmp:getRemainingCooldown()) -- this uses a function to get the cooldown of that skill, in this case it prints it.
 return tmp:getRemainingCooldown()
 end 
 end
 end
 ]]></onLoad>

Code: Select all

<onPreSkillCast><![CDATA[
if getcooldown("ROGUE_ASSASSINS_RAGE") > 4 then 
print("assasins rage has longer than 4 seconds as cooldown")
end
]]></onPreSkillCast>
Hopefully this will at least get you started in what you are really trying to do.

Re: Get Skill cooldown to use in profile

Posted: Fri Nov 06, 2015 4:22 pm
by ThulsaDoom
great, it works! Thanks

Re: Get Skill cooldown to use in profile

Posted: Sat Nov 07, 2015 4:47 am
by ThulsaDoom
Now I can select between "Keen Attack" or "Splitting Chop" depending on its availability. This allow to be efficient on rage use.
Here the options on <skills_warrior> and <OnPreSkillCast> for Warrior / Rogue.

Code: Select all

		<skill name="WARRIOR_SPLITTING_CHOP"    hotkey="MACRO" priority="100"/>
		<skill name="WARRIOR_OPEN_FLANK"      	hotkey="MACRO" priority="95" />
		<skill name="WARRIOR_KEEN_ATTACK"      	hotkey="MACRO" priority="90" />
		<skill name="WARRIOR_PROBING_ATTACK" 	hotkey="MACRO" priority="85" />
		<skill name="ROGUE_THROW"    		hotkey="MACRO" priority="80" />
		<skill name="WARRIOR_BLOOD_DANCE"      	hotkey="MACRO" priority="75" />
		<skill name="WARRIOR_SLASH"     	hotkey="MACRO" priority="70" />
		<skill name="ROGUE_SHADOWSTAB"    	hotkey="MACRO" priority="65" />
		<skill name="WARRIOR_FRENZY"    	hotkey="MACRO" priority="50" autouse="false" />
		<skill name="WARRIOR_FRENZIED_ATTACK"   hotkey="MACRO" priority="50" autouse="false" />
		<skill name="WARRIOR_COMPOSURE"		hotkey="MACRO" priority="50" autouse="false" />

Code: Select all

	<OnPreSkillCast><![CDATA[
	
		if arg1.Name == "ROGUE_SHADOWSTAB"  then
         		if player.Energy >= 40 then
				if (target:hasBuff("Vulnerable")) or (target:hasBuff("Weakened")) then
            				return false
				else
            				return true
				end
			else
				return false
			end
      		elseif arg1.Name == "WARRIOR_BLOOD_DANCE"  then
         		if player.HP/player.MaxHP*100 > 90 then
				if player.Energy <= 20 then
            				return true
          			else
            				return false
          			end
			else
            			return false
          		end
		elseif arg1.Name == "WARRIOR_PROBING_ATTACK"  then
         		if player.Rage >= 45 then
            			return true
          		else
            			return false
          		end
		elseif arg1.Name == "WARRIOR_OPEN_FLANK"  then
         		if getcooldown("WARRIOR_SPLITTING_CHOP") < 3 then 
            			return true
          		else
            			return false
          		end
		elseif arg1.Name == "WARRIOR_SLASH"  then
         		if player.Rage >= 60 then
            			return true
			else
            			return false
          		end
      		end
	]]></OnPreSkillCast>