Wiki

trigger · all_purchase_contracts

Definition

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

Description

Checks if all purchase contracts of the Country in scope matches the triggers.
tooltip=key can be defined to override title.
ex: GER = {
  all_purchase_contracts = {
	tooltip = my_loc_key # Optional
     ... Purchase Contract scope triggers ...
  }
}

实战 · 配合 · 坑

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

实战用法

all_purchase_contracts 常用于检查某国是否所有的军火采购合同都满足特定条件,例如在外交或事件决策中判断买方/卖方身份、合同所含装备类型等,从而决定是否触发某个后续效果。典型场景包括:限制某国只有在其全部采购合同均来自同一供应商时才能获得特殊加成,或在 AI 行为逻辑中排查合同状态。

# 检查 GER 的所有采购合同是否均由 USA 作为卖方提供
GER = {
    all_purchase_contracts = {
        tooltip = ger_all_contracts_from_usa_tt
        seller = {
            tag = USA
        }
    }
}

配合关系

  • any_of_scopes:当只需要"至少一份合同满足条件"时,与 all_purchase_contracts 搭配对比使用,形成"全部满足"与"任意满足"的逻辑互补。
  • buyer:在合同 scope 内用于判断采购方国家,是 all_purchase_contracts 内部最常见的子条件之一。
  • contract_contains_equipment:在合同 scope 内检查合同涉及的装备类型,与 all_purchase_contracts 组合可精确筛选特定装备的合同。
  • every_purchase_contract:效果侧的遍历命令,常与 all_purchase_contracts 结合先做条件判断、再对合同批量执行操作(如取消合同)。

常见坑

  1. scope 写错层级all_purchase_contracts 必须在 COUNTRY scope 下调用,内部 seller/buyer 等才是 Purchase Contract scope 的 trigger;新手容易在 STATE scope 或直接在根层级使用,导致脚本报错或条件永远不生效。
  2. 将"全部满足"与"存在满足"混淆all_purchase_contracts 在该国没有任何采购合同时会直接返回 true(空集全称命题为真),如果业务逻辑要求"至少有一份合同且满足条件",必须额外用 any_purchase_contractcount_triggers 等手段先确认合同存在,否则无合同时会误判为满足条件。

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

all_purchase_contracts is commonly used to check whether every arms purchase contract belonging to a country meets specific conditions — for example, verifying the buyer/seller identity or the equipment types included in the contracts when evaluating diplomatic or event decisions, in order to determine whether a subsequent effect should fire. Typical use cases include: restricting a special bonus to countries whose every active contract comes from the same supplier, or auditing contract states within AI behavior logic.

# Check whether all of GER's purchase contracts have USA as the seller
GER = {
    all_purchase_contracts = {
        tooltip = ger_all_contracts_from_usa_tt
        seller = {
            tag = USA
        }
    }
}

Synergy

  • any_of_scopes: Use this when you only need "at least one contract satisfies the condition." Pair it with all_purchase_contracts to create complementary "all must match" vs. "any must match" logic.
  • buyer: Used inside a contract scope to check the purchasing country; it is one of the most common sub-conditions written inside all_purchase_contracts.
  • contract_contains_equipment: Checks the equipment type covered by a contract from within the contract scope. Combining it with all_purchase_contracts lets you precisely filter contracts for a specific piece of equipment.
  • every_purchase_contract: The effect-side iteration command. It is frequently paired with all_purchase_contracts — first use the trigger to evaluate conditions, then use the effect to perform bulk operations on the matching contracts (e.g., cancelling them).

Common Pitfalls

  1. Wrong scope level: all_purchase_contracts must be called from within a COUNTRY scope; only then do inner triggers such as seller/buyer correctly resolve as Purchase Contract scope triggers. Beginners often place it inside a STATE scope or at the root level, causing script errors or conditions that never evaluate correctly.
  2. Confusing "all satisfy" with "at least one satisfies": When the country has no purchase contracts at all, all_purchase_contracts returns true immediately (a universal quantifier over an empty set is vacuously true). If your logic requires "at least one contract exists and satisfies the condition," you must separately confirm that a contract exists first — using any_purchase_contract, count_triggers, or a similar approach — otherwise a country with zero contracts will be incorrectly treated as meeting the condition.