Wiki

effect · create_purchase_contract

Definition

  • Supported scope:any
  • Supported target:none

Description

Creates a purchase contract between the countries.
Example:
create_purchase_contract = 
{
	seller = ENG
	buyer = RAJ
	civilian_factories = 2
	equipment = {
		type = infantry_equipment
		amount = 600
	}
	equipment = {
		type = armored_car1
		amount = 100
	}
}

实战 · 配合 · 坑

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

实战用法

create_purchase_contract 常用于建立国家间的军备贸易关系,例如在焦点或事件中模拟历史上的军备出口协议(如英国向殖民地输送装备、小国向大国采购武器等)。它允许同时指定工厂援助和多种装备批次,非常适合构建复杂的借贷援助或军售 mod 系统。

# 英国通过事件向南非联邦提供军备支援
country_event = {
    id = arms_trade.1
    immediate = {
        create_purchase_contract = {
            seller = ENG
            buyer = SAF
            civilian_factories = 1
            equipment = {
                type = infantry_equipment
                amount = 500
            }
            equipment = {
                type = support_equipment
                amount = 100
            }
        }
    }
}

配合关系

  • [every_purchase_contract](/wiki/effect/every_purchase_contract):创建合同后可遍历现有合同进行批量修改或取消,常用于在新合同建立前清理旧合同,避免合同堆积。
  • [any_country](/wiki/trigger/any_country):在 trigger 块中用来检查目标国家是否满足特定条件(如是否为特定阵营成员),决定是否触发 create_purchase_contract
  • [if](/wiki/effect/if):用条件分支包裹合同创建逻辑,根据不同游戏状态(如玩家选择的国策选项)动态决定 seller/buyer 组合或装备种类。
  • [custom_effect_tooltip](/wiki/effect/custom_effect_tooltip):由于合同细节在事件界面不会自动显示,搭配该命令可为玩家提供清晰的可读性提示,说明合同内容。

常见坑

  1. seller/buyer 必须是已存在的国家标签:若指定的国家在游戏中尚未被激活(如历史上尚未独立的国家),合同将静默失败而不报错,新手常因此误以为脚本本身有问题,需用 [country_exists](/wiki/trigger/country_exists) 提前检查。
  2. 重复执行会叠加合同而非覆盖:每次触发都会新建一份独立合同,若在循环或反复触发的事件中调用,会产生大量重复合同拖慢游戏,应在创建前用 [every_purchase_contract](/wiki/effect/every_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

create_purchase_contract is commonly used to establish military trade relationships between nations, such as simulating historical arms export agreements in focuses or events (e.g., Britain supplying equipment to colonies, smaller nations purchasing weapons from major powers). It allows simultaneous specification of factory aid and multiple equipment batches, making it ideal for building complex lend-lease or arms sales mod systems.

# British event providing military support to South African Union
country_event = {
    id = arms_trade.1
    immediate = {
        create_purchase_contract = {
            seller = ENG
            buyer = SAF
            civilian_factories = 1
            equipment = {
                type = infantry_equipment
                amount = 500
            }
            equipment = {
                type = support_equipment
                amount = 100
            }
        }
    }
}

Synergy

  • [every_purchase_contract](/wiki/effect/every_purchase_contract): After creating a contract, iterate through existing contracts for bulk modifications or cancellations. Commonly used to clean up old contracts before establishing new ones, preventing contract accumulation.
  • [any_country](/wiki/trigger/any_country): Used in trigger blocks to check whether the target nation meets specific conditions (e.g., faction membership), determining whether to trigger create_purchase_contract.
  • [if](/wiki/effect/if): Wrap contract creation logic in conditional branches to dynamically decide seller/buyer combinations or equipment types based on different game states (e.g., player-selected national focus options).
  • [custom_effect_tooltip](/wiki/effect/custom_effect_tooltip): Since contract details won't display automatically in the event interface, pairing this command provides clear, readable tooltips for players explaining contract contents.

Common Pitfalls

  1. seller/buyer must be existing country tags: If the specified nation hasn't been activated in the game (e.g., a historically non-independent nation), the contract will silently fail without error. Newcomers often mistake this for a script problem; use [country_exists](/wiki/trigger/country_exists) to check beforehand.
  2. Repeated execution stacks contracts rather than overwriting: Each trigger creates an independent contract. If called in loops or repeatedly-triggered events, it produces massive contract bloat that slows the game. Clean up old contracts with [every_purchase_contract](/wiki/effect/every_purchase_contract) before creation.