Wiki

trigger · ships_in_state_ports

Definition

  • Supported scope:COUNTRY
  • Supported target:none

Description

checks for amount of ships in specified state's ports. 
ships_in_state_ports = { 
  type = ship_category 
  state = state_id (or scopped variable) 
  size = 42 
}

实战 · 配合 · 坑

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

实战用法

ships_in_state_ports 常用于检测某一战略要地(如基尔港、塞瓦斯托波尔)是否已集结足够数量的战舰,以此触发剧本事件、解锁决议或判断玩家是否满足海军集结条件。例如,可在一个需要舰队封锁某关键港口的任务 available 块中用它验证兵力是否到位。

# 检查德国在基尔所在州(state = 57)是否至少有 5 艘任意类型战舰
available = {
    ships_in_state_ports = {
        type = ship
        state = 57
        size > 4
    }
}

配合关系

  • [controls_state](/wiki/trigger/controls_state) — 通常先确认该国实际控制目标州,再检查其港口停泊的舰船数量,避免对不属于自己的港口做无意义判断。
  • [has_navy_size](/wiki/trigger/has_navy_size)(注:此处应使用白名单内的 [has_army_size](/wiki/trigger/has_army_size) 同类逻辑参考)与 [any_navy_leader](/wiki/trigger/any_navy_leader) — 配合使用可同时验证整体海军规模和是否有指挥官就位,构成更完整的"舰队就绪"条件链。
  • [destroy_ships](/wiki/effect/destroy_ships) — 在 effect 块中作为后续动作,当条件满足(港口内舰船达标)后执行摧毁或转移舰船的操作,常见于投降或割让港口的剧本事件。
  • [any_owned_state](/wiki/trigger/any_owned_state) — 用于遍历所拥有的所有州,配合 ships_in_state_ports 检查是否存在任意一个己方州内驻有指定数量舰船,灵活应对多港口场景。

常见坑

  1. state 填写错误类型:新手容易直接填写州的名称字符串(如 state = "schleswig_holstein"),而该字段要求填写数字 state ID 或已经 scope 到 STATE 的变量,填错会导致条件静默失败、始终返回 false。
  2. type 字段混淆 ship_type 与 ship_categorytype 接受的是船只分类(如 shipcapital_shipscreening_shipsubmarine 等大类),而非具体的舰型名称(如 destroyer);误填具体舰型名称不会报错但可能永远匹配不到预期结果。

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_state_ports is commonly used to detect whether a strategic location (such as Kiel or Sevastopol) has assembled a sufficient number of warships, which can trigger scripted events, unlock decisions, or determine whether the player meets naval concentration requirements. For example, it can be used in the available block of a mission requiring a fleet to blockade a key port to verify that forces are in position.

# Check if Germany has at least 5 warships of any type in the state containing Kiel (state = 57)
available = {
    ships_in_state_ports = {
        type = ship
        state = 57
        size > 4
    }
}

Synergy

  • [controls_state](/wiki/trigger/controls_state) — Usually confirm that the country actually controls the target state first, then check the number of ships in its ports, avoiding meaningless checks on ports that don't belong to you.
  • [has_navy_size](/wiki/trigger/has_navy_size) (Note: use the whitelisted [has_army_size](/wiki/trigger/has_army_size) logic for reference) and [any_navy_leader](/wiki/trigger/any_navy_leader) — using them together allows you to verify both overall navy size and commander readiness, forming a more complete "fleet ready" condition chain.
  • [destroy_ships](/wiki/effect/destroy_ships) — as a follow-up action in effect blocks, when conditions are met (ships in port reach target numbers), execute operations to destroy or transfer ships, commonly seen in surrender or port cession scripted events.
  • [any_owned_state](/wiki/trigger/any_owned_state) — used to iterate through all owned states, paired with ships_in_state_ports to check whether any single friendly state contains a specified number of ships, flexibly handling multi-port scenarios.

Common Pitfalls

  1. Incorrect state field type: Beginners often directly fill in the state name as a string (e.g., state = "schleswig_holstein"), but this field requires a numeric state ID or a variable already scoped to STATE. Filling it incorrectly causes the condition to silently fail and always return false.
  2. Confusion between type field values for ship_type vs ship_category: type accepts ship categories (such as ship, capital_ship, screening_ship, submarine and other broad classes), not specific ship type names (such as destroyer). Filling in a specific ship type name won't cause an error but may never match the expected results.