local textures = {} textures['Serpent Sting'] = 'Ability_Hunter_Quickshot' textures['Hunter\'s Mark'] = 'Ability_Hunter_SniperShot' textures['Arcane Shot'] = 'Ability_ImpalingBolt' textures['Concussive Shot'] = 'Spell_Frost_Stun' textures['Throw'] = 'Ability_Throw' local function getTexture(spellName) if textures[spellName] ~= nil then return textures[spellName] end return false end local function getSlot(spellTexture) for i = 1, 120, 1 do if GetActionTexture(i) ~= nil then -- print(GetActionTexture(i)) if (strfind(GetActionTexture(i), spellTexture)) then return i end end end return 0 end local function isUsable(spellName) local spellTexture = getTexture(spellName) if spellTexture then local slot = getSlot(spellTexture) local usable, _ = IsUsableAction(slot) return usable else return false end end local function debuffIndex(spellTexture) for i = 1, 40 do local texturePath = UnitDebuff('target', i) if texturePath ~= nil and strfind(texturePath, spellTexture) then return i end end return 0 end local function debuffStacks(spellName) local spellTexture = getTexture(spellName) if spellTexture then local _, stacks = UnitDebuff('target', debuffIndex(spellTexture)) if stacks == nill then return 0 else return stacks end else print(spellName) return false end end function onCooldown(spellName) local spellID = 1 local name, _ = GetSpellName(spellID, 'BOOKTYPE_SPELL') while (name) do if spellName == name then if GetSpellCooldown(spellID, 'BOOKTYPE_SPELL') == 0 then return false else return true end end spellID = spellID + 1 name, _ = GetSpellName(spellID, 'BOOKTYPE_SPELL') end end local function cast(spellName) CastSpellByName(spellName) end local function healthGtThan(percent, health, max) if health / max > percent / 100 then return true end return false end local function attack() if GetUnitName('target') == nil then PetFollow() TargetNearestEnemy() return else if UnitCanAttack('player', 'target') == nil then ClearTarget() return elseif UnitIsDead('target') == 1 then ClearTarget() return elseif UnitIsPlayer('target') == 1 then ClearTarget() return elseif UnitHealth('target') ~= UnitHealthMax('target') and UnitIsUnit('player', 'targettarget') == nil then ClearTarget() return end local mana = UnitMana('player') local health = UnitHealth('player') if not UnitIsUnit('target', 'pettarget') and UnitExists('pet') and not UnitIsDead('pet') then PetAttack() end if CheckInteractDistance('target', 3) and (not PlayerFrame.inCombat) then AttackTarget() else if isUsable('Hunter\'s Mark') and not buffed('Hunter\'s Mark', 'target') then cast('Hunter\'s Mark') elseif not IsAutoRepeatAction(47) then cast('Auto Shot') elseif isUsable('Serpent Sting') and not buffed('Serpent Sting', 'target') and healthGtThan(25, UnitHealth('target'), UnitHealthMax('target')) then cast('Serpent Sting') elseif isUsable('Concussive Shot') and not onCooldown('Concussive Shot') then cast('Concussive Shot') elseif isUsable('Arcane Shot') and not onCooldown('Arcane Shot') then cast('Arcane Shot') end end end end function wlob_onLoad() SlashCmdList['WLOB'] = attack SLASH_WLOB1 = '/wlob' end