feat(Core/Unit): New helper HasActivePowerType and script hook OnPlayerHasActivePowerType (#18293)

* Create HasActivePower for script intercept

* Replace relevant player-related getPowerType() comparators with HasActivePowerType

* Change OnPlayerHasActivePowerType to regular bool instead of optional

---------

Co-authored-by: NathanHandley <nathanhandley@protonmail.com>
This commit is contained in:
Nathan Handley
2024-02-09 03:27:02 -06:00
committed by GitHub
parent ed53ac2feb
commit 425a490a7b
13 changed files with 66 additions and 38 deletions

View File

@@ -576,7 +576,7 @@ class spell_item_skull_of_impeding_doom : public AuraScript
void CalculateManaLeechAmount(AuraEffect const* /*aurEff*/, int32& amount, bool& /*canBeRecalculated*/)
{
if (!GetCaster() || GetCaster()->getPowerType() != POWER_MANA)
if (!GetCaster() || !GetCaster()->HasActivePowerType(POWER_MANA))
return;
amount = GetCaster()->GetMaxPower(POWER_MANA) * 0.12f; // 5 ticks which reduce health by 60%

View File

@@ -483,7 +483,7 @@ class spell_pal_blessing_of_sanctuary : public AuraScript
bool CheckProc(ProcEventInfo& /*eventInfo*/)
{
return GetTarget()->getPowerType() == POWER_MANA;
return GetTarget()->HasActivePowerType(POWER_MANA);
}
void HandleProc(AuraEffect const* aurEff, ProcEventInfo& /*eventInfo*/)
@@ -969,7 +969,7 @@ class spell_pal_lay_on_hands : public SpellScript
// Xinef: Glyph of Divinity
if (Unit* target = GetExplTargetUnit())
if (target->getPowerType() == POWER_MANA)
if (target->HasActivePowerType(POWER_MANA))
_manaAmount = target->GetPower(POWER_MANA);
return SPELL_CAST_OK;

View File

@@ -992,7 +992,7 @@ class spell_sha_mana_spring_totem : public SpellScript
int32 damage = GetEffectValue();
if (Unit* target = GetHitUnit())
if (Unit* caster = GetCaster())
if (target->getPowerType() == POWER_MANA)
if (target->HasActivePowerType(POWER_MANA))
caster->CastCustomSpell(target, SPELL_SHAMAN_MANA_SPRING_TOTEM_ENERGIZE, &damage, 0, 0, true, 0, 0, GetOriginalCaster()->GetGUID());
}
@@ -1017,7 +1017,7 @@ class spell_sha_mana_tide_totem : public SpellScript
if (Unit* caster = GetCaster())
if (Unit* unitTarget = GetHitUnit())
{
if (unitTarget->getPowerType() == POWER_MANA)
if (unitTarget->HasActivePowerType(POWER_MANA))
{
int32 effValue = GetEffectValue();
// Glyph of Mana Tide