mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-02-03 11:03:47 +00:00
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:
@@ -6244,7 +6244,7 @@ void AuraEffect::HandlePeriodicDummyAuraTick(Unit* target, Unit* caster) const
|
||||
{
|
||||
// Converts up to 10 rage per second into health for $d. Each point of rage is converted into ${$m2/10}.1% of max health.
|
||||
// Should be manauser
|
||||
if (target->getPowerType() != POWER_RAGE)
|
||||
if (!target->HasActivePowerType(POWER_RAGE))
|
||||
break;
|
||||
uint32 rage = target->GetPower(POWER_RAGE);
|
||||
// Nothing todo
|
||||
@@ -7082,7 +7082,7 @@ void AuraEffect::HandlePeriodicManaLeechAuraTick(Unit* target, Unit* caster) con
|
||||
{
|
||||
Powers PowerType = Powers(GetMiscValue());
|
||||
|
||||
if (!caster || !caster->IsAlive() || !target->IsAlive() || target->getPowerType() != PowerType)
|
||||
if (!caster || !caster->IsAlive() || !target->IsAlive() || !target->HasActivePowerType(PowerType))
|
||||
return;
|
||||
|
||||
if (target->HasUnitState(UNIT_STATE_ISOLATED) || target->IsImmunedToDamageOrSchool(GetSpellInfo()))
|
||||
@@ -7189,7 +7189,7 @@ void AuraEffect::HandlePeriodicEnergizeAuraTick(Unit* target, Unit* caster) cons
|
||||
{
|
||||
Powers PowerType = Powers(GetMiscValue());
|
||||
|
||||
if (target->GetTypeId() == TYPEID_PLAYER && target->getPowerType() != PowerType && !m_spellInfo->HasAttribute(SPELL_ATTR7_ONLY_IN_SPELLBOOK_UNTIL_LEARNED))
|
||||
if (target->GetTypeId() == TYPEID_PLAYER && !target->HasActivePowerType(PowerType) && !m_spellInfo->HasAttribute(SPELL_ATTR7_ONLY_IN_SPELLBOOK_UNTIL_LEARNED))
|
||||
return;
|
||||
|
||||
if (!target->IsAlive() || !target->GetMaxPower(PowerType))
|
||||
@@ -7223,7 +7223,7 @@ void AuraEffect::HandlePeriodicPowerBurnAuraTick(Unit* target, Unit* caster) con
|
||||
{
|
||||
Powers PowerType = Powers(GetMiscValue());
|
||||
|
||||
if (!caster || !target->IsAlive() || target->getPowerType() != PowerType)
|
||||
if (!caster || !target->IsAlive() || !target->HasActivePowerType(PowerType))
|
||||
return;
|
||||
|
||||
if (target->HasUnitState(UNIT_STATE_ISOLATED) || target->IsImmunedToDamageOrSchool(GetSpellInfo()))
|
||||
|
||||
@@ -6173,7 +6173,7 @@ SpellCastResult Spell::CheckCast(bool strict)
|
||||
// Can be area effect, Check only for players and not check if target - caster (spell can have multiply drain/burn effects)
|
||||
if (m_caster->GetTypeId() == TYPEID_PLAYER)
|
||||
if (Unit* target = m_targets.GetUnitTarget())
|
||||
if (target != m_caster && target->getPowerType() != Powers(m_spellInfo->Effects[i].MiscValue))
|
||||
if (target != m_caster && !target->HasActivePowerType(Powers(m_spellInfo->Effects[i].MiscValue)))
|
||||
return SPELL_FAILED_BAD_TARGETS;
|
||||
break;
|
||||
}
|
||||
@@ -6702,7 +6702,7 @@ SpellCastResult Spell::CheckCast(bool strict)
|
||||
if (!m_targets.GetUnitTarget())
|
||||
return SPELL_FAILED_BAD_IMPLICIT_TARGETS;
|
||||
|
||||
if (m_targets.GetUnitTarget()->getPowerType() != POWER_MANA)
|
||||
if (!m_targets.GetUnitTarget()->HasActivePowerType(POWER_MANA))
|
||||
return SPELL_FAILED_BAD_TARGETS;
|
||||
|
||||
break;
|
||||
|
||||
@@ -1345,7 +1345,7 @@ void Spell::EffectPowerDrain(SpellEffIndex effIndex)
|
||||
|
||||
Powers PowerType = Powers(m_spellInfo->Effects[effIndex].MiscValue);
|
||||
|
||||
if (!unitTarget || !unitTarget->IsAlive() || unitTarget->getPowerType() != PowerType || damage < 0)
|
||||
if (!unitTarget || !unitTarget->IsAlive() || !unitTarget->HasActivePowerType(PowerType) || damage < 0)
|
||||
return;
|
||||
|
||||
// add spell damage bonus
|
||||
@@ -1424,7 +1424,7 @@ void Spell::EffectPowerBurn(SpellEffIndex effIndex)
|
||||
|
||||
Powers PowerType = Powers(m_spellInfo->Effects[effIndex].MiscValue);
|
||||
|
||||
if (!unitTarget || !unitTarget->IsAlive() || unitTarget->getPowerType() != PowerType || damage < 0)
|
||||
if (!unitTarget || !unitTarget->IsAlive() || !unitTarget->HasActivePowerType(PowerType) || damage < 0)
|
||||
return;
|
||||
|
||||
// burn x% of target's mana, up to maximum of 2x% of caster's mana (Mana Burn)
|
||||
@@ -1877,7 +1877,7 @@ void Spell::EffectEnergize(SpellEffIndex effIndex)
|
||||
|
||||
Powers power = Powers(m_spellInfo->Effects[effIndex].MiscValue);
|
||||
|
||||
if (unitTarget->GetTypeId() == TYPEID_PLAYER && unitTarget->getPowerType() != power && m_spellInfo->SpellFamilyName != SPELLFAMILY_POTION
|
||||
if (unitTarget->GetTypeId() == TYPEID_PLAYER && !unitTarget->HasActivePowerType(power) && m_spellInfo->SpellFamilyName != SPELLFAMILY_POTION
|
||||
&& !m_spellInfo->HasAttribute(SPELL_ATTR7_ONLY_IN_SPELLBOOK_UNTIL_LEARNED))
|
||||
return;
|
||||
|
||||
@@ -1982,7 +1982,7 @@ void Spell::EffectEnergizePct(SpellEffIndex effIndex)
|
||||
|
||||
Powers power = Powers(m_spellInfo->Effects[effIndex].MiscValue);
|
||||
|
||||
if (unitTarget->GetTypeId() == TYPEID_PLAYER && unitTarget->getPowerType() != power && !m_spellInfo->HasAttribute(SPELL_ATTR7_ONLY_IN_SPELLBOOK_UNTIL_LEARNED))
|
||||
if (unitTarget->GetTypeId() == TYPEID_PLAYER && !unitTarget->HasActivePowerType(power) && !m_spellInfo->HasAttribute(SPELL_ATTR7_ONLY_IN_SPELLBOOK_UNTIL_LEARNED))
|
||||
return;
|
||||
|
||||
uint32 maxPower = unitTarget->GetMaxPower(power);
|
||||
|
||||
Reference in New Issue
Block a user