Idea修改

本页面所适用的版本可能已经过时,最后更新于1.11
秋起.讨论 | 贡献2024年8月4日 (日) 19:37的版本 (民族精神汉化(第一部分))


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

创建国家精神

国家精神在 /Hearts of Iron IV/common/ideas/*.txt.中创建。 这是一个仅包含空国家精神(没有修正但仍可通过 add_ideas = idea_name来添加)的文件的例子:

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

在这种情况下,ideas = { ... } 中包含了文件中的每个idea,这是由于引擎的限制所必须的。同时,country = {}是一个idea类别,这就是为什么游戏会把 my_idea_1my_idea_2识别为民族精神,而不是同样属于idea的法律或设计商。

本地化

对于简体中文用户来说,idea的本地化可以在任意 UTF-8-BOM 编码的 /Hearts of Iron IV//Hearts of Iron IV/localisation/simp_chinese/*_l_simp_chinese.yml 文件中定义。如果一个idea没有名称,游戏会使用 /Hearts of Iron IV/common/names 中国家的随机名称列表创建一个名称。但这不适用于国家精神,因为国家精神使用的是idea的 ID。一个idea可以同时拥有一个名称和一个描述,将鼠标悬停在其上时会显示描述。以 ZZZ_example_idea 为例,它们的本地化条目是这样定义的:

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

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

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

图片

默认情况下,一个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 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中的纹理文件不正确,该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在本地化文件中具有相同的名称,游戏中的效果就会显示为修改了idea。交换idea的方法如下:

swap_ideas = {
    remove_idea = old_idea
    add_idea = new_idea
}

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

为了让民族精神持续有限的一段时间,可以使用 add_timed_idea 效果:

add_timed_idea = {
    idea = my_timed_idea
    days = 365
}

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

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

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