OBD/main.lua
2025-09-02 18:32:39 +03:00

159 lines
4.3 KiB
Lua

local textures = {}
textures['Claw'] = 'Ability_Druid_Rake'
textures['Rip'] = 'Ability_GhoulFrenzy'
textures['Ferocious Bite'] = 'Ability_Druid_FerociousBite'
textures['Tiger\'s Fury'] = 'Ability_Mount_JungleTiger'
textures['Faerie Fire (Feral)'] = 'Spell_Nature_FaerieFire'
textures['Rake'] = 'Ability_Druid_Disembowel'
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 comboPoints()
return GetComboPoints('player', 'target')
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
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
end
local mana = UnitMana('player')
local health = UnitHealth('player')
if (not PlayerFrame.inCombat) then
AttackTarget()
else
cast('Faerie Fire (Feral)')
if isUsable('Faerie Fire (Feral)') and not buffed('Faerie Fire (Feral)', 'target') and
not onCooldown('Faerie Fire (Feral)') then
cast('Faerie Fire (Feral)()')
elseif isUsable('Tiger\'s Fury') and not buffed('Tiger\'s Fury', 'player') then
cast('Tiger\'s Fury')
elseif isUsable('Ferocious Bite') and comboPoints() > 2 then
cast('Ferocious Bite')
elseif isUsable('Rake') and not buffed('Rake', 'target') then
cast('Rake')
elseif isUsable('Claw') then
cast('Claw')
-- elseif isUsable('Blood Fury') and not onCooldown('Blood Fury') then
-- cast('Blood Fury')
-- elseif not IsAutoRepeatAction(47) then
-- cast('Auto Shot')
-- elseif isUsable('Multi-Shot') and not onCooldown('Multi-Shot') then
-- cast('Multi-Shot')
-- elseif isUsable('Steady Shot') and not onCooldown('Steady Shot') then
-- cast('Steady Shot')
-- elseif isUsable('Baited Shot') and not onCooldown('Baited Shot') then
-- cast('Baited Shot')
-- elseif isUsable('Kill Command') and not onCooldown('Kill Command') then
-- cast('Kill Command')
-- elseif isUsable('Arcane Shot') and not onCooldown('Arcane Shot') then
-- cast('Arcane Shot(Rank 1)')
-- 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 obd_onLoad()
SlashCmdList['OBD'] = attack
SLASH_OBD1 = '/obd_lvl'
end