Quantcast

Soul Reaper advised only if target is in range

Taracque [10-17-15 - 12:00]
Soul Reaper advised only if target is in range
Filename
DKCrutch.lua
diff --git a/DKCrutch.lua b/DKCrutch.lua
index 133a92c..be3b450 100755
--- a/DKCrutch.lua
+++ b/DKCrutch.lua
@@ -745,7 +745,7 @@ function DKCrutch:AdviseFrostAbilityDW() -- Frost DK DualWield priority
 	if (DKCrutch.person["foeCount"]<=2) then
 		if (DKCrutch.SpellList["Soul Reaper"]) then
 			-- Soul Reaper, if target health < 35%
-			if (DKCrutch.SpellList["Soul Reaper"]) then
+			if (DKCrutch.SpellList["Soul Reaper"]) and (IsSpellInRange(DKCrutch.SpellList["Soul Reaper"], "target") == 1) then
 				cd, _, enabled = DKCrutch:GetSpellCooldownRemaining(DKCrutch.SpellList["Soul Reaper"])
 				if (enabled ~= nil) and (cd) and (cd<=0) and (UnitHealthMax("target")>0) and ((UnitHealth("target")/UnitHealthMax("target")<0.35)) then
 					return "Soul Reaper"
@@ -923,7 +923,7 @@ function DKCrutch:AdviseFrostAbility()
 	end

 	-- Soul Reaper, if target health < 35%
-	if (DKCrutch.SpellList["Soul Reaper"]) then
+	if (DKCrutch.SpellList["Soul Reaper"]) and (IsSpellInRange(DKCrutch.SpellList["Soul Reaper"], "target") == 1) then
 		cd, _, enabled = DKCrutch:GetSpellCooldownRemaining(DKCrutch.SpellList["Soul Reaper"])
 		if (enabled ~= nil) and (cd) and (cd<=0) and (UnitHealthMax("target")>0) and (UnitHealth("target")/UnitHealthMax("target")<0.35) then
 			return "Soul Reaper"
@@ -1118,7 +1118,7 @@ function DKCrutch:AdviseUnholyAbility()
 			(
 				(UnitHealth("target")/UnitHealthMax("target")<0.45) and (DKCrutch.SpellList["Improved Soul Reaper"] ~= nil)
 			)
-		) then
+		) and (IsSpellInRange(DKCrutch.SpellList["Soul Reaper"], "target") == 1) then
 			if (enabled ~= nil) then
 				if (cd) and (cd<=0) then
 					return "Soul Reaper"
@@ -1387,14 +1387,14 @@ function DKCrutch:Update()

 	if (not DKCrutchDB.advisorDisabled) then
 		local spell = DKCrutch:AdviseAbility( not ((UnitHealth("target") == 0) or (guid == nil)) )
-		if (spell == "Soul Reaper") and (DKCrutchDB.srSoundEnable) and (DKCrutch.lastSpell ~= "Soul Reaper") then
-			PlaySoundFile("Interface\\AddOns\\DKCrutch\\media\\soul_reaper.ogg");
-		end
 		DKCrutch:Debug("Advised: " .. spell, DKCrutch.SpellList[spell])
 		if (spell) and (spell ~= "") then
 			local inRange = IsSpellInRange(DKCrutch.SpellList[spell],"target")
 			if (inRange) then
 				DKCrutch.advisorFrame.texture:SetVertexColor( 0.75 + (inRange * 0.25),1 * inRange,1 * inRange,1)
+				if (spell == "Soul Reaper") and (DKCrutchDB.srSoundEnable) and (DKCrutch.lastSpell ~= "Soul Reaper") then
+					PlaySoundFile("Interface\\AddOns\\DKCrutch\\media\\soul_reaper.ogg");
+				end
 			end
 			if (spell ~= DKCrutch.lastSpell) then
 				DKCrutch.advisorFrame.texture:SetTexture( GetSpellTexture(DKCrutch.SpellList[spell]) )