mNo edit summary |
No edit summary |
||
| (2 intermediate revisions by the same user not shown) | |||
| Line 1: | Line 1: | ||
{{version|1.13}}{{需要翻译|译者 = | {{version|1.13}} | ||
{{需要翻译|译者 = 霜泽图书馆}} | |||
'''Scopes''' change the currently-selected entity where the [[effects]] should apply or which is checked by the [[triggers]]. Each one must follow the same formatting of <code>scope = { <contents> }</code>. | |||
When a scope is used as for effects, each effect inside of the scope's block is executed. Conversely, when a scope is used as for triggers, it serves as a [[wp:Logical conjunction|logical conjunction]], requiring every trigger in the scope's block to be met for that scope to evaluate as true. | |||
In addition to serving as blocks for effects or triggers, some scopes can also serve as targets of effects or triggers: e.g. <code>transfer_state_to = ROOT</code> or <code>owns_state = 123</code>.<br/> However, only [[#Dual scopes|some dual scopes]] can be used as a target. For scopes that cannot be used as targets, [[#PREV usage|PREV]], [[Variables]], or [[Event targets]] can be used to get around this limitation. | |||
==Types== | |||
{{Anchor|Scope types}} | |||
Scopes can be thought of as divided into 3 types by purpose: | |||
* Trigger scopes - those that can only be used in trigger blocks, failing when put within an effect block. | |||
* Effect scopes - those that can only be used in effect blocks, failing when put within an trigger block. | |||
* Dual scopes - those that can be put in both trigger and effect blocks without issues. | |||
It is to be noted that trigger or effect scopes cannot ever be used as targets. That is strictly limited to [[#Dual scopes|some dual scopes]]. | |||
Most of the non-dual scopes follow one of these following patterns: | |||
{| class="wikitable" | {| class="wikitable" | ||
|- | |- | ||
!Prefix!!Description | !Prefix!!Description | ||
|- | |- | ||
|all_<name>|| | |all_<name>||Trigger scope, evaluated for each contained scope. Returns false when encountering at least one scope that is false, returns true otherwise. | ||
|- | |- | ||
|any_<name>|| | |any_<name>||Trigger scope, evaluated for each contained scope. Returns true when encountering at least one scope that is true, returns false otherwise. | ||
|- | |- | ||
|every_<name>|| | |every_<name>||Effect scope, executes the effects on each contained scope [[#Scope limits|that meets the limit]] in order. | ||
|- | |- | ||
|random_<name>|| | |random_<name>||Effect scope, executes the effects on a random contained scope [[#Scope limits|that meets the limit]]. | ||
|}Only some scopes that follow this pattern have equivalents with a different pattern. For example, <code>random_owned_controlled_state</code> exists, but <code>every_owned_controlled_state</code> does not. '''Each of these non-dual scopes cannot select a country that does not exist''', with the exception of [[ | |} | ||
Only some scopes that follow this pattern have equivalents with a different pattern. For example, <code>random_owned_controlled_state</code> exists, but <code>every_owned_controlled_state</code> does not. '''Each of these non-dual scopes cannot select a country that does not exist''', with the exception of [[#every_possible_country|every_possible_country]]. | |||
Additionally, scopes can be divided into 6 types by the targets of the scope for which effects are executed or triggers are checked: | Additionally, scopes can be divided into 6 types by the targets of the scope for which effects are executed or triggers are checked: | ||
*Country scopes - Executed for countries. | * Country scopes - Executed for countries. | ||
*State scopes - Executed for states. | * State scopes - Executed for states. | ||
*Character scopes - Executed for characters. Some subsets exist, such as unit leaders and country leaders. | * Character scopes - Executed for characters. Some subsets exist, such as unit leaders and country leaders. | ||
*Division scopes - Executed for divisions. | * Division scopes - Executed for divisions. | ||
*MIO scopes - Executed for [[ | * MIO scopes - Executed for [[military industrial organisation]]s. | ||
*Contract scopes - Executed for purchase contracts. | * Contract scopes - Executed for purchase contracts. | ||
Only [[ | Only [[effects]] or [[triggers]] of the same target type can be used. For example, <code>add_building_construction</code> can only be used in a state scope such as <code>random_owned_controlled_state = { ... }</code>, as you can only construct buildings in states. For countries, [[Effect#add_offsite_building|offsite buildings are used instead]]. | ||
== | |||
Example scope with effects: all contained effects are executed for the scope. This adds 10% {{icon|stability|1}} and 20% {{icon|war support|1}} to the {{flag|Soviet Union}}:<pre>SOV = { | == Examples == | ||
Example scope with effects: all contained effects are executed for the scope. This adds 10% {{icon|stability|1}} and 20% {{icon|war support|1}} to the {{flag|Soviet Union}}: | |||
<pre>SOV = { | |||
add_stability = 0.1 | add_stability = 0.1 | ||
add_war_support = 0.2 | add_war_support = 0.2 | ||
}</pre>Example scope with triggers: all contained triggers must return true for the scope; otherwise, the scope returns false. This requires the state 123 (South-West England) to be owned by the {{flag|United Kingdom}} and controlled by {{flag|Ireland}}:<pre>123 = { | }</pre> | ||
Example scope with triggers: all contained triggers must return true for the scope; otherwise, the scope returns false. This requires the state 123 (South-West England) to be owned by the {{flag|United Kingdom}} and controlled by {{flag|Ireland}}: | |||
<pre>123 = { | |||
is_owned_by = ENG | is_owned_by = ENG | ||
is_controlled_by = IRE | is_controlled_by = IRE | ||
}</pre>Example use of PREV as target for non-targetable scope. Since <code>random_country</code> cannot be used as a target, {{nowrap|1=<code>add_to_faction = random_country</code>}} is not valid syntax; instead, [[ | }</pre> | ||
Example use of PREV as target for non-targetable scope. Since <code>random_country</code> cannot be used as a target, {{nowrap|1=<code>add_to_faction = random_country</code>}} is not valid syntax; instead, [[#PREV usage|PREV]] can be used to get around this limitation. The following example adds random country to ROOT's faction: | |||
<pre>random_country = { | |||
ROOT = { add_to_faction = PREV } | ROOT = { add_to_faction = PREV } | ||
}</pre> | }</pre> | ||
== | |||
{{SVersion|1.13}}Scopes can have additional settings to narrow down the usage. This may change how many and which targets it's able to select or what the tooltip shows. | == Settings == | ||
=== | {{SVersion|1.13}} | ||
{{Anchor|Scope limits| | Scopes can have additional settings to narrow down the usage. This may change how many and which targets it's able to select or what the tooltip shows. | ||
===Limiting=== | |||
{{Anchor|Scope limits|Limits}} | |||
Non-dual scopes that select unit leaders or [[MIO]]s, such as <code>every_navy_leader</code>, by default only include those that are visible to the player, i.e. those unit leaders whose roles do not have an unfulfilled <code>visible = { ... }</code> and those MIOs that do not have an unfulfilled <code>visible = { ... }</code>. By including <code>include_invisible = yes</code>, this can be changed. This will look as such: | |||
<pre>random_army_leader = { | |||
include_invisible = yes | include_invisible = yes | ||
set_nationality = SWE | set_nationality = SWE | ||
}</pre>Within '''only''' effect scopes, <code>limit = { ... }</code> can be used as a trigger block, evaluated for each possible target contained by the scope. In case of the <code>every_<name></code> pattern, this will ensure that the tooltip will function properly, which may not be the case when using <code>if</code> directly. In case of the <code>random_<name></code> pattern, this will remove the possibility of scopes not meeting the triggers being chosen, limiting the selection. For <code>party_leader</code> in specific, the limit must contain [[ | }</pre> | ||
Within '''only''' effect scopes, <code>limit = { ... }</code> can be used as a trigger block, evaluated for each possible target contained by the scope. In case of the <code>every_<name></code> pattern, this will ensure that the tooltip will function properly, which may not be the case when using <code>if</code> directly. In case of the <code>random_<name></code> pattern, this will remove the possibility of scopes not meeting the triggers being chosen, limiting the selection. For <code>party_leader</code> in specific, the limit must contain [[Triggers#has_ideology|has_ideology]], while there are no requirements on other scopes. An example of limiting the selection is the following: | |||
<pre> | |||
every_neighbor_country = { #Targets every neighbor country | every_neighbor_country = { #Targets every neighbor country | ||
limit = { | limit = { | ||
| Line 59: | Line 78: | ||
give_military_access = ROOT #Neighbor countries with more than 5 military factories give military access to the ROOT country | give_military_access = ROOT #Neighbor countries with more than 5 military factories give military access to the ROOT country | ||
} | } | ||
</pre>In case of multiple triggers, <code>limit</code> acts like an <code>AND</code> block, requiring each one to be true. To reiterate, '''this cannot be used within trigger or dual scopes''', only in effect scopes. | </pre> | ||
In case of multiple triggers, <code>limit</code> acts like an <code>AND</code> block, requiring each one to be true. To reiterate, '''this cannot be used within trigger or dual scopes''', only in effect scopes. | |||
For scopes of the <code>every_</code> type, an additional setting for limiting the selection is <code>random_select_amount</code>. In particular, it takes an integer and limits the maximum amount of chosen scopes to that number, picking a random sub-set if exceeded. It is used as such:<pre>every_country = { | For scopes of the <code>every_</code> type, an additional setting for limiting the selection is <code>random_select_amount</code>. In particular, it takes an integer and limits the maximum amount of chosen scopes to that number, picking a random sub-set if exceeded. It is used as such: | ||
<pre>every_country = { | |||
random_select_amount = 3 # Selects 3 random countries | random_select_amount = 3 # Selects 3 random countries | ||
country_event = lottery_win.0 | country_event = lottery_win.0 | ||
}</pre> | }</pre> | ||
By using <code>tooltip = loc_key</code> within any non-dual scope, including of the <code>random_</code> type, the tooltip shown to the player can be changed towards the value of the targeted [[ | === Tooltip === | ||
By default, using a scope of either of the <code>any_</code>, <code>all_</code>, and <code>every_</code> types will show a title specific to that scope in the tooltip, such as <code>Every country:</code> or <code>All neighbor states:</code>. If scope limits are used, then this changes to the list of scopes that fulfill the limit, such as <code>Corsica, Rome, Sardinia:</code>. For countries, the order in which [[Country creation#Country tags|country tags are created]] is used in ordering; for states, the state ID is used. If the tooltip differs depending on the scope where it's executed, such as with if statements, then only the first-selected scope is used in the evaluation. | |||
By using <code>tooltip = loc_key</code> within any non-dual scope, including of the <code>random_</code> type, the tooltip shown to the player can be changed towards the value of the targeted [[localisation]] key in the currently enabled language. This will look like the following: | |||
<pre>any_country = { | |||
hidden_trigger = { | hidden_trigger = { | ||
has_opinion = { target = PREV value > 50 } # Serves as a "limit" hidden from the player. | has_opinion = { target = PREV value > 50 } # Serves as a "limit" hidden from the player. | ||
| Line 74: | Line 97: | ||
tooltip = any_friendly_country_tt # Replaces "Any country" with the localisation key | tooltip = any_friendly_country_tt # Replaces "Any country" with the localisation key | ||
has_war_with = ITA | has_war_with = ITA | ||
}</pre>The localisation key will be defined as such in any localisation file:<syntaxhighlight lang="yaml">l_english: | }</pre> | ||
any_friendly_country_tt: "Any friendly country"</syntaxhighlight>This will appear in the tooltip as such: | The localisation key will be defined as such in any localisation file: | ||
<syntaxhighlight lang="yaml">l_english: | |||
any_friendly_country_tt: "Any friendly country"</syntaxhighlight> | |||
This will appear in the tooltip as such: | |||
{| class="eu4box-inline" style="padding: 1px;" | {| class="eu4box-inline" style="padding: 1px;" | ||
|- | |- | ||
|{{icon|yes}} Any friendly country: | | {{icon|yes}} Any friendly country: | ||
:Is at war with {{flag|Italy}}. | : Is at war with {{flag|Italy}}. | ||
|}In tooltips of the <code>every_</code> type where scope limits are used, by default the tooltip unites it into a single scope, such as <code>Germany, United Kingdom, Soviet Union:</code>. By using <code>display_individual_scopes = yes</code>, this will make each selected scope appear in the tooltip separately. For example:<pre>every_neighbor_country = { | |} | ||
In tooltips of the <code>every_</code> type where scope limits are used, by default the tooltip unites it into a single scope, such as <code>Germany, United Kingdom, Soviet Union:</code>. By using <code>display_individual_scopes = yes</code>, this will make each selected scope appear in the tooltip separately. For example: | |||
<pre>every_neighbor_country = { | |||
limit = { | limit = { | ||
OR = { has_government = communism has_government = fascism } | OR = { has_government = communism has_government = fascism } | ||
| Line 92: | Line 121: | ||
} | } | ||
else = { add_stability = -0.1 } | else = { add_stability = -0.1 } | ||
}</pre>Without displaying individual scopes, this will be shown as one effect block, such as the following: | }</pre> | ||
Without displaying individual scopes, this will be shown as one effect block, such as the following: | |||
{| class="eu4box-inline" style="padding: 1px;" | {| class="eu4box-inline" style="padding: 1px;" | ||
|- | |- | ||
|{{Flag|Germany}}, {{Flag|Soviet Union}}: | | {{Flag|Germany}}, {{Flag|Soviet Union}}: | ||
:Gain Base War Support: {{red|-10%}}. | : Gain Base War Support: {{red|-10%}}. | ||
|}By the nature of tooltips, the if statements for the first country are evaluated and the same tooltip is shown for both countries. This falsely implies that the Soviet Union will have 10% {{icon|war support|1}} removed. However, adding <code>display_individual_scopes = yes</code> changes it to the following: | |} | ||
By the nature of tooltips, the if statements for the first country are evaluated and the same tooltip is shown for both countries. This falsely implies that the Soviet Union will have 10% {{icon|war support|1}} removed. However, adding <code>display_individual_scopes = yes</code> changes it to the following: | |||
{| class="eu4box-inline" style="padding: 1px;" | {| class="eu4box-inline" style="padding: 1px;" | ||
|- | |- | ||
|{{Flag|Germany}}: | | {{Flag|Germany}}: | ||
:Gain Base War Support: {{red|-10%}}. | : Gain Base War Support: {{red|-10%}}.<br/> | ||
{{Flag|Soviet Union}}: | {{Flag|Soviet Union}}: | ||
:Gain Base Stability: {{red|-10%}}. | : Gain Base Stability: {{red|-10%}}. | ||
|} | |} | ||
=== | ===Priority=== | ||
{{Anchor|Scope priority}} Within effect scopes of the <code>random_</code> type, if it is aimed at states, it is possible to prioritize a certain state if possible, by using <code>prioritize</code> as such:<pre>random_owned_controlled_state = { | {{Anchor|Scope priority}} | ||
Within effect scopes of the <code>random_</code> type, if it is aimed at states, it is possible to prioritize a certain state if possible, by using <code>prioritize</code> as such: | |||
<pre>random_owned_controlled_state = { | |||
prioritize = { 123 321 } | prioritize = { 123 321 } | ||
limit = { | limit = { | ||
| Line 112: | Line 145: | ||
} | } | ||
<...> | <...> | ||
}</pre>In this case, the limit will first be evaluated for states 123 and 321. Only if neither of the states 123 or 321 meets the conditions of being owned, controlled, and cored by the country will the random_owned_controlled_state scope be able to select a state that isn't 123 or 321. States 123 and 321, in this case, have the same priority: if both have conditions fulfilled, which one will be picked is random. This only applies at scopes of the <code>random_</code> type which target states, this cannot be done with countries or characters. | }</pre> In this case, the limit will first be evaluated for states 123 and 321. Only if neither of the states 123 or 321 meets the conditions of being owned, controlled, and cored by the country will the random_owned_controlled_state scope be able to select a state that isn't 123 or 321. States 123 and 321, in this case, have the same priority: if both have conditions fulfilled, which one will be picked is random. This only applies at scopes of the <code>random_</code> type which target states, this cannot be done with countries or characters. | ||
== | |||
==Dual scopes== | |||
The following scopes can be used either as effect or trigger scopes; some can also be used as the right side of some effects and triggers as a target. If usage as a target is possible, it's marked within the table. | The following scopes can be used either as effect or trigger scopes; some can also be used as the right side of some effects and triggers as a target. If usage as a target is possible, it's marked within the table. | ||
Several dual scopes may have a scope that varies depending on where it's used, such as variables, which can be set to anything. | Several dual scopes may have a scope that varies depending on where it's used, such as variables, which can be set to anything. | ||
{| class="wikitable sortable mw-collapsible | |||
|+ style="white-space:nowrap;" |Dual scopes: | {| class="wikitable sortable mw-collapsible" style="display: inline-block; padding: 5px" width="100%" | ||
! width="5%" |Name | |+ style="white-space:nowrap;" | Dual scopes:<br/> | ||
! width="10%" |Usage | ! width="5%" | Name | ||
! width="10%" |Target type | ! width="10%" | Usage | ||
! width="23%" |Example | ! width="10%" | Target type | ||
! width="37%" |Description | ! width="23%" | Example | ||
! width="5%" |Usable as target | ! width="37%" | Description | ||
! width="5%" |Version Added | ! width="5%" | Usable as target | ||
|- id="TAG" | ! width="5%" | Version Added | ||
|-id="TAG" | |||
|TAG | |TAG | ||
|Always usable | |Always usable | ||
|Country scope | |Country scope | ||
|<code>SOV = { country_event = my_event.1 }</code> | |<code>SOV = { country_event = my_event.1 }</code> | ||
|The country defined by the tag or tag alias. Tag aliases are defined in {{path|common/country_tag_aliases}}, as a way to refer to a specific country (such as a side in a civil war) in addition to its actual tag. If the country with the exact tag doesn't exist, but a dynamic country originating from the specified tag does, the scope will refer to the dynamic country. | |The country defined by the tag or tag alias. Tag aliases are defined in {{path|common/country_tag_aliases}}, as a way to refer to a specific country (such as a side in a civil war) in addition to its actual tag. If the country with the exact tag doesn't exist, but a dynamic country originating from the specified tag does, the scope will refer to the dynamic country. | ||
|✓ | |✓ | ||
|1.0 | |1.0 | ||
|- id="state_id" | |-id="state_id" | ||
|<state_id> | |<state_id> | ||
|Always usable | |Always usable | ||
| Line 142: | Line 177: | ||
|✓ | |✓ | ||
|1.0 | |1.0 | ||
|- id="character" | |-id="character" | ||
|<character> | |<character> | ||
|not within Character scope | |not within Character scope | ||
|Character scope | |Character scope | ||
| Line 150: | Line 185: | ||
|✓ | |✓ | ||
|1.11 | |1.11 | ||
|- id="mio" | |-id="mio" | ||
|mio:<MIO> | |mio:<MIO> | ||
|Always usable | |Always usable | ||
| Line 158: | Line 193: | ||
|✓ | |✓ | ||
|1.13 | |1.13 | ||
|- id="ROOT" | |-id="ROOT" | ||
|ROOT | |ROOT | ||
|Always usable | |Always usable | ||
| Line 174: | Line 209: | ||
} #GER declares war on ENG (if there is no scope before ENG) | } #GER declares war on ENG (if there is no scope before ENG) | ||
</pre> | </pre> | ||
|Targets the root node of the block, an inherent property of each block. Most commonly, this is the default scope: for example, ROOT [[ | |Targets the root node of the block, an inherent property of each block. Most commonly, this is the default scope: for example, ROOT [[National focus modding|within a national focus]] will always refer to the country doing the focus and ROOT [[Event modding|within a event]] will always refer to the country getting the event. However, some blocks do distinguish between the default scope and ROOT, such as [[Scripted GUI modding|certain scripted GUI contexts]] or [[On actions#La_R.C3.A9sistance|certain on actions]]. If a block doesn't have ROOT defined (such as [[On actions#on_startup|on_startup in on actions]]), then it is impossible to use it. | ||
|✓ | |✓ | ||
|1.0 | |1.0 | ||
|- id="THIS" | |-id="THIS" | ||
|THIS | |THIS | ||
|Always usable | |Always usable | ||
|Depends on usage | |Depends on usage | ||
|<pre>set_temp_variable = { target_country = THIS }</pre> | |<pre>set_temp_variable = { target_country = THIS }</pre> | ||
| Targets the current scope where it's used. For example, when used in [[ | |Targets the current scope where it's used. For example, when used in [[#every_state|every_state]], it will refer to the state that's currently being evaluated. Primarily useful for [[variables]] (as in the example, where omitting it wouldn't work) or for [[Localisation#Namespaces|built-in localisation commands]], where some scope must be specified. More rarely, this may help with scope manipulation when using [[#PREV|PREV]]. Since omitting it makes no difference in how the code gets interpreted, there is little to no usage outside of these cases. | ||
|✓ | |✓ | ||
|1.0 | |1.0 | ||
|- id="PREV" | |-id="PREV" | ||
|PREV | |PREV | ||
|Always usable | |Always usable | ||
|Depends on usage | |Depends on usage | ||
|<pre> | |<pre> | ||
| Line 201: | Line 236: | ||
} #Germany declares war on random_country | } #Germany declares war on random_country | ||
</pre> | </pre> | ||
| Targets the scope that the current scope is contained in. Can have additional applications where the assumed default scope differs from the ROOT, such as in state events or some on_actions. Can be chained indefinitely as PREV.PREV. '''Commonly results in broken-looking tooltips''': what's shown to the player doesn't always correlate with reality. | |Targets the scope that the current scope is contained in. Can have additional applications where the assumed default scope differs from the ROOT, such as in state events or some on_actions. Can be chained indefinitely as PREV.PREV. '''Commonly results in broken-looking tooltips''': what's shown to the player doesn't always correlate with reality.<br/> | ||
See also: [[Scopes#PREV usage|PREV usage]]. | |||
|✓ | |||
See also: [[ | |||
| | |||
|1.0 | |1.0 | ||
|- id="FROM" | |-id="FROM" | ||
|FROM | |FROM | ||
|Always usable | |Always usable | ||
| Depends on usage | |Depends on usage | ||
| <pre> | |<pre> | ||
declare_war_on = { | declare_war_on = { | ||
target = FROM | target = FROM | ||
| Line 220: | Line 253: | ||
load_oob = defend_ourselves | load_oob = defend_ourselves | ||
} | } | ||
</pre> | </pre> | ||
|Can be chained indefinitely as FROM.FROM. Used to target various hardcoded scopes inherent to the block, often a secondary scope in addition to ROOT. For example: | |Can be chained indefinitely as FROM.FROM. Used to target various hardcoded scopes inherent to the block, often a secondary scope in addition to ROOT. For example:<br/> | ||
In [[event modding|events]], this refers to the country that sent the event (i.e. if the event was fired [[Event modding#Effect|using an effect]], then it's the ROOT scope where it was fired).<br/> | |||
In [[decision modding#targeted decisions|targeted decisions]] or [[Conditions#Scripted triggers|diplomacy scripted triggers]], this refers to the scope that is targeted.<br/> | |||
In [[ | |||
In [[ | |||
|✓ | |✓ | ||
|1.0 | |1.0 | ||
|- id="overlord" | |-id="overlord" | ||
|overlord | |overlord | ||
|Within country scope only | |Within country scope only | ||
|Country scope | |Country scope | ||
|<code>overlord = { … }</code> | |<code>overlord = { … }</code> | ||
|The overlord of the country if it is a subject. [[ | |The overlord of the country if it is a subject. [[#Invalid event target|Subject to the 'invalid event target' error.]] | ||
|X | |X | ||
|1.3 | |1.3 | ||
|- id="faction_leader" | |-id="faction_leader" | ||
|faction_leader | |faction_leader | ||
|Within country scope only | |Within country scope only | ||
|Country scope | |Country scope | ||
|<code>faction_leader = { add_to_faction = FROM }</code> | |<code>faction_leader = { add_to_faction = FROM }</code> | ||
|Faction leader of the faction the country is a part of. [[ | |Faction leader of the faction the country is a part of. [[#Invalid event target|Subject to the 'invalid event target' error.]] | ||
|X | |X | ||
|1.10.1 | |1.10.1 | ||
|- id="owner" | |-id="owner" | ||
|owner | |owner | ||
|Within state, character, or combatant scope only | |Within state, character, or combatant scope only | ||
|Country scope | |Country scope | ||
|<code>owner = { add_ideas = owns_this_state }</code> | |<code>owner = { add_ideas = owns_this_state }</code> | ||
|In state scope, the country that owns the state. In {{hover|Used in triggers within abilities, combat tactics, and unit leader traits.|combatant scope}}, the country that owns the divisions. In character scope, the country that has recruited the character. [[ | |In state scope, the country that owns the state. In {{hover|Used in triggers within abilities, combat tactics, and unit leader traits.|combatant scope}}, the country that owns the divisions. In character scope, the country that has recruited the character. [[#Invalid event target|Subject to the 'invalid event target' error]] when used for a state. | ||
|X | |X | ||
|1.0 | |1.0 | ||
|- id="controller" | |-id="controller" | ||
|controller | |controller | ||
|Within state scope only | |Within state scope only | ||
| Line 266: | Line 296: | ||
} | } | ||
}</pre> | }</pre> | ||
|The controller of the current state. [[ | |The controller of the current state. [[#Invalid event target|Subject to the 'invalid event target' error.]] | ||
|X | |X | ||
|1.0 | |1.0 | ||
|- id="capital_scope" | |-id="capital_scope" | ||
|capital_scope | |capital_scope | ||
|Within country scope only | |Within country scope only | ||
|State scope | |State scope | ||
|<code>capital_scope = { … }</code> | |<code>capital_scope = { … }</code> | ||
|The state where the capital of the current country is located in. [[ | |The state where the capital of the current country is located in. [[#Invalid event target|Subject to the 'invalid event target' error]] in rare cases. | ||
|X | |X | ||
|1.0 | |1.0 | ||
|- id="event_target" | |-id="event_target" | ||
|event_target:<event_target_key> | |event_target:<event_target_key> | ||
|Always usable | |Always usable | ||
|Depends on usage | |Depends on usage | ||
|<code>event_target:my_event_target = { … }</code> | |<code>event_target:my_event_target = { … }</code> | ||
|Saved [[ | |Saved [[Data structures#Event targets|event target or global event target]], with no space after the colon. [[#Invalid event target|Subject to the 'invalid event target' error.]] | ||
|✓ | |✓ | ||
|1.0 | |1.0 | ||
|- id="var" | |-id="var" | ||
|var:<variable> | |var:<variable> | ||
|Always usable | |Always usable | ||
|Depends on usage | |Depends on usage | ||
|<code>var:my_variable = { … }</code><code>add_to_faction = my_variable</code> or | |<code>var:my_variable = { … }</code><br><code>add_to_faction = my_variable</code> or <br><code>add_to_faction = var:my_variable</code> | ||
<code>add_to_faction = var:my_variable</code> | |[[Variable]] set to a scope.<br/> | ||
|[[ | |||
When used as a target rather than a scope, the <code>var:</code> can be omitted in most cases. | When used as a target rather than a scope, the <code>var:</code> can be omitted in most cases. | ||
|✓ | |✓ | ||
|1.5 | |1.5 | ||
|} | |} | ||
<noinclude> | |||
=== Invalid event target === | |||
{{See also|Event targets}} | |||
In regards to some dual scopes, a possible logged error to get while using them is "Invalid event target", as in <code>common/national_focus/generic.txt:690: controller: invalid event target: controller</code>, while the scope being used is not necessarily an event target.<br/> | |||
This refers to the scope not having any defined target in the context that it is used, i.e. it is impossible to select any single target when it is used. In case of <code>controller = { ... }</code> as in the example, this means that the scope is checked or executed in a state that isn't controlled by any country. Such states are rather unstable and can cause crashes easily (such as if evaluated for an air mission by AI or if doing almost any effect on them), so if this happens for <code>controller</code> or <code>owner</code>, then this must be fixed only by making sure that every state has an owner or controller. | This refers to the scope not having any defined target in the context that it is used, i.e. it is impossible to select any single target when it is used. In case of <code>controller = { ... }</code> as in the example, this means that the scope is checked or executed in a state that isn't controlled by any country. Such states are rather unstable and can cause crashes easily (such as if evaluated for an air mission by AI or if doing almost any effect on them), so if this happens for <code>controller</code> or <code>owner</code>, then this must be fixed only by making sure that every state has an owner or controller. | ||
In practice, this gets skipped over entirely when evaluating the effects or triggers: none of the effects would be executed; as a trigger it'll not come up as either true or false. However, since this can be checked every tick, leaving it as is can result in cluttering the error log. To avoid this, it's possible to use the if statement in [[ | In practice, this gets skipped over entirely when evaluating the effects or triggers: none of the effects would be executed; as a trigger it'll not come up as either true or false. However, since this can be checked every tick, leaving it as is can result in cluttering the error log. To avoid this, it's possible to use the if statement in [[Effect#If statements|effects]] or [[Triggers#if|triggers]] in such a manner that the dual scope would only be checked if the conditions for it existing are fulfilled, such as by checking that the country is indeed a subject before checking the overlord. An example of that being done is as such: | ||
<pre>if = { | |||
limit = { | limit = { | ||
is_subject = yes | is_subject = yes | ||
| Line 310: | Line 340: | ||
country_event = example.0 | country_event = example.0 | ||
} | } | ||
}</pre>While this has identical effects regardless of whether the country is independent or is a subject, this doesn't access the <code>overlord</code> scope for an independent country. | }</pre> | ||
While this has identical effects regardless of whether the country is independent or is a subject, this doesn't access the <code>overlord</code> scope for an independent country.</noinclude> | |||
==Trigger scopes== | ==Trigger scopes== | ||
These can only be used as [[ | These can only be used as [[triggers]]; trying to use them as [[effects]] will result in nothing happening. | ||
{| class="wikitable sortable mw-collapsible | {{SVersion|1.13}} | ||
|+ style="white-space:nowrap;" |Trigger scopes: | {| class="wikitable sortable mw-collapsible" style="display: inline-block; padding: 5px" width="100%" | ||
! width="10%" |Name | |+ style="white-space:nowrap;" | Trigger scopes:<br/> | ||
! width="15%" |Usage | ! width="10%" | Name | ||
! width="10%" |Target type | ! width="15%" | Usage | ||
! width="23%" |Example | ! width="10%" | Target type | ||
! width="37%" |Description | ! width="23%" | Example | ||
! width="5%" |Version Added | ! width="37%" | Description | ||
|- id="all_country" | ! width="5%" | Version Added | ||
|-id="all_country" | |||
|all_country | |all_country | ||
|Always usable | |Always usable | ||
| Line 328: | Line 361: | ||
|Checks if all countries meet the triggers. | |Checks if all countries meet the triggers. | ||
|1.0 | |1.0 | ||
|- id="any_country" | |-id="any_country" | ||
|any_country | |any_country | ||
|Always usable | |Always usable | ||
| Line 335: | Line 368: | ||
|Checks if any country meets the triggers. | |Checks if any country meets the triggers. | ||
|1.0 | |1.0 | ||
|- id="all_other_country" | |-id="all_other_country" | ||
|all_other_country | |all_other_country | ||
|Within country scope only | |Within country scope only | ||
| Line 342: | Line 375: | ||
|Checks if all countries other than the one where this scope is located meet the triggers. | |Checks if all countries other than the one where this scope is located meet the triggers. | ||
|1.0 | |1.0 | ||
|- id="any_other_country" | |-id="any_other_country" | ||
|any_other_country | |any_other_country | ||
|Within country scope only | |Within country scope only | ||
| Line 349: | Line 382: | ||
|Checks if any country other than the one where this scope is located meets the triggers. | |Checks if any country other than the one where this scope is located meets the triggers. | ||
|1.0 | |1.0 | ||
|- id="all_country_with_original_tag" | |-id="all_country_with_original_tag" | ||
|all_country_with_original_tag | |all_country_with_original_tag | ||
|Always usable | |Always usable | ||
| Line 359: | Line 392: | ||
|Checks if all countries originating from the specified country, including the dynamic countries created for civil wars and other purposes, meet the triggers. <code>original_tag_to_check = TAG</code> is used to specify the original tag. | |Checks if all countries originating from the specified country, including the dynamic countries created for civil wars and other purposes, meet the triggers. <code>original_tag_to_check = TAG</code> is used to specify the original tag. | ||
|1.9 | |1.9 | ||
|- id="any_country_with_original_tag" | |-id="any_country_with_original_tag" | ||
|any_country_with_original_tag | |any_country_with_original_tag | ||
|Always usable | |Always usable | ||
| Line 369: | Line 402: | ||
|Checks if any country originating from the specified country, including the dynamic countries created for civil wars and other purposes, meets the triggers. <code>original_tag_to_check = TAG</code> is used to specify the original tag. | |Checks if any country originating from the specified country, including the dynamic countries created for civil wars and other purposes, meets the triggers. <code>original_tag_to_check = TAG</code> is used to specify the original tag. | ||
|1.9 | |1.9 | ||
|- id="all_neighbor_country" | |-id="all_neighbor_country" | ||
|all_neighbor_country | |all_neighbor_country | ||
|Within country scope only | |Within country scope only | ||
| Line 376: | Line 409: | ||
|Checks if all countries that border the one where this scope is located meet the triggers. | |Checks if all countries that border the one where this scope is located meet the triggers. | ||
|1.0 | |1.0 | ||
|- id="any_neighbor_country" | |-id="any_neighbor_country" | ||
|any_neighbor_country | |any_neighbor_country | ||
|Within country scope only | |Within country scope only | ||
| Line 383: | Line 416: | ||
|Checks if any country that borders the one where this scope is located meets the triggers. | |Checks if any country that borders the one where this scope is located meets the triggers. | ||
|1.0 | |1.0 | ||
|- id="any_home_area_neighbor_country" | |-id="any_home_area_neighbor_country" | ||
|any_home_area_neighbor_country | |any_home_area_neighbor_country | ||
|Within country scope only | |Within country scope only | ||
| Line 390: | Line 423: | ||
|Checks if any country that borders the one where this scope is located, as well as being in its home area - meaning a direct land connection between the capitals of countries - meets the triggers. | |Checks if any country that borders the one where this scope is located, as well as being in its home area - meaning a direct land connection between the capitals of countries - meets the triggers. | ||
|1.0 | |1.0 | ||
|- id="all_guaranteed_country" | |-id="all_guaranteed_country" | ||
|all_guaranteed_country | |all_guaranteed_country | ||
|Within country scope only | |Within country scope only | ||
| Line 397: | Line 430: | ||
|Checks if all countries that are guaranteed by the one where this scope is located meet the triggers. | |Checks if all countries that are guaranteed by the one where this scope is located meet the triggers. | ||
|1.9 | |1.9 | ||
|- id="any_guaranteed_country" | |-id="any_guaranteed_country" | ||
|any_guaranteed_country | |any_guaranteed_country | ||
|Within country scope only | |Within country scope only | ||
| Line 404: | Line 437: | ||
|Checks if any country that is guaranteed by the one where this scope is located meets the triggers. | |Checks if any country that is guaranteed by the one where this scope is located meets the triggers. | ||
|1.9 | |1.9 | ||
|- id="all_allied_country" | |-id="all_allied_country" | ||
|all_allied_country | |all_allied_country | ||
|Within country scope only | |Within country scope only | ||
| Line 411: | Line 444: | ||
|Checks if all countries that are allied with the one where this scope is located - meaning that they are either a subject of the country, its overlord, or that they share a faction - meet the triggers. Does not include the country itself. | |Checks if all countries that are allied with the one where this scope is located - meaning that they are either a subject of the country, its overlord, or that they share a faction - meet the triggers. Does not include the country itself. | ||
|1.9 | |1.9 | ||
|- id="any_allied_country" | |-id="any_allied_country" | ||
|any_allied_country | |any_allied_country | ||
|Within country scope only | |Within country scope only | ||
| Line 418: | Line 451: | ||
|Checks if any country that is allied with the one where this scope is located - meaning that they are either a subject of the country, its overlord, or that they share a faction - meets the triggers. Does not include the country itself. | |Checks if any country that is allied with the one where this scope is located - meaning that they are either a subject of the country, its overlord, or that they share a faction - meets the triggers. Does not include the country itself. | ||
|1.9 | |1.9 | ||
|- id="all_occupied_country" | |-id="all_occupied_country" | ||
|all_occupied_country | |all_occupied_country | ||
|Within country scope only | |Within country scope only | ||
| Line 425: | Line 458: | ||
|Checks if all countries that are occupied by the one where this scope is located - meaning that the occupied country has core states controlled by the occupier country - meet the triggers. | |Checks if all countries that are occupied by the one where this scope is located - meaning that the occupied country has core states controlled by the occupier country - meet the triggers. | ||
|1.9 | |1.9 | ||
|- id="any_occupied_country" | |-id="any_occupied_country" | ||
|any_occupied_country | |any_occupied_country | ||
|Within country scope only | |Within country scope only | ||
| Line 432: | Line 465: | ||
|Checks if any country that is occupied by the one where this scope is located - meaning that the occupied country has core states controlled by the occupier country - meets the triggers. | |Checks if any country that is occupied by the one where this scope is located - meaning that the occupied country has core states controlled by the occupier country - meets the triggers. | ||
|1.9 | |1.9 | ||
|- id="all_enemy_country" | |-id="all_enemy_country" | ||
|all_enemy_country | |all_enemy_country | ||
|Within country scope only | |Within country scope only | ||
| Line 439: | Line 472: | ||
|Checks if all countries that are at war with the one where this scope is located meet the triggers. | |Checks if all countries that are at war with the one where this scope is located meet the triggers. | ||
|1.9 | |1.9 | ||
|- id="any_enemy_country" | |-id="any_enemy_country" | ||
|any_enemy_country | |any_enemy_country | ||
|Within country scope only | |Within country scope only | ||
| Line 446: | Line 479: | ||
|Checks if any country that are at war with the one where this scope is located meets the triggers. | |Checks if any country that are at war with the one where this scope is located meets the triggers. | ||
|1.9 | |1.9 | ||
|- id="all_subject_countries" | |-id="all_subject_countries" | ||
|all_subject_countries | |all_subject_countries | ||
|Within country scope only | |Within country scope only | ||
| Line 453: | Line 486: | ||
|Checks if all countries that are a subject of the one where this scope is located meet the triggers. Notice the plural spelling in the scope. | |Checks if all countries that are a subject of the one where this scope is located meet the triggers. Notice the plural spelling in the scope. | ||
|1.11 | |1.11 | ||
|- id="any_subject_country" | |-id="any_subject_country" | ||
|any_subject_country | |any_subject_country | ||
|Within country scope only | |Within country scope only | ||
| Line 460: | Line 493: | ||
|Checks if any country that is a subject of the one where this scope is located meets the triggers. | |Checks if any country that is a subject of the one where this scope is located meets the triggers. | ||
|1.11 | |1.11 | ||
|- id="any_country_with_core" | |-id="any_country_with_core" | ||
|any_country_with_core | |any_country_with_core | ||
|Within state scope only | |Within state scope only | ||
| Line 467: | Line 500: | ||
|Checks if any country that has the current scope as a core state meets the triggers. '''Does not have an equivalent for other effect/trigger scope types.''' | |Checks if any country that has the current scope as a core state meets the triggers. '''Does not have an equivalent for other effect/trigger scope types.''' | ||
|1.12 | |1.12 | ||
|- id="all_state" | |-id="all_state" | ||
|all_state | |all_state | ||
|Always usable | |Always usable | ||
| Line 474: | Line 507: | ||
|Check if all states meet the triggers. | |Check if all states meet the triggers. | ||
|1.0 | |1.0 | ||
|- id="any_state" | |-id="any_state" | ||
|any_state | |any_state | ||
|Always usable | |Always usable | ||
| Line 481: | Line 514: | ||
|Check if any state meets the triggers. | |Check if any state meets the triggers. | ||
|1.0 | |1.0 | ||
|- id="all_neighbor_state" | |-id="all_neighbor_state" | ||
|all_neighbor_state | |all_neighbor_state | ||
|Within state scope only | |Within state scope only | ||
| Line 488: | Line 521: | ||
|Check if all states that are neighbour to the one where this scope is located meet the triggers. | |Check if all states that are neighbour to the one where this scope is located meet the triggers. | ||
|1.0 | |1.0 | ||
|- id="any_neighbor_state" | |-id="any_neighbor_state" | ||
|any_neighbor_state | |any_neighbor_state | ||
|Within state scope only | |Within state scope only | ||
| Line 495: | Line 528: | ||
|Check if any state that is neighbour to the one where this scope is located meets the triggers. | |Check if any state that is neighbour to the one where this scope is located meets the triggers. | ||
|1.0 | |1.0 | ||
|- id="all_owned_state" | |-id="all_owned_state" | ||
|all_owned_state | |all_owned_state | ||
|Within country scope only | |Within country scope only | ||
| Line 502: | Line 535: | ||
|Check if all states that are owned by the country where this scope is located meet the triggers. | |Check if all states that are owned by the country where this scope is located meet the triggers. | ||
|1.0 | |1.0 | ||
|- id="any_owned_state" | |-id="any_owned_state" | ||
|any_owned_state | |any_owned_state | ||
|Within country scope only | |Within country scope only | ||
| Line 509: | Line 542: | ||
|Check if any state that is owned by the country where this scope is located meets the triggers. | |Check if any state that is owned by the country where this scope is located meets the triggers. | ||
|1.0 | |1.0 | ||
|- id="all_core_state" | |-id="all_core_state" | ||
|all_core_state | |all_core_state | ||
|Within country scope only | |Within country scope only | ||
| Line 516: | Line 549: | ||
|Check if any state that is cored by the country where this scope is located meets the triggers. | |Check if any state that is cored by the country where this scope is located meets the triggers. | ||
|1.11 | |1.11 | ||
|- id="any_core_state" | |-id="any_core_state" | ||
|any_core_state | |any_core_state | ||
|Within country scope only | |Within country scope only | ||
| Line 523: | Line 556: | ||
|Check if all states that are cored by the country where this scope is located meet the triggers. | |Check if all states that are cored by the country where this scope is located meet the triggers. | ||
|1.11 | |1.11 | ||
|- id="all_controlled_state" | |-id="all_controlled_state" | ||
|all_controlled_state | |all_controlled_state | ||
|Within country scope only | |Within country scope only | ||
| Line 530: | Line 563: | ||
|Check if all states that are controlled by the country where this scope is located meet the triggers. | |Check if all states that are controlled by the country where this scope is located meet the triggers. | ||
|1.9 | |1.9 | ||
|- id="any_controlled_state" | |-id="any_controlled_state" | ||
|any_controlled_state | |any_controlled_state | ||
|Within country scope only | |Within country scope only | ||
| Line 537: | Line 570: | ||
|Check if any state that is controlled by the country where this scope is located meets the triggers. | |Check if any state that is controlled by the country where this scope is located meets the triggers. | ||
|1.9 | |1.9 | ||
|- id="all_unit_leader" | |-id="all_unit_leader" | ||
|all_unit_leader | |all_unit_leader | ||
|Within country scope only | |Within country scope only | ||
| Line 544: | Line 577: | ||
|Checks if all unit leaders (corps commanders, field marshals, admirals) that are employed by the country where this scope is located meet the triggers. | |Checks if all unit leaders (corps commanders, field marshals, admirals) that are employed by the country where this scope is located meet the triggers. | ||
|1.5 | |1.5 | ||
|- id="any_unit_leader" | |-id="any_unit_leader" | ||
|any_unit_leader | |any_unit_leader | ||
|Within country scope only | |Within country scope only | ||
| Line 551: | Line 584: | ||
|Checks if any unit leader (corps commander, field marshal, admiral) that is employed by the country where this scope is located meets the triggers. | |Checks if any unit leader (corps commander, field marshal, admiral) that is employed by the country where this scope is located meets the triggers. | ||
|1.5 | |1.5 | ||
|- id="all_army_leader" | |-id="all_army_leader" | ||
|all_army_leader | |all_army_leader | ||
|Within country scope only | |Within country scope only | ||
| Line 558: | Line 591: | ||
|Checks if all army leaders that are employed by the country where this scope is located meet the triggers. | |Checks if all army leaders that are employed by the country where this scope is located meet the triggers. | ||
|1.5 | |1.5 | ||
|- id="any_army_leader" | |-id="any_army_leader" | ||
|any_army_leader | |any_army_leader | ||
|Within country scope only | |Within country scope only | ||
| Line 565: | Line 598: | ||
|Checks if any army leader that is employed by the country where this scope is located meets the triggers. | |Checks if any army leader that is employed by the country where this scope is located meets the triggers. | ||
|1.5 | |1.5 | ||
|- id="all_navy_leader" | |-id="all_navy_leader" | ||
|all_navy_leader | |all_navy_leader | ||
|Within country scope only | |Within country scope only | ||
| Line 572: | Line 605: | ||
|Checks if all navy leaders that are employed by the country where this scope is located meet the triggers. | |Checks if all navy leaders that are employed by the country where this scope is located meet the triggers. | ||
|1.5 | |1.5 | ||
|- id="any_navy_leader" | |-id="any_navy_leader" | ||
|any_navy_leader | |any_navy_leader | ||
|Within country scope only | |Within country scope only | ||
| Line 579: | Line 612: | ||
|Checks if any navy leader that is employed by the country where this scope is located meets the triggers. | |Checks if any navy leader that is employed by the country where this scope is located meets the triggers. | ||
|1.5 | |1.5 | ||
|- id="all_operative_leader" | |-id="all_operative_leader" | ||
|all_operative_leader | |all_operative_leader | ||
|Within country scope or operations only | |Within country scope or operations only | ||
| Line 586: | Line 619: | ||
|Checks if all operatives that are employed by the country where this scope is located meet the triggers. | |Checks if all operatives that are employed by the country where this scope is located meet the triggers. | ||
|1.9 | |1.9 | ||
|- id="any_operative_leader" | |-id="any_operative_leader" | ||
|any_operative_leader | |any_operative_leader | ||
|Within country scope or operations only | |Within country scope or operations only | ||
| Line 593: | Line 626: | ||
|Checks if any operative that is employed by the country where this scope is located meets the triggers. | |Checks if any operative that is employed by the country where this scope is located meets the triggers. | ||
|1.9 | |1.9 | ||
|- id="all_character" | |-id="all_character" | ||
|all_character | |all_character | ||
|Within country scope only | |Within country scope only | ||
| Line 600: | Line 633: | ||
|Checks if all characters that are recruited by the country where this scope is located meet the triggers. | |Checks if all characters that are recruited by the country where this scope is located meet the triggers. | ||
|1.11 | |1.11 | ||
|- id="any_character" | |-id="any_character" | ||
|any_character | |any_character | ||
|Within country scope only | |Within country scope only | ||
| Line 607: | Line 640: | ||
|Checks if any character that is recruited by the country where this scope is located meets the triggers. | |Checks if any character that is recruited by the country where this scope is located meets the triggers. | ||
|1.11 | |1.11 | ||
|- id="any_country_division" | |-id="any_country_division" | ||
|any_country_division | |any_country_division | ||
|Within country scope only | |Within country scope only | ||
| Line 614: | Line 647: | ||
|Checks if any division owned by the current country meets the triggers. | |Checks if any division owned by the current country meets the triggers. | ||
|1.12 | |1.12 | ||
|- id="any_state_division" | |-id="any_state_division" | ||
|any_state_division | |any_state_division | ||
|Within state scope only | |Within state scope only | ||
| Line 621: | Line 654: | ||
|Checks if any division within the current state meets the triggers. | |Checks if any division within the current state meets the triggers. | ||
|1.12 | |1.12 | ||
|- id="all_military_industrial_organization" | |-id="all_military_industrial_organization" | ||
|all_military_industrial_organization | |all_military_industrial_organization | ||
|Within country scope only | |Within country scope only | ||
| Line 628: | Line 661: | ||
|Checks if all MIOs within the current country meet the conditions. | |Checks if all MIOs within the current country meet the conditions. | ||
|1.13 | |1.13 | ||
|- id="any_military_industrial_organization" | |-id="any_military_industrial_organization" | ||
|any_military_industrial_organization | |any_military_industrial_organization | ||
|Within country scope only | |Within country scope only | ||
| Line 635: | Line 668: | ||
|Checks if any MIO within the current country meets the conditions. | |Checks if any MIO within the current country meets the conditions. | ||
|1.13 | |1.13 | ||
|- id="all_purchase_contract" | |-id="all_purchase_contract" | ||
|all_purchase_contract | |all_purchase_contract | ||
|Within country scope only | |Within country scope only | ||
| Line 642: | Line 675: | ||
|Checks if all purchase contracts within the current country meet the conditions. | |Checks if all purchase contracts within the current country meet the conditions. | ||
|1.13 | |1.13 | ||
|- id="any_purchase_contract" | |-id="any_purchase_contract" | ||
|any_purchase_contract | |any_purchase_contract | ||
|Within country scope only | |Within country scope only | ||
| Line 651: | Line 684: | ||
|} | |} | ||
==Effect scopes== | ==Effect scopes== | ||
These can only be used as [[ | These can only be used as [[effects]]; trying to use them as [[triggers]] will result in nothing happening. | ||
{| class="wikitable sortable mw-collapsible | {{SVersion|1.13}} | ||
|+ style="white-space:nowrap;" |Effect scopes: | {| class="wikitable sortable mw-collapsible" style="display: inline-block; padding: 5px" width="100%" | ||
! width="10%" |Name | |+ style="white-space:nowrap;" | Effect scopes:<br/> | ||
! width="15%" |Usage | ! width="10%" | Name | ||
! width="10%" |Target type | ! width="15%" | Usage | ||
! width="23%" |Example | ! width="10%" | Target type | ||
! width="37%" |Description | ! width="23%" | Example | ||
! width="5%" |Version Added | ! width="37%" | Description | ||
|- id="every_possible_country" | ! width="5%" | Version Added | ||
|-id="every_possible_country" | |||
|every_possible_country | |every_possible_country | ||
|Always usable | |Always usable | ||
| Line 667: | Line 701: | ||
|Executes children effects on every country that meets the limit, including those that do not exist. | |Executes children effects on every country that meets the limit, including those that do not exist. | ||
|1.11 | |1.11 | ||
|- id="every_country" | |-id="every_country" | ||
|every_country | |every_country | ||
|Always usable | |Always usable | ||
| Line 674: | Line 708: | ||
|Executes contained effects on every country that meets the limit. | |Executes contained effects on every country that meets the limit. | ||
|1.0 | |1.0 | ||
|- id="random_country" | |-id="random_country" | ||
|random_country | |random_country | ||
|Always usable | |Always usable | ||
| Line 681: | Line 715: | ||
|Executes contained effects on a random country that meets the limit. | |Executes contained effects on a random country that meets the limit. | ||
|1.0 | |1.0 | ||
|- id="every_other_country" | |-id="every_other_country" | ||
|every_other_country | |every_other_country | ||
|Within country scope only | |Within country scope only | ||
| Line 688: | Line 722: | ||
|Executes contained effects on every country that meets the limit and is not the same country as the one this is contained in. | |Executes contained effects on every country that meets the limit and is not the same country as the one this is contained in. | ||
|1.0 | |1.0 | ||
|- id="random_other_country" | |-id="random_other_country" | ||
|random_other_country | |random_other_country | ||
|Within country scope only | |Within country scope only | ||
| Line 695: | Line 729: | ||
|Executes contained effects on a random country that meets the limit and is not the same country as the one this is contained in. | |Executes contained effects on a random country that meets the limit and is not the same country as the one this is contained in. | ||
|1.0 | |1.0 | ||
|- id="every_country_with_original_tag" | |-id="every_country_with_original_tag" | ||
|every_country_with_original_tag | |every_country_with_original_tag | ||
|Always usable | |Always usable | ||
| Line 705: | Line 739: | ||
|Executes contained effects on every country that meets the limit and has the specified original tag. | |Executes contained effects on every country that meets the limit and has the specified original tag. | ||
|1.9 | |1.9 | ||
|- id="random_country_with_original_tag" | |-id="random_country_with_original_tag" | ||
|random_country_with_original_tag | |random_country_with_original_tag | ||
|Always usable | |Always usable | ||
| Line 714: | Line 748: | ||
}</pre> | }</pre> | ||
|Executes contained effects on a random country that meets the limit and has the specified original tag. | |Executes contained effects on a random country that meets the limit and has the specified original tag. | ||
|- id="every_neighbor_country" | |-id="every_neighbor_country" | ||
|every_neighbor_country | |every_neighbor_country | ||
|Within country scope only | |Within country scope only | ||
| Line 721: | Line 755: | ||
|Executes contained effects on every country that meets the limit and borders the country this is contained in. | |Executes contained effects on every country that meets the limit and borders the country this is contained in. | ||
|1.0 | |1.0 | ||
|- id="random_neighbor_country" | |-id="random_neighbor_country" | ||
|random_neighbor_country | |random_neighbor_country | ||
|Within country scope only | |Within country scope only | ||
| Line 728: | Line 762: | ||
|Executes contained effects on a random country that meets the limit and borders the country this is contained in. | |Executes contained effects on a random country that meets the limit and borders the country this is contained in. | ||
|1.0 | |1.0 | ||
|- id="every_occupied_country" | |-id="every_occupied_country" | ||
|every_occupied_country | |every_occupied_country | ||
|Within country scope only | |Within country scope only | ||
| Line 735: | Line 769: | ||
|Executes contained effects on every country that meets the limit and has any core states controlled by the country this is contained in. | |Executes contained effects on every country that meets the limit and has any core states controlled by the country this is contained in. | ||
|1.9 | |1.9 | ||
|- id="random_occupied_country" | |-id="random_occupied_country" | ||
|random_occupied_country | |random_occupied_country | ||
|Within country scope only | |Within country scope only | ||
| Line 742: | Line 776: | ||
|Executes contained effects on a random country that meets the limit and has any core states controlled by the country this is contained in. | |Executes contained effects on a random country that meets the limit and has any core states controlled by the country this is contained in. | ||
|1.9 | |1.9 | ||
|- id="every_enemy_country" | |-id="every_enemy_country" | ||
|every_enemy_country | |every_enemy_country | ||
|Within country scope only | |Within country scope only | ||
| Line 749: | Line 783: | ||
|Executes contained effects on every country that meets the limit and is at war with the country this is contained in. | |Executes contained effects on every country that meets the limit and is at war with the country this is contained in. | ||
|1.0 | |1.0 | ||
|- id="random_enemy_country" | |-id="random_enemy_country" | ||
|random_enemy_country | |random_enemy_country | ||
|Within country scope only | |Within country scope only | ||
| Line 756: | Line 790: | ||
|Executes contained effects on a random country that meets the limit and is at war with the country this is contained in. | |Executes contained effects on a random country that meets the limit and is at war with the country this is contained in. | ||
|1.0 | |1.0 | ||
|- id="every_subject_country" | |-id="every_subject_country" | ||
|every_subject_country | |every_subject_country | ||
|Within country scope only | |Within country scope only | ||
| Line 763: | Line 797: | ||
|Executes contained effects on every country that meets the limit and is a subject of the country this is contained in. | |Executes contained effects on every country that meets the limit and is a subject of the country this is contained in. | ||
|1.11 | |1.11 | ||
|- id="random_subject_country" | |-id="random_subject_country" | ||
|random_subject_country | |random_subject_country | ||
|Within country scope only | |Within country scope only | ||
| Line 770: | Line 804: | ||
|Executes contained effects on a random country that meets the limit and is a subject of the country this is contained in. | |Executes contained effects on a random country that meets the limit and is a subject of the country this is contained in. | ||
|1.11 | |1.11 | ||
|- id="every_state" | |-id="every_state" | ||
|every_state | |every_state | ||
|Always usable | |Always usable | ||
| Line 777: | Line 811: | ||
|Executes contained effects on every state that meets the limit. | |Executes contained effects on every state that meets the limit. | ||
|1.0 | |1.0 | ||
|- id="random_state" | |-id="random_state" | ||
|random_state | |random_state | ||
|Always usable | |Always usable | ||
| Line 787: | Line 821: | ||
|Executes contained effects on a random state that meets the limit. | |Executes contained effects on a random state that meets the limit. | ||
|1.0 | |1.0 | ||
|- id="every_neighbor_state" | |-id="every_neighbor_state" | ||
|every_neighbor_state | |every_neighbor_state | ||
|Within state scope only | |Within state scope only | ||
| Line 794: | Line 828: | ||
|Executes contained effects on every state that meets the limit and neighbours the state this is contained in. | |Executes contained effects on every state that meets the limit and neighbours the state this is contained in. | ||
|1.0 | |1.0 | ||
|- id="random_neighbor_state" | |-id="random_neighbor_state" | ||
|random_neighbor_state | |random_neighbor_state | ||
|Within state scope only | |Within state scope only | ||
|State | |State | ||
|<code>random_neighbor_state = { … }</code> | |<code>random_neighbor_state = { … }</code> | ||
|Executes contained effects on a random state that meets the limit and neighbours the state this is contained in. Does not support [[ | |Executes contained effects on a random state that meets the limit and neighbours the state this is contained in. Does not support [[#Scope priority|prioritizing]]. | ||
|1.0 | |1.0 | ||
|- id="every_owned_state" | |-id="every_owned_state" | ||
|every_owned_state | |every_owned_state | ||
|Within country scope only | |Within country scope only | ||
| Line 808: | Line 842: | ||
|Executes contained effects on every state that meets the limit and is owned by the country this is contained in. | |Executes contained effects on every state that meets the limit and is owned by the country this is contained in. | ||
|1.0 | |1.0 | ||
|- id="random_owned_state" | |-id="random_owned_state" | ||
|random_owned_state | |random_owned_state | ||
|Within country scope only | |Within country scope only | ||
| Line 818: | Line 852: | ||
|Executes contained effects on a random state that meets the limit and is owned by the country this is contained in. | |Executes contained effects on a random state that meets the limit and is owned by the country this is contained in. | ||
|1.0 | |1.0 | ||
|- id="every_core_state" | |-id="every_core_state" | ||
|every_core_state | |every_core_state | ||
|Within country scope only | |Within country scope only | ||
| Line 825: | Line 859: | ||
|Executes contained effects on every state that meets the limit and is a core of the country this is contained in. | |Executes contained effects on every state that meets the limit and is a core of the country this is contained in. | ||
|1.11 | |1.11 | ||
|- id="random_core_state" | |-id="random_core_state" | ||
|random_core_state | |random_core_state | ||
|Within country scope only | |Within country scope only | ||
| Line 835: | Line 869: | ||
|Executes contained effects on a random state that meets the limit and is a core of the country this is contained in. | |Executes contained effects on a random state that meets the limit and is a core of the country this is contained in. | ||
|1.11 | |1.11 | ||
|- id="every_controlled_state" | |-id="every_controlled_state" | ||
|every_controlled_state | |every_controlled_state | ||
|Within country scope only | |Within country scope only | ||
| Line 842: | Line 876: | ||
|Executes contained effects on every state that meets the limit and is controlled by the country this is contained in. | |Executes contained effects on every state that meets the limit and is controlled by the country this is contained in. | ||
|1.9 | |1.9 | ||
|- id="random_controlled_state" | |-id="random_controlled_state" | ||
|random_controlled_state | |random_controlled_state | ||
|Within country scope only | |Within country scope only | ||
| Line 852: | Line 886: | ||
|Executes contained effects on a random state that meets the limit and is controlled by the country this is contained in. | |Executes contained effects on a random state that meets the limit and is controlled by the country this is contained in. | ||
|1.9 | |1.9 | ||
|- id="random_owned_controlled_state" | |-id="random_owned_controlled_state" | ||
|random_owned_controlled_state | |random_owned_controlled_state | ||
|Within country scope only | |Within country scope only | ||
| Line 862: | Line 896: | ||
|Executes contained effects on a random state that meets the limit and is owned and controlled by the country this is contained in. | |Executes contained effects on a random state that meets the limit and is owned and controlled by the country this is contained in. | ||
|1.3 | |1.3 | ||
|- id="every_unit_leader" | |-id="every_unit_leader" | ||
|every_unit_leader | |every_unit_leader | ||
|Within country scope only | |Within country scope only | ||
| Line 869: | Line 903: | ||
|Executes contained effects on every unit leader (corps commanders, field marshals, admirals) that meets the limit and is recruited by the country this is contained in. | |Executes contained effects on every unit leader (corps commanders, field marshals, admirals) that meets the limit and is recruited by the country this is contained in. | ||
|1.5 | |1.5 | ||
|- id="random_unit_leader" | |-id="random_unit_leader" | ||
|random_unit_leader | |random_unit_leader | ||
|Within country scope only | |Within country scope only | ||
| Line 876: | Line 910: | ||
|Executes contained effects on a random unit leader (corps commanders, field marshals, admirals) that meets the limit and is recruited by the country this is contained in. | |Executes contained effects on a random unit leader (corps commanders, field marshals, admirals) that meets the limit and is recruited by the country this is contained in. | ||
|1.5 | |1.5 | ||
|- id="every_army_leader" | |-id="every_army_leader" | ||
|every_army_leader | |every_army_leader | ||
|Within country scope only | |Within country scope only | ||
| Line 883: | Line 917: | ||
|Executes contained effects on every army leader that meets the limit and is recruited by the country this is contained in. | |Executes contained effects on every army leader that meets the limit and is recruited by the country this is contained in. | ||
|1.5 | |1.5 | ||
|- id="random_army_leader" | |-id="random_army_leader" | ||
|random_army_leader | |random_army_leader | ||
|Within country scope only | |Within country scope only | ||
| Line 890: | Line 924: | ||
|Executes contained effects on a random army leader that meets the limit and is recruited by the country this is contained in. | |Executes contained effects on a random army leader that meets the limit and is recruited by the country this is contained in. | ||
|1.5 | |1.5 | ||
|- id="global_every_army_leader" | |-id="global_every_army_leader" | ||
|global_every_army_leader | |global_every_army_leader | ||
|Always usable | |Always usable | ||
| Line 897: | Line 931: | ||
|Executes contained effects on every army leader that meets the limit. Preferable to use every_army_leader unless necessary to use global_every_army_leader. | |Executes contained effects on every army leader that meets the limit. Preferable to use every_army_leader unless necessary to use global_every_army_leader. | ||
|1.5 | |1.5 | ||
|- id="every_navy_leader" | |-id="every_navy_leader" | ||
|every_navy_leader | |every_navy_leader | ||
|Within country scope only | |Within country scope only | ||
| Line 904: | Line 938: | ||
|Executes contained effects on every navy leader that meets the limit and is recruited by the country this is contained in. | |Executes contained effects on every navy leader that meets the limit and is recruited by the country this is contained in. | ||
|1.5 | |1.5 | ||
|- id="random_navy_leader" | |-id="random_navy_leader" | ||
|random_navy_leader | |random_navy_leader | ||
|Within country scope only | |Within country scope only | ||
| Line 911: | Line 945: | ||
|Executes contained effects on a random navy leader that meets the limit and is recruited by the country this is contained in. | |Executes contained effects on a random navy leader that meets the limit and is recruited by the country this is contained in. | ||
|1.5 | |1.5 | ||
|- id="every_operative " | |-id="every_operative " | ||
|every_operative | |every_operative | ||
|Within country scope or operations only | |Within country scope or operations only | ||
| Line 918: | Line 952: | ||
|Executes contained effects on every operative that meets the limit and is recruited by the country this is contained in. | |Executes contained effects on every operative that meets the limit and is recruited by the country this is contained in. | ||
|1.9 | |1.9 | ||
|- id="random_operative" | |-id="random_operative" | ||
|random_operative | |random_operative | ||
|Within country scope or operations only | |Within country scope or operations only | ||
| Line 925: | Line 959: | ||
|Executes contained effects on a random operative that meets the limit and is recruited by the country this is contained in. | |Executes contained effects on a random operative that meets the limit and is recruited by the country this is contained in. | ||
|1.9 | |1.9 | ||
|- id="every_character" | |-id="every_character" | ||
|every_character | |every_character | ||
|Within country scope only | |Within country scope only | ||
| Line 932: | Line 966: | ||
|Executes contained effects on every character that meets the limit and is recruited by the country this is contained in. | |Executes contained effects on every character that meets the limit and is recruited by the country this is contained in. | ||
|1.11 | |1.11 | ||
|- id="random_character" | |-id="random_character" | ||
|random_character | |random_character | ||
|Within country scope only | |Within country scope only | ||
| Line 939: | Line 973: | ||
|Executes contained effects on a random character that meets the limit and is recruited by the country this is contained in. | |Executes contained effects on a random character that meets the limit and is recruited by the country this is contained in. | ||
|1.11 | |1.11 | ||
|- id="every_country_division" | |-id="every_country_division" | ||
|every_country_division | |every_country_division | ||
|Within country scope only | |Within country scope only | ||
| Line 946: | Line 980: | ||
|Executes contained effects on every division that meets the limit and is owned by the current country. | |Executes contained effects on every division that meets the limit and is owned by the current country. | ||
|1.12 | |1.12 | ||
|- id="random_country_division" | |-id="random_country_division" | ||
|random_country_division | |random_country_division | ||
|Within country scope only | |Within country scope only | ||
| Line 953: | Line 987: | ||
|Executes contained effects on a random division that meets the limit and is owned by the current country. | |Executes contained effects on a random division that meets the limit and is owned by the current country. | ||
|1.12 | |1.12 | ||
|- id="every_state_division" | |-id="every_state_division" | ||
|every_state_division | |every_state_division | ||
|Within state scope only | |Within state scope only | ||
| Line 960: | Line 994: | ||
|Executes contained effects on every division that meets the limit and is located within the current state. | |Executes contained effects on every division that meets the limit and is located within the current state. | ||
|1.12 | |1.12 | ||
|- id="random_state_division" | |-id="random_state_division" | ||
|random_state_division | |random_state_division | ||
|Within state scope only | |Within state scope only | ||
| Line 967: | Line 1,001: | ||
|Executes contained effects on a random division that meets the limit and is located within the current state. | |Executes contained effects on a random division that meets the limit and is located within the current state. | ||
|1.12 | |1.12 | ||
|- id="every_military_industrial_organization" | |-id="every_military_industrial_organization" | ||
|every_military_industrial_organization | |every_military_industrial_organization | ||
|Within country scope only | |Within country scope only | ||
| Line 974: | Line 1,008: | ||
|Executes contained effects on every MIO within the current country that meets the limit. | |Executes contained effects on every MIO within the current country that meets the limit. | ||
|1.13 | |1.13 | ||
|- id="random_military_industrial_organization" | |-id="random_military_industrial_organization" | ||
|random_military_industrial_organization | |random_military_industrial_organization | ||
|Within country scope only | |Within country scope only | ||
| Line 981: | Line 1,015: | ||
|Executes contained effects on a random MIO within the current country that meets the limit. | |Executes contained effects on a random MIO within the current country that meets the limit. | ||
|1.13 | |1.13 | ||
|- id="every_purchase_contract" | |-id="every_purchase_contract" | ||
|every_purchase_contract | |every_purchase_contract | ||
|Within country scope only | |Within country scope only | ||
| Line 988: | Line 1,022: | ||
|Executes contained effects on every purchase contract within the current country that meets the limit. | |Executes contained effects on every purchase contract within the current country that meets the limit. | ||
|1.13 | |1.13 | ||
|- id="random_purchase_contract" | |-id="random_purchase_contract" | ||
|random_purchase_contract | |random_purchase_contract | ||
|Within country scope only | |Within country scope only | ||
| Line 995: | Line 1,029: | ||
|Executes contained effects on a random purchase contract within the current country that meets the limit. | |Executes contained effects on a random purchase contract within the current country that meets the limit. | ||
|1.13 | |1.13 | ||
|- id="party_leader" | |-id="party_leader" | ||
|party_leader | |party_leader | ||
|Within country scope only | |Within country scope only | ||
| Line 1,007: | Line 1,041: | ||
|Executes the effects on the party leader with the specified ideology type. Must contain a <code>has_ideology</code> in the limit that refers to a specific ideology type (e.g. Despotic), not a group that contain the type (e.g. Non-Aligned). The selected character must be the leader of a party corresponding to the ideology group. | |Executes the effects on the party leader with the specified ideology type. Must contain a <code>has_ideology</code> in the limit that refers to a specific ideology type (e.g. Despotic), not a group that contain the type (e.g. Non-Aligned). The selected character must be the leader of a party corresponding to the ideology group. | ||
|1.11 | |1.11 | ||
|}'''NOTE:''' Some of these scopes may have no countries/states that match the criteria | |} | ||
===Effects with scopes=== | |||
There are the following [[ | '''NOTE:''' Some of these scopes may have no countries/states that match the criteria | ||
{| class="wikitable sortable mw-collapsible | === Effects with scopes === | ||
|+ style="white-space:nowrap;" |Effects changing the scope: | <noinclude>There are the following [[effects]] that also change the currently-selected scope: | ||
{| class="wikitable sortable mw-collapsible" style="display: inline-block; padding: 5px" width="100%" | |||
|+ style="white-space:nowrap;" | Effects changing the scope:<br/> | |||
! width="10%" |Name | ! width="10%" |Name | ||
! width="25%" |Parameters | ! width="25%" |Parameters | ||
| Line 1,017: | Line 1,053: | ||
! width="20%" |Description | ! width="20%" |Description | ||
! width="15%" |Notes | ! width="15%" |Notes | ||
! width="5%" |Version Added | ! width="5%" |Version Added | ||
|- id="start_civil_war" | |-id="start_civil_war" | ||
|start_civil_war | |start_civil_war | ||
|<code>ideology = <ideology></code>The ideology of the breakaway country. | |<code>ideology = <ideology></code><br/>The ideology of the breakaway country. | ||
<code>ruling_party = <ideology></code> | <code>ruling_party = <ideology></code><br/>The ruling party of the '''original, player-led''' country. Optional.<br/> | ||
<code>size = <float></code><br/>The size of the breakaway country and the fraction of the original stockpile and military units it will receive by default. Optional, defaults to 0.5.<br/> | |||
The ruling party of the '''original, player-led''' country. Optional. | <code>army_ratio = <float></code><br/>The size of the land army that the breakaway country gets. Optional, defaults to being the same as size.<br/> | ||
<code>navy_ratio = <float></code><br/>The size of the naval forces that the breakaway country gets. Optional, defaults to being the same as size.<br/> | |||
<code>size = <float></code> | <code>air_ratio = <float></code><br/>The size of the airforce that the breakaway country gets. Optional, defaults to being the same as size.<br/> | ||
<code>capital = <state></code><br/>The capital state of the breakaway country. Optional.<br/> | |||
The size of the breakaway country and the fraction of the original stockpile and military units it will receive by default. Optional, defaults to 0.5. | <code>states = { <state> }</code><br/>The states included in the breakway country. Optional, defaults to random states based off size. <code>all</code> will result in all states that meet the filter going to the breakaway.<br/> | ||
<code>states_filter = { <triggers> }</code><br/>A trigger block checked for the state that must be met to be transferred to the breakaway. Optional.<br/> | |||
<code>army_ratio = <float></code> | <code>keep_unit_leaders = { <unit leader id> }</code><br/>List of unit leaders to be kept by their legacy_id. Optional.<br/> | ||
<code>keep_unit_leaders_trigger = { <triggers> }</code><br/>Trigger block checked for every unit leader that forces them to be kept if they meet the triggers. Optional.<br/> | |||
The size of the land army that the breakaway country gets. Optional, defaults to being the same as size. | <code>keep_political_leader = <bool></code><br/>Controls if the promoted party leader (i.e. the one that'd take power if the country were to be switched to that ideology group) of the revolting ideology group will be kept by the country or join the revolt, yes resulting in the former. Optional, defaults to false.<br/> | ||
<code>keep_political_party_members = <bool></code><br>Controls if non-promoted party leaders of the revolting ideology group will be kept by the country or join the revolt, yes resulting in the former. Optional, defaults to false.<br/> | |||
<code>navy_ratio = <float></code> | <code>keep_all_characters = yes</code><br/>If true, the revolter will have no characters from the original country transferred to them. Optional, defaults to false.<br/> | ||
<code><effects></code><br/>An effect block executed for the breakaway country. | |||
The size of the naval forces that the breakaway country gets. Optional, defaults to being the same as size. | |||
<code>air_ratio = <float></code> | |||
The size of the airforce that the breakaway country gets. Optional, defaults to being the same as size. | |||
<code>capital = <state></code> | |||
The capital state of the breakaway country. Optional. | |||
<code>states = { <state> }</code> | |||
The states included in the breakway country. Optional, defaults to random states based off size. <code>all</code> will result in all states that meet the filter going to the breakaway. | |||
<code>states_filter = { <triggers> }</code> | |||
A trigger block checked for the state that must be met to be transferred to the breakaway. Optional. | |||
<code>keep_unit_leaders = { <unit leader id> }</code> | |||
List of unit leaders to be kept by their legacy_id. Optional. | |||
<code>keep_unit_leaders_trigger = { <triggers> }</code> | |||
Trigger block checked for every unit leader that forces them to be kept if they meet the triggers. Optional. | |||
<code>keep_political_leader = <bool></code> | |||
Controls if the promoted party leader (i.e. the one that'd take power if the country were to be switched to that ideology group) of the revolting ideology group will be kept by the country or join the revolt, yes resulting in the former. Optional, defaults to false. | |||
<code>keep_political_party_members = <bool></code> | |||
Controls if non-promoted party leaders of the revolting ideology group will be kept by the country or join the revolt, yes resulting in the former. Optional, defaults to false. | |||
<code>keep_all_characters = yes</code> | |||
If true, the revolter will have no characters from the original country transferred to them. Optional, defaults to false. | |||
<code><effects></code> | |||
An effect block executed for the breakaway country. | |||
|<pre>start_civil_war = { | |<pre>start_civil_war = { | ||
ruling_party = communism | ruling_party = communism | ||
| Line 1,092: | Line 1,087: | ||
keep_political_party_members = yes | keep_political_party_members = yes | ||
} | } | ||
</pre><pre>start_civil_war = { | </pre> | ||
<pre>start_civil_war = { | |||
ideology = democratic | ideology = democratic | ||
size = 0.1 | size = 0.1 | ||
| Line 1,102: | Line 1,098: | ||
set_country_flag = TAG_my_country_tag_alias_trigger | set_country_flag = TAG_my_country_tag_alias_trigger | ||
# Sets a country flag that gets used in a country tag alias. | # Sets a country flag that gets used in a country tag alias. | ||
}</pre>([[ | }</pre> | ||
([[Country tag aliases|See country tag aliases]]) | |||
<pre>start_civil_war = { | |||
ideology = neutrality | ideology = neutrality | ||
size = 0.1 | size = 0.1 | ||
| Line 1,119: | Line 1,117: | ||
} | } | ||
promote_character = TAG_airforce_leader | promote_character = TAG_airforce_leader | ||
}</pre>([[ | }</pre> | ||
([[Scopes#PREV usage|See usage for PREV and PREV.PREV]]) | |||
|'''Within country scope:''' starts a civil war for the current scope with the specified parameters, changing the scope to the dynamic country. | |'''Within country scope:''' starts a civil war for the current scope with the specified parameters, changing the scope to the dynamic country. | ||
|<code>states = all</code> would include every single state controlled by the country. '''If the country's current capital state is set as one of the states that the revolt can gain, it won't fire'''. [[ | |<code>states = all</code> would include every single state controlled by the country. '''If the country's current capital state is set as one of the states that the revolt can gain, it won't fire'''. [[#set_capital|set_capital]] can be used to change the capital beforehand, with [[On_actions#on_civil_war_end]] being used to set it back to the default after the civil war ends. | ||
|1.0 | |1.0 | ||
|- id="create_dynamic_country" | |-id="create_dynamic_country" | ||
|create_dynamic_country | |create_dynamic_country | ||
|<code>original_tag = <tag></code>The original tag to be used by the country. | |<code>original_tag = <tag></code><br/>The original tag to be used by the country.<br/> | ||
<code>copy_tag = <tag></code><br/>If specified, copies stuff from this tag rather than the original tag.<br/> | |||
<code><effects></code><br/>Effects that will be executed on the new dynamic country.<br/> | |||
<code>copy_tag = <tag></code> | |||
If specified, copies stuff from this tag rather than the original tag. | |||
<code><effects></code> | |||
Effects that will be executed on the new dynamic country. | |||
|<pre> | |<pre> | ||
create_dynamic_country = { | create_dynamic_country = { | ||
| Line 1,144: | Line 1,136: | ||
</pre> | </pre> | ||
|'''Within country scope:''' Creates a new dynamic country, akin to ones used in civil wars, adding every core of the original tag as core and changing the scope to the dynamic country. | |'''Within country scope:''' Creates a new dynamic country, akin to ones used in civil wars, adding every core of the original tag as core and changing the scope to the dynamic country. | ||
|The [[ | |The [[#reserve_dynamic_country|reserve_dynamic_country]] effect can be used if the dynamic country does not yet exist in order to ensure that it does not get overwritten by other creations of dynamic countries. | ||
|1.9 | |1.9 | ||
|} | |} | ||
==Array scopes== | </noinclude> | ||
{{See also|Arrays}}[[ | <includeonly>Effects that change the scope include the following: | ||
{| class="wikitable sortable mw-collapsible | * [[Effect#start_civil_war|start_civil_war]], which changes it to the rebelling dynamic country. | ||
|+ style="white-space:nowrap;" |Array-related scopes: | * [[Effect#create_dynamic_country|create_dynamic_country]], which changes it to the newly-created dynamic country.</includeonly> | ||
== Array scopes == | |||
{{See also|Arrays}} | |||
[[Arrays]] can be used to create a generic selection of scopes meeting the criteria. These scopes exist for checking conditions on elements of an array or executing effects on them: | |||
{| class="wikitable sortable mw-collapsible" style="display: inline-block; padding: 5px" width="100%" | |||
|+ style="white-space:nowrap;" | Array-related scopes:<br/> | |||
! width="10%" |Name | ! width="10%" |Name | ||
! width="5%" |Type | ! width="5%" |Type | ||
! width="25%" |Parameters | ! width="25%" |Parameters | ||
! width="25%" |Examples | ! width="25%" |Examples | ||
! width="20%" |Description | ! width="20%" |Description | ||
! width="15%" |Notes | ! width="15%" |Notes | ||
|- id="any_of_scopes" | |-id="any_of_scopes" | ||
|any_of_scopes | |any_of_scopes | ||
|Trigger | |Trigger | ||
|<code>array = <array></code>The array to check. | |<code>array = <array></code><br/>The array to check.<br/> | ||
<code>tooltip = <localisation key></code><br/>The localisation key used for the trigger.<br/> | |||
<code><triggers></code><br/> An AND trigger block. | |||
<code>tooltip = <localisation key></code> | |||
The localisation key used for the trigger. | |||
<code><triggers></code> | |||
An AND trigger block. | |||
|<pre>any_of_scopes = { | |<pre>any_of_scopes = { | ||
array = global.majors | array = global.majors | ||
| Line 1,178: | Line 1,169: | ||
|Checks if any value within the array fulfills the triggers, halting and returning true if that's the case, scoping into each element in the array. | |Checks if any value within the array fulfills the triggers, halting and returning true if that's the case, scoping into each element in the array. | ||
|Appending <code>_NOT</code> to the tooltip's key (such as has_more_states_than_any_other_major_tt_NOT in the example) results in the localisation key used if this any_of_scopes is put inside of <code>NOT = { ... }</code>. | |Appending <code>_NOT</code> to the tooltip's key (such as has_more_states_than_any_other_major_tt_NOT in the example) results in the localisation key used if this any_of_scopes is put inside of <code>NOT = { ... }</code>. | ||
|- id="all_of_scopes" | |-id="all_of_scopes" | ||
|all_of_scopes | |all_of_scopes | ||
|Trigger | |Trigger | ||
|<code>array = <array></code>The array to check. | |<code>array = <array></code><br/>The array to check.<br/> | ||
<code>tooltip = <localisation key></code><br/>The localisation key used for the trigger.<br/> | |||
<code><triggers></code><br/> An AND trigger block. | |||
<code>tooltip = <localisation key></code> | |||
The localisation key used for the trigger. | |||
<code><triggers></code> | |||
An AND trigger block. | |||
|<pre>all_of_scopes = { | |<pre>all_of_scopes = { | ||
array = global.majors | array = global.majors | ||
| Line 1,201: | Line 1,185: | ||
|Checks if every value within the array fulfills the triggers, halting and returning false if any one doesn't, scoping into each element in the array. | |Checks if every value within the array fulfills the triggers, halting and returning false if any one doesn't, scoping into each element in the array. | ||
|Appending <code>_NOT</code> to the tooltip's key (such as has_more_states_than_every_other_major_tt_NOT in the example) results in the localisation key used if this any_of_scopes is put inside of <code>NOT = { ... }</code>. | |Appending <code>_NOT</code> to the tooltip's key (such as has_more_states_than_every_other_major_tt_NOT in the example) results in the localisation key used if this any_of_scopes is put inside of <code>NOT = { ... }</code>. | ||
|- id="for_each_scope_loop" | |-id="for_each_scope_loop" | ||
|for_each_scope_loop | |for_each_scope_loop | ||
|Effect | |Effect | ||
|<code>array = <array></code>The array to check. | |<code>array = <array></code><br/>The array to check.<br/> | ||
<code>break = <variable></code><br/>The temporary variable that can be set to be not 0 to instantly break the loop.<br/> | |||
<code><effects></code><br/> An effect block. | |||
<code>break = <variable></code> | |||
The temporary variable that can be set to be not 0 to instantly break the loop. | |||
<code><effects></code> | |||
An effect block. | |||
|<pre>for_each_scope_loop = { | |<pre>for_each_scope_loop = { | ||
array = global.majors | array = global.majors | ||
| Line 1,227: | Line 1,204: | ||
|Runs the effects for every scope within the array. | |Runs the effects for every scope within the array. | ||
|Equivalent to a <code>every_<...></code> effect scope type, with additional <code>break</code>. | |Equivalent to a <code>every_<...></code> effect scope type, with additional <code>break</code>. | ||
|- id="random_scope_in_array" | |-id="random_scope_in_array" | ||
|random_scope_in_array | |random_scope_in_array | ||
|Effect | |Effect | ||
|<code>array = <array></code>The array to check. | |<code>array = <array></code><br/>The array to check.<br/> | ||
<code>break = <variable></code><br/>The temporary variable that can be set to be not 0 to instantly break the loop.<br/> | |||
<code>limit = { <triggers> }</code><br/>An AND trigger block deciding which scopes can be picked.<br/> | |||
<code>break = <variable></code> | <code><effects></code><br/> An effect block. | ||
The temporary variable that can be set to be not 0 to instantly break the loop. | |||
<code>limit = { <triggers> }</code> | |||
An AND trigger block deciding which scopes can be picked. | |||
<code><effects></code> | |||
An effect block. | |||
|<pre>random_scope_in_array = { | |<pre>random_scope_in_array = { | ||
array = global.countries | array = global.countries | ||
| Line 1,261: | Line 1,228: | ||
|Equivalent to a <code>random_<...></code> effect scope type, with additional <code>break</code>. | |Equivalent to a <code>random_<...></code> effect scope type, with additional <code>break</code>. | ||
|} | |} | ||
==PREV usage== | ==PREV usage== | ||
In order to understand PREV, it can be helpful to think back to the trigger/effect scopes such as every_controlled_state. In this case, if put inside directly, PREV can be used as the controller of the state. In fact, every_controlled_state is equivalent to every_state with a limit of <code>is_controlled_by = PREV</code> in most ways, although it is recommended to use every_controlled_state instead as it is better for optimisation. For example, the following will transfer every state to its controller, changing the owner:<pre>every_country = { | |||
In order to understand PREV, it can be helpful to think back to the trigger/effect scopes such as every_controlled_state. In this case, if put inside directly, PREV can be used as the controller of the state. In fact, every_controlled_state is equivalent to every_state with a limit of <code>is_controlled_by = PREV</code> in most ways, although it is recommended to use every_controlled_state instead as it is better for optimisation. For example, the following will transfer every state to its controller, changing the owner: | |||
<pre>every_country = { | |||
every_controlled_state = { | every_controlled_state = { | ||
transfer_state_to = PREV | transfer_state_to = PREV | ||
} | } | ||
}</pre>If thinking of it as a tree, the scopes are in the order of [every_country,every_controlled_state]. Using it within every_controlled_state will refer back to the parent node, or every_country, specifically the country in the every_country list this is currently being executed for. This can be used in other ways, such as obtaining a wargoal against the owner of a state:<pre>123 = { | }</pre>If thinking of it as a tree, the scopes are in the order of [every_country,every_controlled_state]. Using it within every_controlled_state will refer back to the parent node, or every_country, specifically the country in the every_country list this is currently being executed for. This can be used in other ways, such as obtaining a wargoal against the owner of a state: | ||
<pre>123 = { | |||
owner = { | owner = { | ||
ROOT = { | ROOT = { | ||
| Line 1,276: | Line 1,248: | ||
} | } | ||
} | } | ||
}</pre>[[File:PREV usage.png|thumb|450px|alt=A diagram showing the connection in the code.|Diagram showing how PREV and PREV.PREV connect to other entries in the code example. | }</pre> | ||
[[File:PREV usage.png|thumb|450px|alt=A diagram showing the connection in the code.|Diagram showing how PREV and PREV.PREV connect to other entries in the code example.]]In this case, the tree is constructed with [123,owner,ROOT]. Using PREV within ROOT will refer to the previously-defined owner. | |||
Chaining PREV can be done by separating them with a dot as PREV.PREV.PREV. This can be useful if the needed scope is more than 1 scope back. | Chaining PREV can be done by separating them with a dot as PREV.PREV.PREV. This can be useful if the needed scope is more than 1 scope back.<br/> | ||
This is an another example of PREV usage with an attached diagram showing how they connect to other scopes: | |||
This is an another example of PREV usage with an attached diagram showing how they connect to other scopes:<pre> | <pre> | ||
every_country = { | every_country = { | ||
limit = { | limit = { | ||
| Line 1,293: | Line 1,266: | ||
country_event = my_event.0 | country_event = my_event.0 | ||
} | } | ||
</pre>In this case, an event will be sent to every country that has sent an [[ | </pre>In this case, an event will be sent to every country that has sent an [[attaché]] to a country that's at war with a neighbour of the original country (i.e. the country that would receive the event). Using PREV.PREV is necessary in this case as all 3 countries don't have single defined tags or pointers and all interact with each other.{{clear}} | ||
*(Sardinia, Corsica, Sicily): | |||
**{{flag|Switzerland}}: | In many cases, using PREV can result in seemingly broken tooltips which'll work fine regardless when executing the effects in-game. This typically happens when using it pointing to scopes of the <code>every_<...></code>/<code>all_<...></code> types. A single effect or trigger's tooltip can only show one scope as a target at once, and the game would only pick the first possible scope in the tooltip. This can look like the following: | ||
***Becomes owner and controller of '''Sardinia''' | * (Sardinia, Corsica, Sicily): | ||
This can not be avoided with traditional means while still using PREV. Instead, it's possible to use [[ | ** {{flag|Switzerland}}: | ||
*** Becomes owner and controller of '''Sardinia''' | |||
This can not be avoided with traditional means while still using PREV. Instead, it's possible to use [[Effect#Effect tooltips|hidden_effect and custom_effect_tooltip]] or [[Triggers#custom_trigger_tooltip|custom_trigger_tooltip]] in order to completely replace the tooltip in this case. | |||
==Flow control tools== | ==Flow control tools== | ||
While these aren't scopes, not changing where the effects are run or triggers are checked, they still function as blocks of code that can be used within any trigger and/or effect. | While these aren't scopes, not changing where the effects are run or triggers are checked, they still function as blocks of code that can be used within any trigger and/or effect. | ||
{| class="wikitable sortable mw-collapsible" style="display: inline-block; padding: 5px" width="100%" | |||
{| class="wikitable sortable mw-collapsible | |+ style="white-space:nowrap;" | Flow control tools:<br/> | ||
|+ style="white-space:nowrap;" |Flow control tools: | |||
!Script | !Script | ||
! width="10%" |Usage | ! width="10%" | Usage | ||
! | ! width="25%" class="unsortable" |Example | ||
! class="unsortable" |Description | ! class="unsortable" |Description | ||
! | ! width="25%" class="unsortable" |Notes | ||
|- id="AND" | |-id="AND" | ||
|AND | |AND | ||
|Within triggers | |Within triggers | ||
| Line 1,317: | Line 1,292: | ||
} | } | ||
</pre> | </pre> | ||
|Returns false if any sub-trigger returns false, true otherwise. Evaluation stops at the first false sub-trigger. | |Returns false if any sub-trigger returns false, true otherwise. Evaluation stops at the first false sub-trigger.<br/> | ||
Nearly all trigger blocks (including scopes) use AND by defaults, so its primary use is with OR and NOT, which affects their function. | Nearly all trigger blocks (including scopes) use AND by defaults, so its primary use is with OR and NOT, which affects their function. | ||
|Usually modifies trigger tooltips to include "All of the following must be true" | |Usually modifies trigger tooltips to include "All of the following must be true" | ||
|- id="OR" | |-id="OR" | ||
|OR | |OR | ||
|Within triggers | |Within triggers | ||
| Line 1,332: | Line 1,305: | ||
</pre> | </pre> | ||
|Returns true if any sub-trigger returns true, false otherwise. Evaluation stops at the first true sub-trigger. | |Returns true if any sub-trigger returns true, false otherwise. Evaluation stops at the first true sub-trigger. | ||
By default, OR checks each contained trigger separately, AND can be used in order to check between groups of triggers. | By default, OR checks each contained trigger separately, AND can be used in order to check between groups of triggers. | ||
|Usually modifies trigger tooltips to include "One of the following must be true" | |Usually modifies trigger tooltips to include "One of the following must be true" | ||
|- id="NOT" | |-id="NOT" | ||
|NOT | |NOT | ||
|Within triggers | |Within triggers | ||
| Line 1,343: | Line 1,317: | ||
} | } | ||
</pre> | </pre> | ||
|Returns false if any sub-trigger returns true, true otherwise. Evaluation stops at the first true sub-trigger. | |Returns false if any sub-trigger returns true, true otherwise. Evaluation stops at the first true sub-trigger.<br/> | ||
This is equivalent to logical NOR, as it returns true only if all contained triggers are false.<br/> | |||
This is equivalent to logical NOR, as it returns true only if all contained triggers are false. | |||
There is no direct form of logical NAND (true if any contained trigger is false), however <code>NOT = { AND = { … } }</code> emulates NAND, as does <code>OR = { NOT = { … } NOT = { … } }</code>, with each contained trigger in a separate NOT block. | There is no direct form of logical NAND (true if any contained trigger is false), however <code>NOT = { AND = { … } }</code> emulates NAND, as does <code>OR = { NOT = { … } NOT = { … } }</code>, with each contained trigger in a separate NOT block. | ||
|NOT also allows emulating greater/less than or equals in comparisions that are normally strictly greater or less than. | |NOT also allows emulating greater/less than or equals in comparisions that are normally strictly greater or less than. | ||
NOT usually inverts trigger tooltips, though not always predictably or neatly. The inverted tooltip for scopes or <code>custom_trigger_tooltip</code> can be defined by appending <code>_NOT</code> to the localisation key of the tooltip. | NOT usually inverts trigger tooltips, though not always predictably or neatly. The inverted tooltip for scopes or <code>custom_trigger_tooltip</code> can be defined by appending <code>_NOT</code> to the localisation key of the tooltip. | ||
|- id="count_triggers" | |-id="count_triggers" | ||
|count_triggers | |count_triggers | ||
|Within triggers | |Within triggers | ||
| Line 1,364: | Line 1,335: | ||
|Returns true if the number of contained triggers which return true is greater than or equal to the value of <code>amount</code> | |Returns true if the number of contained triggers which return true is greater than or equal to the value of <code>amount</code> | ||
| | | | ||
|- id="hidden_trigger" | |-id="hidden_trigger" | ||
|hidden_trigger | |hidden_trigger | ||
|Within triggers | |Within triggers | ||
| Line 1,374: | Line 1,345: | ||
|Hides the tooltips from all contained triggers | |Hides the tooltips from all contained triggers | ||
| | | | ||
|- id="custom_trigger_tooltip" | |-id="custom_trigger_tooltip" | ||
|custom_trigger_tooltip | |custom_trigger_tooltip | ||
|Within triggers | |Within triggers | ||
| Line 1,389: | Line 1,360: | ||
|Replaces the tooltips from all contained triggers with the custom localisation set by <code>tooltip</code> | |Replaces the tooltips from all contained triggers with the custom localisation set by <code>tooltip</code> | ||
|If the <code>custom_trigger_tooltip</code> is negated (within NOT or a <code><scripted_trigger> = no</code>, the negated tooltip can be customized by appending <code>_NOT</code> to the localisation key of the tooltip (e.g. <code>sunrise_invasion_tt_NOT</code>). | |If the <code>custom_trigger_tooltip</code> is negated (within NOT or a <code><scripted_trigger> = no</code>, the negated tooltip can be customized by appending <code>_NOT</code> to the localisation key of the tooltip (e.g. <code>sunrise_invasion_tt_NOT</code>). | ||
|- id="hidden_effect" | |-id="hidden_effect" | ||
|hidden_effect | |hidden_effect | ||
|Within effects | |Within effects | ||
| Line 1,402: | Line 1,373: | ||
|Hides the tooltips from all contained effects | |Hides the tooltips from all contained effects | ||
|Commonly used alongside <code>custom_effect_tooltip</code>, to avoid messy effect tooltips or hide precise effects from the player. | |Commonly used alongside <code>custom_effect_tooltip</code>, to avoid messy effect tooltips or hide precise effects from the player. | ||
|- id="effect_tooltip" | |-id="effect_tooltip" | ||
|effect_tooltip | |effect_tooltip | ||
|Within effects | |Within effects | ||
| Line 1,415: | Line 1,386: | ||
|Shows the tooltips of the contained effects, but does not execute them. | |Shows the tooltips of the contained effects, but does not execute them. | ||
|Most often useful with event chains, where the actual effect is done in a follow-up event. | |Most often useful with event chains, where the actual effect is done in a follow-up event. | ||
|- id="if" | |-id="if" | ||
|if | |if | ||
|Always usable | |Always usable | ||
| Line 1,436: | Line 1,407: | ||
</pre> | </pre> | ||
|If statements allow to conditionally check triggers or run effects. The <code>limit</code> block is used to define triggers that must be fulfilled for the effects to be run or triggers to be checked. The triggers in <code>limit</code> are ''never'' shown to the player: if they are unfulfilled, the if statement will have no tooltip, while, if fulfilled, the player will see the effects/triggers inside the if statement itself. | |If statements allow to conditionally check triggers or run effects. The <code>limit</code> block is used to define triggers that must be fulfilled for the effects to be run or triggers to be checked. The triggers in <code>limit</code> are ''never'' shown to the player: if they are unfulfilled, the if statement will have no tooltip, while, if fulfilled, the player will see the effects/triggers inside the if statement itself. | ||
In addition, <code>else_if</code> and <code>else</code> can be optionally defined to run if the limit is considered false. They can be defined as both nested (i.e. directly inside of the previous <code>if</code> or <code>else_if</code>) or unnested (i.e. directly after, but not inside of the previous <code>if</code> or <code>else_if</code>). In case of overlap, the game will prefer the unnested variant, so using that is preferred. | In addition, <code>else_if</code> and <code>else</code> can be optionally defined to run if the limit is considered false. They can be defined as both nested (i.e. directly inside of the previous <code>if</code> or <code>else_if</code>) or unnested (i.e. directly after, but not inside of the previous <code>if</code> or <code>else_if</code>). In case of overlap, the game will prefer the unnested variant, so using that is preferred. | ||
|<code>else_if</code> is optional and can be used as many times as desired. <code>else</code> is also optional, but can only be used once per <code>if</code>. | |<code>else_if</code> is optional and can be used as many times as desired. <code>else</code> is also optional, but can only be used once per <code>if</code>.<br/> | ||
The main <code>if</code> as well as any <code>else_if</code> must have a <code>limit</code>, and <code>else</code> cannot use a <code>limit</code>.<br/> | |||
The main <code>if</code> as well as any <code>else_if</code> must have a <code>limit</code>, and <code>else</code> cannot use a <code>limit</code>. | |||
If statements can be used to clean up tooltips on triggers: the limit can check if the country has a specific tag, while the if statement can contain an always false custom trigger tooltip. This will restrict it from being true for that country, while other countries will not see anything in the tooltip. | If statements can be used to clean up tooltips on triggers: the limit can check if the country has a specific tag, while the if statement can contain an always false custom trigger tooltip. This will restrict it from being true for that country, while other countries will not see anything in the tooltip. | ||
|- id="for_loop_effect" | |-id="for_loop_effect" | ||
|for_loop_effect | |for_loop_effect | ||
|Within effects | |Within effects | ||
| Line 1,457: | Line 1,426: | ||
} | } | ||
</pre> | </pre> | ||
|Runs the effect in a typical [wp:For_loop for loop], with the current value of the variable kept with the [[ | |Runs the effect in a typical [[wp:For_loop|for loop]], with the current value of the variable kept with the [[variables|temp variable]] specified with <code>value</code>. <code>break</code> defines a [[variables|temp variable]] that can be set to 1 to break the loop instantly. | ||
|If unspecified, <code>start</code> and <code>end</code> are 0, <code>compare</code> is less_than, <code>add</code> is 1, <code>value</code> is v, and <code>break</code> is break. Can run for up to {{hover|MAX_EFFECT_ITERATION = 1000 in common/defines/00_defines.lua|1000 times}} before stopping automatically. | |If unspecified, <code>start</code> and <code>end</code> are 0, <code>compare</code> is less_than, <code>add</code> is 1, <code>value</code> is v, and <code>break</code> is break. Can run for up to {{hover|MAX_EFFECT_ITERATION = 1000 in common/defines/00_defines.lua|1000 times}} before stopping automatically. | ||
|- id="while_loop_effect" | |-id="while_loop_effect" | ||
|while_loop_effect | |while_loop_effect | ||
|Within effects | |Within effects | ||
| Line 1,481: | Line 1,450: | ||
} | } | ||
</pre> | </pre> | ||
|Runs the effect as long as the trigger is true. <code>break</code> defines a [[ | |Runs the effect as long as the trigger is true. <code>break</code> defines a [[variables|temp variable]] that can be set to 1 to break the loop instantly. | ||
|The trigger is checked at the start of each loop only. Can run for up to {{hover|MAX_EFFECT_ITERATION = 1000 in common/defines/00_defines.lua|1000 times}} before stopping automatically. If <code>break</code> is unspecified, assumes to be a temp variable with the name of break. | |The trigger is checked at the start of each loop only. Can run for up to {{hover|MAX_EFFECT_ITERATION = 1000 in common/defines/00_defines.lua|1000 times}} before stopping automatically. If <code>break</code> is unspecified, assumes to be a temp variable with the name of break. | ||
|- id="random" | |-id="random" | ||
|random | |random | ||
|Within effects | |Within effects | ||
| Line 1,494: | Line 1,463: | ||
|Simulates a random chance to either execute the effect or do nothing, with the <code>chance</code> used to define the chance. | |Simulates a random chance to either execute the effect or do nothing, with the <code>chance</code> used to define the chance. | ||
|Chance is defined on the scale from 0 to 100. | |Chance is defined on the scale from 0 to 100. | ||
|- id="random_list" | |-id="random_list" | ||
|random_list | |random_list | ||
|Within effects | |Within effects | ||
| Line 1,512: | Line 1,481: | ||
</pre> | </pre> | ||
|Simulates a random chance to pick one of the listed effects. | |Simulates a random chance to pick one of the listed effects. | ||
|Chance for each section is proportional, doesn't have to add up to 100. Can use a variable as a chance. Modifiers can be used in the same way as in [[ | |Chance for each section is proportional, doesn't have to add up to 100. Can use a variable as a chance. Modifiers can be used in the same way as in [[AI modding#AI will do|ai_will_do blocks]]. | ||
|} | |} | ||
{{Modding navbox}} | {{Modding navbox}} | ||
[[分类:Modding]] | [[分类:Modding]] | ||
Latest revision as of 01:30, 8 September 2024
Scopes change the currently-selected entity where the effects should apply or which is checked by the triggers. Each one must follow the same formatting of scope = { <contents> }.
When a scope is used as for effects, each effect inside of the scope's block is executed. Conversely, when a scope is used as for triggers, it serves as a logical conjunction, requiring every trigger in the scope's block to be met for that scope to evaluate as true.
In addition to serving as blocks for effects or triggers, some scopes can also serve as targets of effects or triggers: e.g. transfer_state_to = ROOT or owns_state = 123.
However, only some dual scopes can be used as a target. For scopes that cannot be used as targets, PREV, Variables, or Event targets can be used to get around this limitation.
Types
Scopes can be thought of as divided into 3 types by purpose:
- Trigger scopes - those that can only be used in trigger blocks, failing when put within an effect block.
- Effect scopes - those that can only be used in effect blocks, failing when put within an trigger block.
- Dual scopes - those that can be put in both trigger and effect blocks without issues.
It is to be noted that trigger or effect scopes cannot ever be used as targets. That is strictly limited to some dual scopes.
Most of the non-dual scopes follow one of these following patterns:
| Prefix | Description |
|---|---|
| all_<name> | Trigger scope, evaluated for each contained scope. Returns false when encountering at least one scope that is false, returns true otherwise. |
| any_<name> | Trigger scope, evaluated for each contained scope. Returns true when encountering at least one scope that is true, returns false otherwise. |
| every_<name> | Effect scope, executes the effects on each contained scope that meets the limit in order. |
| random_<name> | Effect scope, executes the effects on a random contained scope that meets the limit. |
Only some scopes that follow this pattern have equivalents with a different pattern. For example, random_owned_controlled_state exists, but every_owned_controlled_state does not. Each of these non-dual scopes cannot select a country that does not exist, with the exception of every_possible_country.
Additionally, scopes can be divided into 6 types by the targets of the scope for which effects are executed or triggers are checked:
- Country scopes - Executed for countries.
- State scopes - Executed for states.
- Character scopes - Executed for characters. Some subsets exist, such as unit leaders and country leaders.
- Division scopes - Executed for divisions.
- MIO scopes - Executed for military industrial organisations.
- Contract scopes - Executed for purchase contracts.
Only effects or triggers of the same target type can be used. For example, add_building_construction can only be used in a state scope such as random_owned_controlled_state = { ... }, as you can only construct buildings in states. For countries, offsite buildings are used instead.
Examples
Example scope with effects: all contained effects are executed for the scope. This adds 10%
- 重定向 Template:图标 and 20%
- 重定向 Template:图标 to the
- 重定向 Template:国旗:
SOV = {
add_stability = 0.1
add_war_support = 0.2
}
Example scope with triggers: all contained triggers must return true for the scope; otherwise, the scope returns false. This requires the state 123 (South-West England) to be owned by the
- 重定向 Template:国旗 and controlled by
- 重定向 Template:国旗:
123 = {
is_owned_by = ENG
is_controlled_by = IRE
}
Example use of PREV as target for non-targetable scope. Since random_country cannot be used as a target, add_to_faction = random_country is not valid syntax; instead, PREV can be used to get around this limitation. The following example adds random country to ROOT's faction:
random_country = {
ROOT = { add_to_faction = PREV }
}
Settings
|
|
这部分内容可能已不适合当前版本,最后更新于1.13。 |
Scopes can have additional settings to narrow down the usage. This may change how many and which targets it's able to select or what the tooltip shows.
Limiting
Non-dual scopes that select unit leaders or MIOs, such as every_navy_leader, by default only include those that are visible to the player, i.e. those unit leaders whose roles do not have an unfulfilled visible = { ... } and those MIOs that do not have an unfulfilled visible = { ... }. By including include_invisible = yes, this can be changed. This will look as such:
random_army_leader = {
include_invisible = yes
set_nationality = SWE
}
Within only effect scopes, limit = { ... } can be used as a trigger block, evaluated for each possible target contained by the scope. In case of the every_<name> pattern, this will ensure that the tooltip will function properly, which may not be the case when using if directly. In case of the random_<name> pattern, this will remove the possibility of scopes not meeting the triggers being chosen, limiting the selection. For party_leader in specific, the limit must contain has_ideology, while there are no requirements on other scopes. An example of limiting the selection is the following:
every_neighbor_country = { #Targets every neighbor country
limit = {
num_of_military_factories > 5 #Limit the scope to neighbor countries with more than 5 (at least 6) military factories
}
give_military_access = ROOT #Neighbor countries with more than 5 military factories give military access to the ROOT country
}
In case of multiple triggers, limit acts like an AND block, requiring each one to be true. To reiterate, this cannot be used within trigger or dual scopes, only in effect scopes.
For scopes of the every_ type, an additional setting for limiting the selection is random_select_amount. In particular, it takes an integer and limits the maximum amount of chosen scopes to that number, picking a random sub-set if exceeded. It is used as such:
every_country = {
random_select_amount = 3 # Selects 3 random countries
country_event = lottery_win.0
}
Tooltip
By default, using a scope of either of the any_, all_, and every_ types will show a title specific to that scope in the tooltip, such as Every country: or All neighbor states:. If scope limits are used, then this changes to the list of scopes that fulfill the limit, such as Corsica, Rome, Sardinia:. For countries, the order in which country tags are created is used in ordering; for states, the state ID is used. If the tooltip differs depending on the scope where it's executed, such as with if statements, then only the first-selected scope is used in the evaluation.
By using tooltip = loc_key within any non-dual scope, including of the random_ type, the tooltip shown to the player can be changed towards the value of the targeted localisation key in the currently enabled language. This will look like the following:
any_country = {
hidden_trigger = {
has_opinion = { target = PREV value > 50 } # Serves as a "limit" hidden from the player.
}
tooltip = any_friendly_country_tt # Replaces "Any country" with the localisation key
has_war_with = ITA
}
The localisation key will be defined as such in any localisation file:
l_english: any_friendly_country_tt: "Any friendly country"
This will appear in the tooltip as such:
|
In tooltips of the every_ type where scope limits are used, by default the tooltip unites it into a single scope, such as Germany, United Kingdom, Soviet Union:. By using display_individual_scopes = yes, this will make each selected scope appear in the tooltip separately. For example:
every_neighbor_country = {
limit = {
OR = { has_government = communism has_government = fascism }
}
display_individual_scopes = yes
if = {
limit = {
has_government = fascism
}
add_war_support = -0.1
}
else = { add_stability = -0.1 }
}
Without displaying individual scopes, this will be shown as one effect block, such as the following:
|
By the nature of tooltips, the if statements for the first country are evaluated and the same tooltip is shown for both countries. This falsely implies that the Soviet Union will have 10%
- 重定向 Template:图标 removed. However, adding
display_individual_scopes = yeschanges it to the following:
|
Priority
Within effect scopes of the random_ type, if it is aimed at states, it is possible to prioritize a certain state if possible, by using prioritize as such:
random_owned_controlled_state = {
prioritize = { 123 321 }
limit = {
is_core_of = PREV
}
<...>
} In this case, the limit will first be evaluated for states 123 and 321. Only if neither of the states 123 or 321 meets the conditions of being owned, controlled, and cored by the country will the random_owned_controlled_state scope be able to select a state that isn't 123 or 321. States 123 and 321, in this case, have the same priority: if both have conditions fulfilled, which one will be picked is random. This only applies at scopes of the random_ type which target states, this cannot be done with countries or characters.
Dual scopes
The following scopes can be used either as effect or trigger scopes; some can also be used as the right side of some effects and triggers as a target. If usage as a target is possible, it's marked within the table.
Several dual scopes may have a scope that varies depending on where it's used, such as variables, which can be set to anything.
| Name | Usage | Target type | Example | Description | Usable as target | Version Added |
|---|---|---|---|---|---|---|
| TAG | Always usable | Country scope | SOV = { country_event = my_event.1 }
|
The country defined by the tag or tag alias. Tag aliases are defined in /Hearts of Iron IV/common/country_tag_aliases, as a way to refer to a specific country (such as a side in a civil war) in addition to its actual tag. If the country with the exact tag doesn't exist, but a dynamic country originating from the specified tag does, the scope will refer to the dynamic country. | ✓ | 1.0 |
| <state_id> | Always usable | State scope | 123 = { transfer_state_to = SCO }
|
The state defined by this id. | ✓ | 1.0 |
| <character> | not within Character scope | Character scope | ENG_theodore_makhno = { set_nationality = UKR }
|
On game versions prior to 1.12.8, the character must be already recruited by the country this is scoped from. | ✓ | 1.11 |
| mio:<MIO> | Always usable | MIO scope | mio:AST_cockatoo_doe_organization = { … }
|
The MIO identified by that ID as defined within the /Hearts of Iron IV/common/military_industrial_organization/organizations/*.txt file. | ✓ | 1.13 |
| ROOT | Always usable | Depends on usage | ENG = {
FRA = {
GER = {
declare_war_on = {
target = ROOT
type = annex_everything
}
}
}
} #GER declares war on ENG (if there is no scope before ENG)
|
Targets the root node of the block, an inherent property of each block. Most commonly, this is the default scope: for example, ROOT within a national focus will always refer to the country doing the focus and ROOT within a event will always refer to the country getting the event. However, some blocks do distinguish between the default scope and ROOT, such as certain scripted GUI contexts or certain on actions. If a block doesn't have ROOT defined (such as on_startup in on actions), then it is impossible to use it. | ✓ | 1.0 |
| THIS | Always usable | Depends on usage | set_temp_variable = { target_country = THIS }
|
Targets the current scope where it's used. For example, when used in every_state, it will refer to the state that's currently being evaluated. Primarily useful for variables (as in the example, where omitting it wouldn't work) or for built-in localisation commands, where some scope must be specified. More rarely, this may help with scope manipulation when using PREV. Since omitting it makes no difference in how the code gets interpreted, there is little to no usage outside of these cases. | ✓ | 1.0 |
| PREV | Always usable | Depends on usage | FRA = {
random_country = {
GER = {
declare_war_on = {
target = PREV
type = annex_everything
}
}
}
} #Germany declares war on random_country
|
Targets the scope that the current scope is contained in. Can have additional applications where the assumed default scope differs from the ROOT, such as in state events or some on_actions. Can be chained indefinitely as PREV.PREV. Commonly results in broken-looking tooltips: what's shown to the player doesn't always correlate with reality. See also: PREV usage. |
✓ | 1.0 |
| FROM | Always usable | Depends on usage | declare_war_on = {
target = FROM
type = annex_everything
}
FROM = {
load_oob = defend_ourselves
}
|
Can be chained indefinitely as FROM.FROM. Used to target various hardcoded scopes inherent to the block, often a secondary scope in addition to ROOT. For example: In events, this refers to the country that sent the event (i.e. if the event was fired using an effect, then it's the ROOT scope where it was fired). |
✓ | 1.0 |
| overlord | Within country scope only | Country scope | overlord = { … }
|
The overlord of the country if it is a subject. Subject to the 'invalid event target' error. | X | 1.3 |
| faction_leader | Within country scope only | Country scope | faction_leader = { add_to_faction = FROM }
|
Faction leader of the faction the country is a part of. Subject to the 'invalid event target' error. | X | 1.10.1 |
| owner | Within state, character, or combatant scope only | Country scope | owner = { add_ideas = owns_this_state }
|
In state scope, the country that owns the state. In combatant scope, the country that owns the divisions. In character scope, the country that has recruited the character. Subject to the 'invalid event target' error when used for a state. | X | 1.0 |
| controller | Within state scope only | Country scope | controller = {
ROOT = {
create_wargoal = {
target = PREV
type = take_state_focus
generator = { 123 }
}
}
}
|
The controller of the current state. Subject to the 'invalid event target' error. | X | 1.0 |
| capital_scope | Within country scope only | State scope | capital_scope = { … }
|
The state where the capital of the current country is located in. Subject to the 'invalid event target' error in rare cases. | X | 1.0 |
| event_target:<event_target_key> | Always usable | Depends on usage | event_target:my_event_target = { … }
|
Saved event target or global event target, with no space after the colon. Subject to the 'invalid event target' error. | ✓ | 1.0 |
| var:<variable> | Always usable | Depends on usage | var:my_variable = { … }add_to_faction = my_variable or add_to_faction = var:my_variable
|
Variable set to a scope. When used as a target rather than a scope, the |
✓ | 1.5 |
Invalid event target
In regards to some dual scopes, a possible logged error to get while using them is "Invalid event target", as in common/national_focus/generic.txt:690: controller: invalid event target: controller, while the scope being used is not necessarily an event target.
This refers to the scope not having any defined target in the context that it is used, i.e. it is impossible to select any single target when it is used. In case of controller = { ... } as in the example, this means that the scope is checked or executed in a state that isn't controlled by any country. Such states are rather unstable and can cause crashes easily (such as if evaluated for an air mission by AI or if doing almost any effect on them), so if this happens for controller or owner, then this must be fixed only by making sure that every state has an owner or controller.
In practice, this gets skipped over entirely when evaluating the effects or triggers: none of the effects would be executed; as a trigger it'll not come up as either true or false. However, since this can be checked every tick, leaving it as is can result in cluttering the error log. To avoid this, it's possible to use the if statement in effects or triggers in such a manner that the dual scope would only be checked if the conditions for it existing are fulfilled, such as by checking that the country is indeed a subject before checking the overlord. An example of that being done is as such:
if = {
limit = {
is_subject = yes
}
overlord = {
country_event = example.0
}
}
While this has identical effects regardless of whether the country is independent or is a subject, this doesn't access the overlord scope for an independent country.
Trigger scopes
These can only be used as triggers; trying to use them as effects will result in nothing happening.
|
|
这部分内容可能已不适合当前版本,最后更新于1.13。 |
| Name | Usage | Target type | Example | Description | Version Added |
|---|---|---|---|---|---|
| all_country | Always usable | Country | all_country = { … }
|
Checks if all countries meet the triggers. | 1.0 |
| any_country | Always usable | Country | any_country = { … }
|
Checks if any country meets the triggers. | 1.0 |
| all_other_country | Within country scope only | Country | all_other_country = { … }
|
Checks if all countries other than the one where this scope is located meet the triggers. | 1.0 |
| any_other_country | Within country scope only | Country | any_other_country = { … }
|
Checks if any country other than the one where this scope is located meets the triggers. | 1.0 |
| all_country_with_original_tag | Always usable | Country | all_country_with_original_tag = {
original_tag_to_check = TAG #required
… #triggers to check
}
|
Checks if all countries originating from the specified country, including the dynamic countries created for civil wars and other purposes, meet the triggers. original_tag_to_check = TAG is used to specify the original tag.
|
1.9 |
| any_country_with_original_tag | Always usable | Country | any_country_with_original_tag = {
original_tag_to_check = TAG #required
… #triggers to check
}
|
Checks if any country originating from the specified country, including the dynamic countries created for civil wars and other purposes, meets the triggers. original_tag_to_check = TAG is used to specify the original tag.
|
1.9 |
| all_neighbor_country | Within country scope only | Country | all_neighbor_country = { … }
|
Checks if all countries that border the one where this scope is located meet the triggers. | 1.0 |
| any_neighbor_country | Within country scope only | Country | any_neighbor_country = { … }
|
Checks if any country that borders the one where this scope is located meets the triggers. | 1.0 |
| any_home_area_neighbor_country | Within country scope only | Country | any_home_area_neighbor_country = { … }
|
Checks if any country that borders the one where this scope is located, as well as being in its home area - meaning a direct land connection between the capitals of countries - meets the triggers. | 1.0 |
| all_guaranteed_country | Within country scope only | Country | all_guaranteed_country = { … }
|
Checks if all countries that are guaranteed by the one where this scope is located meet the triggers. | 1.9 |
| any_guaranteed_country | Within country scope only | Country | any_guaranteed_country = { … }
|
Checks if any country that is guaranteed by the one where this scope is located meets the triggers. | 1.9 |
| all_allied_country | Within country scope only | Country | all_allied_country = { … }
|
Checks if all countries that are allied with the one where this scope is located - meaning that they are either a subject of the country, its overlord, or that they share a faction - meet the triggers. Does not include the country itself. | 1.9 |
| any_allied_country | Within country scope only | Country | any_allied_country = { … }
|
Checks if any country that is allied with the one where this scope is located - meaning that they are either a subject of the country, its overlord, or that they share a faction - meets the triggers. Does not include the country itself. | 1.9 |
| all_occupied_country | Within country scope only | Country | all_occupied_country = { … }
|
Checks if all countries that are occupied by the one where this scope is located - meaning that the occupied country has core states controlled by the occupier country - meet the triggers. | 1.9 |
| any_occupied_country | Within country scope only | Country | any_occupied_country = { … }
|
Checks if any country that is occupied by the one where this scope is located - meaning that the occupied country has core states controlled by the occupier country - meets the triggers. | 1.9 |
| all_enemy_country | Within country scope only | Country | all_enemy_country = { … }
|
Checks if all countries that are at war with the one where this scope is located meet the triggers. | 1.9 |
| any_enemy_country | Within country scope only | Country | any_enemy_country = { … }
|
Checks if any country that are at war with the one where this scope is located meets the triggers. | 1.9 |
| all_subject_countries | Within country scope only | Country | all_subject_countries = { … }
|
Checks if all countries that are a subject of the one where this scope is located meet the triggers. Notice the plural spelling in the scope. | 1.11 |
| any_subject_country | Within country scope only | Country | any_subject_country = { … }
|
Checks if any country that is a subject of the one where this scope is located meets the triggers. | 1.11 |
| any_country_with_core | Within state scope only | Country | any_country_with_core = { … }
|
Checks if any country that has the current scope as a core state meets the triggers. Does not have an equivalent for other effect/trigger scope types. | 1.12 |
| all_state | Always usable | State | all_state = { … }
|
Check if all states meet the triggers. | 1.0 |
| any_state | Always usable | State | any_state = { … }
|
Check if any state meets the triggers. | 1.0 |
| all_neighbor_state | Within state scope only | State | all_neighbor_state = { … }
|
Check if all states that are neighbour to the one where this scope is located meet the triggers. | 1.0 |
| any_neighbor_state | Within state scope only | State | any_neighbor_state = { … }
|
Check if any state that is neighbour to the one where this scope is located meets the triggers. | 1.0 |
| all_owned_state | Within country scope only | State | all_owned_state = { … }
|
Check if all states that are owned by the country where this scope is located meet the triggers. | 1.0 |
| any_owned_state | Within country scope only | State | any_owned_state = { … }
|
Check if any state that is owned by the country where this scope is located meets the triggers. | 1.0 |
| all_core_state | Within country scope only | State | all_core_state = { … }
|
Check if any state that is cored by the country where this scope is located meets the triggers. | 1.11 |
| any_core_state | Within country scope only | State | any_core_state = { … }
|
Check if all states that are cored by the country where this scope is located meet the triggers. | 1.11 |
| all_controlled_state | Within country scope only | State | all_controlled_state = { … }
|
Check if all states that are controlled by the country where this scope is located meet the triggers. | 1.9 |
| any_controlled_state | Within country scope only | State | any_controlled_state = { … }
|
Check if any state that is controlled by the country where this scope is located meets the triggers. | 1.9 |
| all_unit_leader | Within country scope only | Unit Leader | all_unit_leader = { … }
|
Checks if all unit leaders (corps commanders, field marshals, admirals) that are employed by the country where this scope is located meet the triggers. | 1.5 |
| any_unit_leader | Within country scope only | Unit Leader | any_unit_leader = { … }
|
Checks if any unit leader (corps commander, field marshal, admiral) that is employed by the country where this scope is located meets the triggers. | 1.5 |
| all_army_leader | Within country scope only | Unit Leader | all_army_leader = { … }
|
Checks if all army leaders that are employed by the country where this scope is located meet the triggers. | 1.5 |
| any_army_leader | Within country scope only | Unit Leader | any_army_leader = { … }
|
Checks if any army leader that is employed by the country where this scope is located meets the triggers. | 1.5 |
| all_navy_leader | Within country scope only | Unit Leader | all_navy_leader = { … }
|
Checks if all navy leaders that are employed by the country where this scope is located meet the triggers. | 1.5 |
| any_navy_leader | Within country scope only | Unit Leader | any_navy_leader = { … }
|
Checks if any navy leader that is employed by the country where this scope is located meets the triggers. | 1.5 |
| all_operative_leader | Within country scope or operations only | Operative | all_operative_leader = { … }
|
Checks if all operatives that are employed by the country where this scope is located meet the triggers. | 1.9 |
| any_operative_leader | Within country scope or operations only | Operative | any_operative_leader = { … }
|
Checks if any operative that is employed by the country where this scope is located meets the triggers. | 1.9 |
| all_character | Within country scope only | Character | all_character = { … }
|
Checks if all characters that are recruited by the country where this scope is located meet the triggers. | 1.11 |
| any_character | Within country scope only | Character | any_character = { … }
|
Checks if any character that is recruited by the country where this scope is located meets the triggers. | 1.11 |
| any_country_division | Within country scope only | Division | any_country_division = { … }
|
Checks if any division owned by the current country meets the triggers. | 1.12 |
| any_state_division | Within state scope only | Division | any_state_division = { … }
|
Checks if any division within the current state meets the triggers. | 1.12 |
| all_military_industrial_organization | Within country scope only | MIO | all_military_industrial_organization = { … }
|
Checks if all MIOs within the current country meet the conditions. | 1.13 |
| any_military_industrial_organization | Within country scope only | MIO | any_military_industrial_organization = { … }
|
Checks if any MIO within the current country meets the conditions. | 1.13 |
| all_purchase_contract | Within country scope only | Purchase contract | all_purchase_contract = { … }
|
Checks if all purchase contracts within the current country meet the conditions. | 1.13 |
| any_purchase_contract | Within country scope only | Purchase contract | any_purchase_contract = { … }
|
Checks if any purchase contract within the current country meets the conditions. | 1.13 |
Effect scopes
These can only be used as effects; trying to use them as triggers will result in nothing happening.
|
|
这部分内容可能已不适合当前版本,最后更新于1.13。 |
| Name | Usage | Target type | Example | Description | Version Added |
|---|---|---|---|---|---|
| every_possible_country | Always usable | Country | every_possible_country = { ... }
|
Executes children effects on every country that meets the limit, including those that do not exist. | 1.11 |
| every_country | Always usable | Country | every_country = { … }
|
Executes contained effects on every country that meets the limit. | 1.0 |
| random_country | Always usable | Country | random_country = { … }
|
Executes contained effects on a random country that meets the limit. | 1.0 |
| every_other_country | Within country scope only | Country | every_other_country = { … }
|
Executes contained effects on every country that meets the limit and is not the same country as the one this is contained in. | 1.0 |
| random_other_country | Within country scope only | Country | random_other_country = { … }
|
Executes contained effects on a random country that meets the limit and is not the same country as the one this is contained in. | 1.0 |
| every_country_with_original_tag | Always usable | Country | every_country_with_original_tag = {
original_tag_to_check = TAG #required
… #effects to run
}
|
Executes contained effects on every country that meets the limit and has the specified original tag. | 1.9 |
| random_country_with_original_tag | Always usable | Country | random_country_with_original_tag = {
original_tag_to_check = TAG #required
… #effects to run
}
|
Executes contained effects on a random country that meets the limit and has the specified original tag. | |
| every_neighbor_country | Within country scope only | Country | every_neighbor_country = { … }
|
Executes contained effects on every country that meets the limit and borders the country this is contained in. | 1.0 |
| random_neighbor_country | Within country scope only | Country | random_neighbor_country = { … }
|
Executes contained effects on a random country that meets the limit and borders the country this is contained in. | 1.0 |
| every_occupied_country | Within country scope only | Country | every_occupied_country = { … }
|
Executes contained effects on every country that meets the limit and has any core states controlled by the country this is contained in. | 1.9 |
| random_occupied_country | Within country scope only | Country | random_occupied_country = { … }
|
Executes contained effects on a random country that meets the limit and has any core states controlled by the country this is contained in. | 1.9 |
| every_enemy_country | Within country scope only | Country | every_enemy_country = { … }
|
Executes contained effects on every country that meets the limit and is at war with the country this is contained in. | 1.0 |
| random_enemy_country | Within country scope only | Country | random_enemy_country = { … }
|
Executes contained effects on a random country that meets the limit and is at war with the country this is contained in. | 1.0 |
| every_subject_country | Within country scope only | Country | every_subject_country = { … }
|
Executes contained effects on every country that meets the limit and is a subject of the country this is contained in. | 1.11 |
| random_subject_country | Within country scope only | Country | random_subject_country = { … }
|
Executes contained effects on a random country that meets the limit and is a subject of the country this is contained in. | 1.11 |
| every_state | Always usable | State/s | every_state = { … }
|
Executes contained effects on every state that meets the limit. | 1.0 |
| random_state | Always usable | State | random_state = {
prioritize = { 123 321 } #optional
… #effects to run
}
|
Executes contained effects on a random state that meets the limit. | 1.0 |
| every_neighbor_state | Within state scope only | State | every_neighbor_state = { … }
|
Executes contained effects on every state that meets the limit and neighbours the state this is contained in. | 1.0 |
| random_neighbor_state | Within state scope only | State | random_neighbor_state = { … }
|
Executes contained effects on a random state that meets the limit and neighbours the state this is contained in. Does not support prioritizing. | 1.0 |
| every_owned_state | Within country scope only | State | every_owned_state = { … }
|
Executes contained effects on every state that meets the limit and is owned by the country this is contained in. | 1.0 |
| random_owned_state | Within country scope only | State | random_owned_state = {
prioritize = { 123 321 } #optional
… #effects to run
}
|
Executes contained effects on a random state that meets the limit and is owned by the country this is contained in. | 1.0 |
| every_core_state | Within country scope only | State | every_core_state = { … }
|
Executes contained effects on every state that meets the limit and is a core of the country this is contained in. | 1.11 |
| random_core_state | Within country scope only | State | random_core_state = {
prioritize = { 123 321 } #optional
… #effects to run
}
|
Executes contained effects on a random state that meets the limit and is a core of the country this is contained in. | 1.11 |
| every_controlled_state | Within country scope only | State | every_controlled_state = { … }
|
Executes contained effects on every state that meets the limit and is controlled by the country this is contained in. | 1.9 |
| random_controlled_state | Within country scope only | State | random_controlled_state = {
prioritize = { 123 321 } #optional
… #effects to run
}
|
Executes contained effects on a random state that meets the limit and is controlled by the country this is contained in. | 1.9 |
| random_owned_controlled_state | Within country scope only | State | random_owned_controlled_state = {
prioritize = { 123 321 } #optional
… #effects to run
}
|
Executes contained effects on a random state that meets the limit and is owned and controlled by the country this is contained in. | 1.3 |
| every_unit_leader | Within country scope only | Unit Leader | every_unit_leader = { … }
|
Executes contained effects on every unit leader (corps commanders, field marshals, admirals) that meets the limit and is recruited by the country this is contained in. | 1.5 |
| random_unit_leader | Within country scope only | Unit Leader | random_unit_leader = { … }
|
Executes contained effects on a random unit leader (corps commanders, field marshals, admirals) that meets the limit and is recruited by the country this is contained in. | 1.5 |
| every_army_leader | Within country scope only | Unit Leader | every_unit_leader = { … }
|
Executes contained effects on every army leader that meets the limit and is recruited by the country this is contained in. | 1.5 |
| random_army_leader | Within country scope only | Unit Leader | random_army_leader = { … }
|
Executes contained effects on a random army leader that meets the limit and is recruited by the country this is contained in. | 1.5 |
| global_every_army_leader | Always usable | Unit Leader | global_every_army_leader = { … }
|
Executes contained effects on every army leader that meets the limit. Preferable to use every_army_leader unless necessary to use global_every_army_leader. | 1.5 |
| every_navy_leader | Within country scope only | Unit Leader | every_navy_leader = { … }
|
Executes contained effects on every navy leader that meets the limit and is recruited by the country this is contained in. | 1.5 |
| random_navy_leader | Within country scope only | Unit Leader | random_navy_leader = { … }
|
Executes contained effects on a random navy leader that meets the limit and is recruited by the country this is contained in. | 1.5 |
| every_operative | Within country scope or operations only | Operative | every_operative = { … }
|
Executes contained effects on every operative that meets the limit and is recruited by the country this is contained in. | 1.9 |
| random_operative | Within country scope or operations only | Operative | random_operative = { … }
|
Executes contained effects on a random operative that meets the limit and is recruited by the country this is contained in. | 1.9 |
| every_character | Within country scope only | Character | every_character = { … }
|
Executes contained effects on every character that meets the limit and is recruited by the country this is contained in. | 1.11 |
| random_character | Within country scope only | Character | random_character = { … }
|
Executes contained effects on a random character that meets the limit and is recruited by the country this is contained in. | 1.11 |
| every_country_division | Within country scope only | Division | every_country_division = { … }
|
Executes contained effects on every division that meets the limit and is owned by the current country. | 1.12 |
| random_country_division | Within country scope only | Division | random_country_division = { … }
|
Executes contained effects on a random division that meets the limit and is owned by the current country. | 1.12 |
| every_state_division | Within state scope only | Division | every_state_division = { … }
|
Executes contained effects on every division that meets the limit and is located within the current state. | 1.12 |
| random_state_division | Within state scope only | Division | random_state_division = { … }
|
Executes contained effects on a random division that meets the limit and is located within the current state. | 1.12 |
| every_military_industrial_organization | Within country scope only | MIO | every_military_industrial_organization = { … }
|
Executes contained effects on every MIO within the current country that meets the limit. | 1.13 |
| random_military_industrial_organization | Within country scope only | MIO | random_military_industrial_organization = { … }
|
Executes contained effects on a random MIO within the current country that meets the limit. | 1.13 |
| every_purchase_contract | Within country scope only | Purchase contract | every_purchase_contract = { … }
|
Executes contained effects on every purchase contract within the current country that meets the limit. | 1.13 |
| random_purchase_contract | Within country scope only | Purchase contract | random_state_division = { … }
|
Executes contained effects on a random purchase contract within the current country that meets the limit. | 1.13 |
| party_leader | Within country scope only | Character | party_leader = {
limit = {
has_ideology = liberalism
}
set_nationality = BHR
}
|
Executes the effects on the party leader with the specified ideology type. Must contain a has_ideology in the limit that refers to a specific ideology type (e.g. Despotic), not a group that contain the type (e.g. Non-Aligned). The selected character must be the leader of a party corresponding to the ideology group.
|
1.11 |
NOTE: Some of these scopes may have no countries/states that match the criteria
Effects with scopes
There are the following effects that also change the currently-selected scope:
| Name | Parameters | Examples | Description | Notes | Version Added |
|---|---|---|---|---|---|
| start_civil_war | ideology = <ideology>The ideology of the breakaway country.
|
start_civil_war = {
ruling_party = communism
# Original country's ideology changes to communism
ideology = ROOT
# Breakaway gets old ideology of ROOT
size = 0.8
capital = 282
states = {
282 533 536 555 529 530 528
}
keep_unit_leaders = {
750 751 752
}
keep_political_leader = yes
keep_political_party_members = yes
}
start_civil_war = {
ideology = democratic
size = 0.1
states = all
states_filter = {
is_on_continent = europe
is_capital = no
}
set_country_flag = TAG_my_country_tag_alias_trigger
# Sets a country flag that gets used in a country tag alias.
}
start_civil_war = {
ideology = neutrality
size = 0.1
army_ratio = 0.5
navy_ratio = 0
air_ratio = 1
keep_unit_leaders_trigger = {
has_trait = my_trait_name
}
keep_all_characters = yes
PREV = { # Original country
TAG_airforce_leader = { # Character
set_nationality = PREV.PREV
# Transfers to breakaway
}
}
promote_character = TAG_airforce_leader
}
|
Within country scope: starts a civil war for the current scope with the specified parameters, changing the scope to the dynamic country. | states = all would include every single state controlled by the country. If the country's current capital state is set as one of the states that the revolt can gain, it won't fire. set_capital can be used to change the capital beforehand, with On_actions#on_civil_war_end being used to set it back to the default after the civil war ends.
|
1.0 |
| create_dynamic_country | original_tag = <tag>The original tag to be used by the country.
|
create_dynamic_country = {
original_tag = POL
copy_tag = SOV
add_political_power = 100
transfer_state = 123
}
|
Within country scope: Creates a new dynamic country, akin to ones used in civil wars, adding every core of the original tag as core and changing the scope to the dynamic country. | The reserve_dynamic_country effect can be used if the dynamic country does not yet exist in order to ensure that it does not get overwritten by other creations of dynamic countries. | 1.9 |
Array scopes
- 参见:Arrays
Arrays can be used to create a generic selection of scopes meeting the criteria. These scopes exist for checking conditions on elements of an array or executing effects on them:
| Name | Type | Parameters | Examples | Description | Notes |
|---|---|---|---|---|---|
| any_of_scopes | Trigger | array = <array>The array to check.
|
any_of_scopes = {
array = global.majors
tooltip = has_more_states_than_any_other_major_tt
NOT = { tag = PREV }
check_variable = { num_owned_controlled_states > PREV.num_owned_controlled_states }
}
|
Checks if any value within the array fulfills the triggers, halting and returning true if that's the case, scoping into each element in the array. | Appending _NOT to the tooltip's key (such as has_more_states_than_any_other_major_tt_NOT in the example) results in the localisation key used if this any_of_scopes is put inside of NOT = { ... }.
|
| all_of_scopes | Trigger | array = <array>The array to check.
|
all_of_scopes = {
array = global.majors
tooltip = has_more_states_than_every_other_major_tt
OR = {
tag = PREV
check_variable = { num_owned_controlled_states < PREV.num_owned_controlled_states }
}
}
|
Checks if every value within the array fulfills the triggers, halting and returning false if any one doesn't, scoping into each element in the array. | Appending _NOT to the tooltip's key (such as has_more_states_than_every_other_major_tt_NOT in the example) results in the localisation key used if this any_of_scopes is put inside of NOT = { ... }.
|
| for_each_scope_loop | Effect | array = <array>The array to check.
|
for_each_scope_loop = {
array = global.majors
if = {
limit = {
NOT = { tag = ROOT }
}
random_owned_controlled_state = {
transfer_state_to = ROOT
}
}
}
|
Runs the effects for every scope within the array. | Equivalent to a every_<...> effect scope type, with additional break.
|
| random_scope_in_array | Effect | array = <array>The array to check.
|
random_scope_in_array = {
array = global.countries
break = break
limit = {
is_dynamic_country = no
exists = no
any_state = {
is_core_of = PREV # Is core of the currently-checked country
}
}
random_core_state = {
transfer_state_to = PREV # Transfers to the currently-selected country.
}
}
|
Runs the effects for a random scope within the array. | Equivalent to a random_<...> effect scope type, with additional break.
|
PREV usage
In order to understand PREV, it can be helpful to think back to the trigger/effect scopes such as every_controlled_state. In this case, if put inside directly, PREV can be used as the controller of the state. In fact, every_controlled_state is equivalent to every_state with a limit of is_controlled_by = PREV in most ways, although it is recommended to use every_controlled_state instead as it is better for optimisation. For example, the following will transfer every state to its controller, changing the owner:
every_country = {
every_controlled_state = {
transfer_state_to = PREV
}
}If thinking of it as a tree, the scopes are in the order of [every_country,every_controlled_state]. Using it within every_controlled_state will refer back to the parent node, or every_country, specifically the country in the every_country list this is currently being executed for. This can be used in other ways, such as obtaining a wargoal against the owner of a state:
123 = {
owner = {
ROOT = {
create_wargoal = {
target = PREV
type = take_state_focus
generator = { 123 }
}
}
}
}
In this case, the tree is constructed with [123,owner,ROOT]. Using PREV within ROOT will refer to the previously-defined owner.
Chaining PREV can be done by separating them with a dot as PREV.PREV.PREV. This can be useful if the needed scope is more than 1 scope back.
This is an another example of PREV usage with an attached diagram showing how they connect to other scopes:
every_country = {
limit = {
any_country = {
any_country = {
has_war_with = PREV
is_neighbor_of = PREV.PREV
}
has_attache_from = PREV
}
}
country_event = my_event.0
}
In this case, an event will be sent to every country that has sent an attaché to a country that's at war with a neighbour of the original country (i.e. the country that would receive the event). Using PREV.PREV is necessary in this case as all 3 countries don't have single defined tags or pointers and all interact with each other.
In many cases, using PREV can result in seemingly broken tooltips which'll work fine regardless when executing the effects in-game. This typically happens when using it pointing to scopes of the every_<...>/all_<...> types. A single effect or trigger's tooltip can only show one scope as a target at once, and the game would only pick the first possible scope in the tooltip. This can look like the following:
- (Sardinia, Corsica, Sicily):
- 重定向 Template:国旗:
- Becomes owner and controller of Sardinia
This can not be avoided with traditional means while still using PREV. Instead, it's possible to use hidden_effect and custom_effect_tooltip or custom_trigger_tooltip in order to completely replace the tooltip in this case.
Flow control tools
While these aren't scopes, not changing where the effects are run or triggers are checked, they still function as blocks of code that can be used within any trigger and/or effect.
| Script | Usage | Example | Description | Notes |
|---|---|---|---|---|
| AND | Within triggers | AND = {
original_tag = GER
has_stability > 0.5
}
|
Returns false if any sub-trigger returns false, true otherwise. Evaluation stops at the first false sub-trigger. Nearly all trigger blocks (including scopes) use AND by defaults, so its primary use is with OR and NOT, which affects their function. |
Usually modifies trigger tooltips to include "All of the following must be true" |
| OR | Within triggers | OR = {
original_tag = ENG
original_tag = USA
}
|
Returns true if any sub-trigger returns true, false otherwise. Evaluation stops at the first true sub-trigger.
By default, OR checks each contained trigger separately, AND can be used in order to check between groups of triggers. |
Usually modifies trigger tooltips to include "One of the following must be true" |
| NOT | Within triggers | NOT = {
has_stability > 0.5
has_war_support > 0.5
}
|
Returns false if any sub-trigger returns true, true otherwise. Evaluation stops at the first true sub-trigger. This is equivalent to logical NOR, as it returns true only if all contained triggers are false. |
NOT also allows emulating greater/less than or equals in comparisions that are normally strictly greater or less than.
NOT usually inverts trigger tooltips, though not always predictably or neatly. The inverted tooltip for scopes or |
| count_triggers | Within triggers | count_triggers = {
amount = 2
10 = { state_population_k > 100 }
11 = { state_population_k > 100 }
12 = { state_population_k > 100 }
}
|
Returns true if the number of contained triggers which return true is greater than or equal to the value of amount
|
|
| custom_trigger_tooltip | Within triggers | custom_trigger_tooltip = {
tooltip = sunrise_invasion_tt
any_state = {
is_owned_by = JAP
is_on_continent = europe
is_coastal = yes
}
}
|
Replaces the tooltips from all contained triggers with the custom localisation set by tooltip
|
If the custom_trigger_tooltip is negated (within NOT or a <scripted_trigger> = no, the negated tooltip can be customized by appending _NOT to the localisation key of the tooltip (e.g. sunrise_invasion_tt_NOT).
|
| effect_tooltip | Within effects | effect_tooltip = {
declare_war_on = {
target = FROM
type = annex_everything
}
}
|
Shows the tooltips of the contained effects, but does not execute them. | Most often useful with event chains, where the actual effect is done in a follow-up event. |
| if | Always usable | if = {
limit = {
original_tag = GER
}
has_political_power > 100
}
else_if = {
limit = {
original_tag = ENG
}
has_stability > 0.5
}
else = {
has_war_support > 0.5
}
|
If statements allow to conditionally check triggers or run effects. The limit block is used to define triggers that must be fulfilled for the effects to be run or triggers to be checked. The triggers in limit are never shown to the player: if they are unfulfilled, the if statement will have no tooltip, while, if fulfilled, the player will see the effects/triggers inside the if statement itself.
In addition, |
else_if is optional and can be used as many times as desired. else is also optional, but can only be used once per if.The main |
| for_loop_effect | Within effects | for_loop_effect = {
start = -3
end = 9
compare = less_than_or_equals
add = 3
value = value_name
break = break_name
add_political_power = value_name # Adds -3, then 0, then 3, then 6, then 9, after which the loop breaks for 15 total political power.
}
|
Runs the effect in a typical for loop, with the current value of the variable kept with the temp variable specified with value. break defines a temp variable that can be set to 1 to break the loop instantly.
|
If unspecified, start and end are 0, compare is less_than, add is 1, value is v, and break is break. Can run for up to 1000 times before stopping automatically.
|
| while_loop_effect | Within effects | while_loop_effect = {
break = temp_break
limit = {
country_exists = GER
}
random_state = {
limit = {
is_owned_by = GER
}
random_country = {
limit = {
NOT = { tag = GER }
}
transfer_state = PREV
}
}
}
|
Runs the effect as long as the trigger is true. break defines a temp variable that can be set to 1 to break the loop instantly.
|
The trigger is checked at the start of each loop only. Can run for up to 1000 times before stopping automatically. If break is unspecified, assumes to be a temp variable with the name of break.
|
| random | Within effects | random = {
chance = 80
add_stability = 0.8
}
|
Simulates a random chance to either execute the effect or do nothing, with the chance used to define the chance.
|
Chance is defined on the scale from 0 to 100. |
| random_list | Within effects | random_list = {
10 = {
modifier = {
factor = 0
has_stability > 0.9
}
add_stability = 0.1
}
20 = {
add_stability = -0.1
}
}
|
Simulates a random chance to pick one of the listed effects. | Chance for each section is proportional, doesn't have to add up to 100. Can use a variable as a chance. Modifiers can be used in the same way as in ai_will_do blocks. |
| 文件 | 效果 • 条件 • 定义 • 修正 • 修正列表 • 作用域 • 本地化 • on action • 数据结构 (标记, 临时标记, 国家别名, 变量, 数组) |
| 脚本 | 成就修改 • AI修改 • AI focuses • 自治领修改 • 权力平衡修改 • 剧本/标签 (游戏规则)• 建筑修改 • 人物修改 • 修饰性TAG修改 • 国家创建 • 军队修改 • 决议制作 • 装备修改 • 事件修改 • Idea修改 • 意识形态修改 • 军工商修改 • 国策制作 • 资源修改 • Scripted GUI • 科技制作 • 单位修改 |
| 地图 | 地图 • 省份 • 补给区域 • 战略区域 |
| 图形图像 | 界面 • 图形资产 • 实体模型 • 后期特效 • 粒子效果 • 字体 |
| 装饰性 | 肖像 • 命名列表 • 音乐包制作 • 音效 |
| 其他 | 控制台指令 • 故障排除 • 模组结构 • 成就代码分析 • Mod相关 • Nudger修改 |
