feat(Core/Unit): Implement OnPowerUpdate() unit script hook (#17560)

This commit is contained in:
Andrew
2023-10-22 09:14:41 -03:00
committed by GitHub
parent 0cc85086a4
commit 9935e72341
2 changed files with 9 additions and 1 deletions

View File

@@ -353,11 +353,14 @@ public:
// Called at any Damage from any attacker (before damage apply)
// Note: it for recalculation damage or special reaction at damage
// for attack reaction use AttackedBy called for not DOT damage in Unit::DealDamage also
virtual void DamageTaken(Unit* /*attacker*/, uint32& /*damage*/, DamageEffectType /*damagetype*/, SpellSchoolMask /*damageSchoolMask*/ ) {}
virtual void DamageTaken(Unit* /*attacker*/, uint32& /*damage*/, DamageEffectType /*damagetype*/, SpellSchoolMask /*damageSchoolMask*/) {}
// Called when the creature receives heal
virtual void HealReceived(Unit* /*done_by*/, uint32& /*addhealth*/) {}
// Called when the creature power updates
virtual void OnPowerUpdate(Powers /*power*/, int32 /*updateVal*/, int32 /*gain*/, uint32 /*currPower*/) {}
// Called when the unit heals
virtual void HealDone(Unit* /*done_to*/, uint32& /*addhealth*/) {}

View File

@@ -14115,6 +14115,11 @@ int32 Unit::ModifyPower(Powers power, int32 dVal, bool withPowerUpdate /*= true*
gain = maxPower - curPower;
}
if (GetAI())
{
GetAI()->OnPowerUpdate(power, gain, dVal, curPower);
}
return gain;
}