Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: Hey so uh, kinda dumb question that I'm very sorry for asking  (Read 2324 times)

Gnomedevourer

  • Bay Watcher
    • View Profile

Like the title says it's dumb(ish) and sorry for having to ask but is there a script that I can use to turn people into kids? (Reason being is I wanted to make an adventurer that's a kid)
Logged
tried to balance a mod, once upon a time, fell and scraped my knee, ain't doing that again.

PatrikLundell

  • Bay Watcher
    • View Profile
Re: Hey so uh, kinda dumb question that I'm very sorry for asking
« Reply #1 on: June 19, 2021, 04:52:50 pm »

I doubt there's a dedicated script for it.
It ought to be possible to use gui/gm-editor on the unit and change the time of birth (although the age may take some time to adjust, based on some weird issue seen with migrant kids arriving with inconsistent info that corrects itself over time). Also, the history entry for the character may well state the time of birth being the original one.
In addition to that, you may or may not run into problems with trying to perform jobs that are reserved for adults.

And, being ignorant of the situation is not stupid: the stupid thing is not to seek out the information about it when that info would be relevant (or simply expect wishing will cause the reality to be bent).
Logged

Atomic Chicken

  • Bay Watcher
    • View Profile
Re: Hey so uh, kinda dumb question that I'm very sorry for asking
« Reply #2 on: June 20, 2021, 03:19:24 am »

Here's a quick draft of one:

Code: [Select]
-- 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):
Code: [Select]
set-unit-age -age 10
Alternatively, you could locate a child and use bodyswap or unretire-anyone to turn them into a player character.
« Last Edit: June 20, 2021, 10:06:54 am by Atomic Chicken »
Logged
As mentioned in the previous turn, the most exciting field of battle this year will be in the Arstotzkan capitol, with plenty of close-quarter fighting and siege warfare.  Arstotzka, accordingly, spent their design phase developing a high-altitude tactical bomber. 

Gnomedevourer

  • Bay Watcher
    • View Profile
Re: Hey so uh, kinda dumb question that I'm very sorry for asking
« Reply #3 on: June 20, 2021, 09:14:02 am »

Atomic chicken, it doesn't work sadly, buuut thanks for trying I'll probably just use the other methods (aka bodyswap and unretire-anyone)
Logged
tried to balance a mod, once upon a time, fell and scraped my knee, ain't doing that again.

Atomic Chicken

  • Bay Watcher
    • View Profile
Re: Hey so uh, kinda dumb question that I'm very sorry for asking
« Reply #4 on: June 20, 2021, 09:34:16 am »

Loaded a save to actually test it, with the result of spotting and fixing a small typo. It should work now, at least for your purposes (converting children into adults isn't fully supported yet; their profession needs to be set appropriately in place of the Child/Baby status, which the function in create-unit does not currently handle, so they'll initially be labelled as Peasants regardless of the skills they might possess).
« Last Edit: June 20, 2021, 10:05:21 am by Atomic Chicken »
Logged
As mentioned in the previous turn, the most exciting field of battle this year will be in the Arstotzkan capitol, with plenty of close-quarter fighting and siege warfare.  Arstotzka, accordingly, spent their design phase developing a high-altitude tactical bomber. 

Ziusudra

  • Bay Watcher
    • View Profile
Re: Hey so uh, kinda dumb question that I'm very sorry for asking
« Reply #5 on: June 20, 2021, 12:26:07 pm »

No need to be sorry for asking a question - and it's not a dumb question.

The thread title that does not give any information as to what the thread is actually about is a different story.
Logged
Ironblood didn't use an axe because he needed it. He used it to be kind. And right now he wasn't being kind.

Nopenope

  • Bay Watcher
    • View Profile
Re: Hey so uh, kinda dumb question that I'm very sorry for asking
« Reply #6 on: June 24, 2021, 04:44:28 am »

It kind of baits the reader into opening the thread and reading it, which given the current lethargic state of the forum is not at at all a bad idea. Of course it'd become annoying if the forum became active again and everyone did this, but it won't, and they won't.
Logged