创建国家:修订间差异

本页面所适用的版本可能已经过时,最后更新于1.13
无编辑摘要
无编辑摘要
 
(未显示5个用户的10个中间版本)
第1行: 第1行:
{{Version|1.8}}
{{Version|1.13}}
这个网页包括了假如你已经掌握基础的[[Mod_structure| 创建一个模组]] 的基本知识,就可以学习接下来的进阶内容。
{{需要翻译|译者=霜泽图书馆}}
The guide below presumes that you understand the basics of how to [[Mod_structure|create a mod]]. This page should also help modders understand how to change some more specific aspects of a country.


== 快速制作 ==
== Quick checklist ==
{{SVersion|1.8}}
{{anchor|Quick check-list}}
如果你想在模组中创建一个新国家,可以参考以下快速制作教程:
*Define a unique 3-character country tag in any {{path|custom=1|<yourmod>/common/country_tags/*.txt}} file.
* 定义一个独一无二的三英文字符国家tag。
*Create a file in the {{path|custom=1|<yourmod>/common/countries}} folder with the same name as the one that's linked in the country tag definition.
* 在''< 你的模组>/common/countries''中新建文件。
*Define the country leader and optionally advisors and unit leaders in {{path|custom=1|<yourmod>/common/characters}}
* 在''< 你的模组>/history/countries'' 中新建文件。
*Create a .txt file in the {{path|custom=1|<yourmod>/history/countries}} folder, with the first three letters of the filename being the country's tag, and fill it with the starting historical information.
* 在''< 你的模组>/localisations''中增加本地化。
*Create an OOB file in {{path|custom=1|<yourmod>/history/units}} and load it within the previous country history file. '''Buildings will not be assigned to the country properly otherwise.'''
* 在''< 你的模组>/gfx/flags''中为每一种意识形态添加一个大,中,小号的旗帜。
*Add the country's name to any {{path|custom=1|<yourmod>/localisation/english/*_l_english.yml}} file that uses the UTF-8-BOM encoding{{cref|a}}.
* 可选:在''< 你的模组>/history/units''中创建OOB文件。
*Add a large, medium and small flag for each ideology to the {{path|custom=1|<yourmod>/gfx/flags}} folder.
* 可选:把国家加入到游戏中。
*Optionally add the country to the game by assigning it states within the {{path|custom=1|<yourmod>/history/states/*.txt}} files.


== 国家标签——tag ==
== Tag ==
{{SVersion|Timeless}}
{{Anchor|Country tag}}
每个国家都要一个三英文字符的tag,这是你在你的模组中唯一指定国家的内容。所有国家的TAG都得是独一无二的并且为三个大写英文字母. 任何国家都不能跟别的国家有一样的TAG
Countries need a 3-character country tag. This is how a country is referred to in all of the game's script. All country tags must be unique. A country must not share a tag with any other country.


要建立一个新TAG,就往''< 你的模组>/common/country_tags'' ( 或者把原有的文件改了) 添加新信息并且再写上像这样的东西:
To create a tag, add a new file to {{path|custom=1|<yourmod>/common/country_tags}} (or edit an existing file, though creating a new one is preferable due to making the mod easier to make compatible to newer game versions) and add a line similar to <code>SCO = "countries/Scotland.txt"</code>, where <code>countries/Scotland.txt</code> is the address of the country file that will be created/edited, located in {{path|custom=1|<yourmod>/common/countries}}. There is no need for this file to be unique: multiple countries may use the exact same {{path|custom=1|common/countries/}} file in its definition.
SCO = "countries/Scotland.txt"
如上所示。在这里,SCO的地方必须为三大写英文字母,而在后面的txt则可以是任意长度的大写小写,但不能有中文。


你想创建或者改动国家标签的文件位于''< 你的模组>/common/countries''
There are some country tags that must be avoided, as they will cause in-game confusion whether something is meant to be a reference to a country or not. Their mere existence can cause other code to break. A list of them is the following:
{|class = "wikitable sortable" width = "100%"
!width = "4%" style = "text-align:center;" | Tag
!width = "96%" | Reason to avoid
|-
|style = "text-align:right;" | NOT
|Used as a [[Scopes#Flow control tools|flow control tool]] that comes up as true when any of the triggers within is false.
|-
|style = "text-align:right;" | AND
|Used as a [[Scopes#Flow control tools|flow control tool]] that comes up as true when all of the triggers within are true.
|-
|style = "text-align:right;" | TAG
|Used as a [[Conditions#tag|trigger]] that checks the country being chosen.
|-
|style = "text-align:right;" | OOB
|Used within country history files as an argument deciding the loaded order of battle file, deciding the amount of divisions and where they are located.
|-
|style = "text-align:right;" | LOG
|Used as an [[Effect#log|effect]] or a [[Conditions#log|trigger]] that writes the specified argument within the [[Modding|user directory]]'s {{path|logs/game.log}} file or in console if it is open.
|-
|style = "text-align:right;" | NUM
|Used for [[arrays]] in order to count the amount of elements within them. This will break the resistance system as the [[Conditions#Scripted triggers|scripted trigger]] responsible for deciding when resistance must be enabled utilises this.
|-
|style = "text-align:right;" | RED
|Used within custom map modes as a temporary variable deciding how red the state should be. This will make every custom map mode always have 0 as the red value.
|-
|style = "text-align:right;" | Numbers
|Numbers meaning an entirely numeric country tag such as <code>123</code>, although the game prevents tags from ''beginning'' with numbers. While numbers can be used within country tags (such as <code>D01</code>), if it's entirely numeric there might be confusion whether, for example, <code>123</code> would refer to a state ID or a country tag.
|}


== 国家文件 ==
A file can have <code>dynamic_tags = yes</code> within of itself, which marks every country defined in that file afterwards to be marked as a dynamic country. A dynamic country is one that doesn't have explicit data defined, but instead copies it on the fly from an original country that it branches off. This is most commonly used within civil wars, with [[Effect#start_civil_war|the effect to start one]] auto-generating one. '''If the mod doesn't have enough dynamic countries defined, the game will crash''' if there is a sufficient amount of non-dynamic countries, with [[Troubleshooting#Crash data log|the last read file being marked as map/cities.txt or a savegame]] (Though that crash is not necessarily caused by the lack of dynamic countries).
{{SVersion|1.8}}


在''<你的模组>/common/countries'' 文件夹中创建一个新的文件.建议复制一个原版中的国家的文件来再改成你要的。
== Country file ==


===  单位模型 ===
The country tag list refers to a file in the {{path|custom=1|<yourmod>/common/countries/}} folder. The file sets the graphical culture and the default colour which may be overwritten by a <code>colors.txt</code> entry. An example of a file is as such:
<pre>graphical_culture = commonwealth_gfx
graphical_culture_2d = commonwealth_2d
color = rgb { 2 10  222 }</pre>


在这里设置设置国家单位模型。比如苏格兰是:
Graphical culture defines the set of graphics used for units, while the 2D graphical culture defines portraits used for aces and generic advisors. A list can be found in {{path|common/graphicalculturetype.txt}}. For Scotland this would be the following:
<pre>graphical_culture = commonwealth_gfx
graphical_culture_2d = commonwealth_2d</pre>


  graphical_culture = commonwealth_gfx
<code>color = rgb { 2 10 222 }</code> is the country's default colour on the political map mode (overridden by a colors.txt entry if one exists. '''This requires specifying a colour model, such as rgb or hsv, to work.'''). The [[Wikipedia:RGB colour model|RGB colour model]] uses numbers on the scale from 0 to 255 or 0 to 1 (using exactly 1 is considered to be on the second scale), while the [[Wikipedia:HSV colour model|HSV colour model]] uses numbers on the scale from 0 to 1.
  graphical_culture_2d = commonwealth_2d


===  颜色 ===
Additionally, an entry can be made in {{path|custom=1|<yourmod>/common/countries/colors.txt}} in order to specify more country colours. The file '''has to be called colors.txt''', and so it will overwrite the base game file if the entry is added. An entry in the file is formatted as the following:
<pre>SCO = {
   color = rgb { 2 10  222 }
   color_ui = rgb { 255 255 155 }
}</pre>


这里设置的是国家在地图上的颜色。 它使用 [[wikipedia:RGB color model|RGB色阶]]
<code>color</code> will overwrite the country's colour on the political map, while <code>color_ui</code> will be used externally, such as in the map generated with the {{key press|ctrl}} + {{key press|F10}} hotkey or the history viewer tool in {{path|tools/history_viewer/}}. Colours may also be specified in the [[Wikipedia:HSL and HSV|HSV color model]], in which case <code>rgb</code> will need to be replaced with <code>hsv</code>. The <code>color_ui</code> is also used in order to colour in the background of the country's division counter, if the option is set to be country-specific. If a country doesn't have a color_ui entry, it defaults to a grey colour.<br/>
In HSV, hue, saturation, and value are each on the scale from 0 to 1, using decimals to show the value.


color = { 2  10  222 }
After reading the colour from the file, the saturation and value of the colour will be multiplied by 0.6 and 0.8 respectively by default<ref><code>NDefines.NGraphics.COUNTRY_COLOR_SATURATION_MODIFIER = 0.6</code> and <code>NDefines.NGraphics.COUNTRY_COLOR_BRIGHTNESS_MODIFIER = 0.8</code> in [[Defines]]</ref>. This means the colour appearing in-game will be slightly darker and less saturated (closer to a shade of grey) than defined in the file. In order to have a country colour in HSV have a higher saturation or value than 0.6 or 0.8 respectively, a value larger than 1 can be used as long as it'll end up between 0 and 1 after the application of modifiers. For example, a pure red country colour can be simulated in HSV with <code>color = hsv { 0 1.66 1.25 }</code>. After applying the offsets, this will result in a saturation of 0.996 and a value of 1, being as close to pure red as possible. <br/>
For RGB, this calculation is harder: "Saturation" defines the difference between the colour with the largest value and the others (changing it does not change the largest colour's value), while "Value" manifests in multiplying every colour's value by that. For replicating a desired value, let <math>V_M</math> represent the maximum value of colour. As such, each colour's value, originally <math>V</math>, by default should be <math>\frac{5}{12}\left(5V-2V_M\right)</math>. With arbitrary Value/Saturation modifiers (represented with <math>M_V</math> and <math>M_S</math>), it's <math>\frac{1}{M_V}\left(\frac{V}{M_S}+V_M*\frac{M_S-1}{M_S}\right)</math>. For example, pure green (i.e. what <code>rgb { 0 255 0 }</code> intends), would be represented well with <code>rgb { -107 425 -107 }</code> plugging numbers into that formula. Indeed, entering this value into the game, the result is exactly pure green, far closer to it than <code>rgb { 0 255 0 }</code> or {{nowrap|<code>rgb { 0 425 0 }</code>}} are.<br/>
These modifiers do not get applied when using the <code>tag_color</code> [[console command]].


=== colors.txt ===
==History==
{{SVersion|1.13}}
{{Anchor|Country history}}
Create a file in the {{path|custom=1|<yourmod>/history/countries}} folder. Alternatively, copy, rename, and edit a similar file. The filename typically follows the format of <code>TAG - country name.txt</code>, e.g. "SCO - Scotland.txt". The important aspect is that the '''first three letters of the filename must be the same as the country's tag''' in order to be loaded, without taking capitalisation into account. Everything after the tag is purely a comment and can be made into anything: "SCO - Bahrain.txt" will work just as well for SCO as would "SCO_qatar.txt".<br/>
This file contains information about the starting attributes of the country for each scenario, such as the capital and the ruling party. They serve as an effect block, so most effects can be used within of them. '''These files get executed in the order of the countries in the country_tags file,''' which may come into play for subjects, as puppeting changes party popularity.


确保国家颜色被写入了''<你的模组>/common/countries/colors.txt'':
A country may have more than one history file, in which case each one will be used.<br/>
As a note, '''any unnecessary closing bracket will stop the execution of the file prematurely''', leading anything afterwards to not be read. If nothing in the history file after a certain point applies, this is likely the cause.


SCO = {
<code>capital = 121</code> defines the capital state. The province with the most victory points within that state will get used as the capital. In case of overlap, the lowest province ID out of the possible choices gets chosen. In this case, 121 is the state Lothian, which contains Edinburgh as the largest victory point. To reiterate, '''this must be a state ID, not a province ID.'''
  color = rgb { 2  10  222 }
  color_ui = rgb { 255 255 155}
}


`color_ui` 通常是比该国家普通颜色更深的色彩,因为这是用于涂边界的 (如果边界看起来很丑,那就再看看你文件有没写错). 颜色也能用 [[Wikipedia:HSL and HSV|HSV形式]] 写指定
===Order of battle===
{{See also|Division modding}} {{anchor|oob}} {{anchor|OOB}}
Orders of battle are used for the starting military information: templates, divisions that use them, as well as the starting navy and airforce. Traditionally, the starting equipment production is put there within instant_effect while equipment variants are within country history, however instant_effect in orders of battle is an effect block, similarly to country history, so it's not necessary to divide them in this manner. As a byproduct of how the engine works, '''countries with no order of battle will have broken buildings''': any building [[Effect#add_building_construction|constructed via an effect]] will not apply to the country immediately, rendering them impossible to use until the consumer goods percentage changes or a savefile gets reloaded. Orders of battle can also contain information on what national focus the country is ''currently'' doing, however any already-completed focuses must be in country history.


==国家历史==
There are several arguments/effects that can be used in country history. Each one is constructed in the manner of <code>oob = "filename"</code>, which would link to the {{path|custom=1|<yourmod>/history/units/filename.txt}} file. The .txt extension is omitted from the filename necessary to be put in. '''The filename of the order of battle is irrelevant as long as it matches up with the one loaded within the country history file.''' These are what can be used:<br/>
{{SVersion|1.8}}
*<code>oob = "SCO_1936"</code> is the traditional way to load a land order of battle, assigning it to the country to be loaded before the game's start. However, ''this is not an effect but an argument in country history'', meaning that it can't be used within other effect blocks (e.g. if statements).
*<code>set_oob = "SCO_1936"</code> is identical to the prior way: assigning a land order of battle to the country to be loaded before the game's start. However, ''this is an effect'', meaning it can indeed be used in if statements. This is required to use within if statements, such as if different orders of battle are used depending on the DLC, however this can be used outside of if statements.
*<code>set_naval_oob = "SCO_1936_naval_legacy"</code> and <code>set_air_oob = "SCO_1936_air_bba"</code> are similar to the previous one, however are instead used for the specified branches of the military. These will overwrite any other previously-defined order of battle of the same type.
*<code>load_oob = "my_template_shared"</code> is an effect and '''is not recommended to be used in history'''. It, instead, loads the order of battle ''immediately'', which can lead to errors if it's put before technologies necessary to load the order and can lead to crashes if the order contains any divisions. However, this can be used to load orders of battle ''after'' the first-defined orders. This can be used for compatibility reasons as to not overwrite any unnecessary files or to re-use the same file containing templates, starting effects, or starting focus information across different countries to be loaded after the base order of battle.


在 <你的模组>/history/countries> 文件夹中创建该文件. 或者复制个原版中国家的文件,重命名并更改为你的。文件名应该是<该国tag - 该国名字>, 比如"SCO - Scotland".这个文件包含了该国家的历史以及默认属性


===首都===
Naval and air units are divided into two separate orders of battle. This is because {{icon|mtg|1}} changes the naval system and {{icon|bba|1}} changes the air system enough that any orders of battle created for the base game will not be compatible with the DLC or vise-versa. At times, the land order of battle can also be divided into multiple, most commonly if there are any references to tank equipment within <code>force_equipment_variants</code> or starting equipment production. For each one of these, the same [[Effect#If statements|if statements are used]]:
在这写入国家首都. 要用地区ID(state)而非省份(province)ID指定首都. 这样的话,121是洛锡安地区,包含爱丁堡
capital = 121
 
===战斗部署===
这些文件会被链接到'Order of Battle' (OoB)记录了部队数量和位置、经验及装备状况, 还有开局国家拥有的空军联队。开始时的生产状况及部队编制也被记录在那儿。每个国家都需要链接到OoB, 不过如果那个国家将在之后被吞并那么就别给他写OoB文件了
oob = "SCO_1936"
为了方便调用, 海军通常被编入单独的OoB. 另外,因为'炮手就位' DLC对海军改动很大,一个国家通常都有两个独立的海军OoB, 一个就是为了给那个DLC的, 另一个就是给没买那个DLC的人, 使用旧的海军系统(OOB通常以a _legacy为后缀区分)
<pre>
<pre>
if = {
if = {
limit= { has_dlc = "Man the Guns" }
   limit = { has_dlc = "Man the Guns" }
set_naval_oob = "SCO_1936_naval_mtg"
   set_naval_oob = "SCO_1936_naval_mtg"
else = {
}
set_naval_oob = "SCO_1936_naval_legacy"
if = {
}
   limit = { NOT = { has_dlc = "Man the Guns" } }
   set_naval_oob = "SCO_1936_naval_legacy"
}
if = {
   limit = { has_dlc = "By Blood Alone" }
   set_air_oob = "SCO_1936_air_bba"
}
if = {
   limit = { NOT = { has_dlc = "By Blood Alone" } }
   set_air_oob = "SCO_1936_air_legacy"
}
}
</pre>
</pre>
===科研槽===
Note that <code>else</code> only works in its nested form in history files.
写入开局时国家的科研槽数量。一般大国有4个,北美和欧洲的小国有两个,其他地方的小国也是两个。如果不写就默认是两个
set_research_slots = 3


=== 稳定度===
===Effects===
写入国家开局时的稳定度百分比。在游戏中会把文件中的数值×100,所以最大是1(游戏中为100)最小是0(游戏中为0),如下所示,现在在游戏中显示的稳定度为70%
{{main|Effects}}
set_stability = 0.7
These are [[effects]] which are traditionally put in history files of the country to be executed on startup, meaning that they can be used elsewhere as well. '''Any other [[Effect|effect within the list]] can be used as well.'''


===战争支持度===
<code>set_research_slots = 3</code> defines the amount of research slots a country has access to at the start. Normally, major powers have 4 slots, minor countries in North America and Europe have 3, and minor countries in the rest of the world have 2. Defaults to 2 slots if not specified.
写入国家开局时的战争支持度百分比。在游戏中会把文件中的数值×100,所以最大是1(游戏中为100)最小是0(游戏中为0)。如下所示,现在游戏中显示的战争支持度为50%
set_war_support = 0.5


===民族精神和内阁===
<code>set_stability = 0.7</code> defines the {{icon|stability|1}} that a country will have at the start of the game, defined on the scale from 0 to 1. The prior example of 0.7 will lead to the country starting with 70% stability.
设置国家开局时的内阁 (民族精神 顾问 制造商和法案). 这些东西的清单在 {{path|common/ideas}}<br>


不过注意,如果你不添加任何内阁. 国家开局时就是没有顾问,民用经济和志愿制兵役
<code>set_war_support = 0.5</code> defines the {{icon|war support|1}} that a country will have at the start of the game. Similar to stability, it is defined on the scale from 0 to 1, the prior example of 0.5 being 50%.
这是个例子:
 
<pre>
<pre>add_ideas = {
add_ideas = {
   henschel
henschel
   GER_autarky_idea
GER_autarky_idea
   #laws #Remember that the sharp sign is used to mark comments.
#laws
   war_economy
war_economy
   extensive_conscription
extensive_conscription
}</pre>This is the list of [[ideas]] that the country starts with in the game, including national spirits, design companies, and laws. Ideas are defined in {{path|common/ideas}}. If starting laws aren't defined, then the country will start with the laws of {{icon|volunteer only|1}}, {{icon|export focus|1}}, and {{icon|civilian economy|1}}.
}
 
</pre>
<pre>set_technology = {
===科技===
   infantry_weapons = 1
这里写入国家开局时的科技等级。科技列表在 {{path|common/technologies}}.
   infantry_weapons1 = 1
<pre>
   gw_artillery = 1
set_technology = {
   interwar_antiair = 1
infantry_weapons = 1
   fuel_silos = 1
infantry_weapons1 = 1
   basic_train = 1
tech_engineers = 1
}</pre>
tech_mountaineers = 1
This defines the starting technologies of the country. A list of technologies can be found in {{path|common/technologies/}}. It is notable that, similarly to orders of battle, several technologies depend on DLC, such as the {{icon|mtg|1}} naval tech and {{icon|nsb|1}} tank tech. In that case, an if statement needs to be used in order to set only the technologies that the country has access to, such as, using it in a conjunction with the prior naval oob:
motorised_infantry = 1
gw_artillery = 1
interwar_antiair = 1
gwtank = 1
basic_light_tank = 1
basic_heavy_tank = 1
early_fighter = 1
fighter1 = 1
early_bomber = 1
tactical_bomber1 = 1
strategic_bomber1 = 1
CAS1 = 1
naval_bomber1 = 1
}
</pre>
记住,有炮手就位DLC的玩家需要一份不同的科技文件给海军~所以你得给海军科技设置两次,就像这样:
<pre>
<pre>
if = {
if = {
limit = { not = { has_dlc = "Man the Guns" } }
   limit = { has_dlc = "Man the Guns" }
set_technology = {
   set_technology = {
early_submarine = 1
     basic_naval_mines = 1
early_destroyer = 1
     submarine_mine_laying = 1
}
     early_ship_hull_light = 1
set_naval_oob = "SCO_1936_naval_legacy"
     early_ship_hull_submarine = 1
     basic_ship_hull_submarine = 1
     basic_battery = 1
     basic_torpedo = 1
     basic_depth_charges = 1
   }
   set_naval_oob = "SCO_1936_naval_mtg"
}
}
if = {
if = {
limit = { has_dlc = "Man the Guns" }
   limit = { NOT = { has_dlc = "Man the Guns" } }
set_technology = {
   set_technology = {
basic_naval_mines = 1
     early_submarine = 1
submarine_mine_laying = 1
     early_destroyer = 1
early_ship_hull_light = 1
   }
early_ship_hull_submarine = 1
   set_naval_oob = "SCO_1936_naval_legacy"
basic_ship_hull_submarine = 1
basic_battery = 1
basic_torpedo = 1
basic_depth_charges = 1
}
set_naval_oob = "SCO_1936_naval_mtg"
}
}
</pre>
</pre>
===其他(可选)===
'''写入初始政治点数'''
<pre>
add_political_power = 500
</pre>
'''写入初始运输船数量'''.


注意: 如果这在同一文件出现了数次会被叠加
<code>recruit_character = TAG_character_name</code> is used to recruit [[#Starting characters|the specified character]]. This includes country leaders, commanders, admirals, and advisors. Country leaders that are recruited ''after'' setting political information can fail to appear, so it's recommended to recruit them before setting any political information. If multiple country leaders fall under the same political party, the game will place the first-recruited one as its leader. The recruitment will fail if the effect is placed as the last line in the file: there must be at least one line after the recruitment, even if it's empty.
<pre>
set_convoys = 100
</pre>
''' 写入初始科研加成'''. 


有了这一行代码,可以让国家在开局时就默认有一个科研加成。 比如苏联的历史文件中就用了这:
====Diplomacy-related effects====
<pre>
add_tech_bonus = {
bonus = 1.0
uses = 2
category = armor
}
</pre>
'''战争化借口:'''


有了这行代码可以让当前国家在开局就有一个对某国的战争借口。
In order to make the country start as a subject, the following can be put in the history file:
<pre>
<pre>ENG = {
create_wargoal = {
   if = {
type = take_state_focus
     limit = {
target = POL
       has_dlc = "Together for Victory"
generator = { 72 88 90 87 86 } # Zaolzie Krakow Kielce Lodz Poznan
     }
}
     set_autonomy = {
</pre>
       target = SCO
'''[[Cosmetic tag modding|国家标志]]''':
       autonomous_state = autonomy_integrated_puppet
     }
     else = {
       puppet = SCO
     }
   }
}</pre>'''Since the history files get loaded in a specific order, it is preferable to put it in the subject's history file, as to avoid the case where the overlord's file gets loaded after the subject's, which'll make the puppeting reset the politics of the subject. For this reason, <code>set_autonomy</code> must also be set before the political party and popularities of the subject.''' The if statement is there to ensure that the integrated puppet is only there with {{icon|tfv|1}}, as that autonomous state is not available otherwise. A list of autonomous states can be found in {{path|common/autonomous_states/*.txt}} files.


用于更加进阶的模组制作。可以用于开局就标志一个国家。
A faction can be created with <code>create_faction = localisation_key</code>. The localisation key will be used to define the name of the faction, defined in any {{path|custom=1|<yourmod>/localisation/english/*_l_english.yml}} file.<br/>
<pre>
Members are added to the faction with <code>add_to_faction = IRE</code> within the faction leader's history file. Although puppets usually get added to the faction automatically, it is recommended to add them manually as well.
set_global_flag = earhart_disappeared
set_country_flag = sudetenland_acquired
</pre> 让一个国家毫无条件的触发新闻。<pre>
USA = {
country_event = { id = usa.50 days = 2 } #id为事件的id,days是多少天后触发
country_event = { id = usa.51 days = 2 }
}
</pre>
Opinion modifiers:
<pre>
add_opinion_modifier = { target = POL modifier = refused_anti_comintern_pact_opinion }
</pre>
Modifiers have their effects defined in {{path|common/opinion_modifiers}}
===外交===
如果一个国家在开局时就与别的国家有交流,那么在这里定义。建议一个定义内容只写在一个文件中。(比如阵营领导人只写在阵营领导人的文件里,阵营中的次要国家就不必要写了)


====阵营====
In order to use technology sharing groups, <code>add_to_tech_sharing_group = my_tech_group</code> can be used in each country's history file. This requires the {{icon|tfv|1}} DLC check (always positive) in order to work properly. Technology groups are defined in {{path|common/technology_sharing/*.txt}} files. [[Technology modding#Technology sharing groups|Additional details on the technology groups can be found on the dedicated article]].
在国家文件中写下这行代码,将会让游戏一开始就有这个阵营,并且国家默认加入其中,是其成员。
create_faction = Clanintern
在上一行的基础上,再加上这一行,则表示它是目前阵营的领导人。
add_to_faction = IRE
如果阵营中的某个国家有傀儡国,那也应该加入到阵营中,以防止不必要的bug。


==== 傀儡国====
====Politics-related effects====
如果玩家有“共同胜利”DLC,那么傀儡国的定义如下:
<pre>set_popularities = {
set_autonomy = {
   democratic = 80
target = ENG
   communism = 10
autonomous_state = autonomy_integrated_puppet
   fascism = 10
}
}</pre> This defines the starting party popularities, on the scale from 0 to 100. If an ideology is left out, then it will be assumed to have 0% popularity. '''If it doesn't add up to 100, then the popularities will fail to be set.'''
如果没有,则是如下:
<pre>set_politics = {
puppet = ENG
   ruling_party = neutrality
为了使有DLC和没有DLC的玩家都可以正常使用,因此你可以使用if语句:
   last_election = "1932.11.8"
if = {
   election_frequency = 48 # Every 4 years
limit = {
   elections_allowed = yes
has_dlc = "Together for Victory"
}</pre> This defines the starting political situation of the country, with the ruling party and details on elections. Notably, the election frequency is defined in months.
}
==== Variants ====
set_autonomy = {
Special variants on equipment available for this country from the start can be put in, defining the starting equipment upgrades or modules. Since this can depend on DLC, for ships, tanks, and airplanes, a DLC check can be used as the following:
target = ENG
<pre>if = {
autonomous_state = autonomy_integrated_puppet
   limit = { has_dlc = "Man the Guns" }
}
   create_equipment_variant = {
else = {
     name = "Celtic Series"
puppet = ENG
     type = ship_hull_submarine_1               # See list in common/units/equipment
}
     name_group = SCO_SS_HISTORICAL              # Defines names used for ships of this variant, defined in common/units/names_ships/
}
     modules = {
注意:puppet = ENG指的是当前国家的傀儡是ENG而并非是当前国家被ENG傀儡。
       fixed_ship_torpedo_slot = ship_torpedo_sub_1     # Module slots for equipment types are defined in common/units/equipment
       fixed_ship_engine_slot = sub_ship_engine_1      # While modules themselves are defined in common/units/equipment/modules
       rear_1_custom_slot = empty
     }
     obsolete = yes                      # Marks as obsolete, changing the UI.
   }
}
if = {
   limit = { NOT = { has_dlc = "Man the Guns" } }
   create_equipment_variant = {
     name = "Celtic Series"
     type = submarine_1                    # Note different equipment type due to no MtG.
     upgrades = {
       ship_reliability_upgrade = 1             # See list in common/units/equipment/upgrades
       sub_engine_upgrade = 1
       sub_stealth_upgrade = 1
       sub_torpedo_upgrade = 1
     }
     obsolete = yes
   }
}</pre>


====其他外交行动====
=== Date-dependent history ===
'''保证独立:'''<br> 这行代码可以让当前国家保证另一个国家的独立:
{{Anchor|Adding history for other bookmarks}}
In order to assign a part of the history file to only apply on start dates later than a certain date, a date block is used. It's formatted in the manner of <code>YYYY.MM.DD = { ... }</code> and accepts the same attributes and effects that may be used elsewhere in the file:
<pre>
<pre>
give_guarantee = FRA
1939.1.1 = {
   oob = "SCO_1939"
   set_technology = {
     atomic_research = 1
     nuclear_reactor = 1
     nukes = 1
   }
}
</pre>
</pre>
在这里你只需要修改FRA为任意国家TAG即可
In particular, this would ''replace'' the used order of battle with {{path|history/units/SCO_1939.txt}} and ''add'' atomic_research, nuclear_reactor, and nukes technologies to the ones the country already has researched.<br/>
This will only apply on the start dates that are '''strictly''' later than the defined timestamp.
==== Useful effects ====
While any [[#effects|effects]] can be used, same as in regular history, the following are specifically useful for later start dates:


'''互不侵犯条约:'''
In order to simulate completion of the national focus tree, the two effects are used: [[Effect#unlock_national_focus|unlock_national_focus = focus_name]], which bypasses the focus without granting effects, and [[Effect#complete_national_focus|complete_national_focus = focus_name]], which fully completes the focus, granting the effects.
<pre>
diplomatic_relation = { country = USA relation = non_aggression_pact }
</pre>
在这里你只需要修改USA为任意国家TAG即可。


'''初始贸易:'''<br> 这行代码可以让国家开局就和任意国家进行贸易并添加资源。
The [[Effect#diplomatic_relation|diplomatic_relation effect]] can be used in order to cancel previously applied diplomatic relations, such as guarantees or military access. Ideas would be removed with the [[Effect#remove_ideas|remove_ideas effect]], applied in the exact same manner as <code>add_ideas</code>
<pre>
create_import = {
resource = tungsten
factories = 1
exporter = SWE
}
</pre>
改变文件中的SWE可以改变贸易国家,改变factories后面的数字可以该表交易物品的数量(前提是那个国家要有这么多),改变resource后面的内容可以修改交易的物品。


'''军事通行权:'''
In order to replace the country leader, the [[Effect#promote_character|promote_character effect]] can be used as <code>promote_character = TAG_character_name</code>. However, make sure that the character is recruited beforehand and has a country leader role within their definition. Recruitment is allowed within a date-block.
===Full file example===
{{VisibleCollapse|<pre>capital = 121
oob = "SCO_1936"


这行代码可以让当前国家在开局就给目标国家军事通行权。
set_research_slots = 3
<pre>
set_stability = 0.7
give_military_access = IRE
set_war_support = 0.5
</pre>改变IRE就可以了。


====科技共享====
recruit_character = SCO_ronald_mcdonald # Before set_politics
If the player has 'Together for Victory' one can add the country to a tech sharing group:
add_to_tech_sharing_group = haggis_investigators
An if-statement as shown above will be required to limit it to 'Together for Victory' owners and to prevent bugs with those that don't own it.


<nowiki>#</nowiki>目前这行代码并不完整,不推荐使用。
add_ideas = {
   henschel
   GER_autarky_idea
   #laws
   war_economy
   extensive_conscription
}


=== 设定党派支持度===
set_technology = {
定义当前国家不同意识形态党派的支持率:
   infantry_weapons = 1
<pre>
   infantry_weapons1 = 1
set_popularities = {
   gw_artillery = 1
democratic = 5
   interwar_antiair = 1
communism = 80
   early_fighter = 1
fascism = 10
   early_bomber = 1
neutrality = 5
   fuel_silos = 1
   basic_train = 1
}
}
</pre>你可以添加或删减任何意识形态,但是其总支持率必须要等于100.


=== 设定政治===
if = {
定义当前国家的执政党和大选。
   limit = { has_dlc = "Man the Guns" }
<pre>
   set_technology = {
set_politics = {
     basic_naval_mines = 1
ruling_party = communism #执政党的意识形态
     submarine_mine_laying = 1
last_election = "1932.11.8" #上次大选时间
     early_ship_hull_light = 1
election_frequency = 48 #大选间隔时间,单位:月
     early_ship_hull_submarine = 1
elections_allowed = no #是否有下次大选,no为没有,yes为有
     basic_ship_hull_submarine = 1
     basic_battery = 1
     basic_torpedo = 1
     basic_depth_charges = 1
   }
   create_equipment_variant = {
     name = "Celtic Series"
     type = ship_hull_submarine_1
     name_group = SCO_SS_HISTORICAL
     modules = {
       fixed_ship_torpedo_slot = ship_torpedo_sub_1
       fixed_ship_engine_slot = sub_ship_engine_1
       rear_1_custom_slot = empty
     }
     obsolete = yes
   }
   set_naval_oob = "SCO_1936_naval_mtg"
}
}
</pre>
if = {
===国家领导人===
   limit = { NOT = { has_dlc = "Man the Guns" } }
指定一个国家的领导人。正常来说,你只需要制作一个国家开局时的意识形态领导人就足够了。因为别的领导人可以随机产生。不过如果你制作了别的意识形态党派的领导人,那么在非执政党状态下,他们是党派领导人。为执政党时为领导人。
   set_technology = {
create_country_leader = {
     early_submarine = 1
name = "Ronald McDonald" #领导人名字
     early_destroyer = 1
desc = "POLITICS_RONALD_MCDONALD_DESC" #领导人介绍
   }
picture = "gfx/leaders/Europe/Portrait_Europe_Generic_land_3.dds" #领导人图片
   create_equipment_variant = {
expire = "1965.1.1" #领导人退休时间
     name = "Celtic Series"
ideology = fascism_ideology #领导人子意识形态
     type = submarine_1
traits = { #领导人特质
     upgrades = {
scary_clown
       ship_reliability_upgrade = 1
}
       sub_engine_upgrade = 1
}
       sub_stealth_upgrade = 1
你在制作领导人图片时,导出的格式推荐为dds格式(当然也可以是png), 这可能需要用到[https://www.gimp.org/ Gimp]或者 [http://www.getpaint.net/index.html Paint.net]来制作。
       sub_torpedo_upgrade = 1
 
     }
领导人特质可以在 {{path|common/country_leader}} 找到。
     obsolete = yes
 
   }
===将军===
   set_naval_oob = "SCO_1936_naval_legacy"
在当前国家文件中写下这些,就可以让国家拥有一个陆军将军:
<pre>
create_corps_commander = {
name = "Sean McHaggis" #名字
portrait_path = "gfx/leaders/Europe/Portrait_Europe_Generic_land_4.dds" #图片
traits = { panzer_leader fortress_buster } #特质
attack_skill = 4 #攻击能力
defense_skill = 2 #防御能力
planning_skill = 1 #计划速度
logistics_skill = 2 #后勤速度
}
}
</pre>
if = {
这一些则是海军将领:
   limit = { has_dlc = "By Blood Alone" }
<pre>
   set_air_oob = "SCO_1936_air_bba"
create_navy_leader = {
   set_technology = {
name = "James McSeafarer"
     aa_lmg = 1
portrait_path = "gfx/leaders/Europe/Portrait_Europe_Generic_navy_1.dds"
     engines_1 = 1
traits = { blockade_runner superior_tactician }
     engines_2 = 1
attack_skill = 3
     early_bombs = 1
defense_skill = 3
     aircraft_construction = 1
maneuvering_skill = 5
     iw_small_airframe = 1
coordination_skill = 2
     iw_medium_airframe = 1
     iw_large_airframe = 1
     basic_medium_airframe = 1
     basic_small_airframe = 1
   }
}
}
</pre>
if = {
===变种型号(可选)===
   limit = { NOT = { has_dlc = "By Blood Alone" } }
Special variants on equipment available for this country from the start can be defined as well:
   set_air_oob = "SCO_1936_air_legacy"
create_equipment_variant = {
   set_technology = {
name = "Haggis Class"
     early_fighter = 1
type = submarine_1
     cv_early_fighter = 1
upgrades = {
     cv_naval_bomber1 = 1
sub_engine_upgrade = 3
     naval_bomber1 = 1
sub_stealth_upgrade = 2
     early_bomber = 1
sub_torpedo_upgrade = 2
     CAS1 = 1
}
   }
}
<pre>
create_equipment_variant = {
name = "Scotfire"
type = fighter_equipment_1
upgrades = {
plane_gun_upgrade = 3
plane_range_upgrade =
plane_engine_upgrade = 3
plane_reliability_upgrade = 3
}
}
}
create_equipment_variant = {
 
name = "Tanktoon 2"
ENG = {
type = light_tank_equipment_2
   if = {
upgrades = {
     limit = {
tank_gun_upgrade = 5
       has_dlc = "Together for Victory"
tank_armor_upgrade =
     }
tank_engine_upgrade = 2
     set_autonomy = {
tank_reliability_upgrade = 0
       target = SCO
}
       autonomous_state = autonomy_integrated_puppet
obsolete = yes #optional, marks the unit as obsolete and hides the unit from the UI
     }
   }
   else = {
     puppet = SCO
   }
}
}
</pre>


== 本地化 ==
{{SVersion|Timeless}}
通过在下面的介绍路径来添加本地化文件(最好去原版复制一个文件过来然后改成别的名字)
<pre>
<你的模组>/localisation/<任意名字>_l_english.yml
</pre>
如果你希望翻译成别的语言,比如说变成修改成法语,你只需要修改english为French就可以了


对于国家来说有许多种不同的意识形态党派会上台,因此你最好为国家的每一种意识形态都取上名字:<pre>
set_popularities = {   # Notice how set_popularities is after puppeting. Otherwise would lead to puppeting resetting politics.
l_english:
   democratic = 80
SCO_communism:0 "苏格兰人民共和国"
   communism = 10
SCO_communism_DEF:0 "苏格兰人民共和国" # 英文中,这一行的意思是国家名称在新闻中是什么样的
   fascism = 10
SCO_fascism:0 "苏格兰帝国"
}
SCO_fascism_DEF:0 "苏格兰帝国"
set_politics = {
SCO_ADJ:0 "苏格兰" #不知道是什么意识形态时显示的
   ruling_party = democratic
</pre>
   last_election = "1932.11.8"
当然如果你是中文的话, 你只需要为每一种意识形态制作一行就可以了,就像下面这样:<pre>
   election_frequency = 48 # Every 4 years
l_english:
   elections_allowed = yes
SCO_communism:0 " 苏格兰人民共和国"
}</pre>}}
SCO_fascism:0 "苏格兰帝国"
</pre>
因为我们是不需要像英语那样那么多修饰词的。


'''注意:'''不要把文中的l,这是一个小写的L,很多人会误认为i(I)或者1,这是一个很常见的错误,如果你的本地化一直不显示,这很有可能是一个原因,当然最好还是从原版中复制一个文件过来修改名称。
==Flag==
== 旗帜==
{{SVersion|Timeless}}
{{SVersion|Timeless}}
每个国家都至少要有一面意识形态国旗,如果你不制作任何国旗,那么游戏中将会显示一个黑面。我们推荐你最好为每一种意识形态都添加上国旗,这样可以使你的模组更加完整。每种意识形态一个旗帜,并且每种需要三个尺寸:标准、中(Medium)、小(Small)。所有旗帜需要以[[wikipedia:Truevision TGA|TGA 格式]] 保存,文件名包括国家的tag和旗帜所用于的意识形态。(例如:ABC_neutrality.tga)文件格式应该是32位、无压缩的。
The flags representing a country are stored in {{path|gfx/flags}} and its subfolders. Each country needs at least 3 flags. Each flag is commonly used in the UI, most notably the regular flag is used when viewing the country in the diplomacy menu or in the top-left corner of the screen, while the medium and small flags are used for divisions and in [[Localisation#GetFlag|localisation]]; the flags get automatically assigned to countries based on the flag's filename.<br/>
Each flag needs to be a [[wikipedia:Truevision TGA|TGA-file]] with the name of the country tag and, optionally, the ideology group that the flag is assigned to. '''The flag file format is uncompressed 32-bit ARGB.''' In this case, "32-bit", "32 bits per pixel (bpp)", and "32 bitdepth" have the exact same meaning. In some editors where the bitdepth isn't settable when exporting but rather static without allowing the user to draw anything that the bitdepth doesn't allow, 32-bit means the RGB image mode alongside an alpha channel used for transparency present within the image. If it is 24-bit (meaning there is no alpha channel), the file will load but throw an error stating that it'll slow down the game and that it's recommended to use 32bpp.<br/>
If the origin point is set to top left rather than bottom left, the image will appear flipped upside down. This can be common within online converters. Instead, it's better to use a more configurable image editor in order to convert files to TGA, such as [https://getpaint.net/ Paint.net], [https://gimp.org/ GIMP], or [https://adobe.com/products/photoshop.html Photoshop].


然而,如果你不想为每个意识形态制作单独的旗帜,也可以创建一个各种尺寸的单独旗帜,并且将其单纯以国家tag命名而不包括意识形态。例如:ABC.tga 将会在该国家没有此时意识形态特定的旗帜时,作为该国家的旗帜使用。
There are two ways to name a flag:
* Ideology group-specific, such as <code>SCO_neutrality.tga</code>. These will have the highest priority as the starting flags (Assuming no [[Cosmetic tag modding|cosmetic tags]] are set).
* Non-specific, such as <code>SCO.tga</code>. If there's an ideology group-specific flag for the party ruling over the country, that one will be chosen, and this one is used as a backup in case it's not present.
Either one is optional, however it's recommended for a country to have some sort of a flag regardless which ideology group it has (Meaning either that there's a non-specific flag optionally alongside some ideology group-specific ones or that each ideology group in the mod has a specific flag for this country)


{| class="wikitable"
{| class="wikitable"
|-
|-
!  !! 要求尺寸
!  !! Size requirement<ref>{{cd2|NGraphics|COUNTRY_FLAG_TEX_WIDTH|COUNTRY_FLAG_TEX_HEIGHT|COUNTRY_FLAG_MEDIUM_TEX_WIDTH|COUNTRY_FLAG_MEDIUM_TEX_HEIGHT|COUNTRY_FLAG_SMALL_TEX_WIDTH|COUNTRY_FLAG_SMALL_TEX_HEIGHT}} in [[Defines]]</ref> !! Resulting filesize{{cref|b}}
|-
|-
| 标准 || 82x52 pixel
| Standard || 82x52 pixels || 16.6 or 17.1 KiB
|-
|-
| || 41x26 pixel
| Medium || 41x26 pixels || 4.2 or 4.69 KiB
|-
|-
| || 10x7 pixel
| Small || 10x7 pixels || 324 or 819 bytes
|}
|}
所有旗帜位于{{path|gfx/flags}} 。用于模组制作目的时,将旗帜放置于''<你的模组>/gfx/flag''下,并且将各尺寸的旗帜放置于相应的子文件夹下。
For the purpose of this mode, place them in {{path|custom=1|<yourmod>/gfx/flags}}, each flag size into the corresponding folder.
 
For medium and small flags to be generated, the game requires there to be a sufficient amount of [[#Country tag|dynamic country tags]], ~10 for medium flags to work and ~20 for small flags to work. If the requirement isn't met, the medium and small flags will appear as transparent for every single country even if they're saved properly, without anything related in {{path|custom=1|logs/error.log}}.
 
== Name ==
{{SVersion|Timeless}}
{{Anchor|Localisation}}
{{See also|Localisation}}


==军队—OOB(可选)==
Localisation, such as the country name, is defined in the {{path|custom=1|<yourmod>/localisation/english/}} folder for English. It is preferable to use a new file in the folder, as to not overwrite any base game files. The newly-created file will have to end with <code>_l_english.yml</code> in its filename ('''This is a lowercase L, not an uppercase i''') for it to be loaded properly. Additionally, '''it has to use the UTF-8-BOM text encoding'''. Exact details on how to change the encoding depend on the text editor used.
{{SVersion|1.8}}
如果一个国家是开始就存在的,那么拥有一支军队可以说是必要的,在{{path|history/units}} 建立一个新的txt文件,或者从原版复制一个国家的过来。它的命名必须与你在国家文件中所写的一模一样,否则将无法正常读取。比如你在国家文件中写<oob = "SCO_1936"> ,那么在units中,这个文件也要叫SCO_1936。


===师模板===
Within the file, localisation can be added accordingly:
  首先制作一个国家所拥有的师编制,编制中的营你可以在{{path|common/units}}找到。
<syntaxhighlight lang = "yaml">l_english:
division_template = {
SCO: "Scotland"                #Non-ideology name, primarily used for collaboration governments and as a fallback if an ideology group-specific one doesn't exist.
name = "Blueskirt Division" # 师的名字
SCO_DEF: "Scotland"
  
SCO_ADJ: "Scottish"
regiments = {
SCO_democratic: "Republic of Scotland"
infantry = { x = 0 y = 0 } # 步兵师 x是横排的位置,y是竖排的位置。从0开始,最高都是4.
SCO_democratic_DEF: "the Republic of Scotland"
infantry = { x = 0 y = 1 }
SCO_democratic_ADJ: "Scottish"
infantry = { x = 0 y = 2 }
  <...>
infantry = { x = 1 y = 0 }
</syntaxhighlight>
infantry = { x = 1 y = 1 }
The localisation key follows the formatting of <code>TAG_ideology</code>, where TAG is to be replaced with the country's tag and ideology is to be replaced with the ideology group.
infantry = { x = 1 y = 2 }
The _DEF and _ADJ suffixes may be added. The suffixes serve the following purpose:
infantry = { x = 2 y = 0 }
* No suffix: The primary name for the country. Shows up on the world map and with the [TAG.GetName] [[Localisation#Namespaces|localisation command]]
infantry = { x = 2 y = 1 }
* _ADJ: The adjective form for the country. Used with the [TAG.GetAdjective] localisation command.
infantry = { x = 2 y = 2 }
* _DEF: The definition form for the country. Used with the [TAG.GetNameDef] localisation command and when hovering over the state on the world map as the owner/controller. In base game, it's most commonly the same as the country's regular name but with "the " (Beginning with a lowercase letter as [TAG.GetNameDefCap] exists for otherwise) inserted in the beginning ''if needed''. Due to widespread use of this localisation command within generic events and decisions, this is essentially mandatory to define.
infantry = { x = 3 y = 0 }
 
infantry = { x = 3 y = 1 }
By changing each instance of English to the corresponding language, including the filename, the folder, and the first line of the file, it is also possible to make the name for different languages, including and limited to Brazilian Portuguese (l_braz_por instead of l_english), French, German, Polish, Russian, Spanish, and Japanese.<br/>
}
Additionally, there are other cosmetic versions of the country's name that can apply automatically that can be mixed together:
}
<syntaxhighlight lang = "yaml">l_english:
我们可以看到,上面那个师完全由步兵所组成,并且没有名字。而下面的内容,则加上了来自德国的更高级单位,比如支援营。有了师的名字下面那行内容之后,师的名字也有了以德国名字组为基础:
SCO_liberalism: "Federal Republic of Scotland"             # Applies when the country has a specific ideology type, commonly called sub-ideologies in community jargon.
<pre>
SCO_subject: "$OVERLORDADJ$ Scotland"                  # Applies when the country is a subject of any other country.
division_template = {
  SCO_IRE_subject: "Alba"                         # Applies when the country is a subject of a specific another country.
name = "Infanterie-Division" #师的名字
SCO_autonomy_dominion: "Dominion of Scotland"              # Applies when the country has the specified autonomy type with any other country as overlord.
division_names_group = GER_Inf_01 #师的名字组合
SCO_IRE_democratic_autonomy_integrated_puppet: "Most Northern Ireland" # Example of mixing these together. Must be in the country-ideology-autonomy order.
COUNTRY_SCO_autonomy_dominion: "Comhairle nan $NONIDEOLOGY$"      # The first tag can be replaced with COUNTRY to apply to a generic country.
</syntaxhighlight>
IDs of autonomous states can be found within {{path|common/autonomous_states/*.txt}} files, while the names of ideology types can be found in {{path|common/ideologies/*.txt}} files.<br/>
The country names are applied with the following priority:<br/>
* Autonomous state with a specific country as overlord
* Autonomous state
* Subject of a specific country
* Subject
* Ideology type
* Ideology group
* TAG
* COUNTRY
For example, <code>COUNTRY_SCO_autonomy_dominion</code>, due to being on the top of the list, will apply towards ''every'' country that's a dominion of Scotland, unless a more specific mix of a Scottish-controlled dominion applies (e.g. <code>ENG_SCO_autonomy_dominion</code> or <code>COUNTRY_SCO_democratic_autonomy_dominion</code>).
 
Inside of subject names, [[Localisation#Nesting strings|nested strings can be used]] that correspond to the overlord's name and the country's non-ideology name. Despite the fact that the latter doesn't seem to be subject-related, it cannot be used in names of independent countries.
These include:
* <code>$NONIDEOLOGY$</code>, <code>$NONIDEOLOGYADJ$</code>, and <code>$NONIDEOLOGYDEF$</code> for the non-ideology name.
* <code>$OVERLORD$</code>, <code>$OVERLORDADJ$</code>, and <code>$OVERLORDNAMEDEF$</code> (Note the NAME) for the overlord's name.
This can ''only'' be used in country names, regardless if it's an automatically-applying name or a [[Cosmetic tag modding|cosmetic tag]].


regiments = { # 进攻营
These localisation keys may unintentionally make the country name be something unexpected. For example, the base game {{flag|Turkey|Turkish}} national spirit <code>TUR_liberalism</code> gets used as the country's name when it gets a leader with the <code>liberalism</code> ideology type, making it have the name of "Liberalism". To find such instances, [[Modding#Searching multiple files|most text editors have capacity to search entire folders]]. By searching for the country's unintended name surrounded by quotes (in this case, <code>"Liberalism"</code>) in all of the loaded localisation files (usually the mod and the base game), the file with the root cause can be found to know the localisation key. From this key, every instance of the database entry with the overlapping name can be found and edited with another folder search, with the localisation key either deleted by copying over the entire file if necessary or [[Localisation#Replacing|replaced without copying the file]].
infantry = { x = 0 y = 0 }
=== Other localisation ===
infantry = { x = 0 y = 1 }
Other than the country name, there are certain other aspects of localisation that are commonly used to provide country-specific flair. Same as the name, this can go into any {{path|localisation/english/*_l_english.yml}} file with the UTF-8-BOM encoding:
infantry = { x = 0 y = 2 }
* Party names. More strictly, parties are country-specific names for ideology group that show up near the pie chart in the politics and diplomacy menus, whose names can also be accessed elsewhere with [[Localisation#Namespaces|localisation namespaces]]. A party uses up to 2 localisation keys: the regular name that appears in the piechart and the optional long name, which appears when hovering over the party name. If the long name is undefined, it will re-use the regular name.
  infantry = { x = 1 y = 0 }
: A localisation key for the regular name follows the <code>TAG_ideology_party</code> format, while the long name uses the <code>TAG_ideology_party_long</code> format.
infantry = { x = 1 y = 1 }
* Equipment: In order to rename an equipment type for a country, the localisation key used for it needs to be prefixed with the country's tag (separated with an underscore), such as <code>TAG_infantry_equipment_1</code>. Equipment may also have an optional short name, by appending <code>_short</code> to the key. Equipment is defined in {{path|common/units/equipment/*.txt}} files, where the IDs can be obtained. The same also works for equipment modules.
infantry = { x = 1 y = 2 }
Some other localisation keys that support similar country prefixing, such as division experience titles or idea/advisor names. Example localisation file with party/equipment renaming:
  infantry = { x = 2 y = 0 }
<syntaxhighlight lang="yaml">l_english:
infantry = { x = 2 y = 1 }
  SCO_communism_party: "SCP"
infantry = { x = 2 y = 2 }
  SCO_communism_party_long: "Scottish Communist Party"
}
  SCO_neutrality_party: "True Scotsman" # The long name will re-use this
support = { #支援营
  SCO_artillery_equipment: "Armata 75mm wz. 31 St."
engineer = { x = 0 y = 0 }
  SCO_artillery_equipment_short: "75mm wz. 31"
artillery = { x = 0 y = 1 }
</syntaxhighlight>
}
}
</pre> 师名字组合可以在{{path|common/units/names_divisicons}}找到。


=== 师位置===
== Starting characters ==
division可以让我们的部队直接在地图上出现,即开局就部署好了的部队。
{{Main|Character modding}}
units = {
division= {
name = "1st Blueskirt Division" #师编号
location = 9392 #师的位置(小地块)
division_template = "Blueskirt Division" #师的编制(也就是上面写的那个)
start_experience_factor = 0.2  #经验等级,不写就是没有
start_equipment_factor = 0.3   #装备后勤,不写就是完整
}
}
这里的name和上面师模板的的name不一样,这里的name是部队在地图上被选中显示的名称,而师模板那里的name是指编制的名称。下面所使用的的division_name是原版中使用的命名方法,相对来说比较麻烦,比较推荐上面的手动命名。
<pre>
     division= {
division_name = {
is_name_ordered = yes
name_order = 35
}
location = 6488
division_template = "Infanterie-Division"
start_experience_factor = 0.1                         #optional, otherwise starts with 0 expereince
force_equipment_variants = { infantry_equipment_0 = { owner = "GER" } }    #optional, replaces equipment with a specific variant (for example to give obsolete equipment to garrison units)
}
</pre>
===空军联队===
开局就部署在各机场的空军。
<pre>
air_wings = {
121 = { # Edinburgh
tac_bomber_equipment_0 = { owner = "SCO" amount = 72 }
start_experience_factor = 0.2 #optional, otherwise starts with 0 expereince
fighter_equipment_1 = { owner = "SCO"  version_name = "Scotfire" amount = 150 } #version_name is optional
start_experience_factor = 0.5
}
}
</pre>
''version_name'' defines a specific variant of that type of equipment to be used. It first needs to be defined in the same file.


== 添加其他剧本的历史(可选) ==
Characters are defined in any file in the {{path|common/characters/}} folder. An example of a file within that folder, with just a country leader, is the following:
If you want to edit something about your country, but only want it applied after a specific date (as in 1939 bookmark for example), you have to add these lines to the history file:
<pre>characters = {
<pre>
   SCO_ronald_mcdonald = {
1939.1.1 = {
     name = SCO_ronald_mcdonald
#There you can add anything, in the same format as described earlier
     portraits = {
oob = "SCO_1939" #Usually another oob is used for later bookmarks, only the latest one will be loaded
       civilian = {
set_technology = {
         large = GFX_SCO_ronald_mcdonald
atomic_research = 1
       }
nuclear_reactor = 1
     }
nukes = 1
     country_leader = {
}
       ideology = socialism
}
       traits = { scary_clown }
</pre>
     }
=== 国策 ===
   }
National Focuses can be completed in two ways:
}</pre>
If you want the effects to apply, then use:
The <code>ideology</code> defined for the country leader must be an {{hover|Commonly called sub-ideology in community jargon, but called ideology type with in-game code|ideology type}}, rather than an ideology group such as {{icon|democratic|1}}. A list of ideology types across groups, alongside more information, can be found on the [[Character modding#Country leader|dedicated character modding article]].
<pre>
complete_national_focus = army_effort
</pre>
If you want to just bypass the focus (often used for more complex focuses, like 'Demand Sudetenland', and apply effect manually, without triggering all the associated events), use:
<pre>
unlock_national_focus = GER_demand_sudetenland
</pre>
=== 具体案例 ===
Cancelling a relation that is activated earlier (like a guarantee to FRA used earlier):
<pre>
diplomatic_relation = {
country = FRA
relation = guarantee
active = no
}
</pre>
Removing previously used idea:
<pre>
remove_ideas = {
great_depression
}
</pre>
=== 要记住的事情 ===
*The date used must be at least 1 day before the actual bookmark start date, multiple dates can be used
*Ideas are added, Laws are replaced by the latest loaded
*Technologies only have to be applied once, add only extra technologies to the later bookmarks
*If a National Focus triggers an event, or adds effect, completing it by history file does not apply these, they have to be triggered separately
*Country leader is chosen based on corresponding ideology, if multiple are present, the one located lower in the file is chosen


== 在游戏中增加国家 ==
The picture used is a spriteType, defined in any {{path|interface/*.gfx}} file. It is recommended to use a new file for this purpose instead of overwriting the base game files. An example of how a new file can look like is the following:
<pre>spriteTypes = {
   spriteType = {
     name = GFX_SCO_ronald_mcdonald
     texturefile = gfx/leaders/SCO/ronald_mcdonald.dds
   }
}</pre>


There are three ways to implement the new country into the game.
The name picked for the character depending on the language set when launching the game is defined within {{path|localisation/}}. In particular, for English, this would be in any {{path|localisation/english/*_l_english.yml}} file as this: <code>SCO_ronald_mcdonald:0 "Ronald McDonald"</code>. The description when hovering over the character can be added by appending <code>_desc</code> to the character's name, as <code>SCO_ronald_mcdonald_desc:0 "Insert description here"</code>.


*Using events
In order to appear, a character '''must''' be recruited in the history file of the country. This is done with the <code>recruit_character</code> effect, as the following:
*By national focus
<pre>recruit_character = SCO_ronald_mcdonald</pre>
*Editing state history
If multiple country leaders fall under the same political party, the game will place the first-recruited one as its leader. Since <code>set_politics = { ... }</code> forces a leader of the specified ideology group to come to power, any characters recruited after a <code>set_politics</code> block will not immediately become country leader since the country already has one: '''recruitment of the intended country leader must be before setting politics'''. <br/>
Corps commanders, field marshals, admirals, and advisors are also regarded as characters in the in-game code, and are added similarly: [[Character modding|defined in the characters file]] and then recruited in {{path|history/countries/TAG*.txt}}


=== 通过事件或国策增加国家 ===
==Order of battle==
{{main|Event Modding}}
{{Hatnote|Parts of this section are transcluded from [[Division modding]]}}
{{SVersion|1.12}}
If the country will exist at the start, an order of battle is necessary for the country to have an army. Orders of battle are used for establishing the starting military of the country, and they are generally separated into land, naval, and air branches, since enabling the {{icon|mtg|1}} and {{icon|bba|1}} DLCs requires separate definitions for the navy and the air force respectively that are not compatible with the DLC being disabled.


There are multiple ways to add a country's presence by event or national focus. Here are two:
'''[[#Order of battle|Each order of battle must be loaded, usually in country history,]] in order for the units to show up.''' The filename is irrelevant, as long as it matches up with the one given in the country history file.


set_state_owner = 119
The internal names for sub-units can be found in {{path|common/units/*.txt}} files, [[Modding#Searching multiple files|localisation can be checked as well]]. For the sake of briefness, naval and air branches will be covered in the main article of [[Division modding]] instead.
===Division template===
{{#section-h:Division modding|Division template}}


Using this script in an event option or national focus reward, when scoped to the new country, will cause the province to be owned by the new country. If it is occupied by a third power and the new country is at war with them however, the region will remain occupied.
===Division placement===
{{#section-h:Division modding|Division placement}}
===Equipment production===
{{#section-h:Division modding|Equipment production}}


transfer_state = 119
== Character names ==
{{Anchor|Randomly-generated names (optional)}}
{{See also|Namelist modding}}
Character names are used for randomly-generated characters. This includes but is not limited to generic advisors, division commanders, newly-created unit leaders, or generic country leaders. Any {{path|common/names/*.txt}} file can be used as the file, and each country's entry is marked by being a block with the name of the country's tag (with <code>default</code> or a [[cosmetic tag]] also being possible). An example entry looks like this:
<pre>TAG = {
   male = {
     names = {
       Name "Name with multiple words"
     }
   }
   female = {
     names = {
       Name "Name with multiple words"
     }
   }
   surnames = {
     Surname "Surname with multiple words"
   }
   callsigns = {
     Callsign "Callsign with multiple words"
   }
}</pre>This will assign these names to TAG. In particular:
* <code>names = { ... }</code> is used to assign the first names of the characters. For [[ace]]s, this is used for [[Localisation#GetName|the GetName localisation namespace]]. For other characters or pseudo-characters, it's used as the word or the combination of words that are placed in the beginning of the name.
* <code>surnames = { ... }</code> is used to assign the last names of the characters. For [[ace]]s, this is used for [[Localisation#GetSurname|the GetSurname localisation namespace]]. For other characters or pseudo-characters, it's used as the word or the combination of words that are placed in the end of the name.
* <code>male = { ... }</code> and <code>female = { ... }</code> are used to assign a name or a surname to be specific to a particular gender. <code>names</code> and <code>surnames</code> may be used either inside or outside of the gendered blocks, in case of unisex names or gendered surnames.
* <code>callsigns = { ... }</code> is used to assign a callsign to newly-generated [[operatives]].
[[Modding#Code structure|Quotation marks may be used in order to include whitespaces inside of a single token]], as names are traditionally unlocalised.
== Character portraits ==
{{Anchor|Randomly-generated portraits (optional)}}
{{Main|Portrait modding}}
When the game automatically generates a country or a unit leader, a portrait is randomly chosen from a pool that depends on country or continent, if there's not a country-specific one. This pool is located in any {{path|portraits/*.txt}} file. An example entry looks like
<pre>TAG = {
   navy = {
     male = {
       "GFX_navy_portrait_male_1"
     }
     female = {
       "GFX_navy_portrait_female_1"
     }
   }
   army = {
     male = {
       "GFX_army_portrait_male_1"
     }
     female = {
       "GFX_army_portrait_female_1"
     }
   }
   operative = {
     male = {
       "GFX_operative_portrait_male_1"
     }
     female = {
       "GFX_operative_portrait_female_1"
     }
   }
   political = {
     neutrality = { # Each ideology group should be present individually.
       male = {
         "GFX_neutrality_portrait_male_1"
       }
       female = {
         "GFX_neutrality_portrait_female_1"
       }
     }
   }
}</pre>
This assigns these particular [[spriteType]]s to the newly-created character. In particular, it is important for army portraits to also have a small equivalent, created as a new spriteType where the <code>name</code> attribute is the same as the large one, but with <code>_small</code> to the end (e.g. <code>GFX_army_portrait_male_1_small</code> would be a small male portrait in the example). This is used for the [[Officer corps]] system.


This script will change both the ownership and control to the scoped state. If a third country occupies it it will go to the new country regardless of the state of relations between it and the occupying power.
== Adding the country to the game ==
The country will exist as long as an entry in {{path|common/country_tags/*.txt}} exists. However, it will not exist on the map at first.


=== 通过地区历史添加国家 ===
If it should appear on the game's start, whether fully owning the states or just having them as cores, [[State modding|the states themselves need to be edited]] to be owned by the country at the game's start, stored in {{path|history/states/*.txt}} files.


Change the owner and cores in province history files so that they include the new country either by default or in defined bookmarks (for instance only in 1939)
If the country is only to appear in the middle of the game, effects can be used within any effect block, such as a focus reward or an event option. In particular, [[Effect#add_state_core|add_state_core]] and [[Effect#transfer_state|transfer_state]], [[Scopes|within that country's scope]] can be used to, respectively, core the specified states and change their owner and controller to the needed country.


== Notes and references ==
{{cnote|a|A similar process applies for other languages that the game supports, with the filename ending with the internal name of the language. The exact folder path is actually irrelevant, as long as the file is contained within the localisation folder or any of its subfolders at any depth level.}}
{{cnote|b|If the correct settings of 32 bitdepth/bits per pixel and no RLE encoding are used, saving the flag should result in a consistent filesize each time. Paint.net, however, adds an approximately 500 byte large watermark to the end of the file if it is used to save the flag, which is not present when GIMP or Photoshop are used instead. The filesize is as shown in the Windows File Explorer and may differ in rounding if viewed elsewhere, such as the image editor's export menu.}}
<references/>
{{Modding navbox}}
{{Modding navbox}}
[[Category:Modding]]
[[ 分类:Modding]]

2024年8月31日 (六) 11:52的最新版本

The guide below presumes that you understand the basics of how to create a mod. This page should also help modders understand how to change some more specific aspects of a country.

Quick checklist

  • Define a unique 3-character country tag in any <yourmod>/common/country_tags/*.txt file.
  • Create a file in the <yourmod>/common/countries folder with the same name as the one that's linked in the country tag definition.
  • Define the country leader and optionally advisors and unit leaders in <yourmod>/common/characters
  • Create a .txt file in the <yourmod>/history/countries folder, with the first three letters of the filename being the country's tag, and fill it with the starting historical information.
  • Create an OOB file in <yourmod>/history/units and load it within the previous country history file. Buildings will not be assigned to the country properly otherwise.
  • Add the country's name to any <yourmod>/localisation/english/*_l_english.yml file that uses the UTF-8-BOM encoding[a].
  • Add a large, medium and small flag for each ideology to the <yourmod>/gfx/flags folder.
  • Optionally add the country to the game by assigning it states within the <yourmod>/history/states/*.txt files.

Tag

Countries need a 3-character country tag. This is how a country is referred to in all of the game's script. All country tags must be unique. A country must not share a tag with any other country.

To create a tag, add a new file to <yourmod>/common/country_tags (or edit an existing file, though creating a new one is preferable due to making the mod easier to make compatible to newer game versions) and add a line similar to SCO = "countries/Scotland.txt", where countries/Scotland.txt is the address of the country file that will be created/edited, located in <yourmod>/common/countries. There is no need for this file to be unique: multiple countries may use the exact same common/countries/ file in its definition.

There are some country tags that must be avoided, as they will cause in-game confusion whether something is meant to be a reference to a country or not. Their mere existence can cause other code to break. A list of them is the following:

Tag Reason to avoid
NOT Used as a flow control tool that comes up as true when any of the triggers within is false.
AND Used as a flow control tool that comes up as true when all of the triggers within are true.
TAG Used as a trigger that checks the country being chosen.
OOB Used within country history files as an argument deciding the loaded order of battle file, deciding the amount of divisions and where they are located.
LOG Used as an effect or a trigger that writes the specified argument within the user directory's /Hearts of Iron IV/logs/game.log file or in console if it is open.
NUM Used for arrays in order to count the amount of elements within them. This will break the resistance system as the scripted trigger responsible for deciding when resistance must be enabled utilises this.
RED Used within custom map modes as a temporary variable deciding how red the state should be. This will make every custom map mode always have 0 as the red value.
Numbers Numbers meaning an entirely numeric country tag such as 123, although the game prevents tags from beginning with numbers. While numbers can be used within country tags (such as D01), if it's entirely numeric there might be confusion whether, for example, 123 would refer to a state ID or a country tag.

A file can have dynamic_tags = yes within of itself, which marks every country defined in that file afterwards to be marked as a dynamic country. A dynamic country is one that doesn't have explicit data defined, but instead copies it on the fly from an original country that it branches off. This is most commonly used within civil wars, with the effect to start one auto-generating one. If the mod doesn't have enough dynamic countries defined, the game will crash if there is a sufficient amount of non-dynamic countries, with the last read file being marked as map/cities.txt or a savegame (Though that crash is not necessarily caused by the lack of dynamic countries).

Country file

The country tag list refers to a file in the <yourmod>/common/countries/ folder. The file sets the graphical culture and the default colour which may be overwritten by a colors.txt entry. An example of a file is as such:

graphical_culture = commonwealth_gfx
graphical_culture_2d = commonwealth_2d
color = rgb { 2  10  222 }

Graphical culture defines the set of graphics used for units, while the 2D graphical culture defines portraits used for aces and generic advisors. A list can be found in /Hearts of Iron IV/common/graphicalculturetype.txt. For Scotland this would be the following:

graphical_culture = commonwealth_gfx
graphical_culture_2d = commonwealth_2d

color = rgb { 2 10 222 } is the country's default colour on the political map mode (overridden by a colors.txt entry if one exists. This requires specifying a colour model, such as rgb or hsv, to work.). The RGB colour model uses numbers on the scale from 0 to 255 or 0 to 1 (using exactly 1 is considered to be on the second scale), while the HSV colour model uses numbers on the scale from 0 to 1.

Additionally, an entry can be made in <yourmod>/common/countries/colors.txt in order to specify more country colours. The file has to be called colors.txt, and so it will overwrite the base game file if the entry is added. An entry in the file is formatted as the following:

SCO = {
    color = rgb { 2  10  222 }
    color_ui = rgb { 255 255 155 }
}

color will overwrite the country's colour on the political map, while color_ui will be used externally, such as in the map generated with the ^Ctrl + F10 hotkey or the history viewer tool in /Hearts of Iron IV/tools/history_viewer/. Colours may also be specified in the HSV color model, in which case rgb will need to be replaced with hsv. The color_ui is also used in order to colour in the background of the country's division counter, if the option is set to be country-specific. If a country doesn't have a color_ui entry, it defaults to a grey colour.
In HSV, hue, saturation, and value are each on the scale from 0 to 1, using decimals to show the value.

After reading the colour from the file, the saturation and value of the colour will be multiplied by 0.6 and 0.8 respectively by default[1]. This means the colour appearing in-game will be slightly darker and less saturated (closer to a shade of grey) than defined in the file. In order to have a country colour in HSV have a higher saturation or value than 0.6 or 0.8 respectively, a value larger than 1 can be used as long as it'll end up between 0 and 1 after the application of modifiers. For example, a pure red country colour can be simulated in HSV with color = hsv { 0 1.66 1.25 }. After applying the offsets, this will result in a saturation of 0.996 and a value of 1, being as close to pure red as possible.
For RGB, this calculation is harder: "Saturation" defines the difference between the colour with the largest value and the others (changing it does not change the largest colour's value), while "Value" manifests in multiplying every colour's value by that. For replicating a desired value, let [math]\displaystyle{ V_M }[/math] represent the maximum value of colour. As such, each colour's value, originally [math]\displaystyle{ V }[/math], by default should be [math]\displaystyle{ \frac{5}{12}\left(5V-2V_M\right) }[/math]. With arbitrary Value/Saturation modifiers (represented with [math]\displaystyle{ M_V }[/math] and [math]\displaystyle{ M_S }[/math]), it's [math]\displaystyle{ \frac{1}{M_V}\left(\frac{V}{M_S}+V_M*\frac{M_S-1}{M_S}\right) }[/math]. For example, pure green (i.e. what rgb { 0 255 0 } intends), would be represented well with rgb { -107 425 -107 } plugging numbers into that formula. Indeed, entering this value into the game, the result is exactly pure green, far closer to it than rgb { 0 255 0 } or rgb { 0 425 0 } are.
These modifiers do not get applied when using the tag_color console command.

History

Create a file in the <yourmod>/history/countries folder. Alternatively, copy, rename, and edit a similar file. The filename typically follows the format of TAG - country name.txt, e.g. "SCO - Scotland.txt". The important aspect is that the first three letters of the filename must be the same as the country's tag in order to be loaded, without taking capitalisation into account. Everything after the tag is purely a comment and can be made into anything: "SCO - Bahrain.txt" will work just as well for SCO as would "SCO_qatar.txt".
This file contains information about the starting attributes of the country for each scenario, such as the capital and the ruling party. They serve as an effect block, so most effects can be used within of them. These files get executed in the order of the countries in the country_tags file, which may come into play for subjects, as puppeting changes party popularity.

A country may have more than one history file, in which case each one will be used.
As a note, any unnecessary closing bracket will stop the execution of the file prematurely, leading anything afterwards to not be read. If nothing in the history file after a certain point applies, this is likely the cause.

capital = 121 defines the capital state. The province with the most victory points within that state will get used as the capital. In case of overlap, the lowest province ID out of the possible choices gets chosen. In this case, 121 is the state Lothian, which contains Edinburgh as the largest victory point. To reiterate, this must be a state ID, not a province ID.

Order of battle

Orders of battle are used for the starting military information: templates, divisions that use them, as well as the starting navy and airforce. Traditionally, the starting equipment production is put there within instant_effect while equipment variants are within country history, however instant_effect in orders of battle is an effect block, similarly to country history, so it's not necessary to divide them in this manner. As a byproduct of how the engine works, countries with no order of battle will have broken buildings: any building constructed via an effect will not apply to the country immediately, rendering them impossible to use until the consumer goods percentage changes or a savefile gets reloaded. Orders of battle can also contain information on what national focus the country is currently doing, however any already-completed focuses must be in country history.

There are several arguments/effects that can be used in country history. Each one is constructed in the manner of oob = "filename", which would link to the <yourmod>/history/units/filename.txt file. The .txt extension is omitted from the filename necessary to be put in. The filename of the order of battle is irrelevant as long as it matches up with the one loaded within the country history file. These are what can be used:

  • oob = "SCO_1936" is the traditional way to load a land order of battle, assigning it to the country to be loaded before the game's start. However, this is not an effect but an argument in country history, meaning that it can't be used within other effect blocks (e.g. if statements).
  • set_oob = "SCO_1936" is identical to the prior way: assigning a land order of battle to the country to be loaded before the game's start. However, this is an effect, meaning it can indeed be used in if statements. This is required to use within if statements, such as if different orders of battle are used depending on the DLC, however this can be used outside of if statements.
  • set_naval_oob = "SCO_1936_naval_legacy" and set_air_oob = "SCO_1936_air_bba" are similar to the previous one, however are instead used for the specified branches of the military. These will overwrite any other previously-defined order of battle of the same type.
  • load_oob = "my_template_shared" is an effect and is not recommended to be used in history. It, instead, loads the order of battle immediately, which can lead to errors if it's put before technologies necessary to load the order and can lead to crashes if the order contains any divisions. However, this can be used to load orders of battle after the first-defined orders. This can be used for compatibility reasons as to not overwrite any unnecessary files or to re-use the same file containing templates, starting effects, or starting focus information across different countries to be loaded after the base order of battle.


Naval and air units are divided into two separate orders of battle. This is because 炮手就位炮手就位 changes the naval system and 唯有浴血唯有浴血 changes the air system enough that any orders of battle created for the base game will not be compatible with the DLC or vise-versa. At times, the land order of battle can also be divided into multiple, most commonly if there are any references to tank equipment within force_equipment_variants or starting equipment production. For each one of these, the same if statements are used:

if = {
    limit = { has_dlc = "Man the Guns" }
    set_naval_oob = "SCO_1936_naval_mtg"
}
if = {
    limit = { NOT = { has_dlc = "Man the Guns" } }
    set_naval_oob = "SCO_1936_naval_legacy"
}
if = {
    limit = { has_dlc = "By Blood Alone" }
    set_air_oob = "SCO_1936_air_bba"
}
if = {
    limit = { NOT = { has_dlc = "By Blood Alone" } }
    set_air_oob = "SCO_1936_air_legacy"
}

Note that else only works in its nested form in history files.

Effects

主条目:Effects

These are effects which are traditionally put in history files of the country to be executed on startup, meaning that they can be used elsewhere as well. Any other effect within the list can be used as well.

set_research_slots = 3 defines the amount of research slots a country has access to at the start. Normally, major powers have 4 slots, minor countries in North America and Europe have 3, and minor countries in the rest of the world have 2. Defaults to 2 slots if not specified.

set_stability = 0.7 defines the 稳定度稳定度 that a country will have at the start of the game, defined on the scale from 0 to 1. The prior example of 0.7 will lead to the country starting with 70% stability.

set_war_support = 0.5 defines the 战争支持度战争支持度 that a country will have at the start of the game. Similar to stability, it is defined on the scale from 0 to 1, the prior example of 0.5 being 50%.

add_ideas = {
    henschel
    GER_autarky_idea
    #laws #Remember that the sharp sign is used to mark comments.
    war_economy
    extensive_conscription
}

This is the list of ideas that the country starts with in the game, including national spirits, design companies, and laws. Ideas are defined in /Hearts of Iron IV/common/ideas. If starting laws aren't defined, then the country will start with the laws of 志愿兵役制志愿兵役制, Export FocusExport Focus, and Civilian EconomyCivilian Economy.

set_technology = {
    infantry_weapons = 1
    infantry_weapons1 = 1
    gw_artillery = 1
    interwar_antiair = 1
    fuel_silos = 1
    basic_train = 1
}

This defines the starting technologies of the country. A list of technologies can be found in /Hearts of Iron IV/common/technologies/. It is notable that, similarly to orders of battle, several technologies depend on DLC, such as the 炮手就位炮手就位 naval tech and 寸步不退寸步不退 tank tech. In that case, an if statement needs to be used in order to set only the technologies that the country has access to, such as, using it in a conjunction with the prior naval oob:

if = {
    limit = { has_dlc = "Man the Guns" }
    set_technology = {
        basic_naval_mines = 1
        submarine_mine_laying = 1
        early_ship_hull_light = 1
        early_ship_hull_submarine = 1
        basic_ship_hull_submarine = 1
        basic_battery = 1
        basic_torpedo = 1
        basic_depth_charges = 1
    }
    set_naval_oob = "SCO_1936_naval_mtg"
}
if = {
    limit = { NOT = { has_dlc = "Man the Guns" } }
    set_technology = {
        early_submarine = 1
        early_destroyer = 1
    }
    set_naval_oob = "SCO_1936_naval_legacy"
}

recruit_character = TAG_character_name is used to recruit the specified character. This includes country leaders, commanders, admirals, and advisors. Country leaders that are recruited after setting political information can fail to appear, so it's recommended to recruit them before setting any political information. If multiple country leaders fall under the same political party, the game will place the first-recruited one as its leader. The recruitment will fail if the effect is placed as the last line in the file: there must be at least one line after the recruitment, even if it's empty.

Diplomacy-related effects

In order to make the country start as a subject, the following can be put in the history file:

ENG = {
    if = {
        limit = {
            has_dlc = "Together for Victory"
        }
        set_autonomy = {
            target = SCO
            autonomous_state = autonomy_integrated_puppet
        }
        else = {
            puppet = SCO
        }
    }
}

Since the history files get loaded in a specific order, it is preferable to put it in the subject's history file, as to avoid the case where the overlord's file gets loaded after the subject's, which'll make the puppeting reset the politics of the subject. For this reason, set_autonomy must also be set before the political party and popularities of the subject. The if statement is there to ensure that the integrated puppet is only there with 共赴胜利共赴胜利, as that autonomous state is not available otherwise. A list of autonomous states can be found in /Hearts of Iron IV/common/autonomous_states/*.txt files.

A faction can be created with create_faction = localisation_key. The localisation key will be used to define the name of the faction, defined in any <yourmod>/localisation/english/*_l_english.yml file.
Members are added to the faction with add_to_faction = IRE within the faction leader's history file. Although puppets usually get added to the faction automatically, it is recommended to add them manually as well.

In order to use technology sharing groups, add_to_tech_sharing_group = my_tech_group can be used in each country's history file. This requires the 共赴胜利共赴胜利 DLC check (always positive) in order to work properly. Technology groups are defined in /Hearts of Iron IV/common/technology_sharing/*.txt files. Additional details on the technology groups can be found on the dedicated article.

Politics-related effects

set_popularities = {
    democratic = 80
    communism = 10
    fascism = 10
}

This defines the starting party popularities, on the scale from 0 to 100. If an ideology is left out, then it will be assumed to have 0% popularity. If it doesn't add up to 100, then the popularities will fail to be set.

set_politics = {
    ruling_party = neutrality
    last_election = "1932.11.8"
    election_frequency = 48 # Every 4 years
    elections_allowed = yes
}

This defines the starting political situation of the country, with the ruling party and details on elections. Notably, the election frequency is defined in months.

Variants

Special variants on equipment available for this country from the start can be put in, defining the starting equipment upgrades or modules. Since this can depend on DLC, for ships, tanks, and airplanes, a DLC check can be used as the following:

if = {
    limit = { has_dlc = "Man the Guns" }
    create_equipment_variant = {
        name = "Celtic Series"
        type = ship_hull_submarine_1                            # See list in common/units/equipment
        name_group = SCO_SS_HISTORICAL                          # Defines names used for ships of this variant, defined in common/units/names_ships/
        modules = {
            fixed_ship_torpedo_slot = ship_torpedo_sub_1        # Module slots for equipment types are defined in common/units/equipment
            fixed_ship_engine_slot = sub_ship_engine_1          # While modules themselves are defined in common/units/equipment/modules
            rear_1_custom_slot = empty
        }
        obsolete = yes                                          # Marks as obsolete, changing the UI.
    }
}
if = {
    limit = { NOT = { has_dlc = "Man the Guns" } }
    create_equipment_variant = {
        name = "Celtic Series"
        type = submarine_1                                      # Note different equipment type due to no MtG.
        upgrades = {
            ship_reliability_upgrade = 1                        # See list in common/units/equipment/upgrades
            sub_engine_upgrade = 1
            sub_stealth_upgrade = 1
            sub_torpedo_upgrade = 1
        }
        obsolete = yes
    }
}

Date-dependent history

In order to assign a part of the history file to only apply on start dates later than a certain date, a date block is used. It's formatted in the manner of YYYY.MM.DD = { ... } and accepts the same attributes and effects that may be used elsewhere in the file:

1939.1.1 = {
    oob = "SCO_1939"
    set_technology = {
        atomic_research = 1
        nuclear_reactor = 1
        nukes = 1
    }
}

In particular, this would replace the used order of battle with /Hearts of Iron IV/history/units/SCO_1939.txt and add atomic_research, nuclear_reactor, and nukes technologies to the ones the country already has researched.
This will only apply on the start dates that are strictly later than the defined timestamp.

Useful effects

While any effects can be used, same as in regular history, the following are specifically useful for later start dates:

In order to simulate completion of the national focus tree, the two effects are used: unlock_national_focus = focus_name, which bypasses the focus without granting effects, and complete_national_focus = focus_name, which fully completes the focus, granting the effects.

The diplomatic_relation effect can be used in order to cancel previously applied diplomatic relations, such as guarantees or military access. Ideas would be removed with the remove_ideas effect, applied in the exact same manner as add_ideas

In order to replace the country leader, the promote_character effect can be used as promote_character = TAG_character_name. However, make sure that the character is recruited beforehand and has a country leader role within their definition. Recruitment is allowed within a date-block.

Full file example

The text in this section has been collapsed by default.
capital = 121
oob = "SCO_1936"

set_research_slots = 3
set_stability = 0.7
set_war_support = 0.5

recruit_character = SCO_ronald_mcdonald # Before set_politics

add_ideas = {
    henschel
    GER_autarky_idea
    #laws
    war_economy
    extensive_conscription
}

set_technology = {
    infantry_weapons = 1
    infantry_weapons1 = 1
    gw_artillery = 1
    interwar_antiair = 1
    early_fighter = 1
    early_bomber = 1
    fuel_silos = 1
    basic_train = 1
}

if = {
    limit = { has_dlc = "Man the Guns" }
    set_technology = {
        basic_naval_mines = 1
        submarine_mine_laying = 1
        early_ship_hull_light = 1
        early_ship_hull_submarine = 1
        basic_ship_hull_submarine = 1
        basic_battery = 1
        basic_torpedo = 1
        basic_depth_charges = 1
    }
    create_equipment_variant = {
        name = "Celtic Series"
        type = ship_hull_submarine_1
        name_group = SCO_SS_HISTORICAL
        modules = {
            fixed_ship_torpedo_slot = ship_torpedo_sub_1
            fixed_ship_engine_slot = sub_ship_engine_1
            rear_1_custom_slot = empty
        }
        obsolete = yes
    }
    set_naval_oob = "SCO_1936_naval_mtg"
}
if = {
    limit = { NOT = { has_dlc = "Man the Guns" } }
    set_technology = {
        early_submarine = 1
        early_destroyer = 1
    }
    create_equipment_variant = {
        name = "Celtic Series"
        type = submarine_1
        upgrades = {
            ship_reliability_upgrade = 1
            sub_engine_upgrade = 1
            sub_stealth_upgrade = 1
            sub_torpedo_upgrade = 1
        }
        obsolete = yes
    }
    set_naval_oob = "SCO_1936_naval_legacy"
}
if = {
    limit = { has_dlc = "By Blood Alone" }
    set_air_oob = "SCO_1936_air_bba"
    set_technology = {
        aa_lmg = 1
        engines_1 = 1
        engines_2 = 1
        early_bombs = 1
        aircraft_construction = 1
        iw_small_airframe = 1
        iw_medium_airframe = 1
        iw_large_airframe = 1
        basic_medium_airframe = 1
        basic_small_airframe = 1
    }
}
if = {
    limit = { NOT = { has_dlc = "By Blood Alone" } }
    set_air_oob = "SCO_1936_air_legacy"
    set_technology = {
        early_fighter = 1
        cv_early_fighter = 1
        cv_naval_bomber1 = 1
        naval_bomber1 = 1
        early_bomber = 1
        CAS1 = 1
    }
}

ENG = {
    if = {
        limit = {
            has_dlc = "Together for Victory"
        }
        set_autonomy = {
            target = SCO
            autonomous_state = autonomy_integrated_puppet
        }
    }
    else = {
        puppet = SCO
    }
}


set_popularities = {    # Notice how set_popularities is after puppeting. Otherwise would lead to puppeting resetting politics.
    democratic = 80
    communism = 10
    fascism = 10
}
set_politics = {
    ruling_party = democratic
    last_election = "1932.11.8"
    election_frequency = 48 # Every 4 years
    elections_allowed = yes
}


Flag

The flags representing a country are stored in /Hearts of Iron IV/gfx/flags and its subfolders. Each country needs at least 3 flags. Each flag is commonly used in the UI, most notably the regular flag is used when viewing the country in the diplomacy menu or in the top-left corner of the screen, while the medium and small flags are used for divisions and in localisation; the flags get automatically assigned to countries based on the flag's filename.
Each flag needs to be a TGA-file with the name of the country tag and, optionally, the ideology group that the flag is assigned to. The flag file format is uncompressed 32-bit ARGB. In this case, "32-bit", "32 bits per pixel (bpp)", and "32 bitdepth" have the exact same meaning. In some editors where the bitdepth isn't settable when exporting but rather static without allowing the user to draw anything that the bitdepth doesn't allow, 32-bit means the RGB image mode alongside an alpha channel used for transparency present within the image. If it is 24-bit (meaning there is no alpha channel), the file will load but throw an error stating that it'll slow down the game and that it's recommended to use 32bpp.
If the origin point is set to top left rather than bottom left, the image will appear flipped upside down. This can be common within online converters. Instead, it's better to use a more configurable image editor in order to convert files to TGA, such as Paint.net, GIMP, or Photoshop.

There are two ways to name a flag:

  • Ideology group-specific, such as SCO_neutrality.tga. These will have the highest priority as the starting flags (Assuming no cosmetic tags are set).
  • Non-specific, such as SCO.tga. If there's an ideology group-specific flag for the party ruling over the country, that one will be chosen, and this one is used as a backup in case it's not present.

Either one is optional, however it's recommended for a country to have some sort of a flag regardless which ideology group it has (Meaning either that there's a non-specific flag optionally alongside some ideology group-specific ones or that each ideology group in the mod has a specific flag for this country)

Size requirement[2] Resulting filesize[b]
Standard 82x52 pixels 16.6 or 17.1 KiB
Medium 41x26 pixels 4.2 or 4.69 KiB
Small 10x7 pixels 324 or 819 bytes

For the purpose of this mode, place them in <yourmod>/gfx/flags, each flag size into the corresponding folder.

For medium and small flags to be generated, the game requires there to be a sufficient amount of dynamic country tags, ~10 for medium flags to work and ~20 for small flags to work. If the requirement isn't met, the medium and small flags will appear as transparent for every single country even if they're saved properly, without anything related in logs/error.log.

Name

参见:Localisation

Localisation, such as the country name, is defined in the <yourmod>/localisation/english/ folder for English. It is preferable to use a new file in the folder, as to not overwrite any base game files. The newly-created file will have to end with _l_english.yml in its filename (This is a lowercase L, not an uppercase i) for it to be loaded properly. Additionally, it has to use the UTF-8-BOM text encoding. Exact details on how to change the encoding depend on the text editor used.

Within the file, localisation can be added accordingly:

l_english:
 SCO: "Scotland"                               #Non-ideology name, primarily used for collaboration governments and as a fallback if an ideology group-specific one doesn't exist.
 SCO_DEF: "Scotland"
 SCO_ADJ: "Scottish"
 SCO_democratic: "Republic of Scotland"
 SCO_democratic_DEF: "the Republic of Scotland"
 SCO_democratic_ADJ: "Scottish"
 <...>

The localisation key follows the formatting of TAG_ideology, where TAG is to be replaced with the country's tag and ideology is to be replaced with the ideology group. The _DEF and _ADJ suffixes may be added. The suffixes serve the following purpose:

  • No suffix: The primary name for the country. Shows up on the world map and with the [TAG.GetName] localisation command
  • _ADJ: The adjective form for the country. Used with the [TAG.GetAdjective] localisation command.
  • _DEF: The definition form for the country. Used with the [TAG.GetNameDef] localisation command and when hovering over the state on the world map as the owner/controller. In base game, it's most commonly the same as the country's regular name but with "the " (Beginning with a lowercase letter as [TAG.GetNameDefCap] exists for otherwise) inserted in the beginning if needed. Due to widespread use of this localisation command within generic events and decisions, this is essentially mandatory to define.

By changing each instance of English to the corresponding language, including the filename, the folder, and the first line of the file, it is also possible to make the name for different languages, including and limited to Brazilian Portuguese (l_braz_por instead of l_english), French, German, Polish, Russian, Spanish, and Japanese.
Additionally, there are other cosmetic versions of the country's name that can apply automatically that can be mixed together:

l_english:
 SCO_liberalism: "Federal Republic of Scotland"                         # Applies when the country has a specific ideology type, commonly called sub-ideologies in community jargon.
 SCO_subject: "$OVERLORDADJ$ Scotland"                                  # Applies when the country is a subject of any other country.
 SCO_IRE_subject: "Alba"                                                # Applies when the country is a subject of a specific another country.
 SCO_autonomy_dominion: "Dominion of Scotland"                          # Applies when the country has the specified autonomy type with any other country as overlord.
 SCO_IRE_democratic_autonomy_integrated_puppet: "Most Northern Ireland" # Example of mixing these together. Must be in the country-ideology-autonomy order.
 COUNTRY_SCO_autonomy_dominion: "Comhairle nan $NONIDEOLOGY$"           # The first tag can be replaced with COUNTRY to apply to a generic country.

IDs of autonomous states can be found within /Hearts of Iron IV/common/autonomous_states/*.txt files, while the names of ideology types can be found in /Hearts of Iron IV/common/ideologies/*.txt files.
The country names are applied with the following priority:

  • Autonomous state with a specific country as overlord
  • Autonomous state
  • Subject of a specific country
  • Subject
  • Ideology type
  • Ideology group
  • TAG
  • COUNTRY

For example, COUNTRY_SCO_autonomy_dominion, due to being on the top of the list, will apply towards every country that's a dominion of Scotland, unless a more specific mix of a Scottish-controlled dominion applies (e.g. ENG_SCO_autonomy_dominion or COUNTRY_SCO_democratic_autonomy_dominion).

Inside of subject names, nested strings can be used that correspond to the overlord's name and the country's non-ideology name. Despite the fact that the latter doesn't seem to be subject-related, it cannot be used in names of independent countries. These include:

  • $NONIDEOLOGY$, $NONIDEOLOGYADJ$, and $NONIDEOLOGYDEF$ for the non-ideology name.
  • $OVERLORD$, $OVERLORDADJ$, and $OVERLORDNAMEDEF$ (Note the NAME) for the overlord's name.

This can only be used in country names, regardless if it's an automatically-applying name or a cosmetic tag.

These localisation keys may unintentionally make the country name be something unexpected. For example, the base game 土耳其的国旗 土耳其 national spirit TUR_liberalism gets used as the country's name when it gets a leader with the liberalism ideology type, making it have the name of "Liberalism". To find such instances, most text editors have capacity to search entire folders. By searching for the country's unintended name surrounded by quotes (in this case, "Liberalism") in all of the loaded localisation files (usually the mod and the base game), the file with the root cause can be found to know the localisation key. From this key, every instance of the database entry with the overlapping name can be found and edited with another folder search, with the localisation key either deleted by copying over the entire file if necessary or replaced without copying the file.

Other localisation

Other than the country name, there are certain other aspects of localisation that are commonly used to provide country-specific flair. Same as the name, this can go into any /Hearts of Iron IV/localisation/english/*_l_english.yml file with the UTF-8-BOM encoding:

  • Party names. More strictly, parties are country-specific names for ideology group that show up near the pie chart in the politics and diplomacy menus, whose names can also be accessed elsewhere with localisation namespaces. A party uses up to 2 localisation keys: the regular name that appears in the piechart and the optional long name, which appears when hovering over the party name. If the long name is undefined, it will re-use the regular name.
A localisation key for the regular name follows the TAG_ideology_party format, while the long name uses the TAG_ideology_party_long format.
  • Equipment: In order to rename an equipment type for a country, the localisation key used for it needs to be prefixed with the country's tag (separated with an underscore), such as TAG_infantry_equipment_1. Equipment may also have an optional short name, by appending _short to the key. Equipment is defined in /Hearts of Iron IV/common/units/equipment/*.txt files, where the IDs can be obtained. The same also works for equipment modules.

Some other localisation keys that support similar country prefixing, such as division experience titles or idea/advisor names. Example localisation file with party/equipment renaming:

l_english:
  SCO_communism_party: "SCP"
  SCO_communism_party_long: "Scottish Communist Party"
  SCO_neutrality_party: "True Scotsman" # The long name will re-use this
  SCO_artillery_equipment: "Armata 75mm wz. 31 St."
  SCO_artillery_equipment_short: "75mm wz. 31"

Starting characters

主条目:Character modding

Characters are defined in any file in the /Hearts of Iron IV/common/characters/ folder. An example of a file within that folder, with just a country leader, is the following:

characters = {
    SCO_ronald_mcdonald = {
        name = SCO_ronald_mcdonald
        portraits = {
            civilian = {
                large = GFX_SCO_ronald_mcdonald
            }
        }
        country_leader = {
            ideology = socialism
            traits = { scary_clown }
        }
    }
}

The ideology defined for the country leader must be an ideology type, rather than an ideology group such as 民主主义民主主义. A list of ideology types across groups, alongside more information, can be found on the dedicated character modding article.

The picture used is a spriteType, defined in any /Hearts of Iron IV/interface/*.gfx file. It is recommended to use a new file for this purpose instead of overwriting the base game files. An example of how a new file can look like is the following:

spriteTypes = {
    spriteType = {
        name = GFX_SCO_ronald_mcdonald
        texturefile = gfx/leaders/SCO/ronald_mcdonald.dds
    }
}

The name picked for the character depending on the language set when launching the game is defined within /Hearts of Iron IV/localisation/. In particular, for English, this would be in any /Hearts of Iron IV/localisation/english/*_l_english.yml file as this: SCO_ronald_mcdonald:0 "Ronald McDonald". The description when hovering over the character can be added by appending _desc to the character's name, as SCO_ronald_mcdonald_desc:0 "Insert description here".

In order to appear, a character must be recruited in the history file of the country. This is done with the recruit_character effect, as the following:

recruit_character = SCO_ronald_mcdonald

If multiple country leaders fall under the same political party, the game will place the first-recruited one as its leader. Since set_politics = { ... } forces a leader of the specified ideology group to come to power, any characters recruited after a set_politics block will not immediately become country leader since the country already has one: recruitment of the intended country leader must be before setting politics.
Corps commanders, field marshals, admirals, and advisors are also regarded as characters in the in-game code, and are added similarly: defined in the characters file and then recruited in /Hearts of Iron IV/history/countries/TAG*.txt

Order of battle

Parts of this section are transcluded from Division modding

If the country will exist at the start, an order of battle is necessary for the country to have an army. Orders of battle are used for establishing the starting military of the country, and they are generally separated into land, naval, and air branches, since enabling the 炮手就位炮手就位 and 唯有浴血唯有浴血 DLCs requires separate definitions for the navy and the air force respectively that are not compatible with the DLC being disabled.

Each order of battle must be loaded, usually in country history, in order for the units to show up. The filename is irrelevant, as long as it matches up with the one given in the country history file.

The internal names for sub-units can be found in /Hearts of Iron IV/common/units/*.txt files, localisation can be checked as well. For the sake of briefness, naval and air branches will be covered in the main article of Division modding instead.

Division template

参见:Effect

Land units require a template of some sort, which assigns the necessary information. The template definition is equivalent to the division_template effect internally. A simple template can be defined as such:

division_template = {
    name = "Blueskirt Division"
    regiments = {
        infantry = { x = 0 y = 0 }
        infantry = { x = 0 y = 1 }
        artillery_brigade = { x = 1 y = 0 }
        artillery_brigade = { x = 1 y = 1 }
    }
    support = {
        artillery = { x = 0 y = 0 }
    }
}
  • name = "" is the name of the division template as it shows up in the template selection. This will also get used for creating or modifying units.
  • regiments = { ... } and support = { ... } decide the sub-units of the template, meaning combat battalions and support companies respectively. In particular:
    • subunit = { x = 0 y = 0 } decides the placement of the specified sub-unit. The coordinates represent the Cartesian coordinate system, where (0,0) is the top-left corner, x goes left-to-right, and y goes up-to-down. For a unit to be placed as a support company, it must have group = support in its definition, and to be placed in combat battalions, it must have a different group. The group cannot change in a single y column.
By default, the combat battalions have NDefines.NMilitary.MAX_DIVISION_BRIGADE_WIDTH = 5 columns and NDefines.NMilitary.MAX_DIVISION_BRIGADE_HEIGHT = 5 rows, while the support companies have NDefines.NMilitary.MAX_DIVISION_SUPPORT_WIDTH = 1 column and NDefines.NMilitary.MAX_DIVISION_SUPPORT_HEIGHT = 5 rows.[3] The max index is one less than the total amount.

There are other arguments that can be used in a division template, as outlined in Division modding. The most common one to include is division_names_group = USA_INF_01: this forcefully changes the name group used for new divisions, defined in /Hearts of Iron IV/common/units/names_divisions/*.txt files. This is used to automatically generate names and numeration for new divisions, such as a division newly created by the player being named "1st 'Big Red One' Division". If not set, the template automatically picks the name group based on the sub-units.

Division placement

The units = { ... } block is used for positioning land and naval divisions. In particular, a land division placement is done via division = { ... }:

units = {
    division= {
        name = "1st Blueskirt Division"
        location = 9392 # Edinburgh
        division_template = "Blueskirt Division"
        start_experience_factor = 0.2
        start_equipment_factor = 0.3
    }
    division= {
        division_name = {
            is_name_ordered = yes
            name_order = 35
        }
        location = 6488
        division_template = "Infanterie-Division"
        force_equipment_variants = { infantry_equipment_0 = { owner = "SCO" } }
        officer = {
            name = SCO_officer_1
            portraits = {
                army = {
                    large = GFX_SCO_officer_1
                    small = GFX_SCO_officer_generic_small
                }
            }
        }
    }
}

For the division naming, there are two mutually-exclusive ways to do so:

  • name = "Unit's name" directly changes the name of the division to the given string.
  • division_name = { ... } instead uses the name group assigned to the division template:
    • is_name_ordered = yes is mandatory to include.
    • name_order = 35 sets the number that gets used for the numeration. If the name group's ordered = { ... } includes this number, that entry gets used. Otherwise, the fallback_name is used.

There are these mandatory arguments in addition to the name:

  • location = 1234 is the province where the unit should be positioned.
  • division_template is the name of the template that the unit should use. Generally best to limit to the one that's defined in the same file.

There are also optional arguments:

  • start_experience_factor = 0.2 sets the experience level of the division (from Greens to Veterans) in the range from 0 to 1. If unset, defaults to 0. The experience level boundaries in the base game are NDefines.NMilitary.UNIT_EXP_LEVELS = { 0.1, 0.3, 0.75, 0.9 }
  • start_equipment_factor = 0.5 decides the starting equipment level of the division, not deciding on the manpower. The equipment is not subtracted from the reserves of the country. If unset, defaults to 1.
  • start_manpower_factor = 0.3 decides the starting manpower level of the division. If unset, then it's automatically subtracted from the reserves of the country until the highest possible level.
  • force_equipment_variants = { ... } is a set of equipment types that the division should use, replacing the default. Each entry in there is equipment_type = { ... }, which may include:
    • owner = TAG is the owner of the equipment that should be used. This should be the same as the country which gets the order of battle.
    • creator = TAG is the original creator of the equipment that should be used. This is used to determine the variants, and it defaults to the owner if not specified.
    • amount = 14 is how much of the equipment should be there. The rest of required equipment within the archetype will remain ungiven.
    • version_name = "Variant's name" is the name of the equipment variant that should be used. If the equipment type requires a variant to use, such as tanks in 寸步不退寸步不退, this is mandatory. Otherwise, this is optional.
  • officer = { ... } is a character definition that will be used for the divisional commander if promoted to a commander or the officer corps system is used. In particular, these attributes are common inside:
    • name = loc_key is the localisation key to be used as the division commander's name.
    • portraits = { army = { large = "GFX_portrait_SCO_character" small = "GFX_idea_SCO_character" } } is the portrait that the division commander must use. The large portrait will be used for the corps commander promotion and the small portrait will be used for the officer corps system. If both are unset, randomly generates a portrait. If the large is set, the small portrait will default to the name of large portrait with _small appended to the end.

Equipment production

The equipment production is simulated using the instant_effect = { ... } block. This is a regular effect block, any effect can be used here. Usually, the production is added in this manner:

instant_effect = {
    add_equipment_production = {
        equipment = {
	    type = infantry_equipment_0
	    creator = "ARG"
	}
	requested_factories = 1
	progress = 0.19
	efficiency = 100
    }
}

The add_equipment_production = { ... } has these attributes:

  • equipment = { ... } decides on which equipment specifically should be made, in particular:
    • creator = TAG is the creator of the equipment. Usually it's the same person who makes the equipment, but it may be different for lend-leases.
    • type = infantry_equipment_0 is the exact equipment type that should be produced. The technology to unlock it, if needed, must be researched by the creator. Equipment can be found in /Hearts of Iron IV/common/units/equipment/*.txt files.
    • version_name = "Variant name" is the variant that should be used for equipment, usually defined in country history. This is mandatory if the equipment requires a variant to produce, such as ships in 炮手就位炮手就位 or airplanes in 唯有浴血唯有浴血. Otherwise, it's optional.
  • requested_factories = 1 is the amount of military factories or dockyards that should be dedicated towards producing this equipment type. If unfulfilled, the factories will be assigned into the queue.
  • progress = 0.2 is used to assign the current amount of progress towards a single piece of equipment being finished. This is usually changed for expensive equipment, such as battleships.
  • efficiency = 100 is, with 0 as 0% and 100 as 100%, the production efficiency which the factories should have immediately.

Character names

Character names are used for randomly-generated characters. This includes but is not limited to generic advisors, division commanders, newly-created unit leaders, or generic country leaders. Any /Hearts of Iron IV/common/names/*.txt file can be used as the file, and each country's entry is marked by being a block with the name of the country's tag (with default or a cosmetic tag also being possible). An example entry looks like this:

TAG = {
    male = {
        names = {
            Name "Name with multiple words"
        }
    }
    female = {
        names = {
            Name "Name with multiple words"
        }
    }
    surnames = {
        Surname "Surname with multiple words"
    }
    callsigns = {
        Callsign "Callsign with multiple words"
    }
}

This will assign these names to TAG. In particular:

  • names = { ... } is used to assign the first names of the characters. For aces, this is used for the GetName localisation namespace. For other characters or pseudo-characters, it's used as the word or the combination of words that are placed in the beginning of the name.
  • surnames = { ... } is used to assign the last names of the characters. For aces, this is used for the GetSurname localisation namespace. For other characters or pseudo-characters, it's used as the word or the combination of words that are placed in the end of the name.
  • male = { ... } and female = { ... } are used to assign a name or a surname to be specific to a particular gender. names and surnames may be used either inside or outside of the gendered blocks, in case of unisex names or gendered surnames.
  • callsigns = { ... } is used to assign a callsign to newly-generated operatives.

Quotation marks may be used in order to include whitespaces inside of a single token, as names are traditionally unlocalised.

Character portraits

主条目:Portrait modding

When the game automatically generates a country or a unit leader, a portrait is randomly chosen from a pool that depends on country or continent, if there's not a country-specific one. This pool is located in any /Hearts of Iron IV/portraits/*.txt file. An example entry looks like

TAG = {
    navy = {
        male = {
            "GFX_navy_portrait_male_1"
        }
        female = {
            "GFX_navy_portrait_female_1"
        }
    }
    army = {
        male = {
            "GFX_army_portrait_male_1"
        }
        female = {
            "GFX_army_portrait_female_1"
        }
    }
    operative = {
        male = {
            "GFX_operative_portrait_male_1"
        }
        female = {
            "GFX_operative_portrait_female_1"
        }
    }
    political = {
        neutrality = { # Each ideology group should be present individually.
            male = {
                "GFX_neutrality_portrait_male_1"
            }
            female = {
                "GFX_neutrality_portrait_female_1"
            }
        }
    }
}

This assigns these particular spriteTypes to the newly-created character. In particular, it is important for army portraits to also have a small equivalent, created as a new spriteType where the name attribute is the same as the large one, but with _small to the end (e.g. GFX_army_portrait_male_1_small would be a small male portrait in the example). This is used for the Officer corps system.

Adding the country to the game

The country will exist as long as an entry in /Hearts of Iron IV/common/country_tags/*.txt exists. However, it will not exist on the map at first.

If it should appear on the game's start, whether fully owning the states or just having them as cores, the states themselves need to be edited to be owned by the country at the game's start, stored in /Hearts of Iron IV/history/states/*.txt files.

If the country is only to appear in the middle of the game, effects can be used within any effect block, such as a focus reward or an event option. In particular, add_state_core and transfer_state, within that country's scope can be used to, respectively, core the specified states and change their owner and controller to the needed country.

Notes and references

^ a: A similar process applies for other languages that the game supports, with the filename ending with the internal name of the language. The exact folder path is actually irrelevant, as long as the file is contained within the localisation folder or any of its subfolders at any depth level.
^ b: If the correct settings of 32 bitdepth/bits per pixel and no RLE encoding are used, saving the flag should result in a consistent filesize each time. Paint.net, however, adds an approximately 500 byte large watermark to the end of the file if it is used to save the flag, which is not present when GIMP or Photoshop are used instead. The filesize is as shown in the Windows File Explorer and may differ in rounding if viewed elsewhere, such as the image editor's export menu.

  1. NDefines.NGraphics.COUNTRY_COLOR_SATURATION_MODIFIER = 0.6 and NDefines.NGraphics.COUNTRY_COLOR_BRIGHTNESS_MODIFIER = 0.8 in Defines
  2. NDefines.NGraphics.COUNTRY_FLAG_TEX_WIDTH = 82, NDefines.NGraphics.COUNTRY_FLAG_TEX_HEIGHT = 52, NDefines.NGraphics.COUNTRY_FLAG_MEDIUM_TEX_WIDTH = 41, NDefines.NGraphics.COUNTRY_FLAG_MEDIUM_TEX_HEIGHT = 26, NDefines.NGraphics.COUNTRY_FLAG_SMALL_TEX_WIDTH = 10, and NDefines.NGraphics.COUNTRY_FLAG_SMALL_TEX_HEIGHT = 7 in Defines
  3. NDefines.NMilitary.MAX_DIVISION_BRIGADE_WIDTH = 5, NDefines.NMilitary.MAX_DIVISION_BRIGADE_HEIGHT = 5, NDefines.NMilitary.MAX_DIVISION_SUPPORT_WIDTH = 1, and NDefines.NMilitary.MAX_DIVISION_SUPPORT_HEIGHT = 5 in Defines