Core/Creatures: moved despawning summons upon summoner death to SummonInfo API and implemented more specific despawn rules

This commit is contained in:
Ovahlord committed 2025-08-24 13:23:45 +02:00
1 parent c77ed42bf2
commit 0e5489a9da
5 files changed
+65 -5

No files matched your search

+15 -1
View File
@@ -8606,7 +8606,8 @@ void Unit::setDeathState(DeathState s)
ExitVehicle(); // Exit vehicle before calling RemoveAllControlled
// vehicles use special type of charm that is not removed by the next function
// triggering an assert
UnsummonAllTotems();
DespawnSummonsOnSummonerDeath();
RemoveAllControlled();
RemoveAllAurasOnDeath();
}
@@ -8889,6 +8890,19 @@ void Unit::DespawnSummonsOnSummonerLogout()
summon->GetSummonedCreature()->DespawnOrUnsummon();
}
void Unit::DespawnSummonsOnSummonerDeath()
{
std::vector<SummonInfo*> slottedSummons = _slottedSummons;
for (SummonInfo* summon : slottedSummons)
if (summon && summon->DespawnsOnSummonerDeath())
summon->GetSummonedCreature()->DespawnOrUnsummon();
std::vector<SummonInfo*> wildSummons = _wildSummons;
for (SummonInfo* summon : wildSummons)
if (summon->DespawnsOnSummonerDeath())
summon->GetSummonedCreature()->DespawnOrUnsummon();
}
SummonInfo* Unit::GetSummonInSlot(SummonPropertiesSlot slot) const
{
if (slot == SummonPropertiesSlot::None ||