模组制作:修订间差异

本页面讲述的内容长期有效
(merge from offical wiki)
 
无编辑摘要
第1行: 第1行:
{{version|Timeless}}
{{version|Timeless}}


'''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].
''' 模组制作''' ,或者制作 [[ 模组]], 是修改基本游戏(有时也叫'' 原版'' )的行为,可能是用于个人用途,也可能是要发布给其他玩家,例如,通过steam创意工坊 [http://steamcommunity.com/app/394360/workshop/ Steam Workshop].


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


By default, mods for Hearts of Iron IV are located in these folders:
钢铁雄心4的mod文件默认位于以下位置:
* '''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>
* '''Mac OS''': <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.
为了开始模组制作, you will want to create a [[Mod_structure|mod structure]] in the mod directory.


==Guidelines==
== 指导原则==


*'''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.
*''' 永远不要修改游戏文件''': 即使是小的修改也要通过mod文件来实现,永远不要直接修改Steam库里的钢铁雄心4文件夹中的游戏文件,因为你的改动可能在完全没有警告的情况下失败。
*'''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.
*''' 使用好的文本编辑器''' (例如[http://notepad-plus-plus.org/ Notepad++] 或者 [https://www.sublimetext.com/ Sublime Text] ) 来编辑文件并调查多个文件。
*'''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)
*''' 尽量减少对原版文件的重写''' 通过添加分开的文件并尽可能地从文件夹中加载,来改善模组的兼容性和可维护性。(你的文件可以使用任何名字,文件夹中的所有文件都会被游戏加载。所以选择一个酷酷的其他人都没有用过的文件夹名字。例如: 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.
*''' 使用正确的合并工具'''( 例如 [http://winmerge.org/ WinMerge]) ,来 [[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.
*''' 备份你的工作''' 以避免丢失全部。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.
*''' 使用 UTF-8 编码''' 在文本文件中.
*'''Use UTF-8-BOM''' for localisation files (.yml).
*''' 使用 UTF-8-BOM 编码''' 在localisation文件中 (.yml).
*'''Indent properly''' to easily spot unclosed braces. Vanilla uses 1 tab for indentation rather than spaces.
*''' 正确地缩进''' 以方便快速找到未对应的花括号。原版游戏使用1个tab的缩进而不是空格。
*'''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.
* 高效的'''Debug''' 通过使用Debug模式。通过在Steam的游戏启动选项中添加'''-debug''' 。这可以启用error log。


== Mod Structure ==
== 模组结构 ==
Game mods are located in:
游戏模组位于:
* Regular <code>\Paradox Interactive\Hearts of Iron IV\mod\</code>
* 普通模组 <code>\Paradox Interactive\Hearts of Iron IV\mod\</code>
* Steam Workshop: <code>\Steam\steamapps\workshop\content\394360\</code>
* 工坊模组: <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.
.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.
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.

2020年8月15日 (六) 18:08的版本


模组制作,或者制作 模组, 是修改基本游戏(有时也叫原版)的行为,可能是用于个人用途,也可能是要发布给其他玩家,例如,通过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