Idea修改:修订间差异

本页面所适用的版本可能已经过时,最后更新于1.11
无编辑摘要
无编辑摘要
第100行: 第100行:
|}
|}
{| class="wikitable mw-collapsible"
{| class="wikitable mw-collapsible"
!Game rule list
! 游戏规则
|-
|-
|The following game rules exist as possible options: 
|The following game rules exist as possible options: 
{| class="wikitable sortable mw-collapsible"
{| class="wikitable sortable mw-collapsible"
!Internal name
! 规则代码
!Localised name
! 规则说明
!Notes
! 备注
|-
|-
|can_access_market
|can_access_market
第233行: 第233行:
}</pre>只有在游戏开始后添加idea时,效果才会被执行:如果是通过history文件或bookmark文件的 <code>effect = { ...}</code> 块,则不会执行效果。在这种情况下,需要在添加idea的同一个效果块中复制添加idea时给出的效果。
}</pre>只有在游戏开始后添加idea时,效果才会被执行:如果是通过history文件或bookmark文件的 <code>effect = { ...}</code> 块,则不会执行效果。在这种情况下,需要在添加idea的同一个效果块中复制添加idea时给出的效果。
===取消效果===
===取消效果===
  可以设置 民族精神,使其在满足一组触发 [[:en:Triggers|条件]] 后取消。这可以通过<code>cancel</code>效果实现。如果存在<code>on_remove</code>效果 ,取消也会触发idea中的<code>on_remove</code>效果。如下所示:<pre>cancel = {
  在已存在 民族精神 的前提下 ,使其在满足一组触发[[:en:Triggers|条件]]后取消 该民族精神 。这可以通过<code>cancel</code>效果实现。如果 代码块中 存在<code>on_remove</code>效果,取消也会触发idea中的<code>on_remove</code>效果。如下所示:<pre>cancel = {
    has_political_power > 50 
    has_political_power > 50 
}</pre>
}</pre>
=== 其他 效果 ===
=== 补充 效果 ===
 另一个触发条件是 <code>allowed_civil_war = { ... }</code> 当开始内战时,会对每一方进行条件判断,只有当条件判断结果为 时,才会 出现 民族精神。例如<code>has_government = democratic</code> 将确保内战中只有 {{Icon|Democratic|1}} 的一方才能获得民族精神。默认情况下, 总是 ,导致内战开始时民族精神 消失 。若将其设置为 <code>always = yes</code>则在双方中都出现。
 另一个触发条件是 <code>allowed_civil_war = { ... }</code> 当开始内战时,会对每一方进行条件判断,只有当条件判断结果为'''ture(即满足条件)''' 时,才会 继承民族精神,即当'''内战'''爆发时,分裂的国家满足某种条件会继承原有国家 民族精神。例如<code>has_government = democratic</code> 将确保内战中只有 {{Icon|Democratic|1}} 的一方才能获得民族精神。默认情况下, 若某国判断 '''false(即不满足条件)''' 则会 导致内战开始时 无法继承原有 民族精神。若将其设置为 <code>always = yes</code>则在双方中都出现。


<code>do_effect = { ... }</code> 是一个条件效果,它为idea应用modifier指定了必要条件。如果不满足内条件,则该民族精神的modifier(包括研究和装备 奖励 )无效,但该idea不会被删除。
<code>do_effect = { ... }</code> 是一个条件效果,它为idea应用modifier指定了必要条件。如果不满足内条件,则该民族精神的modifier(包括研究和装备 修正 )无效,但该idea不会被删除。


=== 完整的民族精神例子===
=== 完整的民族精神例子===
第303行: 第303行:
}</pre>
}</pre>
==其他Idea类别==
==其他Idea类别==
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可以使用民族精神idea中可以使用的一切,但是,在非民族精神的idea中有更多的有意义的代码类型,而这些代码类型在民族精神中没有任何作用,或者是没有必要加入。
===隐藏Idea===
===隐藏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.
除了必须定义为 <code>hidden_ideas</code> idea 类别而不是 <code>country</code> ,隐藏idea在创建的各个方面都与普通国家精神完全相同。这将确保idea被隐藏起来,不会显示在存放民族精神的页面中。不过,为它们制作本地化仍然是有意义的: 如果隐藏Idea自动取消,则会弹出宣布Idea被取消的窗口;将鼠标悬停在某些界面元素上(如稳定度或研究速度),就会显示这个隐藏Idea所作出的修正。
===Idea category arguments ===
===Idea 的类别定义 ===
These arguments are used within the idea category within the {{path|common/ideas/*.txt}} file.
这些定义方式用于{{path|common/ideas/*.txt}} 文件中。


<code>designer = yes</code> marks the entire category as designer ideas. This is primarily used for AI.
<code>designer = yes</code> 将整个类别标记为设计商idea。这主要用于AI。


<code>law = yes</code> marks the entire category as laws. This is primarily used for AI.
<code>law = yes</code> 将整个类别标记为法案。这主要用于AI。


<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> 将整个类别标记为使用列表视角来选择idea,类似于原版游戏中的法案的选择。


These will look in the idea file like the following:<pre>ideas = {
这些内容在idea文件中将如下所示:<pre>ideas = {
    my_law_category = {
    my_law_category = {
      law = yes
      law = yes
第325行: 第325行:
    }
    }
}</pre>
}</pre>
===Additional arguments ===
=== 补充代码 ===
This assumes that the idea is of the type that can be selected in-game, such as a law or a designer.
以下补充代码可用的前提条件是该idea属于可以在游戏中选择的类型,例如法案或设计商。


<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> 是一个[[:en:Trigger| 条件]] 块,只在游戏开始或加载保存时进行检查,主要用于将一个idea限制在一个国家(<code>tag = BHR</code> <code>original_tag = POL</code> )和/ 或一个 DLC <code>has_dlc = "One Step Back"</code> )中。如果一个idea的allowed未被满足,那么它将永远不会出现在相关Idea列表中中,除非在重新加载保存时变成了真;不过,通过 <code>add_ideas</code> 进行手动分配可以绕过检查。如果未填写,则默认<code>always = yes</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>.
<code>allowed_to_remove</code> 是一个条件块,详细说明了何时可以删除idea,将其更改为类别中的另一个idea。与<code>allowed</code> 不同,它是随时检测的。


<code>visible</code> 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.
<code>visible</code> 是一个条件块,它会'''随时检测'''当前状态是否符合规定的条件,这是使idea在决策选择屏幕上可见的必要条件。'''提示:最好将国家(tag = xxx)或 DLC (has_dlc = "xxx")检查放在<code>allowed</code>中。'''


<code>available</code> 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.
<code>available</code> 是一个条件块,它会'''随时检测'''是否满足可见条件,这是实际采纳idea的必要条件。如果为假,idea将保持可见,但会显示为灰色,无法采纳。这是在政治点数花费的基础上应用的。


<code>cost = 123</code> is the price in political power it takes to add the idea. This becomes 150 political power if not set{{cref|a}}.
<code>cost = 123</code> 是添加idea所需的政治点数。如果未设置,则所需政治点数将变为 150


<code>removal_cost = 123</code> 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.
<code>removal_cost = 123</code> 是移除该idea所需的政治点数。如果设置为-1 ,则无法手动移除该idea。如果未设置,则默认为 0


<code>level = 2</code> 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.
<code>level = 2</code> 用于在idea中创建不断攀升的花费,类似于动员法案。如果你拥有等级为 1 的法律,那么如果改成等级 3 ,除了等级 3 外,还需要支付等级 2 的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>traits</code> 是分配给这个idea的特质块,在 {{path|common/country_leader/*.txt}} 中定义,也会赋予一个静态修正,并显示在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> 决定将该想法分配给哪个<code>intelligence ledger</code>。这主要是适用于[[:en:Character_modding|character]] 系统的遗留问题,但仍可用于军官团精神。可能的值有<code>army</code>, <code>air</code>, <code>navy</code>, <code>military</code> (出现在之前的每个<code>ledger</code>)、<code>civilian</code>, <code>all</code> <code>hidden</code>
=== Example===
=== 例子===
<pre>ideas = {
<pre>ideas = {
    law_category = {
    law_category = {
第380行: 第380行:
    }
    }
}</pre>
}</pre>
==Categories==
==Idea类别==
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类别在{{path|common/idea_tags/*.txt}} 文件中定义。所有类别都将包含在 <code>idea_categories</code> 的头部代码块中,并可包含以下参数:
*<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> 是一个严格的idea类别槽。这是在玩家政治菜单中显示的内容,也是idea定义中'''必须'''包含的类别。
*<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> 是一个[[:en:Character_modding|character]] 槽。也可以定义idea使用这个槽,但它会像普通idea槽一样显示在GUI中。
*<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> 在该类别的一个插槽中添加一个idea的默认政治点数花费。如果该idea没有设置政治点数花费,则会应用此花费。
*<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> 是删除本类别中某个idea的默认默认点数花费。
*<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> 是为本类别中的idea定义的<code>intelligence ledger</code>,除非在<code>slot</code>、<code>idea</code>或角色中被重载。可能的值有<code>army</code>, <code>air</code>, <code>navy</code>, <code>military</code> (出现在之前的每个<code>ledger</code>),<code>civilian</code>, <code>all</code> <code>hidden</code> 。此外,还可以使用<code>invalid</code> ,这将迫使 <code>ledger</code> 的定义级别降低一级。
*<code>hidden</code> is a boolean value making this category not show up in the GUI. Optional, defaults to no.
*<code>hidden</code> 是一个布尔值,表示该类别不会在GUI中显示。选填,默认为 "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> 是一个布尔值,用于使该分类显示在政治视图中。选填,默认为“yes”。
This will look like the following:<pre>idea_categories = {
如下所示:<pre>idea_categories = {
    my_category = {
    my_category = {
      slot = my_slot
      slot = my_slot
第397行: 第397行:
      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> 然后,idea将通过slot使用该类别(这样就可以把一个idea映射到一个类别)。


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 = {
该文件还包括 <code>slot_ledgers</code>,用于将<code>idea_slots</code>单独分配给情<code>intelligence ledger</code>,<code>intelligence ledger</code>的优先级高于idea类别的<code>ledger</code>。使用它的一个例子是:<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> 如果无效,则需要在每个idea中逐一标明。
===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}} 每个idea类别代表国家政治视图中的一行,而每个slot代表该行下的一个slot。


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:

2024年8月8日 (四) 03:12的版本

Ideas是一种向国家添加修正的固定方式,尤其是包括民族精神、法案、设计商(p社在1.13版本中已经用MIO系统代替了该类别)、内阁和隐藏民族精神。Ideas被定义在 /Hearts of Iron IV/common/ideas/*.txt文件中,并且Ideas的类别被定义在 /Hearts of Iron IV/common/idea_tags/*.txt文件中

创建民族精神

译者注:大家在各种翻译内看到的民族精神和国家精神,实际上指的是同一个idea。本文翻译则使用“民族精神”作为译词。

民族精神文件在/Hearts of Iron IV/common/ideas/*.txt中创建。这是不存在任何效果的民族精神(虽然该民族精神内不存在修正,但仍可通过 add_ideas = idea_name的效果代码进行添加)。

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

上述内容中,ideas = {...} 中包含了所有的idea,这是由于《钢铁雄心4》引擎的限制所必须的。同时,country = {...} 是一个idea类别(这个类别定义了该idea为民族精神),这就是为什么游戏会把 my_idea_1 和 my_idea_2 识别为民族精神,而不是同样属于idea的法案或是内阁。

本地化

对于简体中文(Simp_chinese)的制作者来说,idea的本地化可以在任意 UTF-8-BOM 编码/Hearts of Iron IV/localisation/simp_chinese/*_simp_chinese.yml 文件中定义。 如果一个idea没有名称,游戏会使用 /Hearts of Iron IV/common/names 中国家的随机名称列表创建一个名称。但这不适用于民族精神,因为民族精神使用的是idea的ID。

并且,一个idea可以同时拥有一个名称和一个描述,将鼠标悬停在其上时会显示其描述。下图则以 ZZZ_example_idea 为例,它们的本地化条目是这样定义的:

l_simp_chinese:
 ZZZ_example_idea: "Idea的名字"
 ZZZ_example_idea_desc: "idea的描述"

name = new_idea_name 会将idea名称指定为另一条本地化条目。如果您计划通过多次交换来修改一个idea,这将非常有用,因为这样就不必为该idea的每个实例创建重复的本地化条目。这同样需要在本地化文件中定义:

l_simp_chinese:
 new_idea_name: "新的idea名字"
 new_idea_name_desc: "新的idea描述"

图片(图标)

General sprite overview
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.

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 spriteTypes = { ... } 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 spriteType = { ... }. The simplest sprite definition looks like the following:

spriteTypes = {
    spriteType = {
        name = GFX_first_sprite                         # In some cases, beginning with GFX_ is mandatory for it to work.
        texturefile = gfx/interface/folder/filename.dds # The folder and filename don't matter, as long as they are correct
    }                                                   # 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 GFX_first_sprite 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. GFX_second_sprite:1 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.

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 GFX_idea_traits_strip 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.

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

默认情况下,一个idea会使用一个与该idea名称相同的sprite图形,但需要开头加上GFX_idea_。例如,名称为my_idea_1 的idea将使用名称为 GFX_idea_my_idea_1 的sprite。

这可以使用idea中的 picture = my_sprite 属性来更改。游戏仍会在参数中插入 GFX_idea_ 前缀,以决定应使用的sprite,例如 picture = XYZ 会导致 GFX_idea_XYZ 被用作sprite。如果游戏找不到与它期望的名称相同的sprite,就会使用 Unknown.png 默认图标代替。

插入前缀意味着,在大多数情况下,picture = GFX_XYZ(这会使 GFX_idea_GFX_XYZ 用作sprite)或picture = idea_XYZ(这会使 GFX_idea_idea_XYZ 用作sprite)会导致游戏试图调用一个不存在的sprite,而不遵循 GFX_idea_XYZ 命名模式的sprite不能用作idea的图标。

如果sprite中的texturefile文件不正确,该idea在国家政治视图中将不可见,但仍会应用修正效果。所以确保idea以相同的文件夹路径位置、相同的文件名(包括扩展名)存储,并使用正确的文件夹分隔符。

还可以让图片根据 /Hearts of Iron IV/common/countries/*.txt 文件中定义的国家 graphical_culture_2d 变化。具体做法是在图片名称后添加该名称,并用下划线分隔。例如,在定义中包含 GFX_idea_my_picture_middle_eastern_2d 名称的精灵将代替 GFX_idea_my_picture,出现在拥有 middle_eastern_2d 文化的国家中。

实际运用

民族精神只能通过效果手动添加. 在相关效果块(如国策完成奖励)内 add_ideas = idea_name 可添加国家精神,而 remove_ideas = idea_name 则会将其移除。

为了交换两个idea并让游戏显示追加效果的变化,需要使用 swap_ideas虽然无法直接修改一个idea,但如果被交换的两个idea在本地化文件中具有相同的名称(id相同),游戏中的效果就会显示追加该idea的效果(modifier - 持续性效果)。但是p社仅仅在这里展示了swap_ideas的idea效果的特殊用法,即实现追加效果。一般情况下,swap_ideas效果的原意则是替换两个民族idea,若id相同,则被识别为追加效果;如若id不同,则是替换效果(先移除一个idea,后添加一个新的idea)。

替换(追加)idea的方法如下:

swap_ideas = {
    remove_idea = old_idea
    add_idea = new_idea
}

在大多数情况下,创建多个idea并在它们之间交换就足够了,比如有几个阶段的线性流程(Scripted effects 可用于创建一系列条件语句,并在每次需要时重复使用)。如果创建多个idea太不可行,比如有多个可以并行的修改流程,动态修正将允许用变量作为修正数值,但它们只接受修正(也就是不接受研究或装备加成等无关属性),而且由于没有自动的热更新,因此更难操作。 为了让民族精神持续有限的一段时间(暂时性民族精神),可以使用 add_timed_idea 效果:

add_timed_idea = {
    idea = my_timed_idea
    days = 365
}

可通过 modify_timed_idea 效果来延长或加快计时。

为了让一个国家在游戏开始就有idea,可以在 /Hearts of Iron IV/history/countries/ 中的国家文件这个决定游戏开始时的历史信息的效果块中,使用add_ideas(通常以扩展形式使用,可同时分配多个idea)可以让国家在游戏开局时就拥有民族精神。为了使该idea显示在国家选择界面中,需要对 bookmark文件进行编辑,将该idea包含在国家条目中的 ideas = { ... } 块中。

修正(持续性效果)

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
}
游戏规则
The following game rules exist as possible options:
规则代码 规则说明 备注
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.



效果(瞬时性效果)

可以设置民族精神在添加或删除时应用的效果。具体做法是分别使用 on_addon_remove 效果块,如下所示:

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

只有在游戏开始后添加idea时,效果才会被执行:如果是通过history文件或bookmark文件的 effect = { ...} 块,则不会执行效果。在这种情况下,需要在添加idea的同一个效果块中复制添加idea时给出的效果。

取消效果

在已存在民族精神的前提下,使其在满足一组触发条件后取消该民族精神。这可以通过cancel效果实现。如果代码块中存在on_remove效果,取消也会触发idea中的on_remove效果。如下所示:

cancel = {
    has_political_power > 50 
}

补充效果

另一个触发条件是 allowed_civil_war = { ... } 当开始内战时,会对每一方进行条件判断,只有当条件判断结果为ture(即满足条件)时,才会继承民族精神,即当内战爆发时,分裂的国家满足某种条件会继承原有国家民族精神。例如has_government = democratic 将确保内战中只有 民主主义民主主义 的一方才能获得民族精神。默认情况下,若某国判断为false(即不满足条件),则会导致内战开始时无法继承原有民族精神。若将其设置为 always = yes则在双方中都出现。

do_effect = { ... } 是一个条件效果,它为idea应用modifier指定了必要条件。如果不满足内条件,则该民族精神的modifier(包括研究和装备修正)无效,但该idea不会被删除。

完整的民族精神例子

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
            }
        }
    }
}

其他Idea类别

非民族精神的idea可以使用民族精神idea中可以使用的一切,但是,在非民族精神的idea中有更多的有意义的代码类型,而这些代码类型在民族精神中没有任何作用,或者是没有必要加入。

隐藏Idea

除了必须定义为 hidden_ideas idea类别而不是 country ,隐藏idea在创建的各个方面都与普通国家精神完全相同。这将确保idea被隐藏起来,不会显示在存放民族精神的页面中。不过,为它们制作本地化仍然是有意义的: 如果隐藏Idea自动取消,则会弹出宣布Idea被取消的窗口;将鼠标悬停在某些界面元素上(如稳定度或研究速度),就会显示这个隐藏Idea所作出的修正。

Idea的类别定义

这些定义方式用于/Hearts of Iron IV/common/ideas/*.txt 文件中。

designer = yes 将整个类别标记为设计商idea。这主要用于AI。

law = yes 将整个类别标记为法案。这主要用于AI。

use_list_view = yes 将整个类别标记为使用列表视角来选择idea,类似于原版游戏中的法案的选择。

这些内容在idea文件中将如下所示:

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

补充代码

以下补充代码可用的前提条件是该idea属于可以在游戏中选择的类型,例如法案或设计商。

allowed 是一个条件块,只在游戏开始或加载保存时进行检查,主要用于将一个idea限制在一个国家(tag = BHRoriginal_tag = POL)和/或一个 DLC(has_dlc = "One Step Back")中。如果一个idea的allowed未被满足,那么它将永远不会出现在相关Idea列表中中,除非在重新加载保存时变成了真;不过,通过 add_ideas 进行手动分配可以绕过检查。如果未填写,则默认always = yes并且该条件仅开局或重新加载的时候检测一次!

allowed_to_remove 是一个条件块,详细说明了何时可以删除idea,将其更改为类别中的另一个idea。与allowed不同,它是随时检测的。

visible是一个条件块,它会随时检测当前状态是否符合规定的条件,这是使idea在决策选择屏幕上可见的必要条件。提示:最好将国家(tag = xxx)或 DLC (has_dlc = "xxx")检查放在allowed中。

available是一个条件块,它会随时检测是否满足可见条件,这是实际采纳idea的必要条件。如果为假,idea将保持可见,但会显示为灰色,无法采纳。这是在政治点数花费的基础上应用的。

cost = 123 是添加idea所需的政治点数。如果未设置,则所需政治点数将变为 150。

removal_cost = 123是移除该idea所需的政治点数。如果设置为-1,则无法手动移除该idea。如果未设置,则默认为 0。

level = 2 用于在idea中创建不断攀升的花费,类似于动员法案。如果你拥有等级为 1 的法律,那么如果改成等级 3,除了等级 3 外,还需要支付等级 2 的idea的费用,反之亦然。

traits是分配给这个idea的特质块,在 /Hearts of Iron IV/common/country_leader/*.txt中定义,也会赋予一个静态修正,并显示在idea附近。

ledger 决定将该想法分配给哪个intelligence ledger。这主要是适用于character系统的遗留问题,但仍可用于军官团精神。可能的值有army, air, navy, military(出现在之前的每个ledger)、civilian, allhidden

例子

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 }
        }
    }
}

Idea类别

idea类别在/Hearts of Iron IV/common/idea_tags/*.txt文件中定义。所有类别都将包含在 idea_categories 的头部代码块中,并可包含以下参数:

  • slot是一个严格的idea类别槽。这是在玩家政治菜单中显示的内容,也是idea定义中必须包含的类别。
  • character_slot 是一个character槽。也可以定义idea使用这个槽,但它会像普通idea槽一样显示在GUI中。
  • cost 在该类别的一个插槽中添加一个idea的默认政治点数花费。如果该idea没有设置政治点数花费,则会应用此花费。
  • removal_cost是删除本类别中某个idea的默认默认点数花费。
  • ledger是为本类别中的idea定义的intelligence ledger,除非在slotidea或角色中被重载。可能的值有army, air, navy, military(出现在之前的每个ledger),civilian, allhidden。此外,还可以使用invalid,这将迫使 ledger 的定义级别降低一级。
  • hidden 是一个布尔值,表示该类别不会在GUI中显示。选填,默认为 "no"。
  • politics_tab是一个布尔值,用于使该分类显示在政治视图中。选填,默认为“yes”。

如下所示:

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

然后,idea将通过slot使用该类别(这样就可以把一个idea映射到一个类别)。 该文件还包括 slot_ledgers,用于将idea_slots单独分配给情intelligence ledgerintelligence ledger的优先级高于idea类别的ledger。使用它的一个例子是:

slot_ledgers = {
	XXX_idea_slot = civilian
	ZZZ_idea_slot = invalid
}

如果无效,则需要在每个idea中逐一标明。

GFX and GUI

每个idea类别代表国家政治视图中的一行,而每个slot代表该行下的一个slot。

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