Wiki

trigger · is_ally_with

Definition

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

Description

checks if a country is ally with another country. will check if two countries are same/in same faction/has subject master relation
Example: is_ally_with = ITA

实战 · 配合 · 坑

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

实战用法

is_ally_with 常用于外交事件或决策的 available/trigger 块中,判断当前国家与目标国是否处于盟友关系,从而限制特定选项仅对盟友开放,例如军事援助决策或联合行动事件。该 trigger 会同时识别同一阵营成员、主从关系(宗主/附庸)以及国家相同的情况,覆盖范围比单纯检查阵营成员更广。

# 决策:仅对盟友意大利开放的联合军事演习
available = {
    is_ally_with = ITA
    has_war = no
}

配合关系

  • [any_allied_country](/wiki/trigger/any_allied_country):当需要检查"是否与任意满足条件的盟友"存在关系时,可与 is_ally_with 搭配做双重过滤,前者遍历所有盟友,后者精确锁定特定国家。
  • [has_defensive_war_with](/wiki/trigger/has_defensive_war_with):常与 is_ally_with 并列使用,用于判断"与盟友共同处于防御战争"的复合条件,触发援助或联合防御事件。
  • [add_to_faction](/wiki/effect/add_to_faction):在 effect 块中,当 is_ally_with 返回假时才执行邀请入阵营的操作,避免重复添加已是盟友的国家。
  • [exists](/wiki/trigger/exists):使用前先确认目标国家标签存在于当前游戏局中,防止因国家被吞并导致 trigger 判断出现意外行为。

常见坑

  1. 误以为只检查同一阵营:新手常认为 is_ally_with 等同于"同一阵营成员"检查,但它同样对宗主-附庸关系返回真,若场景中需要严格区分"阵营盟友"与"主从关系",需额外用其他条件排除附庸情况。
  2. 在非 COUNTRY scope 下使用:该 trigger 仅支持 COUNTRY scope,若误用于 STATE 或 UNIT LEADER 等 scope 内会导致脚本报错或静默失效,需确保外层作用域是国家级别。

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

is_ally_with is commonly used in the available/trigger blocks of diplomatic events or decisions to check whether the current nation and target nation are in an allied relationship, thereby restricting specific options to allies only—for example, military aid decisions or joint operation events. This trigger simultaneously recognizes faction members, subject-overlord relationships (suzerain/vassal), and identical nations, providing broader coverage than checking faction membership alone.

# Decision: Joint military exercise available only to ally Italy
available = {
    is_ally_with = ITA
    has_war = no
}

Synergy

  • [any_allied_country](/wiki/trigger/any_allied_country): When you need to check "whether a relationship exists with any ally meeting certain conditions," it can be paired with is_ally_with for double filtering—the former iterates through all allies, the latter pinpoints a specific nation.
  • [has_defensive_war_with](/wiki/trigger/has_defensive_war_with): Often used in parallel with is_ally_with to determine the compound condition "in defensive war alongside an ally," triggering aid or joint defense events.
  • [add_to_faction](/wiki/effect/add_to_faction): In an effect block, the operation to invite a nation into a faction is only executed when is_ally_with returns false, preventing duplicate additions of nations already allied.
  • [exists](/wiki/trigger/exists): Before using, confirm the target nation tag exists in the current game session to prevent unexpected trigger behavior caused by the nation being annexed.

Common Pitfalls

  1. Mistaking it as only checking faction membership: Beginners often assume is_ally_with is equivalent to checking "same faction member," but it also returns true for subject-overlord relationships. If your scenario requires strict distinction between "faction allies" and "subject-overlord relationships," you must use additional conditions to exclude vassals.
  2. Using outside COUNTRY scope: This trigger only supports COUNTRY scope. If mistakenly used within STATE or UNIT LEADER scopes, it will cause script errors or silent failure. Ensure the outer scope is nation-level.