fix(Core/Unit): Keep Lightwell alive on player death (#24675)
This commit is contained in:
@@ -34,12 +34,20 @@ Totem::Totem(SummonPropertiesEntry const* properties, ObjectGuid owner) : Minion
|
|||||||
void Totem::Update(uint32 time)
|
void Totem::Update(uint32 time)
|
||||||
{
|
{
|
||||||
Unit* owner = GetOwner();
|
Unit* owner = GetOwner();
|
||||||
if (!owner || !owner->IsAlive() || !IsAlive() || m_duration <= time)
|
|
||||||
|
if (!owner || !IsAlive() || m_duration <= time)
|
||||||
{
|
{
|
||||||
UnSummon(); // remove self
|
UnSummon(); // remove self
|
||||||
return;
|
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;
|
m_duration -= time;
|
||||||
Creature::Update(time);
|
Creature::Update(time);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8077,24 +8077,36 @@ void Unit::RemoveAllControlled(bool onDeath /*= false*/)
|
|||||||
if (IsPlayer())
|
if (IsPlayer())
|
||||||
ToPlayer()->StopCastingCharm();
|
ToPlayer()->StopCastingCharm();
|
||||||
|
|
||||||
while (!m_Controlled.empty())
|
for (auto it = m_Controlled.begin(); it != m_Controlled.end();)
|
||||||
{
|
{
|
||||||
Unit* target = *m_Controlled.begin();
|
Unit* target = *it;
|
||||||
m_Controlled.erase(m_Controlled.begin());
|
|
||||||
if (target->GetCharmerGUID() == GetGUID())
|
if (target->GetCharmerGUID() == GetGUID())
|
||||||
{
|
{
|
||||||
|
it = m_Controlled.erase(it);
|
||||||
target->RemoveCharmAuras();
|
target->RemoveCharmAuras();
|
||||||
}
|
}
|
||||||
else if (target->GetOwnerGUID() == GetGUID() && target->IsSummon())
|
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()))
|
if (!(onDeath && !IsPlayer() && target->IsGuardian()))
|
||||||
{
|
{
|
||||||
target->ToTempSummon()->UnSummon();
|
target->ToTempSummon()->UnSummon();
|
||||||
|
it = m_Controlled.erase(it);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
LOG_ERROR("entities.unit", "Unit {} is trying to release unit {} which is neither charmed nor owned by it", GetEntry(), target->GetEntry());
|
LOG_ERROR("entities.unit", "Unit {} is trying to release unit {} which is neither charmed nor owned by it", GetEntry(), target->GetEntry());
|
||||||
|
++it;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user