trigger · and
Definition
- Supported scope:
any - Supported target:
THIS,ROOT,PREV,FROM,OWNER,CONTROLLER,OCCUPIED,CAPITAL
Description
all inside trigger must be true
andanyTHIS, ROOT, PREV, FROM, OWNER, CONTROLLER, OCCUPIED, CAPITALall inside trigger must be true
实战内容由 AI 生成,并已对照 vanilla 命令词表校验 —— 请当作起点而非权威依据。上方的定义节才是游戏自带文档原文。
and 是最基础的逻辑组合器,用于要求多个条件同时成立,例如在国家事件的 trigger 块中限定"必须是民主国家且处于战争状态",或在 focus 的 available 里叠加多项前置要求。在大型 mod 中常用它将若干子条件显式分组,提高脚本可读性。
focus = {
id = my_focus
available = {
and = {
is_historical_focus_on = no
country_exists = USA
not = { has_global_flag = ww2_started }
}
}
}
[not](/wiki/trigger/not) — 与 and 嵌套使用,实现"所有条件均满足,且某条件不成立"的复合逻辑。[or](/wiki/trigger/or) — 常作为 and 的子块,在整体"全部为真"要求中允许其中某组条件满足其一。[custom_trigger_tooltip](/wiki/trigger/custom_trigger_tooltip) — 包裹 and 块以自定义 tooltip 显示文本,避免界面将多个条件罗列得过于冗长。[count_triggers](/wiki/trigger/count_triggers) — 作为 and 的兄弟或子条件,统计满足数量后再与其余强制条件并列使用。and 导致误解逻辑层级:HOI4 的 trigger 块顶层默认即为隐式 and,但在 or / not 内部若想再做"全部成立"的子组合,必须显式写出 and = { ... },否则结构会被解析错误。and 内混写 effect 命令:and 是纯判断块,不能将 set_variable、if(effect 版)等改变游戏状态的命令写进去;应将逻辑判断与状态修改分别放在 trigger 和 effect 块中。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.
and is the most fundamental logical combinator, used to require multiple conditions to be true simultaneously. For example, in a country event's trigger block to restrict "must be a democratic nation and at war," or in a focus's available to stack multiple prerequisites. In large mods, it is commonly used to explicitly group sub-conditions and improve script readability.
focus = {
id = my_focus
available = {
and = {
is_historical_focus_on = no
country_exists = USA
not = { has_global_flag = ww2_started }
}
}
}
[not](/wiki/trigger/not) — Nested with and to implement composite logic of "all conditions satisfied AND a certain condition does not hold."[or](/wiki/trigger/or) — Commonly used as a sub-block of and, allowing one condition from a group to be satisfied within an overall "all true" requirement.[custom_trigger_tooltip](/wiki/trigger/custom_trigger_tooltip) — Wraps an and block to customize tooltip display text and avoid the interface listing multiple conditions excessively.[count_triggers](/wiki/trigger/count_triggers) — Used as a sibling or sub-condition of and to count satisfied conditions before combining with other mandatory conditions.and causes confusion in logic hierarchy: The top level of HOI4's trigger block implicitly functions as and by default, but within or / not, if you want to create a sub-combination of "all conditions must be true," you must explicitly write and = { ... }. Otherwise, the structure will be parsed incorrectly.and: and is a pure judgment block and cannot contain commands that modify game state like set_variable, if (effect version), etc. Logic judgments and state modifications should be placed in separate trigger and effect blocks respectively.