Quantcast

Presence is suggested out of combat or if no target present.

Taracque [09-06-12 - 09:43]
Presence is suggested out of combat or if no target present.

If no presence, or not matching presence has been set, the correct one
displayed while out of combat, or in combat, but no (or dead) target
selected.
Filename
DKCrutch.lua
diff --git a/DKCrutch.lua b/DKCrutch.lua
index ace9202..72cc02b 100644
--- a/DKCrutch.lua
+++ b/DKCrutch.lua
@@ -47,6 +47,11 @@ DKCrutch.SpellList = {
 	["Blood Charge"] = GetSpellInfo(114851),
 	["Unholy Blight"] = GetSpellInfo(115989),

+-- presences
+	["Unholy Presence"] = GetSpellInfo(48265),
+	["Frost Presence"] = GetSpellInfo(48266),
+	["Blood Presence"] = GetSpellInfo(48263),
+
 -- buff, procs
 	["Sudden Doom"] = GetSpellInfo(81340),
 	["Unholy Strength"] = GetSpellInfo(53365),
@@ -423,27 +428,39 @@ function DKCrutch:ProcIcon(name,icon,d,e,value)
 	end
 end

-function DKCrutch:AdviseAbility()
+function DKCrutch:AdviseAbility( hasTarget )
 	local _,name,icon,count,d,e

 	if (DKCrutch.talentUnsure) then
 		DKCrutch:detectTalent()
 	end
 	if (DKCrutch.talent == "unholy") then
-		-- show shadow infusion count or Dark Transformation CD
-		if (not DKCrutchDB.procDisabled) then
-			name,_,icon,count,_,d,e = DKCrutch:hasBuff("pet", DKCrutch.SpellList["Dark Transformation"])
-			if (name) then
-				DKCrutch:ProcIcon(name,icon,d,e,"")
-			else
-				name,_,icon,count,_,d,e = DKCrutch:hasBuff("pet", DKCrutch.SpellList["Shadow Infusion"])
-				DKCrutch:ProcIcon(name,icon,d,e,count)
+		if (InCombatLockdown() and hasTarget) then
+			-- show shadow infusion count or Dark Transformation CD
+			if (not DKCrutchDB.procDisabled) then
+				name,_,icon,count,_,d,e = DKCrutch:hasBuff("pet", DKCrutch.SpellList["Dark Transformation"])
+				if (name) then
+					DKCrutch:ProcIcon(name,icon,d,e,"")
+				else
+					name,_,icon,count,_,d,e = DKCrutch:hasBuff("pet", DKCrutch.SpellList["Shadow Infusion"])
+					DKCrutch:ProcIcon(name,icon,d,e,count)
+				end
+				if (not name) and (DKCrutch.lastProc ~= "") then
+					DKCrutch:ProcIcon(false)
+				end
 			end
-			if (not name) and (DKCrutch.lastProc ~= "") then
-				DKCrutch:ProcIcon(false)
+			return DKCrutch:AdviseUnholyAbility()
+		else
+			-- check presence
+			if (not DKCrutch:hasBuff("player", DKCrutch.SpellList["Unholy Presence"])) then
+				return "Unholy Presence"
+			end
+			-- check pet status
+			local cd = DKCrutch:GetSpellCooldownRemaining(DKCrutch.SpellList["Raise Dead"])
+			if (cd<=0) and (PetHasActionBar() ~= 1) then
+				return "Raise Dead"
 			end
 		end
-		return DKCrutch:AdviseUnholyAbility()
 	end
 	if (DKCrutch.talent == "frost") then
 		-- killing machine proc
@@ -456,7 +473,14 @@ function DKCrutch:AdviseAbility()
 				DKCrutch:ProcIcon(false)
 			end
 		end
-		return DKCrutch:AdviseFrostAbility()
+		if (InCombatLockdown() and hasTarget) then
+			return DKCrutch:AdviseFrostAbility()
+		else
+			-- check presence
+			if (not DKCrutch:hasBuff("player", DKCrutch.SpellList["Frost Presence"])) then
+				return "Frost Presence"
+			end
+		end
 	end
 	if (DKCrutch.talent == "blood") then
 		-- killing machine proc
@@ -469,7 +493,14 @@ function DKCrutch:AdviseAbility()
 				DKCrutch:ProcIcon(false)
 			end
 		end
-		return DKCrutch:AdviseBloodAbility()
+		if (InCombatLockdown() and hasTarget) then
+			return DKCrutch:AdviseBloodAbility()
+		else
+			-- check presence
+			if (not DKCrutch:hasBuff("player", DKCrutch.SpellList["Blood Presence"])) then
+				return "Blood Presence"
+			end
+		end
 	end

 	return ""
@@ -835,6 +866,7 @@ function DKCrutch:Update()
 	end
 	DKCrutch.depletedCount = 0

+	DKCrutch:Debug("UPDATE", "")
 	for i=1,6,1 do
 		start, duration, runeReady = GetRuneCooldown(i)
 		runeType = GetRuneType(i)
@@ -859,7 +891,7 @@ function DKCrutch:Update()
 		guid = nil
 	end

-	if ( UnitInVehicle("player") or (UnitHealth("target") == 0) or (guid == nil) ) then
+	if ( UnitInVehicle("player") ) then
 		-- player is in a "vehicle", or has no target don't suggest abilities
 		DKCrutch.advisorFrame.texture:SetTexture("")
 		if (DKCrutch.lastD2 ~= "") then
@@ -875,8 +907,8 @@ function DKCrutch:Update()
 		return
 	end

-	if (not DKCrutchDB.advisorDisabled) and (InCombatLockdown()) then
-		local spell = DKCrutch:AdviseAbility()
+	if (not DKCrutchDB.advisorDisabled) then
+		local spell = DKCrutch:AdviseAbility( not ((UnitHealth("target") == 0) or (guid == nil)) )
 		DKCrutch:Debug("Advised: " .. spell, DKCrutch.SpellList[spell])
 		if (spell) and (spell ~= "") then
 			local inRange = IsSpellInRange(DKCrutch.SpellList[spell],"target")