fix(Core/Creatures): Creatures' guardian should not despawn on summon… (#7607)
- Closes #6211
This commit is contained in:
@@ -10360,7 +10360,7 @@ Unit* Unit::GetFirstControlled() const
|
|||||||
return unit;
|
return unit;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Unit::RemoveAllControlled()
|
void Unit::RemoveAllControlled(bool onDeath /*= false*/)
|
||||||
{
|
{
|
||||||
// possessed pet and vehicle
|
// possessed pet and vehicle
|
||||||
if (GetTypeId() == TYPEID_PLAYER)
|
if (GetTypeId() == TYPEID_PLAYER)
|
||||||
@@ -10371,18 +10371,21 @@ void Unit::RemoveAllControlled()
|
|||||||
Unit* target = *m_Controlled.begin();
|
Unit* target = *m_Controlled.begin();
|
||||||
m_Controlled.erase(m_Controlled.begin());
|
m_Controlled.erase(m_Controlled.begin());
|
||||||
if (target->GetCharmerGUID() == GetGUID())
|
if (target->GetCharmerGUID() == GetGUID())
|
||||||
|
{
|
||||||
target->RemoveCharmAuras();
|
target->RemoveCharmAuras();
|
||||||
|
}
|
||||||
else if (target->GetOwnerGUID() == GetGUID() && target->IsSummon())
|
else if (target->GetOwnerGUID() == GetGUID() && target->IsSummon())
|
||||||
target->ToTempSummon()->UnSummon();
|
{
|
||||||
|
if (!(onDeath && !IsPlayer() && target->IsGuardian()))
|
||||||
|
{
|
||||||
|
target->ToTempSummon()->UnSummon();
|
||||||
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
LOG_ERROR("entities.unit", "Unit %u is trying to release unit %u which is neither charmed nor owned by it", GetEntry(), target->GetEntry());
|
LOG_ERROR("entities.unit", "Unit %u is trying to release unit %u which is neither charmed nor owned by it", GetEntry(), target->GetEntry());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (GetPetGUID())
|
|
||||||
LOG_FATAL("entities.unit", "Unit %u is not able to release its pet %s", GetEntry(), GetPetGUID().ToString().c_str());
|
|
||||||
if (GetMinionGUID())
|
|
||||||
LOG_FATAL("entities.unit", "Unit %u is not able to release its minion %s", GetEntry(), GetMinionGUID().ToString().c_str());
|
|
||||||
if (GetCharmGUID())
|
|
||||||
LOG_FATAL("entities.unit", "Unit %u is not able to release its charm %s", GetEntry(), GetCharmGUID().ToString().c_str());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Unit* Unit::GetNextRandomRaidMemberOrPet(float radius)
|
Unit* Unit::GetNextRandomRaidMemberOrPet(float radius)
|
||||||
@@ -10476,16 +10479,25 @@ void Unit::RemoveCharmAuras()
|
|||||||
RemoveAurasByType(SPELL_AURA_AOE_CHARM);
|
RemoveAurasByType(SPELL_AURA_AOE_CHARM);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Unit::UnsummonAllTotems()
|
void Unit::UnsummonAllTotems(bool onDeath /*= false*/)
|
||||||
{
|
{
|
||||||
for (uint8 i = 0; i < MAX_SUMMON_SLOT; ++i)
|
for (uint8 i = 0; i < MAX_SUMMON_SLOT; ++i)
|
||||||
{
|
{
|
||||||
if (!m_SummonSlot[i])
|
if (!m_SummonSlot[i])
|
||||||
|
{
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (Creature* OldTotem = GetMap()->GetCreature(m_SummonSlot[i]))
|
if (Creature* OldTotem = GetMap()->GetCreature(m_SummonSlot[i]))
|
||||||
|
{
|
||||||
if (OldTotem->IsSummon())
|
if (OldTotem->IsSummon())
|
||||||
OldTotem->ToTempSummon()->UnSummon();
|
{
|
||||||
|
if (!(onDeath && !IsPlayer() && OldTotem->IsGuardian()))
|
||||||
|
{
|
||||||
|
OldTotem->ToTempSummon()->UnSummon();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -13571,8 +13583,8 @@ void Unit::setDeathState(DeathState s, bool despawn)
|
|||||||
if (IsNonMeleeSpellCast(false))
|
if (IsNonMeleeSpellCast(false))
|
||||||
InterruptNonMeleeSpells(false);
|
InterruptNonMeleeSpells(false);
|
||||||
|
|
||||||
UnsummonAllTotems();
|
UnsummonAllTotems(true);
|
||||||
RemoveAllControlled();
|
RemoveAllControlled(true);
|
||||||
RemoveAllAurasOnDeath();
|
RemoveAllAurasOnDeath();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1918,7 +1918,7 @@ public:
|
|||||||
|
|
||||||
ControlSet m_Controlled;
|
ControlSet m_Controlled;
|
||||||
[[nodiscard]] Unit* GetFirstControlled() const;
|
[[nodiscard]] Unit* GetFirstControlled() const;
|
||||||
void RemoveAllControlled();
|
void RemoveAllControlled(bool onDeath = false);
|
||||||
|
|
||||||
[[nodiscard]] bool IsCharmed() const { return GetCharmerGUID(); }
|
[[nodiscard]] bool IsCharmed() const { return GetCharmerGUID(); }
|
||||||
[[nodiscard]] bool isPossessed() const { return HasUnitState(UNIT_STATE_POSSESSED); }
|
[[nodiscard]] bool isPossessed() const { return HasUnitState(UNIT_STATE_POSSESSED); }
|
||||||
@@ -2244,7 +2244,7 @@ public:
|
|||||||
void ModifyAuraState(AuraStateType flag, bool apply);
|
void ModifyAuraState(AuraStateType flag, bool apply);
|
||||||
uint32 BuildAuraStateUpdateForTarget(Unit* target) const;
|
uint32 BuildAuraStateUpdateForTarget(Unit* target) const;
|
||||||
bool HasAuraState(AuraStateType flag, SpellInfo const* spellProto = nullptr, Unit const* Caster = nullptr) const;
|
bool HasAuraState(AuraStateType flag, SpellInfo const* spellProto = nullptr, Unit const* Caster = nullptr) const;
|
||||||
void UnsummonAllTotems();
|
void UnsummonAllTotems(bool onDeath = false);
|
||||||
Unit* GetMagicHitRedirectTarget(Unit* victim, SpellInfo const* spellInfo);
|
Unit* GetMagicHitRedirectTarget(Unit* victim, SpellInfo const* spellInfo);
|
||||||
Unit* GetMeleeHitRedirectTarget(Unit* victim, SpellInfo const* spellInfo = nullptr);
|
Unit* GetMeleeHitRedirectTarget(Unit* victim, SpellInfo const* spellInfo = nullptr);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user