执行:修订间差异

本页面所适用的版本可能已经过时,最后更新于1.12
(merge from offical wiki)
 
(调整了目录和代码块缩进)
 
(未显示4个用户的11个中间版本)
第1行: 第1行:
{{Version|1.9}}
{{Version|1.12}}


== Miscellaneous ==
代码在一个特定的行动发生后被执行,例如当一个国家向另一个国家宣战或者当一个省份变更控制权时触发某种效果。On actions被定义在 {{path|common/on_actions/*.txt}}文件中。
 
__TOC__
 
每一个on action都是一个被包含在<code>on_actions = { ... }</code>代码中,也就是on actions文件的根代码块中的独立代码块。每一个on_action最多有2个参数:
* <code>effect = { ... }</code>存在于每一个单独的on action中,在需要时作为一个效果执行内效果代码。
* <code>random_events = { ... }</code> 用于on_actions中,其默认作用域(如果没有另行指定,则与ROOT相同)是一个国家,例如<code>on_new_term_election</code>。这将立即随机触发给定权重的指定事件中的事件之一。这是通过概率与权重成正比的随机方法完成的。
: 用<code>0</code>代替事件ID将确保如果随机到该事件时不会有任何事情发生。
: 另外,当一个事件的<code>trigger = { ... }</code>代码块计算结果为false(即不满足触发条件)时,该事件不会被<code>random_events = { ... }</code>触发。在这种情况下,每个作用域的处理方式与on action的相同:on action的FROM被视为该事件的FROM,对于<code>FROM.FROM</code>也是一样(注:FROM与上文的ROOT相同,都是指代码的[[Scopes|作用域]],但是在大部分情况下意义不同)。
: 如果存在多个<code>random_events</code>代码,将从每个块中选择一个事件。
 
请注意,就[[Scopes|作用域]]而言,ROOT是默认的假定作用域,除非另有指定(在<code>on_actions</code>中,THIS作为一个独立于ROOT的实体),而FROM和FROM.FROM可以作为另外提供的辅助块。
 
每个on action只能在游戏开始后执行,不受任何通常会触发一次的来自历史文件或剧本的<code>effects = { ... }</code>部分的效果所影响,例如[[Effect#set_politics|set_politics]]。
 
{{red|'''<big>再次强调:本篇wiki下文所指的ROOT、THIS、FROM、PREV等相关代码,都是指代码的[[Scopes|作用域]](类似于函数的定义域,确定代码的适用范围的代码)</big>'''}}
== 文件示例 ==
<pre>on_actions = {
   on_startup = {
     effect = { # NEVER FORGET! Important to include this line to distinguish it from random_events = { ... }
       every_country = {
         limit = {
           is_ai = no
         }
         country_event = welcome_event.1
       }
       ENG = {
         country_event = {
           id = new_year.1
           days = 365  # Fires on January 1 1937. Remember that leap days do not exist in-game.
         }
       }
     }
   }
   on_state_control_changed = {
     random_events = {
       1 = germany_state_control.1 # Assuming the triggers for the events are met, then
       1 = germany_state_control.2 # fires one of germany_state_control.1 or germany_state_control.2
       3 = 0            # Each has a 20% chance, and there's 60% chance nothing happens.
     }
     effect = {
       if = {
         limit = {  # Execute if Italy captures Corsica or Savoy from France
           tag = ITA
           FROM = { tag = FRA }
           FROM.FROM = {
             OR = {
               state = 1
               state = 735
             }
           }
         }
         FROM.FROM = {
           set_resistance = 60
           damage_building = {
             type = infrastructure
             damage = 2
           }
         }
       }
     }
   }
}</pre>
 
== 常见的on_actions代码 ==
{| class="wikitable sortable" width="100%"
{| class="wikitable sortable" width="100%"
! width="10%" | Name
! width="10%" | 名字
! width="20%" | Description
! width="20%" | 描述
! width="25%" | Examples
! width="25%" | 示例
! width="15%" | Notes
! width="15%" | 提示
! width="5%" | Version Added
! width="5%" | 版本
|-
|-id="on_startup"
|on_startup
|on_startup
|Trigger the following commands at the first day of a new game (doesn't work with save loading).
| 在游戏开局(新的一局开始的时候)时触发一次效果。'''但是加载存档时不触发该效果。'''
|<code>on_startup = { effect = { ... } }</code>
|<pre>on_startup = { 
|
   effect = {
|1.0
     ENG = {
|-
       news_event = { id = news_event.1 days = 31 random_days = 27 }
       # Fires a news event in February 1936
     }  # assuming the default start date
   }    # Scoping into ENG is necessary, since
}      # news_event is a country-scoped effect</pre>
|'''默认作用域为<code>none</code>''',而不是像其他P社游戏(如《欧陆风云4》)那样针对每个国家单独触发。如果没有手动将作用域划分到国家、省份或其他地方,许多通常可以在任何[[scopes| 作用域]]内使用的效果将无法工作。
|1.3.3
|-id="on_daily"
|on_daily
|on_daily
|Triggers each day for every country separately (performance heavy, use carefully)
| 在每一天为每个国家分别触发效果'''( 对性能的影响大,请谨慎使用) 。'''
|<code>on_daily = { effect = { ... } }</code>
|<pre>on_daily = {
|Useful for scripted guis and mods adding new mechanics (can increment a variable daily e.g.).
   effect = {
     if = {
       limit = { has_variable = to_be_updated_daily }
       add_to_variable = { to_be_updated_daily = 1 }
    
   }
}</pre>
| 对于scripted guis 和添加新机制的mod非常有用( 例如可以每天增加一个变量) 。'''只有在小心避免重复效果的情况下才使用该作用域。'''在每个国家单独执行意味着本质上相当于在每个国家每一天执行一个单独的效果。例如 <code>effect = { GER = { add_political_power = 100 } }</code>将每天增加约100政治点数到{{flag|Germany}} ,因为世界地图上有约100个国家,这意味着每天将执行约100次。
|1.5.2
|1.5.2
|-
|-id="on_daily_TAG"
|on_daily_<TAG>
|每天为指定国家触发效果'''(注:TAG就是你要指定的国家)'''
|<pre>on_daily_SOV = {
   effect = { 
     if = {
       limit = { has_war_with = GER }
       SOV_escalate_the_war_effect = yes
     }
   }
}</pre>
|只有在国家存在的前提条件下才能触发该效果,否则无效
|1.9
|-id="on_weekly"
|on_weekly
|on_weekly
|Triggers each week for every country separately
| 每周为每个国家触发一次效果
|<code>on_weekly = { effect = { ... } }</code>
|<pre>on_weekly = {
|Useful for ai scripting.
   effect = {
     if = {
       limit = {
         has_intelligence_agency = yes
         is_ai = yes
       }
       update_operation_ai = yes
     }
   }
}
</pre>
| 对ai脚本很有用。如果<code>num_days_variable</code>能被7整除,则在这一天的开始运行。
|1.9
|1.9
|-
|-id="on_weekly_TAG"
|on_weekly_TAG
|on_weekly_<TAG>
|Triggers TAG country weekly
| 每周为指定国家触发一次效果'''(注:TAG就是你要指定国家)'''
|<code>on_weekly_TAG = { effect = { ... } }</code>
|<pre>on_weekly_BHR = {
|
   if = {
     limit = {
       has_country_flag = BHR_must_control_states
       any_owned_state = {
         NOT = { is_controlled_by = ROOT }
       }
       has_stability < 0.5
     }
     country_event = BHR_event.0
     clr_country_flag = BHR_must_control_states
   }
}</pre>
| 只有在该国家存在的情况下才执行效果。如果<code>num_days_variable</code>能被7整除,则在这一天的开始运行。
|1.9
|1.9
|-
|-id="on_monthly"
|on_monthly
|on_monthly
|Triggers each month for every country separately
| 在每月为每个国家分别触发效果。
|<code>on_monthly = { effect = { ... } }</code>
|<pre>on_monthly = { 
   random_events = {
     1 = random_event.0
     99 = 0
   }
}</pre>
|
|
|1.9
|1.9
|-
|-id="on_monthly_TAG"
|on_monthly_TAG
|on_monthly_<TAG>
|Triggers TAG country monthly
| 在每月为指定国家触发一次效果'''(注:TAG就是你要指定的国家)'''。
|<code>on_monthly_TAG = { effect = { ... } }</code>
|<pre>on_monthly_USA = {
|
   effect = {
|1.9
     add_to_variable = { USA_unrest = 1 }
|-
     clamp_variable = {
|on_nuke_drop
       var = USA_unrest
|Trigger the following commands whenever a country drops a nuke.
       max = 10
|<code>on_nuke_drop = { effect = { set_global_flag = first_nuke_dropped } }</code>
     }
|FROM is the nuked state.
     if = {
|1.0
       limit = { 
|-
         check_variable = { USA_unrest = 10 }
|on_pride_of_the_fleet_sunk
       }
|Triggers when a country's pride of the fleet is sunk
       country_event = usa.rebellion.0
|<code>on_pride_of_the_fleet_sunk = { effect = { ... } }</code>
     }
|FROM is the killer country, ROOT is the country of that lost its pride of the fleet.
   }
|1.6
}</pre>
|-
| 只有在该国家存在的前提条件下才能执行该效果,否则无效。
|on_naval_invasion
|Triggers the following commands whenever a sea invasion is made.
|<code>on_naval_invasion = { effect = { ... } }</code>
|THIS state that is invaded, ROOT country that invades, FROM state that the invasion started
|1.9
|-
|on_paradrop
|Triggers the following commands whenever a landing occurs.
|<code>on_paradrop = { effect = { ... } }</code>
|THIS state that is invaded, ROOT country that invades, FROM state that the invasion started
|1.9
|1.9
|}
|}


== Politics ==
== 政治相关 ==
{| class="wikitable sortable" width="100%"
{| class="wikitable sortable" width="100%"
! width="10%" | Name
! width="10%" | 名字
! width="20%" | Description
! width="20%" | 描述
! width="25%" | Examples
! width="25%" | 示例
! width="15%" | Notes
! width="15%" | 提示
! width="5%" | Version Added
! width="5%" | 版本
|-
|-id="on_stage_coup"
|on_stage_coup
|对没有{{icon|lar|1}}DLC的国家策划政变使用,每当政变策划时,触发以下效果。
|<pre>on_stage_coup = {
   effect = {
   }
}</pre>
|ROOT是策划政变的国家,FROM是目标国家。
|1.0
|-id="on_coup_succeeded"
|on_coup_succeeded
|on_coup_succeeded
|Trigger the following commands whenever a coup succeeds.
| 对没有{{icon|lar|1}}DLC的国家策划政变使用,每当政变成功时,触发以下效果。
|<code>on_coup_succeeded = { effect = { random_other_country = { limit = { has_government = democratic original_tag = ROOT } set_politics = { elections_allowed = yes } } } }</code>
|<pre>on_coup_succeeded = { 
|
   effect = { 
     random_other_country = { 
       limit = { 
         has_government = democratic
         original_tag = ROOT
      
       set_politics = { elections_allowed = yes }
     }
   }
}</pre>
|ROOT是政变成功的国家,FROM是策划政变的国家。
|1.0
|1.0
|-
|-id="on_government_change"
|on_government_change
|on_government_change
|Trigger the following commands whenever a country switch government.
| 每当一个国家更换政府时,触发以下效果。
|<code>on_government_change = { effect = { ... } }</code>
|<pre>on_government_change = { effect = { &hellip;  } }</pre>
|
|这包括<code>set_politics</code>和<code>start_civil_war</code>(总是为双方),不包括被傀儡的情况。总是同时触发[[#on_ruling_party_change|on_ruling_party_change]]效果.
|1.0
|1.0
|-
|-id="on_ruling_party_change"
|on_ruling_party_change
|on_ruling_party_change
|Trigger the following commands whenever a country switch ideology.
| 每当某个国家改变其意识形态时,触发以下命令。
|<code>on_ruling_party_change = { effect = { ... } }</code>
|<pre>on_ruling_party_change = { effect = { &hellip;  } }</pre>
|
|<code>old_ideology_token</code>是一个临时变量,,它将旧的意识形态存储为token。除了包括触发[[#on_government_change|on_government_change]]的效果外,还包括被傀儡或通过[[Variables#Variable types| 控制台命令]]改变意识形态的情况。
|1.9
|1.9
|-
|-id="on_new_term_election"
|on_new_term_election
|on_new_term_election
|Trigger the following commands whenever an election happen or is called by the '''hold_election''' command.
| 每当发生选举或被'''hold_election''' 命令调用时,触发效果。
|<code>on_new_term_election = { random_events = { 100 = usa.6 } }</code>
|<pre>on_new_term_election = { random_events = { 100 = usa.6 } }</pre>
|
|
|1.0
|1.0
|-
|-id="on_peaceconference_ended"
|on_peaceconference_ended
|on_peaceconference_ended
|Trigger the following commands whenever a peace conference ends.
| 每当和平会议结束时,触发效果。
|<code>on_peaceconference_ended = { effect = {...} }</code>
|<pre>on_peaceconference_ended = { effect = { &hellip; } }</pre>
|ROOT is the winner, FROM is the loser.
|ROOT是赢家(胜利者),FROM是输家(失败方)。也会在使用<pre>white_peace</pre>效果或接受有条件投降时触发。
|1.0
|1.5
|-id="on_peaceconference_started"
|on_peaceconference_started
|每当和平会议开始时,触发以下命令。
|<pre>on_peaceconference_started = { effect = { &hellip; } }</pre>
|ROOT 是赢家(胜利者),FROM是输家(失败方)。也会在使用<pre>white_peace</pre>效果或接受有条件投降时触发。
|1.12.3
|}
|}


== Diplomacy/War ==
== 外交/ 战争相关 ==
{| class="wikitable sortable" width="100%"
{| class="wikitable sortable" width="100%"
! width="10%" | Name
! width="10%" | 名字
! width="20%" | Description
! width="20%" | 描述
! width="25%" | Examples
! width="25%" | 示例
! width="15%" | Notes
! width="15%" | 提示
! width="5%" | Version Added
! width="5%" | 版本
|-
|-id="on_send_volunteers"
|on_send_volunteers
|on_send_volunteers
|Trigger the following commands whenever a country send volunteers to another.
| 每当一个国家向另一个国家派遣志愿军时,触发该效果。
|<code>on_send_volunteers = { effect = {...} }</code>
|<pre>on_send_volunteers = {
|ROOT is sender, FROM is receiver.
   effect = { &hellip; }
}</pre>
|ROOT 为派遣志愿军的国家,FROM为接收志愿军的国家。
|1.9
|1.9
|-
<!--on_recall_volunteers isn't a real on action, despite the fact that it's listed in documentation. It's not in the binary file and trying to use it will do nothing. Note: Trying to use a non-existing on action doesn't throw an unexpected token error by itself.
|-id="on_recall_volunteers"
|on_recall_volunteers
|Trigger the following commands whenever a country recalls volunteers from another.
|<pre>on_recall_volunteers = {
   effect = { &hellip; }
}</pre>
|ROOT is recaller, FROM is originator.
| unknown - 1.9!-->
|-id="on_border_war_lost"
|on_border_war_lost
|on_border_war_lost
|Trigger the following commands whenever a country lose a border war.
| 每当一个国家输掉边境战争时,触发该效果。
|<code>on_border_war_lost = { effect = { owner = { country_event = { id = china.14 } } } }</code>
|<pre>on_border_war_lost = {
|
   effect = {
     owner = {
       add_ideas = lost_conflict
     }
   }
}</pre>
| “边境战争”是指通过[[Effect#set_border_war|set_border_war]]效果(在省份上方用橙色条纹表示)启动的以省份为基础的边境战争,而不是模拟国与国之间战斗的边境战争。默认作用域是输掉边界战争的省份。
|1.0
|1.0
|-
|-id="on_war_relation_added"
|on_war_relation_added
|每当两个国家最终彼此开战时,触发该效果。(<code>on_war</code>条件效果是当一个国家将要与任意国家发生战争时触发,并且当该国家进入与另一个国家的战争时不会再次触发,除非该国家在再次进入战争前先进入和平状态)
|<pre>on_war_relation_added = {
   effect = { &hellip; }
}</pre>
|ROOT是宣战方,FROM是被宣战方。
|1.9.3
|-id="on_declare_war"
|on_declare_war
|on_declare_war
|Trigger the following commands whenever a country declares war.
| 每当一个国家宣战时,触发该效果。
|<code>on_declare_war = { effect = { if = { limit = { ROOT = { tag = SOV } FROM = { has_idea = anti_soviet_pact } } } } }</code>
|<pre>on_declare_war = {
|FROM is war target.
   effect = {
     if = {
       limit = {
         tag = GER
         FROM = { tag = SOV }
       }
       add_ideas = GER_barbarossa
     }
   }
}</pre>
|FROM 是战争目标,ROOT是宣战国。
|1.0
|1.0
|-
|-id="on_war"
|on_war
|on_war
|Trigger the following commands whenever a country has just entered a war.
| 每当一个国家从和平状态进入战争状态时,触发该命令。
|<code>on_war = { effect = { = {...} }</code>
|<pre>on_war = {
|#THIS is country that has just gotten into a war.
   effect = { &hellip; }
|1.9
}</pre>
|-
|THIS是刚刚被卷入战争的国家。
|1.7
|-id="on_peace"
|on_peace
|每当一个国家不再处于战争状态时'''(即刚进入和平状态)''',触发该效果。
|<pre>on_peace = {
   effect = { &hellip; }
}</pre>
|THIS 是不再处于战争状态的国家。
|1.7
|-id="on_capitulation"
|on_capitulation
|on_capitulation
|Trigger the following commands whenever a country capitulates.
| 每当一个国家投降,在这个过程中,触发该效果。
|<code>on_capitulation = { effect = {...} }</code>
|<pre>on_capitulation = {
|ROOT is capitulated country, FROM is winner.
   effect = { &hellip; }
}</pre>
|ROOT 是投降方,FROM是胜利方。在这时,就已经执行了一些效果,例如删除投降方单位和转移设备。
|1.0
|1.0
|-
|-id="on_capitulation_immediate"
|on_capitulation_immediate
|每当一个国家投降,在这个过程开始时,触发该效果。
|<pre>on_capitulation_immediate = {
   effect = { &hellip; }
}</pre>
|ROOT是投降方,FROM是胜利方。
|1.11.5
|-id="on_uncapitulation"
|on_uncapitulation
|on_uncapitulation
|Trigger the following commands whenever a country that was previously capitulated changes its status to no longer having capitulated.
| 每当一个先前投降的国家将其状态更改为不再投降时,触发该效果。
|<code>on_uncapitulation = { effect = {...} }</code>
|<pre>on_uncapitulation = {
|ROOT is the country affected.
   effect = { &hellip; }
|1.6
}</pre>
|-
|ROOT 是受影响的国家。
|1.4
|-id="on_annex"
|on_annex
|on_annex
|Trigger the following commands whenever a country is annexed.
| 每当一个国家被吞并时,触发该效果。
|<code>on_annex = { effect = { = {...} }</code>
|<pre>on_annex = {
|ROOT is winner, FROM gets annexed. For civil wars '''on_civil_war_end''' is also fired.
   effect = { &hellip; }
|1.0
}</pre>
|-
|ROOT 是胜利方,FROM是被吞并方。对于在内战中的国家,<code>on_civil_war_end</code>效果将同时被触发。
|1.3.3
|-id="on_civil_war_end_before_annexation"
|on_civil_war_end_before_annexation
|on_civil_war_end_before_annexation
|Trigger the following commands just before FROM gets annexed, meaning the country and everything it owns still exists.
| 在FROM被吞并之前效果,这意味着这个国家和它拥有的一切仍然存在。
|<code>on_civil_war_end_before_annexation = { effect = { = {...} }</code>
|<pre>on_civil_war_end_before_annexation = {
|ROOT is winner, FROM gets annexed. It will also fire '''on_annex''' and '''on_civil_war_end'''.
   effect = { &hellip; }
}</pre>
|ROOT 是吞并方,FROM是被吞并方。总是同时触发<code>on_annex</code>和<code>on_civil_war_end</code>。
|1.6
|1.6
|-
|-id="on_civil_war_end"
|on_civil_war_end
|on_civil_war_end
|Trigger the following commands whenever a civil war ends.
| 每当一场内战结束时,触发该效果。
|<code>on_civil_war_end = { effect = { = {...} }</code>
|<pre>on_civil_war_end = {
|ROOT is civil war winner, FROM gets annexed. This will also fire '''on_annex'''.
   effect = { &hellip; }
}</pre>
|ROOT 是内战胜利方,FROM是被吞并方。总是同时触发<code>on_annex</code>。
|1.0
|1.0
|-
|-id="on_puppet"
|on_puppet
|on_puppet
|Trigger the following commands whenever a country is puppeted in a peace conference '''only'''.
| 每当一个国家在''' 和平会议''' 中被傀儡时,触发该效果。
|<code>on_puppet = { effect = { = {...} }</code>
|<pre>on_puppet = {
|ROOT is the nation being puppeted, FROM is the overlord.
   effect = { &hellip; }
}</pre>
|ROOT 是被傀儡的国家,FROM是宗主国。
|1.0
|1.0
|-
|-id="on_liberate"
|on_liberate
|on_liberate
|Trigger the following commands whenever a country is liberated in a peace conference '''only'''.
| 每当一个国家在''' 和平会议''' 中被解放时,触发该效果。
|<code>on_liberate = { effect = { = {...} }</code>
|<pre>on_liberate = {
|ROOT is the nation being liberated, FROM is the leader of the liberators.
   effect = { &hellip; }
}</pre>
|ROOT 是被解放的国家,FROM是解放它的国家。
|1.0
|1.0
|-
|-id="on_release_as_free"
|on_release_as_free
|on_release_as_free
|Trigger the following commands whenever a country is released.
| 每当一个国家被释放时,触发该效果。释放可以在各种效果下释放,并不局限于和平会议
|<code>on_release_as_free = { effect = { = {...} }</code>
|<pre>on_release_as_free = {
|#ROOT is free nation FROM is releaser.
   effect = { &hellip; }
|1.0
}</pre>
|-
|ROOT 是被释放的国家,FROM是释放者。
|1.3
|-id="on_release_as_puppet"
|on_release_as_puppet
|on_release_as_puppet
|Trigger the following commands whenever puppeting through the occupied territories menu during peace time (or when releasing from non-core but owned territory).
| 每当在和平时期通过占领地区菜单释放傀儡( 或从非核心但占领的领土释放) 时,触发该效果。
|<code>on_release_as_puppet = { effect = { = {...} }</code>
|<pre>on_release_as_puppet = {
|ROOT is the nation being released, FROM is the overlord.
   effect = { &hellip; }
|1.0
}</pre>
|-
|ROOT是被释放的国家,FROM是宗主国。
|on_war_relation_added
|1.3
|fired when two countries end up at war with each other (on_war is fired when a country goes to war against anyone and is not fired again when it enters war against another country unless it went to peace first)
|-id="on_guarantee"
|<code>on_war_relation_added = { effect = { = {...} } </code>
|on_guarantee
|ROOT is attacker, FROM is defender
|每当一个国家保障另一个国家的独立时,触发该效果。
|1.9.3
|<pre>on_guarantee = {
   effect = { &hellip; }
}</pre>
|ROOT是保障的国家,FROM是被保障的国家。
|
|-id="on_military_access"
|on_military_access
|每当一个国家'''接受军事通行权'''请求时,触发该效果。
|<pre>on_military_access = {
   effect = { &hellip; }
}</pre>
|ROOT是请求军通的国家,FROM是接受军通的国家。
|
|-id="on_offer_military_access"
|on_offer_military_access
|每当一个国家接受'''提供军事通行权请求'''的提议时,触发该效果。{{red|(注意:这个和上面是两个不同的外交选项!)}}
|<pre>on_offer_military_access = {
   effect = { &hellip; }
}</pre>
|ROOT是提供的国家,FROM是接受的国家。
|
|-id="on_call_allies"
|on_call_allies
|每当一个国家接受战争召唤时,触发该效果。
|<pre>on_call_allies = {
   effect = { &hellip; }
}</pre>
|ROOT是发出召唤的国家,FROM是加入战争的国家。
|
|-id="on_join_allies"
|on_join_allies
|每当一个国家加入盟友的战争时,触发该效果。
|<pre>on_join_allies = {
   effect = { &hellip; }
}</pre>
|ROOT是加入战争的国家,FROM是战争被加入的国家。
|
|-id="on_lend_lease"
|on_lend_lease
|每当一个国家起草的租借法案被接受时,触发该效果。
|<pre>on_lend_lease = {
   effect = { &hellip; }
}</pre>
|ROOT是发出租借法案的国家,FROM是接受租借法案的国家。
|
|-id="on_incoming_lend_lease"
|on_incoming_lend_lease
|每当一个国家接受请求租借时,触发该效果。
|<pre>on_incoming_lend_lease = {
   effect = { &hellip; }
}</pre>
|ROOT是接受请求的国家,FROM是发出请求的国家。
|
|-id="on_send_expeditionary_force"
|on_send_expeditionary_force
|每当一个国家接受派遣远征军时,触发该效果。
|<pre>on_send_expeditionary_force = {
   effect = { &hellip; }
}</pre>
|ROOT是派遣远征军的国家,FROM是接受的国家。
|
|-id="on_return_expeditionary_forces"
|on_return_expeditionary_forces
|每当一个国家撤回他们的远征军时,触发该效果。
|<pre>on_send_expeditionary_force = {
   effect = { &hellip; }
}</pre>
|ROOT是部队的所有者(派遣方),FROM是部队被派遣到的国家。
|
|-id="on_request_expeditionary_forces"
|on_request_expeditionary_forces
|每当一个国家要求军队指挥权时,触发该效果。
|<pre>on_request_expeditionary_forces = {
   effect = { &hellip; }
}</pre>
|ROOT是发出要求的国家,FROM是要求的目标国家。
|
|-id="on_ask_for_state_control"
|on_ask_for_state_control
|每当一个国家接受要求接管占领区的请求时,触发该效果。
|<pre>on_ask_for_state_control = {
   effect = { &hellip; }
}</pre>
|ROOT 是发出请求的国家,FROM是控制该占领区的国家。
|
|-id="on_give_state_control"
|on_give_state_control
| 每当一个国家接受移交占领区的请求时,触发该效果。
|<pre>on_give_state_control = {
   effect = { &hellip; }
}</pre>
|ROOT是移交占领区的国家,FROM是接受的国家。
|
|-id="on_peace_proposal"
|on_peace_proposal
|每当一个国家接受有条件投降时,触发该效果。
|<pre>on_peace_proposal = {
   effect = { &hellip; }
}</pre>
|ROOT 是发起有条件投降的国家,FROM是接受的国家。
|
|-id="on_send_attache"
|on_send_attache
|每当派遣军事顾问被接受时,触发该效果。
|<pre>on_send_attache = {
   effect = { &hellip; }
}</pre>
|默认作用域是派遣的国家,FROM是接受的国家。
|
|}
|}


== Faction ==
== 阵营相关 ==
{| class="wikitable sortable" width="100%"
{| class="wikitable sortable" width="100%"
! width="10%" | Name
! width="10%" | 名字
! width="20%" | Description
! width="20%" | 描述
! width="25%" | Examples
! width="25%" | 示例
! width="15%" | Notes
! width="15%" | 提示
! width="5%" | Version Added
! width="5%" | 版本
|-
|-id="on_create_faction"
|on_create_faction
|on_create_faction
|Trigger the following commands whenever a country create a faction.
| 每当一个国家创建一个阵营时,触发该效果。
|<code>on_create_faction = { effect = {...} }</code>
|<pre>on_create_faction = {\
|FROM is the one that joins the faction.
   effect = { &hellip; }
}</pre>
|FROM 是加入该阵营的国家。
|1.0
|1.0
|-
|-id="on_faction_formed"
|on_faction_formed
|on_faction_formed
|Trigger the following commands when a faction is formed.
| 每当一个阵营创建完成时,触发该效果。
|<code>on_faction_formed = { effect = { news_event = { id = news.159 } } }</code>
|<pre>on_faction_formed = {
   effect = { news_event = { id = news.159 } }
}</pre>
|
|
|1.0
|1.0
|-
|-id="on_offer_join_faction"
|on_offer_join_faction
|on_offer_join_faction
|Trigger the following commands whenever a country is invited in a faction.
| 每当一个国家被邀请加入一个阵营时,触发该效果。
|<code>on_offer_join_faction = { effect = {...} }</code>
|<pre>on_offer_join_faction = {
|FROM is the country invited.
   effect = { &hellip; }
}</pre>
|FROM 是被邀请的国家,THIS和ROOT是阵营领袖。
|1.0
|1.0
|-
|-id="on_join_faction"
|on_join_faction
|on_join_faction
|Trigger the following commands for a faction leader whenever a country is invited in his faction.
| 每当一个国家提出加入阵营并被接受时,触发该效果。
|<code>on_join_faction = { effect = {...} }</code>
|<pre>on_join_faction = {
|FROM is faction leader on join faction requests.
   effect = { &hellip; }
}</pre>
|FROM 是阵营领袖,ROOT和THIS是加入的国家。
|1.0
|1.0
|-
|-id="on_assume_faction_leadership"
|on_assume_faction_leadership
|on_assume_faction_leadership
|Trigger the following commands whenever a country assumes leadership of a faction.
| 每当一个国家接管一个阵营时,触发该效果。
|<code>on_assume_faction_leadership = { effect = {...} }</code>
|<pre>on_assume_faction_leadership = {
|FROM is the former faction leader.
   effect = { &hellip; }
|1.6
}</pre>
|-
|ROOT是新的阵营领袖,FROM是旧的阵营领袖。
|1.7
|-id="on_leave_faction"
|on_leave_faction
|on_leave_faction
|Trigger the following commands whenever a country leave a faction.
| 每当一个国家离开一个阵营时,触发该效果。
|<code>on_leave_faction = { effect = { if = { limit = { AND = { tag = CAN NOT = { has_dlc = "Together for Victory" } } } drop_cosmetic_tag = yes } }</code>
|<pre>on_leave_faction = {
|
   effect = {
     if = {
       limit = {
         AND = {
           tag = CAN
           NOT = { has_dlc = "Together for Victory" }
         }
       }
     drop_cosmetic_tag = yes
   }
}</pre>
|FROM是阵营领袖,ROOT是离开阵营的国家。
|1.0
|1.0
|}
|}


== Autonomy ==
== 傀儡国相关 ==
{| class="wikitable sortable" width="100%"
{| class="wikitable sortable" width="100%"
! width="10%" | Name
! width="10%" | 名字
! width="20%" | Description
! width="20%" | 描述
! width="25%" | Examples
! width="25%" | 例子
! width="15%" | Notes
! width="15%" | 提示
! width="5%" | Version Added
! width="5%" | 版本
|-
|-id="on_subject_annexed"
|on_subject_annexed
|on_subject_annexed
|Trigger the following commands when a country annex a subject.
| 每当一个国家吞并一个傀儡时,触发该效果。
|<code>on_subject_annexed = { effect = { ... } }</code>
|<pre>on_subject_annexed = { effect = { &hellip;  } }</pre>
|ROOT is the subject, FROM is the overlord.
|ROOT 是傀儡国, FROM 是宗主国。
|1.0
|1.0
|-
|-id="on_subject_free"
|on_subject_free
|on_subject_free
|Trigger the following commands when a country grants freedom to a puppet.
| 每当一个国家同意傀儡独立时,触发该效果。
|<code>on_subject_free = { effect = { ... } }</code>
|<pre>on_subject_free = { effect = { &hellip;  } }</pre>
|ROOT is the subject, FROM is the previous overlord.
|ROOT 是傀儡国, FROM 是宗主国。
|1.0
|1.0
|-
|-id="on_subject_autonomy_level_change"
|on_subject_autonomy_level_change
|on_subject_autonomy_level_change
|Trigger the following commands when the autonomy level of a puppet changes.
| 每当一个傀儡的自治级别发生变化时,触发该效果。
|<code>on_subject_autonomy_level_change = { effect = { ... } }</code>
|<pre>on_subject_autonomy_level_change = { effect = { &hellip;  } }</pre>
|ROOT is the subject, FROM is the overlord.
|ROOT 是傀儡国, FROM 是宗主国。
|1.0
|1.0
|}
|}


== Governments in Exile ==
== 流亡政府相关 ==
{| class="wikitable sortable" width="100%"
{| class="wikitable sortable" width="100%"
! width="10%" | Name
! width="10%" | 名字
! width="20%" | Description
! width="20%" | 描述
! width="25%" | Examples
! width="25%" | 例子
! width="15%" | Notes
! width="15%" | 提示
! width="5%" | Version Added
! width="5%" | 版本
|-
|-id="on_government_exiled"
|on_government_exiled
|on_government_exiled
|Trigger the following commands whenever a country becomes a government in exile.
| 每当一个国家成为流亡政府时,触发该效果。
|<code>on_government_exiled = { effect = { = {...} }</code>
|<pre>on_government_exiled = { effect = { = { &hellip; } }</pre>
|ROOT is the government in exile, FROM is the country that is hosting the government in exile.
|ROOT 是流亡政府,FROM是收容流亡政府的国家。
|1.6
|1.6
|-
|-id="on_host_changed_from_capitulation"
|on_host_changed_from_capitulation
|on_host_changed_from_capitulation
|Trigger the following commands whenever a country that is hosting a government in exile has capitulated.
| 每当一个流亡政府所在的国家投降时,触发该效果。
|<code>on_host_changed_from_capitulation= { effect = { = {...} }</code>
|<pre>on_host_changed_from_capitulation= { effect = { = { &hellip; } }</pre>
|ROOT is the government in exile, FROM is the new country hosting the government in exile, FROM:FROM is the old country that was hosting the government in exile.
|ROOT 是流亡政府,'''FROM'''是{{red|新}}的收容流亡政府的国家,'''FROM:FROM'''是{{red|之前}}收容流亡政府的国家。
|1.6
|1.6
|-
|-id="on_exile_government_reinstated"
|on_exile_government_reinstated
|on_exile_government_reinstated
|Trigger the following commands whenever a country has returned from governing in exile.
| 每当一个国家结束流亡状态时,触发该效果。
|<code>on_exile_government_reinstated = { effect = { = {...} }</code>
|<pre>on_exile_government_reinstated = { effect = { = { &hellip; } }</pre>
|ROOT is the government in exile, FROM is the country that was hosting the government in exile.
|ROOT 是流亡政府,FROM是之前收容流亡政府的国家。
|1.6
|1.6
|}
|}


== States ==
== 省份相关 ==
{| class="wikitable sortable" width="100%"
{| class="wikitable sortable" width="100%"
! width="10%" | Name
! width="10%" | 名字
! width="20%" | Description
! width="20%" | 描述
! width="25%" | Examples
! width="25%" | 示例
! width="15%" | Notes
! width="15%" | 提示
! width="5%" | Version Added
! width="5%" | 版本
|-
|-id="on_state_control_changed"
|on_state_control_changed
|on_state_control_changed
|Trigger the following commands when a state's controller changes.
| 每当一个省份的控制权变更时,触发该效果。
|<code>on_state_control_changed = { effect = { ... } }</code>
|<pre>on_state_control_changed = {
|ROOT is new controller, FROM is old controller, FROM.FROM is state ID.
   effect = {
|1.0
     if = {
       limit = {
         FROM.FROM = { state = 123 }
       }
       if =  {
         limit = {
           tag = BHR
         }
         FROM.FROM = {
           set_state_name = STATE_123_BHR
           set_province_name = {
             id = 1234
             name = VICTORY_POINTS_1234_BHR
           }
         }
       }
       else = { # Unnested else is preferred over nested
         FROM.FROM = {
           reset_state_name = yes
           reset_province_name = 1234
         }
       }
     }
   }
}</pre>
|ROOT 是该省份新的控制者,FROM该省份之前的控制者,FROM.FROM 是省份ID。
|1.4
|}
|}


== Wargoals ==
== 战争目标相关 ==
{| class="wikitable sortable" width="100%"
{| class="wikitable sortable" width="100%"
! width="10%" | Name
! width="10%" | 名字
! width="20%" | Description
! width="20%" | 描述
! width="25%" | Examples
! width="25%" | 示例
! width="15%" | Notes
! width="15%" | 提示
! width="5%" | Version Added
! width="5%" | 版本
|-
|-id="on_generate_wargoal"
|on_generate_wargoal
|每当一个国家生成一个战争目标时,触发该效果。
|<pre>on_generate_wargoal = {  }</pre>
|ROOT是战争目标的拥有国家,FROM是战争目标的目标国家。
|
|-id="on_justifying_wargoal_pulse"
|on_justifying_wargoal_pulse
|on_justifying_wargoal_pulse
|Trigger the following commands whenever the country is targeted by a wargoal under justification.
| 每当一个国家被作为正当化战争的目标时,触发该效果。
|<code>on_justifying_wargoal_pulse = { random_events = { 100 = war_justification.1 } }</code>
|<pre>on_justifying_wargoal_pulse = { random_events = { 100 = war_justification.1 } }</pre>
|FROM = target nation. Checked every day.
|FROM 是战争目标的目标国家。'''每天进行检查'''。
|1.0
|1.0
|-
|-id="on_wargoal_expire"
|on_wargoal_expire
|on_wargoal_expire
|Trigger the following commands whenever a wargoal expire.
| 每当战争目标到期时,触发该效果。
|<code>on_wargoal_expire = { random_events = { 100 = war_justification.301 } }</code>
|<pre>on_wargoal_expire = { random_events = { 100 = war_justification.301 } }</pre>
|FROM is the wargoal owner.
|FROM 是战争目标的拥有国家。
|1.0
|1.0
|}
|}


== Unit Leader ==
== 将领相关 ==
{| class="wikitable sortable" width="100%"
{| class="wikitable sortable" width="100%"
! width="10%" | Name
! width="10%" | 名字
! width="20%" | Description
! width="20%" | 描述
! width="25%" | Examples
! width="25%" | 示例
! width="15%" | Notes
! width="15%" | 提示
! width="5%" | Version Added
! width="5%" | 版本
|-
|-id="on_unit_leader_created"
|on_unit_leader_created
|on_unit_leader_created
|Trigger the following commands when an army leader is created.
| 每当招募一名新将领时,触发该效果。
|<code>on_unit_leader_created= { effect = {...} }</code>
|<pre>on_unit_leader_created = { effect = { &hellip; } }</pre>
|FROM is owner country, ROOT is the unit leader
|FROM 是该将领所在国家,ROOT是该将领。
|1.5
|1.5
|-
|-id="on_army_leader_daily"
|on_army_leader_daily
|on_army_leader_daily
|Trigger the following commands on an army leader each day.
| 在每一天为一名将领触发该效果。
|<code>on_army_leader_daily = { effect = {...} }</code>
|<pre>on_army_leader_daily = { effect = { &hellip; } }</pre>
|FROM is owner country.
|FROM 是该将领所在国家,ROOT是该将领。
|1.0
|1.0
|-
|-id="on_army_leader_won_combat"
|on_army_leader_won_combat
|on_army_leader_won_combat
|Trigger the following commands whenever an army leader won a combat.
| 每当一名将领打赢一场战斗时,触发该效果。
|<code>on_army_leader_won_combat = { effect = {...} }</code>
|<pre>on_army_leader_won_combat = { effect = { &hellip; } }</pre>
|FROM is owner country.
|FROM 是该将领所在国家,ROOT是该将领。
|1.0
|1.0
|-
|-id="on_army_leader_lost_combat"
|on_army_leader_lost_combat
|on_army_leader_lost_combat
|Trigger the following commands whenever an army leader lost a combat.
| 每当一名将领打输一场战斗时,触发该效果。
|<code>on_army_leader_lost_combat = { effect = {...} }</code>
|<pre>on_army_leader_lost_combat = { effect = { &hellip; } }</pre>
|FROM is owner country.
|FROM 是该将领所在国家,ROOT是该将领。
|1.0
|1.0
|-
|-id="on_unit_leader_level_up"
|on_unit_leader_level_up
|on_unit_leader_level_up
|Trigger the following commands when a leader gain a level.
| 每当一名将领获得升级时,触发该效果。
|<code>on_unit_leader_level_up = { effect = {...} }</code>
|<pre>on_unit_leader_level_up = { effect = { &hellip; } }</pre>
|
|FROM是该将领所在国家,ROOT是该将领。
|1.0
|1.0
|-
|-id="on_army_leader_promoted"
|on_army_leader_promoted
|on_army_leader_promoted
|Trigger the following commands whenever an army leader is promoted.
| 每当一名将领晋升为元帅时,触发该效果。
|<code>on_army_leader_lost_combat = { effect = { add_timed_unit_leader_trait = { trait = recently_promoted days = 100 } } }</code>
|<pre>on_army_leader_promoted = {
   effect = {
     add_timed_unit_leader_trait = { trait = recently_promoted days = 100 }
   }
}</pre>
|FROM是该将领所在国家,ROOT是该将领。
|1.0
|-id="on_unit_leader_promote_from_ranks_veteran"
|on_unit_leader_promote_from_ranks_veteran
|每当一名战地军官晋升为将军时,触发该效果。
|<pre>on_unit_leader_promote_from_ranks_veteran = { effect = { &hellip; } }</pre>
|FROM是该战地军官所在的单位,OWNER是该战地军官所在的国家,ROOT是该战地军官。
|1.12
|-id="on_unit_leader_promote_from_ranks_green"
|on_unit_leader_promote_from_ranks_green
|每当一名战地军官晋升为将军时,触发该效果。
|<pre>on_unit_leader_promote_from_ranks_green = { effect = { &hellip; } }</pre>
|FROM是该战地军官所在的单位,OWNER是该战地军官所在的国家,ROOT是该战地军官。
|1.12
|}
 
== 军事相关 ==
{| class="wikitable sortable" width="100%"
! width="10%" | 名字
! width="20%" | 描述
! width="25%" | 示例
! width="15%" | 提示
! width="5%" | 版本
|-id="on_nuke_drop"
|on_nuke_drop
|每当一个国家投掷核弹时,触发该效果。
|<pre>on_nuke_drop = {
   effect = {
     set_global_flag = first_nuke_dropped
   }
}</pre>
|ROOT是发射核弹的国家,FROM是被核弹打击的省份。
|1.0
|-id="on_pride_of_the_fleet_sunk"
|on_pride_of_the_fleet_sunk
|每当一个国家的舰队荣耀被击沉时,触发该效果。
|<pre>on_pride_of_the_fleet_sunk = {
   effect = {
     if = {
       limit = {
         tag = ENG
       }
       FROM = { set_country_flag = achievements_pride_and_extreme_prejudice }
     }
   }
}</pre>
|FROM是击沉舰队荣耀的国家,ROOT是被击沉舰队荣耀的国家。
|1.6
|-id="on_naval_invasion"
|on_naval_invasion
|每当海上入侵发生时,触发该效果。
|<pre>on_naval_invasion = {
   effect = {
     ROOT = {   # Unlike most on_actions, ROOT isn't the default scope
       add_political_power = 100
     }
   }
}</pre>
|THIS(默认作用域)是被入侵的省份,ROOT是入侵的国家,FROM是入侵开始的省份。
|1.9
|-id="on_paradrop"
|on_paradrop
|每当空投发生时,触发该效果。
|<pre>on_paradrop = {
   effect = {
     FROM = {
       controller = {
         add_war_support = 0.01
       }
     }
   }
}</pre>
|THIS (默认作用域)是未被空投的省份,ROOT是被空投的省份,FROM是进行空投的国家。
|1.9
|-id="on_units_paradropped_in_state"
|on_units_paradropped_in_state
|这与on_paradrop的不同之处在于它对每一次空投运行一次,而不是对每个空投的单位运行一次。
|<pre>on_paradrop = {
   effect = {
     FROM = {
       controller = {
         add_war_support = 0.01
       }
     }
   }
}</pre>
|ROOT是被空投的省份,FROM是进行空投的国家。
|
|
|1.0
|-id="on_add_history"
|on_add_history
|每当接收到单位的战斗历史记录时,触发该效果。
|<pre>on_add_history = { effect = { &hellip; } }</pre>
|ROOT是该单位。
|1.12
|}
|}


== Aces ==
== 王牌飞行员相关 ==
{| class="wikitable sortable" width="100%"
{| class="wikitable sortable" width="100%"
! width="10%" | Name
! width="10%" | 名字
! width="20%" | Description
! width="20%" | 描述
! width="25%" | Examples
! width="25%" | 示例
! width="15%" | Notes
! width="15%" | 提示
! width="5%" | Version Added
! width="5%" | 版本
|-
|-id="on_ace_promoted"
|on_ace_promoted
|on_ace_promoted
|Trigger the following commands whenever an ace is created.
| 每当创建一个王牌飞行员时,触发该效果。
|<code>on_ace_promoted = { random_events = { 100 = ace_promoted.1 } }</code>
|<pre>on_ace_promoted = { random_events = { 100 = ace_promoted.1 } }</pre>
|FROM = ace.
|FROM 是该王牌飞行员。
|1.0
|1.0
|-
|-id="on_ace_killed"
|on_ace_killed
|on_ace_killed
|Trigger the following commands whenever an aces is killed.
| 每当一个王牌飞行员被消灭时,触发该效果。
|<code>on_ace_killed = { random_events = { 100 = ace_died.1 } }</code>
|<pre>on_ace_killed = { random_events = { 100 = ace_died.1 } }</pre>
|FROM = ace.
|FROM 是该王牌飞行员。
|1.0
|1.0
|-
|-id="on_ace_killed_on_accident"
|on_ace_killed_on_accident
|on_ace_killed_on_accident
|Trigger the following commands whenever our aces died on accident.
| 每当我方王牌飞行员在意外中死亡时,触发该效果。
|<code>on_ace_killed_on_accident = { random_events = { 100 = ace_died.1 } }</code>
|<pre>on_ace_killed_on_accident = { random_events = { 100 = ace_died.1 } }</pre>
|FROM = our ace died in accident.
|FROM 是我方意外死亡的王牌飞行员。
|1.9
|1.9
|-
|-id="on_non_ace_killed_other_ace"
|on_non_ace_killed_other_ace
|on_non_ace_killed_other_ace
|Trigger the following commands whenever non ace killed enemy ace.
| 每当我方非王牌飞行员击落敌方王牌飞行员时,触发该效果。
|<code>on_non_ace_killed_other_ace = { FROM = { random_events = { 100 = ace_died.1 } } }</code>
|<pre>on_non_ace_killed_other_ace = { FROM = { random_events = { 100 = ace_died.1 } } }</pre>
|FROM = enemy ace.
|FROM 是该敌方王牌飞行员。
|1.9
|1.9
|-
|-id="on_ace_killed_by_ace"
|on_ace_killed_by_ace
|on_ace_killed_by_ace
|Trigger the following commands whenever an aces is killed by another ace.
| 每当一个王牌飞行员被另一个王牌飞行员击落(敌方击落我方)时,触发该效果。
|<code>on_ace_killed_by_ace = { random_events = { 100 = ace_killed_by_ace.1 } }</code>
|<pre>on_ace_killed_by_ace = { random_events = { 100 = ace_killed_by_ace.1 } }</pre>
|FROM = our ace, PREV = enemy ace, has killed FROM.
|FROM 是我方王牌飞行员,PREV是击落FROM的敌方王牌飞行员
|1.0
|1.0
|-
|-id="on_ace_killed_other_ace"
|on_ace_killed_other_ace
|on_ace_killed_other_ace
|Trigger the following commands whenever an aces is killed by another ace (surviving ace side).
| 每当一个王牌飞行员被另一个王牌飞行员击落(我方击落敌方)时,触发该效果。
|<code>on_ace_killed_other_ace = { random_events = { 100 = ace_killed_other_ace.1 } }</code>
|<pre>on_ace_killed_other_ace = { random_events = { 100 = ace_killed_other_ace.1 } }</pre>
|FROM = our ace, PREV = enemy ace, killed by FROM.
|FROM 是我方王牌飞行员,PREV是被FROM击落的敌方王牌飞行员。
|1.0
|1.0
|-
|-id="on_aces_killed_each_other"
|on_aces_killed_each_other
|on_aces_killed_each_other
|Trigger the following commands whenever two aces kill each other in air duel.
| 每当两个王牌飞行员在空中对决中同归于尽时,触发该效果。
|<code>on_aces_killed_each_other = { random_events = { 100 = aces_killed_each_other.1 } }</code>
|<pre>on_aces_killed_each_other = { random_events = { 100 = aces_killed_each_other.1 } }</pre>
|FROM = ace, PREV = enemy ace.
|FROM 是我方王牌飞行员,PREV是敌方王牌飞行员。
|1.0
|1.0
|}
|}


== La Résistance ==
== 抵抗运动相关 ==
{| class="wikitable sortable" width="100%"
{| class="wikitable sortable" width="100%"
! width="10%" | Name
! width="10%" | 名字
! width="20%" | Description
! width="20%" | 描述
! width="25%" | Examples
! width="25%" | 示例
! width="15%" | Notes
! width="15%" | 提示
! width="5%" | Version Added
! width="5%" | 版本
|-
|-id="on_operation_completed"
|on_operation_completed
|on_operation_completed
|Trigger the following commands whenever an operative completed.
| 每当一名特工完成任务时,触发该效果。
|<code>on_operation_completed = { effect = {...} }</code>
|<pre>on_operation_completed = { effect = { &hellip; } }</pre>
|THIS - the operative, ROOT - the initiating country, FROM - the target country.
|THIS 是该特工,ROOT是发起行动的国家,FROM是目标国家。
|1.9
|1.9
|-
|-id="on_operative_detected_during_operation"
|on_operative_detected_during_operation
|on_operative_detected_during_operation
|Trigger the following commands whenever an operative dies.
| 每当一名特工死亡时,触发该效果。
|<code>on_operative_death = { effect = {...} }</code>
|<pre>on_operative_death = { effect = { &hellip; } }</pre>
|THIS - the operative, ROOT - the killer country (optional), FROM - the country the operative is operating for, FROM.FROM - operation state (will only be set if the operation has a specific selection_target).
|THIS 是该特工,ROOT是杀死该特工的国家(可选),FROM是该特工执行任务的目标国家,FROM.FROM 是任务状态(仅在任务有特定选择目标时设置)。
|1.9
|1.9
|-
|-id="on_operative_on_mission_spotted"
|on_operative_on_mission_spotted
|on_operative_on_mission_spotted
|Trigger the following commands whenever an operative performing an offensive mission in a country.
| 每当一名特工在一个国家执行破坏任务时,触发该效果。
|<code>on_operative_on_mission_spotted = { effect = {...} }</code>
|<pre>on_operative_on_mission_spotted = { effect = { &hellip; } }</pre>
|THIS - the operative, FROM - the country the operative was performing its mission in, ROOT - the country the operative is operating for.
|THIS 是该特工,FROM是该特工正在执行任务所在的国家,ROOT是该特工所属国家。
|1.9
|1.9
|-
|-id="on_operative_captured"
|on_operative_captured
|on_operative_captured
|Trigger the following commands whenever an operative is captured.
| 每当一名特工被俘获时,触发该效果。
|<code>on_operative_captured = { effect = {...} }</code>
|<pre>on_operative_captured = { effect = { &hellip; } }</pre>
|THIS - the operative, ROOT - the country the operative was performing its mission in, FROM - the country the operative is operating for.
|THIS 是该特工,ROOT是该特工执行任务所在的国家,FROM是该特工为其服务的国家。
|1.9
|1.9
|-
|-id="on_operative_created"
|on_operative_created
|每当一名特工被创建时,触发该效果。
|<pre>on_operative_created = { effect = { &hellip; } }</pre>
|THIS是该特工,FROM是创建该特工的国家。
|1.9.1
|-id="on_operative_death"
|on_operative_death
|on_operative_death
|Trigger the following commands whenever an operative dies.
| 每当一名特工死亡时,触发该效果。
|<code>on_operative_death = { effect = {...} }</code>
|<pre>on_operative_death = { effect = { &hellip; } }</pre>
|THIS - the operative, ROOT - the killer country (optional), FROM - the country the operative is operating for.
|THIS 是该特工,ROOT是杀死该特工的国家(可选),FROM是该特工所属国家。
|1.9
|1.9
|-
|-id="on_operative_recruited"
|on_operative_recruited
|每当一名特工被招募时,触发该效果。
|<pre>on_operative_recruited = { effect = { &hellip; } }</pre>
|THIS是该特工,FROM是创建该特工的国家。
|1.9.1
|-id="on_fully_decrypted_cipher"
|on_fully_decrypted_cipher
|on_fully_decrypted_cipher
|Trigger the following commands whenever a country fully decrypts cipher of a target country.
| 每当一个国家完全破译了目标国家的密码时,触发该效果。
|<code>on_fully_decrypted_cipher = { effect = {...} }</code>
|<pre>on_fully_decrypted_cipher = { effect = { &hellip; } }</pre>
|THIS - the target country that its cipher is decrypted, FROM - the decrypter country.
|THIS 是密码被破译的国家,FROM是破译密码的国家。
|1.9
|1.9
|-
|-id="on_activated_active_decryption_bonuses"
|on_activated_active_decryption_bonuses
|on_activated_active_decryption_bonuses
|Trigger the following commands whenever a country activates its active cipher bonuses against a target.
| 每当一个国家针对目标国家激活已破译密码的加成效果时,触发该效果。
|<code>on_activated_active_decryption_bonuses = { effect = {...} }</code>
|<pre>on_activated_active_decryption_bonuses = { effect = { &hellip; } }</pre>
|THIS - the target country, FROM - the country that activates its bonuses.
|THIS 是目标国家,FROM是激活加成效果的国家。
|1.9
|1.9
|}
== 军工组织系统(MIO)相关 ==
{| class="wikitable sortable" width="100%"
! width="10%" | 名字
! width="20%" | 描述
! width="25%" | 示例
! width="15%" | 提示
! width="5%" | 版本
|-id="on_mio_size_increased"
|on_mio_size_increased
|每当一个军工机构的规模增长(升级)时,触发该效果。
|
|ROOT是该军工机构,FROM是该军工机构所在的国家。
|1.13
|-id="on_mio_design_team_assigned_to_tech"
|on_mio_design_team_assigned_to_tech
|每当一个军工机构被分配给科技研究时,触发该效果。
|
|ROOT是该军工机构,FROM是该军工机构所在的国家。
|1.13
|-id="on_mio_design_team_assigned_to_variant"
|on_mio_design_team_assigned_to_variant
|每当一个军工机构被分配给一个装备的衍生型号时,触发该效果。
|
|ROOT是该军工机构,FROM是该军工机构所在的国家。
|1.13
|-id="on_mio_industrial_manufacturer_assigned"
|on_mio_industrial_manufacturer_assigned
|每当一个军工机构被分配到一条生产线时,触发该效果。
|
|ROOT是该军工机构,FROM是该军工机构所在的国家。
|1.13
<!-- These do not work while still being present in the vanilla on_actions files
|-id="on_mio_tech_research_cancelled"
|on_mio_tech_research_cancelled
|Trigger the following commands whenever a technology a MIO is assigned to is canceled.
|
|ROOT is the Military Industrial Organization, FROM is the owner of the MIO
|1.13
|-id="on_mio_tech_research_completed"
|on_mio_tech_research_completed
|Trigger the following commands whenever a technology a MIO is assigned to is completed.
|
|ROOT is the Military Industrial Organization, FROM is the owner of the MIO
|1.13
-->
|-id="on_mio_industrial_manufacturer_unassigned"
|on_mio_industrial_manufacturer_unassigned
|每当一个军工机构被从一条生产线取消分配时,触发该效果。
|
|ROOT是该军工机构,FROM是该军工机构所在的国家。
|1.13
|}
|}


{{Modding navbox}}
{{Modding navbox}}
[[Category:Modding]]
[[Category:Modding]]

2024年8月10日 (六) 19:13的最新版本


代码在一个特定的行动发生后被执行,例如当一个国家向另一个国家宣战或者当一个省份变更控制权时触发某种效果。On actions被定义在 /Hearts of Iron IV/common/on_actions/*.txt文件中。

每一个on action都是一个被包含在on_actions = { ... }代码中,也就是on actions文件的根代码块中的独立代码块。每一个on_action最多有2个参数:

  • effect = { ... }存在于每一个单独的on action中,在需要时作为一个效果执行内效果代码。
  • random_events = { ... } 用于on_actions中,其默认作用域(如果没有另行指定,则与ROOT相同)是一个国家,例如on_new_term_election。这将立即随机触发给定权重的指定事件中的事件之一。这是通过概率与权重成正比的随机方法完成的。
0代替事件ID将确保如果随机到该事件时不会有任何事情发生。
另外,当一个事件的trigger = { ... }代码块计算结果为false(即不满足触发条件)时,该事件不会被random_events = { ... }触发。在这种情况下,每个作用域的处理方式与on action的相同:on action的FROM被视为该事件的FROM,对于FROM.FROM也是一样(注:FROM与上文的ROOT相同,都是指代码的作用域,但是在大部分情况下意义不同)。
如果存在多个random_events代码,将从每个块中选择一个事件。

请注意,就作用域而言,ROOT是默认的假定作用域,除非另有指定(在on_actions中,THIS作为一个独立于ROOT的实体),而FROM和FROM.FROM可以作为另外提供的辅助块。

每个on action只能在游戏开始后执行,不受任何通常会触发一次的来自历史文件或剧本的effects = { ... }部分的效果所影响,例如set_politics

'再次强调:本篇wiki下文所指的ROOT、THIS、FROM、PREV等相关代码,都是指代码的作用域(类似于函数的定义域,确定代码的适用范围的代码)'

文件示例

on_actions = {
    on_startup = {
        effect = { # NEVER FORGET! Important to include this line to distinguish it from random_events = { ... }
            every_country = {
                limit = {
                    is_ai = no
                }
                country_event = welcome_event.1
            }
            ENG = {
                country_event = { 
                    id = new_year.1
                    days = 365  # Fires on January 1 1937. Remember that leap days do not exist in-game.
                }
            }
        }
    }
    on_state_control_changed = {
        random_events = {
            1 = germany_state_control.1 # Assuming the triggers for the events are met, then
            1 = germany_state_control.2 # fires one of germany_state_control.1 or germany_state_control.2
            3 = 0                       # Each has a 20% chance, and there's 60% chance nothing happens.
        }
        effect = {
            if = {
                limit = {   # Execute if Italy captures Corsica or Savoy from France
                    tag = ITA
                    FROM = { tag = FRA }
                    FROM.FROM = {
                        OR = {
                            state = 1
                            state = 735
                        }
                    }
                }
                FROM.FROM = {
                    set_resistance = 60
                    damage_building = {
                        type = infrastructure
                        damage = 2
                    }
                }
            }
        }
    }
}

常见的on_actions代码

名字 描述 示例 提示 版本
on_startup 在游戏开局(新的一局开始的时候)时触发一次效果。但是加载存档时不触发该效果。
on_startup = { 
    effect = {
        ENG = {
            news_event = { id = news_event.1 days = 31 random_days = 27 }
            # Fires a news event in February 1936
        }  # assuming the default start date
    }      # Scoping into ENG is necessary, since
}          # news_event is a country-scoped effect
默认作用域为none,而不是像其他P社游戏(如《欧陆风云4》)那样针对每个国家单独触发。如果没有手动将作用域划分到国家、省份或其他地方,许多通常可以在任何作用域内使用的效果将无法工作。 1.3.3
on_daily 在每一天为每个国家分别触发效果(对性能的影响大,请谨慎使用)。
on_daily = {
    effect = {
        if = {
            limit = { has_variable = to_be_updated_daily }
            add_to_variable = { to_be_updated_daily = 1 }
        } 
    }
}
对于scripted guis和添加新机制的mod非常有用(例如可以每天增加一个变量)。只有在小心避免重复效果的情况下才使用该作用域。在每个国家单独执行意味着本质上相当于在每个国家每一天执行一个单独的效果。例如 effect = { GER = { add_political_power = 100 } }将每天增加约100政治点数到德意志国的国旗 德意志国 ,因为世界地图上有约100个国家,这意味着每天将执行约100次。 1.5.2
on_daily_<TAG> 每天为指定国家触发效果(注:TAG就是你要指定的国家)
on_daily_SOV = {
    effect = {  
        if = {
            limit = { has_war_with = GER }
            SOV_escalate_the_war_effect = yes
        }
    }
}
只有在国家存在的前提条件下才能触发该效果,否则无效 1.9
on_weekly 每周为每个国家触发一次效果
on_weekly = {
    effect = {
        if = {
            limit = { 
                has_intelligence_agency = yes
                is_ai = yes
            }
            update_operation_ai = yes
        }
    }
}
对ai脚本很有用。如果num_days_variable能被7整除,则在这一天的开始运行。 1.9
on_weekly_<TAG> 每周为指定国家触发一次效果(注:TAG就是你要指定国家)
on_weekly_BHR = {
    if = {
        limit = {
            has_country_flag = BHR_must_control_states
            any_owned_state = {
                NOT = { is_controlled_by = ROOT }
            }
            has_stability < 0.5
        }
        country_event = BHR_event.0
        clr_country_flag = BHR_must_control_states
    }
}
只有在该国家存在的情况下才执行效果。如果num_days_variable能被7整除,则在这一天的开始运行。 1.9
on_monthly 在每月为每个国家分别触发效果。
on_monthly = { 
    random_events = {
        1 = random_event.0
        99 = 0
    }
}
1.9
on_monthly_<TAG> 在每月为指定国家触发一次效果(注:TAG就是你要指定的国家)
on_monthly_USA = {
    effect = {
        add_to_variable = { USA_unrest = 1 }
        clamp_variable = {
            var = USA_unrest
            max = 10
        }
        if = {
            limit = { 
                check_variable = { USA_unrest = 10 }
            }
            country_event = usa.rebellion.0
        }
    }
}
只有在该国家存在的前提条件下才能执行该效果,否则无效。 1.9

政治相关

名字 描述 示例 提示 版本
on_stage_coup 对没有抵抗运动抵抗运动DLC的国家策划政变使用,每当政变策划时,触发以下效果。
on_stage_coup = { 
    effect = { 
    }
}
ROOT是策划政变的国家,FROM是目标国家。 1.0
on_coup_succeeded 对没有抵抗运动抵抗运动DLC的国家策划政变使用,每当政变成功时,触发以下效果。
on_coup_succeeded = { 
    effect = { 
        random_other_country = { 
            limit = { 
                has_government = democratic
                original_tag = ROOT
            } 
            set_politics = { elections_allowed = yes }
        }
    }
}
ROOT是政变成功的国家,FROM是策划政变的国家。 1.0
on_government_change 每当一个国家更换政府时,触发以下效果。
on_government_change = { effect = {  …  } }
这包括set_politicsstart_civil_war(总是为双方),不包括被傀儡的情况。总是同时触发on_ruling_party_change效果. 1.0
on_ruling_party_change 每当某个国家改变其意识形态时,触发以下命令。
on_ruling_party_change = { effect = {  …  } }
old_ideology_token是一个临时变量,,它将旧的意识形态存储为token。除了包括触发on_government_change的效果外,还包括被傀儡或通过控制台命令改变意识形态的情况。 1.9
on_new_term_election 每当发生选举或被hold_election命令调用时,触发效果。
on_new_term_election = { random_events = { 100 = usa.6 } }
1.0
on_peaceconference_ended 每当和平会议结束时,触发效果。
on_peaceconference_ended = { effect = { … } }
ROOT是赢家(胜利者),FROM是输家(失败方)。也会在使用
white_peace
效果或接受有条件投降时触发。
1.5
on_peaceconference_started 每当和平会议开始时,触发以下命令。
on_peaceconference_started = { effect = { … } }
ROOT是赢家(胜利者),FROM是输家(失败方)。也会在使用
white_peace
效果或接受有条件投降时触发。
1.12.3

外交/战争相关

名字 描述 示例 提示 版本
on_send_volunteers 每当一个国家向另一个国家派遣志愿军时,触发该效果。
on_send_volunteers = {
    effect = { … }
}
ROOT为派遣志愿军的国家,FROM为接收志愿军的国家。 1.9
on_border_war_lost 每当一个国家输掉边境战争时,触发该效果。
on_border_war_lost = {
    effect = {
        owner = {
            add_ideas = lost_conflict
        }
    }
}
“边境战争”是指通过set_border_war效果(在省份上方用橙色条纹表示)启动的以省份为基础的边境战争,而不是模拟国与国之间战斗的边境战争。默认作用域是输掉边界战争的省份。 1.0
on_war_relation_added 每当两个国家最终彼此开战时,触发该效果。(on_war条件效果是当一个国家将要与任意国家发生战争时触发,并且当该国家进入与另一个国家的战争时不会再次触发,除非该国家在再次进入战争前先进入和平状态)
on_war_relation_added = {
    effect = { … }
}
ROOT是宣战方,FROM是被宣战方。 1.9.3
on_declare_war 每当一个国家宣战时,触发该效果。
on_declare_war = {
    effect = {
        if = {
            limit = {
                tag = GER
                FROM = { tag = SOV }
            }
            add_ideas = GER_barbarossa
        }
    }
}
FROM是战争目标,ROOT是宣战国。 1.0
on_war 每当一个国家从和平状态进入战争状态时,触发该命令。
on_war = {
    effect = { … }
}
THIS是刚刚被卷入战争的国家。 1.7
on_peace 每当一个国家不再处于战争状态时(即刚进入和平状态),触发该效果。
on_peace = {
    effect = { … }
}
THIS是不再处于战争状态的国家。 1.7
on_capitulation 每当一个国家投降,在这个过程中,触发该效果。
on_capitulation = {
    effect = { … }
}
ROOT是投降方,FROM是胜利方。在这时,就已经执行了一些效果,例如删除投降方单位和转移设备。 1.0
on_capitulation_immediate 每当一个国家投降,在这个过程开始时,触发该效果。
on_capitulation_immediate = {
    effect = { … }
}
ROOT是投降方,FROM是胜利方。 1.11.5
on_uncapitulation 每当一个先前投降的国家将其状态更改为不再投降时,触发该效果。
on_uncapitulation = {
    effect = { … }
}
ROOT是受影响的国家。 1.4
on_annex 每当一个国家被吞并时,触发该效果。
on_annex = {
    effect = { … }
}
ROOT是胜利方,FROM是被吞并方。对于在内战中的国家,on_civil_war_end效果将同时被触发。 1.3.3
on_civil_war_end_before_annexation 在FROM被吞并之前效果,这意味着这个国家和它拥有的一切仍然存在。
on_civil_war_end_before_annexation = {
    effect = { … }
}
ROOT是吞并方,FROM是被吞并方。总是同时触发on_annexon_civil_war_end 1.6
on_civil_war_end 每当一场内战结束时,触发该效果。
on_civil_war_end = {
    effect = { … }
}
ROOT是内战胜利方,FROM是被吞并方。总是同时触发on_annex 1.0
on_puppet 每当一个国家在和平会议中被傀儡时,触发该效果。
on_puppet = {
    effect = { … }
}
ROOT是被傀儡的国家,FROM是宗主国。 1.0
on_liberate 每当一个国家在和平会议中被解放时,触发该效果。
on_liberate = {
    effect = { … }
}
ROOT是被解放的国家,FROM是解放它的国家。 1.0
on_release_as_free 每当一个国家被释放时,触发该效果。释放可以在各种效果下释放,并不局限于和平会议
on_release_as_free = {
    effect = { … }
}
ROOT是被释放的国家,FROM是释放者。 1.3
on_release_as_puppet 每当在和平时期通过占领地区菜单释放傀儡(或从非核心但占领的领土释放)时,触发该效果。
on_release_as_puppet = {
    effect = { … }
}
ROOT是被释放的国家,FROM是宗主国。 1.3
on_guarantee 每当一个国家保障另一个国家的独立时,触发该效果。
on_guarantee = {
    effect = { … }
}
ROOT是保障的国家,FROM是被保障的国家。
on_military_access 每当一个国家接受军事通行权请求时,触发该效果。
on_military_access = {
    effect = { … }
}
ROOT是请求军通的国家,FROM是接受军通的国家。
on_offer_military_access 每当一个国家接受提供军事通行权请求的提议时,触发该效果。(注意:这个和上面是两个不同的外交选项!)
on_offer_military_access = {
    effect = { … }
}
ROOT是提供的国家,FROM是接受的国家。
on_call_allies 每当一个国家接受战争召唤时,触发该效果。
on_call_allies = {
    effect = { … }
}
ROOT是发出召唤的国家,FROM是加入战争的国家。
on_join_allies 每当一个国家加入盟友的战争时,触发该效果。
on_join_allies = {
    effect = { … }
}
ROOT是加入战争的国家,FROM是战争被加入的国家。
on_lend_lease 每当一个国家起草的租借法案被接受时,触发该效果。
on_lend_lease = {
    effect = { … }
}
ROOT是发出租借法案的国家,FROM是接受租借法案的国家。
on_incoming_lend_lease 每当一个国家接受请求租借时,触发该效果。
on_incoming_lend_lease = {
    effect = { … }
}
ROOT是接受请求的国家,FROM是发出请求的国家。
on_send_expeditionary_force 每当一个国家接受派遣远征军时,触发该效果。
on_send_expeditionary_force = {
    effect = { … }
}
ROOT是派遣远征军的国家,FROM是接受的国家。
on_return_expeditionary_forces 每当一个国家撤回他们的远征军时,触发该效果。
on_send_expeditionary_force = {
    effect = { … }
}
ROOT是部队的所有者(派遣方),FROM是部队被派遣到的国家。
on_request_expeditionary_forces 每当一个国家要求军队指挥权时,触发该效果。
on_request_expeditionary_forces = {
    effect = { … }
}
ROOT是发出要求的国家,FROM是要求的目标国家。
on_ask_for_state_control 每当一个国家接受要求接管占领区的请求时,触发该效果。
on_ask_for_state_control = {
    effect = { … }
}
ROOT是发出请求的国家,FROM是控制该占领区的国家。
on_give_state_control 每当一个国家接受移交占领区的请求时,触发该效果。
on_give_state_control = {
    effect = { … }
}
ROOT是移交占领区的国家,FROM是接受的国家。
on_peace_proposal 每当一个国家接受有条件投降时,触发该效果。
on_peace_proposal = {
    effect = { … }
}
ROOT是发起有条件投降的国家,FROM是接受的国家。
on_send_attache 每当派遣军事顾问被接受时,触发该效果。
on_send_attache = {
    effect = { … }
}
默认作用域是派遣的国家,FROM是接受的国家。

阵营相关

名字 描述 示例 提示 版本
on_create_faction 每当一个国家创建一个阵营时,触发该效果。
on_create_faction = {\
    effect = { … }
}
FROM是加入该阵营的国家。 1.0
on_faction_formed 每当一个阵营创建完成时,触发该效果。
on_faction_formed = {
    effect = { news_event = { id = news.159 } }
}
1.0
on_offer_join_faction 每当一个国家被邀请加入一个阵营时,触发该效果。
on_offer_join_faction = {
    effect = { … }
}
FROM是被邀请的国家,THIS和ROOT是阵营领袖。 1.0
on_join_faction 每当一个国家提出加入阵营并被接受时,触发该效果。
on_join_faction = {
    effect = { … }
}
FROM是阵营领袖,ROOT和THIS是加入的国家。 1.0
on_assume_faction_leadership 每当一个国家接管一个阵营时,触发该效果。
on_assume_faction_leadership = {
    effect = { … }
}
ROOT是新的阵营领袖,FROM是旧的阵营领袖。 1.7
on_leave_faction 每当一个国家离开一个阵营时,触发该效果。
on_leave_faction = {
    effect = {
        if = {
            limit = {
                AND = {
                    tag = CAN
                    NOT = { has_dlc = "Together for Victory" }
                }
            }
        drop_cosmetic_tag = yes
    }
}
FROM是阵营领袖,ROOT是离开阵营的国家。 1.0

傀儡国相关

名字 描述 例子 提示 版本
on_subject_annexed 每当一个国家吞并一个傀儡时,触发该效果。
on_subject_annexed = { effect = {  …  } }
ROOT是傀儡国, FROM是宗主国。 1.0
on_subject_free 每当一个国家同意傀儡独立时,触发该效果。
on_subject_free = { effect = {  …  } }
ROOT是傀儡国, FROM是宗主国。 1.0
on_subject_autonomy_level_change 每当一个傀儡的自治级别发生变化时,触发该效果。
on_subject_autonomy_level_change = { effect = {  …  } }
ROOT是傀儡国, FROM是宗主国。 1.0

流亡政府相关

名字 描述 例子 提示 版本
on_government_exiled 每当一个国家成为流亡政府时,触发该效果。
on_government_exiled = { effect = { = { … } }
ROOT是流亡政府,FROM是收容流亡政府的国家。 1.6
on_host_changed_from_capitulation 每当一个流亡政府所在的国家投降时,触发该效果。
on_host_changed_from_capitulation= { effect = { = { … } }
ROOT是流亡政府,FROM的收容流亡政府的国家,FROM:FROM之前收容流亡政府的国家。 1.6
on_exile_government_reinstated 每当一个国家结束流亡状态时,触发该效果。
on_exile_government_reinstated = { effect = { = { … } }
ROOT是流亡政府,FROM是之前收容流亡政府的国家。 1.6

省份相关

名字 描述 示例 提示 版本
on_state_control_changed 每当一个省份的控制权变更时,触发该效果。
on_state_control_changed = {
    effect = {
        if = {
            limit = {
                FROM.FROM = { state = 123 }
            }
            if =  {
                limit = {
                    tag = BHR
                }
                FROM.FROM = {
                    set_state_name = STATE_123_BHR
                    set_province_name = {
                        id = 1234
                        name = VICTORY_POINTS_1234_BHR
                    }
                }
            }
            else = { # Unnested else is preferred over nested
                FROM.FROM = {
                    reset_state_name = yes
                    reset_province_name = 1234
                }
            }
        }
    }
}
ROOT是该省份新的控制者,FROM该省份之前的控制者,FROM.FROM 是省份ID。 1.4

战争目标相关

名字 描述 示例 提示 版本
on_generate_wargoal 每当一个国家生成一个战争目标时,触发该效果。
on_generate_wargoal = {  }
ROOT是战争目标的拥有国家,FROM是战争目标的目标国家。
on_justifying_wargoal_pulse 每当一个国家被作为正当化战争的目标时,触发该效果。
on_justifying_wargoal_pulse = { random_events = { 100 = war_justification.1 } }
FROM是战争目标的目标国家。每天进行检查 1.0
on_wargoal_expire 每当战争目标到期时,触发该效果。
on_wargoal_expire = { random_events = { 100 = war_justification.301 } }
FROM是战争目标的拥有国家。 1.0

将领相关

名字 描述 示例 提示 版本
on_unit_leader_created 每当招募一名新将领时,触发该效果。
on_unit_leader_created = { effect = { … } }
FROM是该将领所在国家,ROOT是该将领。 1.5
on_army_leader_daily 在每一天为一名将领触发该效果。
on_army_leader_daily = { effect = { … } }
FROM是该将领所在国家,ROOT是该将领。 1.0
on_army_leader_won_combat 每当一名将领打赢一场战斗时,触发该效果。
on_army_leader_won_combat = { effect = { … } }
FROM是该将领所在国家,ROOT是该将领。 1.0
on_army_leader_lost_combat 每当一名将领打输一场战斗时,触发该效果。
on_army_leader_lost_combat = { effect = { … } }
FROM是该将领所在国家,ROOT是该将领。 1.0
on_unit_leader_level_up 每当一名将领获得升级时,触发该效果。
on_unit_leader_level_up = { effect = { … } }
FROM是该将领所在国家,ROOT是该将领。 1.0
on_army_leader_promoted 每当一名将领晋升为元帅时,触发该效果。
on_army_leader_promoted = {
    effect = {
        add_timed_unit_leader_trait = { trait = recently_promoted days = 100 }
    }、
}
FROM是该将领所在国家,ROOT是该将领。 1.0
on_unit_leader_promote_from_ranks_veteran 每当一名战地军官晋升为将军时,触发该效果。
on_unit_leader_promote_from_ranks_veteran = { effect = { … } }
FROM是该战地军官所在的单位,OWNER是该战地军官所在的国家,ROOT是该战地军官。 1.12
on_unit_leader_promote_from_ranks_green 每当一名战地军官晋升为将军时,触发该效果。
on_unit_leader_promote_from_ranks_green = { effect = { … } }
FROM是该战地军官所在的单位,OWNER是该战地军官所在的国家,ROOT是该战地军官。 1.12

军事相关

名字 描述 示例 提示 版本
on_nuke_drop 每当一个国家投掷核弹时,触发该效果。
on_nuke_drop = {
    effect = {
        set_global_flag = first_nuke_dropped
    }
}
ROOT是发射核弹的国家,FROM是被核弹打击的省份。 1.0
on_pride_of_the_fleet_sunk 每当一个国家的舰队荣耀被击沉时,触发该效果。
on_pride_of_the_fleet_sunk = {
    effect = {
        if = {
            limit = {
                tag = ENG
            }
            FROM = { set_country_flag = achievements_pride_and_extreme_prejudice }
        }
    }
}
FROM是击沉舰队荣耀的国家,ROOT是被击沉舰队荣耀的国家。 1.6
on_naval_invasion 每当海上入侵发生时,触发该效果。
on_naval_invasion = {
    effect = { 
        ROOT = {    # Unlike most on_actions, ROOT isn't the default scope
            add_political_power = 100
        }
    }
}
THIS(默认作用域)是被入侵的省份,ROOT是入侵的国家,FROM是入侵开始的省份。 1.9
on_paradrop 每当空投发生时,触发该效果。
on_paradrop = { 
    effect = {
        FROM = {
            controller = {
                add_war_support = 0.01
            }
        }
    }
}
THIS (默认作用域)是未被空投的省份,ROOT是被空投的省份,FROM是进行空投的国家。 1.9
on_units_paradropped_in_state 这与on_paradrop的不同之处在于它对每一次空投运行一次,而不是对每个空投的单位运行一次。
on_paradrop = { 
    effect = {
        FROM = {
            controller = {
                add_war_support = 0.01
            }
        }
    }
}
ROOT是被空投的省份,FROM是进行空投的国家。
on_add_history 每当接收到单位的战斗历史记录时,触发该效果。
on_add_history = { effect = { … } }
ROOT是该单位。 1.12

王牌飞行员相关

名字 描述 示例 提示 版本
on_ace_promoted 每当创建一个王牌飞行员时,触发该效果。
on_ace_promoted = { random_events = { 100 = ace_promoted.1 } }
FROM是该王牌飞行员。 1.0
on_ace_killed 每当一个王牌飞行员被消灭时,触发该效果。
on_ace_killed = { random_events = { 100 = ace_died.1 } }
FROM是该王牌飞行员。 1.0
on_ace_killed_on_accident 每当我方王牌飞行员在意外中死亡时,触发该效果。
on_ace_killed_on_accident = { random_events = { 100 = ace_died.1 } }
FROM是我方意外死亡的王牌飞行员。 1.9
on_non_ace_killed_other_ace 每当我方非王牌飞行员击落敌方王牌飞行员时,触发该效果。
on_non_ace_killed_other_ace = { FROM = { random_events = { 100 = ace_died.1 } } }
FROM是该敌方王牌飞行员。 1.9
on_ace_killed_by_ace 每当一个王牌飞行员被另一个王牌飞行员击落(敌方击落我方)时,触发该效果。
on_ace_killed_by_ace = { random_events = { 100 = ace_killed_by_ace.1 } }
FROM是我方王牌飞行员,PREV是击落FROM的敌方王牌飞行员 1.0
on_ace_killed_other_ace 每当一个王牌飞行员被另一个王牌飞行员击落(我方击落敌方)时,触发该效果。
on_ace_killed_other_ace = { random_events = { 100 = ace_killed_other_ace.1 } }
FROM是我方王牌飞行员,PREV是被FROM击落的敌方王牌飞行员。 1.0
on_aces_killed_each_other 每当两个王牌飞行员在空中对决中同归于尽时,触发该效果。
on_aces_killed_each_other = { random_events = { 100 = aces_killed_each_other.1 } }
FROM是我方王牌飞行员,PREV是敌方王牌飞行员。 1.0

抵抗运动相关

名字 描述 示例 提示 版本
on_operation_completed 每当一名特工完成任务时,触发该效果。
on_operation_completed = { effect = { … } }
THIS是该特工,ROOT是发起行动的国家,FROM是目标国家。 1.9
on_operative_detected_during_operation 每当一名特工死亡时,触发该效果。
on_operative_death = { effect = { … } }
THIS是该特工,ROOT是杀死该特工的国家(可选),FROM是该特工执行任务的目标国家,FROM.FROM是任务状态(仅在任务有特定选择目标时设置)。 1.9
on_operative_on_mission_spotted 每当一名特工在一个国家执行破坏任务时,触发该效果。
on_operative_on_mission_spotted = { effect = { … } }
THIS是该特工,FROM是该特工正在执行任务所在的国家,ROOT是该特工所属国家。 1.9
on_operative_captured 每当一名特工被俘获时,触发该效果。
on_operative_captured = { effect = { … } }
THIS是该特工,ROOT是该特工执行任务所在的国家,FROM是该特工为其服务的国家。 1.9
on_operative_created 每当一名特工被创建时,触发该效果。
on_operative_created = { effect = { … } }
THIS是该特工,FROM是创建该特工的国家。 1.9.1
on_operative_death 每当一名特工死亡时,触发该效果。
on_operative_death = { effect = { … } }
THIS是该特工,ROOT是杀死该特工的国家(可选),FROM是该特工所属国家。 1.9
on_operative_recruited 每当一名特工被招募时,触发该效果。
on_operative_recruited = { effect = { … } }
THIS是该特工,FROM是创建该特工的国家。 1.9.1
on_fully_decrypted_cipher 每当一个国家完全破译了目标国家的密码时,触发该效果。
on_fully_decrypted_cipher = { effect = { … } }
THIS是密码被破译的国家,FROM是破译密码的国家。 1.9
on_activated_active_decryption_bonuses 每当一个国家针对目标国家激活已破译密码的加成效果时,触发该效果。
on_activated_active_decryption_bonuses = { effect = { … } }
THIS是目标国家,FROM是激活加成效果的国家。 1.9

军工组织系统(MIO)相关

名字 描述 示例 提示 版本
on_mio_size_increased 每当一个军工机构的规模增长(升级)时,触发该效果。 ROOT是该军工机构,FROM是该军工机构所在的国家。 1.13
on_mio_design_team_assigned_to_tech 每当一个军工机构被分配给科技研究时,触发该效果。 ROOT是该军工机构,FROM是该军工机构所在的国家。 1.13
on_mio_design_team_assigned_to_variant 每当一个军工机构被分配给一个装备的衍生型号时,触发该效果。 ROOT是该军工机构,FROM是该军工机构所在的国家。 1.13
on_mio_industrial_manufacturer_assigned 每当一个军工机构被分配到一条生产线时,触发该效果。 ROOT是该军工机构,FROM是该军工机构所在的国家。 1.13
on_mio_industrial_manufacturer_unassigned 每当一个军工机构被从一条生产线取消分配时,触发该效果。 ROOT是该军工机构,FROM是该军工机构所在的国家。 1.13