OBWT/OBWT.lua

63 lines
2.0 KiB
Lua

local function getSlot(spellTexture)
for i = 1, 120, 1 do
if GetActionTexture(i) ~= nil then
if(strfind(GetActionTexture(i), spellTexture)) then return i end
end
end
return 0
end
local function isUsable(spellTexture)
local usable, _ = IsUsableAction(getSlot(spellTexture))
return usable
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(spellTexture)
local _, stacks = UnitDebuff('target', debuffIndex(spellTexture))
if stacks == nill then return 0 else return stacks end
end
local function main(cmd)
local rage = UnitMana('player')
local bloodrage = 'Ability_Racial_BloodRage'
local revenge = 'Ability_Warrior_Revenge'
local sunderArmor = 'Ability_Warrior_Sunder'
local rend = 'Ability_Gouge'
local battleShout = 'Ability_Warrior_BattleShout'
local heroicStrike = 'Ability_Rogue_Ambush'
if UnitExists('target') and UnitCanAttack('player','target') then
if (not PlayerFrame.inCombat) then AttackTarget() end
if rage < 15 and isUsable(bloodrage) then
CastSpellByName('Bloodrage')
if PlayerFrame.inCombat and GetUnitName('targettarget')~=GetUnitName('player') then
CastSpellByName('Taunt')
elseif buffed('Battle Shout') == nil and isUsable(battleShout) then
CastSpellByName('Battle Shout')
elseif isUsable(revenge) then
CastSpellByName('Revange')
elseif isUsable(sunderArmor) and debuffStacks(sunderArmor) < 5 then
CastSpellByName('Sunder Armor')
elseif rage > 60 and buffed('Shield Block') == nil then
CastSpellByName('Shield Block')
elseif rage > 70 and buffed('Demoralizing Shout', 'target') == nil then
CastSpellByName('Demoralizing Shout')
elseif rage > 80 and buffed('Rend', 'target') == nil and isUsable(rend) then
CastSpellByName('Rend')
elseif rage > 90 and isUsable(heroicStrike) then
CastSpellByName('Heroic Strike')
end
end
end
function OBWT_OnLoad()
SlashCmdList["OBWT"] = main
SLASH_OBWT1 = "/obwt"
end