Version 2
Scott King [01-13-14 - 04:37]
Version 2
- added class detection
diff --git a/PortraitHealth.lua b/PortraitHealth.lua
index b2d5f55..56984ee 100644
--- a/PortraitHealth.lua
+++ b/PortraitHealth.lua
@@ -1,19 +1,70 @@
+
+classDisplayName, class, classID = UnitClass("player");
+PlayerClass = classID;
+
+-- Class ID Listing
+
+-- Warrior 1
+-- Paladin 2
+-- Hunter 3
+-- Rogue 4
+-- Priest 5
+-- Death Knight 6
+-- Shaman 7
+-- Mage 8
+-- Warlock 9
+-- Monk 10
+-- Druid 11
+
+
function HealthPercentage()
+
-- health value to display. whole numbers only.
- local TargetPercentHealth = math.ceil((UnitHealth("target") / UnitHealthMax("target") * 100));
+ TargetPercentHealth = math.ceil((UnitHealth("target") / UnitHealthMax("target") * 100));
+ -- Class detection
- -- recolor text at 35% (future idea: class detection)
- if TargetPercentHealth < 35 then
+ if PlayerClass == 1 and TargetPercentHealth < 20 then -- Warrior
PortraitHealth_Health:SetTextColor(1,0,0);
- else
+
+ elseif PlayerClass == 2 and TargetPercentHealth <= 20 then -- Paladin
+ PortraitHealth_Health:SetTextColor(1,0,0);
+
+ elseif PlayerClass == 3 and TargetPercentHealth <= 20 then -- Hunter
+ PortraitHealth_Health:SetTextColor(1,0,0);
+
+ elseif PlayerClass == 4 and TargetPercentHealth < 35 then -- Rogue
+ PortraitHealth_Health:SetTextColor(1,0,0);
+
+ elseif PlayerClass == 5 and TargetPercentHealth <= 25 then -- Priest
+ PortraitHealth_Health:SetTextColor(1,0,0);
+
+ elseif PlayerClass == 6 and TargetPercentHealth < 35 then -- Death Knight
+ PortraitHealth_Health:SetTextColor(1,0,0);
+
+ elseif PlayerClass == 9 and TargetPercentHealth <= 25 then -- Warlock
+ PortraitHealth_Health:SetTextColor(1,0,0);
+
+ elseif PlayerClass == 10 and TargetPercentHealth <= 10 then -- Monk
+ PortraitHealth_Health:SetTextColor(1,0,0);
+
+ elseif PlayerClass == 11 and TargetPercentHealth <= 25 then -- Priest
+ PortraitHealth_Health:SetTextColor(1,0,0);
+
+ elseif TargetPercentHealth <= 10 then -- Other classes
+ PortraitHealth_Health:SetTextColor(1,0,0);
+
+ else
PortraitHealth_Health:SetTextColor(1,1,0);
end
+
-- change the portrait to show current health
if UnitIsDead("target") then
PortraitHealth_Health:SetText('Dead');
else
PortraitHealth_Health:SetText(TargetPercentHealth .. '%');
end
-end
\ No newline at end of file
+
+end
+
diff --git a/PortraitHealth.toc b/PortraitHealth.toc
index 62e6d18..ac56163 100644
--- a/PortraitHealth.toc
+++ b/PortraitHealth.toc
@@ -2,6 +2,6 @@
## Title: Portrait Health
## Notes: See the health of your target as a percentage in the target frame portrait.
## Author: Cilcraft
-## Version: 1.1
+## Version: 2.0
PortraitHealth.lua
PortraitHealth.xml
diff --git a/PortraitHealth.xml b/PortraitHealth.xml
index e7e75cc..9d9a242 100644
--- a/PortraitHealth.xml
+++ b/PortraitHealth.xml
@@ -32,6 +32,7 @@
<OnLoad>
self:RegisterEvent("UNIT_HEALTH");
self:RegisterEvent("PLAYER_TARGET_CHANGED");
+ self:RegisterEvent("PLAYER_ENTERING_WORLD");
</OnLoad>
<OnEvent>
HealthPercentage();