Quantcast

Fix target used in "targetlifenocd" computation for spell cooldowns.

Johnny C. Lam [11-15-13 - 19:55]
Fix target used in "targetlifenocd" computation for spell cooldowns.

git-svn-id: svn://svn.curseforge.net/wow/ovale/mainline/trunk@1163 d5049fe3-3747-40f7-a4b5-f36d6801af5f
Filename
OvaleCooldown.lua
diff --git a/OvaleCooldown.lua b/OvaleCooldown.lua
index f5b8093..15a52e9 100644
--- a/OvaleCooldown.lua
+++ b/OvaleCooldown.lua
@@ -14,6 +14,7 @@ Ovale.OvaleCooldown = OvaleCooldown

 --<private-static-properties>
 local OvaleData = Ovale.OvaleData
+local OvaleGUID = Ovale.OvaleGUID
 local OvalePaperDoll = Ovale.OvalePaperDoll
 local OvaleStance = Ovale.OvaleStance
 local OvaleState = Ovale.OvaleState
@@ -135,8 +136,9 @@ function OvaleCooldown:ApplySpellOnPlayer(state, spellId, startCast, endCast, ne

 				-- There is no cooldown if the target's health percent is below what's specified
 				-- with the "targetlifenocd" parameter.
-				if si.targetlifenocd then
-					local healthPercent = API_UnitHealth("target") / API_UnitHealthMax("target") * 100
+				local target = OvaleGUID:GetUnitId(targetGUID)
+				if target and si.targetlifenocd then
+					local healthPercent = API_UnitHealth(target) / API_UnitHealthMax(target) * 100
 					if healthPercent < si.targetlifenocd then
 						cd.duration = 0
 					end