变量:修订间差异

本页面所适用的版本可能已经过时,最后更新于1.9
(Yrsn509移动页面Variables变量:汉化)
第87行: 第87行:
=== 添加到变量 ===
=== 添加到变量 ===
{{SVersion|1.9}}
{{SVersion|1.9}}
 包括“从变量中减去”、“乘以变量”、“从变量中除去”和" 取余数”
 包括“从变量中减去”、“乘以变量”、“从变量中除去”和 取余数”


 这些和设置变量的机制差不多
 这些和设置变量的机制差不多

2020年8月30日 (日) 13:02的版本


变量[1]是我们在1.5.0中添加的一个功能强大的系统。它使内容设计者能够在不同的地方存储数字(“值”),并在效果/触发器中使用它们。

有四个作用域能使用变量

  • Country
  • State
  • Unit Leader
  • Global

每个国家、省份和将领都有自己的变量列表。全局作用域是唯一的,应该用于存储在全局范围内真正有意义的变量,而不是特定于某个国家的变量。

访问变量

在各种效果/触发器中,可以通过给变量一个名称来访问它。变量名不区分大小写,除了一些特殊字符外,您可以使用任何您想要的字符。尽管为了一致性和未来的维护,避免使用数字和特殊字符(除了下划线"_")

默认情况下,您将访问当前范围中的变量。如果要访问特定范围或其他范围上的变量,可以使用以下命令:

ENG.var_name
42.var_name
global.var_name
ROOT.var_name
FROM.FROM.var_name
event_target:event_target_name.var_name
global_event_target:event_target_name.var_name
another_var_name:var_name
  • 使用国家Tag以访问存储在国家作用域内的变量。在第一个例子里能够访问英格兰的特定变量
  • 使用省份ID以访问存储在省份作用域内的变量。第二个例子能够访问摩泽兰的特定变量
  • 使用Global以访问存储在全局作用域内的变量。
  • 使用像ROOT,PREV或者FROM这些代码来切换到不同的作用域(第四个例子),也可以把他们连接起来(第五个例子)。
  • You can access a variable on an event target by adding event_target:event_target_name before the variable (6th) or you can do * same for a global_event_target (7th)

默认情况下变量的值为0。当你访问一个不存在的变量时,其值默认为0。你可以通过下列的命令来让其默认值为别的数字。

var_name?123

当你访问一个像这样的变量时,如果这个变量不存在的话其默认值就会为“123”

在剩下的教程中,我将使用var_name访问当前范围中名为“var_name”的示例变量,但您也可以使用这里提到的所有其他方法访问不同范围中的变量

变量效果

下面是一个可以用来改变变量值的效果列表。

设置变量值

set_variable = {
    var = var_name
    value = 123
}
set_variable = {
    var = var_name
    value = var_name_2
}

或简写成:

set_variable = { var_name = var_name_2 }

set_variable用于将一个变量的值设置为一个数字或另一个变量。第一个示例将var_name设置为123,第二个示例将其设置为var_name_2的值。第三个例子相当于第二个例子,但写起来要简短一些。

每个能用到变量的地方都能写的这么简短。

变量的一个特殊之处是可以使用值而不是变量。这是第一个例子的工作原理。在这个例子中,123实际上是一个变量,但是它的值总是123,不管怎样。这使得在实际需要变量的地方使用常量成为可能。

但当然如果你写成像下面这样的话:

set_variable = { 1 = 2 }

它会立刻报错因为这样的赋值没有意义。

清空变量

clear_variable = var_name

这将完全清除变量。清除一个变量后,它将不再存在,当您访问它时,您将得到0(除非它被?)覆盖)

添加到变量

包括“从变量中减去”、“乘以变量”、“从变量中除去”和“取余数”

这些和设置变量的机制差不多

add_to_variable = {
    var = var_name
    value = 123
}
add_to_variable = {
    var = var_name
    value = var_name_2
}
或简写成:

add_to_variable = { var_name = var_name_2 } 

