Skip to content

Commit

Permalink
Creature: Rework CreatureStaticFlags::CAN_WIELD_LOOT based on evidence
Browse files Browse the repository at this point in the history
  • Loading branch information
killerwife committed Dec 27, 2024
1 parent a70537a commit cda5f88
Showing 1 changed file with 6 additions and 11 deletions.
17 changes: 6 additions & 11 deletions src/game/Entities/Creature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -409,15 +409,17 @@ bool Creature::InitEntry(uint32 Entry, CreatureData const* data /*=nullptr*/, Ga
}
else if (!data || (data->spawnTemplate->equipmentId == -1))
{
bool usingLoot = false;
if (GetSettings().HasFlag(CreatureStaticFlags::CAN_WIELD_LOOT))
if (cinfo->EquipmentTemplateId == 0)
LoadEquipment(normalInfo->EquipmentTemplateId, true); // use default from normal template if diff does not have any
else
LoadEquipment(cinfo->EquipmentTemplateId); // else use from diff template

if (GetSettings().HasFlag(CreatureStaticFlags::CAN_WIELD_LOOT)) // override from loot if any
{
PrepareBodyLootState();
if (m_loot != nullptr)
{
auto [mh, oh, ranged] = m_loot->GetQualifiedWeapons();
if (mh != 0 || oh != 0 || ranged != 0)
usingLoot = true;

if (mh != 0)
SetVirtualItem(VIRTUAL_ITEM_SLOT_0, mh);
Expand All @@ -429,13 +431,6 @@ bool Creature::InitEntry(uint32 Entry, CreatureData const* data /*=nullptr*/, Ga
SetVirtualItem(VIRTUAL_ITEM_SLOT_0, ranged);
}
}
if (!usingLoot)
{
if (cinfo->EquipmentTemplateId == 0)
LoadEquipment(normalInfo->EquipmentTemplateId, true); // use default from normal template if diff does not have any
else
LoadEquipment(cinfo->EquipmentTemplateId); // else use from diff template
}
}
else if (data)
{
Expand Down

0 comments on commit cda5f88

Please sign in to comment.