It is now possible to remove syndromes by SYN_CLASS.

develop
expwnent 2014-11-14 23:33:49 -05:00
parent 5e3bf9a494
commit 59ef4e0cc2
3 changed files with 45 additions and 10 deletions

@ -13,6 +13,11 @@ DFHack Future
allows the user to add thoughts to creatures. allows the user to add thoughts to creatures.
devel/ devel/
all-bob.lua: renames everyone Bob to help test interaction-trigger all-bob.lua: renames everyone Bob to help test interaction-trigger
Misc improvements:
lua/syndrome-util.lua
now you can remove syndromes by SYN_CLASS
scripts/modtools/add-syndrome.lua
now you can remove syndromes by SYN_CLASS
DFHack 0.40.15-r1 DFHack 0.40.15-r1
Fixes: Fixes:

@ -45,6 +45,27 @@ function eraseSyndrome(unit,syndromeId,oldestFirst)
return false return false
end end
local function eraseSyndromeClassHelper(unit,synclass)
for i,unitSyndrome in ipairs(unit.syndromes.active) do
local syndrome = df.syndrome.find(unitSyndrome.type)
for _,class in ipairs(syndrome.syn_class) do
if class.value == synclass then
unit.syndromes.active:erase(i)
return true
end
end
end
return false
end
function eraseSyndromeClass(unit,synclass)
local count=0
while eraseSyndromeClassHelper(unit,synclass) do
count = count+1
end
return count
end
function eraseSyndromes(unit,syndromeId) function eraseSyndromes(unit,syndromeId)
local count=0 local count=0
while eraseSyndrome(unit,syndromeId,true) do while eraseSyndrome(unit,syndromeId,true) do

@ -13,7 +13,8 @@ validArgs = validArgs or utils.invert({
'eraseOldest', 'eraseOldest',
'eraseAll', 'eraseAll',
'target', 'target',
'skipImmunities' 'skipImmunities',
'eraseClass'
}) })
local args = utils.processArgs({...}, validArgs) local args = utils.processArgs({...}, validArgs)
@ -39,6 +40,8 @@ arguments:
instead of adding an instance of the syndrome, erase one instead of adding an instance of the syndrome, erase one
-eraseAll -eraseAll
erase every instance of the syndrome erase every instance of the syndrome
-eraseClass SYN_CLASS
erase every instance of every syndrome with the given SYN_CLASS
-target id -target id
the unit id of the target unit the unit id of the target unit
examples: examples:
@ -50,6 +53,21 @@ arguments:
return return
end end
if not args.target then
error 'Specify a target.'
end
local targ = df.unit.find(tonumber(args.target))
if not targ then
error ('Could not find target: ' .. args.target)
end
args.target = targ
if args.eraseClass then
local count = syndromeUtil.eraseSyndromeClass(args.target, args.eraseClass)
--print('deleted ' .. tostring(count) .. ' syndromes')
return
end
if args.resetPolicy then if args.resetPolicy then
args.resetPolicy = syndromeUtil.ResetPolicy[args.resetPolicy] args.resetPolicy = syndromeUtil.ResetPolicy[args.resetPolicy]
if not args.resetPolicy then if not args.resetPolicy then
@ -73,15 +91,6 @@ if not syndrome then
end end
args.syndrome = syndrome args.syndrome = syndrome
if not args.target then
error 'Specify a target.'
end
local targ = df.unit.find(tonumber(args.target))
if not targ then
error ('Could not find target: ' .. args.target)
end
args.target = targ
if args.erase then if args.erase then
syndromeUtil.eraseSyndrome(args.target,args.syndrome.id,args.eraseOldest) syndromeUtil.eraseSyndrome(args.target,args.syndrome.id,args.eraseOldest)
return return