这些示例将为其添加值,而不是仅仅设置变量的值,您也可以用其他效果替换add_to_variable代码以使用这些操作。

设置变量的上下限

clamp_variable = {
    var = var_name
    min = var_name_2
    max = var_name_3
}

clamp_variable 能用来设置变量的上下限 (通过变量或者值)。在这个例子,如果var_name < var_name_2,它就会被设为var_name 2。如果它大于var_name_3,它就会被设为var_name_3。否则,它的值就会保持不变。

变量取整

round_variable = var_name

这会将变量的值设置为最近的整数

变量触发

只有两个触发和变量有关,它们分别是:

检查变量的值

check_variable 会比较两个变量或者变量和值之间的数量关系,作为触发条件使用。

check_variable = {
    var = var_name
    value = var_name_2
    compare = less_than
}

这个例子会比较var_name和var_name_2的值是否符合条件(var_name < var_name_2),如果符合将返回True

有效的比较条件:

  • less_than
  • less_than_or_equals
  • greater_than
  • greater_than_or_equals
  • equals
  • not_equals

如果你想的话也可以省略比较条件,这时会默认为greater_than_or_equals(大于等于)

这同样可以简写成:

check_variable = { var_name = var_name_2 }
check_variable = { var_name < var_name_2 }
check_variable = { var_name > var_name_2 }

第一个会检查是否相等,第二个会检查前者是否小于后者,第三个会检查前者是否大于后者。但是不能通过数学符号来比较除此以外的数量关系(比如">="就不行)

存在变量

has_variable = var_name

这会检查在当前作用域下是否存在变量。clear_variable会完全地清除变量,因此这时has_variable会返回False

Targeted Variables

You can define a variable that is targeted at some other scope. Here is an example usage

ENG = {
  TUR = {
    set_variable = { var_name@PREV = 5 }
  }
}

Here first we set scope to ENG and then to TUR. When we call set_variable, it will set a variable named var_name on TUR targeted towards PREV scope (which is ENG).

You can chain scopes (var_name@PREV.PREV) or use country tags/state IDs as well (var_name@ENG for example would behave same in previous example, an example for states would be var_name@42).

You can only target states or countries (no unit leaders).

Using variables like event targets

Variables can replace event targets up to a point. Instead of storing a value, you can store a country TAG or state id in variables and use them later in a similar way. Example:

set_variable = { var_name = POL.id }
var:var_name = {
    set_variable = { var_name_2 = 125 }
}

This example will create a var_name variable in current scope and set it to id of POL (a unique number represents POL). After that you can switch scope to POL using this variable like we did in the example. The example here will set a variable named var_name_2 to 125 in Poland scope.

You can set a variable to a country TAG like we did in example. You can also use scopes like PREV/FROM/ROOT or chain them together. To set something to current scope, use THIS instead. If you want to set a variable to a specific state scope, you can use set_variable = { var_name = 42.id} (which is basically id on 42 scope)

You can only set a variable to a country or a state scope (no unit leader scope, they are like a bastard child of this system)

Variables and Scripted Localization

You can access a variable in scripted using the following in the string:

[?var_name]

Will print the value of var_name in scope of scripted localization.

Temporary Variables

Temporary variables is a 'feature' (read hack) that lets you store variables that will be stored temporarily and will be deleted after the script ends. You can use those to make a calculations without , lets say you want to calculate following equation:

c = a * 2 - b / 3

Here is how you can do it without creating additional variables anywhere:

set_temp_variable = { temp1 = a }
multiply_temp_variable = { temp1 = 2 }

set_temp_variable = { temp2 = b }
divide_temp_variable = { temp2 = 3 }

subtract_from_temp_variable = { temp1 = temp2 }

set_variable = { c = temp1 }

These are the effects relating to temporary variables:

  • set_temp_variable
  • add_to_temp_variable
  • subtract_from_temp_variable
  • multiply_temp_variable
  • divide_temp_variable
  • modulo_temp_variable
  • round_temp_variable
  • clamp_temp_variable

