
Cataclysm-DDA 怎么创建带 modinfo.json 的最小模组并让游戏识别它【免费下载链接】Cataclysm-DDACataclysm - Dark Days Ahead. A turn-based survival game set in a post-apocalyptic world.项目地址: https://gitcode.com/GitHub_Trending/ca/Cataclysm-DDACataclysm-DDACataclysm - Dark Days Ahead的绝大多数二次开发是通过编辑 JSON 文件完成的不需要重新编译游戏。如果你要做一个自己的模组任务就是在正确的模组目录里建一个文件夹并在其中放入一个modinfo.json文件——根据 MODDING 指南Cataclysm 只有在文件夹内存在modinfo.json时才会把该文件夹识别为一个模组。本文按官方文档走一遍这条路径放置目录、最小modinfo.json写法、可选字段、内容 JSON 的放置位置以及加载后如何判断模组是否被识别、出错了怎么看。模组应该放在哪个目录模组目录取决于模组是随游戏发行的还是第三方/私有模组doc/MODDING.md随 CDDA 发行的模组在data/mods例如仓库中的 dda 核心模组、Only_Wildlife 模组第三方/私有模组放在./mods游戏安装目录内或USER_DIR/mods。本文按第三方模组的常规做法走在游戏安装目录的mods/下新建一个文件夹文件夹名即模组的目录名。下面以文档中使用的my_mod为例。创建最小 modinfo.json在模组文件夹内创建modinfo.json。文档给出的最小可用内容是[ { type: MOD_INFO, id: Mod_ID, name: Mods Display Name } ]这是识别模组的绝对下限。其中两个值需要你替换成自己的内容id是模组的唯一标识name是显示名称。对id文档给出了明确限制不能与其他任何模组的id重复不能包含#字符必须是合法的文件夹路径为兼容其他模组做依赖检查。如果你希望在 Mod Selection 菜单中展示更多信息可以继续加authors、description、category等字段。按需填写 MOD_INFO 可选字段doc/MODDING.md 列出了 MOD_INFO 支持的全部字段一个带注释的完整示例[ { type: MOD_INFO, // Mandatory, youre making one of these! id: Mod_ID, // Mandatory, unique id for your mod. You should not use the same id as any other mod. Cannot contain the # character. Mod ids must also be valid folder pathing in order to support compatibility with other mods. name: Mods Display Name, // Mandatory. authors: [ Me, A really cool friend ], // Optional, but you probably want to put your name here. More than one entry can be added, as shown. description: The best mod ever!, // Optional category: graphical, // Optional, see below for a full list of supported values. The category is just for information purposes, so dont worry if your mod might fit more than one category. dependencies: [ dda ], // Optional. What other mods are required for this mod to function? If your mod depends on another one to work properly, adding that mods id attribute to the array causes Cataclysm to force that mod to load before yours. loading_images: [ cool.png, cool2.png ], // Optional. Filenames for any loading screen images the mod may have. Loading screens are only present on the graphical/tiles version. Only supports .png files. Actual loading screen image will be picked randomly from among all mod loading screens, including other loaded mods that have loading screens. disable_other_loading_screens: true, // Optional, default false. If set to true, only loading screens from this mod are used. version: 1.3.bacon, // Optional. For informational purposes only. No versioning system is provided, so whatever you put here is up to you. Feel free to name your versions after ice cream. core: false, // Optional, default false. Core mods will be loaded before anything else. Used for DDA, third-party use will not be supported. obsolete: false, // Optional, default false. Obsolete mods are loaded for legacy saves but cannot be used when starting new worlds path: my_mod_files/ // Optional, this directory relative to modinfo.jsons location will be considered the mods actual directory. e.g. if modinfo.json is located at C:\CDDA\my_mod\modinfo.json, then the mod files would be considered to be at C:\CDDA\my_mod\my_mod_files\. A file such as C:\CDDA\my_mod\some_other_file.json would be ignored, it isnt located inside the specified directory. } ]几个直接影响识别与加载行为的字段dependencies数组中写其他模组的idCataclysm 会强制那些模组先于你的模组加载。基础游戏内容的模组id是dda见 data/mods/dda/modinfo.json仓库里第三方模组普遍如此声明例如 Only_Wildlife 的 modinfo 使用dependencies: [ dda ]。如果你的模组依赖核心内容建议加上dda。category决定模组在 Mod Selection 菜单中出现在哪个分类。文档列出的可用取值有content、total_conversion、items、creatures、misc_additions、buildings、vehicles、rebalance、magical、item_exclude、monster_exclude、graphical。分类只是信息用途一个模组符合多个分类也没关系。path可选。指定相对modinfo.json的目录作为模组实际目录该目录之外的 JSON 文件会被忽略。不写这个字段时模组文件夹内的 JSON 即被读取。放入模组内容 JSON建好modinfo.json后把要加入游戏的内容写成 JSON 放进模组文件夹。文件结构上没有强制要求模组文件夹及其子文件夹中的所有 JSON 文件都会被 Cataclysm 检测并读取官方建议按内容类型拆分成不同的 JSON 文件doc/MODDING.md 的 File structure 一节。具体能定义哪些内容物品、职业、场景、怪物黑名单等以 doc/JSON/JSON_INFO.md 为准。doc/MODDING.md本身也给了一份可直接复制的最低限度示例比如在items.json中定义一个通用物品[ { id: family_photo, type: GENERIC, //: Unique mission item for the CITY_COP., category: other, name: family photo, description: A photo of a smiling family on a camping trip. One of the parents looks like a cleaner, happier version of the person you know., weight: 1 g, volume: 0, price: 8 USD, material: [ paper ], symbol: *, color: light_gray } ]基础游戏的数据同样用这套 JSON 定义不确定字段写法时可以对照data/json下的核心游戏文件。验证游戏是否识别模组识别与加载的判定来自两处文档描述Mod Selection 菜单category字段决定模组出现在模组选择菜单的哪个分类即模组被成功识别后你会在游戏启动时的 Mod Selection 菜单中按分类看到它。可以拿仓库里的现成模组对照确认格式例如data/mods/Only_Wildlife/modinfo.json只有modinfo.json一个文件即可构成一个完整模组。加载游戏世界时dependencies声明的依赖模组会被强制先加载。如果你的 JSON 有语法问题文档的说明是If the game finds any issues in your JSON syntax when you try to load a game world, it will spit out an error message, and you wont be able to load that game until the issue is fixed. 也就是说验证动作是尝试加载世界能加载说明 JSON 被正常读取弹出错误信息则按报错定位到具体 JSON。JSON 语法错误是这类模组最主要的坑doc/MODDING.md 专门有一节 Important note on json files[ { , } ] : 这些字符在 JSON 中非常关键漏掉一个逗号或括号就是能用的文件和启动时卡死的区别。两个文档给出的应对方法如果需要把上述字符写进文本内容比如在物品描述里放引号用反斜杠转义description: This is a shirt that says \I wanna kill ALL the zombies\ on the front.,编辑器选择带括号配对检查的功能且该功能要能正确处理转义字符。文档提到 Windows 上 Notepad 有该功能Linux 上自行选择常用编辑器。限制与边界识别一个模组的硬性条件就是文件夹内存在modinfo.jsonmodinfo.json中type、id、name三个字段必填id唯一且不含#。core字段仅用于 DDA 核心模组第三方模组使用不受支持。loading_images只在图形/tiles 版本中有加载画面效果且只支持.png。模组能修改的只是 JSON 可表达的内容哪些内容不能被模组修改见 doc/MODDING.md 的 That which cannot be modded 一节具体字段范围以 doc/JSON/JSON_INFO.md 为准。下一步如果要往模组里加职业、场景、对话或调整怪物生成doc/MODDING.md的 Actually adding things to your mod 一节提供了每种类型可直接复制的 JSON 片段可以按同样方式追加到模组文件夹中。【免费下载链接】Cataclysm-DDACataclysm - Dark Days Ahead. A turn-based survival game set in a post-apocalyptic world.项目地址: https://gitcode.com/GitHub_Trending/ca/Cataclysm-DDA创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考