Skip to content

Commit cdf3ebb

Browse files
committed
Fix uniform assignment state inconsistency caused by uniform-unstick
1 parent 61e0e18 commit cdf3ebb

2 files changed

Lines changed: 17 additions & 0 deletions

File tree

changelog.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ Template for new versions:
3131
## New Features
3232

3333
## Fixes
34+
- `uniform-unstick`: no longer causes units to equip multiples of assigned items
3435

3536
## Misc Improvements
3637

uniform-unstick.lua

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,22 @@ local function process(unit, args, need_newline)
196196
end
197197
end
198198

199+
-- Make the equipment.assigned_items list consistent with what is present in equipment.uniform
200+
for i=#(squad_position.equipment.assigned_items)-1,0,-1 do
201+
local u_id = squad_position.equipment.assigned_items[i]
202+
-- Quiver, backpack, and flask are assigned in their own locations rather than in equipment.uniform, and thus need their own checks
203+
-- If more separately-assigned items are added in the future, this handling will need to be updated accordingly
204+
if assigned_items[u_id] == nil and u_id ~= squad_position.equipment.quiver and u_id ~= squad_position.equipment.backpack and u_id ~= squad_position.equipment.flask then
205+
local item = df.item.find(u_id)
206+
if item ~= nil then
207+
need_newline = print_line(unit_name .. " has an improperly assigned item, item # " .. u_id .. " '" .. item_description(item) .. "'; removing it")
208+
else
209+
need_newline = print_line(unit_name .. " has a nonexistent item assigned, item # " .. u_id .. "; removing it")
210+
end
211+
squad_position.equipment.assigned_items:erase(i)
212+
end
213+
end
214+
199215
-- Figure out which worn items should be dropped
200216

201217
-- First, figure out which body parts are covered by the uniform pieces we have.

0 commit comments

Comments
 (0)