From 7b18ce6826ddf06c41b81b1b7eaafe972edb9967 Mon Sep 17 00:00:00 2001 From: Taracque Date: Tue, 13 Jan 2015 10:40:24 +0100 Subject: [PATCH] Rotation are updated once again, some code cleanup, and bug fixes --- DKCrutch.lua | 174 +++++++++++++++++++++++++--------------------------------- DKCrutch.toc | 2 +- 2 files changed, 76 insertions(+), 100 deletions(-) diff --git a/DKCrutch.lua b/DKCrutch.lua index 432e1a9..9edc91b 100755 --- a/DKCrutch.lua +++ b/DKCrutch.lua @@ -1,5 +1,5 @@ ------------------------------------------------------------------------------- --- DKCrutch 1.0.5 +-- DKCrutch 1.0.6 -- -- Death Knight rune tracker and ability advisor ------------------------------------------------------------------------------- @@ -8,7 +8,7 @@ DKCrutch = {Locals = {}} local L = DKCrutch.Locals -DKCrutch.versionNumber = '1.0.5' +DKCrutch.versionNumber = '1.0.6' DKCrutch.talent = "" DKCrutch.talentUnsure = true DKCrutch.DebugMode = false @@ -128,7 +128,7 @@ end function DKCrutch.events.PLAYER_EQUIPMENT_CHANGED() local _, itemType, itemSlot; - _, itemSlot = GetInventorySlotInfo("MainHandSlot"); + itemSlot = GetInventorySlotInfo("MainHandSlot"); if (itemSlot) and (GetInventoryItemID("player", itemSlot)) then _, _, _, _, _, _, _, _, itemType = GetItemInfo( GetInventoryItemID("player", itemSlot)); DKCrutch.dualWield = (itemType == "INVTYPE_WEAPON"); @@ -595,6 +595,42 @@ function DKCrutch:ProcIcon(name,icon,d,e,value) end end +-- returns true, if diseases expires on target +-- diseaseType : 0 for any, 1 for Frost Fever of Necrotic Plague, 2 for Blood Plague or Necrotic Plague +-- expirationTime : 0 for expired, otherwise check expiration time between 1 and expirationTime +function DKCrutch:DiseaseExpires(diseaseType,expirationTime) + diseaseType = diseaseType or 0; + expirationTime = expirationTime or 0; + + local ffExpiration, bpExpiration, npExpiration = DKCrutch:getDiseaseExpiration(); + + if (DKCrutch.tier7talent == 21207) then -- Necrotic plague talent active, check only Necrotic plague + if (expirationTime>0) then + return ((npExpiration > 1) and (npExpiration < expirationTime)); + else + return (npExpiration <= 0); + end + else -- check both diseases or, only requested + local expired = false; + if (diseaseType == 1) or (diseaseType == 0) then -- Check frost fever + if (expirationTime>0) then + expired = expired or ((ffExpiration > 1) and (ffExpiration < expirationTime)); + else + expired = expired or (ffExpiration < 2); + end + end + if (diseaseType == 2) or (diseaseType == 0) then -- Check blood plague + if (expirationTime>0) then + expired = expired or ((bpExpiration > 1) and (bpExpiration < expirationTime)); + else + expired = expired or (bpExpiration < 2); + end + end + + return expired; + end +end + function DKCrutch:AdviseAbility( hasTarget ) local _,name,icon,count,d,e @@ -698,7 +734,7 @@ function DKCrutch:getDiseaseExpiration() npExpiration = npExpiration - GetTime(); end - return ffExpiration, bpExpiration, npExpiration + return ffExpiration, bpExpiration, npExpiration; end function DKCrutch:AdviseBloodAbility() @@ -706,16 +742,10 @@ function DKCrutch:AdviseBloodAbility() local spell = "" local obcd, cd - -- check disease cooldowns - local ffExpiration, bpExpiration, npExpiration = DKCrutch:getDiseaseExpiration(); - -- Refresh diseases with Blood Boil if available cd = DKCrutch:GetSpellCooldownRemaining(DKCrutch.SpellList["Blood Boil"]) if (cd) and (cd<=0) and (IsUsableSpell(DKCrutch.SpellList["Outbreak"], "target") == 1) then - if ( - ( (DKCrutch.tier7talent == 21207) and ( npExpiration < 5 ) and ( npExpiration > 1 ) ) or - ( (DKCrutch.tier7talent ~= 21207) and ( ( ffExpiration < 5 ) or ( bpExpiration < 5) ) and ( ( ffExpiration > 1) and ( bpExpiration > 1) ) ) - ) then + if (DKCrutch:DiseaseExpires()) then return "Blood Boil" end end @@ -723,10 +753,7 @@ function DKCrutch:AdviseBloodAbility() -- outbreak if frost fever or blood plague less than 2 sec remaining obcd = DKCrutch:GetSpellCooldownRemaining(DKCrutch.SpellList["Outbreak"]) if (obcd) and (obcd<=0) and (IsSpellInRange(DKCrutch.SpellList["Outbreak"], "target") == 1) then - if ( - ( (DKCrutch.tier7talent == 21207) and ( npExpiration <= 0 ) ) or - ( (DKCrutch.tier7talent ~= 21207) and ( ffExpiration < 2 ) or ( bpExpiration < 2) ) - ) then + if (DKCrutch:DiseaseExpires()) then return "Outbreak" end end @@ -734,10 +761,7 @@ function DKCrutch:AdviseBloodAbility() -- icy touch cd = DKCrutch:GetSpellCooldownRemaining(DKCrutch.SpellList["Icy Touch"]) if (cd<=0) and ( IsSpellInRange(DKCrutch.SpellList["Icy Touch"],"target") == 1) then - if ( - ( (DKCrutch.tier7talent == 21207) and (npExpiration <= 0) ) or - ( (DKCrutch.tier7talent ~= 21207) and (ffExpiration < 3) ) - ) then + if (DKCrutch:DiseaseExpires(1)) then return "Icy Touch" end end @@ -745,10 +769,7 @@ function DKCrutch:AdviseBloodAbility() -- plague strike cd = DKCrutch:GetSpellCooldownRemaining(DKCrutch.SpellList["Plague Strike"]) if (cd) and (cd<=0) and ( IsSpellInRange(DKCrutch.SpellList["Plague Strike"],"target") == 1) then - if ( - ( (DKCrutch.tier7talent == 21207) and (npExpiration <= 0) ) or - ( (DKCrutch.tier7talent ~= 21207) and (bpExpiration < 3) ) - ) then + if (DKCrutch:DiseaseExpires(2)) then return "Plague Strike" end end @@ -795,8 +816,6 @@ function DKCrutch:AdviseFrostAbilityDW() -- Frost DK DualWield priority -- spell advisor local spell = "" local obcd,cd,enabled,_ - -- Diseases - local ffExpiration, bpExpiration, npExpiration = DKCrutch:getDiseaseExpiration(); -- Pillar of Frost if not on CD cd, _, enabled = DKCrutch:GetSpellCooldownRemaining(DKCrutch.SpellList["Pillar of Frost"]) @@ -895,7 +914,6 @@ function DKCrutch:AdviseFrostAbilityDW() -- Frost DK DualWield priority end end - -- Frost Strike if Killing Machine Procs OR Runic Power >= 88 local fscd = DKCrutch:GetSpellCooldownRemaining(DKCrutch.SpellList["Frost Strike"]) if (fscd) and (fscd <= 1) and (DKCrutch:hasBuff("player", DKCrutch.SpellList["Killing Machine"]) or (UnitPower("player", 6) >= 88)) then @@ -904,38 +922,23 @@ function DKCrutch:AdviseFrostAbilityDW() -- Frost DK DualWield priority end end - -- howling blast, if death rune count > 1 or unholy rune count > 1 - local hbcd = DKCrutch:GetSpellCooldownRemaining(DKCrutch.SpellList["Howling Blast"]) - if (hbcd) and (hbcd<=0) and ((DKCrutch.runesUp[4]>1) or (DKCrutch.runesUp[2]>1)) and ( IsSpellInRange(DKCrutch.SpellList["Howling Blast"],"target") == 1) then - return "Howling Blast" - end - -- Unholy blight and debuffs are expiring if (DKCrutch.tier1talent == 19217) and (DKCrutch.SpellList["Unholy Blight"]) then cd = DKCrutch:GetSpellCooldownRemaining(DKCrutch.SpellList["Unholy Blight"]) - if (cd) and (cd<=0) and ( - ((DKCrutch.tier7talent ~= 21207) and ((ffExpiration<3) or (bpExpiration<3))) or - ((DKCrutch.tier7talent == 21207) and (npExpiration <= 0)) - ) then + if (cd) and (cd<=0) and (DKCrutch:DiseaseExpires()) then return "Unholy Blight" end end - -- Howling blast, if rime, or dieseases are expired - if (hbcd) and (hbcd<=0) and ( IsSpellInRange(DKCrutch.SpellList["Howling Blast"],"target") == 1) and ( - ((DKCrutch.tier7talent ~= 21207) and ((ffExpiration<3) or (bpExpiration<3))) or - ((DKCrutch.tier7talent == 21207) and (npExpiration <= 0)) - ) then + -- Howling blast dieseases are expired + if (hbcd) and (hbcd<=0) and ( IsSpellInRange(DKCrutch.SpellList["Howling Blast"],"target") == 1) and (DKCrutch:DiseaseExpires(1)) then return "Howling Blast" end -- Plague Strike if diseases are expired cd = DKCrutch:GetSpellCooldownRemaining(DKCrutch.SpellList["Plague Strike"]) if (cd) and (cd<=0) and ( IsSpellInRange(DKCrutch.SpellList["Plague Strike"],"target") == 1) then - if ( - ((DKCrutch.tier7talent ~= 21207) and (bpExpiration < 3)) or - ((DKCrutch.tier7talent == 21207) and (npExpiration <= 0)) - ) then + if (DKCrutch:DiseaseExpires(2)) then return "Plague Strike" end end @@ -949,8 +952,9 @@ function DKCrutch:AdviseFrostAbilityDW() -- Frost DK DualWield priority return "Howling Blast" end - -- Frost Strike if runic power > 76 - if (fscd) and (fscd <= 1) and (IsUsableSpell(DKCrutch.SpellList["Frost Strike"])) and (UnitPower("player", 6) >= 76) then + -- Frost Strike if runic power > 76 or Killing Machine + local fscd = DKCrutch:GetSpellCooldownRemaining(DKCrutch.SpellList["Frost Strike"]) + if (fscd) and (fscd <= 1) and (IsUsableSpell(DKCrutch.SpellList["Frost Strike"])) and ((UnitPower("player", 6) >= 76) or DKCrutch:hasBuff("player", DKCrutch.SpellList["Killing Machine"]))then return "Frost Strike" end @@ -960,8 +964,14 @@ function DKCrutch:AdviseFrostAbilityDW() -- Frost DK DualWield priority return "Obliterate" end - -- Howling blast - if (hbcd) and (hbcd <= 1) then + -- Frost strike if runic power > 35 + if (fscd) and (fscd <= 1) and (IsUsableSpell(DKCrutch.SpellList["Frost Strike"])) and (UnitPower("player", 6) >= 25) then + return "Frost Strike" + end + + -- howling blast, if death rune count > 1 or unholy rune count > 1 + local hbcd = DKCrutch:GetSpellCooldownRemaining(DKCrutch.SpellList["Howling Blast"]) + if (hbcd) and (hbcd<=0) and ((DKCrutch.runesUp[4]>1) or (DKCrutch.runesUp[2]>1)) and ( IsSpellInRange(DKCrutch.SpellList["Howling Blast"],"target") == 1) then return "Howling Blast" end @@ -1070,15 +1080,9 @@ function DKCrutch:AdviseFrostAbility() end end - -- outbreak if frost fever or blood plague less than 2 sec remaining - local ffExpiration, bpExpiration, npExpiration = DKCrutch:getDiseaseExpiration(); - obcd = DKCrutch:GetSpellCooldownRemaining(DKCrutch.SpellList["Outbreak"]) if (obcd) and (obcd<=0) and (IsSpellInRange(DKCrutch.SpellList["Outbreak"], "target") == 1) then - if ( - ((DKCrutch.tier7talent ~= 21207) and ((ffExpiration < 2) or (bpExpiration < 2))) or - ((DKCrutch.tier7talent == 21207) and (npExpiration <= 0)) - ) then + if (DKCrutch:DiseaseExpires()) then return "Outbreak" end end @@ -1094,48 +1098,39 @@ function DKCrutch:AdviseFrostAbility() -- Unholy blight and debuffs are expiring if (DKCrutch.tier1talent == 19217) and (DKCrutch.SpellList["Unholy Blight"]) then cd = DKCrutch:GetSpellCooldownRemaining(DKCrutch.SpellList["Unholy Blight"]) - if (cd) and (cd<=0) and ( - ((DKCrutch.tier7talent ~= 21207) and ((ffExpiration<3) or (bpExpiration<3))) or - ((DKCrutch.tier7talent == 21207) and (npExpiration <= 0)) - ) then + if (cd) and (cd<=0) and (DKCrutch:DiseaseExpires()) then return "Unholy Blight" end end -- howling blast local hbcd = DKCrutch:GetSpellCooldownRemaining(DKCrutch.SpellList["Howling Blast"]) - if (hbcd) and (hbcd<=0) and ( IsSpellInRange(DKCrutch.SpellList["Howling Blast"],"target") == 1) then - if ( ffExpiration < 3) then - return "Howling Blast" - end + if (hbcd) and (hbcd<=0) and ( IsSpellInRange(DKCrutch.SpellList["Howling Blast"],"target") == 1) and (DKCrutch:DiseaseExpires(1)) then + return "Howling Blast" end -- plague strike cd = DKCrutch:GetSpellCooldownRemaining(DKCrutch.SpellList["Plague Strike"]) - if (cd) and (cd<=0) and ( IsSpellInRange(DKCrutch.SpellList["Plague Strike"],"target") == 1) then - if ( - ((DKCrutch.tier7talent ~= 21207) and (bpExpiration < 2)) or - ((DKCrutch.tier7talent == 21207) and (npExpiration <= 0)) - ) then - return "Plague Strike" - end + if (cd) and (cd<=0) and ( IsSpellInRange(DKCrutch.SpellList["Plague Strike"],"target") == 1) and (DKCrutch:DiseaseExpires(2)) then + return "Plague Strike" end - -- Obliterate if all runes are up or killing machine not proc + -- Obliterate if all runes are up or killing machine proc local obcd = DKCrutch:GetSpellCooldownRemaining(DKCrutch.SpellList["Obliterate"]) - if (DKCrutch.runesUp[2] > 0) and (obcd) and (obcd <= 1) and ( + if (DKCrutch.runesUp[2] > 0) and (obcd) and (obcd <= 1) and (( (DKCrutch.runesUp[1] + DKCrutch.runesUp[2] + DKCrutch.runesUp[3] + DKCrutch.runesUp[4]) == 6) or - not(DKCrutch:hasBuff("player", DKCrutch.SpellList["Killing Machine"]) + (DKCrutch:hasBuff("player", DKCrutch.SpellList["Killing Machine"])) ) then return "Obliterate" end -- Frost Strike if runic power > 40 + local fscd = DKCrutch:GetSpellCooldownRemaining(DKCrutch.SpellList["Frost Strike"]) if (fscd) and (fscd <= 1) and (IsUsableSpell(DKCrutch.SpellList["Frost Strike"])) and (UnitPower("player", 6) >= 40) then return "Frost Strike" end - -- Howling blast, if rime, or dieseases are expired + -- Howling blast, if rime if (hbcd) and (hbcd<=0) and ( IsSpellInRange(DKCrutch.SpellList["Howling Blast"],"target") == 1) and ( (DKCrutch:hasBuff("player", DKCrutch.SpellList["Freezing Fog"])) ) then @@ -1181,8 +1176,6 @@ function DKCrutch:AdviseUnholyAbility() return "Raise Dead" end - local ffExpiration, bpExpiration, npExpiration = DKCrutch:getDiseaseExpiration(); - -- Plague Leech if (DKCrutch.tier1talent == 19166) and (DKCrutch.SpellList["Plague Leech"]) then -- if outbreak available @@ -1192,9 +1185,7 @@ function DKCrutch:AdviseUnholyAbility() end end -- or if diseases will expire in 2 sec on target - if ((DKCrutch.tier7talent == 21207) and (npExpiration <= 0) ) or -- necrotic plague - ((DKCrutch.tier7talent ~= 21207) and (ffExpiration < 2) and (bpExpiration < 2) ) - then + if (DKCrutch:DiseaseExpires()) then if (DKCrutch:GetSpellCooldownRemaining(DKCrutch.SpellList["Plague Leech"]) <= 1) then return "Plague Leech"; end @@ -1248,22 +1239,14 @@ function DKCrutch:AdviseUnholyAbility() -- Unholy Blight if (DKCrutch.tier1talent == 19217) and (DKCrutch.SpellList["Unholy Blight"]) then cd = DKCrutch:GetSpellCooldownRemaining(DKCrutch.SpellList["Unholy Blight"]) - if (cd) and (cd<=0) and ( - ( (DKCrutch.tier7talent == 21207) and (npExpiration <= 0) ) - or - ( (DKCrutch.tier7talent ~= 21207) and (ffExpiration < 3) or (bpExpiration < 3) ) - ) then + if (cd) and (cd<=0) and (DKCrutch:DiseaseExpires()) then return "Unholy Blight" end end -- Outbreak if frost fever or blood plague less than 2 sec remaining if (obcd) and (obcd<=0) and (IsSpellInRange(DKCrutch.SpellList["Outbreak"], "target") == 1) then - if ( - ((DKCrutch.tier7talent == 21207) and (npExpiration <= 0) ) - or - ((DKCrutch.tier7talent ~= 21207) and ((ffExpiration < 2) or ( bpExpiration < 2)) ) - ) then + if (DKCrutch:DiseaseExpires()) then return "Outbreak" end end @@ -1271,11 +1254,7 @@ function DKCrutch:AdviseUnholyAbility() -- Plague strike cd = DKCrutch:GetSpellCooldownRemaining(DKCrutch.SpellList["Plague Strike"]) if (cd) and (cd<=0) and ( IsSpellInRange(DKCrutch.SpellList["Plague Strike"],"target") == 1) then - if ( - ((DKCrutch.tier7talent == 21207) and (npExpiration <= 0) ) - or - ((DKCrutch.tier7talent ~= 21207) and ((ffExpiration <2) or ( bpExpiration < 2))) - ) then + if (DKCrutch:DiseaseExpires()) then return "Plague Strike" end end @@ -1374,10 +1353,7 @@ function DKCrutch:AdviseUnholyAbility() -- Unholy blight and debuffs are expiring if (DKCrutch.tier1talent == 19217) and (DKCrutch.SpellList["Unholy Blight"]) then cd = DKCrutch:GetSpellCooldownRemaining(DKCrutch.SpellList["Unholy Blight"]) - if (cd) and (cd<=0) and ( - ((DKCrutch.tier7talent ~= 21207) and ((ffExpiration<3) or (bpExpiration<3))) or - ((DKCrutch.tier7talent == 21207) and (npExpiration <= 0)) - ) then + if (cd) and (cd<=0) and (DKCrutch:DiseaseExpires()) then return "Unholy Blight" end end diff --git a/DKCrutch.toc b/DKCrutch.toc index fa2dc82..de8418a 100755 --- a/DKCrutch.toc +++ b/DKCrutch.toc @@ -2,7 +2,7 @@ ## Title: DKCrutch ## Notes: Death Knight rune tracker and rotation helper ## Author: Taracque, Dšgrov‡s of Arathor -## Version: 1.0.5 +## Version: 1.0.6 ## SavedVariables: DKCrutchDB ## OptionalDeps: ## Dependencies: -- 1.7.9.5