RimWorld

RimWorld

Toddlers
 This topic has been pinned, so it's probably important
cyanobot  [developer] 27 Sep, 2024 @ 8:58am
Take Baby To Safety
The code that governs “taking baby to safety” – both by player order and spontaneous – has been rewritten more or less from scratch. Hopefully this will eliminate all of the previous peculiar errors. I’m sure it will introduce some new ones, but the code is a lot cleaner and more logical now, so it should be easier to bugfix going forwards.

I’ve tested extensively in a simple test environment, but not yet in actual gameplay. Since the old code is so buggy, I figured I’d release now and hopefully it’s better than the old version even if it’s not perfect yet.

The new code uses vanilla functions as much as possible, which ought to improve compatibility. I haven’t spotted any weird bugs using Tacticowl, Pathfinding Framework, or Locks (mods that caused issues with the previous code). Celsius still behaves weirdly because Toddlers has difficulty working out where a safe temperature might be found, but a patch is on my to do list.

You may see one-off errors on loading save games if the pawns were in the process of doing one the old take-to-safety jobs when the game was saved. Hopefully these shouldn’t cause any ongoing problems.

Here’s how the new code is supposed to behave:

Forced baby moving:
  • The float menu (right-click dropdown menu) ought to always display at least one option to rescue the baby, return to safety or return to their crib
  • If there is nowhere to move the baby to, a greyed out option will show
  • If “move to safety” would take the baby to somewhere other than their crib, a “take to crib” option should also be shown

Spontaneous baby moving:
  • Moving a downed baby (ie pre-toddler infant, injured toddler, etc) counts as a Rescue job, so it will be performed regardless of Childcare settings and at the same priority as other Rescue jobs (default is as Doctor work I believe, but other mods may change this)
  • Moving a mobile toddler should respect Feeding settings (set per baby in the Feeding tab). Urgent : high priority, above work/meeting needs. Childcare : priority set by Childcare work type. Never : never.
  • Babies will not be returned to safety if:
    • another pawn is interacting with the baby
    • the baby is being taken on a caravan or attending a ceremony
    • the toddler is drafted
    • the toddler is eating because they’re starving

Reasons an adult will move a baby:
  • Baby needs medical rest
  • Downed baby (pre-toddler infants and ie injured toddlers) out of bed
  • Baby outside allowed zone
  • Baby is in an area with unsafe temperature
  • Baby should be in bed to sleep (only if relevant settings enabled)

If a high priority problem can’t be solved (ie there are no beds for medical rest), adults will still try to resolve lower priority problems.

Medical rest:
  • Medical beds will be prioritised, just like with any other pawn needing medical rest. Non-medical beds will be used if no medical beds are available.
  • Taking a downed pawn to bed ignores that pawn’s allowed areas. (This is also true for adults.)
  • If the baby has hypothermia/heatstroke at “minor” severity or worse, they won’t be taken to beds that are at an unsafe temperature. If the severity is “serious” or worse, they will be removed from unsafe beds to be taken somewhere safe, if possible.
  • When medical beds are rejected for temperature reasons, pawns will look for a non-medical bed as a backup to put the baby in, in preference to leaving them on the floor.

Allowed zones:
  • Taking a downed pawn to bed ignores that pawn’s zone. (This is also true for adults.) This means that allowed zones are only relevant for infants (pre-toddler) if they don’t have a bed to be returned to.
  • Toddlers ought to respect their own allowed zones. (Not realistic, perhaps, but gameplay wins out.) Note that they may not be able to get back to their allowed zone if they’re too young to use doors.
  • Allowed zone takes priority over safe temperature, until the hypothermia/heatstroke/ gets bad enough for the baby to need medical rest.
  • Adults should consider both their own allowed zone and the baby’s when deciding where to put them.

Unsafe temperature:
  • Adults will try to keep babies in areas that are safe for them. They will not try to remove babies from areas that are safe but merely uncomfortable.
  • Allowed zones take priority over safe temperature. See also medical rest section above.
  • When deciding where to move a baby to, comfortable temperatures will be prioritised over uncomfortable.

Bedtime:
  • Two settings (same as before) control whether adult pawns care about A) toddlers sleeping on the floor and B) toddlers being out of bed during hours scheduled for Sleep.
  • Toddlers will only be returned to bed for these reasons if the bed is at a safe temperature.
Last edited by cyanobot; 27 Sep, 2024 @ 9:01am
< >
Showing 1-2 of 2 comments
Wolmer 29 Sep, 2024 @ 7:47am 
Can't post a file here but here is what the log shows:

