fix(Core/Unit): Keep Lightwell alive on player death (#24675)

This commit is contained in:
sogladev 2026-03-14 16:43:24 +01:00 committed by GitHub
parent a7f49ff6b2
commit fda5093e59
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 24 additions and 4 deletions

View file

@ -34,12 +34,20 @@ Totem::Totem(SummonPropertiesEntry const* properties, ObjectGuid owner) : Minion
void Totem::Update(uint32 time)
{
Unit* owner = GetOwner();
if (!owner || !owner->IsAlive() || !IsAlive() || m_duration <= time)
if (!owner || !IsAlive() || m_duration <= time)
{
UnSummon(); // remove self
return;
}
// If owner is dead and this is not a lightwell, despawn
if (!owner->IsAlive() && !(m_Properties && m_Properties->Type == SUMMON_TYPE_LIGHTWELL))
{
UnSummon();
return;
}
m_duration -= time;
Creature::Update(time);
}

View file

@ -8077,24 +8077,36 @@ void Unit::RemoveAllControlled(bool onDeath /*= false*/)
if (IsPlayer())
ToPlayer()->StopCastingCharm();
while (!m_Controlled.empty())
for (auto it = m_Controlled.begin(); it != m_Controlled.end();)
{
Unit* target = *m_Controlled.begin();
m_Controlled.erase(m_Controlled.begin());
Unit* target = *it;
if (target->GetCharmerGUID() == GetGUID())
{
it = m_Controlled.erase(it);
target->RemoveCharmAuras();
}
else if (target->GetOwnerGUID() == GetGUID() && target->IsSummon())
{
// Keep Lightwell alive on owner death
if (onDeath)
if (TempSummon* ts = target->ToTempSummon())
if (ts->m_Properties && ts->m_Properties->Type == SUMMON_TYPE_LIGHTWELL)
{
++it;
continue;
}
if (!(onDeath && !IsPlayer() && target->IsGuardian()))
{
target->ToTempSummon()->UnSummon();
it = m_Controlled.erase(it);
}
}
else
{
LOG_ERROR("entities.unit", "Unit {} is trying to release unit {} which is neither charmed nor owned by it", GetEntry(), target->GetEntry());
++it;
}
}
}