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

@@ -929,7 +929,7 @@ uint32 Unit::DealDamage(Unit* attacker, Unit* victim, uint32 damage, CleanDamage
}
// Rage from Damage made (only from direct weapon damage)
if (attacker && cleanDamage && damagetype == DIRECT_DAMAGE && attacker != victim && attacker->getPowerType() == POWER_RAGE)
if (attacker && cleanDamage && damagetype == DIRECT_DAMAGE && attacker != victim && attacker->HasActivePowerType(POWER_RAGE))
{
uint32 weaponSpeedHitFactor;
@@ -957,10 +957,10 @@ uint32 Unit::DealDamage(Unit* attacker, Unit* victim, uint32 damage, CleanDamage
// Rage from absorbed damage
if (cleanDamage && cleanDamage->absorbed_damage)
{
if (victim->getPowerType() == POWER_RAGE)
if (victim->HasActivePowerType(POWER_RAGE))
victim->RewardRage(cleanDamage->absorbed_damage, 0, false);
if (attacker && attacker->getPowerType() == POWER_RAGE )
if (attacker && attacker->HasActivePowerType(POWER_RAGE))
attacker->RewardRage(cleanDamage->absorbed_damage, 0, true);
}
@@ -1083,7 +1083,7 @@ uint32 Unit::DealDamage(Unit* attacker, Unit* victim, uint32 damage, CleanDamage
}
// Rage from damage received
if (attacker != victim && victim->getPowerType() == POWER_RAGE)
if (attacker != victim && victim->HasActivePowerType(POWER_RAGE))
{
uint32 rageDamage = damage + (cleanDamage ? cleanDamage->absorbed_damage : 0);
victim->RewardRage(rageDamage, 0, false);
@@ -6996,7 +6996,7 @@ bool Unit::HandleDummyAuraProc(Unit* victim, uint32 damage, AuraEffect* triggere
// Magic Absorption
if (dummySpell->SpellIconID == 459) // only this spell has SpellIconID == 459 and dummy aura
{
if (getPowerType() != POWER_MANA)
if (!HasActivePowerType(POWER_MANA))
return false;
// mana reward
@@ -7775,7 +7775,7 @@ bool Unit::HandleDummyAuraProc(Unit* victim, uint32 damage, AuraEffect* triggere
// Judgement of Wisdom
case 20186:
{
if (!victim || !victim->IsAlive() || victim->getPowerType() != POWER_MANA || victim->HasSpellCooldown(20268))
if (!victim || !victim->IsAlive() || !victim->HasActivePowerType(POWER_MANA) || victim->HasSpellCooldown(20268))
return false;
// 2% of base mana