模组制作

本页面讲述的内容长期有效
林登万讨论 | 贡献2020年8月15日 (六) 18:19的版本


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

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

钢铁雄心4的mod文件默认位于以下位置:

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

为了开始模组制作, you will want to create a mod structure in the mod directory.

指导原则

  • 永远不要修改游戏文件: 即使是小的修改也要通过mod文件来实现,永远不要直接修改Steam库里的钢铁雄心4文件夹中的游戏文件,因为你的改动可能在完全没有警告的情况下失败。
  • 使用好的文本编辑器(例如Notepad++ 或者 Sublime Text) 来编辑文件并调查多个文件。
  • 尽量减少对原版文件的重写。通过添加分开的文件并尽可能地从文件夹中加载来改善模组的兼容性和可维护性。(你的文件可以使用任何名字,文件夹中的所有文件都会被游戏加载。所以选择一个酷酷的其他人都没有用过的文件夹名字。例如: coolmod_countries)
  • 使用正确的合并工具(例如 WinMerge),来 merge between folders, and update modified vanilla files to a new vanilla patch.
  • 备份你的工作以避免丢失全部进度。Consider using a source control system like Git and a collaborative forge like GitHub to manage team collaboration, or just make a copy of the file somewhere else.
  • 使用 UTF-8 编码编写文本文件。
  • 使用 UTF-8-BOM 编码编写localisation文件(.yml)。
  • 正确地缩进以快速找到未对应的花括号。原版游戏使用1个tab的缩进而不是空格。
  • 使用注释。用 # 符号注释本行以更好地想起编写难办的代码的逻辑。
  • 通过使用Debug模式高效地Debug。通过在Steam的游戏启动选项中添加-debug。这样可以启用error log。

模组结构

游戏模组位于:

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

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

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 Thumbnail

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

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 user_dir nor replace_path in order to keep compatibility with other small mods.

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

Major Mod

Major mods can typically be divided into two categories, though can - and often do - overlap. These are Overhauls and Total Conversion Mods. Overhauls use user_dir due to the fact that saves cannot be loaded outside of the mod. For Total Conversion mods, replace_path can be used to completely ignore vanilla directories that don't make sense in the context of the mod (history, flags, ...).

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

Sub Mod

Submods of a major mod can use dependencies to be able to more precisely override files from main mod. This is necessary for the submods to operate as intended.

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

Game data

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.

Image file formats

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.

Tools & utilities

See also

References


hoi4fr:Modding