Here's a quick draft of one:
-- Change the age of a creature.
-- Author: Atomic Chicken
-- to do: set profession appropriately when making somebody grow up
local createUnit = reqscript('modtools/create-unit')
local utils = require 'utils'
local validArgs = utils.invert({
'unit',
'age'
})
local args = utils.processArgs({...}, validArgs)
if not args.age then
qerror("Age not specified!")
end
local unit = args.unit and df.unit.find(tonumber(args.unit)) or dfhack.gui.getSelectedUnit()
if not unit then
if args.unit then
qerror("Invalid unit ID: " .. tostring(args.unit))
else
qerror("You must either select the target creature prior to running this script, such as by viewing its description, or specify it via the -unit argument followed by its unit ID.")
end
end
if unit.profession == df.profession.BABY or unit.profession == df.profession.CHILD then
unit.profession = df.profession.STANDARD -- clear the Child/Baby profession in case we're making somebody grow up. Would be ideal to make the script set profession appropriately later on.
local hf = df.historical_figure.find(unit.hist_figure_id)
if hf then
hf.profession = df.profession.STANDARD
end
end
createUnit.setAge(unit, tonumber(args.age))
createUnit.induceBodyComputations(unit)
This was a fairly simple task as modtools/create-unit already has an age modifying function.
However, I threw it together on my phone and haven't had the opportunity to test it out yet, so don't be surprised if it shoots an error at you when you try to use it. Edit: now tested. I've also omitted a -help printout for now.
To use:
- Install
DFHack if you've not done so already.
- Copy-paste the above code into a text editor.
- Save it as a
.lua file within the
\hack\scripts folder.
- When playing, select the creature whose age you want to alter (in adventure mode, this is most easily done by viewing its description, but I've also made it possible to specify the target via its unit ID following a -unit argument as per convention) and enter [whatever it was that you named the file when saving it] as a command in the DFHack console followed by
-age and your desired age in years.
Example (with the unit selected):
set-unit-age -age 10
Alternatively, you could locate a child and use
bodyswap or
unretire-anyone to turn them into a player character.