Added catches for quest and money loot
This commit is contained in:
parent
4886019ca0
commit
ff4d63ef39
@ -25,11 +25,17 @@ namespace
|
||||
uint32 sRequiredEquipId = 0;
|
||||
std::vector<uint32> sBobberEntries;
|
||||
|
||||
struct GuidHash { std::size_t operator()(ObjectGuid const& g) const noexcept { return std::hash<uint64>()(g.GetRawValue()); } };
|
||||
struct GuidHash
|
||||
{
|
||||
std::size_t operator()(ObjectGuid const &g) const noexcept { return std::hash<uint64>()(g.GetRawValue()); }
|
||||
};
|
||||
|
||||
std::unordered_map<ObjectGuid, uint32, GuidHash> sRecastTimers;
|
||||
|
||||
struct PendingLoot { uint32 timer; };
|
||||
struct PendingLoot
|
||||
{
|
||||
uint32 timer;
|
||||
};
|
||||
std::unordered_map<ObjectGuid, PendingLoot, GuidHash> sLootTimers;
|
||||
|
||||
std::vector<uint32> ParseEntryList(std::string const &csv)
|
||||
@ -49,7 +55,8 @@ namespace
|
||||
|
||||
bool HasEquippedItem(Player *plr, uint32 entry)
|
||||
{
|
||||
if (!entry) return true;
|
||||
if (!entry)
|
||||
return true;
|
||||
for (uint8 slot = EQUIPMENT_SLOT_START; slot < EQUIPMENT_SLOT_END; ++slot)
|
||||
{
|
||||
if (Item *it = plr->GetItemByPos(INVENTORY_SLOT_BAG_0, slot))
|
||||
@ -61,7 +68,8 @@ namespace
|
||||
|
||||
bool RequirementMet(Player *plr)
|
||||
{
|
||||
if (!plr) return false;
|
||||
if (!plr)
|
||||
return false;
|
||||
if (sRequiredItemId && !plr->HasItemCount(sRequiredItemId, 1, false))
|
||||
return false;
|
||||
if (sRequiredEquipId && !HasEquippedItem(plr, sRequiredEquipId))
|
||||
@ -122,14 +130,40 @@ namespace
|
||||
if (GameObject *lootGo = ObjectAccessor::GetGameObject(*plr, lootGuid))
|
||||
{
|
||||
Loot *loot = &lootGo->loot;
|
||||
for (uint32 i = 0; i < loot->items.size(); ++i)
|
||||
|
||||
// 1) Normal items
|
||||
for (uint32 slot = 0; slot < loot->items.size(); ++slot)
|
||||
{
|
||||
if (loot->items[i].is_looted)
|
||||
LootItem &li = loot->items[slot];
|
||||
if (li.is_looted)
|
||||
continue;
|
||||
|
||||
InventoryResult msg = EQUIP_ERR_OK;
|
||||
plr->StoreLootItem(uint8(i), loot, msg);
|
||||
plr->StoreLootItem(uint8(slot), loot, msg);
|
||||
|
||||
if (!loot->quest_items.empty())
|
||||
{
|
||||
uint32 baseSlot = loot->items.size();
|
||||
for (uint32 q = 0; q < loot->quest_items.size(); ++q)
|
||||
{
|
||||
QuestItem &qi = loot->quest_items[q];
|
||||
if (qi.is_looted)
|
||||
continue;
|
||||
|
||||
uint8 slot = uint8(baseSlot + q);
|
||||
InventoryResult msg = EQUIP_ERR_OK;
|
||||
plr->StoreLootItem(slot, loot, msg);
|
||||
}
|
||||
}
|
||||
|
||||
if (loot->gold > 0)
|
||||
{
|
||||
plr->ModifyMoney(loot->gold);
|
||||
loot->gold = 0;
|
||||
}
|
||||
|
||||
plr->SendLootRelease(lootGuid);
|
||||
|
||||
if (lootGo->GetGoType() == GAMEOBJECT_TYPE_FISHINGNODE)
|
||||
lootGo->SetLootState(GO_JUST_DEACTIVATED);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user