fix(Core/Unit): Keep Lightwell alive on player death (#24675)
This commit is contained in:
parent
a7f49ff6b2
commit
fda5093e59
2 changed files with 24 additions and 4 deletions
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue