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
+14 -14
View File
@@ -10658,24 +10658,17 @@ void Unit::SetMeleeAnimKitId(uint16 animKitId)
}
}
else
{
player->SendDirectMessage(partyKillLog.Write());
if (creature)
{
WorldPackets::Loot::LootList lootList;
lootList.Owner = creature->GetGUID();
lootList.LootObj = creature->loot.GetGUID();
player->SendMessageToSet(lootList.Write(), true);
}
}
// Generate loot before updating looter
if (creature)
{
Loot* loot = &creature->loot;
loot->clear();
creature->m_loot.reset(new Loot());
Loot* loot = creature->m_loot.get();
loot->SetGUID(ObjectGuid::Create<HighGuid::LootObject>(creature->GetMapId(), 0, creature->GetMap()->GenerateLowGuid<HighGuid::LootObject>()));
if (creature->GetMap()->Is25ManRaid())
loot->maxDuplicates = 3;
if (uint32 lootid = creature->GetCreatureTemplate()->lootid)
loot->FillLoot(lootid, LootTemplates_Creature, looter, false, false, creature->GetLootMode(), creature->GetMap()->GetDifficultyLootItemContext());
@@ -10693,6 +10686,13 @@ void Unit::SetMeleeAnimKitId(uint16 animKitId)
if (!loot->empty())
group->UpdateLooterGuid(creature);
}
else
{
WorldPackets::Loot::LootList lootList;
lootList.Owner = creature->GetGUID();
lootList.LootObj = creature->m_loot->GetGUID();
player->SendMessageToSet(lootList.Write(), true);
}
}
player->RewardPlayerAndGroupAtKill(victim, false);
@@ -10785,7 +10785,7 @@ void Unit::SetMeleeAnimKitId(uint16 animKitId)
if (!creature->IsPet())
{
// must be after setDeathState which resets dynamic flags
if (!creature->loot.isLooted())
if (creature->m_loot && !creature->m_loot->isLooted())
creature->SetDynamicFlag(UNIT_DYNFLAG_LOOTABLE);
else
creature->AllLootRemovedFromCorpse();