mirror of
https://github.com/parnic/ice-hud.git
synced 2025-06-16 06:40:13 -05:00
Changed support from MobHealth2 to MobHealth3
This commit is contained in:
@ -3,11 +3,12 @@
|
||||
## Name: IceHUD
|
||||
## Title: IceHUD |cff7fff7f -Ace2-|r
|
||||
## Notes: Another HUD mod
|
||||
## Version: 0.4 ($Revision$)
|
||||
## Version: 0.4.1 ($Revision$)
|
||||
## SavedVariables: IceCoreDB
|
||||
## OptionalDeps: FuBar_ToFu, DruidBar, SoleManax, MobHealth
|
||||
## X-Category: UnitFrame
|
||||
## X-Date: $Date$
|
||||
## X-eMail: iceroth@iceroth.net
|
||||
## X-Website: http://www.wowace.com/forums/index.php/topic,1705.0.html
|
||||
|
||||
# Libraries
|
||||
|
@ -2,8 +2,6 @@ local AceOO = AceLibrary("AceOO-2.0")
|
||||
|
||||
local TargetHealth = AceOO.Class(IceUnitBar, "AceHook-2.0")
|
||||
|
||||
TargetHealth.prototype.mobHealth = nil
|
||||
TargetHealth.prototype.mobMaxHealth = nil
|
||||
TargetHealth.prototype.color = nil
|
||||
|
||||
|
||||
@ -32,18 +30,17 @@ function TargetHealth.prototype:GetOptions()
|
||||
|
||||
opts["mobhealth"] = {
|
||||
type = "toggle",
|
||||
name = "MobHealth2 support",
|
||||
desc = "Will NOT work with the original MobHealth addon",
|
||||
name = "MobHealth3 support",
|
||||
desc = "Enable/disable MobHealth3 target HP data. If this option is gray, you do not have MobHealth3.",
|
||||
get = function()
|
||||
return self.moduleSettings.mobhealth
|
||||
end,
|
||||
set = function(value)
|
||||
self.moduleSettings.mobhealth = value
|
||||
if (self.moduleSettings.mobhealth) then
|
||||
self:EnableMobHealth()
|
||||
else
|
||||
self:DisableMobHealth()
|
||||
end
|
||||
self:Update(self.unit)
|
||||
end,
|
||||
disabled = function()
|
||||
return (MobHealth3 == nil)
|
||||
end,
|
||||
order = 40
|
||||
}
|
||||
@ -59,11 +56,7 @@ function TargetHealth.prototype:Enable()
|
||||
self:RegisterEvent("UNIT_MAXHEALTH", "Update")
|
||||
self:RegisterEvent("PLAYER_TARGET_CHANGED", "TargetChanged")
|
||||
|
||||
if (self.moduleSettings.mobhealth) then
|
||||
self:EnableMobHealth()
|
||||
end
|
||||
|
||||
self:Update("target")
|
||||
self:Update(self.unit)
|
||||
end
|
||||
|
||||
|
||||
@ -74,22 +67,8 @@ function TargetHealth.prototype:Disable()
|
||||
end
|
||||
|
||||
|
||||
function TargetHealth.prototype:EnableMobHealth()
|
||||
if (IsAddOnLoaded("MobHealth")) then
|
||||
self:Hook("MobHealth_OnEvent", "MobHealth")
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
function TargetHealth.prototype:DisableMobHealth()
|
||||
if (self:IsHooked("MobHealth_OnEvent")) then
|
||||
self:Unhook("MobHealth_OnEvent")
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
function TargetHealth.prototype:TargetChanged()
|
||||
self:Update("target")
|
||||
self:Update(self.unit)
|
||||
end
|
||||
|
||||
|
||||
@ -122,40 +101,9 @@ function TargetHealth.prototype:Update(unit)
|
||||
self:UpdateBar(self.health/self.maxHealth, self.color)
|
||||
self:SetBottomText1(self.healthPercentage)
|
||||
|
||||
self:UpdateHealthText(false)
|
||||
end
|
||||
|
||||
|
||||
function TargetHealth.prototype:MobHealth(event)
|
||||
self.hooks.MobHealth_OnEvent.orig(event)
|
||||
|
||||
-- we are getting valid values from the server, no need for MobHealth2
|
||||
if (self.maxHealth ~= 100) then
|
||||
self.mobHealth = nil
|
||||
self.mobMaxHealth = nil
|
||||
self:UpdateHealthText(false)
|
||||
return
|
||||
end
|
||||
|
||||
self.mobHealth = MobHealth_GetTargetCurHP()
|
||||
self.mobMaxHealth = MobHealth_GetTargetMaxHP()
|
||||
|
||||
self:UpdateHealthText(true)
|
||||
end
|
||||
|
||||
|
||||
function TargetHealth.prototype:UpdateHealthText(mobHealth)
|
||||
local validData = (self.mobHealth and self.mobMaxHealth and self.health > 0 and self.mobMaxHealth > 0)
|
||||
|
||||
if (mobHealth) then
|
||||
if (validData) then
|
||||
self:SetBottomText2(self:GetFormattedText(self.mobHealth, self.mobMaxHealth), self.color)
|
||||
else
|
||||
self:SetBottomText2()
|
||||
end
|
||||
else
|
||||
if (validData and self.moduleSettings.mobhealth) then
|
||||
return
|
||||
if (self.moduleSettings.mobhealth and MobHealth3) then
|
||||
self.health, self.maxHealth, _ = MobHealth3:GetUnitHealth(self.unit, self.health, self.maxHealth)
|
||||
end
|
||||
|
||||
-- assumption that if a unit's max health is 100, it's not actual amount
|
||||
@ -166,7 +114,6 @@ function TargetHealth.prototype:UpdateHealthText(mobHealth)
|
||||
else
|
||||
self:SetBottomText2()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user