模組製作

本頁面講述的內容長期有效
(重新導向自Modding

Template:需要翻譯

模組製作(Modding)允許改變遊戲的要素或者添加新特性。
Certain things are hardcoded, i.e. not available for modding, such as changing mapmodes and diplomatic actions or adding new hotkeys.

Important: the majority of mods will change the checksum, not allowing the player to get achievements. Loading an ironman game with such a mod will irreversably corrupt the save file, so be careful.
See "checksum_manifest.txt" in the game folder for the list of checksummed folders and files. The only safe mods are the ones that replace textures, fonts or music.

提示和指南

  • 創建一個模組而非直接修改遊戲文件,它們將在任何遊戲更新時被覆蓋(原文如此,說人話就是模組文件夾里的內容會覆蓋原版內容)
  • 使用一個好的文本編輯器來顯示語法高亮,自動補全及跨文件搜索。以下程序是免費的:
  1. Visual Studio Code. VSCode里有一個粉絲製作的CWTools擴展, 該擴展標識了Paradox代碼, 它會提示你補全括號並在提示中顯示作用域和效果信息。在VSCode左側擴展面板中搜索CWTools並下載。 (注: 如果該擴展與遊戲發布版本不匹配,會有很多誤報錯)
  2. Sublime Text. Imperator developers have released Sublime Tools with syntax highlighting and function search. In addition, to be able to toggle comments, you need to add this file to the same "User" folder.
  3. Notepad++. Choose Perl as your language, as it will provide good highlighting and allow to fold blocks of code and comments. To set it as default, go to Settings, Styler Configurator, find Perl in the list on the left and add "gui txt" (without quotes) to the "User ext." field at the bottom.
  4. Atom. Doesn't include UTF-8-BOM encoding needed for localization files. Choose Perl 6 as your language for better results. To set it as default, go to File, Config, find "core:" and add below it: "customFileTypes: "source.perl6": [ "txt" "gui"]", like in this example.
  • Indent properly, so that opening and closing brackets are on the same level. Proper formatting will allow you to fold blocks of code, help spot any mistakes and make it easier to read.
  • 行開頭加#注釋,提醒後來的人這些內容如何工作,方便導航,注釋掉不要的代碼而非直接刪除。
  • txt文件使用UTF-8編碼。
  • 本地化文件使用UTF-8-BOM編碼。(譯者註:VSCode右下角編碼那邊點一下可以直接調,不需要記事本打開再保存為特點編碼。)
  • Start the game with the "-debug_mode" and "-develop" options to use the console, dev tools and "reload" commands. See here how to add launch options.
  • Use the error.log to catch any bugs. It's located next to the mod folder, in Documents/Paradox Interactive/Imperator/logs.
  • Use "script_docs" and "DumpDataTypes" console commands in the game to generate other logs with event effects, triggers and scopes.
  • 模組上傳steam創意工坊之後,移除本地模組,否則不生效。
  • Clearly communicate to users whether your mod is ironman-friendly.
  • 備份你的作品。手動備份或者使用譬如Git的版本控制系統都可以。也可以考慮使用GitHub以供團隊寫作開發。(譯者註:國內訪問GitHub困難,並且GitHub項目有一個G的空間限制,如果美術素材多的話很容易就超了。這裡有上中下三策,上策是自己部署一個Git平台,gitlab太重了,這裡建議使用輕量版的git託管平台onedev,也是國人開發的開源項目,支持docker部署;中策可以使用阿里雲的代碼平台codeup,免費的項目大小可以有兩個G,稍微大一些;下策是使用魔法訪問github。)
  • 使用合適的合併工具 (譬如 WinMerge) 來合併不同文件夾並為新版本更新修改後的文件。

創建你的第一個 mod

1. Start the game launcher, go to All Installed Mods, Upload Mod, Create a Mod and fill in all the fields, including tags. Clicking Create will create a new folder and a .mod file in Documents/Paradox Interactive/Imperator/mod.

  • "Version" refers to the game version this mod is made for.
  • Folder name may include spaces, although it is common to use lower_spaces instead.

2. Copy the game files you wish to mod to your newly created mod folder or create your own files, while using the same folder structure.

  • For example, if you want to mod the topbar, your should have the following: my_topbar_mod/gui/ingame_topbar.gui.
  • If you want to add events to this mod, you would have my_topbar_mod/events/topbar_events.txt.

3. After modifying the files, enable the mod in the launcher and test it in the game.

  • If modding UI, you can use "reload gui" command to see new changes without restarting the game. (This requires both -develop and -debug_mode launch options. See above how to enable them.)
  • Remember to check the error.log for any errors.

4. To add a thumbnail for a mod, name your image "thumbnail.png" and put it inside your mod folder. Make it at least 200x200 pixels, so Steam doesn't add black borders around it.
5. To upload a mod, open the game launcher, go to All Installed Mods, Upload Mod. Select your mod from the dropdown menu, select the platform to upload it to and click Upload. The description isn't necessary.

  • You will find your mod in your Steam profile, Workshop Items. New mods are uploaded in private mode, so change their visibility to Public to actually publish them.
  • Remember, remove your local mod folder if you want to test the Steam version of it, otherwise they will conflict with each other. You may simply move it, along with the .mod file, to another folder and move it back whenever you want to update your mod.

6. To update a mod, simply open the launcher and upload it again.
(When you upload a mod for the first time, the launcher creates a descriptor.mod file in your mod folder which links to your Steam mod. This is what's used for updating, so don't remove this file.)

遊戲數據

  • Effects - 用於動態地影響遊戲。
  • Triggers - 用於執行命令/事件/決議/等等。只有當特定條件為真時。
  • Scopes - 用於明確規定命令和條件的目標。
  • Modifier list - 影響遊戲方方面面的腳本修正。
  • Defines - 用於遊戲在幾乎所有方面的全局值。
  • Country list - 原版遊戲中全部國家的基本信息,包括國家代碼。
  • Console commands - 關於如何使用遊戲控制台命令的指南。
  • 遊戲預置腳本
  • 遊戲預置修正
  • 總表

指南

排除故障

Mod 在上傳到 Steam 之後不工作

Check whether other mods work for you. If not and your Documents folder is not in the default place, the launcher can't find it.

You need to edit "launcher-settings.json":

  1. open the game directory (Right-click on Steam, Properties, Local Files, Browse Local Files)
  2. in the 'launcher' folder open launcher-settings.json with a notepad
  3. change gameDataPath to "%USER_DOCUMENTS%/Paradox Interactive/Imperator"

If this still doesn't help, try using the whole path, like "F:/Documents/Paradox Interactive/Imperator". Make sure you use forward slashes / and double quotes ".

在 .mod 文件中的路徑變成絕對路徑

The new launcher overwrites the "mod/modname" path to the absolute one, like "C:/Users/User/Documents.../mod/modname".

While this is normal, for some modders it can prevent the game from loading the mod. To solve it:

  1. Change the path to relative again.
  2. Right-click the file -> Properties -> check Read-only.

This will prevent the launcher from editing it. Remember to disable read-only when uploading, since the launcher needs access to the file.

工具與實用程序

  • Clausewitz Maya Exporter - 此工具允許更簡便地創建3D模型(單位)用於較新的克勞塞維茨引擎遊戲中的模組。
  • VS Code - 強大的、可控制的、免費開源編輯器,來自微軟。(在VS Code擴展中心搜索安裝中文語言包)
  • CWTools - 一個用於VS Code的擴展,提供拼寫驗證、代碼補全、語法高亮以及更多功能給Paradox腳本文件。(在VS Code擴展中心搜索安裝CWTools)
  • Notepad++ Syntax Highlighter - Notepad++語法高亮規則定義。(已過時)
  • province setup converter 1.3.x -> 1.4 - 一個用來轉換舊的省份數據信息,從 Imperator 1.3.x 或者使用 province_setup.csv 文件到文本格式給 Imperator 1.4

社區

雜項

參考資料