Wiki

trigger · has_offensive_war

Definition

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

Description

is country at offensive war

实战 · 配合 · 坑

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

实战用法

has_offensive_war 常用于判断某国当前是否处于进攻性战争状态,例如在国策、决议或事件中限制只有正在主动出击的国家才能触发特定奖励或选项。典型场景包括:禁止处于攻势的国家获取某些外交事件选项,或在 AI 策略中检查盟友是否已经开战以决定是否跟进参战。

# 仅当本国正在进行进攻性战争时,才允许触发该决议
available = {
    has_offensive_war = yes
}

配合关系

  • [has_defensive_war](/wiki/trigger/has_defensive_war):两者经常成对使用,通过 OR/NOT 组合区分"主动进攻"与"被动防御",精确筛选国家所处的战争性质。
  • [any_enemy_country](/wiki/trigger/any_enemy_country):在确认存在进攻性战争后,进一步遍历敌对国以添加针对具体交战对象的条件判断。
  • [create_wargoal](/wiki/effect/create_wargoal):在 effect 块中与之配合,先用 has_offensive_war 确认已处于战争状态,避免重复创建战争目标导致逻辑冲突。
  • [has_war_support](/wiki/trigger/has_war_support)(即 [any_war_score](/wiki/trigger/any_war_score)):攻势战争中常需同步检查战争支持度或战争分数,以决定是否触发后续奖励或惩罚事件。

注:has_war_support 不在白名单中,上方第四条请替换为:

  • [casualties](/wiki/trigger/casualties):进攻战争往往伴随较高伤亡,可配合 casualties 阈值判断攻势激烈程度,进而触发不同的事件分支。

常见坑

  1. 混淆进攻/防御判定:新手容易认为"只要在打仗就返回 yes",但实际上发起宣战方才是进攻方;若本国是被宣战的一方,需改用 has_defensive_war,否则条件永远不会触发。
  2. 在非 COUNTRY scope 下使用:该 trigger 只支持国家 scope,若误写在 STATE 或 CHARACTER scope 块内(如 every_owned_statelimit 中而没有切回国家 scope),游戏会报错或静默返回 false,需确保外层 scope 是国家或显式用 OWNER 等目标切换回国家 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

has_offensive_war is commonly used to determine whether a nation is currently engaged in an offensive war, for example in national focuses, decisions, or events to restrict certain rewards or options to only those nations actively on the offensive. Typical scenarios include: preventing nations on the offensive from accessing certain diplomatic event options, or checking in AI strategies whether allies have already joined the war to decide whether to follow suit.

# This decision can only be triggered when the nation is conducting an offensive war
available = {
    has_offensive_war = yes
}

Synergy

  • [has_defensive_war](/wiki/trigger/has_defensive_war): These two are frequently used in pairs, combining with OR/NOT to distinguish between "active aggression" and "passive defense", precisely filtering the nature of a nation's war status.
  • [any_enemy_country](/wiki/trigger/any_enemy_country): After confirming the existence of an offensive war, further iterate through hostile nations to add conditional checks specific to the actual belligerents.
  • [create_wargoal](/wiki/effect/create_wargoal): When paired in effect blocks, first use has_offensive_war to confirm the nation is already in a war state, avoiding logic conflicts from duplicate wargoal creation.
  • [casualties](/wiki/trigger/casualties): Offensive wars often involve high casualties, which can be combined with casualties thresholds to judge the intensity of the offensive, thereby triggering different event branches.

Common Pitfalls

  1. Confusing offensive/defensive determination: Beginners often assume "any active war returns yes", but in fact only the nation that declared war is the aggressor; if your nation is the one being declared on, use has_defensive_war instead, otherwise the condition will never trigger.
  2. Using outside COUNTRY scope: This trigger only supports national scope; if mistakenly written in a STATE or CHARACTER scope block (such as in the limit of every_owned_state without switching back to national scope), the game will error or silently return false. Ensure the outer scope is a nation or explicitly switch back to national scope using OWNER or similar target selectors.