NPC Registration

Estimated reading time: 6 minutes

Overview

The NPC system allows mod authors to add custom non-player characters (NPCs) to the game. You can define appearance, personality, relationship state, schedule, and special abilities.

Register mod NPCs via maplebirch.npc.add or maplebirchFrameworks.addNPC.

When used with ModI18N, the framework corrects pronoun (his/hers) display for some vanilla NPCs.


Basic Syntax

maplebirch.npc.add(
  npcData,     // NPC base data
  npcConfig,   // NPC configuration
  translations // Translation data (optional)
);

NPC Base Data (NPCData)

FieldTypeDescriptionDefault
namstringRequired. Unique NPC name
gender'm'/'f'/'h'/'n'/'none'Genderrandom
titlestringTitle / epithet'none'
descriptionstringDescription textNPC name
typestringNPC type'human'
adultnumberAdult (1/0)random
teennumberTeen (1/0)random
agenumberAge0
insecuritystringInsecurity typerandom
chastityobjectChastity state{}
virginityobjectVirginity stateintact
hair_side_typestringSide hair type'default'
hair_fringe_typestringFringe type'default'
hair_positionstringHair position'back'
hairlengthnumberHair lengthrandom
eyeColourstringEye colourrandom
hairColourstringHair colourrandom
bottomsizenumberBottom sizerandom
skincolournumberSkin colour0
initnumberInit state0
intronumberIntro state0
penisstringPenis stateby gender
penissizenumberPenis sizeby gender
vaginastringVagina stateby gender
breastsizenumberBreast sizeby gender
ballssizenumberTesticles sizeby gender
outfitsstring[]Outfit listdefault
pregnancyanyPregnancy statenull

Gender

  • 'm': Male
  • 'f': Female
  • 'h': Herm
  • 'n': Neuter
  • 'none': None

Random Weights

  • Male: 47%, Female: 47%, Herm: 5%, Neuter: 1%

Insecurity Types

  • 'weak', 'looks', 'ethics', 'skill'

Eye Colours

Purple, dark blue, light blue, amber, hazel, green, red, pink, grey, light grey, lime.

Hair Colours

Red, black, brown, light brown, blond, platinum blond, strawberry blond, ginger.


Basic NPC Creation

// Simple NPC
maplebirch.npc.add(
  {
    nam: "Luna",
    gender: "f",
    title: "Moon Witch",
    description: "A mysterious witch who lives deep in the forest",
    age: 25,
    hairColour: "platinumblond",
    eyeColour: "purple",
    breastsize: 3,
    outfits: ["witch_robes", "casual_dress"],
  },
  {
    love: { maxValue: 100 },
    important: true,
    loveInterest: true,
  },
);

Complex NPC

maplebirch.npc.add(
  {
    nam: "Draven",
    gender: "m",
    title: "Mercenary Captain",
    description: "A seasoned mercenary with a prominent scar over his right eye",
    adult: 1,
    insecurity: "skill",
    chastity: { penis: "chastity_belt", vagina: "", anus: "" },
    virginity: { penile: false, vaginal: true, anal: false },
    hair_side_type: "short",
    hair_fringe_type: "messy",
    hairlength: 300,
    eyeColour: "light grey",
    hairColour: "black",
    penissize: 4,
    breastsize: 0,
    ballssize: 3,
    outfits: ["mercenary_armor", "casual_clothes", "formal_wear"],
  },
  {
    love: { maxValue: 150 },
    important: true,
    special: true,
    romance: [() => V.completedDravenQuest, () => V.dravenTrust >= 50],
    loveAlias: ["Loyalty", "Loyalty"],
  },
);

With Translations

const translations = new Map();
translations.set("Luna", { EN: "Luna", CN: "露娜" });
translations.set("Moon Witch", { EN: "Moon Witch", CN: "月光女巫" });

maplebirch.npc.add(
  { nam: "Luna", description: "A mysterious witch who lives deep in the forest" },
  { love: { maxValue: 100 } },
  translations,
);

boot.json Configuration

Structure

{
  "modName": "maplebirch",
  "addonName": "maplebirchAddon",
  "modVersion": "^3.1.0",
  "params": {
    "npc": {
      "NamedNPC": [
        [
          { "/* npcData */" },
          { "/* npcConfig */" },
          { "/* translations */" }
        ]
      ]
    }
  }
}

Full Example

{
  "params": {
    "npc": {
      "NamedNPC": [
        [
          {
            "nam": "Elara",
            "gender": "f",
            "title": "Elven Archer",
            "description": "Guardian of the forest, skilled with the bow",
            "age": 120,
            "eyeColour": "green",
            "hairColour": "lightbrown",
            "breastsize": 2,
            "outfits": ["elven_armor", "hunting_gear"]
          },
          {
            "love": { "maxValue": 120 },
            "important": true,
            "loveInterest": false
          },
          {
            "Elara": { "EN": "Elara", "CN": "伊拉娜" },
            "Elven Archer": { "EN": "Elven Archer", "CN": "精灵弓箭手" }
          }
        ],
        [
          {
            "nam": "Kael",
            "gender": "m",
            "title": "Dwarven Smith",
            "description": "A gruff but skilled dwarven blacksmith",
            "adult": 1,
            "hairColour": "ginger",
            "penissize": 2,
            "ballssize": 3
          },
          { "love": { "maxValue": 80 }, "special": true }
        ]
      ]
    }
  }
}

NPC Config (NPCConfig)

FieldTypeDescription
love{ maxValue: number }Love/Like max value
loveAlias[string, string] or functionLove/Like alias (e.g. CN/EN)
importantboolean or functionWhether NPC is important
specialboolean or functionWhether NPC is special
loveInterestboolean or functionWhether NPC can be love interest
romance(() => boolean)[]Romance condition functions

Example

{
  love: { maxValue: 100 },
  loveAlias: ['Affection', 'Affection'],
  loveAlias: () => (V.playerTrust > 50 ? ['Trust', 'Trust'] : ['Affection', 'Affection']),
  important: true,
  important: () => V.hasCompletedMainQuest === true,
  special: false,
  loveInterest: true,
  romance: [
    () => V.npcMet >= 5,
    () => V.npcTrust >= 30,
    () => !V.npcBetrayed,
  ],
}

Pronoun System

The framework provides pronoun mapping for English and Chinese:

TypeDescriptionhe (EN)he (CN)
mMalehe
fFemaleshe
iNon-personit
nNeuterthey
tPluralthey他们

Each type includes mappings for he, his, hers, him, himself, man, boy, men, etc.



Pregnancy System

The framework initializes the NPC pregnancy system by NPC name and type:

  • Infertile NPCs (e.g. Bailey, Leighton) are not initialized.
  • Supported types: human, wolf, wolfboy, wolfgirl, hawk, harpy.
  • Specific NPCs (Alex, Black Wolf, Great Hawk) are pregnant by default.