How make adding syndrome of regeneration and body parts regrowing for blizzard men from any contact with water? Water is hardcoded, so standard way of adding syndromes is not our way. Adding new material will not work too, I need regeneration from rain, rivers and snow.
This was fairly straightforward, so I went ahead and wrote a script for adding syndromes to inbuilt materials:
-- Add a syndrome to an inbuilt material.
-- Author: Atomic Chicken
local utils = require 'utils'
local validArgs = utils.invert({
'material',
'syndrome',
})
local args = utils.processArgs({...}, validArgs)
if not args.material then
qerror('Material not specified!')
end
if not args.syndrome then
qerror('Syndrome not specified!')
end
addedSynMats = addedSynMats or {}
local matInfo = dfhack.matinfo.find(args.material)
if not matInfo then
qerror('Material not found: ' .. args.material)
end
if matInfo.mode ~= 'builtin' then
qerror('This script should only be used with inbuilt materials.')
end
local material = matInfo.material
local foundSyn = false
for _, syndrome in ipairs(df.global.world.raws.syndromes.all) do
if syndrome.syn_name == args.syndrome then
material.syndrome:insert('#', syndrome)
if syndrome.flags.SYN_INJECTED then
material.flags.ENTER_BLOOD = true -- reverses on reload
end
if not addedSynMats[args.material] then
addedSynMats[args.material] = true
end
foundSyn = true
break
end
end
if not foundSyn then
qerror('Syndrome not found: ' .. args.syndrome)
end
-- Clear added syndromes when unloading; prevents crashes when reloading
dfhack.onStateChange.InbuiltMatSynMonitor = function(event)
if event == SC_WORLD_UNLOADED then
for k,_ in pairs(addedSynMats) do
local material = dfhack.matinfo.find(k).material
material.syndrome:resize(0)
addedSynMats[k] = nil
end
end
end
It worked as expected when I tested it (which is to say that I managed to transform my adventurer into a cat by jumping into a river), but I can't guarantee that it won't cause problems, so use with caution. I might add a -help printout and make it possible to specify multiple syndromes simultaneously at a later stage if no problems crop up.
To use, paste the code into a text editor and save it as a
.lua file (such as
inbuilt-material-syndrome.lua) in
\hack\scripts. You can then run it either manually from the console after loading the a save, or place the command in
onLoad.init in
\raw to have it run automatically when a world is loaded (create this file if it doesn't exist already). Call as follows:
inbuilt-material-syndrome -material WATER -syndrome YOUR_SYN_NAME
Other
inbuilt materials, such as "VOMIT", may also be specified. The syndrome needs to have been defined elsewhere.