mirror of
https://github.com/parnic/LibDogTag-Unit-3.0.git
synced 2025-06-16 21:41:53 -05:00
remove references to WotLK.
remove MobHealth references and fix up the Health module a bit.
This commit is contained in:
@ -1,6 +1,5 @@
|
||||
local MAJOR_VERSION = "LibDogTag-Unit-3.0"
|
||||
local MINOR_VERSION = 90000 + tonumber(("$Revision$"):match("%d+")) or 0
|
||||
local WoTLK = select(4,GetBuildInfo()) >= 30000
|
||||
|
||||
if MINOR_VERSION > _G.DogTag_Unit_MINOR_VERSION then
|
||||
_G.DogTag_Unit_MINOR_VERSION = MINOR_VERSION
|
||||
@ -322,13 +321,7 @@ DogTag:AddTag("Unit", "IsShadowform", {
|
||||
})
|
||||
|
||||
local STEALTH = GetSpellInfo(1784)
|
||||
local SHADOWFORM
|
||||
if WoTLK then
|
||||
SHADOWFORM = GetSpellInfo(58984)
|
||||
else
|
||||
|
||||
SHADOWFORM = GetSpellInfo(20580)
|
||||
end
|
||||
local SHADOWFORM = GetSpellInfo(58984)
|
||||
local PROWL = GetSpellInfo(5215)
|
||||
DogTag:AddTag("Unit", "IsStealthed", {
|
||||
alias = ("HasAura(aura=%q, unit=unit) or HasAura(aura=%q, unit=unit) or HasAura(aura=%q, unit=unit)"):format(STEALTH, SHADOWFORM, PROWL),
|
||||
|
@ -8,7 +8,6 @@ end
|
||||
DogTag_Unit_funcs[#DogTag_Unit_funcs+1] = function(DogTag_Unit, DogTag)
|
||||
|
||||
local L = DogTag_Unit.L
|
||||
local WoTLK = select(4,GetBuildInfo()) >= 30000
|
||||
|
||||
local isDruid = select(2, UnitClass("player")) == "DRUID"
|
||||
|
||||
@ -17,37 +16,16 @@ local function DruidMP_func(unit)
|
||||
end
|
||||
local MaxDruidMP_func = DruidMP_func
|
||||
|
||||
local LibDruidMana
|
||||
if isDruid then
|
||||
if not WoTLK then
|
||||
DogTag:AddAddonFinder("Unit", "LibStub", "LibDruidMana-1.0", function(v)
|
||||
LibDruidMana = v
|
||||
LibDruidMana:AddListener(function(currMana, maxMana)
|
||||
DogTag:FireEvent("DruidMana")
|
||||
end)
|
||||
function DruidMP_func(unit)
|
||||
if unit == "player" then
|
||||
return LibDruidMana:GetCurrentMana()
|
||||
end
|
||||
end
|
||||
function MaxDruidMP_func(unit)
|
||||
if unit == "player" then
|
||||
return LibDruidMana:GetMaximumMana()
|
||||
end
|
||||
end
|
||||
end)
|
||||
else
|
||||
function DruidMP_func(unit)
|
||||
if unit == "player" then
|
||||
return UnitPower(unit,0)
|
||||
end
|
||||
function DruidMP_func(unit)
|
||||
if unit == "player" then
|
||||
return UnitPower(unit,0)
|
||||
end
|
||||
function MaxDruidMP_func(unit)
|
||||
if unit == "player" then
|
||||
return UnitPowerMax(unit,0)
|
||||
end
|
||||
end
|
||||
function MaxDruidMP_func(unit)
|
||||
if unit == "player" then
|
||||
return UnitPowerMax(unit,0)
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -8,226 +8,80 @@ end
|
||||
DogTag_Unit_funcs[#DogTag_Unit_funcs+1] = function(DogTag_Unit, DogTag)
|
||||
|
||||
local L = DogTag_Unit.L
|
||||
local WoTLK = select(4,GetBuildInfo())
|
||||
|
||||
local function HP_func(unit, known)
|
||||
local hp = UnitHealth(unit)
|
||||
if known and UnitHealthMax(unit) == 100 then
|
||||
return nil
|
||||
else
|
||||
DogTag:AddTag("Unit", "HP", {
|
||||
code = function(unit)
|
||||
local hp = UnitHealth(unit)
|
||||
if hp == 1 and UnitIsGhost(unit) then
|
||||
return 0
|
||||
end
|
||||
return hp
|
||||
end
|
||||
end
|
||||
|
||||
local function MaxHP_func(unit, known)
|
||||
local maxhp = UnitHealthMax(unit)
|
||||
if known and maxhp == 100 then
|
||||
return nil
|
||||
else
|
||||
return maxhp
|
||||
end
|
||||
end
|
||||
|
||||
if not WoTLK then
|
||||
local HP_lib
|
||||
DogTag:AddAddonFinder("Unit", "LibStub", "LibMobHealth-4.0", function(v)
|
||||
HP_lib = "LibMobHealth-4.0"
|
||||
local LibMobHealth = v
|
||||
function HP_func(unit, known)
|
||||
local hp, found = LibMobHealth:GetUnitCurrentHP(unit)
|
||||
if known and not found then
|
||||
return nil
|
||||
else
|
||||
if hp == 1 and UnitIsGhost(unit) then
|
||||
return 0
|
||||
end
|
||||
return hp
|
||||
end
|
||||
end
|
||||
function MaxHP_func(unit, known)
|
||||
local maxhp, found = LibMobHealth:GetUnitMaxHP(unit)
|
||||
if known and not found then
|
||||
return nil
|
||||
else
|
||||
return maxhp
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
DogTag:AddAddonFinder("Unit", "_G", "MobHealth3", function(v)
|
||||
if HP_lib == "LibMobHealth-4.0" then
|
||||
return
|
||||
end
|
||||
local MobHealth3 = v
|
||||
function HP_func(unit, found)
|
||||
local currValue = UnitHealth(unit)
|
||||
if not UnitIsFriend("player", unit) then
|
||||
local maxValue = UnitHealthMax(unit)
|
||||
local curr, max, found = MobHealth3:GetUnitHealth(unit, currValue, maxValue)
|
||||
if found then
|
||||
return curr
|
||||
elseif known then
|
||||
return nil
|
||||
end
|
||||
elseif known and UnitHealthMax(unit) == 100 then
|
||||
return nil
|
||||
end
|
||||
return currValue
|
||||
end
|
||||
function MaxHP_func(unit, found)
|
||||
local maxValue = UnitHealthMax(unit)
|
||||
if not UnitIsFriend("player", unit) then
|
||||
local curr, max, MHfound = MobHealth3:GetUnitHealth(unit, 1, maxValue)
|
||||
if MHfound then
|
||||
return max
|
||||
elseif known then
|
||||
return nil
|
||||
end
|
||||
elseif known and maxValue == 100 then
|
||||
return nil
|
||||
end
|
||||
return maxValue
|
||||
end
|
||||
end)
|
||||
|
||||
DogTag:AddAddonFinder("Unit", "_G", "MobHealth_PPP", function(v)
|
||||
if HP_lib then
|
||||
return
|
||||
end
|
||||
local MobHealth_PPP = v
|
||||
function HP_func(unit, found)
|
||||
local currValue = UnitHealth(unit)
|
||||
if not UnitIsFriend("player", unit) then
|
||||
local name = UnitName(unit)
|
||||
local level = UnitLevel(unit)
|
||||
local ppp = MobHealth_PPP(name..":"..level)
|
||||
if ppp > 0 then
|
||||
return math.floor(currValue * ppp + 0.5)
|
||||
elseif known then
|
||||
return nil
|
||||
end
|
||||
elseif known and UnitHealthMax(unit) == 100 then
|
||||
return nil
|
||||
end
|
||||
return currValue
|
||||
end
|
||||
function MaxHP_func(unit, found)
|
||||
local maxValue = UnitHealthMax(unit)
|
||||
if not UnitIsFriend("player", unit) then
|
||||
local name = UnitName(unit)
|
||||
local level = UnitLevel(unit)
|
||||
local ppp = MobHealth_PPP(name..":"..level)
|
||||
if ppp > 0 then
|
||||
return math.floor(100 * ppp + 0.5)
|
||||
elseif known then
|
||||
return nil
|
||||
end
|
||||
elseif known and maxValue == 100 then
|
||||
return nil
|
||||
end
|
||||
return maxValue
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
DogTag:AddTag("Unit", "HP", {
|
||||
code = function(args)
|
||||
return HP_func
|
||||
end,
|
||||
dynamicCode = true,
|
||||
arg = {
|
||||
'unit', 'string;undef', 'player',
|
||||
'known', 'boolean', false,
|
||||
},
|
||||
ret = function(args)
|
||||
if args.known.types == "nil" then
|
||||
return 'number'
|
||||
else
|
||||
return 'nil;number'
|
||||
end
|
||||
end,
|
||||
ret = 'number',
|
||||
events = "UNIT_HEALTH#$unit;UNIT_MAXHEALTH#$unit;FastStats#$unit",
|
||||
doc = L["Return the current health of unit, will use MobHealth if found"],
|
||||
doc = L["Return the current health of unit"],
|
||||
example = ('[HP] => "%d"'):format(UnitHealthMax("player")*.758),
|
||||
category = L["Health"],
|
||||
})
|
||||
|
||||
DogTag:AddTag("Unit", "MaxHP", {
|
||||
code = function(args)
|
||||
return MaxHP_func
|
||||
code = function(unit)
|
||||
return UnitHealthMax(unit)
|
||||
end,
|
||||
dynamicCode = true,
|
||||
arg = {
|
||||
'unit', 'string;undef', 'player',
|
||||
'known', 'boolean', false,
|
||||
},
|
||||
ret = function(args)
|
||||
if args.known.types == "nil" then
|
||||
return 'number'
|
||||
else
|
||||
return 'nil;number'
|
||||
end
|
||||
end,
|
||||
ret = 'number',
|
||||
events = "UNIT_HEALTH#$unit;UNIT_MAXHEALTH#$unit",
|
||||
doc = L["Return the maximum health of unit, will use MobHealth if found"],
|
||||
doc = L["Return the maximum health of unit"],
|
||||
example = ('[MaxHP] => "%d"'):format(UnitHealthMax("player")),
|
||||
category = L["Health"],
|
||||
})
|
||||
|
||||
DogTag:AddTag("Unit", "PercentHP", {
|
||||
code = function(unit)
|
||||
local hp = UnitHealth(unit)
|
||||
if hp == 0 then
|
||||
return 0
|
||||
end
|
||||
return math.floor(hp/UnitHealthMax(unit)*1000 + 0.5) / 10
|
||||
end,
|
||||
fakeAlias = "[CurHP / MaxHP * 100]:Round(1)",
|
||||
alias = [=[[HP(unit=unit) / MaxHP(unit=unit) * 100]:Round(1)]=],
|
||||
arg = {
|
||||
'unit', 'string;undef', 'player'
|
||||
},
|
||||
ret = "number",
|
||||
events = "UNIT_HEALTH#$unit;UNIT_MAXHEALTH#$unit",
|
||||
doc = L["Return the percentage health of unit"],
|
||||
example = '[PercentHP] => "75.8"; [PercentHP:Percent] => "75.8%"',
|
||||
category = L["Health"],
|
||||
})
|
||||
|
||||
DogTag:AddTag("Unit", "MissingHP", {
|
||||
alias = [=[MaxHP(unit=unit, known=known) - HP(unit=unit, known=known)]=],
|
||||
alias = [=[MaxHP(unit=unit) - HP(unit=unit)]=],
|
||||
arg = {
|
||||
'unit', 'string;undef', 'player',
|
||||
'known', 'boolean', false,
|
||||
},
|
||||
ret = "number",
|
||||
doc = L["Return the missing health of unit, will use MobHealth if found"],
|
||||
doc = L["Return the missing health of unit"],
|
||||
example = ('[MissingHP] => "%d"'):format(UnitHealthMax("player")*.242),
|
||||
category = L["Health"]
|
||||
})
|
||||
|
||||
DogTag:AddTag("Unit", "FractionalHP", {
|
||||
alias = [=[Concatenate(HP(unit=unit, known=known), "/", MaxHP(unit=unit, known=known))]=],
|
||||
alias = [=[Concatenate(HP(unit=unit), "/", MaxHP(unit=unit))]=],
|
||||
arg = {
|
||||
'unit', 'string;undef', 'player',
|
||||
'known', 'boolean', false,
|
||||
},
|
||||
ret = "string",
|
||||
doc = L["Return the current health and maximum health of unit, will use MobHealth if found"],
|
||||
doc = L["Return the current health and maximum health of unit"],
|
||||
example = ('[FractionalHP] => "%d/%d"'):format(UnitHealthMax("player")*.758, UnitHealthMax("player")),
|
||||
category = L["Health"]
|
||||
})
|
||||
|
||||
DogTag:AddTag("Unit", "IsMaxHP", {
|
||||
code = function(unit)
|
||||
return UnitHealth(unit) == UnitHealthMax(unit)
|
||||
end,
|
||||
alias = [=[HP(unit=unit) == MaxHP(unit=unit)]=],
|
||||
arg = {
|
||||
'unit', 'string;undef', 'player'
|
||||
},
|
||||
ret = "boolean",
|
||||
doc = L["Return True if unit is at full health"],
|
||||
example = ('[IsMaxHP] => %q; [IsMaxHP] => ""'):format(L["True"]),
|
||||
category = L["Health"]
|
||||
|
Reference in New Issue
Block a user