Bug report – negative resistance causes crash on game startup
When it happens:
The error occurs during game loading / startup phase (data stage), before entering a save.
Error message:
Failed to load mods: smart-enemy-ai/data/validate-variants.lua:40:
[smart-enemy-ai] validate-variants: small-cold-spitter-smart-resist-fire-1 —
resistance percent for 'fire' is -90; expected (0, 30]
stack traceback:
[C]: in function 'error'
smart-enemy-ai/data/validate-variants.lua:40: in function 'fail'
smart-enemy-ai/data/validate-variants.lua:99: in function 'check_one'
smart-enemy-ai/data/validate-variants.lua:108: in main chunk
[C]: in function 'require'
smart-enemy-ai/data-final-fixes.lua:14: in main chunk
Cause:
In data/resistance-variants.lua, variant generation increases existing resistance with:
existing.percent = existing.percent + level * 10
However, some base entities (e.g. small-cold-spitter) have negative fire resistance (vulnerability), e.g.:
-100
This results in:
-100 + 10 = -90
The validator then rejects it because it enforces:
0 < percent <= 30
Solution:
Clamp negative base resistance to 0 before applying scaling:
local base_percent = math.max(0, existing.percent or 0)
existing.percent = base_percent + level * 10
Result:
Level 1 → 10
Level 2 → 20
Level 3 → 30
This keeps values within validator bounds and avoids startup crash.
Note:
This report and fix suggestion were generated with GPT.