• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

TFS 0.X OTX 0.4 - Drop Rate

subyth

New Member
Joined
May 1, 2009
Messages
56
Reaction score
4
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):
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?
 

Similar threads

Back
Top