trigger · has_opinion_modifier
Definition
- Supported scope:
COUNTRY - Supported target:
none
Description
check if a country has the opinion modifier
has_opinion_modifierCOUNTRYnonecheck if a country has the opinion modifier
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.
has_opinion_modifier is commonly used to determine whether diplomatic relations have entered a specific phase, such as checking whether a country has imposed an "distrust" or "friendly agreement" opinion modifier on the player, thereby deciding whether subsequent diplomatic events or decisions should be available. When creating diplomatic chain mods, you can use it to prevent duplicate additions of same-named modifiers, or as a prerequisite condition for unlocking advanced cooperation options.
# Example: Only allow triggering this decision if the target country does not yet have the "trade_agreement_bonus" opinion modifier
available = {
FROM = {
NOT = {
has_opinion_modifier = {
modifier = trade_agreement_bonus
target = ROOT
}
}
}
}
[add_opinion_modifier](/wiki/effect/add_opinion_modifier) — The most direct companion: use has_opinion_modifier first to check whether the modifier exists, avoiding duplicate stacking of same-named modifiers that could cause logic confusion.[add_opinion_modifier](/wiki/effect/add_opinion_modifier) on the trigger side often works in conjunction with [has_country_flag](/wiki/trigger/has_country_flag) — use country flags to record diplomatic status, and combine with opinion modifiers to form a double-check judgment for "already processed" states.[has_dynamic_modifier](/wiki/trigger/has_dynamic_modifier) — similarly used to check whether a certain attached status exists; both are often listed in parallel within the same trigger block to jointly describe complete diplomatic or relationship state conditions.[has_relation_modifier](/wiki/trigger/has_relation_modifier) — outside the whitelist, but logically… (Note: this trigger is not in the whitelist, so not listed) — instead use [has_country_flag](/wiki/trigger/has_country_flag) as a supplementary judgment to mark bilateral relationship phases.target field: has_opinion_modifier typically requires both modifier (the modifier name) and target (the object being given the modifier) to be specified. If only the modifier name is written and target is omitted, the script may error or always return false. Beginners often mistakenly think the trigger itself has a problem.add_opinion_modifier: opinion modifiers must be predefined in /common/opinion_modifiers/ first. The name filled in has_opinion_modifier must exactly match the key in the definition file (case-sensitive). Minor spelling differences will cause the judgment to always return false with no error message.