fix(Core/Gameobject): Spell spawned chests should not despawn on loot (#4413)

* Fix despawning temporary lootable objects

* Fix codestyle

* Add comment

* Fix indendation

Co-authored-by: Zoidwaffle <zoidwaffle@gmail.com>
This commit is contained in:
Peter
2021-03-28 01:02:29 +01:00
committed by GitHub
parent 3e29ce2e50
commit 555862f059

View File

@@ -707,8 +707,17 @@ void GameObject::Update(uint32 diff)
//! The GetOwnerGUID() check is mostly for compatibility with hacky scripts - 99% of the time summoning should be done trough spells.
if (GetSpellId() || GetOwnerGUID())
{
SetRespawnTime(0);
Delete();
//Don't delete spell spawned chests, which are not consumed on loot
if (m_respawnTime > 0 && GetGoType() == GAMEOBJECT_TYPE_CHEST && !GetGOInfo()->IsDespawnAtAction())
{
UpdateObjectVisibility();
SetLootState(GO_READY);
}
else
{
SetRespawnTime(0);
Delete();
}
return;
}