In previous example, the last line sets c to temp1. If you already had an actual variable named temp1 in current scope, it will be shadowed by temp variable. So try to use unique names for your temp variables or otherwise it will be weird.

One cool about temp variables is that you can use them in triggers. Since their effects are only temporary and does not affect game play, they should be safe to use. For example in previous example we could calculate a * 2 - b / 3 same way and check if it is greater than 0 using using check_variable trigger.

Also in a couple part of the programs, temporary variables are not cleared between triggers and effects. For example temporary variables stays same for is_valid trigger of an event and their effects. So you can calculate something in trigger, then use it on effect. This is kinda weird but it has uses.

Random Variables

You can use a variable named 'random' to get a random variable:

set_variable = { var_name = random }

Will set var_name to a value between 0 and 1. You can use it on triggers as well but it will give you same variable.

There are also a couple more types of randomization distributions: uniform, binomial and poisson distribution. The first type is almost identical to the default distribution, except that when using it, you can select the minimum and maximum values of the variable. Example:

randomize_temp_variable = {
  var = num_dogs
  distribution = uniform
  min = 0
  max = 1
}

The second type can take the minimum and maximum values as the previous one, but in contrast to the previous one is more likely to take an average value, note: N=2. Example:

randomize_temp_variable = {
  var = num_dogs
  distribution = binomial
  min = 0  # optional
  max = 10 # required if min is specified
}

The last distribution uses the lambda value to randomize the variable. When using this type of distribution, the difference between the maximum and average values of the variable decreases as the lambda value increases. Unlike the previous ones, it can only set the minimum value of a variable. Example:

randomize_temp_variable = {
  var = num_dogs
  distribution = poisson
  lambda = 10  # required
  min = 10     # optional
}

For AI triggers (like ai_will_do modifiers), use ai_random instead.

Game Variables

Game variables are a special read only variables. You can read them like regular variables but they are actually calculated dynamically. For example in countries you can access political power of a country and use it as a variable:

set_variable = { var_name = political_power }

Here political_power is actually a game variable and it gives you political power that a country has. You can not edit them though, you have to use effects for those.

Some of them are automatically converted from triggers (basically any triggers that accepts country/state/unit leader/global scope and works like max_manpower = 10 can be used as game variable) but some of them are unique to modifier system.

Do not use name of game variables in your variables.

hoi4 scripting language supports storing tokens as a variable. For example you can do the following:

set_temp_variable = { t = token:infantry_equipment }

add_equipment_to_stockpile = {
	type = var:t
	amount = 100
}

Here you are storing token infantry_equipment in a temporary variable named t and later we are using this stored token in add_equipment_to_stockpile effect.

At the moment following objects can be stored in variables and all effects/triggers should be able to accept such variables.

ideology/ideology groups
equipment types
operation

Here is a list of game variables for each type of scope:

Global

Variable Description
countries get array of all countries (including non existing)
date get date value that can be comparable to other date values and localized using GetDateString/GetDateStringShortMonth/GetDateStringNoHour/GetDateStringNoHourLong scripted locs
ideology_groups array of objects in ideology_groups database
majors get array of all majors (including non existing)
num_days current total days
operations array of objects in operations database
year current year
difficulty (trigger) check if the difficulty is above or below specified value 0-2 (difficulty enum). Example: difficulty > 0 (above easy)
threat (trigger) check the global threat value. 0-1 value

Country

