Quantcast

Removed sound due to 7.0 bug

Cilcraft [07-27-16 - 03:40]
Removed sound due to 7.0 bug
Filename
PortraitHealth.lua
PortraitHealth.xml
diff --git a/PortraitHealth.lua b/PortraitHealth.lua
index 01ca7b0..baf3723 100755
--- a/PortraitHealth.lua
+++ b/PortraitHealth.lua
@@ -5,10 +5,9 @@ local PlayerClass = classID;                                  -- this code and v
 local PlayerClassName = classDisplayName;                     -- could be redundant. fix later.
 local PlayerClassNameIndex = class;                           -- **
 local PH_v = '4.0.1'; -- version number
-local limit1 = 0; -- limiter for sounds
-local executeSound = "Sound\\interface\\AuctionWindowClose.ogg";
 local total = 0; -- timer start
 local done = 0; -- toggle for timer repeat
+-- local debug = "yep";

 -- check for sound enabled
 if PH_sound == nil then
@@ -61,7 +60,6 @@ if msg == '' then
   DEFAULT_CHAT_FRAME:AddMessage( "|cffffff00Portrait Health "..PH_v.."|r commands:");
   DEFAULT_CHAT_FRAME:AddMessage( "Usage: |cff00aaff/ph|r <|cff00aaffcommand|r>");
   DEFAULT_CHAT_FRAME:AddMessage(" - |cff00aaffshow|r to toggle health display");
-  DEFAULT_CHAT_FRAME:AddMessage(" - |cff00aaffsound|r to toggle sound at execute phase");
   DEFAULT_CHAT_FRAME:AddMessage(" - |cff00aaffinfo|r to show current settings");
 end

@@ -78,17 +76,6 @@ if msg == 'show' then
   end
 end

--- sound toggle
-if msg == 'sound' then
-  if PH_sound == 1 then
-    PH_sound = 0;
-    DEFAULT_CHAT_FRAME:AddMessage("Portrait Health |cff00aaffsound disabled|r.");
-  elseif PH_sound == 0 then
-    PH_sound = 1;
-    DEFAULT_CHAT_FRAME:AddMessage("Portrait Health |cff00aaffsound enabled|r.");
-  end
-end
-
 -- show current settings
 if msg == 'info' then
   DEFAULT_CHAT_FRAME:AddMessage("Portrait Health version |cFFFFFF00" ..PH_v.. "|r");
@@ -100,11 +87,7 @@ if msg == 'info' then
     DEFAULT_CHAT_FRAME:AddMessage("Health display is |cff00aaffoff|r.");
   end

-  if PH_sound == 1 then
-    DEFAULT_CHAT_FRAME:AddMessage("Sound is |cff00aaffon|r.");
-  else
-    DEFAULT_CHAT_FRAME:AddMessage("Sound is |cff00aaffoff|r.");
-  end
+
 end
 end

@@ -118,39 +101,18 @@ function PH_display()
 end

 -- Set the text color and update health output
-function HealthPercentage(event)
+function HealthPercentage(self, event, unit)

 	-- Health value to display. Whole numbers only.
-	 TargetPercentHealth = (UnitHealth("target") / UnitHealthMax("target") * 100); --causes "division by zero error on beta."
-
-
-  -- Reset notifier when target changes or the target's health increases beyond the execute range
-  if event == "PLAYER_TARGET_CHANGED" then
-    limit1 = 0;
-  end
-
-  if TargetPercentHealth > PH_p[classID] then
-    limit1 = 0;
-  end
-
+	TargetPercentHealth = (UnitHealth("target") / UnitHealthMax("target") * 100); --causes "division by zero error on beta."

-	-- Class detection : Checks for Paladin, as their execute phase is "less than or equal to 20%" unlike other classes.
-  if PlayerClass ~= 2 and TargetPercentHealth < PH_p[PlayerClass] then
+  -- Set to red if 10% or lower
+  if TargetPercentHealth < PH_p[classID] then
     PortraitHealth_Health:SetTextColor(1,0,0);
-    if not UnitIsDead("target") and limit1 == 0 and PH_sound == 1 then
-      PlaySoundFile(executeSound);
-      limit1 = 1;
-    end
-  elseif PlayerClass == 2 and TargetPercentHealth <= PH_p[PlayerClass] then
-    PortraitHealth_Health:SetTextColor(1,0,0);
-    if not UnitIsDead("target") and limit1 == 0 and PH_sound == 1 then
-      PlaySoundFile(executeSound);
-      limit1 = 1;
-    end
-
-	else
-		PortraitHealth_Health:SetTextColor(1,1,0);
-	end
+  else
+  -- Set color to yellow
+    PortraitHealth_Health:SetTextColor(1,1,0);
+  end

 	-- reformat health without decimals
 	local h = string.format("%.0f",TargetPercentHealth);
@@ -163,7 +125,6 @@ function HealthPercentage(event)
 		TargetPercentHealth >= 1 then PortraitHealth_Health:SetText(h .. '%');
 	elseif
 		TargetPercentHealth < 1 then PortraitHealth_Health:SetText(i .. '%');
-
 	end

 end
diff --git a/PortraitHealth.xml b/PortraitHealth.xml
index fba3876..c30d5ad 100755
--- a/PortraitHealth.xml
+++ b/PortraitHealth.xml
@@ -30,12 +30,12 @@
 			</Layers>
 			<Scripts>
 				<OnLoad>
-					self:RegisterEvent("UNIT_HEALTH");
-					self:RegisterEvent("PLAYER_TARGET_CHANGED");
+          self:RegisterEvent("UNIT_COMBAT");
+          self:RegisterEvent("PLAYER_TARGET_CHANGED");
           PH_Loading();
 				</OnLoad>
 				<OnEvent>
-					HealthPercentage(event);
+					HealthPercentage(self, event, unit);
           PH_display();
 				</OnEvent>
 			</Scripts>