void getChestItems(CInstance* instance){ int instzone = instance->getZoneId(); uint8 maxloot = 0; LootList_t* LootList = itemutils::GetLootList(instance->getLootId()); if (LootList == NULL){ ShowError("BCNM Chest opened with no valid loot list!"); //no loot available for bcnm. End bcnm. instance->winBcnm(); return; } else { for (uint8 sizeoflist=0; sizeoflist < LootList->size() ; ++sizeoflist){ if(LootList->at(sizeoflist).LootGroupId > maxloot){ maxloot= LootList->at(sizeoflist).LootGroupId; } } } //getMaxLootGroups(instance); if(maxloot!=0){ for (uint8 group = 0; group <= maxloot; ++group){ uint16 maxRolls = getRollsPerGroup(instance,group); uint16 groupRoll = (uint16)(WELL512::irand()%maxRolls); uint16 itemRolls = 0; for (uint8 item = 0; item < LootList->size(); ++item) { if (group == LootList->at(item).LootGroupId) { itemRolls += LootList->at(item).Rolls; if (groupRoll <= itemRolls) { instance->m_PlayerList.at(0)->PTreasurePool->AddItemFromChest(LootList->at(item).ItemID, instance->m_NpcList.at(0)); break; } } } } } //user opened chest, complete bcnm if(instzone!=37 && instzone!=38 ){ instance->winBcnm(); } else{ instance->m_NpcList.clear(); } }
void getChestItems(CBattlefield* battlefield) { int instzone = battlefield->getZoneId(); uint8 maxloot = 0; LootList_t* LootList = itemutils::GetLootList(battlefield->getLootId()); if (LootList == nullptr) { ShowError("BCNM Chest opened with no valid loot list!"); //no loot available for bcnm. End bcnm. battlefield->winBcnm(); return; } else { for (uint8 sizeoflist = 0; sizeoflist < LootList->size(); ++sizeoflist) { if (LootList->at(sizeoflist).LootGroupId > maxloot) { maxloot = LootList->at(sizeoflist).LootGroupId; } } } //getMaxLootGroups(battlefield); if (maxloot != 0) { for (uint8 group = 0; group <= maxloot; ++group) { uint16 maxRolls = getRollsPerGroup(battlefield, group); uint16 groupRoll = dsprand::GetRandomNumber(maxRolls); uint16 itemRolls = 0; for (uint8 item = 0; item < LootList->size(); ++item) { if (group == LootList->at(item).LootGroupId) { itemRolls += LootList->at(item).Rolls; if (groupRoll <= itemRolls) { battlefield->m_PlayerList.at(0)->PTreasurePool->AddItem(LootList->at(item).ItemID, battlefield->m_NpcList.at(0)); break; } } } } } //user opened chest, complete bcnm if (instzone != 37 && instzone != 38) { battlefield->winBcnm(); } else { battlefield->m_NpcList.clear(); } }