Variable Description
ai_attitude_allied_weight weight for an ai attitude attitude_allied against country. Example: GER.ai_attitude_allied_weight@ENG
ai_attitude_friendly_weight weight for an ai attitude attitude_friendly against country. Example: GER.ai_attitude_friendly_weight@ENG
ai_attitude_hostile_weight weight for an ai attitude attitude_hostile against country. Example: GER.ai_attitude_hostile_weight@ENG
ai_attitude_is_threatened returns 1 if ai is threatened
ai_attitude_neutral_weight weight for an ai attitude attitude_neutral against country. Example: GER.ai_attitude_neutral_weight@ENG
ai_attitude_outraged_weight weight for an ai attitude attitude_outraged against country. Example: GER.ai_attitude_outraged_weight@ENG
ai_attitude_protective_weight weight for an ai attitude attitude_protective against country. Example: GER.ai_attitude_protective_weight@ENG
ai_attitude_threatened_weight weight for an ai attitude attitude_threatened against country. Example: GER.ai_attitude_threatened_weight@ENG
ai_attitude_wants_ally returns 1 if ai wants ally
ai_attitude_wants_antagonize returns 1 if ai wants antagonize
ai_attitude_wants_ignore returns 1 if ai wants ignore
ai_attitude_wants_protect returns 1 if ai wants protect
ai_attitude_wants_weaken returns 1 if ai wants weaken
ai_strategy_activate_crypto ai strategy value activate_crypto against country. Example: GER.ai_strategy_activate_crypto@ENG
ai_strategy_alliance ai strategy value alliance against country. Example: GER.ai_strategy_alliance@ENG
ai_strategy_antagonize ai strategy value antagonize against country. Example: GER.ai_strategy_antagonize@ENG
ai_strategy_befriend ai strategy value befriend against country. Example: GER.ai_strategy_befriend@ENG
ai_strategy_conquer ai strategy value conquer against country. Example: GER.ai_strategy_conquer@ENG
ai_strategy_consider_weak ai strategy value consider_weak against country. Example: GER.ai_strategy_consider_weak@ENG
ai_strategy_contain ai strategy value contain against country. Example: GER.ai_strategy_contain@ENG
ai_strategy_declare_war ai strategy value declare_war against country. Example: GER.ai_strategy_declare_war@ENG
ai_strategy_decrypt_target ai strategy value decrypt_target against country. Example: GER.ai_strategy_decrypt_target@ENG
ai_strategy_dont_defend_ally_borders ai strategy value dont_defend_ally_bordersagainst country. Example: GER.ai_strategy_dont_defend_ally_borders@ENG
ai_strategy_force_defend_ally_borders ai strategy value force_defend_ally_borders against country. Example: GER.ai_strategy_force_defend_ally_borders@ENG
ai_strategy_ignore ai strategy value ignore against country. Example: GER.ai_strategy_ignore@ENG
ai_strategy_ignore_claim ai strategy value ignore_claim against country. Example: GER.ai_strategy_ignore_claim@ENG
ai_strategy_influence ai strategy value influence against country. Example: GER.ai_strategy_influence@ENG
ai_strategy_invade ai strategy value invade against country. Example: GER.ai_strategy_invade@ENG
ai_strategy_occupation_policy ai strategy value occupation_policy against country. Example: GER.ai_strategy_occupation_policy@ENG
ai_strategy_prepare_for_war ai strategy value prepare_for_war against country. Example: GER.ai_strategy_prepare_for_war@ENG
ai_strategy_protect ai strategy value protect against country. Example: GER.ai_strategy_protect@ENG
ai_strategy_send_volunteers_desire ai strategy value send_volunteers_desire against country. Example: GER.ai_strategy_send_volunteers_desire@ENG
ai_strategy_support ai strategy value support against country. Example: GER.ai_strategy_support@ENG
air_intel air intel against a target country. example GER.air_intel@ENG
allies array of allies (faction members). prefer using faction_members instead
army_intel army intel against a target country. example GER.army_intel@ENG
army_leaders all army leaders of a country
autonomy_ratio autonomy of scope country. -1 if not a subject
capital capital state of the country
civilian_intel civilian intel against a target country. example GER.civilian_intel@ENG
command_power total command power of country
controlled_states array of controlled states
core_compliance returns core compliance of target country
core_resistance returns core resistance of target country
core_states array of core states
cryptology_defense_level cryptology defense level of a country
current_party_ideology_group returns the token for current party ideology group
days_mission_timeout timeout in days for a specific timed mission, mission type token is defined in target. example: days_mission_timeout@GER_mefo_bills_mission
decryption_speed total encryption strength of a country that is needed
encryption_strength total encryption strength of a country that is needed
enemies array of enemies at war with
enemies_of_allies array of enemies of allies
exiles exile host of this country
faction_leader faction leader of this country's faction
faction_members array of faction members
fuel_k total fuel of country in thousands
highest_party_ideology ideology of the most popular party. Can exclude the ruling party by using @exclude_ruling_party. Example: highest_party_ideology OR highest_party_ideology@exclude_ruling_party
highest_party_popularity popularity size of the most popular party [0.00, 1.00]. Can exclude the ruling party by using @exclude_ruling_party. Example: highest_party_popularity OR highest_party_popularity@exclude_ruling_party
host exile host of this country
legitimacy legitimacy of scope country. -1 if not an exile
manpower DEPRECATED, MAY OVERFLOW. total manpower of country
manpower_k total manpower of country in thousands
max_available_manpower DEPRECATED, MAY OVERFLOW. total available manpower of country
max_available_manpower_k total available manpower of country in thousands
max_fuel_k max fuel of country in thousands
max_manpower DEPRECATED, MAY OVERFLOW. maximum manpower of country
max_manpower_k maximum manpower of country in thousands
modifier a modifier stored in country scope (usage modifier@stability_weekly or any other modifier. Gives you value of a modifier at country)
navy_intel navy intel against a target country. example GER.navy_intel@ENG
navy_leaders all navy leaders of a country
neighbors array of neighbors
neighbors_owned array of neighbors to owned states
num_armies number of armies
num_armies_in_state number of armies in state, state is in target. example num_armies_in_state@123
num_armies_with_type number of armies with dominant type, dominant type is defined in target. example: num_armies_with_type@light_armor
num_battalions number of battalions
num_battalions_with_type number of battalions with sub unit type, sub unit type is defined in target. example: num_of_battalions_with_type@light_armor
num_controlled_states number of controlled states
num_core_states number of core states
num_deployed_planes number of deployed planes
num_deployed_planes_with_type number of deployed planes with equipment type. example num_deployed_planes_with_type@fighter
num_equipment number of equipment in country. example num_equipment@infantry_equipment
num_equipment_in_armies number of equipment in armies of the country, equipment type token is defined in target. example num_equipment_in_armies@infantry_equipment
num_equipment_in_armies_k number of equipment in armies of the country in thousands, equipment type token is defined in target. example num_equipment_in_armies_k@infantry_equipment
num_owned_controlled_states number of owned and core states
num_owned_states number of owned states
num_ships number of ships
num_ships_with_type number of ships controlled in country, ship type is defined in target. example num_ships_with_type@carrier
num_target_equipment_in_armies number of equipment required in armies of the country, equipment type token is defined in target. example num_target_equipment_in_armies@infantry_equipment
num_target_equipment_in_armies_k number of equipment required in armies of the country in thousands, equipment type token is defined in target. example num_target_equipment_in_armies_k@infantry_equipment
occupied_countries array of occupied countries
operatives all operatives of a country
opinion opinion of a country targeted on another one. example GER.opinion@ENG
original_tag returns the original tag of a country
overlord master of this subject
owned_controlled_states array owned and core states
owned_states array of owned states
party_popularity popularity of targeted party. example party_popularity@democratic. mat also target ruling_party
political_power total political power of country
potential_and_current_enemies array of potential and actual enemies
resource number of surplus resources in country, resource type is defined in target resource@steel
resource_consumed number of resources consumed by country, resource type is defined in target resource_consumed@steel
resource_exported number of resources exported by country, resource type is defined in target resource_exported@steel
resource_imported number of resources imported by country, resource type is defined in target resource_imported@steel
resource_produced number of resources produced by country, resource type is defined in target. example resource_produced@steel
stability stability of a country
subjects array of subjects
agency_upgrade_number (Trigger) Checks the number of upgrade done in the intelligence agency.
ai_irrationality (trigger) Check the ai irrationality value.
ai_wants_divisions (trigger) Will compare towards the amount of divisions an ai wants to have.
alliance_naval_strength_ratio (trigger) Compares the estimated naval strength between the scope country, his allies and his enemies.
alliance_strength_ratio (trigger) Compares the estimated army strength between the scope country, his allies and his enemies.
amount_manpower_in_deployment_queue (trigger) Checks for amount manpower currently in deploymentview.
amount_research_slots (trigger) Check number of research current research slots.
any_war_score (trigger) Compares the warscore of all wars in a country to see if any fullfills the comparison condition 0-100. Example: any_war_score > 40.
casualties (trigger) Check the amount of casualties a country has suffered in all of it's wars.
casualties_k (trigger) Check the amount of casualties in thousands a country has suffered in all of it's wars.
command_power_daily (trigger) Checks if daily command power increase is more or less that specified value.
compare_autonomy_progress_ratio (trigger) Check if autonomy progress ratio is higher than value.
conscription_ratio (trigger) Checks conscription ratio of the country compared to target conscription ratio.
convoy_threat (trigger) A trigger to check convoy threat for a country. Controlled by NAVAL_CONVOY_DANGER defines. Returns a value between 0 and 1. Example: convoy_threat > 0.5
current_conscription_amount (trigger) Checks the current conscription amount of the country.
days_since_capitulated (trigger) Checks the number of days since the country last capitulated, even if it is no longer capitulated. If it has not ever capitulated, the value is extremely large. It is recommended to combine this with has_capitulated = yes when you specifically want to ignore non-active capitulations. Example: GER = { OR = { has_capitulated = no days_since_capitulated > 14 } } # Germany is not both actively and recently capitulated.
decryption_progress (trigger) Checks decryption ratio against a country. Example: decryption_progress = { target = GER value > 0.5 } OR decryption_progress@GER as variable.
enemies_naval_strength_ratio (trigger) Compares the estimated navy strength between the scope country and all its enemies.
enemies_strength_ratio (trigger) Compares the estimated army strength between the scope country and all its enemies.
foreign_manpower (trigger) Check the amount of foreign garrison manpower we have.
fuel_ratio (trigger) Compares the fuel ratio to a variable.
garrison_manpower_need (trigger) Check the amount of manpower needed by garrisons.
has_added_tension_amount (trigger) Compare if the country has added above or below the specified amount of tension.
has_collaboration (trigger) Checks the collaboration in a target country with our currently scoped country. Example: has_collaboration = { target = GER value > 0.5} OR has_collaboration@GER as variable.
has_legitimacy (trigger) Check scope country legitimacy 0-100.
has_manpower (trigger) Check amount of manpower.
has_political_power (trigger) Check amount of political power.
has_stability (trigger) Check value of stability 0-1. Example: has_stability < 0.6.
has_war_support (trigger) Check value of war_support 0-1. Example: has_war_support < 0.6.
land_doctrine_level (trigger) Checks researched land doctrine level.
manpower_per_military_factory (trigger) Number of available manpower per factory (excluding dockyards) the country has.
mine_threat (trigger) A trigger to check how dangerous enemy mines are for a country. Controlled by NAVAL_MINE_DANGER defines. Returns a value between 0 and 1. Example: mine_threat > 0.5
network_national_coverage (trigger) Checks network national coverage you have over a country. Example: network_national_coverage = { target = GER value > 0.5 }.
num_divisions (trigger) Will compare towards the amount of divisions a country has control over, if strength matters use has_army_size.
num_faction_members (trigger) Compares the number of members in the faction for the current country.
num_fake_intel_divisions (trigger) Will compare towards the amount of fake intel divisions a country has control over.
num_free_operative_slots (trigger) Checks the number of operative a country can recruit right now. Note that this is not necessarily greater than zero, if num_operative_slots returned a number greater than the number of operative.
num_occupied_states (trigger) Check the number of states occupied by nation.
num_of_available_civilian_factories (trigger) Check amount of available civilian factories.
num_of_available_military_factories (trigger) Check amount of available military factories.
num_of_available_naval_factories (trigger) Check amount of available naval factories.
num_of_civilian_factories (trigger) Check amount of civilian factories.
num_of_civilian_factories_available_for_projects (trigger) Check amount of civilian factories available for a new project to use.
num_of_controlled_states (trigger) Check amount of controlled states.
num_of_factories (trigger) Check amount of total factories.
num_of_military_factories (trigger) Check amount of military factories.
num_of_naval_factories (trigger) Check amount of naval factories.
num_of_nukes (trigger) Check amount of nukes.
num_of_operatives (trigger) Checks the number of operatives the country controls.
num_operative_slots (trigger) Checks the number of available operative slots a country has. If this differs from the number of operative, this does not mean the country can recruit an operative, but that it will eventually be able to.
num_subjects (trigger) Check the number of subjects of nation.
num_tech_sharing_groups (trigger) Checks how many tech sharing groups a nation is a member of.
original_research_slots (trigger) Check number of research slots at start of game.
political_power_daily (trigger) Checks if daily political power increase is more or less that specified value .
political_power_growth (trigger) Check the value of political power daily growth.
surrender_progress (trigger) Check if a country is close to surrendering.
target_conscription_amount (trigger) Checks the target conscription amount of the country.

