跳轉到

插件開發

不馴之冠支援插件系統,你可以新增或覆蓋職業、敵人、建築和語言包。


插件結構

插件以資料夾形式放在 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": "插件描述"
}

載入順序

  1. 核心內容game/content/)先載入
  2. 外部插件按資料夾名稱字母排序後載入
  3. 後載入的插件覆蓋先前同 ID 定義
  4. 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.jsonlang/*.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/ 目錄