Rondel
Active Member
- Joined
- Feb 1, 2022
- Messages
- 15
- Reaction score
- 38
Hey there!
Balancing loot is quite a tedious task - it's easy to make mistakes and accidentally add an extra zero somewhere. It's always helpful to see how things actually look in-game, so to make life a bit easier for everyone, I've made this module. After following the installation steps, you'll need to populate the monsters array with all the monsters from your /monsters folder aswell as the items.lua file from game_lootsimulator folder with all the values.
Show-off




How to install
1. Server
1.1. Add to -> /lib/core/container.lua
1.2. Add to -> /global.lua
1.3. Add to -> /data/scripts -> lootSimulator.lua file from the folder.
2. Client
2.1. Add to -> /modules -> the game_lootsimulator folder.
To open the simulator window press 'CTRL + S'
I do believe that's all but I might have forgotten about something so if anything is missing, let me know. Enjoy ;3
Balancing loot is quite a tedious task - it's easy to make mistakes and accidentally add an extra zero somewhere. It's always helpful to see how things actually look in-game, so to make life a bit easier for everyone, I've made this module. After following the installation steps, you'll need to populate the monsters array with all the monsters from your /monsters folder aswell as the items.lua file from game_lootsimulator folder with all the values.
Show-off




How to install
1. Server
1.1. Add to -> /lib/core/container.lua
LUA:
function Container.createSimulationLootItem(self, item, rateLoot)
if self:getEmptySlots() == 0 then
return true
end
local itemCount = 0
local randvalue = getLootSimulationRandom(rateLoot)
local itemType = ItemType(item.itemId)
if randvalue < item.chance then
if itemType:isStackable() then
itemCount = randvalue % item.maxCount + 1
else
itemCount = 1
end
end
while itemCount > 0 do
local count = math.min(100, itemCount)
local subType = count
if itemType:isFluidContainer() then
subType = math.max(0, item.subType)
end
local tmpItem = Game.createItem(item.itemId, subType)
if not tmpItem then
return false
end
if tmpItem:isContainer() then
for i = 1, #item.childLoot do
if not tmpItem:createSimulationLootItem(item.childLoot[i], rateLoot) then
tmpItem:remove()
return false
end
end
if #item.childLoot > 0 and tmpItem:getSize() == 0 then
tmpItem:remove()
return true
end
end
if item.subType ~= -1 then
tmpItem:setAttribute(ITEM_ATTRIBUTE_CHARGES, item.subType)
end
if item.actionId ~= -1 then
tmpItem:setActionId(item.actionId)
end
if item.text and item.text ~= "" then
tmpItem:setText(item.text)
end
local ret = self:addItemEx(tmpItem)
if ret ~= RETURNVALUE_NOERROR then
tmpItem:remove()
end
itemCount = itemCount - count
end
return true
end
Code:
function getLootSimulationRandom(rateLoot)
return math.random(0, MAX_LOOTCHANCE) / rateLoot
end
2. Client
2.1. Add to -> /modules -> the game_lootsimulator folder.
To open the simulator window press 'CTRL + S'
I do believe that's all but I might have forgotten about something so if anything is missing, let me know. Enjoy ;3
Attachments
-
lootsimulator.zip9.2 KB · Views: 165 · VirusTotal
Last edited: