Wiki

effect · set_legitimacy

Definition

  • Supported scope:COUNTRY
  • Supported target:none

Description

set_legitimacy = 10. Sets legitimacy on scope country to specified value. Value has to be 0-100.

实战 · 配合 · 坑

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

实战用法

set_legitimacy 常用于事件或决策中直接重置傀儡/君主政体的合法性值,例如在政变后将合法性清零,或完成某个国策后将其拉满至 100。与 add_legitimacy 的累加方式不同,此命令是强制覆盖,适合需要精确控制初始状态的场景。

country_event = {
    id = my_mod.10
    # ...
    option = {
        name = my_mod.10.a
        # 政变成功,合法性跌至谷底
        set_legitimacy = 15
    }
}

配合关系

  • [add_legitimacy](/wiki/effect/add_legitimacy) — 与 set_legitimacy 互补:先用 set_legitimacy 确定基准值,再用 add_legitimacy 做动态增减,避免累加导致数值越界。
  • [add_stability](/wiki/effect/add_stability) — 合法性与稳定度往往同步变动,表现政权动荡或巩固时两者常一起调整。
  • [has_country_flag](/wiki/trigger/has_country_flag) — 在执行 set_legitimacy 前用旗帜检查确保同一事件链不会重复触发,防止数值被多次覆盖。
  • [add_popularity](/wiki/effect/add_popularity) — 合法性骤降时通常伴随执政党支持率的变化,两者搭配使政治面貌更真实。

常见坑

  1. 数值越界不报错但行为异常:传入小于 0 或大于 100 的值时游戏不会报错,但实际效果不符合预期;务必确保所有传入数值(包括变量计算结果)始终落在 0–100 范围内。
  2. 误用在非 COUNTRY scopeset_legitimacy 只对国家 scope 有效,若写在 every_owned_state 等状态循环内部则静默无效,新手常因 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

set_legitimacy is commonly used in events or decisions to directly reset the legitimacy value of a puppet state or monarchy, such as zeroing legitimacy after a coup or maxing it to 100 upon completing a national focus. Unlike the cumulative approach of add_legitimacy, this command forcibly overwrites the value, making it suitable for scenarios requiring precise control over initial states.

country_event = {
    id = my_mod.10
    # ...
    option = {
        name = my_mod.10.a
        # Coup successful, legitimacy plummets
        set_legitimacy = 15
    }
}

Synergy

  • [add_legitimacy](/wiki/effect/add_legitimacy) — Complements set_legitimacy: use set_legitimacy first to establish a baseline, then apply add_legitimacy for dynamic adjustments to avoid overflow from successive additions.
  • [add_stability](/wiki/effect/add_stability) — Legitimacy and stability typically shift in tandem; when depicting regime upheaval or consolidation, both are often adjusted together.
  • [has_country_flag](/wiki/trigger/has_country_flag) — Check flags before executing set_legitimacy to ensure the same event chain doesn't trigger multiple times, preventing the value from being overwritten repeatedly.
  • [add_popularity](/wiki/effect/add_popularity) — When legitimacy drops sharply, it is usually accompanied by changes in the ruling party's support; pairing these two creates a more authentic political landscape.

Common Pitfalls

  1. Out-of-range values produce no error but abnormal behavior: passing values less than 0 or greater than 100 triggers no error, but produces unexpected results in-game. Always ensure all input values (including variable calculations) stay within the 0–100 range.
  2. Misuse outside COUNTRY scope: set_legitimacy only works at country scope; placing it inside state loops like every_owned_state silently fails. Novices often struggle to find the cause of non-functioning commands due to scope hierarchy confusion.