Wiki

trigger · has_active_mission

Definition

  • Supported scope:COUNTRY
  • Supported target:none

Description

check if country has an active mission with specified ID. has_active_mission = my_test_mission

实战 · 配合 · 坑

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

实战用法

has_active_mission 常用于任务链设计中,当某个任务激活后需要锁定其他选项、显示特定提示或触发后续事件时作为前置条件判断。例如在 availabletrigger 块里检测玩家是否已处于某个倒计时任务的进行中,以防止重复触发或提供互斥逻辑。

# 在另一个决策的 available 里,避免与正在进行的任务冲突
available = {
    NOT = { has_active_mission = my_expansion_mission }
}

配合关系

  • [activate_mission](/wiki/effect/activate_mission):最直接的搭档——先用 activate_mission 激活任务,再用 has_active_mission 检测该任务是否仍在运行,形成完整的"激活→监测"闭环。
  • [add_days_mission_timeout](/wiki/effect/add_days_mission_timeout):需要在任务进行中动态延长倒计时时,先用 has_active_mission 确认任务处于激活状态再执行,避免对不存在的任务操作。
  • [has_decision](/wiki/trigger/has_decision):两者常并排出现在同一 trigger 块中,分别检测决策与任务的激活状态,共同构成复杂任务链的互斥或联锁条件。
  • [activate_mission_tooltip](/wiki/effect/activate_mission_tooltip):在 available 判断失败时用于向玩家提示"某任务正在进行中"的原因,与 has_active_mission 配合提升 UI 可读性。

常见坑

  1. 任务 ID 拼写与 missions 文件不一致has_active_mission 的值必须与 missions 文件夹中对应任务块的键名完全一致(区分大小写),写错 ID 不会报错但永远返回假,导致逻辑静默失效,排查时极难发现。
  2. 误以为任务完成后仍为"active":任务超时或被完成后即不再处于激活状态,该 trigger 会立刻返回假;若需要检测"曾经触发过"的状态,应改用 [has_country_flag](/wiki/trigger/has_country_flag) 配合在任务 complete_effect 中设置标记旗帜来持久记录。

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_active_mission is commonly used in mission chain design to lock other options, display specific prompts, or trigger subsequent events once a mission is activated. It serves as a prerequisite check in available or trigger blocks to determine whether the player is currently in an active countdown mission, preventing duplicate triggers or enforcing mutually exclusive logic.

# In another decision's available block, prevent conflicts with ongoing missions
available = {
    NOT = { has_active_mission = my_expansion_mission }
}

Synergy

  • [activate_mission](/wiki/effect/activate_mission): The most direct partner — first use activate_mission to activate a mission, then use has_active_mission to check if that mission is still running, forming a complete "activate → monitor" loop.
  • [add_days_mission_timeout](/wiki/effect/add_days_mission_timeout): When dynamically extending a countdown timer during mission execution, use has_active_mission first to confirm the mission is active before proceeding, avoiding operations on non-existent missions.
  • [has_decision](/wiki/trigger/has_decision): These two often appear side-by-side in the same trigger block, separately checking the activation status of decisions and missions to jointly establish mutual exclusion or interlocking conditions for complex mission chains.
  • [activate_mission_tooltip](/wiki/effect/activate_mission_tooltip): Used to hint to the player "a certain mission is in progress" when available checks fail, improving UI readability in conjunction with has_active_mission.

Common Pitfalls

  1. Mission ID spelling mismatch with missions file: The value in has_active_mission must match the key name of the corresponding mission block in the missions folder exactly (case-sensitive). Misspelling the ID produces no error but always returns false, causing silent logic failure that is extremely difficult to debug.
  2. Mistaking completed missions as still "active": Once a mission times out or is completed, it no longer remains in active status, and this trigger immediately returns false. If you need to check for "previously triggered" states, use [has_country_flag](/wiki/trigger/has_country_flag) instead, setting a flag in the mission's complete_effect to persistently record the state.