Core/AI: Implemented OnHealthDepleted hook
Port From (https://github.com/TrinityCore/TrinityCore/commit/ea134c0eae83b4cdbb5f0e941ed867a144bb01f6)
This commit is contained in:
@@ -448,6 +448,9 @@ namespace Game.AI
|
||||
// Called for reaction when initially engaged - this will always happen _after_ JustEnteredCombat
|
||||
public virtual void JustEngagedWith(Unit who) { }
|
||||
|
||||
// Called when the creature reaches 0 health (or 1 if unkillable).
|
||||
public virtual void OnHealthDepleted(Unit attacker, bool isKill) { }
|
||||
|
||||
// Called when the creature is killed
|
||||
public virtual void JustDied(Unit killer) { }
|
||||
|
||||
|
||||
@@ -942,7 +942,10 @@ namespace Game.Entities
|
||||
// Call creature just died function
|
||||
CreatureAI ai = creature.GetAI();
|
||||
if (ai != null)
|
||||
{
|
||||
ai.OnHealthDepleted(attacker, true);
|
||||
ai.JustDied(attacker);
|
||||
}
|
||||
|
||||
TempSummon summon = creature.ToTempSummon();
|
||||
if (summon != null)
|
||||
|
||||
@@ -2672,6 +2672,10 @@ namespace Game.Entities
|
||||
else if (victim.IsCreature() && damageTaken >= health && victim.ToCreature().HasFlag(CreatureStaticFlags.Unkillable))
|
||||
{
|
||||
damageTaken = health - 1;
|
||||
|
||||
// If we had damage (aka health was not 1 already) trigger OnHealthDepleted
|
||||
if (damageTaken > 0)
|
||||
victim.ToCreature().GetAI()?.OnHealthDepleted(attacker, false);
|
||||
}
|
||||
else if (victim.IsVehicle() && damageTaken >= (health - 1) && victim.GetCharmer() != null && victim.GetCharmer().IsTypeId(TypeId.Player))
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user