NPC 注册

Estimated reading time: 7 minutes

基本介绍

NPC 系统允许模组制作者在游戏中添加自定义的非玩家角色(NPC)。通过此系统,您可以定义角色的外貌、性格、关系状态、日程安排和特殊能力。

可通过 maplebirch.npc.addmaplebirchFrameworks.addNPC 来进行模组 NPC 的注册。

与 ModI18N 同时使用时,框架会修正部分原版 NPC 的性别代词(his/hers)显示。


基本语法

maplebirch.npc.add(
  npcData, // NPC基础数据
  npcConfig, // NPC配置
  translations, // 翻译数据
);

NPC 基础数据 (NPCData)

属性类型说明默认值
namstring必需,NPC 的唯一名称-
gender'm'/'f'/'h'/'n'/'none'性别随机
titlestring称呼/头衔'none'
descriptionstring描述文本NPC 名称
typestringNPC 类型'human'
adultnumber是否为成人 (1/0)随机
teennumber是否为青少年 (1/0)随机
agenumber年龄0
insecuritystring不安全感类型随机
chastityobject贞操带状态{}
virginityobject处女状态完整
hair_side_typestring侧发类型'default'
hair_fringe_typestring前发类型'default'
hair_positionstring头发位置'back'
hairlengthnumber头发长度随机
eyeColourstring眼睛颜色随机
hairColourstring头发颜色随机
bottomsizenumber臀部大小随机
skincolournumber肤色0
initnumber初始化状态0
intronumber介绍状态0
penisstring阴茎状态根据性别
penissizenumber阴茎大小根据性别
vaginastring阴道状态根据性别
breastsizenumber胸部大小根据性别
ballssizenumber睾丸大小根据性别
outfitsstring[]服装列表默认服装
pregnancyany怀孕状态null

性别说明

  • 'm': 男性
  • 'f': 女性
  • 'h': 人妖/双性
  • 'n': 中性
  • 'none': 无性别

随机权重

  • 男性: 47%
  • 女性: 47%
  • 人妖: 5%
  • 中性: 1%

不安全感类型

  • 'weak': 虚弱/无力
  • 'looks': 外貌/外表
  • 'ethics': 道德/伦理
  • 'skill': 技能/能力

眼睛颜色

紫色、深蓝、浅蓝、琥珀色、榛色、绿色、红色、粉色、灰色、浅灰、青柠绿

头发颜色

红色、黑色、棕色、浅棕色、金色、铂金色、草莓金、姜黄色


基本 NPC 创建

// 创建简单的NPC
maplebirch.npc.add(
  {
    nam: "Luna",
    gender: "f",
    title: "月光女巫",
    description: "居住在森林深处的神秘女巫",
    age: 25,
    hairColour: "platinumblond",
    eyeColour: "purple",
    breastsize: 3,
    outfits: ["witch_robes", "casual_dress"],
  },
  {
    love: { maxValue: 100 },
    important: true,
    loveInterest: true,
  },
);

复杂 NPC 定义

// 创建复杂的NPC
maplebirch.npc.add(
  {
    nam: "Draven",
    gender: "m",
    title: "佣兵队长",
    description: "经验丰富的佣兵,右眼有一道明显的伤疤",
    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"],
  },
);

翻译数据

// 添加带翻译的NPC
const translations = new Map();
translations.set("Luna", { EN: "Luna", CN: "露娜" });
translations.set("月光女巫", { EN: "Moonlight Witch", CN: "月光女巫" });

maplebirch.npc.add(
  {
    nam: "Luna",
    description: "居住在森林深处的神秘女巫",
  },
  {
    love: { maxValue: 100 },
  },
  translations,
);

在 boot.json 中配置

基本结构

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

完整示例

{
  "params": {
    "npc": {
      "NamedNPC": [
        [
          {
            "nam": "Elara",
            "gender": "f",
            "title": "精灵弓箭手",
            "description": "森林的守护者,箭术高超",
            "age": 120,
            "eyeColour": "green",
            "hairColour": "lightbrown",
            "breastsize": 2,
            "outfits": ["elven_armor", "hunting_gear"]
          },
          {
            "love": { "maxValue": 120 },
            "important": true,
            "loveInterest": false
          },
          {
            "Elara": { "EN": "Elara", "CN": "伊拉娜" },
            "精灵弓箭手": { "EN": "Elven Archer", "CN": "精灵弓箭手" }
          }
        ],
        [
          {
            "nam": "Kael",
            "gender": "m",
            "title": "矮人铁匠",
            "description": "脾气暴躁但手艺精湛的矮人铁匠",
            "adult": 1,
            "hairColour": "ginger",
            "penissize": 2,
            "ballssize": 3
          },
          {
            "love": { "maxValue": 80 },
            "special": true
          }
        ]
      ]
    }
  }
}

NPC 配置 (NPCConfig)

配置选项

属性类型说明
loveobject好感度配置
love.maxValuenumber最大好感度值
loveAlias[string, string] 或 function好感度别名(中/英)
importantboolean 或 function是否为重要 NPC
specialboolean 或 function是否为特殊 NPC
loveInterestboolean 或 function是否为可恋爱对象
romanceFunction[]恋爱条件函数数组

示例配置

{
  // 好感度配置
  love: { maxValue: 100 },

  // 好感度别名(静态)
  loveAlias: ['好感', 'Affection'],

  // 好感度别名(动态)
  loveAlias: () => {
    const trustLevel = V.playerTrust || 0;
    return trustLevel > 50 ? ['信赖', 'Trust'] : ['好感', 'Affection'];
  },

  // 重要NPC
  important: true,

  // 动态重要NPC
  important: () => {
    return V.hasCompletedMainQuest || false;
  },

  // 特殊NPC
  special: false,

  // 可恋爱对象
  loveInterest: true,

  // 恋爱条件
  romance: [
    () => V.npcMet >= 5,
    () => V.npcTrust >= 30,
    () => !V.npcBetrayed
  ]
}