Wiki

trigger · any_purchase_contract

Definition

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

Description

Checks if at least one Purchase contract of the Country in scope matches the triggers. 
tooltip=key can be defined to override title.
ex: GER = {
  any_purchase_contract = {
	tooltip = my_loc_key # Optional
    ... Purchase Contract scope triggers ...
  }
}

实战 · 配合 · 坑

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

实战用法

any_purchase_contract 常用于检测某国是否存在满足特定条件的采购合同,例如在外购军备 DLC 相关 mod 中,判断一国是否有正在进行的特定装备采购,从而触发事件或解锁决策。典型场景包括:当某国至少有一份合同处于特定交付阶段时,才允许执行对应的外交选项或 AI 行为。

# 检查德国是否存在至少一份包含某类装备的采购合同
GER = {
    any_purchase_contract = {
        contract_contains_equipment = {
            type = infantry_equipment
        }
    }
}

配合关系

  • buyer — 在 any_purchase_contract 的子块中使用,用于进一步限定该合同的买方是否为目标国,实现更精确的合同筛选。
  • seller — 与 buyer 对应,用于检查合同的卖方身份,常与 buyer 同时使用以定位双边特定合同。
  • contract_contains_equipment — 最常见的子条件,用于确认合同中包含的装备类型,是 any_purchase_contract 最核心的配套 trigger。
  • every_purchase_contract — 在 effect 侧遍历所有合同执行操作,通常先用 any_purchase_contract 做存在性检查,再用 every_purchase_contract 批量处理。

常见坑

  1. 在错误 scope 下调用any_purchase_contract 只能在 COUNTRY scope 下使用,若写在 STATE 或 UNIT LEADER 等 scope 内会静默失败或报错,需确保外层是国家 scope(如 GER = { ... }ROOT = { ... } 且 ROOT 为国家)。
  2. 混淆 any 与 all 语义any_purchase_contract 只要有一份合同满足子条件即返回真;若想要求全部合同都满足条件,应另行用 NOT + any_purchase_contract 取反逻辑,而不是误以为存在 all_purchase_contract 这一命令(白名单中并不存在)。

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

any_purchase_contract is commonly used to check whether a country has at least one purchase contract that meets specific conditions — for example, in mods related to the foreign arms purchasing DLC, determining whether a nation has an ongoing contract for a particular type of equipment in order to fire an event or unlock a decision. Typical use cases include gating a diplomatic option or AI behavior behind the requirement that at least one contract is at a specific delivery stage.

# Check whether Germany has at least one purchase contract containing a specific equipment type
GER = {
    any_purchase_contract = {
        contract_contains_equipment = {
            type = infantry_equipment
        }
    }
}

Synergy

  • buyer — Used inside the child block of any_purchase_contract to further restrict whether the buyer of the contract is the target country, enabling more precise contract filtering.
  • seller — The counterpart to buyer; used to check the seller's identity on a contract. Frequently used alongside buyer to pinpoint a specific bilateral contract.
  • contract_contains_equipment — The most common sub-condition, used to confirm the equipment type included in a contract. This is the most essential companion trigger for any_purchase_contract.
  • every_purchase_contract — The effect-side counterpart that iterates over all contracts to perform operations. The typical pattern is to use any_purchase_contract first for an existence check, then use every_purchase_contract to process them in bulk.

Common Pitfalls

  1. Calling it in the wrong scope: any_purchase_contract can only be used within a COUNTRY scope. Writing it inside a STATE or UNIT LEADER scope will cause it to silently fail or throw an error. Make sure the enclosing scope is a country scope (e.g., GER = { ... } or ROOT = { ... } where ROOT is a country).
  2. Confusing any semantics with all semantics: any_purchase_contract returns true as long as at least one contract satisfies the sub-conditions. If you need all contracts to satisfy the conditions, use NOT + any_purchase_contract with inverted logic — do not assume that an all_purchase_contract command exists, as it is not present in the whitelist.