the method (
Container.createLootItem(self, item)
) responsible for generating loot is here:
data/lib/core/container.lua
the event callback (
ec.onDropLoot
) responsible for dropping the loot is here:
data/scripts/eventcallbacks/monster/default_onDropLoot.lua
if you add third parameter (
player
) to
createLootItem
and pass it from
ec.onDropLoot
, you may use
player
object to obtain whatever you need to determine player's personal loot rate
final piece of code you have to adjust (container.lua)
change this:
Lua:
local itemCount = 0
local randvalue = getLootRandom()
if randvalue < item.chance then
if ItemType(item.itemId):isStackable() then
itemCount = randvalue % item.maxCount + 1
else
itemCount = 1
end
end
to this:
Lua:
local itemCount = 0
local randvalue = getLootRandom()
local personalLootRate = 1
if player then
-- personalLootRate = player storage or something idk
end
local lootChance = item.chance * personalLootRate
if randvalue < lootChance then
if ItemType(item.itemId):isStackable() then
itemCount = randvalue % item.maxCount + 1
else
itemCount = 1
end
end
if you don't have event callbacks, the function responsible for loot dropping and all necessary variables should be located in data/events/scripts/monster.lua
.