effect · cancel_purchase_contract
Definition
- Supported scope:
PURCHASE_CONTRACT - Supported target:
none
Description
Cancels the scoped purchase contract.
Example:
contract = {cancel_purchase_contract = yes}
cancel_purchase_contractPURCHASE_CONTRACTnoneCancels the scoped purchase contract.
Example:
contract = {cancel_purchase_contract = yes}
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.
When a player or AI's purchase contract no longer meets its trigger conditions (for example, the buyer's faction changes or a resource agreement breaks down), you can call this effect within a contract iteration block to forcibly terminate that contract. This is commonly used in "dynamic trade management" mods to clear old contracts after specific events occur and prevent contract zombie accumulation.
# Example of canceling all contracts for the buyer in an event's immediate block
country_event = {
id = my_trade_mod.1
immediate = {
# Iterate through purchase contracts involving this country
every_purchase_contract = {
limit = {
buyer = { tag = ENG }
}
cancel_purchase_contract = yes
}
}
}
[buyer](/wiki/trigger/buyer) — Use to verify before execution whether the contract's buyer is the target country, preventing accidental cancellation of other countries' contracts.[seller](/wiki/trigger/seller) — Combine with seller identity filtering to ensure only contracts with specific suppliers are canceled.[contract_contains_equipment](/wiki/trigger/contract_contains_equipment) — Check the equipment type contained in the contract first, executing cancellation only for contracts containing specific equipment to achieve fine-grained control.[deal_completion](/wiki/trigger/deal_completion) — Skip cancellation when a contract has already completed its transaction, avoiding logic errors from redundant operations on concluded contracts.PURCHASE_CONTRACT scope (typically entered via every_purchase_contract / random_purchase_contract, etc.). Writing it directly under a country scope will cause script errors or silent failures—beginners most often forget to switch scope first.limit Causing Bulk Deletion: When iterating through all contracts without restricting with buyer/seller/contract_contains_equipment and other triggers, all purchase contracts for that country will be canceled at once, resulting in unexpected game state corruption.