diff --git a/OBWT.lua b/OBWT.lua index 8bd77e1..4755d99 100644 --- a/OBWT.lua +++ b/OBWT.lua @@ -1,3 +1,29 @@ +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' + +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 @@ -8,9 +34,16 @@ local function getSlot(spellTexture) return 0 end -local function isUsable(spellTexture) - local usable, _ = IsUsableAction(getSlot(spellTexture)) - return usable +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) @@ -21,69 +54,120 @@ local function debuffIndex(spellTexture) return 0 end -local function debuffStacks(spellTexture) - local _, stacks = UnitDebuff('target', debuffIndex(spellTexture)) - if stacks == nill then return 0 else return stacks 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 bloodrage = 'Ability_Racial_BloodRage' - local revenge = 'Ability_Warrior_Revenge' - local sunderArmor = 'Ability_Warrior_Sunder' - local rend = 'Ability_Gouge' - local shieldBash = 'Ability_Warrior_ShieldBash' - local battleShout = 'Ability_Warrior_BattleShout' - local heroicStrike = 'Ability_Rogue_Ambush' + local health = UnitHealth('player') + if UnitExists('target') and UnitCanAttack('player','target') then if (not PlayerFrame.inCombat) then AttackTarget() end - if rage < 15 and isUsable(bloodrage) then - CastSpellByName('Bloodrage') - elseif buffed('Battle Shout') == nil and isUsable(battleShout) then - CastSpellByName('Battle Shout') - elseif isUsable(shieldBash) then - CastSpellByName('Shield Bash') - elseif buffed('Shield Block') == nil then - CastSpellByName('Shield Block') - elseif isUsable(revenge) then - CastSpellByName('Revange') - elseif isUsable(sunderArmor) and debuffStacks(sunderArmor) < 5 then - CastSpellByName('Sunder Armor') - elseif rage > 60 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') + + 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 bloodrage = 'Ability_Racial_BloodRage' - local rend = 'Ability_Gouge' - local battleShout = 'Ability_Warrior_BattleShout' - local heroicStrike = 'Ability_Rogue_Ambush' - local overpower = 'Ability_MeleeDamage' - local execute = 'INV_Sword_48' - local slam = 'Ability_Warrior_DecisiveStrike_New' + local health = UnitHealth('player') + if UnitExists('target') and UnitCanAttack('player','target') then if (not PlayerFrame.inCombat) then AttackTarget() end - if rage < 15 and isUsable(bloodrage) then - CastSpellByName('Bloodrage') - elseif buffed('Battle Shout') == nil and isUsable(battleShout) then - CastSpellByName('Battle Shout') - elseif isUsable(execute) then - CastSpellByName('Execute') - elseif isUsable(overpower) then - CastSpellByName('Overpower') - elseif isUsable(slam) then - CastSpellByName('Slam') - elseif buffed('Rend', 'target') == nil and isUsable(rend) then - CastSpellByName('Rend') - elseif isUsable(heroicStrike) then - CastSpellByName('Heroic Strike') + + if health < 400 then panic() end + + if isUsable('Bloodrage') and not onCooldown('Bloodrage') and rage < 30 then + cast('Bloodrage') + + 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('Execute') and not onCooldown('Execute') and rage > 40 then + cast('Execute') + + 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