Wiki

trigger · ships_in_area

Definition

  • Supported scope:COUNTRY
  • Supported target:none

Description

checks for amount of ships in specified area

实战 · 配合 · 坑

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

实战用法

ships_in_area 常用于检测某国在特定海域的海军存在,例如在海战事件或决策中判断玩家或 AI 是否已在目标海区部署足够舰队,从而触发后续剧情或解锁特定选项。典型场景包括:封锁某条航线前检测己方舰船是否就位,或在任务链中验证玩家是否完成了战略部署。

# 示例:检测本国在北海区域是否有足够舰船,作为决策的 available 条件
decision_example = {
    available = {
        ships_in_area = {
            area = north_sea
            count > 5
            type = ship
        }
    }
}

配合关系

  • [has_navy_size](/wiki/trigger/has_navy_size)(如果白名单中存在)→ 实际上可改为 [any_navy_leader](/wiki/trigger/any_navy_leader):检测是否存在海军指挥官,配合 ships_in_area 可以同时确认舰队部署与指挥链完整性。
  • [controls_state](/wiki/trigger/controls_state):确认己方控制沿岸州省的同时,再用 ships_in_area 验证对应海域的舰船存在,两者联合可精确描述"沿海封锁"条件。
  • [convoy_threat](/wiki/trigger/convoy_threat):与 ships_in_area 配合,既检查己方舰船规模,又评估对方护航压力,适用于判断是否应启动潜艇战决策。
  • [destroy_ships](/wiki/effect/destroy_ships):在 ships_in_area 触发确认海域有船后,可在 effect 块中执行摧毁命令,形成"有则清除"的完整逻辑闭环。

常见坑

  1. area 字段填写错误area 必须填写游戏内定义的战略海区 ID(如 north_seaenglish_channel 等),直接填写省份 ID 或州 ID 会导致 trigger 静默失败,不报错但永远返回 false,新手很难排查。
  2. 忽略 scope 限制ships_in_area 只能在 COUNTRY scope 下使用,若写在 STATE scope(例如某个州的 trigger 块内)会导致脚本报错或行为异常,需要先用 owner = { ... } 等方式切换回 COUNTRY 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

ships_in_area is commonly used to detect naval presence of a country in a specific sea region—for instance, in naval combat events or decisions to determine whether the player or AI has deployed a sufficient fleet in the target area, thereby triggering subsequent storylines or unlocking specific options. Typical scenarios include checking whether your own ships are positioned before imposing a blockade on a shipping lane, or validating in a mission chain whether the player has completed a strategic deployment.

# Example: checking whether your country has sufficient ships in the North Sea region as an available condition for a decision
decision_example = {
    available = {
        ships_in_area = {
            area = north_sea
            count > 5
            type = ship
        }
    }
}

Synergy

  • [has_navy_size](/wiki/trigger/has_navy_size) (if present in the whitelist) → can alternatively be replaced with [any_navy_leader](/wiki/trigger/any_navy_leader): detects whether a naval commander exists; combined with ships_in_area, you can simultaneously confirm both fleet deployment and command chain integrity.
  • [controls_state](/wiki/trigger/controls_state): confirm that your side controls coastal states/provinces; then use ships_in_area to verify ship presence in the corresponding sea region. Together, these precisely describe "coastal blockade" conditions.
  • [convoy_threat](/wiki/trigger/convoy_threat): in combination with ships_in_area, both check your own fleet scale and assess the opponent's convoy escort pressure, suitable for determining whether to initiate a submarine warfare decision.
  • [destroy_ships](/wiki/effect/destroy_ships): after ships_in_area confirms that ships exist in the region, you can execute destroy commands in the effect block, forming a complete logical closure of "check and eliminate if present".

Common Pitfalls

  1. Incorrect area field: the area field must contain a strategic sea region ID as defined in the game (such as north_sea, english_channel, etc.). Directly entering a province ID or state ID will cause the trigger to fail silently without error messages, always returning false—a frustration for newcomers trying to debug.
  2. Ignoring scope restrictions: ships_in_area can only be used in COUNTRY scope; placing it in STATE scope (for example, within a trigger block of a particular state) will cause script errors or abnormal behavior. You must first switch back to COUNTRY scope using constructs like owner = { ... } before invoking it.