155 lines
4.4 KiB
Lua
155 lines
4.4 KiB
Lua
local textures = {}
|
|
|
|
textures['Serpent Sting'] = 'Ability_Hunter_Quickshot'
|
|
textures['Hunter\'s Mark'] = 'Ability_Hunter_SniperShot'
|
|
textures['Kill Command'] = 'ability_hunter_killcommand'
|
|
textures['Baited Shot'] = 'inv_misc_food_66'
|
|
textures['Arcane Shot'] = 'Ability_ImpalingBolt'
|
|
textures['Multi-Shot'] = 'Ability_UpgradeMoonGlaive'
|
|
textures['Steady Shot'] = 'Ability_Hunter_SteadyShot'
|
|
textures['Concussive Shot'] = 'Spell_Frost_Stun'
|
|
textures['Throw'] = 'Ability_Throw'
|
|
textures['Blood Fury'] = 'Racial_Orc_BerserkerStrength'
|
|
|
|
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 gt(percent, value, max)
|
|
if value / 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 isUsable('Blood Fury') and not onCooldown('Blood Fury') then
|
|
cast('Blood Fury')
|
|
elseif isUsable('Baited Shot') and not onCooldown('Baited Shot') and gt(40, mana, UnitManaMax('player')) then
|
|
cast('Baited Shot')
|
|
elseif isUsable('Kill Command') and not onCooldown('Kill Command') and gt(60, mana, UnitManaMax('player')) then
|
|
cast('Kill Command')
|
|
-- elseif isUsable('Steady Shot') and not onCooldown('Steady Shot') then
|
|
-- cast('Steady Shot')
|
|
elseif isUsable('Arcane Shot') and not onCooldown('Arcane Shot') then
|
|
cast('Arcane Shot(Rank 1)')
|
|
elseif isUsable('Multi-Shot') and not onCooldown('Multi-Shot') and gt(80, mana, UnitManaMax('player')) then
|
|
cast('Multi-Shot')
|
|
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')
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|
|
function wlob_onLoad()
|
|
SlashCmdList['WLOB'] = attack
|
|
SLASH_WLOB1 = '/wlob'
|
|
end
|