Core/Entities: Handle partial state change for pets

Port From (https://github.com/TrinityCore/TrinityCore/commit/0585032c9000386846c506a360eddc09cf069afe)
This commit is contained in:
hondacrx
2021-11-15 23:12:46 -05:00
parent 2aa910e9f6
commit 333179e1e9
2 changed files with 78 additions and 41 deletions
+22
View File
@@ -321,6 +321,28 @@ namespace Game.Entities
base.RemoveFromWorld();
}
public override void SetDeathState(DeathState s)
{
base.SetDeathState(s);
if (s != DeathState.JustDied || !IsGuardianPet())
return;
Unit owner = GetOwner();
if (owner == null || !owner.IsPlayer() || owner.GetMinionGUID() != GetGUID())
return;
foreach (Unit controlled in owner.m_Controlled)
{
if (controlled.GetEntry() == GetEntry() && controlled.IsAlive())
{
owner.SetMinionGUID(controlled.GetGUID());
owner.SetPetGUID(controlled.GetGUID());
owner.ToPlayer().CharmSpellInitialize();
break;
}
}
}
public bool IsGuardianPet()
{
return IsPet() || (m_Properties != null && m_Properties.Control == SummonCategory.Pet);