Wiki

trigger · gives_military_access_to

Definition

  • Supported scope:COUNTRY
  • Supported target:THIS, ROOT, PREV, FROM, OWNER, CONTROLLER, OCCUPIED, CAPITAL

Description

check if country gives military access to specified country

实战 · 配合 · 坑

实战内容由 AI 生成,并已对照 vanilla 命令词表校验 —— 请当作起点而非权威依据。上方的定义节才是游戏自带文档原文。

实战用法

gives_military_access_to 常用于外交或战略决策场景,例如判断玩家/AI是否已获得某国的过境许可后,才允许执行后续的借道进攻决策,或用于成就/事件触发条件中验证外交关系状态。典型用法是在事件 trigger 块或决策 available 块中,检测当前国家是否正在向特定国家提供军事通行权。

# 示例:只有当本国正在向德国提供军事通行权时,该决策才可用
decision_example = {
    available = {
        gives_military_access_to = GER
    }
    ...
}

配合关系

  • [has_country_flag](/wiki/trigger/has_country_flag):通常在判断军事通行权之前,先检查某个外交流程标记是否已设置,两者组合可以精确控制事件链的触发时机。
  • [any_allied_country](/wiki/trigger/any_allied_country):在遍历盟友时嵌套使用,可检查"是否有任何盟友正在向指定国家提供通行权",适合构建联盟外交链条逻辑。
  • [has_defensive_war_with](/wiki/trigger/has_defensive_war_with):与本触发器组合,可判断"在与某国处于防御战争状态的同时是否仍向其提供通行权"这类边缘外交矛盾情况,用于特殊事件或警告触发。
  • [diplomatic_relation](/wiki/effect/diplomatic_relation):作为对应的 effect,当 gives_military_access_to 判断为假时,可用此命令补充建立或修改外交关系,形成"检查→补偿"的完整逻辑。

常见坑

  1. scope 方向混淆:该触发器检查的是"当前 scope 国家向目标国家提供通行权",而非反向(目标国家给当前国家)。新手容易将提供方与接受方搞反,若要检查"我方是否从某国获得通行权",需要切换到对方 scope 来使用此触发器。
  2. 目标填写国家 TAG 而非 scope 关键字时的误用:目标支持 THIS/ROOT 等 scope 关键字,但新手有时会直接硬编码己方 TAG(如 gives_military_access_to = GER 写在德国 scope 内),导致变成"德国是否给德国自己通行权"这类无意义判断,应优先使用 THISROOT 等动态指针以保证逻辑通用性。

Hands-On Notes

Hands-on notes are AI-generated and checked against the vanilla command vocabulary — treat them as a starting point, not authoritative reference. The definition above is the game's own documentation.

Hands-On Usage

gives_military_access_to is commonly used in diplomatic or strategic decision scenarios, such as checking whether the player/AI has already obtained transit permission from a certain nation before allowing subsequent decisions to attack via that route, or validating diplomatic relationship states in achievement/event trigger conditions. Typical usage occurs in event trigger blocks or decision available blocks, where you check whether the current country is currently granting military passage rights to a specific nation.

# Example: This decision is only available if this nation is granting military access to Germany
decision_example = {
    available = {
        gives_military_access_to = GER
    }
    ...
}

Synergy

  • [has_country_flag](/wiki/trigger/has_country_flag): Typically check whether a diplomatic process flag has been set before evaluating military passage rights; combining these two allows precise control over event chain trigger timing.
  • [any_allied_country](/wiki/trigger/any_allied_country): When iterating through allies in a nested fashion, you can check "whether any ally is granting passage rights to the specified nation," ideal for constructing alliance diplomacy chain logic.
  • [has_defensive_war_with](/wiki/trigger/has_defensive_war_with): Combined with this trigger, you can detect edge-case diplomatic contradictions like "is this nation granting passage rights while simultaneously in a defensive war with that same nation," useful for special events or warning triggers.
  • [diplomatic_relation](/wiki/effect/diplomatic_relation): As the corresponding effect, when gives_military_access_to evaluates to false, you can use this command to supplement and establish or modify diplomatic relations, forming a complete "check → compensate" logic flow.

Common Pitfalls

  1. Scope direction confusion: This trigger checks whether the current scope nation is granting passage rights to the target nation, not the reverse (target nation granting to current nation). Beginners often mix up provider and receiver; if you need to check "whether my nation has obtained passage rights from a certain nation," you must switch to that other nation's scope to use this trigger.
  2. Misuse when hardcoding nation TAGs instead of scope keywords as the target: The target supports scope keywords like THIS/ROOT, but beginners sometimes hardcode their own TAG directly (e.g., writing gives_military_access_to = GER within Germany's scope), resulting in a meaningless check like "is Germany granting passage rights to itself." Always prioritize dynamic pointers like THIS or ROOT to ensure logic portability.