Skip to content

Commit

Permalink
fix: ensure loot over stack size drops in multiple stacks (opentibiab…
Browse files Browse the repository at this point in the history
  • Loading branch information
dudantas authored Nov 21, 2023
1 parent cf1963a commit 24c702d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
16 changes: 12 additions & 4 deletions data/libs/functions/container.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,18 @@ function Container:addLoot(loot)
goto continue
end
if iType:isStackable() or iType:getCharges() ~= 0 then
local tmpItem = self:addItem(itemId, item.count, INDEX_WHEREEVER, FLAG_NOLIMIT)
if not tmpItem then
logger.warn("Container:addLoot: failed to add item: {}, to corpse {} with id {}", ItemType(itemId):getName(), self:getName(), self:getId())
goto continue
local stackSize = iType:getStackSize()
local remainingCount = item.count

while remainingCount > 0 do
local countToAdd = math.min(remainingCount, stackSize)
local tmpItem = self:addItem(itemId, countToAdd, INDEX_WHEREEVER, FLAG_NOLIMIT)
if not tmpItem then
logger.warn("Container:addLoot: failed to add stackable item: {}, to corpse {} with id {}", ItemType(itemId):getName(), self:getName(), self:getId())
goto continue
end

remainingCount = remainingCount - countToAdd
end
else
for i = 1, item.count do
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ function callback.monsterOnDropLoot(monster, corpse)

local wealthDuplex = Concoction.find(Concoction.Ids.WealthDuplex)
if not wealthDuplex then
logger.warn("[Monster:onDropLoot] - Could not find WealthDuplex concoction.")
logger.debug("[Monster:onDropLoot] - Could not find WealthDuplex concoction.")
return
end
local chance = 0
Expand Down

0 comments on commit 24c702d

Please sign in to comment.