Postado Outubro 18, 2019 5 anos @MatCollier Vai ficar assim. function Player:onGainExperience(source, exp, rawExp) if getPlayerStorageValue(cid, stor) >= 0 then local stor = 12345 -- storage -- Apply rarity chance to corpse contents find_loot_Container(corpse:getPosition()) -- Print loot list to Server Log if owner then local loot_msg = "Loot of " .. self:getNameDescription() .. ": " .. corpse:getContentDescription() if owner:getParty() then owner:getParty():broadcastLoot(loot_msg) owner:getParty():broadcastChannelLoot(loot_msg) else owner:sendTextMessage(MESSAGE_INFO_DESCR, loot_msg) -- Loot channel un-used on my server. -- owner:channelSay(nil, TALKTYPE_CHANNEL_O, loot_msg, 10) end end else local loot_msg = "Loot of " .. self:getNameDescription() .. ": nothing (due to low stamina)" if owner:getParty() then owner:getParty():broadcastLoot(loot_msg) owner:getParty():broadcastChannelLoot(loot_msg) else owner:sendTextMessage(MESSAGE_INFO_DESCR, loot_msg) end local corpse:decay() = corpse:decay() function MonsterType.createLootItem(self, lootBlock, modifier) local lootTable = {} local itemCount = 0 local randvalue = math.random(0, 100000) / (configManager.getNumber(configKeys.RATE_LOOT) * modifier); if randvalue < lootBlock.chance then if (ItemType(lootBlock.itemId):isStackable()) then itemCount = randvalue % lootBlock.maxCount + 1; else itemCount = 1; while (itemCount > 0) do local n = math.min(itemCount, 100) itemCount = itemCount - n local item = Game.createItem(lootBlock.itemId, n) if item then if lootBlock.subType ~= -1 then item:transform(lootBlock.itemId, lootBlock.subType) end if lootBlock.actionId ~= -1 then item:setActionId(lootBlock.actionId) end if lootBlock.text and lootBlock.text ~= "" then item:setAttribute(ITEM_ATTRIBUTE_TEXT, lootBlock.text) end table.insert(lootTable, item) end return #lootTable == 0 and nil or lootTable function MonsterType.createLootContainer(self, parent, lootBlock, modifier) if #lootBlock.childLoot == 0 then return true for _, v in pairs(lootBlock.childLoot) do if parent:getSize() < parent:getCapacity() then local itemList = self:createLootItem(v, modifier) if itemList then for _, item in ipairs(itemList) do if item:isContainer() then local lootContainer = self:createLootContainer(item, v, modifier) if lootContainer then parent:addItemEx(item) end else parent:addItem(item, 1) end end end end return #parent > 0 end return true end end end end end end end return exp end
Postado Outubro 18, 2019 5 anos Autor @underewarr Boa. Como eu devo modificar naquele randvalue pra ele aumentar a chance de loot em 5%? Exemplo: Se o monstro tem 10000 de chance de dropar um item, ele vai ter 10500 de chance de dropar esse mesmo item caso o player esteja com o colar.
Postado Outubro 18, 2019 5 anos Autor @underewarr No caso assim: math.random(0, 5000) Certo? Vou testar com ele em 100% primeiro pra ver.
Postado Outubro 18, 2019 5 anos 10000*10 = 100%@MatCollier local randvalue = math.random(0, 100000*10)
Participe da conversa
Você pode postar agora e se cadastrar mais tarde. Se você tem uma conta, faça o login para postar com sua conta.