Therosia started 10 jobs in one tick. newJob=BringBabyToSafetyUnforced (Job_99485080) A = Thing_Human3120741 jobGiver=RimWorld.JobGiver_Work jobList=(BringBabyToSafetyUnforced (Job_99485060) A = Thing_Human3120741) (BringBabyToSafetyUnforced (Job_99485062) A = Thing_Human3120741) (BringBabyToSafetyUnforced (Job_99485064) A = Thing_Human3120741) (BringBabyToSafetyUnforced (Job_99485066) A = Thing_Human3120741) (BringBabyToSafetyUnforced (Job_99485068) A = Thing_Human3120741) (BringBabyToSafetyUnforced (Job_99485070) A = Thing_Human3120741) (BringBabyToSafetyUnforced (Job_99485072) A = Thing_Human3120741) (BringBabyToSafetyUnforced (Job_99485074) A = Thing_Human3120741) (BringBabyToSafetyUnforced (Job_99485076) A = Thing_Human3120741) (BringBabyToSafetyUnforced (Job_99485078) A = Thing_Human3120741) (BringBabyToSafetyUnforced (Job_99485080) A = Thing_Human3120741)
(Filename: C:\buildslave\unity\build\Runtime/Export/Debug/Debug.bindings.h Line: 39)

Anastasia started 10 jobs in one tick. newJob=BringBabyToSafetyUnforced (Job_99485104) A = Thing_Human3120741 jobGiver=RimWorld.JobGiver_Work jobList=(BringBabyToSafetyUnforced (Job_99485084) A = Thing_Human3120741) (BringBabyToSafetyUnforced (Job_99485086) A = Thing_Human3120741) (BringBabyToSafetyUnforced (Job_99485088) A = Thing_Human3120741) (BringBabyToSafetyUnforced (Job_99485090) A = Thing_Human3120741) (BringBabyToSafetyUnforced (Job_99485092) A = Thing_Human3120741) (BringBabyToSafetyUnforced (Job_99485094) A = Thing_Human3120741) (BringBabyToSafetyUnforced (Job_99485096) A = Thing_Human3120741) (BringBabyToSafetyUnforced (Job_99485098) A = Thing_Human3120741) (BringBabyToSafetyUnforced (Job_99485100) A = Thing_Human3120741) (BringBabyToSafetyUnforced (Job_99485102) A = Thing_Human3120741) (BringBabyToSafetyUnforced (Job_99485104) A = Thing_Human3120741)
(Filename: C:\buildslave\unity\build\Runtime/Export/Debug/Debug.bindings.h Line: 39)

Romamepla started 10 jobs in one tick. newJob=BringBabyToSafetyUnforced (Job_99485128) A = Thing_Human3120741 jobGiver=RimWorld.JobGiver_Work jobList=(BringBabyToSafetyUnforced (Job_99485108) A = Thing_Human3120741) (BringBabyToSafetyUnforced (Job_99485110) A = Thing_Human3120741) (BringBabyToSafetyUnforced (Job_99485112) A = Thing_Human3120741) (BringBabyToSafetyUnforced (Job_99485114) A = Thing_Human3120741) (BringBabyToSafetyUnforced (Job_99485116) A = Thing_Human3120741) (BringBabyToSafetyUnforced (Job_99485118) A = Thing_Human3120741) (BringBabyToSafetyUnforced (Job_99485120) A = Thing_Human3120741) (BringBabyToSafetyUnforced (Job_99485122) A = Thing_Human3120741) (BringBabyToSafetyUnforced (Job_99485124) A = Thing_Human3120741) (BringBabyToSafetyUnforced (Job_99485126) A = Thing_Human3120741) (BringBabyToSafetyUnforced (Job_99485128) A = Thing_Human3120741)
(Filename: C:\buildslave\unity\build\Runtime/Export/Debug/Debug.bindings.h Line: 39)

(It spams those things a lot every time you open the dev mod)
cyanobot  [developer] 29 Sep, 2024 @ 9:36am 
@Wolmer
That sure is a problem and unfortunately not one that gives me a lot of feedback to figure out where the problem is.

Can you please go into the debug actions menu (from the icons that show across the top of the screen when you have dev mode turned on) and use "T: Toggle Job Logging" and then click on Romamepla (or another adult having the same problem) while the problem is happening. Then show me the extra log information generated with that turned on.

If that still doesn't get enough info for me to pin down the problem, then next time I have time to work on this I'll push an option to turn on my own debug logging and that should definitely let me find the problem.
< >
Showing 1-2 of 2 comments
Per page: 1530 50