mirror of
https://github.com/brues-code/SuperCleveRoidMacros.git
synced 2026-09-16 03:38:00 +00:00
Use ClassicAPI UnitPower* for power reads; drop GetUnitField/SuperWoW paths
Add ClassicAPI UnitPower/UnitPowerMax/UnitPowerMissing/UnitPowerType wrappers
and route the power conditionals through them:
- ValidatePower/ValidateRawPower/GetCachedPlayerPower(Percent) use UnitPower /
UnitPowerMax (omitted type = primary power, matching the old UnitMana path).
- ValidatePowerLost uses UnitPowerMissing (one call vs max - current).
- powertype/nopowertype use ClassicAPI.UnitPowerType.
Replace the SuperWoW "2nd return of UnitMana = caster mana" druid hack in
ValidateDruidRawMana and the #showtooltip OOM check with UnitPower(unit, 0),
which reads the mana slot directly and survives shapeshift. Verified in Cat
Form: UnitPower('player', 0) returns caster mana while UnitPower('player', 3)
returns energy.
Remove the now-dead Nampower GetUnitField-based GetUnitPower/GetUnitMaxPower
wrappers and POWER_FIELDS tables (no caller passed a powerType, so that path
never ran).
This commit is contained in:
@@ -197,6 +197,34 @@ function API.GetSpellBonusHealing()
|
||||
return GetSpellBonusHealing()
|
||||
end
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
-- Unit Power
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
-- Current power for a specific Enum.PowerType (0=Mana, 1=Rage, 2=Focus,
|
||||
-- 3=Energy, 4=Happiness), or the unit's primary power when powerType is omitted.
|
||||
-- Display-divided (rage reads 0..100). Falls back to UnitMana without ClassicAPI.
|
||||
function API.UnitPower(unit, powerType)
|
||||
if type(UnitPower) == "function" then return UnitPower(unit, powerType) end
|
||||
return UnitMana(unit)
|
||||
end
|
||||
|
||||
function API.UnitPowerMax(unit, powerType)
|
||||
if type(UnitPowerMax) == "function" then return UnitPowerMax(unit, powerType) end
|
||||
return UnitManaMax(unit)
|
||||
end
|
||||
|
||||
-- Power deficit (max - current) for the type / primary power, in one call.
|
||||
function API.UnitPowerMissing(unit, powerType)
|
||||
if type(UnitPowerMissing) == "function" then return UnitPowerMissing(unit, powerType) end
|
||||
return (UnitManaMax(unit) or 0) - (UnitMana(unit) or 0)
|
||||
end
|
||||
|
||||
-- Unit's primary power type as an integer (0=Mana .. 4=Happiness).
|
||||
function API.UnitPowerType(unit)
|
||||
return UnitPowerType(unit)
|
||||
end
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
-- State
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user