OBD/main.lua
2025-09-24 01:05:01 +03:00

238 lines
5.8 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'
textures['Enrage'] = 'Ability_Druid_Enrage'
textures['Maul'] = 'Ability_Druid_Maul'
textures['Savage Bite'] = 'Ability_Racial_Cannibalize'
textures['Demoralizing Roar'] = 'Ability_Druid_DemoralizingRoar'
textures['Shred'] = 'Spell_Shadow_VampiricAura'
textures['Reshift'] = 'spell_reshift_2'
textures['Swipe'] = 'INV_Misc_MonsterClaw_03'
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 buffIndex(spellTexture)
for i = 1, 40 do
local texturePath = UnitBuff('player', i)
if texturePath ~= nil and strfind(texturePath, spellTexture) then
return i
end
end
return 0
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 getBuffTimeLeft(buffName)
local buffTexture = getTexture(buffName)
if buffTexture then
local name, _, _, _, _, duration, expirationTime = UnitBuff('player', buffIndex(buffTexture))
return GetPlayerBuffTimeLeft(buffIndex(buffTexture))
else
return false
end
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
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 target()
if GetUnitName('target') == nil then
TargetNearestEnemy()
return
else
if UnitCanAttack('player', 'target') == nil then
ClearTarget()
return
elseif UnitIsDead('target') == 1 then
ClearTarget()
return
end
end
end
local function reshift(lt)
if isUsable('Reshift') and UnitMana('player') <= lt then
cast('Reshift')
end
end
local function dps(cp)
local mana = UnitMana('player')
local health = UnitHealth('player')
if (not PlayerFrame.inCombat) then
AttackTarget()
else
if comboPoints() < cp then
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('Rake') and not buffed('Rake', 'target') then
cast('Rake')
elseif isUsable('Rip') and comboPoints() > 0 and not buffed('Rip', 'target') then
cast('Rip')
elseif isUsable('Claw') then
cast('Claw')
end
elseif comboPoints() >= cp then
if isUsable('Ferocious Bite') then
cast('Ferocious Bite')
end
end
end
end
local function tank()
local mana = UnitMana('player')
local health = UnitHealth('player')
if (not PlayerFrame.inCombat) then
AttackTarget()
else
if mana < 10 then
if isUsable('Reshift') and mana <= 10 then
cast('Reshift')
elseif isUsable('Enrage') and not buffed('Enrage', 'player') and not onCooldown('Enrage') then
cast('Enrage')
end
end
if mana > 60 then
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('Demoralizing Roar') and not buffed('Demoralizing Roar', 'target') then
cast('Demoralizing Roar')
end
end
if isUsable('Maul') then
cast('Maul')
end
end
end
local function dps_st()
target()
if buffed('Clearcasting', 'player') then reshift(40) end
if getBuffTimeLeft('Tiger\'s Fury') < 5 then reshift(40) end
dps(5)
end
local function dps_trash()
target()
if buffed('Clearcasting', 'player') then reshift(40) end
if getBuffTimeLeft('Tiger\'s Fury') < 5 then reshift(40) end
dps(3)
end
local function tank_st()
target()
tank()
if isUsable('Savage Bite') and not onCooldown('Savage Bite') then
cast('Savage Bite')
end
end
local function tank_aoe()
target()
tank()
if isUsable('Swipe') then
cast('Swipe')
end
end
function obd_onLoad()
SlashCmdList['DPS_ST'] = dps_st
SlashCmdList['DPS_TRASH'] = dps_trash
SlashCmdList['TANK_ST'] = tank_st
SlashCmdList['TANK_AOE'] = tank_aoe
SLASH_DPS_ST1 = '/dps_st'
SLASH_DPS_TRASH1 = '/dps_trash'
SLASH_TANK_ST1 = '/tank_st'
SLASH_TANK_AOE1 = '/tank_aoe'
end