mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-22 02:04:52 +01:00
Core/AI: Implemented OnHealthDepleted hook (#29134)
This commit is contained in:
@@ -98,6 +98,9 @@ class TC_GAME_API CreatureAI : public UnitAI
|
||||
// Called for reaction when initially engaged - this will always happen _after_ JustEnteredCombat
|
||||
virtual void JustEngagedWith(Unit* /*who*/) { }
|
||||
|
||||
// Called when the creature reaches 0 health (or 1 if unkillable).
|
||||
virtual void OnHealthDepleted(Unit* /*attacker*/, bool /*isKill*/) { }
|
||||
|
||||
// Called when the creature is killed
|
||||
virtual void JustDied(Unit* /*killer*/) { }
|
||||
|
||||
|
||||
@@ -864,6 +864,13 @@ bool Unit::HasBreakableByDamageCrowdControlAura(Unit* excludeCasterChannel) cons
|
||||
else if (victim->IsCreature() && damageTaken >= health && victim->ToCreature()->HasFlag(CREATURE_STATIC_FLAG_UNKILLABLE))
|
||||
{
|
||||
damageTaken = health - 1;
|
||||
|
||||
// If we had damage (aka health was not 1 already) trigger OnHealthDepleted
|
||||
if (damageTaken > 0)
|
||||
{
|
||||
if (CreatureAI* victimAI = victim->ToCreature()->AI())
|
||||
victimAI->OnHealthDepleted(attacker, false);
|
||||
}
|
||||
}
|
||||
else if (victim->IsVehicle() && damageTaken >= (health-1) && victim->GetCharmer() && victim->GetCharmer()->GetTypeId() == TYPEID_PLAYER)
|
||||
{
|
||||
@@ -10916,7 +10923,10 @@ void Unit::SetMeleeAnimKitId(uint16 animKitId)
|
||||
|
||||
// Call creature just died function
|
||||
if (CreatureAI* ai = creature->AI())
|
||||
{
|
||||
ai->OnHealthDepleted(attacker, true);
|
||||
ai->JustDied(attacker);
|
||||
}
|
||||
|
||||
if (TempSummon * summon = creature->ToTempSummon())
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user