State

Variable Description
arms_factory_level military factory level in the state
building_level building level of a building with type, uses target as building type. example: building_level@arms_factory
controller controller of the state
core_countries countries that cores the state
damaged_building_level damaged building level of a building with type, uses target as building type. example: damaged_building_level@arms_factory
distance_to distance to another state, uses target as another state. example: 123.distance_to@124
industrial_complex_level civilian factory level in the state
infrastructure_level infrastructure level in the state
modifier value of modifier stored in this state, uses target as modifier token, example: 123.modifier@local_manpower
non_damaged_building_level non damaged building level of a building with type, uses target as building type. example: non_damaged_building_level@arms_factory
owner owner of the state
resource resources produced in state. example: resource@steel
compliance (trigger) Compares the current compliance level of a state to a value.
compliance_speed (trigger) Compares the current compliance speed of a state to a value.
days_since_last_strategic_bombing (trigger) Checks the days since last strategic bombing.
resistance (trigger) Compares the current resistance level of a state to a value.
resistance_speed (trigger) Compares the current resistance speed of a state to a value.
resistance_target (trigger) Compares the target resistance level of a state to a value.
state_and_terrain_strategic_value (trigger) Checks for state strategic value.
state_population (trigger) Check the population in the state.
state_population_k (trigger) Check the population in the state in thousands (use to avoid variable overflows).
state_strategic_value (trigger) Checks for state strategic value.

