无编辑摘要 |
无编辑摘要 |
||
第1行: | 第1行: | ||
{{version|1.14.7}} | {{version|1.14.7}} | ||
{{需要翻译 | {{需要翻译| 译者=霜泽图书馆} | ||
The artificial intelligence controlling countries in Hearts of Iron IV can be changed in many different aspects. This includes changing the focuses or technologies it pursues, changing how many units or buildings it should produce and of which type, where it should focus forces, which templates or variants it should aim for, and so on. | The artificial intelligence controlling countries in Hearts of Iron IV can be changed in many different aspects. This includes changing the focuses or technologies it pursues, changing how many units or buildings it should produce and of which type, where it should focus forces, which templates or variants it should aim for, and so on. | ||
2024年8月10日 (六) 01:10的版本
{{需要翻译|译者=霜泽图书馆} The artificial intelligence controlling countries in Hearts of Iron IV can be changed in many different aspects. This includes changing the focuses or technologies it pursues, changing how many units or buildings it should produce and of which type, where it should focus forces, which templates or variants it should aim for, and so on.
- /Hearts of Iron IV/common/ai_areas
- /Hearts of Iron IV/common/ai_focuses
- /Hearts of Iron IV/common/ai_peace
- /Hearts of Iron IV/common/ai_strategy
- /Hearts of Iron IV/common/ai_strategy_plans
- /Hearts of Iron IV/common/ai_templates
- /Hearts of Iron IV/common/ai_attitudes.txt
- /Hearts of Iron IV/common/ai_personalities.txt
许多其他给玩家提供选择的地方应附有 AI 倾向来表达 AI 对各选项的权衡,这些地方使用ai_will_do。
MTTH blocks
MTTH blocks, named in the game within /Hearts of Iron IV/common/mtth/, are a way to assign a dynamic value to some block, whether it's a country = { ... } in a focus tree to assign which countries can get it, a dynamically-changing variable value (as in /Hearts of Iron IV/common/mtth/), a mean-time-to-happen value for an event, et cetera. As MTTH blocks are spread throughout the entire game, it's incredibly important to know how one works. Its most common application, however, is assigning a base AI weight to a database entry such as a national focus or a technology.
In most cases, marked with ai_will_do, the approach taken by the game is generating a decimal number between 0 and the value of the ai_will_do block, and picking the entry with the highest value. There can be other modifiers applied after the ai_will_do value, such as the ones applied within AI strategy plans towards focuses and research or the ones that get defined within Defines, which'll multiply the value you get. This can include different ai_will_do values such as what's done with country leader traits and with ideas or characters that use them.
Event options, instead, use ai_chance, which uses probability-proportional-to-size sampling with a virtual roll of d00 being the final deciding factor. Due to that, in the end, an event option cannot have a probability which isn't a multiple of 1/100 to be picked, although the total sum of each option's weights can be vastly different from 100. In other words, if one option has a value of 1, while the other has a value of 999, the probability for the first option to be picked will be 1% rather than 0.1%.
A MTTH block begins with an assumed value of 1. Further manipulations are done from that value as a starting point. There are 3 value-modifying arguments that can be done, add
, base
, and factor
, done like factor = 0.3
, base = 10
, or add = 5
. add
adds the specified argument to the value, factor
multiplies it, and base
, typically done in the start before any changes, sets it to a different number entirely, akin to multiplying by 0 and adding the number.
In order for an operation to apply conditionally, a modifier = { ... }
block is used. This also functions as a trigger block, with the default scope (thus also ROOT) being the country for which the MTTH block is evaluated. Depending on the MTTH block, there may be additional scopes marked with FROM or FROM.FROM other than the default. The value-modifying arguments function as regular arguments, they can be put in anywhere directly within the modifier = { ... }
block with almost no difference, whether it's in the end, the beginning, or between triggers.
Variables can be used within the value-modifying arguments as well. If using a temporary variable that is defined within the modifier = { ... }
trigger block, then the value-modifying argument of the modifier has to be after the definition of the variable in order for the variable to apply as defined. Variables can also be used outside of the modifier = { ... }
block and directly inside of the MTTH block itself.
Example
ai_will_do = { base = 10.5 # If the country is Germany, set the value to 0, # causing an early end of the evaluation. modifier = { tag = GER factor = 0 } modifier = { is_major = yes add = 1 } modifier = { factor = 3 add = 2.5 tag = FRA } factor = 2 modifier = { set_temp_variable = { t = num_of_civilian_factories } add_to_temp_variable = { t = num_of_military_factories } divide_temp_variable = { t = 10 } round_temp_variable = t add = t } }
Assuming that GER and FRA are major countries, the result is
- 0 for GER: [math]\displaystyle{ 10.5 \cdot 0 = 0 }[/math]
- 74 for FRA: [math]\displaystyle{ ((10.5 + 1) \cdot 3 + 2.5) \cdot 2 = 74 }[/math]
- 23 for other majors: [math]\displaystyle{ (10.5 + 1) \cdot 2 = 23 }[/math]
- 21 for minors: [math]\displaystyle{ 10.5 \cdot 2 = 21 }[/math]
After calculating that value, the total number of civilian and military factories within the country, divided by 10 and rounded, will get added to the score. If FRA has a total of 43 civilian and military factories as it does in base game, then this will result in 4 being added to the prior 74 for a total of 78, for example.
AI strategies
File:Ambox outdated info.png | 这部分内容可能已不适合当前版本,最后更新于1.11。 |
AI strategies are used in order to pursue AI to do or avoid something. This includes diplomatic actions the AI will do, where and how exactly AI should focus and use its land army and the navy, the production lines for buildings and equipment, how AI should handle the intelligence system within the 抵抗运动 DLC.
A value within an AI strategy can be either positive or negative, and it being negative will make AI desire to do it less.
Regular AI strategies are stored in /Hearts of Iron IV/common/ai_strategy/*.txt files, however, AI strategies may be defined outside of that file. The add_ai_strategy effect can add a permament AI strategy within any effect block, and AI strategy plans can also include AI strategies defined within of themselves. Overall, /Hearts of Iron IV/common/ai_strategy/*.txt files describe AI strategies that would enable and disable themselves automatically.
Each entry within a /Hearts of Iron IV/common/ai_strategy/*.txt file is a block with the name of the AI strategy. This name can be anything, even allowing overlap between them: this will only appear in AI dumps and the player will never see it. If an AI strategy modifies the chance for AI to pick a diplomatic option with the player, it will be seen as COUNTRY has strategic reasons to be ...
to the player when hovering over the option. This is an example of an AI strategy with the name of BHR_invade_qatar:
BHR_invade_qatar = { allowed = { original_tag = BHR } enable = { country_exists = QAT } abort = { has_war_with = QAT } abort_when_not_enabled = yes ai_strategy = { type = invade id = QAT value = 200 } }
Arguments
These in particular are arguments for /Hearts of Iron IV/common/ai_strategy/*.txt entries, rather for AI strategy entries within them.
allowed = { ... }
is a trigger block that's checked only before the game's start, permamently allowing or disallowing an AI strategy. Typically, only used for country checks (such as tag = OMA
) or DLC checks that can never be unfulfilled once they are met.
enable = { ... }
is a trigger block that must be met in order to enable the AI strategy. By default, this being unmet will not cancel the AI strategy. However, abort_when_not_enabled = yes
can be used as a separate argument in order to make that be no longer the case. Unlike allowed, this is checked continuously.
abort = { ... }
is a trigger block that must be met in order to remove the AI strategy. It being unmet also prevents it from being added in the first place.
ai_strategy = { ... }
is, itself, the AI strategy that would be applied. The only argument shared for every AI strategy is type = <AI strategy type>
. The rest depends on the AI strategy.
In addition, reversed AI strategies exist. These are used with AI strategies that use id = TAG
to target towards a specific country to swap it around: that strategy will be enabled for TAG towards the country which meets enable = { ... }
. In order to mark the AI strategy as reversed, reversed = yes
is used. enable_reverse = { ... }
is an additional trigger block required to enable this AI strategy. It does not have a default scope, so scoping into a country is required.
An example of a reversed AI strategy is the following:
BHR_support_neutrals = { allowed = { NOT = { original_tag = BHR } } enable = { has_government = neutrality } enable_reverse = { BHR = { has_government = neutrality } } reversed = yes abort_when_not_enabled = yes ai_strategy = { type = support id = BHR value = 100 } }
Without reversed = yes
, this would make every 中立主义 country support BHR. Due to that argument, the strategy is reversed: instead, BHR supports every 中立主义 country.
Types
File:Ambox outdated info.png | 这部分内容可能已不适合当前版本,最后更新于1.11。 |
This list may be outdated. A list of every AI strategy can be found within base game's /Hearts of Iron IV/common/ai_strategy/documentation.info file.
Name | Parameters | Examples | Description | Notes |
---|---|---|---|---|
alliance | value = <int> The weight of the strategy.
|
ai_strategy = { type = alliance id = USA value = -100 } |
Pursues AI to ally with a country, joining the same faction if possible. | |
antagonize | value = <int> The weight of the strategy.
|
ai_strategy = { type = antagonize id = USA value = -100 } |
Pursues AI to antagonize a country, refusing most diplomatic actions with them. | |
asking_foreign_garrison | value = <int> The weight of the strategy.
|
ai_strategy = { type = asking_foreign_garrison id = USA value = 100 } |
Pursues AI to ask for foreign manpower to fulfill garrisons, from a specific country if specified. | If id is not specified, will apply towards every other country.
|
befriend | value = <int> The weight of the strategy.
|
ai_strategy = { type = befriend id = USA value = 100 } |
Pursues AI to befriend a country, accepting most diplomatic actions with them. | |
conquer | value = <int> The weight of the strategy.
|
ai_strategy = { type = conquer id = USA value = 100 } |
Pursues AI to conquer a country, being more likely to declare war and justify wargoals. | This does not change how the AI will control frontlines when at war with that country. |
consider_weak | value = <int> The weight of the strategy.
|
ai_strategy = { type = consider_weak id = USA value = 100 } |
Pursues AI to consider a country more weak, decreasing hesitation for declaration of war or making alliance less likely. | |
contain | value = <int> The weight of the strategy.
|
ai_strategy = { type = contain id = USA value = 100 } |
Pursues AI to contain a country, protecting any countries that it would try to antagonize or invade. | |
declare_war | value = <int> The weight of the strategy.
|
ai_strategy = { type = declare_war id = USA value = 100 } |
Pursues AI to declare war on a country if a wargoal already exists. | |
diplo_action_acceptance | value = <int> The weight of the strategy.
|
ai_strategy = { type = diplo_action_acceptance id = USA value = 100 target = join_allies } |
Pursues AI to accept a diplomatic action if a different country requests it. | AI will not be more likely to propose the diplomatic action in question. Names of diplomatic actions can usually be found from localisation keys used for the title, most of the time yet not always in the /Hearts of Iron IV/localisation/english/diplomacy_l_english.yml file: DIPLOMACY_SEND_VOLUNTEERS_TITLE:0 "Send Volunteers" means that the name of the diplomatic action for sending volunteers is send_volunteers .
|
diplo_action_desire | value = <int> The weight of the strategy.
|
ai_strategy = { type = diplo_action_desire id = USA value = 100 target = call_allies } |
Pursues AI to request a diplomatic action towards the specified country. | AI will not be more likely to accept the diplomatic action in question if it gets proposed to them. Names of diplomatic actions can usually be found from localisation keys used for the title, most of the time yet not always in the /Hearts of Iron IV/localisation/english/diplomacy_l_english.yml file: DIPLOMACY_SEND_VOLUNTEERS_TITLE:0 "Send Volunteers" means that the name of the diplomatic action for sending volunteers is send_volunteers .
|
dont_join_wars_with | value = <int> The weight of the strategy.
|
ai_strategy = { type = dont_join_wars_with id = USA value = 100 target_country = BHR } |
Pursues AI to be less likely to join a war together with a specified country against a specific one. | Does not make AI less likely to join a war together with a different country against target_country, even if it'll result in fighting against target_country together with the specified country. |
ignore | value = <int> The weight of the strategy.
|
ai_strategy = { type = ignore id = USA value = 100 } |
Pursues AI to be less likely to accept or desire any sort of diplomatic action with this country. | |
ignore_claim | value = <int> The weight of the strategy.
|
ai_strategy = { type = ignore_claim id = USA value = 1 } |
Pursues AI to ignore any claims that it has on the specified country. | The value is boolean, just set to be 1. |
protect | value = <int> The weight of the strategy.
|
ai_strategy = { type = protect id = USA value = 100 } |
Pursues AI to protect a certain country, guaranteeing them or adding to the same faction. | A negative total value (taking every AI strategy into consideration) results in AI never guaranteeing that country. |
support | value = <int> The weight of the strategy.
|
ai_strategy = { type = support id = USA value = 100 } |
Pursues AI to support a certain country within wars, sending lend lease, volunteers, or expeditionary forces. | |
send_lend_lease_desire | value = <int> The weight of the strategy.
|
ai_strategy = { type = send_lend_lease_desire id = USA value = 100 } |
Pursues AI to lend-lease equipment to the specified country. | |
send_volunteers_desire | value = <int> The weight of the strategy.
|
ai_strategy = { type = send_volunteers_desire id = USA value = 100 } |
Pursues AI to send volunteers to the specified country. |
Name | Parameters | Examples | Description | Notes |
---|---|---|---|---|
invade | value = <int> The weight of the strategy.
|
ai_strategy = { type = invade id = USA value = -100 } |
Pursues AI to do naval invasions against the specified country. | |
naval_invasion_focus | value = <int> The weight of the strategy. |
ai_strategy = { type = naval_invasion_focus value = 100 } |
Pursues AI to launch naval invasions. | |
prepare_for_war | value = <int> The weight of the strategy.
|
ai_strategy = { type = prepare_for_war id = USA value = 100 } |
Pursues AI to prepare for a war against a specified country, moving troops to their border. | |
area_priority | value = <int> The weight of the strategy.
|
ai_strategy = { type = area_priority id = europe value = 100 } |
Pursues AI to put more units within the specified AI area. | |
dont_defend_ally_borders | value = <int> The weight of the strategy.
|
ai_strategy = { type = dont_defend_ally_borders id = POL value = 10 } |
Makes AI never put troops on the border between the specified country and countries that are at war with it. | Strictly binary. If the total value (taking every AI strategy into consideration) is positive, AI will never put any troops on the border. |
force_defend_ally_borders | value = <int> The weight of the strategy.
|
ai_strategy = { type = force_defend_ally_borders id = FRA value = 100 } |
Pursues AI to put troops on the border between the specified country and countries that are at war with it. | Also accepts AI areas within id .
|
front_armor_score | value = <int> The weight of the strategy.
|
ai_strategy = { type = front_armor_score id = POL value = 100 } |
Pursues AI to put more tank units for invading the specified country. | |
front_control | state = <state> The state to target.
|
ai_strategy = { type = front_control state_trigger = { industrial_complex > 1 is_owned_by = ENG } ratio = 0.1 ordertype = front execution_type = rush manual_attack = no } ai_strategy = { type = front_control area = suez priority = 1 ratio = 0.2 ordertype = invasion execute_order = yes } |
Modifies the orders that AI would give to divisions on a specified frontline. | More than one target type can be used at a time, in which case each one must be met. This only changes the orders assigned to an already-existing frontline, this will not change the amount of units assigned to any particular front or force any to be created. |
front_unit_request | state = <state> The state to target.
|
ai_strategy = { type = front_unit_request tag = POL value = 100 } ai_strategy = { type = front_unit_request country_trigger = { original_tag = SPR has_government = fascism } value = 100 } |
Pursues AI to put more units on a specified land frontline. | More than one target type can be used at a time, in which case each one must be met. |
invasion_unit_request | state = <state> The state to target.
|
ai_strategy = { type = invasion_unit_request state = 123 value = 100 } ai_strategy = { type = invasion_unit_request strategic_region = 42 value = 100 } |
Pursues AI to put more units on a naval invasion with the specified target. | More than one target type can be used at a time, in which case each one must be met. |
garrison | value = <int> The weight of the strategy. |
ai_strategy = { type = garrison value = 10 } |
Controls the amount of units spent on defending the victory points and ports rather than being active on the frontline. | |
garrison_reinforcement_priority | value = <int> The weight of the strategy. |
ai_strategy = { type = garrison_reinforcement_priority value = 100 } |
Pursues AI to reinforce units that are put on garrisons, protecting victory points and naval bases, with higher priority. | |
ignore_army_incompetence | value = <int> The weight of the strategy. |
ai_strategy = { type = ignore_army_incompetence value = 100 } |
Pursues AI to ignore the modifier given by the lack of experience of divisions in calculations. | |
put_unit_buffers | ratio = <decimal> The amount of units to buffer.
|
ai_strategy = { type = put_unit_buffers ratio = 0.2 states = { 123 124 125 126 } subtract_fronts_from_need = yes } |
Pursues AI to keep a certain ratio of divisions on garrison duty in the specified area. | |
spare_unit_factor | value = <int> The weight of the strategy. |
ai_strategy = { type = spare_unit_factor value = 100 } |
Pursues AI to spare more units towards defending allies. | |
theatre_distribution_demand_increase | value = <int> The weight of the strategy.
|
ai_strategy = { type = theatre_distribution_demand_increase value = 10 id = 123 } |
Pursues AI to put more units in the specified state's theater. | A value of 1 translates to 1 unit. |
Name | Parameters | Examples | Description | Notes |
---|---|---|---|---|
naval_avoid_region | value = <int> The weight of the strategy.
|
ai_strategy = { type = naval_avoid_region id = 23 value = 100 } |
Pursues AI to avoid a specific strategic region with its ships. | |
naval_convoy_raid_region | value = <int> The weight of the strategy.
|
ai_strategy = { type = naval_convoy_raid_region id = 23 value = 100 } |
Pursues AI to raid convoys within the specified strategic region. | |
naval_mission_threshold | value = <int> The weight of the strategy.
|
ai_strategy = { type = naval_mission_threshold id = MISSION_CONVOY_RAIDING value = -100 } |
Makes AI have a higher threshold for its desire to do a naval mission. | A higher value means AI is less likely to do the mission. Names of missions can be found in /Hearts of Iron IV/localisation/english/core_l_english.yml, where a localisation key of NAVAL_MISSION_NAME_CONVOY_RAIDING means the mission is called MISSION_CONVOY_RAIDING
|
strike_force_home_base | value = <int> The weight of the strategy.
|
ai_strategy = { type = strike_force_home_base id = 18 value = 70 } |
Pursues AI to do the strike force mission within the specified strategic region. |
Name | Parameters | Examples | Description | Notes |
---|---|---|---|---|
agency_ai_base_num_factories_factor | value = <int> The weight of the strategy. |
ai_strategy = { type = agency_ai_base_num_factories_factor value = 70 } |
Changes the baseline used in the calculation of AI doing agency upgrades. | A value of 1 equals to a 1% increase over the baseline in Defines. |
agency_ai_per_upgrade_factories_factor | value = <int> The weight of the strategy. |
ai_strategy = { type = agency_ai_per_upgrade_factories_factor value = 70 } |
Modifies the needed amount of factories used in the calculation of AI doing agency upgrades. | A value of 1 equals to a 1% increase over the baseline in Defines. |
intelligence_agency_branch_desire_factor | value = <int> The weight of the strategy.
|
ai_strategy = { type = intelligence_agency_branch_desire_factor id = branch_crypto value = 70 } |
Modifies the needed amount of factories used in the calculation of AI doing agency upgrades. | Branches are defined in /Hearts of Iron IV/common/intelligence_agency_upgrades/*.txt files. |
intelligence_agency_usable_factories | value = <int> The weight of the strategy. |
ai_strategy = { type = intelligence_agency_usable_factories value = 8 } |
Modifies the amount of factories that AI would use for intelligence agencies. | |
operation_equipment_priority | value = <int> The weight of the strategy. |
ai_strategy = { type = operation_equipment_priority value = 80 } |
Pursues the AI to prioritise equipment for funding operations over other usages. | |
operative_mission | value = <int> The weight of the strategy.
|
ai_strategy = { type = operative_mission value = 80 mission = quiet_intel_network state = 123 state = 321 mission_target = ENG } |
Pursues the AI to do the specified mission over the target. | Multiple states can be defined, leading to one of them being prioritised. Mission names can be seen in /Hearts of Iron IV/localisation/english/operatives_l_english.yml. For example, OPERATIVE_MISSION_BOOST_IDEOLOGY_TITLE:0 "Boost Ideology" means that boosting ideology is boost_ideology.
|
operative_operation | value = <int> The weight of the strategy.
|
ai_strategy = { type = operative_operation value = 80 operation = heavy_water_raid operation_target = ENG } |
Pursues the AI to do the specified operation over the target. | Multiple states can be defined, leading to one of them being prioritised. Operations are defined within /Hearts of Iron IV/common/operations/*.txt files. |
Name | Parameters | Examples | Description | Notes |
---|---|---|---|---|
added_military_to_civilian_factory_ratio | value = <int> The weight of the strategy. |
ai_strategy = { type = added_military_to_civilian_factory_ratio value = 50 } |
Modifies the ratio of military to civilian factories that the AI desires to keep. | A positive value means more military factories. |
air_factory_balance | value = <int> The weight of the strategy. |
ai_strategy = { type = air_factory_balance value = 50 } |
Modifies the ratio of airforce to factories that the AI desires to keep. | A positive value means more airforce. |
dockyard_to_military_factory_ratio | value = <int> The weight of the strategy. |
ai_strategy = { type = dockyard_to_military_factory_ratio value = 50 } |
Modifies the ratio of dockyards to military factories that the AI desires to keep. | A positive value means more dockyards. |
railway_gun_divisions_ratio | value = <int> The weight of the strategy. |
ai_strategy = { type = railway_gun_divisions_ratio value = 5 } |
Modifies the ratio of railway guns to divisions that the AI desires to keep. | Base ratio is RAILWAY_GUN_PRODUCTION_BASE_DIVISIONS_RATIO_PERCENT in Defines, by default 0. This gets added to it, on the 0-100 scale. |
build_building | value = <int> The weight of the strategy.
|
ai_strategy = { type = build_building id = industrial_complex target = 803 value = 1 } |
Pursues AI to construct a specific building within the specified state. | Value decides how many buildings AI would want to building in the state at once. |
building_target | value = <int> The weight of the strategy.
|
ai_strategy = { type = building_target id = industrial_complex value = 30 } |
Makes AI keep a higher desired target of the specified building. | |
factory_build_score_factor | value = <int> The weight of the strategy.
|
ai_strategy = { type = factory_build_score_factor target = 365 value = 1 } |
Pursues AI to construct buildings within the specified state. | |
equipment_production_factor | value = <int> The weight of the strategy.
|
ai_strategy = { type = equipment_production_factor id = armor value = 30 } |
Pursues AI to produce equipment types of the specified type. | Types are defined for each equipment archetype in /Hearts of Iron IV/common/units/equipment/*.txt files within types = { ... } .
|
equipment_production_min_factories | value = <int> The weight of the strategy.
|
ai_strategy = { type = equipment_production_min_factories id = artillery value = 3 } |
Pursues AI to keep more factories on the production lines for the equipment types of the specified type. | A value of 1 corresponds to 1 military factory. Types are defined for each equipment archetype in /Hearts of Iron IV/common/units/equipment/*.txt files within types = { ... } .
|
equipment_variant_production_factor | value = <int> The weight of the strategy.
|
ai_strategy = { type = equipment_variant_production_factor id = light_tank_chassis value = -100 } |
Pursues AI to produce more of the specified equipment archetype. | Equipment archetypes are defined in /Hearts of Iron IV/common/units/equipment/*.txt files. |
equipment_stockpile_surplus_ratio | value = <int> The weight of the strategy. |
ai_strategy = { type = equipment_stockpile_surplus_ratio value = 30 } |
Changes the ratio of equipment that AI would hold in stockpile rather than immediately using. | |
build_army | value = <int> The weight of the strategy.
|
ai_strategy = { type = build_army id = suppression value = -1000 } |
Modifies the desired division amount for AI. | The used target is roles within AI templates. |
force_build_armies | value = <int> The weight of the strategy. |
ai_strategy = { type = force_build_armies value = 30 } |
Forces AI to build divisions above the desired amount. | |
production_upgrade_desire_offset | value = <int> The weight of the strategy.
|
ai_strategy = { type = production_upgrade_desire_offset id = artillery_equipment_2 value = -50 } |
Pursues AI to upgrade production lines to the specified equipment type. | Equipment types are defined in /Hearts of Iron IV/common/units/equipment/*.txt files. |
role_ratio | value = <int> The weight of the strategy.
|
ai_strategy = { type = role_ratio id = paratroopers value = 30 } |
Modifies the amount of templates that the AI makes for the specified role. | Roles are defined within AI templates for unit templates and AI equipment for ship and tank variants. |
unit_ratio | value = <int> The weight of the strategy.
|
ai_strategy = { type = unit_ratio id = cas value = 30 } |
Modifies the amount of templates that the AI makes with the specified unit. | Units are defined in /Hearts of Iron IV/common/units/*.txt files. This includes the airforce and navy alongside land army. |
min_wanted_supply_trains | value = <int> The weight of the strategy. |
ai_strategy = { type = min_wanted_supply_trains value = 300 } |
Overrides the minimum amount of supply trains wanted by AI. | |
min_wanted_supply_trucks | value = <int> The weight of the strategy. |
ai_strategy = { type = min_wanted_supply_trucks value = 30 } |
Overrides the minimum amount of supply trucks wanted by AI. |
Name | Parameters | Examples | Description | Notes |
---|---|---|---|---|
scorched_earth_prio | value = <int> The weight of the strategy.
|
ai_strategy = { type = scorched_earth_prio value = 100 id = ENG states = { 123 124 125 126 } } |
Pursues AI to use scorched earth within the specified states. | |
land_xp_spend_priority | value = <int> The weight of the strategy.
|
ai_strategy = { type = land_xp_spend_priority id = division_template value = 30 } |
Modifies the priority for AI to spend land experience. | Base game usages include division_template and upgrade_xp_cutoff .
|
pp_spend_amount | value = <int> The weight of the strategy.
|
ai_strategy = { type = pp_spend_amount id = idea value = 100 } |
Modifies the political power that AI should preserve for the specified purpose. | Base game usages include idea and decision .
|
pp_spend_priority | value = <int> The weight of the strategy.
|
ai_strategy = { type = pp_spend_priority id = relation value = 100 } |
Modifies where AI should prioritise spending political power. | Base game usages include the following:
|
research_weight_factor | value = <int> The weight of the strategy.
|
ai_strategy = { type = research_weight_factor id = radio_detection value = 2000 } |
Modifies the AI weight (score) of a specific technology. | value = 50 means 50% increase, -30 means 30% decrease, etc. |
AI areas
File:Ambox outdated info.png | 这部分内容可能已不适合当前版本,最后更新于1.11。 |
AI areas are defined within /Hearts of Iron IV/common/ai_areas/*.txt files. These are only used in a variety of previously-listed AI strategies, such as area_priority. A province may be in several AI areas and it may be in none. Hovering over a province with the debug mode turned on will provide information in which AI areas the province is, if any.
Each AI area is a separate block within the file, with the name of the block being the name of the area. Within these blocks, 2 things can be added:
continents = { ... }
is a list of continents that make up the AI area. Continents are defined within /Hearts of Iron IV/map/continent.txt and assigned to provinces within their definitions in /Hearts of Iron IV/map/definition.csv. The full name of the continent should be used within the AI area's definition, rather than the ID used in the province definition.
strategic_regions = { ... }
is a list of strategic regions that make up the AI area, by their ID number.
If there are multiple defined, the province has to be in any of them.
An example of an AI area is the following:
my_ai_area = { continents = { europe africa } strategic_regions = { 53 # Caribbean 189 # Burma } }
AI focuses
- 主条目:AI focuses
AI focuses, defined within /Hearts of Iron IV/common/ai_focuses/*.txt files, are used to tell the game which technology categories and focuses the AI should pick depending on its currently-pursued focuses.
AI peace
File:Ambox outdated info.png | 这部分内容可能已不适合当前版本,最后更新于1.11。 |
Pre-1.12 AI peace |
---|
The peace conference behaviour for AI is defined within /Hearts of Iron IV/common/peace_conference/ai_peace/*.txt files. When defining the peace conference AI that would be used by the country, the game picks the first-defined one that meets the prerequisites. In this case, files are loaded sorted by their filename using ASCII character IDs. When evaluating the peace conference, ROOT (the default scope) is used to represent the currently-evaluated winner and FROM is used to represent the currently-evaluated loser. Additionally, the following temporary variables exist within:
The There are the following peace options that are used in the game:
When evaluating peace conferences, the controller of a given state is the same one that occupied it before the start of the conference while the owner is the original owner. Each peace conference option is a MTTH block within the file's definition. Example:my_peace_conference = { enable = { has_government = my_ideology_group } annex = { base = 500 modifier = { factor = 0 any_allied_country = { any_state = { is_owned_by = FROM is_core_of = PREV NOT = { is_core_of = ROOT is_claimed_by = ROOT } } } } } puppet = { base = 100 modifier = { factor = 0 FROM = { tag = QAT } } } puppet_all = { base = 0 } puppet_state = { base = 100 modifier = { factor = 0 FROM.FROM = { tag = QAT } } modifier = { factor = 0 any_allied_country = { ROOT = { is_core_of = PREV NOT = { is_core_of = FROM.FROM is_claimed_by = FROM.FROM } } } } } take_states = { base = 100 modifier = { factor = 0 any_allied_country = { FROM = { is_core_of = PREV NOT = { is_core_of = ROOT is_claimed_by = ROOT } } } } } } |
AI strategy plans
File:Ambox outdated info.png | 这部分内容可能已不适合当前版本,最后更新于1.11。 |
AI strategy plans to tell AI what to prioritise depending on circumstances: which advisors to pick, which technologies to research, which AI strategies to apply, which focuses to pick, etc. These are more detailed than general AI strategies, primarily intended to be activated for most of the game to tell the overall plan of a country. Multiple AI strategy plans can be defined and executed at the same time for a country.
AI strategy plans are defined within /Hearts of Iron IV/common/ai_strategy_plans/*.txt files. Within these files, a new strategy plan is done as a new block, the name of which must be the same as the internal ID of the plan.
Within that plan, name = "AI plan's name"
and desc = "AI plan's description"
decide the name and the description of the strategy plan. This is never intended to be shown to the player, so localising it into different languages is never needed. Instead, this is used within the aiview
console command, which tells info to the developer about what AI wants to prioritise.
allowed = { ... }
is, similarly to decisions or ideas, is a trigger block checked only at the game's start. This is primarily used to tell which country and DLCs to restrict the strategy plan to.
enable = { ... }
is checked each day if the allowed is met. If enable = { ... }
is met, then the AI strategy plan will be assigned to the AI regardless of whether enable = { ... }
turns false later or not. Commonly, Triggers#has_game_rule is used to make it work with custom game rules deciding what path the AI will pick. is_historical_focus_on is commonly used with the default AI game rule, and country flags can be used for randomisation, by setting up an on_startup to set a random one using random_list
abort = { ... }
is checked every day in order to make the AI stop using this AI strategy plan if enable = { ... }
is met. Additionally, it must be false in order for the AI strategy plan to be possible to be picked.
ai_national_focuses = { TAG_focus_name_1 TAG_focus_name_2 }
is a list of national focuses, separated by whitespaces, in the order that the AI should take them. In this example, the AI will try to take TAG_focus_name_1 first if possible. If it's already taken or TAG_focus_name_1 is impossible to take, then AI will try to take TAG_focus_name_2. If both of the focuses are impossible to take due to being completed or unavailable, then it will move on to other focuses, taking ai_will_do = { ... }
into consideration. While following a focus order, it ignores ai_will_do = { ... }
values.
focus_factors = { ... }
assigns a multiplier to ai_will_do values of the specified focus. An entry in this block looks like TAG_focus_name = 3
. In this case, this will make the ai_will_do value of the focus be multiplied by 3, assuming AI strategy plan's weight of 1. If the focus has an ai_will_do value of 4 after applying modifiers, it'll become 12 if AI is following this strategy plan, and get treated as such. And, of course, a factor of 0 will make the focus be never picked without specification in ai_national_focuses. This can serve as a faster-to-write or a more randomised way to make AI follow a political path by making focuses it should never pick have a value of 0.
research = { ... }
assigns a multiplier to ai_will_do values of the specified research categories. An entry in this block looks like artillery = 3
. In this case, this will make the ai_will_do value of every technology within the category be multiplied by 3, assuming AI strategy plan's weight of 1. Other built-in modifiers still apply, but this will increase the likelihood.
Other blocks that also assign bonuses are ideas = { ... }
and traits = { ... }
, with the similar formatting. The ideas block is used for individual ideas (such as laws or designers) or advisors (using the idea_token in the entry), while traits are for country leader traits that are assigned to the ideas/advisors.
ai_strategy = { ... }
allows an AI strategy to apply when the strategy plan is turned on.
weight = { ... }
is a MTTH block assigning an overall weight to the plan. This multiplies each factor within the AI strategy plan by the weight before applying them. A weight of 1.25 will turn a focus factor of 4 into 5 before applying it, for instance. This can be used to make the AI follow the strategy plan more strictly in some cases and less strictly in others.
Example
BHR_historical = { name = "Historical plan for BHR" desc = "4 focuses in a specific order" allowed = { tag = BHR } enable = { OR = { AND = { is_historical_focus_on = yes has_game_rule = { rule = BHR_ai_behavior option = DEFAULT } } has_country_flag = BHR_AI_RANDOM_HISTORICAL # Randomly set in on_actions if BHR_ai_behavior is set to RANDOM. Make sure to set that up! has_game_rule = { rule = BHR_ai_behavior option = HISTORICAL } } } abort = { OMA = { OR = { has_government = fascism has_government = communism } } } ai_national_focuses = { BHR_focus_name_1 BHR_focus_name_2 BHR_focus_name_3 BHR_focus_name_4 } ideas = { BHR_advisor = 3 } traits = { fascist_demagouge = 0 } ai_strategy = { type = invade id = OMA value = 200 } } BHR_alternate = { name = "Alternative plan for BHR" desc = "AI is just set to never do BHR_focus_name_2 and be more likely to do BHR_focus_name_5, especially if after 1937" enable = { OR = { has_country_flag = BHR_AI_RANDOM_ALTERNATE # Randomly set in on_actions if BHR_ai_behavior is set to RANDOM. Make sure to set that up! has_game_rule = { rule = BHR_ai_behavior option = ALTERNATE } } } focus_factors = { BHR_focus_name_2 = 0 BHR_focus_name_5 = 2 } weight = { modifier = { factor = 2 date > 1937.1.1 } } research = { artillery = 2 } }
AI templates
File:Ambox outdated info.png | 这部分内容可能已不适合当前版本,最后更新于1.11。 |
/Hearts of Iron IV/common/ai_templates/*.txt files are used in order to define the templates that AI would aim for within the division template window.
A role template is defined as a block within any file in the folder with the name of the block being the same as the name of the role template.
These arguments are used for role templates themselves:
roles = { ... }
is a list of roles that the templates would have. These can be anything, getting used for the role_ratio AI strategy. AI will try to have one template for each role it has.available_for = { ... }
restricts the countries that use this role template to the tags in the list. If unspecified, every country uses them.blocked_for = { ... }
restricts the countries that use this role template from being the tags in the list. This is only needed if there is noavailable_for = { ... }
block.match_to_count = 0.3
is a decimal on the scale of 0-1 that decides how much a division template should fulfill one of the templates within the role template in order to count as one. By default set to 0.5.upgrade_prio = { ... }
is a MTTH block that decides the 'importance' of the role template compared to other role templates for spending experience on improving. If there are several role templates with the same roles, the one with the highest priority gets used, otherwise this decides likelihood compared to role templates with different roles.
Additionally, within role templates each individual template is defined as a block with the name of the template being the name of the block. It may be anything, as long as there is no overlap.
These arguments are used within a template definition:
upgrade_prio = { ... }
is a MTTH block that decides the 'importance' of the template compared to other templates within the role template for spending experience on improving.production_prio = { ... }
is a MTTH block that decides the 'importance' of the template compared to other templates within the role template for actually producing.replace_with = my_other_template
assigns a different template that serves as a more modern version of this one. When it becomes possible to create that template, AI will try to move towards using that one.can_upgrade_in_field = { ... }
is a trigger block that decides when AI will try to upgrade divisions that are already assigned this template to the one that it's set to be replaced with.custom_icon = 10
assigns the icon that AI would assign to this template. This example would assign the template icon using the spritesGFX_div_templ_10_large
andGFX_div_templ_10_small
. Optional, defaults to the majority brigade within the template.reinforce_prio = 2
assigns the reinforce priority that AI would set on this template. The default priority is 1, appearing in-game as 'regular'. 0 is 'reserve', and 2 is 'elite'. Defaults to 1 if unset.target_width = 20
assigns the combat width that the AI aims for on this template.width_weight = 2.5
assigns how much the AI should focus on aiming towards the target width. The higher the weight, the more AI would avoid deviating from the target width.column_swap_factor = 0.3
assigns a likelihood for AI to swap entire columns within the template to a different subunit group to meet the template.stat_weights = { ... }
is a list of decimal values. Each one applies to different stats and decides what exactly AI should try to prioritise and what it should try to avoid. As within NDefines.NAI.DIVISION_DESIGN_WEIGHTS in Defines, these stats are first the 17 army values, then air_attack, then common values and special values. In other words, Air and Navy values get skipped aside from air_attack, which is used by anti-air equipment. The value would be added to the default in defines: a 0.00 would mean it's the same priority as default.allowed_types = { ... }
is a list of sub-units that the AI can add to the template. If one is omitted, then the AI would never add it. This can be used to make AI not put units of different varieties in the template, such as putting infantry in a mobile light tank division, slowing it down.target_template = { ... }
assigns the template that AI should aim for. In particular, these arguments go inside of it:weight = 0.8
is how much the AI should aim towards having that template.match_value = 5000
is a value that decides how much the template is worth to AI if it's matched.support = { ... }
is a list of support battalions within the target template. A single definition within looks likeartillery = 1
. The first decides the unit type, the second decides the amount. Since there is a limit of only one of the same support battalion being allowed, the number can't be anything other than 1.regiments = { ... }
is a list of non-support, regular battalions within the target template. A single definition within looks likeartillery_brigade = 4
. The first decides the unit type, the second decides the amount.
Each template assigned to a role will form a group for the role, and then the fitness score of each available template is used to determine which is used at a specific moment for a specific role.
Example
armor_BHR = { available_for = { BHR } roles = { armor } upgrade_prio = { factor = 2.17 modifier = { factor = 7 OR = { has_tech = basic_medium_tank has_tech = basic_medium_tank_chassis } } modifier = { factor = 2 OR = { has_tech = main_battle_tank has_tech = main_battle_tank_chassis } } } match_to_count = 0.5 medium_armor_BHR = { upgrade_prio = { factor = 2 } target_width = 19.9 width_weight = 3.0 column_swap_factor = 0.1 stat_weights = { 0.00 #-- default_morale 1.10 #-- defense 1.10 #-- breakthrough 1.60 #-- hardness 1.00 #-- soft_attack 2.00 #-- hard_attack 0.10 #-- recon 0.01 #-- entrenchment 0.10 #-- initiative 0.01 #-- casualty_trickleback -0.05 #-- supply_consumption_factor -0.01 #-- supply_consumption 0.00 #-- suppression 0.00 #-- suppression_factor 0.01 #-- experience_loss_factor 0.00 #-- equipment_capture_factor 0.00 #-- fuel_capacity #-- Air Values 0.02 #-- air_attack #-- Common Values 50.00 #-- max_organisation 0.80 #-- max_strength 1.0 #-- maximum_speed 10.0 #-- armor_value 0.05 #-- ap_attack 0.10 #-- reliability 0.10 #-- reliability_factor 0.00 #-- weight 0.00 #-- fuel_consumption 0.00 #-- fuel_consumption_factor 0.00 #-- strat_attack 0.00 #-- carrier_size 0.00 #-- acc_hot_gain 0.00 #-- acc_cold_gain 0.00 #-- build_cost_ic } target_template = { weight = 0.9 match_value = 7000.0 support = { engineer = 1 maintenance_company = 1 logistics_company = 1 } regiments = { medium_armor = 6 motorized = 5 } } allowed_types = { modern_armor medium_armor motorized mechanized infantry motorized_rocket_brigade engineer mot_recon armored_car_recon light_tank_recon signal_company maintenance_company logistics_company anti_tank military_police artillery anti_air rocket_artillery } replace_at_match = 0.8 replace_with = modern_armor_BHR target_min_match = 0.5 } modern_armor_BHR = { upgrade_prio = { factor = 2 modifier = { factor = 1 } } target_width = 19.9 width_weight = 3.0 column_swap_factor = 0.1 stat_weights = { 0.00 #-- default_morale 1.10 #-- defense 1.10 #-- breakthrough 0.60 #-- hardness 2.00 #-- soft_attack 0.00 #-- hard_attack 0.10 #-- recon 0.01 #-- entrenchment 0.10 #-- initiative 0.01 #-- casualty_trickleback -0.05 #-- supply_consumption_factor -0.01 #-- supply_consumption 0.00 #-- suppression 0.00 #-- suppression_factor 0.01 #-- experience_loss_factor 0.00 #-- equipment_capture_factor 0.00 #-- fuel_capacity #-- Air Values 0.02 #-- air_attack #-- Common Values 50.00 #-- max_organisation 0.80 #-- max_strength 10.0 #-- maximum_speed 0.20 #-- armor_value 0.05 #-- ap_attack 0.10 #-- reliability 0.10 #-- reliability_factor 0.00 #-- weight 0.00 #-- fuel_consumption 0.00 #-- fuel_consumption_factor 0.00 #-- strat_attack 0.00 #-- carrier_size 0.00 #-- acc_hot_gain 0.00 #-- acc_cold_gain 0.00 #-- build_cost_ic } target_template = { weight = 0.9 match_value = 9000.0 support = { engineer = 1 recon = 1 maintenance_company = 1 logistics_company = 1 } regiments = { modern_armor = 4 mechanized = 3 medium_sp_artillery_brigade = 2 } } allowed_types = { modern_armor mechanized motorized_rocket_brigade medium_sp_artillery_brigade engineer recon signal_company maintenance_company logistics_company anti_tank military_police artillery anti_air rocket_artillery } } }
AI equipment
File:Ambox outdated info.png | 这部分内容可能已不适合当前版本,最后更新于1.11。 |
/Hearts of Iron IV/common/ai_equipment/*.txt files are used in order to define the equipment variants that the AI should aim for when assigning modules to tank or ship variants.
A role template is defined as a block within any file in the folder with the name of the block being the same as the name of the role template.
These arguments are used for role templates themselves:
category = <land|naval|air>
decides whether the template is used for tanks, ships or planes respectively.roles = { ... }
is a list of roles that the templates would have. These can be anything, getting used for the role_ratio AI strategy. AI will try to have one variant for each role it has.available_for = { ... }
restricts the countries that use this role template to the tags in the list. If unspecified, every country uses them.blocked_for = { ... }
restricts the countries that use this role template from being the tags in the list. This is only needed if there is noavailable_for = { ... }
block.priority = { ... }
is a MTTH block that decides the 'importance' of the role template compared to other role templates for spending experience on improving. If there are several role templates with the same roles, the one with the highest priority gets used, otherwise this decides likelihood compared to role templates with different roles.
Additionally, within role templates each individual design is defined as a block with the name of the design being the name of the block. It may be anything, as long as there is no overlap.
These arguments are used within a design definition:
name = angry_speedboat
required to enable the equipment to be used as preset. If not defined, for example Germanlight_tank_artillery_2
will useGER_light_tank_artillery_equipment_2_short
localization if defined.role_icon_index = 2
is used to assign a specific role icon to a ship. This does not work within land equipment. The icons are defined as a part ofnaval_equipment_role = { ... }
within /Hearts of Iron IV/gfx/army_icons/army_icons.txt.priority = { ... }
is a MTTH block that decides the 'importance' of the design compared to other templates within the role template for spending experience on improving.enable = { ... }
is a trigger block that decides when AI should aim towards the design.allowed_types = { ... }
is a list of sub-units that the AI can add to the design. If one is omitted, then the AI would never add it. This can be used to make AI not put units of different varieties in the design, such as putting infantry in a mobile light tank division, slowing it down.target_variant = { ... }
assigns the variant that AI should aim for. In particular, these arguments go inside of it:match_value = 5000
is a value that decides how much the template is worth to AI if it's matched.type = light_tank_chassis_0
is the specific equipment type that must be used by the design.modules = { ... }
is a list of modules that the equipment should have, in particular:main_armament_slot = tank_flamethrower
decides requirements for a specified module slot, in first place. The requirement may be a module category, a specific module, or the wordempty
. If specifying a module, the greater-than or lesser-than signs can be used in order to require greater or lesser modules: this is decided by the year defined within the module. If lesser is specified, AI aims towards oldest modules, if greater is specified, AI aims towards newest modules. If specifying empty, greater than can be used to ensure it's not empty.main_armament_slot = { ... }
allows specifying more details for a module slot:module = tank_flamethrower
decides a module requirement for the slot. This is the exact same formatting as previousmain_armament_slot = tank_flamethrower
: module categories, modules, or empty are allowed, and the equality signs can be used in the same way.any_of = { ... }
is a list of modules or module categories. The module slot must have at least one of them.upgrade = current
ensures that, when upgrading a variant to match this design, it must use the same one as on the existing equipment. If the 'greater than' sign is used (>), then it would require AI to upgrade this slot as well.
upgrades = { ... }
is a list of upgrades that the design should have, in particular:tank_nsb_engine_upgrade = 3
decides the AI priority that the specified upgrade should have to a fixed number.tank_nsb_engine_upgrade = { ... }
is a MTTH block that assigns the AI priority to the specified upgrade dynamically.
requirements = { ... }
is a list of modules that the AI must have. This follows the same formatting as a specified module slot within a target variant's modules block:module = tank_flamethrower
,any_of = { ... }
, etc. However, this is not tied to a specific slot.allowed_modules = { ... }
is a list of modules that the AI can use after the requirements in the target variant are met. If a module isn't here, it'll never be picked. The modules specified first take priority over the later ones.
Example
BHR_light_tanks = { category = land available_for = {BHR} roles = { land_light_tank } priority = { factor = 1000 } great_war_tank_default = { priority = { factor = 1 modifier = { has_tech = basic_light_tank_chassis factor = 0 #let's not waste XP here } } target_variant = { match_value = 1000 type = light_tank_chassis_0 modules = { main_armament_slot = tank_heavy_machine_gun turret_type_slot = tank_light_one_man_tank_turret suspension_type_slot = tank_bogie_suspension armor_type_slot = tank_riveted_armor engine_type_slot = tank_gasoline_engine special_type_slot_1 = empty special_type_slot_2 = empty special_type_slot_3 = empty special_type_slot_4 = empty } upgrades = { tank_nsb_engine_upgrade = 3 tank_nsb_armor_upgrade = { base = 1 modifier = { add = 1 has_war = yes } } } } allowed_modules = { tank_heavy_machine_gun tank_light_one_man_tank_turret tank_bogie_suspension tank_riveted_armor tank_gasoline_engine } } }
文件 | 效果 • 条件 • 定义 • 修正 • 修正列表 • 作用域 • 本地化 • on action • 数据结构 (标记, 临时标记, 国家别名, 变量, 数组) |
脚本 | 成就修改 • AI修改 • AI focuses • 自治领修改 • 权力平衡修改 • 剧本/标签 (游戏规则)• 建筑修改 • 人物修改 • 修饰性TAG修改 • 国家创建 • 军队修改 • 决议制作 • 装备修改 • 事件修改 • Idea修改 • 意识形态修改 • 军工商修改 • 国策制作 • 资源修改 • Scripted GUI • 科技制作 • 单位修改 |
地图 | 地图 • 省份 • 补给区域 • 战略区域 |
图形图像 | 界面 • 图形资产 • 实体模型 • 后期特效 • 离子效果 • 字体 |
装饰性 | 肖像 • 命名列表 • 音乐 • 音效 |
其他 | 控制台指令 • 故障排除 • 模组结构 • 成就代码分析 • Mod相关 • Nudger修改 |