void WorldSession::HandleAutostoreLootItemOpcode(WorldPacket& recv_data)
{
    uint8 itemSlot;
    recv_data >> itemSlot;

    DEBUG_LOG("WORLD: CMSG_AUTOSTORE_LOOT_ITEM > requesting item in slot %u", uint32(itemSlot));

    Loot* loot = sLootMgr.GetLoot(_player);

    if (!loot)
    {
        sLog.outError("HandleAutostoreLootItemOpcode> Cannot retrieve loot for player %s", _player->GetGuidStr().c_str());
        return;
    }

    ObjectGuid const& lguid = loot->GetLootGuid();

    LootItem* lootItem = loot->GetLootItemInSlot(itemSlot);

    if (!lootItem)
    {
        _player->SendEquipError(EQUIP_ERR_ITEM_NOT_FOUND, nullptr, nullptr);
        return;
    }

    // item may be blocked by roll system or already looted or another cheating possibility
    if (lootItem->isBlocked || lootItem->GetSlotTypeForSharedLoot(_player, loot) == MAX_LOOT_SLOT_TYPE)
    {
        sLog.outError("HandleAutostoreLootItemOpcode> %s have no right to loot itemId(%u)", _player->GetGuidStr().c_str(), lootItem->itemId);
        return;
    }

    InventoryResult result = loot->SendItem(_player, lootItem);

    if (result == EQUIP_ERR_OK && lguid.IsItem())
    {
        if (Item* item = _player->GetItemByGuid(lguid))
            item->SetLootState(ITEM_LOOT_CHANGED);
    }

    if (result == EQUIP_ERR_OK)
    {
        if (sRaidStatsMgr.IsTrackingEnabled(RaidStatsEvent::LOOT_PICK, (Unit*)_player, (Unit*)_player) || (loot->GetLootTarget() && loot->GetLootTarget()->GetObjectGuid().IsCreature() && ((Creature*)loot->GetLootTarget())->GetCreatureInfo()->Rank == 3))
        {
            const ItemPrototype* itemProto = ObjectMgr::GetItemPrototype(lootItem->itemId);
            if (itemProto->Quality >= ITEM_QUALITY_RARE || itemProto->Class == ITEM_CLASS_QUEST)
            {
                RaidStatsData raiddata(RaidStatsEvent::LOOT_PICK, _player->GetMap()->GetInstanceId(), _player->GetZoneId());
                raiddata.lootpickup.item = lootItem->itemId;
                raiddata.lootpickup.looter = _player->GetObjectGuid().GetCounter();
                raiddata.lootpickup.source = loot->GetLootTarget()->GetObjectGuid().GetCounter();
                raiddata.lootpickup.sourceType = (uint32)sRaidStatsMgr.GetRaidStatsType(loot->GetLootTarget()->GetObjectGuid());
                sRaidStatsMgr.AddRaidEvent(raiddata);
            }
        }
    }
}
Beispiel #2
0
void WorldSession::HandleAutostoreLootItemOpcode(WorldPacket& recv_data)
{
    uint8 itemSlot;
    recv_data >> itemSlot;

    DEBUG_LOG("WORLD: CMSG_AUTOSTORE_LOOT_ITEM > requesting item in slot %u", uint32(itemSlot));

    Loot* loot = sLootMgr.GetLoot(_player);

    if (!loot)
    {
        sLog.outError("HandleAutostoreLootItemOpcode> Cannot retrieve loot for player %s", _player->GetGuidStr().c_str());
        return;
    }

    ObjectGuid const& lguid = loot->GetLootGuid();

    LootItem* lootItem = loot->GetLootItemInSlot(itemSlot);

    if (!lootItem)
    {
        _player->SendEquipError(EQUIP_ERR_ITEM_NOT_FOUND, nullptr, nullptr);
        return;
    }

    // item may be blocked by roll system or already looted or another cheating possibility
    if (lootItem->isBlocked || lootItem->GetSlotTypeForSharedLoot(_player, loot) == MAX_LOOT_SLOT_TYPE)
    {
        sLog.outError("HandleAutostoreLootItemOpcode> %s have no right to loot itemId(%u)", _player->GetGuidStr().c_str(), lootItem->itemId);
        return;
    }

    if (loot->GetLootType() == LOOTITEM_TYPE_CURRENCY)
    {
        if (CurrencyTypesEntry const* currencyEntry = sCurrencyTypesStore.LookupEntry(lootItem->itemId))
            _player->ModifyCurrencyCount(lootItem->itemId, int32(lootItem->count * currencyEntry->GetPrecision()));

        loot->NotifyItemRemoved(itemSlot, true);
        // ToDo: fix this!
        // --loot->maxSlot;
        return;
    }

    InventoryResult result = loot->SendItem(_player, lootItem);

    if (result == EQUIP_ERR_OK && lguid.IsItem())
    {
        if (Item* item = _player->GetItemByGuid(lguid))
            item->SetLootState(ITEM_LOOT_CHANGED);
    }
}
Beispiel #3
0
void WorldSession::HandleAutostoreLootItemOpcode(WorldPacket& recv_data)
{
    uint8 itemSlot;
    recv_data >> itemSlot;

    DEBUG_LOG("WORLD: CMSG_AUTOSTORE_LOOT_ITEM > requesting item in slot %u", uint32(itemSlot));

    Loot* loot = sLootMgr.GetLoot(_player);

    if (!loot)
    {
        sLog.outError("HandleAutostoreLootItemOpcode> Cannot retrieve loot for player %s", _player->GetGuidStr().c_str());
        return;
    }

    ObjectGuid const& lguid = loot->GetLootGuid();

    LootItem* lootItem = loot->GetLootItemInSlot(itemSlot);

    if (!lootItem)
    {
        _player->SendEquipError(EQUIP_ERR_ITEM_NOT_FOUND, nullptr, nullptr);
        return;
    }

    // item may be blocked by roll system or already looted or another cheating possibility
    if (lootItem->isBlocked || lootItem->GetSlotTypeForSharedLoot(_player, loot) == MAX_LOOT_SLOT_TYPE)
    {
        sLog.outError("HandleAutostoreLootItemOpcode> %s have no right to loot itemId(%u)", _player->GetGuidStr().c_str(), lootItem->itemId);
        return;
    }

    InventoryResult result = loot->SendItem(_player, lootItem);

    if (result == EQUIP_ERR_OK && lguid.IsItem())
    {
        if (Item* item = _player->GetItemByGuid(lguid))
            item->SetLootState(ITEM_LOOT_CHANGED);
    }
}