From ab7dc7654b5c53aff0bc8821b69531544e4f1d76 Mon Sep 17 00:00:00 2001 From: Kelly Kinkade Date: Wed, 6 Aug 2025 18:18:22 -0500 Subject: [PATCH] prevent `make-legendary` from assigning skill -1 fixes DFHack/dfhack#5541 --- changelog.txt | 1 + make-legendary.lua | 12 ++++++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/changelog.txt b/changelog.txt index 8b79bd7b2d..c6324adf87 100644 --- a/changelog.txt +++ b/changelog.txt @@ -31,6 +31,7 @@ Template for new versions: ## New Features ## Fixes +- `make-legendary`: ``make-legendary all`` will no longer corrupt souls ## Misc Improvements diff --git a/make-legendary.lua b/make-legendary.lua index 2098ad0ba2..a0c96c0cb2 100644 --- a/make-legendary.lua +++ b/make-legendary.lua @@ -7,9 +7,11 @@ function getName(unit) end function legendize(unit, skill_idx) - utils.insert_or_update(unit.status.current_soul.skills, - {new=true, id=skill_idx, rating=df.skill_rating.Legendary5}, - 'id') + if skill_idx >= 0 and skill_idx <= df.job_skill._last_item then + utils.insert_or_update(unit.status.current_soul.skills, + {new=true, id=skill_idx, rating=df.skill_rating.Legendary5}, + 'id') + end end function make_legendary(skillname) @@ -50,7 +52,9 @@ function BreathOfArmok() return end for i in ipairs(df.job_skill) do - legendize(unit, i) + if i >= 0 then + legendize(unit, i) + end end print('The breath of Armok has engulfed ' .. getName(unit)) end