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
- 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.
- 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.