模组制作:修订间差异

本页面讲述的内容长期有效
(merge from offical wiki)
 
(文本替换 - 替换“[[Category:”为“[[分类:”)
 
(未显示10个用户的20个中间版本)
第1行: 第1行:
{{version|Timeless}}
{{version|Timeless}}
'''模组制作'''(英文:'''Modding''')或者制作[[模组]],是修改基本游戏(有时也叫“原版”)的行为。可能是用于个人用途,也可能是例如通过 [http://steamcommunity.com/app/394360/workshop/ steam创意工坊]发布给其他玩家。


'''Modding''', or creating [[mods]], is the act of modifying the behavior of the base game (often referred to as ''vanilla''), either for personal use, or to release publicly for other players, for instance - via the [http://steamcommunity.com/app/394360/workshop/ Steam Workshop].
在所有的P社游戏中,''' 钢铁雄心4''' 的模组制作可以涵盖很大的范围。模组开发者们的动机可能各有不同:更好的语言翻译和本地化,更多的事件或决议,更好的地图,或是一次巨大的改造,等等。


As for all Paradox games, [[Hearts of Iron IV]] is moddable to a great extent. Motivations of modders may vary widely: a better translation to their native language, more events or decisions, better maps, a major overhaul, etc.
默认情况下,MOD位于这些文件夹中:
 
By default, mods for Hearts of Iron IV are located in these folders:
* '''Windows''': <code>C:\Users\<Username>\Documents\Paradox Interactive\Hearts of Iron IV\mod</code>
* '''Windows''': <code>C:\Users\<Username>\Documents\Paradox Interactive\Hearts of Iron IV\mod</code>
* '''Mac OS''': <code>~/Documents/Paradox Interactive/Hearts of Iron IV/mod</code>
* '''macOS''': <code>~/Documents/Paradox Interactive/Hearts of Iron IV/mod</code>
* '''Linux''': <code>~/.local/share/Paradox Interactive/Hearts of Iron IV/mod</code> 
* '''Linux''': <code>~/.local/share/Paradox Interactive/Hearts of Iron IV/mod</code> 


To start modding, you will want to create a [[Mod_structure|mod structure]] in the mod directory.
为了开始模组制作,你需要在模组文件夹下新建一个[[Mod_structure| 模组文件结构]]。
 
== 指导原则 ==
*'''永远不要修改游戏文件''':即使是小的修改也要通过 mod 文件来实现,永远不要直接修改 Steam 库里的钢铁雄心 4 文件夹中的游戏文件,因为你的改动可能在完全没有警告的情况下失败。
*'''使用好的文本编辑器'''(例如 [http://notepad-plus-plus.org/ Notepad++] 或者 [https://www.sublimetext.com/ Sublime Text] )来同时编辑和搜索多个文件。
*'''尽量减少对原版文件的重写''':通过添加分开的文件并尽可能地从文件夹中加载来改善模组的兼容性和可维护性。(你的文件可以使用任何名字,文件夹中的所有文件都会被游戏加载。所以选择一个酷酷的其他人都没有用过的文件夹名字。例如: coolmod_countries)
*'''使用正确的合并工具''':(例如 [http://winmerge.org/ WinMerge] )来 [[Merging guide|合并文件夹]],并将新更新的文件打包为一个新补丁。
*'''备份你的工作'''以避免丢失全部进度:考虑使用诸如 [https://git-scm.com/ Git] 一类的源代码控制系统,还有类似于 [https://github.com/ GitHub] 的协作平台来管理团队协作的事情,或者就只是把文件的备份放在别的什么地方。
*'''使用 UTF-8 编码'''编写文本文件。
*'''使用 UTF-8-BOM 编码'''编写 localisation 文件(.yml)。
*'''正确地缩进'''以快速找到未对应的花括号:原版游戏使用 1 个 tab 的缩进而不是空格。
*'''使用注释''':用 # 符号注释本行以更好地想起编写难办的代码的逻辑。
*通过使用Debug模式高效地'''Debug''':通过在Steam的游戏启动选项中添加'''-debug'''。这样可以启用 error log。
*或者也可以将dowser.exe文件新建一个'''快捷方式''',并在'''快捷方式-属性-目标栏'''里 加入 '''-debug'''(注:前有空格)
 
====== '''使用Debug的优点''' ======


==Guidelines==
*'''自动加载''' - 对mod文件夹内的文件的编辑会在游戏中显示出来,而不需要使用 "reload "控制台命令。这也会自动将文件中的错误添加到错误日志中。但是,请注意,这只适用于在会话中编辑的文件,而不是新创建的文件。
*'''不会因地图定义错误而使游戏崩溃''' - 如果地图被编辑了,就有可能出现错误。任何与地图有关的错误在加载时都会使游戏崩溃,并显示 "一些错误存在于地图定义中并被记录到error.log中"。但如果调试模式打开,游戏将继续正常加载。
*'''扩展的错误日志''' - 某些错误不会被记录在日志中,除非调试模式被打开。一个例子是上面提到的地图定义错误,因为游戏在有机会记录它们之前就崩溃了。启用调试模式将确保所有可以记录在错误日志中的错误都能被记录下来。
*'''错误日志打开的便利性''' - 只要日志中存在任何错误,日志就会在加载游戏时自动打开。在加载到一个国家后,点击右下角的狗狗也能得到访问日志的机会,每次日志中出现新的错误时这只狗狗都会出现(因为文件会自动加载进去)。
*'''方便的NUDGE!访问''' - 在调试模式打开后,主菜单中会出现一个打开'''NUDGE!'''的选项。这可以节省时间,最重要的是当你试图加载到一个国家时游戏崩溃了的时候能够打开'''NUDGE!'''是非常有用的(因为此时已经无法在正式的游戏中测试该国家了)。
*'''更多省份信息''' - 在调试模式下,将鼠标悬停在省份上会有额外的信息,包括它和它所在的国家的ID,所有者和控制器的标签,等等。
*'''更多的控制台命令''' - 某些控制台命令只锁定给开发者使用,调试模式允许玩家使用它们。
*'''易于访问GUI文件''' - 当悬停在一个GUI元素上时,可以使用Ctrl+Alt+右键来打开一个调试菜单,这将允许进入定义该元素的GUI文件。
*'''和平协议的自动保存''' - 每次进入和谈时,游戏都会自动创建一个带有调试功能的保存文件。
*'''注意,如果你通过'debug'控制台命令打开debug模式,只有最后2个优点可以使用。如果通过启动选项打开调试,所有的好处都将被授予。'''


*'''Never modify game files''': use a mod even for small changes, and never modify directly game files in Steam Hearts of Iron 4 folder, as your changes may be undone without warning.
*'''Use a good text editor''' (like [http://notepad-plus-plus.org/ Notepad++] or [https://www.sublimetext.com/ Sublime Text]) to edit files and search into multiple files.
*'''Minimize overwrites of vanilla files''' by adding separate files and loading from folders whenever possible, to improve mod compatibility and maintenance. (Your files can have any name, all files in the folder will be loaded by the game. So choose a name, no one else will ever use, like the name of your mod. Ex: coolmod_countries)
*'''Use a proper merge tool''' (like [http://winmerge.org/ WinMerge]), to [[Merging guide|merge between folders]], and update modified vanilla files to a new vanilla patch.
*'''Backup your work''' to avoid losing everything. Consider using a source control system like [https://git-scm.com/ Git] and a collaborative forge like [https://github.com/ GitHub] to manage team collaboration, or just make a copy of the file somewhere else.
*'''Use UTF-8 encoding''' for text files.
*'''Use UTF-8-BOM''' for localisation files (.yml).
*'''Indent properly''' to easily spot unclosed braces. Vanilla uses 1 tab for indentation rather than spaces.
*'''Use comments''' starting with # character, to remember reasons for writing tricky stuff.
*'''Debug''' effectively by enabling Debug mode. Do this by adding '''-debug''' to your launch options in Steam. This will enable verbose error logging.


== Mod Structure ==
Game mods are located in:
* Regular <code>\Paradox Interactive\Hearts of Iron IV\mod\</code>
* Steam Workshop: <code>\Steam\steamapps\workshop\content\394360\</code>


The name of the .mod file must not contain any spaces, or it will not be auto-selected by the game launcher.
== 模组结构 ==
游戏模组位于:
* 普通模组 <code>\Paradox Interactive\Hearts of Iron IV\mod\</code>
* 工坊模组: <code>\Steam\steamapps\workshop\content\394360\</code>


There are three main classes of mods that pertain to the structure of the .mod file. These classes are '''Minor Mod''', '''Major Mod''', and '''Submod''' and the general structure of these mods is shown below. It is up to the maker of the mod whether or not the mod should be considered a minor, major or sub-mod.
.mod 文件的名字必须不包含任何空格,否则它将不会被游戏启动器自动选择。


===Mod Thumbnail===
根据 .mod 文件的结构可以把模组分为三类,分别是'''小型模组''','''大型模组'''和'''次级模组'''。这些种类模组的总体结构将在下文中讲述。模组是小型、大型还是次级模组取决于模组的制作者。
Since the release of the "new launcher" all thumbnails must be named "thumbnail.png" and located in the root folder of your mod.


===Minor Mod===
=== 模组缩略图 ===
在新启动器发布之后,所有的缩略图都必须被命名为“thumbnail.png”,并且应该放在你的模组的根目录中。


The most common type of mod is a minor mod, or a mod that changes only a small part of the game. These types of mod don't need new savegame or graphics folders as and so do not need to use <code>user_dir</code> nor <code>replace_path</code> in order to keep compatibility with other small mods.
=== 小型模组 ===
最常见的模组类型就是小型模组,即仅仅改变游戏中的一小部分内容的模组。这种模组不需要新的存档或者图形文件,也不需要使用<code>user_dir</code> <code>replace_path</code> ,以保持与其他小型模组的兼容性。


<pre>
<pre>
第48行: 第61行:
</pre>
</pre>


===Major Mod===
=== 大型模组 ===
 
大型模组可以典型地划分为两类——尽管可能并且时常重叠——大改过的模组和完全翻新的模组。
Major mods can typically be divided into two categories, though can - and often do - overlap. These are Overhauls and Total Conversion Mods.
大改过的模组使用<code>user_dir</code> 来保证存档不能在此模组之外加载。
Overhauls use <code>user_dir</code> due to the fact that saves cannot be loaded outside of the mod.
对于完全翻新过的模组,<code>replace_path</code> 可以用来完全忽略原版游戏的在此模组背景下不合理的内容(例如历史、旗帜等)。
For Total Conversion mods, <code>replace_path</code> can be used to completely ignore vanilla directories that don't make sense in the context of the mod (history, flags, ...).


<pre>
<pre>
第63行: 第75行:
</pre>
</pre>


===Sub Mod===
=== 次级模组 ===
 
一个大型模组的次级模组使用<code>dependencies</code> 以更精确地重写主模组内容。如果想要让次级模组正常运作这是必需的。
Submods of a major mod can use <code>dependencies</code> to be able to more precisely override files from main mod. This is necessary for the submods to operate as intended.


<pre>
<pre>
第75行: 第86行:
</pre>
</pre>


==Game data==
== 游戏数据 ==
 
* [[Console commands]], useful for debugging mods.
* [[Defines]], which allow to influence some hardcoded vanilla behaviors
* [[Scopes]], [[Conditions]], and [[Commands]] used for scripting
* [[Modifiers]], used to influence calculations made by the game
* [[Event_Modding|Event Modding]], used to define popups with decisions


Names for in-game items (e.g. the name for research categories or rules like can_create_faction) can be found in the game's localization folder, inside the localization files.
* [[Console commands|控制台指令]],对模组进行调试很有帮助。
* [[Defines]],可以修改一些硬编码的原版行为
* [[Scopes|作用域]],[[Conditions|条件]]还有[[Commands|指令]]被用来编写脚本
* [[Modifiers|修正]]用来影响游戏中进行的计算
* [[Event_Modding]]用来定义带有决议的弹出菜单


==Image file formats==
游戏中物品的名称(像是,研究类别的名称或者像 can_create_faction 等规则)可以在游戏的 localization 文件夹中的本地化文件中找到。


Use DDS format for images. Most of the files are saved in 8.8.8.8 ARGB, 32 bit unsigned sub-format. Some files (like leader portraits) are saved using 1.5.5.5 ARGB 16 bit unsigned variant. Event Image can also be of the .tga format. Flags are saved as 32bpp .tga files.
== 图像文件格式 ==
图像应使用 DDS 格式。大多数文件是以 8.8.8.8 ARGB 32 位无符号格式保存的。一些文件(例如 leader 肖像)是 1.5.5.5 ARGB 16  位无符号格式保存的。事件图片也可以使用 .tga 格式。旗帜是 32 位像素深度的 .tga 文件。


==Tools & utilities==
== 工具& 实用程序 ==
* [http://notepad-plus-plus.org/ Notepad++] - Powerful editor to change files.
* [http://notepad-plus-plus.org/ Notepad++] - 强大的文件编辑器。
* [https://forum.paradoxplaza.com/forum/index.php?forums/hearts-of-iron-4-user-mods.950/ Official Paradox Forum for mods.
* [https://code.visualstudio.com/ Visual Studio Code] - 功能和Notepad++类似,可以非常方便的编辑的文件文本内容和调整MOD文件夹结构,可安装适用于HOI4mod制作的专用[https://marketplace.visualstudio.com/items?itemName=tboby.cwtools-vscode 插件]。
* [https://forum.paradoxplaza.com/forum/index.php?threads/information-and-faq.924764/ Maya exporter] - Clausewitz Maya Exporter to create your own 3D models.
* [https://winmerge.org/ WinMerge]  - 文件夹/文档对比器。
* [http://steamcommunity.com/app/394360/workshop/ Steam Workshop] - The place for where you can share your creations with other players.
* [https://www.getpaint.net/ Paint.net] - 十分精简且方便的图片编辑器,能够修改HOI4常用的DDS格式图片。
* [https://forum.paradoxplaza.com/forum/index.php?forums/hearts-of-iron-4-user-mods.950/ P 社官方论坛的 mod 版面
* [https://forum.paradoxplaza.com/forum/index.php?threads/information-and-faq.924764/ Maya exporter] - Clausewitz Maya Exporter 创建你自己的 3D 模型。
* [http://steamcommunity.com/app/394360/workshop/ steam创意工坊] - 你可以和其他玩家分享作品的地方。


==See also==
== 另见 ==
*[[Mods]]
*[[Mods|模组]]
* Getting started with modding [[forum: 995985]]
* 从制作模组开始 [[forum: 995985]]
* How to create a new ship unit in Man the Guns [[forum: 1157324]]
* 如何在炮手就位中创建一种新的舰船 [[forum: 1157324]]
* How to add a new unit - Checklist [[forum: 947435]]
* 如何添加新的兵种 - 一览表 [[forum: 947435]]


== References ==
== 参考 ==


<references />
<references />


{{Modding navbox}}
{{Modding navbox}}
[[Category:Modding|#]]
[[ 分类:Modding|#]]
[[hoi4fr:Modding]]
[[en:Modding]]

2022年12月5日 (一) 15:44的最新版本

模组制作(英文:Modding)或者制作模组,是修改基本游戏(有时也叫“原版”)的行为。可能是用于个人用途,也可能是例如通过 steam创意工坊发布给其他玩家。

在所有的P社游戏中,钢铁雄心4的模组制作可以涵盖很大的范围。模组开发者们的动机可能各有不同:更好的语言翻译和本地化,更多的事件或决议,更好的地图,或是一次巨大的改造,等等。

默认情况下,MOD位于这些文件夹中:

  • Windows: C:\Users\<Username>\Documents\Paradox Interactive\Hearts of Iron IV\mod
  • macOS: ~/Documents/Paradox Interactive/Hearts of Iron IV/mod
  • Linux: ~/.local/share/Paradox Interactive/Hearts of Iron IV/mod

为了开始模组制作,你需要在模组文件夹下新建一个模组文件结构

指导原则

  • 永远不要修改游戏文件:即使是小的修改也要通过 mod 文件来实现,永远不要直接修改 Steam 库里的钢铁雄心 4 文件夹中的游戏文件,因为你的改动可能在完全没有警告的情况下失败。
  • 使用好的文本编辑器(例如 Notepad++ 或者 Sublime Text )来同时编辑和搜索多个文件。
  • 尽量减少对原版文件的重写:通过添加分开的文件并尽可能地从文件夹中加载来改善模组的兼容性和可维护性。(你的文件可以使用任何名字,文件夹中的所有文件都会被游戏加载。所以选择一个酷酷的其他人都没有用过的文件夹名字。例如: coolmod_countries)
  • 使用正确的合并工具:(例如 WinMerge )来 合并文件夹,并将新更新的文件打包为一个新补丁。
  • 备份你的工作以避免丢失全部进度:考虑使用诸如 Git 一类的源代码控制系统,还有类似于 GitHub 的协作平台来管理团队协作的事情,或者就只是把文件的备份放在别的什么地方。
  • 使用 UTF-8 编码编写文本文件。
  • 使用 UTF-8-BOM 编码编写 localisation 文件(.yml)。
  • 正确地缩进以快速找到未对应的花括号:原版游戏使用 1 个 tab 的缩进而不是空格。
  • 使用注释:用 # 符号注释本行以更好地想起编写难办的代码的逻辑。
  • 通过使用Debug模式高效地Debug:通过在Steam的游戏启动选项中添加-debug。这样可以启用 error log。
  • 或者也可以将dowser.exe文件新建一个快捷方式,并在快捷方式-属性-目标栏里 加入 -debug(注:前有空格)
使用Debug的优点
  • 自动加载 - 对mod文件夹内的文件的编辑会在游戏中显示出来,而不需要使用 "reload "控制台命令。这也会自动将文件中的错误添加到错误日志中。但是,请注意,这只适用于在会话中编辑的文件,而不是新创建的文件。
  • 不会因地图定义错误而使游戏崩溃 - 如果地图被编辑了,就有可能出现错误。任何与地图有关的错误在加载时都会使游戏崩溃,并显示 "一些错误存在于地图定义中并被记录到error.log中"。但如果调试模式打开,游戏将继续正常加载。
  • 扩展的错误日志 - 某些错误不会被记录在日志中,除非调试模式被打开。一个例子是上面提到的地图定义错误,因为游戏在有机会记录它们之前就崩溃了。启用调试模式将确保所有可以记录在错误日志中的错误都能被记录下来。
  • 错误日志打开的便利性 - 只要日志中存在任何错误,日志就会在加载游戏时自动打开。在加载到一个国家后,点击右下角的狗狗也能得到访问日志的机会,每次日志中出现新的错误时这只狗狗都会出现(因为文件会自动加载进去)。
  • 方便的NUDGE!访问 - 在调试模式打开后,主菜单中会出现一个打开NUDGE!的选项。这可以节省时间,最重要的是当你试图加载到一个国家时游戏崩溃了的时候能够打开NUDGE!是非常有用的(因为此时已经无法在正式的游戏中测试该国家了)。
  • 更多省份信息 - 在调试模式下,将鼠标悬停在省份上会有额外的信息,包括它和它所在的国家的ID,所有者和控制器的标签,等等。
  • 更多的控制台命令 - 某些控制台命令只锁定给开发者使用,调试模式允许玩家使用它们。
  • 易于访问GUI文件 - 当悬停在一个GUI元素上时,可以使用Ctrl+Alt+右键来打开一个调试菜单,这将允许进入定义该元素的GUI文件。
  • 和平协议的自动保存 - 每次进入和谈时,游戏都会自动创建一个带有调试功能的保存文件。
  • 注意,如果你通过'debug'控制台命令打开debug模式,只有最后2个优点可以使用。如果通过启动选项打开调试,所有的好处都将被授予。


模组结构

游戏模组位于:

  • 普通模组 \Paradox Interactive\Hearts of Iron IV\mod\
  • 工坊模组: \Steam\steamapps\workshop\content\394360\

.mod 文件的名字必须不包含任何空格,否则它将不会被游戏启动器自动选择。

根据 .mod 文件的结构可以把模组分为三类,分别是小型模组大型模组次级模组。这些种类模组的总体结构将在下文中讲述。模组是小型、大型还是次级模组取决于模组的制作者。

模组缩略图

在新启动器发布之后,所有的缩略图都必须被命名为“thumbnail.png”,并且应该放在你的模组的根目录中。

小型模组

最常见的模组类型就是小型模组,即仅仅改变游戏中的一小部分内容的模组。这种模组不需要新的存档或者图形文件,也不需要使用user_dirreplace_path,以保持与其他小型模组的兼容性。

 name = "Minor Mod"
 path = "mod/MinorMod"
 picture = "thumbnail.png"
 tags = { "Minor" "Mod" }

大型模组

大型模组可以典型地划分为两类——尽管可能并且时常重叠——大改过的模组和完全翻新的模组。 大改过的模组使用user_dir来保证存档不能在此模组之外加载。 对于完全翻新过的模组,replace_path可以用来完全忽略原版游戏的在此模组背景下不合理的内容(例如历史、旗帜等)。

 name = "Major Mod"
 path = "mod/MajorMod"
 user_dir = "MajorMod"
 replace_path = "history/states" 
 picture = "thumbnail.png"
 tags = { "Major" "Mod" }

次级模组

一个大型模组的次级模组使用dependencies以更精确地重写主模组内容。如果想要让次级模组正常运作这是必需的。

 name = "Sub Mod"
 path = "mod/SubMod"
 dependencies = { "Major Mod" }
 picture = "thumbnail.png"
 tags = { "SubMod" "Major Mod" }

游戏数据

游戏中物品的名称(像是,研究类别的名称或者像 can_create_faction 等规则)可以在游戏的 localization 文件夹中的本地化文件中找到。

图像文件格式

图像应使用 DDS 格式。大多数文件是以 8.8.8.8 ARGB 32 位无符号格式保存的。一些文件(例如 leader 肖像)是 1.5.5.5 ARGB 16 位无符号格式保存的。事件图片也可以使用 .tga 格式。旗帜是 32 位像素深度的 .tga 文件。

工具&实用程序

另见

参考