Unit Leader

Variable Description
army_attack_level attack level of the leader
army_defense_level defense level of the leader
attack_level attack level of the leader
average_stats average stats of unit leader
avg_combat_status average progress of all combats
avg_defensive_combat_status average progress of defensive combats
avg_offensive_combat_status average progress of offensive combats
avg_unit_planning_ratio average planning ratio of all units
avg_units_acclimation average unit acclimatization for a specific climate, acclimatization type is defined in target, example: avg_units_acclimation@cold_climate
coordination_level coordination level of the leader
defense_level defense level of the leader
has_orders_group 1 if leader has orders group, zero otherwise
intel_yield_factor_on_capture rate at which intel is extracted from this operative by an enemy country
leader_modifier value of a modifier stored in leader modifier, modifier token is defined in target, example: leader_modifier@navy_max_range
logistics_level logistics level of the leader
maneuvering_level maneuvering level of the leader
num_armored number of units with armored dominant type
num_artillery number of units with artillery dominant type
num_assigned_traits number of assigned traits the leader has
num_basic_traits number of basic traits a leader has
num_battalions number of battalions
num_battalions_with_type number of battalions with sub unit type, sub unit type is defined in target, example: num_battalions_with_type@light_armor
num_battle_plans number of battle plans of unit leader
num_cavalry number of units with cavalry dominant type
num_equipment number of equipment in army of a leader, equipment type token is defined in target, example: num_equipment@infantry_equipment
num_infantry number of units with infantry dominant type
num_max_traits number of maximum assignable traits a leader can have
num_mechanized number of units with mechanized dominant type
num_motorized number of units with motorized dominant type
num_personality_traits number of personality traits a leader has
num_rocket number of units with rocket dominant type
num_ships number of ships controlled by leader
num_ships_with_type number of ships controlled by leader, ship type is defined in target, example: num_ships_with_type@carrier
num_special number of units with special dominant type
num_status_traits number of status traits a leader has
num_target_equipment number of equipment required in army of a leader, equipment type token is defined in target, example: num_target_equipment@infantry_equipment
num_terrain_traits number of terrain traits a leader has
num_traits number of traits a leader has
num_units number of units controlled by leader
num_units_crossing_river number of units currently passing through a river
num_units_defensive_combats number of units in defensive combats
num_units_defensive_combats_on number of units that are defensively fighting on a terrain, terrain type is defined as target, example: num_units_defensive_combats_on@plains
num_units_in_combat number of units current fighting
num_units_in_state number of units controlled by leader in state, state is in target, example: num_units_in_state@123
num_units_offensive_combats number of units in offensive combats
num_units_offensive_combats_against number of units that are offensively fighting against a terrain, terrain type is defined as target, example: num_units_offensive_combats_against@plains
num_units_on_climate number of units that are on an acclimatization required location, acclimatization type is defined in target, example: num_units_on_climate@hot_climate
num_units_with_type number of units with dominant type controlled by leader, dominant type is defined in target, example: num_units_with_type@light_armor
operation_country the country location the operative is assigned. 0 if it is not assigned to a country
operation_state the state location the operative is assigned. 0 if it is not assigned to a state
operation_type returns the operation token the operative is assigned
operative_captor returns the country tag that captured the operative
own_capture_chance_factor the chance this operative has to be captured, taking into account the country it is operating for and the country it is operating against
own_forced_into_hiding_time_factor the time factor applied to the status "forced into hiding". Takes into account the country it is operating for and the country it is operating against
own_harmed_time_factor the time factor applied to the status "harmed". Takes int account the country it is operating for and the country it is operating against
planning_level planning level of the leader
skill_level skill level of the leader
sum_unit_terrain_modifier sum of terrain modifiers of each army's location, terrain type is defined in target, example: sum_unit_terrain_modifier@sickness_chance
unit_modifier value of a modifier stored in unit modifier, modifier token is defined in target, example: unit_modifier@army_attack_factor
unit_ratio_ready_for_plan ratio of units that are ready for plan
attack_skill_level (trigger) Compares attack skill level of a unit leader.
defense_skill_level (trigger) Compares defense skill level of a unit leader.
logistics_skill_level (trigger) Compares logistics skill level of a unit leader.
planning_skill_level (trigger) Compares planning skill level of a unit leader.
skill (trigger) Compare leader skill levels.

Debugging

There are various console commands to debug variables.

All this console command uses selection as a scope. If you select a state (left click a state) it will scope to that. If you select a country (right click a state) it will scope to that country. If you select an army with a leader assigned it will scope to the leader. If nothing is selected, it will scope to player country.

set_var var_name 1
get_var var_name
list_vars
list_vars TUR

First one sets a variable to a value, second one gets result of a variable. 3rd and 4th one lists variables in the scope

There is also print_variables effect/trigger that lets you print every variable (temp or regular) to a file

print_variables = {
    file = log_file
    text = header_text
    append = yes
    print_global = yes
    var_list = { a b c } #optional
}

Footnotes