Idea修改:修订间差异

本页面所适用的版本可能已经过时,最后更新于1.11
无编辑摘要
无编辑摘要
 
(未显示3个用户的6个中间版本)
第1行: 第1行:
{{Version|1.11}}[[:en:Ideas|Ideas]] 是一种向国家添加修正的固定方式,尤其是包括[[:en:National_spirit| 民族精神]] 、法案、设计商(p社在1.13版本中已经用MIO系统代替了该类别)、[[:en:Officer_corps#Spirits| 内阁]] 和隐藏民族精神。Ideas被定义在 {{path|common/ideas/*.txt}} 文件中,并且Ideas的类别被定义在 {{path|common/idea_tags/*.txt}} 文件中
{{Version|1.11}}
{{需要翻译|译者=霜泽图书馆}}
{{Version|1.11}}
 
[[Ideas]] are a static way to apply modifiers to a country, notably including [[National spirit|national spirits]], laws, designers, [[Officer corps#Spirits|officer corps spirits]], and hidden ideas. Ideas themselves are defined in {{path|common/ideas/*.txt}}, while idea categories are defined in {{path|common/idea_tags/*.txt}}
 
__TOC__
__TOC__


== 创建民族精神==
== National spirit creation ==
译者注:大家在各种翻译内看到的民族精神和国家精神,实际上指的是同一个idea。本文翻译则使用“民族精神”作为译词。
Spirits are created in {{path|common/ideas/*.txt}}. An example of a file with empty spirits, without modifiers yet still applicable if added via <code>add_ideas = idea_name</code>, is
 
<pre>ideas = {
民族精神文件在{{path|common/ideas/*.txt}} 中创建。这是不存在任何效果的民族精神(虽然该民族精神内不存在修正,但仍可通过 <code>add_ideas = idea_name</code> 的效果代码进行添加)。<pre>ideas = {
    country = {
    country = {
      my_idea_1 = {
      my_idea_1 = {
第12行: 第16行:
      }
      }
    }
    }
}</pre> 上述内容中,<code>ideas = {...}</code> 中包含了所有的idea,这是由于《钢铁雄心4》引擎的限制所必须的。同时,<code>country = {...}</code> 是一个idea类别(这个类别定义了该idea为民族精神),这就是为什么游戏会把 my_idea_1 my_idea_2 识别为民族精神,而不是同样属于idea的法案或是内阁。
}</pre>In this case, <code>ideas = { ... }</code> encompasses each idea in the file, necessary to include due to the engine consraints. Meanwhile, <code>country = {}</code> is an idea category, which is why the game would recognise <code>my_idea_1</code> and <code>my_idea_2</code> as spirits rather than laws or designers, which are also ideas.
===本地化===
对于简体中文(Simp_chinese)的制作者来说,idea的本地化可以在任意 '''UTF-8-BOM 编码'''的{{path|localisation/simp_chinese/*_simp_chinese.yml}} 文件中定义。 如果一个idea没有名称,游戏会使用  {{path|common/names}} 中国家的随机名称列表创建一个名称。'''但这不适用于民族精神,因为民族精神使用的是idea的ID。'''


并且,一个idea可以同时拥有一个名称和一个描述,将鼠标悬停在其上时会显示其描述。下图则以 ZZZ_example_idea 为例,它们的本地化条目是这样定义的:<syntaxhighlight lang="yaml">l_simp_chinese:
=== Localisation ===
  ZZZ_example_idea: "Idea 的名字"
Localisation for ideas is defined in any {{path|localisation/english/*_l_english.yml}} file '''encoded in UTF-8-BOM''', assuming the English language. If an idea does not have a name, the game uses the country's name-list in {{path|common/names}} to create a random name. This, however, does not apply to national spirits, where it uses the idea's ID. An idea can have both a name and a description that appears when hovering over it. Their localisation entries are defined as such, taking ZZZ_example_idea as an example:
  ZZZ_example_idea_desc: "idea的描述"</syntaxhighlight><code>name = new_idea_name</code> 会将idea名称指定为另一条本地化条目。如果您计划通过多次交换来修改一个idea,这将非常有用,因为这样就不必为该idea的每个实例创建重复的本地化条目。这同样需要在本地化文件中定义:<syntaxhighlight lang="yaml">l_simp_chinese:
<syntaxhighlight lang="yaml">l_english:
  new_idea_name: " 新的idea名字"
  ZZZ_example_idea: "Idea's name"
  new_idea_name_desc: " 新的idea描述"</syntaxhighlight>
  ZZZ_example_idea_desc: "Idea's description"</syntaxhighlight>
=== 图片(图标)===
<code>name = new_idea_name</code> assigns the idea's name to use a different localisation key. This can be useful if you plan to modify an idea by swapping it multiple times, ensuring that you needn't create a duplicate localisation entry for every instance of the idea. This will get defined in a localisation file similarly:
{| class="wikitable mw-collapsible"
<syntaxhighlight lang="yaml">l_english:
!General sprite overview
  new_idea_name: "New idea's name"
|-
  new_idea_name_desc: "New idea's description"</syntaxhighlight>
|For loading GFX, the game uses the sprite system. Sprites are code definitions that attach a name to an image file, as well as optionally adding additional information, such as animation, the amount of frames, the way that the image will be loaded, and so on. This means '''placing an image into the gfx folder isn't enough for it to work''', a sprite has to use that image file as well.
=== Picture ===
Sprites are defined in any /Hearts of Iron IV/interface/*.gfx file (this is separate from gfx/interface/), opened with a text editor. To create a new .gfx file, a text file can be created and renamed to change the extension (on Windows, the Windows Explorer needs to show the extensions, which it doesn't by default). In particular, sprites are defined within a <code>spriteTypes = { ... }</code> block, as to separate from fonts and map arrows also defined in that folder, while the simplest sprite with the least mandatory properties is a <code>spriteType = { ... }</code>. The simplest sprite definition looks like the following:
{{Sprite overview}}
  spriteTypes = {
By default, an idea uses a sprite that is the same as the idea's name, but with <code>GFX_idea_</code> prepended in the beginning. For example, an idea with the name of <code>my_idea_1</code> will use the sprite with the name of <code>GFX_idea_my_idea_1</code>.
   spriteType = {
  
     name = GFX_first_sprite             # In some cases, beginning with GFX_ is mandatory for it to work.
This is possible to change using the <code>picture = my_sprite</code> attribute within the idea. '''The game still inserts a prefix of <code>GFX_idea_</code> to the argument''' to decide the sprite that should be used, e.g. <code>picture = XYZ</code> leads to <code>GFX_idea_XYZ</code> being used as the sprite. If the game cannot find a sprite with the name it expects, the [[File:unknown.png|29px]] default icon will be used instead.<br/>
     texturefile = gfx/interface/folder/filename.dds # The folder and filename don't matter, as long as they are correct
The prefix being inserted means that, most of the time, <code>picture = GFX_XYZ</code> (which makes <code>GFX_idea_GFX_XYZ</code> get used as the sprite) or <code>picture = idea_XYZ</code> (which makes <code>GFX_idea_idea_XYZ</code> get used as the sprite) will lead to the game expecting a sprite that doesn't exist and that sprites that do not follow the <code>GFX_idea_XYZ</code> naming pattern cannot be used as idea pictures.
   }                          # Only the forward slash '/' (can be doubled as '//') can be used to separate folders.
   spriteType = {                    # The image doesn't have to be .dds, as .tga and .png are acceptable.
     name = GFX_second_sprite
     texturefile = gfx/interface/folder2/filename2.dds
     noOfFrames = 2 # Splits the image into 2 halves, which may be switched between dynamically in GUI
   }
}
In this case, this creates a sprite with the name of <code>GFX_first_sprite</code> and attaches the /Hearts of Iron IV/gfx/interface/folder/filename.dds image to it, and a second sprite similarly. The second sprite will be split into 2 frames: this is decided by having the left half of the image as the first frame and the right half as the second frame (more frames would further split the image horizontally). This doesn't make the sprite animated, just turns on the option to switch between the two halves as needed. <code>GFX_second_sprite:1</code> serves as a reference to the first frame, and GUI can be set up to change the shown frame depending on context, such as with radio stations.


In order to add animation, a frameAnimatedSpriteType is used.
If the <code>texturefile</code> within the sprite is incorrect, the idea will be invisible in the country politics view, yet still apply the modifiers. Ensure that the idea is stored with the same folder path location, the same filename (including the extension), and that the right folder separator is used.


'''It's never mandatory to copy a base game file to change a sprite'''. If there are duplicate definitions of a sprite with the same name in different files, the game will prioritise the one that would be evaluated later, based on the filename, and the older sprite will be ignored in entirety. This can be ensured by beginning the replacement file's name with a symbol late in the ASCII character table. Typically the lowercase letter 'z' is used for this purpose. For example, to change the amount of frames in <code>GFX_idea_traits_strip</code> to 10, it is possible to define a sprite with that name with 10 frames in the mod's modname/interface/zz_replace.gfx file instead of copying over the base game file.
It is also possible to make the picture depend on the <code>graphical_culture_2d</code> of the country, defined in the {{path|common/countries/*.txt}} file. This is done by appending the name after the picture's name, separated by an underscore. For example, a sprite with the name of <code>GFX_idea_my_picture_middle_eastern_2d</code> in its definition will show up instead of <code>GFX_idea_my_picture</code> for countries that have the <code>middle_eastern_2d</code> 2D graphical culture.


Since most .gfx files define integral parts of the user interface, copying them over can lead to the mod's loaded files missing sprites upon a major game update, which would appear in-game as the default image, which is the error dog by default. As to ease the burden of needing to check the interface files, it's best to never copy over .gfx files, unless more additions would be actively harmful to the mod, such as with interface/subuniticons.gfx
=== Implementation ===
|}
A spirit can only be added manually, using an [[effect]]. <code>add_ideas = idea_name</code> within an effect block (Such a focus completion reward), while <code>remove_ideas = idea_name</code> will remove it.
默认情况下,一个idea会使用一个与该idea名称相同的sprite图形,但需要开头加上<code>GFX_idea_</code> 。例如,名称为<code>my_idea_1</code> 的idea将使用名称为 <code>GFX_idea_my_idea_1</code> 的sprite。


这可以使用idea中的 <code>picture = my_sprite</code> 属性来更改。游戏仍会在参数中插入 <code>GFX_idea_</code> 前缀,以决定应使用的sprite,例如 <code>picture = XYZ</code> 会导致 <code>GFX_idea_XYZ</code> 被用作sprite。如果游戏找不到与它期望的名称相同的sprite,就会使用  [[File:unknown.png|29px|link=https://hoi4.paradoxwikis.com/File:Unknown.png]] 默认图标代替。
In order to swap two ideas and have the game show the modifiers, <code>swap_ideas</code> is used. '''There is no way to directly modify an idea''', however in case the 2 swapped spirits have the same name in localisation, this will show up in-game as modifying the idea. <code>swap_ideas</code> is used as the following:
 
<pre>swap_ideas = {
插入前缀意味着,在大多数情况下,<code>picture = GFX_XYZ</code>(这会使 <code>GFX_idea_GFX_XYZ</code> 用作sprite)或<code>picture = idea_XYZ</code>(这会使 <code>GFX_idea_idea_XYZ</code> 用作sprite)会导致游戏试图调用一个不存在的sprite,而不遵循 <code>GFX_idea_XYZ</code> 命名模式的sprite不能用作idea的图标。
 
如果sprite中的<code>texturefile</code> 文件不正确,该idea在国家政治视图中将不可见,但仍会应用修正效果。所以确保idea以相同的文件夹路径位置、相同的文件名(包括扩展名)存储,并使用正确的文件夹分隔符。
 
还可以让图片根据  {{path|common/countries/*.txt}} 文件中定义的国家 <code>graphical_culture_2d</code> 变化。具体做法是在图片名称后添加该名称,并用下划线分隔。例如,在定义中包含 <code>GFX_idea_my_picture_middle_eastern_2d</code> 名称的精灵将代替 <code>GFX_idea_my_picture</code>,出现在拥有 <code>middle_eastern_2d</code> 文化的国家中。
===实际运用===
民族精神只能通过[[:en:Effect|效果]]手动添加. 在相关效果块(如国策完成奖励)内 <code>add_ideas = idea_name</code> 可添加国家精神,而 <code>remove_ideas = idea_name</code> 则会将其移除。
 
为了交换两个idea并让游戏显示追加效果的变化,需要使用 <code>swap_ideas</code>。''' 虽然无法直接修改一个idea''' ,但如果被交换的两个idea在本地化文件中具有相同的名称(id相同),游戏中的效果就会显示追加该idea的效果(modifier 持续性效果)。但是p社仅仅在这里展示了<code>swap_ideas</code> 的idea效果的特殊用法,即实现追加效果。一般情况下,<code>swap_ideas</code>效果的原意则是替换两个民族idea,'''若id相同,则被识别为追加效果;如若id不同,则是替换效果(先移除一个idea,后添加一个新的idea)。'''
 
替换(追加)idea的方法如下:<pre>swap_ideas = {
    remove_idea = old_idea
    remove_idea = old_idea
    add_idea = new_idea
    add_idea = new_idea
}</pre> 在大多数情况下,创建多个idea并在它们之间交换就足够了,比如有几个阶段的线性流程([[:en:Scripted_effects|Scripted effects]] 可用于创建一系列条件语句,并在每次需要时重复使用)。如果创建多个idea太不可行,比如有多个可以并行的修改流程,[[:en:Dynamic_modifiers|动态修正]] 将允许用变量作为修正数值,但它们只接受修正(也就是不接受研究或装备加成等无关属性),而且由于没有自动的热更新,因此更难操作。
}</pre>
In most cases, it's enough to create multiple ideas and swap between them, such as if there's a direct progression of several stages ([[Scripted effects]] can be used to create one series of conditional statements and re-use them each time it's needed). If creating multiple ideas is too infeasible, such as if there are several progressions that would need to be modified, [[dynamic modifiers]] allow variable modifier values, but they only accept modifiers (not unrelated attributes such as research or equipment bonuses) and are harder to work with due to no hot-reloading.


为了让民族精神持续有限的一段时间'''(暂时性民族精神)''',可以使用 <code>add_timed_idea</code> 效果:<pre>add_timed_idea = {
In order for a spirit to last for a period of time, the <code>add_timed_idea</code> effect is used as such:
<pre>add_timed_idea = {
    idea = my_timed_idea
    idea = my_timed_idea
    days = 365
    days = 365
}</pre> 可通过 [[:en:Effect#modify_timed_idea|modify_timed_idea]] 效果来延长或加快计时。
}</pre>[[Effect#modify_timed_idea|modify_timed_idea]] can be used to extend or speed up the timer as needed.


为了让一个国家在游戏开始就有idea,可以在 {{path|history/countries/}}  中的国家文件这个决定游戏开始时的历史信息的效果块中,使用[[:en:Effect#add_ideas|add_ideas]] (通常以扩展形式使用,可同时分配多个idea)可以让国家在游戏开局时就拥有民族精神。为了使该idea显示在国家选择界面中,需要对 [[:en:Bookmark_modding|bookmark]]文件进行编辑,将该idea包含在国家条目中的 <code>ideas = { ... }</code> 块中。
In order for a country to start with the idea, the file in {{path|history/countries/}} for that country serves as an effect block that decides the starting historical information. Using [[Effect#add_ideas|add_ideas]], usually in the expanded form to assign multiple ideas at once, in there will enforce it starting with the idea. In order for the idea to show up in country selection, the [[Bookmark modding|bookmark is edited]] to include the idea within its <code>ideas = { ... }</code> block for the country's entry.
===修正(持续性效果)===
[[:en:Modifiers|Modifiers]] are applied continuously as long as the spirit is applied to a country. Alongside modifiers, the spirit can also add a bonus to a technology category or modify an equipment archetype. The spirit can only apply modifiers towards the country that has the spirit, there is no way to scope into a different country. '''Each of these attributes is entirely separate within the idea''' and so each one should be located directly inside of the idea. For example, defining <code>research_bonus</code> inside of <code>modifier = { ... }</code> is erroneous, since <code>research_bonus</code> is an attribute of the idea rather than a modifier.


<code>modifier = { ... }</code> stores the regular modifiers, applied to the country with the spirit. A modifier block can list multiple modifiers, and negatives are also allowed. '''Variables do not work in this section''': instead, use [[:en:Dynamic_modifiers|dynamic modifiers]]. A typical example of a modifier block is the following:<pre>modifier = {
=== Modifiers ===
[[Modifiers]] are applied continuously as long as the spirit is applied to a country. Alongside modifiers, the spirit can also add a bonus to a technology category or modify an equipment archetype. The spirit can only apply modifiers towards the country that has the spirit, there is no way to scope into a different country. '''Each of these attributes is entirely separate within the idea''' and so each one should be located directly inside of the idea. For example, defining <code>research_bonus</code> inside of <code>modifier = { ... }</code> is erroneous, since <code>research_bonus</code> is an attribute of the idea rather than a modifier.
 
<code>modifier = { ... }</code> stores the regular modifiers, applied to the country with the spirit. A modifier block can list multiple modifiers, and negatives are also allowed. '''Variables do not work in this section''': instead, use [[dynamic modifiers]]. A typical example of a modifier block is the following:
<pre>modifier = {
    political_power_cost = 0.1
    political_power_cost = 0.1
    stability_factor = -0.2
    stability_factor = -0.2
}</pre><code>targeted_modifier = { ... }</code> is for using [[:en:Modifiers#Targeted_modifiers|modifiers targeted towards a different country]]. The target is specified as <code>tag = ABC</code>, where ABC represents the target's tag. These are still applied towards the country with the spirit, but their effect is targeted towards a different country. For example, the following block will give the country with the idea a 10% attack bonus against {{flag|Afghanistan}}:<pre>targeted_modifier = {
}</pre>
 
<code>targeted_modifier = { ... }</code> is for using [[Modifiers#Targeted_modifiers|modifiers targeted towards a different country]]. The target is specified as <code>tag = ABC</code>, where ABC represents the target's tag. These are still applied towards the country with the spirit, but their effect is targeted towards a different country. For example, the following block will give the country with the idea a 10% attack bonus against {{flag|Afghanistan}}:
<pre>targeted_modifier = {
    tag = AFG
    tag = AFG
    attack_bonus_against = 0.1
    attack_bonus_against = 0.1
}</pre><code>research_bonus = { ... }</code> grants the country a boost to researching a specific technology category. An unsorted list of technology categories can be found in {{path|common/technology_tags/}} or, if desiring to know which technologies exactly are assigned to each category, individual technologies can be checked in {{path|common/technologies/}}. The following example would provide a +10% bonus to researching destroyers and a -20% bonus to artillery:<pre>research_bonus = {
}</pre>
 
<code>research_bonus = { ... }</code> grants the country a boost to researching a specific technology category. An unsorted list of technology categories can be found in {{path|common/technology_tags/}} or, if desiring to know which technologies exactly are assigned to each category, individual technologies can be checked in {{path|common/technologies/}}. The following example would provide a +10% bonus to researching destroyers and a -20% bonus to artillery:
<pre>research_bonus = {
    dd_tech = 0.1
    dd_tech = 0.1
    artillery = -0.2
    artillery = -0.2
}</pre><code>equipment_bonus = { ... }</code> applies the bonuses towards an equipment archetype or a type of equipment archetypes. By default, the bonus is not granted immediately, but rather requiring to research a new tech first, which is how it's done within designer ideas. This can be prevented by adding <code>instant = yes</code> inside of the equipment archetype within the equipment bonus. Equipment archetypes are defined in {{path|common/units/equipment/*.txt}}, which is where you can also find what can be applied to them. The name of the block within the {{path|common/units/equipment/*.txt}} file would be the archetype, while <code>type = { ... }</code> or <code>type = archetype_type</code> provides the types that the equipment archetype has. The following example will modify the cost to produce equipment within the <code>artillery</code> type (including artillery, rocket artillery, and tank artillery) by -20%, applying immediately, as well as increasing soft attack of any infantry equipment researched after the spirit was added by 10%:<pre>equipment_bonus = {
}</pre>
 
<code>equipment_bonus = { ... }</code> applies the bonuses towards an equipment archetype or a type of equipment archetypes. By default, the bonus is not granted immediately, but rather requiring to research a new tech first, which is how it's done within designer ideas. This can be prevented by adding <code>instant = yes</code> inside of the equipment archetype within the equipment bonus. Equipment archetypes are defined in {{path|common/units/equipment/*.txt}}, which is where you can also find what can be applied to them. The name of the block within the {{path|common/units/equipment/*.txt}} file would be the archetype, while <code>type = { ... }</code> or <code>type = archetype_type</code> provides the types that the equipment archetype has. The following example will modify the cost to produce equipment within the <code>artillery</code> type (including artillery, rocket artillery, and tank artillery) by -20%, applying immediately, as well as increasing soft attack of any infantry equipment researched after the spirit was added by 10%:
<pre>equipment_bonus = {
    artillery = {
    artillery = {
      instant = yes
      instant = yes
第91行: 第86行:
      soft_attack = 0.1
      soft_attack = 0.1
    }
    }
}</pre><code>rule</code> modifies the set of rules that decide what the country is allowed to do. This usually includes diplomatic options (such as peace conference options or being called to war). They show up in the tooltip only if the rule differs from the value without the idea, e.g. <code>can_create_factions = no</code> will usually not appear in the tooltip as countries are already unable to create a faction by default.
}</pre>
 
<code>rule</code> modifies the set of rules that decide what the country is allowed to do. This usually includes diplomatic options (such as peace conference options or being called to war). They show up in the tooltip only if the rule differs from the value without the idea, e.g. <code>can_create_factions = no</code> will usually not appear in the tooltip as countries are already unable to create a faction by default.
{| style="float: left; width:50%"
{| style="float: left; width:50%"
| <pre>rule = {
|<pre>rule = {
    can_join_factions = no
    can_join_factions = no
    can_send_volunteers = yes
    can_send_volunteers = yes
}</pre>
}</pre>
|}
{| class="wikitable mw-collapsible"
!Game rule list
|-
|The following game rules exist as possible options:
{| class="wikitable sortable mw-collapsible"
!Internal name
!Localised name
!Notes
|-
|can_access_market
|Can access International Market (Puppets and Overlords can always access each other's market)
|
|-
|can_be_spymaster
|Can be Spy Master
|
|-
|can_boost_other_ideologies
|Can boost popularity of other ideologies
|
|-
|can_boost_own_ideology
|Can boost own party popularity in other countries
|
|-
|can_create_collaboration_government
|Can create collaboration governments
|
|-
|can_create_factions
|Can Create Factions
|
|-
|can_declare_war_on_same_ideology
|Can declare war on country with the same ideology group without a war goal
|
|-
|can_declare_war_without_wargoal_when_in_war
|Can declare war on a neighbor without a wargoal when at war with a major
|
|-
|can_decline_call_to_war
|Can decline call to war
|
|-
|can_force_government
|Can force government of another country to adopt the same ideology
|
|-
|can_generate_female_aces
|Women in your country are allowed to become military pilots
|
|-
|can_generate_female_country_leaders
|Can generate female country leaders
|
|-
|can_generate_female_unit_leaders
|Can generate female unit leaders
|
|-
|can_guarantee_other_ideologies
|Can guarantee other ideologies
|
|-
|can_join_factions
|Can join factions
|
|-
|can_join_factions_not_allowed_diplomacy
|Country's name is not allowed to join factions
|
|-
|can_join_opposite_factions
|Can Join Factions led by another Ideology
|
|-
|can_lower_tension
|Lowers World Tension with Guarantees
|
|-
|can_not_build_buildings
|CAN_NOT_BUILD_BUILDINGS
|Doesn't seem to work.
|-
|can_not_declare_war
|Can not declare wars
|Prevents generating wargoals, but not using existing ones.
|-
|can_occupy_non_war
|Can hold territory owned by a country they are not at war with
|
|-
|can_only_justify_war_on_threat_country
|Can justify war goals against a country that have not generated world tension
|
|-
|can_puppet
|Can puppet a country
|
|-
|can_send_volunteers
|Can send volunteer forces
|
|-
|can_use_kamikaze_pilots
|Can use kamikaze pilots
|
|-
|contributes_operatives
|Contributes Operatives to Spy Master: Yes
|Only has an effect for subjects.
|-
|units_deployed_to_overlord
|Control over deployed units go to overlord
|Only has an effect for subjects.
|}
|}
|}
{| style="float: right; width:50%"
{| style="float: right; width:50%"
|
| {{Game rule list|width=100%}}
|}
|}
{{clear}}


 
=== Effects ===
 
A spirit can be set to apply [[effects]] when added or removed. This is done, respectively, with <code>on_add</code> and <code>on_remove</code> effect blocks, looking like the following example:
 
<pre>on_add = {
 
=== 效果(瞬时性效果)===
可以设置民族精神在添加或删除时应用的[[:en:Effects|效果]] 。具体做法是分别使用 <code>on_add</code> <code>on_remove</code> 效果块,如下所示:<pre>on_add = {
    add_stability = 0.1
    add_stability = 0.1
}
}
on_remove = {
on_remove = {
    add_political_power = -50
    add_political_power = -50
}</pre> 只有在游戏开始后添加idea时,效果才会被执行:如果是通过history文件或bookmark文件的 <code>effect = { ...}</code> 块,则不会执行效果。在这种情况下,需要在添加idea的同一个效果块中复制添加idea时给出的效果。
}</pre>
=== 取消效果===
The effects will only get executed if the idea is added after the game has already started: if done via a history file or a bookmark's <code>effect = { ... }</code> block, the effects will not be executed. In that case, it's needed to replicate the effects given when adding the idea within the same effect block that adds the idea.
可以设置民族精神,使其在满足一组触发 [[:en:Triggers|条件]] 后取消。这可以通过<code>cancel</code> 效果实现。如果存在<code>on_remove</code> 效果块,取消也会触发idea中的<code>on_remove</code>效果。如下所示:<pre>cancel = {
 
=== Cancellation ===
A spirit can be set to automatically cancel itself once a set of [[triggers]] is met. This is done with the <code>cancel</code> block. A cancellation will also trigger the <code>on_remove</code> effect block in the idea if one is present. This will look like the following:
<pre>cancel = {
    has_political_power > 50 
    has_political_power > 50 
}</pre>
}</pre>
=== 其他效果 ===
=== Additional arguments ===
另一个触发条件是 <code>allowed_civil_war = { ... }</code> 当开始内战时,会对每一方进行条件判断,只有当条件判断结果为真时,才会出现民族精神。例如<code>has_government = democratic</code> 将确保内战中只有 {{Icon|Democratic|1}} 的一方才能获得民族精神。默认情况下,总是为假,导致内战开始时民族精神消失。若将其设置为 <code>always = yes</code>则在双方中都出现。
Another trigger block that can go into an idea is <code>allowed_civil_war = { ... }</code>. When starting a civil war, this is evaluated for each side, and the spirit will only appear for sides where this is true. For instance, a <code>has_government = democratic</code> will ensure that only the {{Icon|Democratic|1}} side in a civil war will obtain the spirit. '''By default, always false, leading to the spirits disappearing when a civil war starts.''' [[Conditions#always|Setting it to be always true]] can be preferred over the default, making it appear for both sides.


<code>do_effect = { ... }</code> 是一个条件效果,它为idea应用modifier指定了必要条件。如果不满足内条件,则该民族精神的modifier(包括研究和装备奖励)无效,但该idea不会被删除。
<code>do_effect = { ... }</code> is a trigger block that assigns the necessary conditions for the idea to apply its modifiers. If false, the modifiers (including research and equipment bonuses) not apply, but the idea will not be removed.


=== 完整的民族精神例子===
 
=== Full idea file example ===
<pre>
<pre>
ideas = {
ideas = {
第301行: 第182行:
    }
    }
}</pre>
}</pre>
== 其他Idea类别==
 
== Other idea categories ==
Non-spirit ideas can use everything that can be within spirits, however there are more arguments that make sense to be added in them that do not do anything in spirits or don't have any reason to be added.
Non-spirit ideas can use everything that can be within spirits, however there are more arguments that make sense to be added in them that do not do anything in spirits or don't have any reason to be added.
===隐藏Idea===
Hidden idea are exactly the same as regular spirits in every aspect in regards to creation, except for the fact that they have to be defined within the <code>hidden_ideas</code> idea category instead of using <code>country</code>. This will ensure that the idea will be hidden and not show up in the spirit container. However, it can still make sense to create localisation for them: If a hidden idea cancels automatically, the pop-up will show up, and hovering over certain elements (Such as the stability counter or research speed) will show each idea that modifies it.
===Idea category arguments ===
These arguments are used within the idea category within the {{path|common/ideas/*.txt}} file.


<code>designer = yes</code> marks the entire category as designer ideas. This is primarily used for AI.
=== Hidden ideas ===
Hidden idea are exactly the same as regular spirits in every aspect in regards to creation, except for the fact that they have to be defined within the <code>hidden_ideas</code> idea category instead of using <code>country</code>. This will ensure that the idea will be hidden and not show up in the spirit container. However, it can still make sense to create localisation for them: If a hidden idea cancels automatically, the pop-up will show up, and hovering over certain elements (Such as the stability counter or research speed) will show each idea that modifies it


<code>law = yes</code> marks the entire category as laws. This is primarily used for AI.
=== Idea category arguments ===
These arguments are used within the idea category within the {{path|common/ideas/*.txt}} file.


<code>designer = yes</code> marks the entire category as designer ideas. This is primarily used for AI.<br/>
<code>law = yes</code> marks the entire category as laws. This is primarily used for AI.<br/>
<code>use_list_view = yes</code> marks the entire category to use a list view for selecting the idea, akin to how the base game treats laws.
<code>use_list_view = yes</code> marks the entire category to use a list view for selecting the idea, akin to how the base game treats laws.


These will look in the idea file like the following:<pre>ideas = {
These will look in the idea file like the following:
<pre>ideas = {
    my_law_category = {
    my_law_category = {
      law = yes
      law = yes
第324行: 第207行:
    }
    }
}</pre>
}</pre>
===Additional arguments ===
 
=== Additional arguments ===
This assumes that the idea is of the type that can be selected in-game, such as a law or a designer.
This assumes that the idea is of the type that can be selected in-game, such as a law or a designer.


<code>allowed</code> is a [[:en:Trigger|trigger]] block that checks only at the game's start or when loading a save, primarily used to restrict an idea to a country (As <code>tag = BHR</code> or <code>original_tag = POL</code>) and/or a DLC (As <code>has_dlc = "One Step Back"</code>). If an idea's allowed is unfulfilled, it will never appear within the selection unless it becomes true on the save being reloaded; however, manual assignment via <code>add_ideas</code> bypasses the check. If left out, assumes to be always allowed. '''This only checks once!'''
<code>allowed</code> is a [[trigger]] block that checks only at the game's start or when loading a save, primarily used to restrict an idea to a country (As <code>tag = BHR</code> or <code>original_tag = POL</code>) and/or a DLC (As <code>has_dlc = "One Step Back"</code>). If an idea's allowed is unfulfilled, it will never appear within the selection unless it becomes true on the save being reloaded; however, manual assignment via <code>add_ideas</code> bypasses the check. If left out, assumes to be always allowed. '''This only checks once!'''


<code>allowed_to_remove</code> is a trigger block that details when exactly you can remove the idea, changing it to a different one in the category. This is checked continuously, unlike <code>allowed</code>.
<code>allowed_to_remove</code> is a trigger block that details when exactly you can remove the idea, changing it to a different one in the category. This is checked continuously, unlike <code>allowed</code>.
第343行: 第227行:
<code>traits</code> is a block of traits that are assigned to this idea, defined in {{path|common/country_leader/*.txt}}, also granting a static modifier and showing up near the idea.
<code>traits</code> is a block of traits that are assigned to this idea, defined in {{path|common/country_leader/*.txt}}, also granting a static modifier and showing up near the idea.


<code>ledger</code> decides which intelligence ledger the idea will be assigned to. This is primarily a leftover now applying to the [[:en:Character_modding|character]] system, but this can still be used in officer corps spirits. Possible values are <code>army</code>, <code>air</code>, <code>navy</code>, <code>military</code> (Appearing on each of the prior ledgers), <code>civilian</code>, <code>all</code>, and <code>hidden</code>.
<code>ledger</code> decides which intelligence ledger the idea will be assigned to. This is primarily a leftover now applying to the [[Character modding|character]] system, but this can still be used in officer corps spirits. Possible values are <code>army</code>, <code>air</code>, <code>navy</code>, <code>military</code> (Appearing on each of the prior ledgers), <code>civilian</code>, <code>all</code>, and <code>hidden</code>.
=== Example===
 
=== Example ===
<pre>ideas = {
<pre>ideas = {
    law_category = {
    law_category = {
第379行: 第264行:
    }
    }
}</pre>
}</pre>
==Categories==
==Categories==
Idea categories are defined in any {{path|common/idea_tags/*.txt}} file. All categories will be contained in the <code>idea_categories</code> top element and can contain the following arguments:
Idea categories are defined in any {{path|common/idea_tags/*.txt}} file. All categories will be contained in the <code>idea_categories</code> top element and can contain the following arguments:
*<code>slot</code> is a proper idea category slot. This is what shows up in the GUI in the politics view menu, and this is what ideas have to have as their category in their definition.
* <code>slot</code> is a proper idea category slot. This is what shows up in the GUI in the politics view menu, and this is what ideas have to have as their category in their definition.
*<code>character_slot</code> is a [[:en:Character_modding|character]] slot. Ideas can also be defined to use this slot and it will show up in the GUI like a regular idea slot, however.
* <code>character_slot</code> is a [[Character modding|character]] slot. Ideas can also be defined to use this slot and it will show up in the GUI like a regular idea slot, however.
*<code>cost</code> is the default price in political power to add an idea within one of the slots of this category. This is applied if the idea doesn't have one.
* <code>cost</code> is the default price in political power to add an idea within one of the slots of this category. This is applied if the idea doesn't have one.
*<code>removal_cost</code> is the default price in political power to remove an idea within one of the slots of this category.
* <code>removal_cost</code> is the default price in political power to remove an idea within one of the slots of this category.
*<code>ledger</code> is the intelligence ledger defined to ideas in this category, unless overridden within the slot, idea, or character. Possible values are <code>army</code>, <code>air</code>, <code>navy</code>, <code>military</code> (Appearing on each of the prior ledgers), <code>civilian</code>, <code>all</code>, and <code>hidden</code>. Additionally, <code>invalid</code> can be used, forcing the ledger to be defined one level lower.
* <code>ledger</code> is the intelligence ledger defined to ideas in this category, unless overridden within the slot, idea, or character. Possible values are <code>army</code>, <code>air</code>, <code>navy</code>, <code>military</code> (Appearing on each of the prior ledgers), <code>civilian</code>, <code>all</code>, and <code>hidden</code>. Additionally, <code>invalid</code> can be used, forcing the ledger to be defined one level lower.
*<code>hidden</code> is a boolean value making this category not show up in the GUI. Optional, defaults to no.
* <code>hidden</code> is a boolean value making this category not show up in the GUI. Optional, defaults to no.
*<code>politics_tab</code> is a boolean value making this category show up in the politics tab. Optional, defaults to yes.
* <code>politics_tab</code> is a boolean value making this category show up in the politics tab. Optional, defaults to yes.
This will look like the following:<pre>idea_categories = {
 
This will look like the following:
<pre>idea_categories = {
    my_category = {
    my_category = {
      slot = my_slot
      slot = my_slot
第396行: 第284行:
      ledger = hidden
      ledger = hidden
    }
    }
}</pre>The category will then be used by the idea via the slot (which allows mapping an idea to a category)
}</pre>


The file also includes slot_ledgers, which distributes idea slots to intelligence ledgers individually, which will take priority over the idea category's ledger. An example of it being used is<pre>slot_ledgers = {
The category will then be used by the idea via the slot (which allows mapping an idea to a category)<br/>
The file also includes slot_ledgers, which distributes idea slots to intelligence ledgers individually, which will take priority over the idea category's ledger. An example of it being used is
<pre>slot_ledgers = {
XXX_idea_slot = civilian
XXX_idea_slot = civilian
ZZZ_idea_slot = invalid
ZZZ_idea_slot = invalid
}</pre>Invalid will require specification in each idea individually.
}</pre> Invalid will require specification in each idea individually.<br/>
===GFX and GUI===
===GFX and GUI===
{{See also|Interface modding}}Each idea category represents a row in the country politics view, while each slot represents a slot under that row.
{{See also|Interface modding}}
 
Each idea category represents a row in the country politics view, while each slot represents a slot under that row.<br/>
The <code>country_politics_idea_category_entry</code> container window within the {{path|interface/countrypoliticsview.gui}} file decides the user inteface information about each row. The most important thing here is the gridbox, as it decides the following:
The <code>country_politics_idea_category_entry</code> container window within the {{path|interface/countrypoliticsview.gui}} file decides the user inteface information about each row. The most important thing here is the gridbox, as it decides the following:
*The size of each idea slot within the category, by default 80 by width and 64 by height. This is used for distances between slots.
* The size of each idea slot within the category, by default 80 by width and 64 by height. This is used for distances between slots.
*The max amount of slots, '''by default 7 horizontally and 1 vertically.''' If not adjusted, it'd be impossible to have more than 7 idea slots in a category.
* The max amount of slots, '''by default 7 horizontally and 1 vertically.''' If not adjusted, it'd be impossible to have more than 7 idea slots in a category.
*The format of the gridbox, deciding in which direction the idea slots are added.
* The format of the gridbox, deciding in which direction the idea slots are added.
The idea category's icon, shown on the left of the category's row, is decided by the GFX_idea_categories sprite. The sprite is split into multiple frames horizontally, and each category is assigned a part of it depending on its order defined in {{path|common/idea_tags/*.txt}}. The sprite is defined in {{path|interface/countrypoliticsview.gfx}} and its definition in the base game consists of the following:<pre> spriteType = {
The idea category's icon, shown on the left of the category's row, is decided by the GFX_idea_categories sprite. The sprite is split into multiple frames horizontally, and each category is assigned a part of it depending on its order defined in {{path|common/idea_tags/*.txt}}. The sprite is defined in {{path|interface/countrypoliticsview.gfx}} and its definition in the base game consists of the following:
<pre> spriteType = {
name = "GFX_idea_categories"
name = "GFX_idea_categories"
texturefile = "gfx/interface/idea_categories.dds"
texturefile = "gfx/interface/idea_categories.dds"
noOfFrames = 6
noOfFrames = 6
}</pre>When adding a new category, make sure to update the sprite and the amount of frames accordingly.
}</pre>When adding a new category, make sure to update the sprite and the amount of frames accordingly.<br/>
 
An icon can be defined for idea slots, which will be used for them if there is no idea assigned to that slot. This definition in any {{path|interface/*.gfx}} file, taking XXX_idea_slot as an example, is done the following way:
An icon can be defined for idea slots, which will be used for them if there is no idea assigned to that slot. This definition in any {{path|interface/*.gfx}} file, taking XXX_idea_slot as an example, is done the following way:<pre> spriteType = {
<pre> spriteType = {
name = GFX_idea_slot_XXX_idea_slot
name = GFX_idea_slot_XXX_idea_slot
textureFile = gfx/interface/filename.dds
textureFile = gfx/interface/filename.dds
}</pre>In other words, the sprite must have the same name as the idea slot but with <code>GFX_idea_slot_</code> prepended in the beginning.
}</pre>In other words, the sprite must have the same name as the idea slot but with <code>GFX_idea_slot_</code> prepended in the beginning.
==Modifying cost of a slot==
 
{{anchor|Modifying cost of a category}} The <code><idea slot>_cost_factor</code> modifier can be used to modify the price in political power for adding ideas or characters in this slot. However, there is a restriction on that modifier. In order for it to work, the idea slot  needs to have any ideas or characters defined beforehand.
== Modifying cost of a slot ==
{{anchor|Modifying cost of a category}}
The <code><idea slot>_cost_factor</code> modifier can be used to modify the price in political power for adding ideas or characters in this slot. However, there is a restriction on that modifier. In order for it to work, the idea slot  needs to have any ideas or characters defined beforehand.


The files in the {{path|common/ideas/*.txt}} folder are loaded in the order of the Unicode character IDs, which put capital letters before underscores, which are put before lowercase letters. For example, this means that a file with the filename of <code>TAG.txt</code> is loaded before <code>_economy.txt</code> or <code>_manpower.txt</code> (the base game's locations of laws), which would get loaded before <code>country.txt</code>. Due to the above quirk, this means that an idea with the modifier affecting a price of a law, for instance, <code>economy_cost_factor = -0.10</code>, '''will throw an error if the filename starts with an uppercase character''' unless the laws are stored from files  different from base game.
The files in the {{path|common/ideas/*.txt}} folder are loaded in the order of the Unicode character IDs, which put capital letters before underscores, which are put before lowercase letters. For example, this means that a file with the filename of <code>TAG.txt</code> is loaded before <code>_economy.txt</code> or <code>_manpower.txt</code> (the base game's locations of laws), which would get loaded before <code>country.txt</code>. Due to the above quirk, this means that an idea with the modifier affecting a price of a law, for instance, <code>economy_cost_factor = -0.10</code>, '''will throw an error if the filename starts with an uppercase character''' unless the laws are stored from files  different from base game.


There are two primary ways to fix this. The first one is to simply change the filename of the country's idea file, changing it from, for instance, <code>GER.txt</code> to<code>germany.txt</code>. In case you have to keep the filename the same to overwrite a file, a new file can be created instead. Alternatively, [[:en:Modding#Mod_definition|assuming that you have a replace_path to the ideas folder]], you could rename the files storing the laws to begin with a character with a smaller ID, for instance, to <code>00_economy.txt</code>, which would get loaded prior to <code>TAG.txt</code>.
There are two primary ways to fix this. The first one is to simply change the filename of the country's idea file, changing it from, for instance, <code>GER.txt</code> to<code>germany.txt</code>. In case you have to keep the filename the same to overwrite a file, a new file can be created instead. Alternatively, [[Modding#Mod_definition|assuming that you have a replace_path to the ideas folder]], you could rename the files storing the laws to begin with a character with a smaller ID, for instance, to <code>00_economy.txt</code>, which would get loaded prior to <code>TAG.txt</code>.


Additionally, this also means that there have to be ideas defined within character slots for the modifier to work, such as <code>political_advisor_cost_factor = 0.1</code>. This is because characters are loaded later than ideas or country leader traits, so they're not loaded yet when evaluating the modifier, causing the error. This can be bypassed by creating ideas for the character slots in {{path|common/ideas/*.txt}} files. These will never appear for the countries as these are character slots rather than idea slots, but an idea that was loaded beforehand will correct the error.
Additionally, this also means that there have to be ideas defined within character slots for the modifier to work, such as <code>political_advisor_cost_factor = 0.1</code>. This is because characters are loaded later than ideas or country leader traits, so they're not loaded yet when evaluating the modifier, causing the error. This can be bypassed by creating ideas for the character slots in {{path|common/ideas/*.txt}} files. These will never appear for the countries as these are character slots rather than idea slots, but an idea that was loaded beforehand will correct the error.
==Notes==


== Notes ==
{{Cnote|a|Depends on the value in the {{path|common/idea_tags/*.txt}} file, which is always 150 in base game}}
{{Modding navbox}}
{{Modding navbox}}
[[Category:Modding]]
[[ 分类:Modding]]

2024年9月21日 (六) 18:44的最新版本


Ideas are a static way to apply modifiers to a country, notably including national spirits, laws, designers, officer corps spirits, and hidden ideas. Ideas themselves are defined in /Hearts of Iron IV/common/ideas/*.txt, while idea categories are defined in /Hearts of Iron IV/common/idea_tags/*.txt

National spirit creation

Spirits are created in /Hearts of Iron IV/common/ideas/*.txt. An example of a file with empty spirits, without modifiers yet still applicable if added via add_ideas = idea_name, is

ideas = {
    country = {
        my_idea_1 = {
        }
        my_idea_2 = {
        }
    }
}

In this case, ideas = { ... } encompasses each idea in the file, necessary to include due to the engine consraints. Meanwhile, country = {} is an idea category, which is why the game would recognise my_idea_1 and my_idea_2 as spirits rather than laws or designers, which are also ideas.

Localisation

Localisation for ideas is defined in any /Hearts of Iron IV/localisation/english/*_l_english.yml file encoded in UTF-8-BOM, assuming the English language. If an idea does not have a name, the game uses the country's name-list in /Hearts of Iron IV/common/names to create a random name. This, however, does not apply to national spirits, where it uses the idea's ID. An idea can have both a name and a description that appears when hovering over it. Their localisation entries are defined as such, taking ZZZ_example_idea as an example:

l_english:
 ZZZ_example_idea: "Idea's name"
 ZZZ_example_idea_desc: "Idea's description"

name = new_idea_name assigns the idea's name to use a different localisation key. This can be useful if you plan to modify an idea by swapping it multiple times, ensuring that you needn't create a duplicate localisation entry for every instance of the idea. This will get defined in a localisation file similarly:

l_english:
 new_idea_name: "New idea's name"
 new_idea_name_desc: "New idea's description"

Picture

By default, an idea uses a sprite that is the same as the idea's name, but with GFX_idea_ prepended in the beginning. For example, an idea with the name of my_idea_1 will use the sprite with the name of GFX_idea_my_idea_1.

This is possible to change using the picture = my_sprite attribute within the idea. The game still inserts a prefix of GFX_idea_ to the argument to decide the sprite that should be used, e.g. picture = XYZ leads to GFX_idea_XYZ being used as the sprite. If the game cannot find a sprite with the name it expects, the Unknown.png default icon will be used instead.
The prefix being inserted means that, most of the time, picture = GFX_XYZ (which makes GFX_idea_GFX_XYZ get used as the sprite) or picture = idea_XYZ (which makes GFX_idea_idea_XYZ get used as the sprite) will lead to the game expecting a sprite that doesn't exist and that sprites that do not follow the GFX_idea_XYZ naming pattern cannot be used as idea pictures.

If the texturefile within the sprite is incorrect, the idea will be invisible in the country politics view, yet still apply the modifiers. Ensure that the idea is stored with the same folder path location, the same filename (including the extension), and that the right folder separator is used.

It is also possible to make the picture depend on the graphical_culture_2d of the country, defined in the /Hearts of Iron IV/common/countries/*.txt file. This is done by appending the name after the picture's name, separated by an underscore. For example, a sprite with the name of GFX_idea_my_picture_middle_eastern_2d in its definition will show up instead of GFX_idea_my_picture for countries that have the middle_eastern_2d 2D graphical culture.

Implementation

A spirit can only be added manually, using an effect. add_ideas = idea_name within an effect block (Such a focus completion reward), while remove_ideas = idea_name will remove it.

In order to swap two ideas and have the game show the modifiers, swap_ideas is used. There is no way to directly modify an idea, however in case the 2 swapped spirits have the same name in localisation, this will show up in-game as modifying the idea. swap_ideas is used as the following:

swap_ideas = {
    remove_idea = old_idea
    add_idea = new_idea
}

In most cases, it's enough to create multiple ideas and swap between them, such as if there's a direct progression of several stages (Scripted effects can be used to create one series of conditional statements and re-use them each time it's needed). If creating multiple ideas is too infeasible, such as if there are several progressions that would need to be modified, dynamic modifiers allow variable modifier values, but they only accept modifiers (not unrelated attributes such as research or equipment bonuses) and are harder to work with due to no hot-reloading.

In order for a spirit to last for a period of time, the add_timed_idea effect is used as such:

add_timed_idea = {
    idea = my_timed_idea
    days = 365
}

modify_timed_idea can be used to extend or speed up the timer as needed.

In order for a country to start with the idea, the file in /Hearts of Iron IV/history/countries/ for that country serves as an effect block that decides the starting historical information. Using add_ideas, usually in the expanded form to assign multiple ideas at once, in there will enforce it starting with the idea. In order for the idea to show up in country selection, the bookmark is edited to include the idea within its ideas = { ... } block for the country's entry.

Modifiers

Modifiers are applied continuously as long as the spirit is applied to a country. Alongside modifiers, the spirit can also add a bonus to a technology category or modify an equipment archetype. The spirit can only apply modifiers towards the country that has the spirit, there is no way to scope into a different country. Each of these attributes is entirely separate within the idea and so each one should be located directly inside of the idea. For example, defining research_bonus inside of modifier = { ... } is erroneous, since research_bonus is an attribute of the idea rather than a modifier.

modifier = { ... } stores the regular modifiers, applied to the country with the spirit. A modifier block can list multiple modifiers, and negatives are also allowed. Variables do not work in this section: instead, use dynamic modifiers. A typical example of a modifier block is the following:

modifier = {
    political_power_cost = 0.1
    stability_factor = -0.2
}

targeted_modifier = { ... } is for using modifiers targeted towards a different country. The target is specified as tag = ABC, where ABC represents the target's tag. These are still applied towards the country with the spirit, but their effect is targeted towards a different country. For example, the following block will give the country with the idea a 10% attack bonus against 阿富汗的国旗 阿富汗:

targeted_modifier = {
    tag = AFG
    attack_bonus_against = 0.1
}

research_bonus = { ... } grants the country a boost to researching a specific technology category. An unsorted list of technology categories can be found in /Hearts of Iron IV/common/technology_tags/ or, if desiring to know which technologies exactly are assigned to each category, individual technologies can be checked in /Hearts of Iron IV/common/technologies/. The following example would provide a +10% bonus to researching destroyers and a -20% bonus to artillery:

research_bonus = {
    dd_tech = 0.1
    artillery = -0.2
}

equipment_bonus = { ... } applies the bonuses towards an equipment archetype or a type of equipment archetypes. By default, the bonus is not granted immediately, but rather requiring to research a new tech first, which is how it's done within designer ideas. This can be prevented by adding instant = yes inside of the equipment archetype within the equipment bonus. Equipment archetypes are defined in /Hearts of Iron IV/common/units/equipment/*.txt, which is where you can also find what can be applied to them. The name of the block within the /Hearts of Iron IV/common/units/equipment/*.txt file would be the archetype, while type = { ... } or type = archetype_type provides the types that the equipment archetype has. The following example will modify the cost to produce equipment within the artillery type (including artillery, rocket artillery, and tank artillery) by -20%, applying immediately, as well as increasing soft attack of any infantry equipment researched after the spirit was added by 10%:

equipment_bonus = {
    artillery = {
        instant = yes
        build_cost_ic = -0.2
    }
    infantry_equipment = {
        soft_attack = 0.1
    }
}

rule modifies the set of rules that decide what the country is allowed to do. This usually includes diplomatic options (such as peace conference options or being called to war). They show up in the tooltip only if the rule differs from the value without the idea, e.g. can_create_factions = no will usually not appear in the tooltip as countries are already unable to create a faction by default.

rule = {
    can_join_factions = no
    can_send_volunteers = yes
}
Game rule list 
The following game rules exist as possible options:
Internal name Localised name Notes
can_access_market Can access International Market (Puppets and Overlords can always access each other's market)
can_be_spymaster Can be Spy Master
can_boost_other_ideologies Can boost popularity of other ideologies
can_boost_own_ideology Can boost own party popularity in other countries
can_create_collaboration_government Can create collaboration governments
can_create_factions Can Create Factions
can_declare_war_on_same_ideology Can declare war on country with the same ideology group without a war goal
can_declare_war_without_wargoal_when_in_war Can declare war on a neighbor without a wargoal when at war with a major
can_decline_call_to_war Can decline call to war
can_force_government Can force government of another country to adopt the same ideology
can_generate_female_aces Women in your country are allowed to become military pilots
can_generate_female_country_leaders Can generate female country leaders
can_generate_female_unit_leaders Can generate female unit leaders
can_guarantee_other_ideologies Can guarantee other ideologies
can_join_factions Can join factions
can_join_factions_not_allowed_diplomacy Country's name is not allowed to join factions
can_join_opposite_factions Can Join Factions led by another Ideology
can_lower_tension Lowers World Tension with Guarantees
can_not_build_buildings CAN_NOT_BUILD_BUILDINGS Doesn't seem to work.
can_not_declare_war Can not declare wars Prevents generating wargoals, but not using existing ones.
can_occupy_non_war Can hold territory owned by a country they are not at war with
can_only_justify_war_on_threat_country Can justify war goals against a country that have not generated world tension
can_puppet Can puppet a country
can_send_volunteers Can send volunteer forces
can_use_kamikaze_pilots Can use kamikaze pilots
contributes_operatives Contributes Operatives to Spy Master: Yes Only has an effect for subjects.
units_deployed_to_overlord Control over deployed units go to overlord Only has an effect for subjects.

Effects

A spirit can be set to apply effects when added or removed. This is done, respectively, with on_add and on_remove effect blocks, looking like the following example:

on_add = {
    add_stability = 0.1
}
on_remove = {
    add_political_power = -50
}

The effects will only get executed if the idea is added after the game has already started: if done via a history file or a bookmark's effect = { ... } block, the effects will not be executed. In that case, it's needed to replicate the effects given when adding the idea within the same effect block that adds the idea.

Cancellation

A spirit can be set to automatically cancel itself once a set of triggers is met. This is done with the cancel block. A cancellation will also trigger the on_remove effect block in the idea if one is present. This will look like the following:

cancel = {
    has_political_power > 50 
}

Additional arguments

Another trigger block that can go into an idea is allowed_civil_war = { ... }. When starting a civil war, this is evaluated for each side, and the spirit will only appear for sides where this is true. For instance, a has_government = democratic will ensure that only the 民主主义民主主义 side in a civil war will obtain the spirit. By default, always false, leading to the spirits disappearing when a civil war starts. Setting it to be always true can be preferred over the default, making it appear for both sides.

do_effect = { ... } is a trigger block that assigns the necessary conditions for the idea to apply its modifiers. If false, the modifiers (including research and equipment bonuses) not apply, but the idea will not be removed.


Full idea file example

ideas = {
    country = { # Necessary for the game to consider them spirits rather than a different idea type.
        my_spirit = {
            picture = my_picture        # Using GFX_idea_my_picture
            modifier = {
                training_time_factor = -0.1
            }
            targeted_modifier = {
                tag = QAT
                defense_bonus_against = 0.2
            }
            research_bonus = {
                infantry = 0.1
            }
            equipment_bonus = {
                infantry_equipment = {
                    instant = yes
                    defense = 0.2
                }
            }
            rule = {
                can_join_factions = no
            }
        }
        my_spirit_2 = {        # Using GFX_idea_my_spirit_2
            allowed_civil_war = {
                has_government = democratic         # Only appear in a civil war for the democratic side.
            }
            cancel = {
                democratic > 0.6
            }
            on_add = {
                add_popularity = {
                    ideology = democratic
                    popularity = 0.2
                }
            }
            on_remove = {
                if = {
                    limit = {
                        democratic > 0.6
                    }
                    start_civil_war = {
                        ideology = democratic
                        size = 0.6
                    }
                }
            }
            do_effect = {
                NOT = {
                    has_government = democratic
                }
            }
            modifier = {
                democratic_drift = 0.005
            }
        }
    }
}

Other idea categories

Non-spirit ideas can use everything that can be within spirits, however there are more arguments that make sense to be added in them that do not do anything in spirits or don't have any reason to be added.

Hidden ideas

Hidden idea are exactly the same as regular spirits in every aspect in regards to creation, except for the fact that they have to be defined within the hidden_ideas idea category instead of using country. This will ensure that the idea will be hidden and not show up in the spirit container. However, it can still make sense to create localisation for them: If a hidden idea cancels automatically, the pop-up will show up, and hovering over certain elements (Such as the stability counter or research speed) will show each idea that modifies it.

Idea category arguments

These arguments are used within the idea category within the /Hearts of Iron IV/common/ideas/*.txt file.

designer = yes marks the entire category as designer ideas. This is primarily used for AI.
law = yes marks the entire category as laws. This is primarily used for AI.
use_list_view = yes marks the entire category to use a list view for selecting the idea, akin to how the base game treats laws.

These will look in the idea file like the following:

ideas = {
    my_law_category = {
        law = yes
        use_list_view = yes
        my_law_1 = {
        }
        my_law_2 = {
        }
    }
}

Additional arguments

This assumes that the idea is of the type that can be selected in-game, such as a law or a designer.

allowed is a trigger block that checks only at the game's start or when loading a save, primarily used to restrict an idea to a country (As tag = BHR or original_tag = POL) and/or a DLC (As has_dlc = "One Step Back"). If an idea's allowed is unfulfilled, it will never appear within the selection unless it becomes true on the save being reloaded; however, manual assignment via add_ideas bypasses the check. If left out, assumes to be always allowed. This only checks once!

allowed_to_remove is a trigger block that details when exactly you can remove the idea, changing it to a different one in the category. This is checked continuously, unlike allowed.

visible is a trigger block that continuously checks every frame if allowed was met, required to make the idea be visible in the decision selection screen. It is preferable to put country or DLC checks into allowed instead.

available is a trigger block that continuously checks every frame if visible was met, required to be possible to actually take the idea. If false, the idea will remain visible, but will be greyed out and be impossible to take. This is applied on top of the political power cost.

cost = 123 is the price in political power it takes to add the idea. This becomes 150 political power if not set[a].

removal_cost = 123 is the price in political power it takes to remove the idea. If set to -1, the idea cannot be removed manually. Defaults to 0 if not set.

level = 2 is used in ideas to create the escalating price, akin to the recruitment laws. If you have the law with the level of 1, changing to level 3 will require the cost of the idea with the level 2 in addition to the level 3, and vise-versa.

traits is a block of traits that are assigned to this idea, defined in /Hearts of Iron IV/common/country_leader/*.txt, also granting a static modifier and showing up near the idea.

ledger decides which intelligence ledger the idea will be assigned to. This is primarily a leftover now applying to the character system, but this can still be used in officer corps spirits. Possible values are army, air, navy, military (Appearing on each of the prior ledgers), civilian, all, and hidden.

Example

ideas = {
    law_category = {
        law = yes
        use_list_view = yes 
        my_law = {
            allowed_to_remove = {
                num_of_civilian_factories > 10
            }
            removal_cost = 100
            cost = 100
            level = 3
            modifier = {
                production_speed_industrial_complex_factor = 0.2
            }
        }
    }
    designer_category = {
        designer = yes
        my_designer = {        # No cost is defined, defaults to 150
            allowed = {
                tag = QAT
            }
            visible = {
                has_tech = infantry_weapons1
            }
            available = {
                has_equipment = {
                    infantry_equipment > 1000
                }
            }
            traits = { infantry_equipment_manufacturer }
        }
    }
}

Categories

Idea categories are defined in any /Hearts of Iron IV/common/idea_tags/*.txt file. All categories will be contained in the idea_categories top element and can contain the following arguments:

  • slot is a proper idea category slot. This is what shows up in the GUI in the politics view menu, and this is what ideas have to have as their category in their definition.
  • character_slot is a character slot. Ideas can also be defined to use this slot and it will show up in the GUI like a regular idea slot, however.
  • cost is the default price in political power to add an idea within one of the slots of this category. This is applied if the idea doesn't have one.
  • removal_cost is the default price in political power to remove an idea within one of the slots of this category.
  • ledger is the intelligence ledger defined to ideas in this category, unless overridden within the slot, idea, or character. Possible values are army, air, navy, military (Appearing on each of the prior ledgers), civilian, all, and hidden. Additionally, invalid can be used, forcing the ledger to be defined one level lower.
  • hidden is a boolean value making this category not show up in the GUI. Optional, defaults to no.
  • politics_tab is a boolean value making this category show up in the politics tab. Optional, defaults to yes.

This will look like the following:

idea_categories = {
    my_category = {
        slot = my_slot
        character_slot = my_character_slot
        cost = 30
        removal_cost = 10
        ledger = hidden
    }
}

The category will then be used by the idea via the slot (which allows mapping an idea to a category)
The file also includes slot_ledgers, which distributes idea slots to intelligence ledgers individually, which will take priority over the idea category's ledger. An example of it being used is

slot_ledgers = {
	XXX_idea_slot = civilian
	ZZZ_idea_slot = invalid
}

Invalid will require specification in each idea individually.

GFX and GUI

Each idea category represents a row in the country politics view, while each slot represents a slot under that row.
The country_politics_idea_category_entry container window within the /Hearts of Iron IV/interface/countrypoliticsview.gui file decides the user inteface information about each row. The most important thing here is the gridbox, as it decides the following:

  • The size of each idea slot within the category, by default 80 by width and 64 by height. This is used for distances between slots.
  • The max amount of slots, by default 7 horizontally and 1 vertically. If not adjusted, it'd be impossible to have more than 7 idea slots in a category.
  • The format of the gridbox, deciding in which direction the idea slots are added.

The idea category's icon, shown on the left of the category's row, is decided by the GFX_idea_categories sprite. The sprite is split into multiple frames horizontally, and each category is assigned a part of it depending on its order defined in /Hearts of Iron IV/common/idea_tags/*.txt. The sprite is defined in /Hearts of Iron IV/interface/countrypoliticsview.gfx and its definition in the base game consists of the following:

	spriteType = {
		name = "GFX_idea_categories"
		texturefile = "gfx/interface/idea_categories.dds"
		noOfFrames = 6
	}

When adding a new category, make sure to update the sprite and the amount of frames accordingly.

An icon can be defined for idea slots, which will be used for them if there is no idea assigned to that slot. This definition in any /Hearts of Iron IV/interface/*.gfx file, taking XXX_idea_slot as an example, is done the following way:

	spriteType = {
		name = GFX_idea_slot_XXX_idea_slot
		textureFile = gfx/interface/filename.dds
	}

In other words, the sprite must have the same name as the idea slot but with GFX_idea_slot_ prepended in the beginning.

Modifying cost of a slot

The <idea slot>_cost_factor modifier can be used to modify the price in political power for adding ideas or characters in this slot. However, there is a restriction on that modifier. In order for it to work, the idea slot needs to have any ideas or characters defined beforehand.

The files in the /Hearts of Iron IV/common/ideas/*.txt folder are loaded in the order of the Unicode character IDs, which put capital letters before underscores, which are put before lowercase letters. For example, this means that a file with the filename of TAG.txt is loaded before _economy.txt or _manpower.txt (the base game's locations of laws), which would get loaded before country.txt. Due to the above quirk, this means that an idea with the modifier affecting a price of a law, for instance, economy_cost_factor = -0.10, will throw an error if the filename starts with an uppercase character unless the laws are stored from files different from base game.

There are two primary ways to fix this. The first one is to simply change the filename of the country's idea file, changing it from, for instance, GER.txt togermany.txt. In case you have to keep the filename the same to overwrite a file, a new file can be created instead. Alternatively, assuming that you have a replace_path to the ideas folder, you could rename the files storing the laws to begin with a character with a smaller ID, for instance, to 00_economy.txt, which would get loaded prior to TAG.txt.

Additionally, this also means that there have to be ideas defined within character slots for the modifier to work, such as political_advisor_cost_factor = 0.1. This is because characters are loaded later than ideas or country leader traits, so they're not loaded yet when evaluating the modifier, causing the error. This can be bypassed by creating ideas for the character slots in /Hearts of Iron IV/common/ideas/*.txt files. These will never appear for the countries as these are character slots rather than idea slots, but an idea that was loaded beforehand will correct the error.

Notes

^ a: Depends on the value in the /Hearts of Iron IV/common/idea_tags/*.txt file, which is always 150 in base game