插件开发¶
不驯之冠支持插件系统,你可以新增或覆盖职业、敌人、建筑和语言包。
插件结构¶
插件以文件夹形式放在 plugins/ 目录下:
plugins/
└── my_plugin/
├── plugin.json # 插件元数据(必须)
├── content/
│ ├── adventurer_classes.json # 自定义职业
│ ├── enemies.json # 自定义敌人
│ └── buildings.json # 自定义建筑
├── lang/
│ ├── en.json # 英文翻译
│ └── zh_TW.json # 繁中翻译
└── assets/ # 自定义图片资源
plugin.json¶
{
"id": "my_plugin",
"name": "我的插件",
"version": "1.0.0",
"author": "作者名称",
"description": "插件描述"
}
载入顺序¶
- 核心内容(
game/content/)先载入 - 外部插件按文件夹名称字母排序后载入
- 后载入的插件覆盖先前同 ID 定义
- 在
plugins/disabled.json中的插件会被完全跳过
自定义冒险者职业¶
在 content/adventurer_classes.json 中定义:
[
{
"id": "NINJA",
"i18n_key": "class_ninja",
"color": [30, 30, 30],
"stats": {
"hp": [35, 80],
"str": [5, 15],
"agi": [10, 25],
"int": [3, 10],
"lck": [5, 15]
},
"desires": {
"gold": [0.3, 0.8],
"safety": [0.0, 0.2],
"glory": [0.5, 1.0],
"curiosity": [0.3, 0.7]
},
"level_up": {
"primary": "agi",
"primary_range": [3, 7],
"secondary": "str",
"secondary_range": [1, 3]
},
"attack_stat": "agi",
"attack_range": 5,
"skills": {
"3": {"id": "shadow_step", "i18n": "advskill_shadow_step", "effect": {"dodge": 0.2}},
"6": {"id": "poison_blade", "i18n": "advskill_poison_blade", "effect": {"atk_flat": 6}}
}
}
]
覆盖核心职业
使用与核心相同的 id(如 "WARRIOR")可以覆盖核心职业定义。
自定义敌人¶
在 content/enemies.json 中定义:
[
{
"id": "ORC",
"i18n_key": "enemy_orc",
"color": [100, 150, 50],
"spawn_tile": "MOUNTAIN",
"danger_level": 3,
"stats": {
"hp": 200,
"attack": 10,
"defense": 8,
"speed": 0.8,
"xp": 50,
"gold": 25,
"attack_range": 3,
"sight_range": 18
}
}
]
自定义建筑¶
在 content/buildings.json 中定义:
[
{
"id": "TAVERN",
"i18n_key": "building_tavern",
"color": [160, 120, 60],
"cost": 180,
"hp": 700,
"max_level": 2,
"upgrade_costs": [300],
"attracts": null,
"category": "shop"
}
]
语言包插件¶
最简单的插件类型 — 只需要 plugin.json 和 lang/*.json:
plugins/example_jp/
├── plugin.json
└── lang/
└── ja.json
语言 JSON 使用 key-value 格式,支持 {placeholder} 替换:
{
"window_title": "ウェイワード・クラウン",
"log_defeated_enemy": "{adv}が{enemy}を倒した(金:{gold} XP:{xp})"
}
启用 / 停用¶
- 在游戏设置菜单中可以启用或停用插件
- 停用的插件会记录在
plugins/disabled.json - 停用后需要重启游戏才生效
远程插件库¶
游戏支持从远程下载插件:
- 插件索引存放在
plugins/repo.json - 设置菜单中可以浏览和安装
- 下载的插件自动解压到
plugins/目录