Core/Loot: Allocate Loot separately from objects

This commit is contained in:
Shauren
2022-09-01 20:07:58 +02:00
parent 62e5b52d2b
commit 7957e2d380
24 changed files with 188 additions and 139 deletions

View File

@@ -825,10 +825,6 @@ bool GameObject::Create(uint32 entry, Map* map, Position const& pos, QuaternionD
LastUsedScriptID = GetGOInfo()->ScriptId;
AIM_Initialize();
// Initialize loot duplicate count depending on raid difficulty
if (map->Is25ManRaid())
loot.maxDuplicates = 3;
if (spawnid)
m_spawnId = spawnid;
@@ -1177,12 +1173,12 @@ void GameObject::Update(uint32 diff)
}
break;
case GAMEOBJECT_TYPE_CHEST:
if (m_groupLootTimer)
if (m_loot && m_groupLootTimer)
{
if (m_groupLootTimer <= diff)
{
if (Group* group = sGroupMgr->GetGroupByGUID(lootingGroupLowGUID))
group->EndRoll(&loot, GetMap());
group->EndRoll(m_loot.get(), GetMap());
m_groupLootTimer = 0;
lootingGroupLowGUID.Clear();
@@ -1269,7 +1265,7 @@ void GameObject::Update(uint32 diff)
return;
}
loot.clear();
m_loot = nullptr;
// Do not delete chests or goobers that are not consumed on loot, while still allowing them to despawn when they expire if summoned
bool isSummonedAndExpired = (GetOwner() || GetSpellId()) && m_respawnTime == 0;