變量

本頁面所適用的版本可能已經過時,最後更新於1.9


變量[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