Is there any way to leave the drop by percentage (%)?
we know that chance 1000 = 1% and 100000 = 100%. But it does not work.
I have already looked at the sources and I can not understand how the calculation works (monsters.cpp):
Could someone give me a hand?
we know that chance 1000 = 1% and 100000 = 100%. But it does not work.
I have already looked at the sources and I can not understand how the calculation works (monsters.cpp):
C++:
uint16_t Monsters::getLootRandom()
{
return (uint16_t)std::ceil((double)random_range(0, MAX_LOOTCHANCE) / g_config.getDouble(ConfigManager::RATE_LOOT));
}
C++:
ItemList MonsterType::createLoot(const LootBlock& lootBlock)
{
uint16_t item = lootBlock.ids[0], random = Monsters::getLootRandom(), count = 0;
if(lootBlock.ids.size() > 1)
item = lootBlock.ids[random_range((size_t)0, lootBlock.ids.size() - 1)];
ItemList items;
if(random < lootBlock.chance)
count = random % lootBlock.count + 1;
Item* tmpItem = NULL;
while(count > 0)
{
uint16_t n = 0;
if(Item::items[item].stackable)
n = std::min(count, (uint16_t)100);
if(!(tmpItem = Item::CreateItem(item, n)))
break;
count -= (!n ? 1 : n);
if(lootBlock.subType != -1)
tmpItem->setSubType(lootBlock.subType);
if(lootBlock.actionId != -1)
tmpItem->setActionId(lootBlock.actionId, false);
if(lootBlock.uniqueId != -1)
tmpItem->setUniqueId(lootBlock.uniqueId);
if(!lootBlock.text.empty())
tmpItem->setText(lootBlock.text);
items.push_back(tmpItem);
}
return items;
}
Could someone give me a hand?