Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: ensure loot over stack size drops in multiple stacks #1862

Merged
merged 5 commits into from
Nov 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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