变量

本页面所适用的版本可能已经过时,最后更新于1.9
(重定向自Variables


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

有四个作用域能使用变量

  • 国家
  • 省份/州
  • 领导者
  • 全球的

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

访问变量

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

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

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这些代码来切换到不同的作用域(第四个例子),也可以把他们连接起来(第五个例子)。
  • 您可以通过添加事件目标(event_target)来访问一个事件目标的变量 :输入event_target_name 在变量之前 (第六个例子) 或者 您可以做 * same for a global_event_target (第七个例子)

默认情况下变量的值为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

定向变量

你可以定义一个定向于某个作用域的变量,下面是示例:

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

这里我们首先设置作用域为ENG,然后是TUR。当我们执行 set_variable 这一命令时,它会在TUR作用域里设置一个名为 var_name 的变量,不过这个变量会定向于PREV作用域(在这里是指ENG)

同样的你也可以连接起不同的作用域 (像var_name@PREV.PREV) 或者使用国家Tag以及省份ID (var_name@ENG 会和上面代码块产生一样的效果。省份的例子有 var_name@42)。

你只能将变量定向于国家或者省份(将领不可以)

使用事件目标等变量

变量可以在一定程度上替代事件目标。您可以在变量中存储国家TAG或州id,然后以类似的方式使用它们,而不是存储值。例如:

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

本示例将在当前范围内创建一个var_name变量,并将其设置为POL的id(一个唯一的数字代表POL)。之后,您可以使用这个变量将范围切换到POL,就像我们在示例中所做的那样。这里的例子将在波兰范围内设置一个名为var_name_2的变量为125。

您可以像我们在示例中所做的那样,将变量设置为country TAG。您还可以使用像PREV/FROM/ROOT这样的作用域,或者将它们链接在一起。若要将某些内容设置为当前范围,请改用THY。如果要将一个变量设置为特定的状态范围,可以使用set_variable = { var_name = 42.id}(基本上是42范围上的id)

你只能给一个国家或者一个州的范围设置一个变量(没有领导范围,他们就像这个系统的私生子?)

变量和本地化

你可以在本地化中像这样访问变量

[?var_name]

这会将var_name的值在本地化中显示出来

临时变量

临时变量是一种“特性”,允许存贮短暂使用的值,而且将会在代码块执行完毕后被清空,你可以将其用于计算。

c = a * 2 - b / 3

你可以使用临时变量来避免创建过多的变量:

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 }

以下是临时变量可用的效果

  • 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

在前面的示例中,最后一行将c设置为temp1。如果在当前范围内已经有一个名为temp1的实际变量,它将被临时变量所隐藏。所以试着为临时变量使用唯一的名称,否则会很奇怪。

临时变量的一个优点是可以在触发器中使用它们。因为它们的效果只是暂时的, 不会影响游戏,所以应该是安全的。例如在前面的例子中,我们可以用同样的方法计算a*2-b/3,并使用check_variable触发器来检查它是否大于0。

同样,在一些程序中,临时变量不会在触发器和效果之间清除。例如,对于事件的触发及其效果,临时变量保持不变。所以你可以在触发代码中计算一些东西,然后在效果上使用它。这有点奇怪,不过它自有用处。

随机变量

你可以使用一个名为"random"的变量来给特定的变量产生随机值

set_variable = { var_name = random }

这将会给 var_name 赋以0到1之间的值。你也可以在触发中使用它,但它会给你相同的变量。

随机分布还有几种类型:均匀分布、二项分布和泊松分布。第一种类型与默认分布几乎相同,只是在使用它时,可以选择变量的最小值和最大值。例如:

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

第二种类型可以采用前一种类型的最小值和最大值,但与前一种类型相比,更可能采用平均值,注:N=2。

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

最后一个分布使用lambda值随机化变量。使用这种类型的分布时,变量的最大值和平均值之间的差值会随着lambda值的增加而减小。与前面的方法不同,它只能设置变量的最小值。

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

对于AI触发(比如AI_will_do modifiers),使用AI_random代替。

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.

排除故障

许多控制台命令都能用于排除变量上的故障

所有这些控制台命令都使用玩家当前选择的作用域作为其作用域。如果你选择一个省份(左键单击一个省份),它的作用域将是该省份。如果您选择了一个国家(右键单击一个国家),它将作用于该国家。如果你选择了一支有将领指挥的军队,它的作用域将是该将领。如果没有选择任何内容,它的作用域将会是玩家正扮演的国家。

set_var var_name 1
get_var var_name
list_vars
list_vars TUR

第一种方法将变量设置为一个值,第二种方法获取变量的值。第三个和第四个列出了作用域内的变量

下列介绍的是 print_variables 命令,它可以将每个变量(无论是常规变量还是临时变量)输出到文件中:

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

Footnotes