216 lines
6.2 KiB
Lua
216 lines
6.2 KiB
Lua
local textures = {}
|
|
textures['Bloodrage'] = 'Ability_Racial_BloodRage'
|
|
textures['Battle Shout'] = 'Ability_Warrior_BattleShout'
|
|
textures['Shield Bash'] = 'Ability_Warrior_ShieldBash'
|
|
textures['Shield Block'] = 'Ability_Defend'
|
|
textures['Revange'] = 'Ability_Warrior_Revenge'
|
|
textures['Sunder Armor'] = 'Ability_Warrior_Sunder'
|
|
textures['Demoralizing Shout'] = 'Ability_Warrior_WarCry'
|
|
textures['Rend'] = 'Ability_Gouge'
|
|
textures['Heroic Strike'] = 'Ability_Rogue_Ambush'
|
|
textures['Shield Slam'] = 'INV_Shield_05'
|
|
textures['Last Stand'] = 'Spell_Holy_AshesToAshes'
|
|
textures['Shield Wall'] = 'Ability_Warrior_ShieldWall'
|
|
textures['Execute'] = 'INV_Sword_48'
|
|
textures['Overpower'] = 'Ability_MeleeDamage'
|
|
textures['Whirlwind'] = 'Ability_Whirlwind'
|
|
textures['Bloodthirst'] = 'Spell_Nature_BloodLust'
|
|
textures['Berserker Rage'] = 'Spell_Nature_AncestralGuardian'
|
|
textures['Berserking'] = 'Racial_Troll_Berserk'
|
|
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
|
|
print(spellName)
|
|
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 panic()
|
|
if isUsable('Last Stand') and not onCooldown('Last Stand') then
|
|
cast('Last Stand')
|
|
|
|
elseif isUsable('Shield Wall') and not onCooldown('Shield Wall') then
|
|
cast('Shield Wall')
|
|
end
|
|
end
|
|
|
|
local function tank(cmd)
|
|
local rage = UnitMana('player')
|
|
local health = UnitHealth('player')
|
|
|
|
if UnitExists('target') and UnitCanAttack('player', 'target') then
|
|
if (not PlayerFrame.inCombat) then
|
|
AttackTarget()
|
|
end
|
|
|
|
if health < 400 then
|
|
panic()
|
|
end
|
|
|
|
if isUsable('Bloodrage') and not onCooldown('Bloodrage') and rage < 30 then
|
|
cast('Bloodrage')
|
|
|
|
elseif isUsable('Battle Shout') and not buffed('Battle Shout') then
|
|
cast('Battle Shout')
|
|
|
|
elseif isUsable('Shield Bash') and not onCooldown('Shield Bash') then
|
|
cast('Shield Bash')
|
|
|
|
elseif isUsable('Shield Slam') and not onCooldown('Shield Slam') then
|
|
cast('Shield Slam')
|
|
|
|
elseif isUsable('Shield Block') and not onCooldown('Shield Block') and not buffed('Shield Block') then
|
|
cast('Shield Block')
|
|
|
|
elseif isUsable('Revange') and not onCooldown('Revange') then
|
|
cast('Revange')
|
|
|
|
elseif isUsable('Sunder Armor') and debuffStacks('Sunder Armor') < 5 then
|
|
cast('Sunder Armor')
|
|
|
|
elseif isUsable('Demoralizing Shout') and not buffed('Demoralizing Shout', 'target') then
|
|
cast('Demoralizing Shout')
|
|
|
|
elseif isUsable('Rend') and not buffed('Rend', 'target') and rage > 80 then
|
|
cast('Rend')
|
|
|
|
elseif isUsable('Heroic Strike') and rage > 80 then
|
|
cast('Heroic Strike')
|
|
end
|
|
end
|
|
end
|
|
|
|
local function dps(cmd)
|
|
local rage = UnitMana('player')
|
|
local health = UnitHealth('player')
|
|
|
|
if UnitExists('target') and UnitCanAttack('player', 'target') then
|
|
if (not PlayerFrame.inCombat) then
|
|
AttackTarget()
|
|
end
|
|
|
|
if health < 400 then
|
|
panic()
|
|
end
|
|
|
|
if isUsable('Bloodrage') and not onCooldown('Bloodrage') and rage < 30 then
|
|
cast('Bloodrage')
|
|
|
|
elseif isUsable('Execute') and not onCooldown('Execute') and rage > 30 then
|
|
cast('Execute')
|
|
|
|
elseif isUsable('Berserker Rage') and not onCooldown('Berserker Rage') then
|
|
cast('Berserker Rage')
|
|
|
|
elseif isUsable('Battle Shout') and not buffed('Battle Shout') then
|
|
cast('Battle Shout')
|
|
|
|
elseif isUsable('Sunder Armor') and debuffStacks('Sunder Armor') < 5 then
|
|
cast('Sunder Armor')
|
|
|
|
elseif isUsable('Bloodthirst') and not onCooldown('Bloodthirst') then
|
|
cast('Bloodthirst')
|
|
|
|
elseif isUsable('Whirlwind') and not onCooldown('Whirlwind') then
|
|
cast('Whirlwind')
|
|
|
|
elseif isUsable('Heroic Strike') and rage > 80 then
|
|
cast('Heroic Strike')
|
|
end
|
|
end
|
|
end
|
|
|
|
local function throw(cmd)
|
|
local rage = UnitMana('player')
|
|
local health = UnitHealth('player')
|
|
|
|
if GetUnitName('target') == nil then
|
|
TargetNearestEnemy()
|
|
end
|
|
if GetUnitName('target') ~= nil and CheckInteractDistance('target', 4) == 1 and CheckInteractDistance('target', 1) ==
|
|
nil then
|
|
cast("Throw")
|
|
else
|
|
ClearTarget();
|
|
end
|
|
end
|
|
|
|
function OBWT_OnLoad()
|
|
SlashCmdList['OBWT'] = tank
|
|
SlashCmdList['OBWF'] = dps
|
|
SlashCmdList['HYPE'] = throw
|
|
SLASH_OBWT1 = '/obwt'
|
|
SLASH_OBWF1 = '/obwf'
|
|
SLASH_HYPE1 = '/obw_throw'
|
|
end
|