NPC Pregnancy
Estimated reading time: 9 minutesNPC pregnancy support is a bridge into the vanilla pregnancy system. It does not turn one species into another.
The system is bidirectional:
- An NPC can impregnate the PC.
- The PC can impregnate an NPC.
The same pregnancy type and generator are used for both directions.
Type And NPC Layers
Pregnancy registration has two layers:
maplebirch.npc.addPregnancy(type, config)registers a pregnancy type. A type owns the generator, ETA, default birth locations, child config, baby wording, and transformation data.maplebirch.npc.Pregnancy.addNpc(npcName, type, config)registers a single NPC. An NPC entry decides whether that character joins the pregnancy system, which pregnancy type it uses, whether it can be pregnant or impregnate the PC, and whether it overrides cycle or birth behavior.
The two layers are separate. Multiple NPCs can use the same pregnancy type, and an NPC can use a pregnancy type different from its normal npc.type.
NPC Data
Set pregnancy.enabled on NPCs that should join the pregnancy system. Set pregnancy.type to the pregnancy species used by sperm records and pregnancy generation.
Add Type
Custom pregnancy types are registered in script. Adding a type only lets the framework keep that type in pregnancy filters. It does not create pregnancy data by itself.
Full Registration
A custom type needs at least a generator. Other callbacks are optional, but they make remaining-day display, child activity, and baby wording work cleanly.
Per-NPC Config
Use maplebirch.npc.Pregnancy.addNpc() when a vanilla or custom NPC should join the pregnancy system.
If the NPC already has pregnancy.type, you can pass only config:
You can also place per-NPC data inside a type registration:
Config Fields
Callback Parameters
generator(mother, father, fatherKnown, genital)
mother === 'pc' means an NPC made the PC pregnant. father === 'pc' means the PC made an NPC pregnant.
The returned object must contain a non-empty fetus array. If it should progress into vanilla birth and child systems, keep the structure close to vanilla pregnancy objects.
eta(pregnancy)
Return remaining days, or null when no clean display is available.
birth
birth can be a plain object:
It can also be a resolver:
The registered data is read with maplebirch.npc.Pregnancy.birthLocation(type, pregnancy, npcName). The framework resolves NPC-level data first, then type-level data, then falls back to unknown.
childActivity(childId, child)
child.activity is the preferred location for this callback. The old top-level childActivity field still works when only activity needs to be registered.
Return a string to write child.localVariables.activity. Return null, false, or undefined to mark the callback handled without changing activity.
child.defaults
child.defaults runs after vanilla <<endNpcPregnancy>> has created V.children[childId]. It can be an object merged into the child, or a resolver:
Use this for custom child fields that should exist only after birth. Fields required during pregnancy should still be created by the generator inside each fetus object.
child.transform
child.transform supports vanilla child transformation fields and framework-added transformation data. Vanilla stores these values under child.features, so the framework writes them after birth.
The common form is a string:
This writes child.features.maplebirchTransform = 'plant'.
transform can also be a function with the same parameters as child.defaults when the result depends on parents, location, or NPC.
text(pregnancy, count, target)
Child-Only Registration
Use maplebirch.npc.Pregnancy.addChild() when the generator is registered elsewhere and you only need child fields, transformation data, activity, or wording:
Runtime Flow
ELK not loaded. Ensure /elk.bundled.js is loaded before the app.
Runtime Touch Points
npcPregnancyCycle() is a closure function inside vanilla time.js / pregnancy.js, so the framework does not call the original function. Instead, the time.js call site is patched to call the framework cycle. giveBirthToChildren() stays inside vanilla and is reached through the original <<endNpcPregnancy>> macro.
Vanilla Route
Vanilla species and special NPC behavior are represented as default data inside the framework. Custom mods use the same type-level and NPC-level configuration path instead of adding new hardcoded branches.
