Wiki

effect · add_corps_commander_role

Definition

  • Supported scope:COUNTRY, CHARACTER
  • Supported target:none

Description

add corps commander role to character

Example:
add_corps_commander_role = {
	character = GER_Character_token # optional if inside character scope
	traits = {  }
	skill = 4
	attack_skill = 2
	defense_skill = 3
	planning_skill = 3
	logistics_skill = 5
	}
}

实战 · 配合 · 坑

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

实战用法

add_corps_commander_role 常用于 mod 中动态为某个角色解锁军团指挥官职位,例如在国策完成后让特定人物从文职顾问转变为可上战场的指挥官,或在事件触发时为新生成的角色赋予初始指挥能力。以下示例展示在国家 scope 内通过国策效果为指定角色添加军团指挥官职位:

focus = {
    id = GER_promote_rommel
    # ...
    completion_reward = {
        add_corps_commander_role = {
            character = GER_Character_token
            traits = { brilliant_strategist }
            skill = 3
            attack_skill = 4
            defense_skill = 2
            planning_skill = 3
            logistics_skill = 2
        }
    }
}

配合关系

  • [create_corps_commander](/wiki/effect/create_corps_commander):若角色尚不存在,需先用此命令创建角色并同时赋予指挥官职位;add_corps_commander_role 则用于对已有角色追加角色类型,两者在角色生命周期的不同阶段各司其职。
  • [add_field_marshal_role](/wiki/effect/add_field_marshal_role):当设计角色成长路线时,可配合使用——先赋予军团指挥官角色积累经验,之后在特定条件下再添加元帅角色,实现职位升迁逻辑。
  • [remove_unit_leader_role](/wiki/effect/remove_unit_leader_role):需要替换角色职位类型时,先用此命令移除旧职位,再添加新的军团指挥官角色,避免角色同时持有冲突职位。
  • [has_character](/wiki/trigger/has_character):在执行前用此触发器判断目标角色是否存在于当前国家,防止因角色缺失导致脚本报错。

常见坑

  1. 在 COUNTRY scope 下忘写 character 字段:只有当脚本已经处于该角色自身的 CHARACTER scope 时,character = ... 才可以省略;若在国家 scope 下调用却漏写角色 token,游戏将无法定位目标角色,效果静默失败且不会有任何报错提示,极难排查。
  2. 对已有军团指挥官角色的角色重复添加:若角色已持有军团指挥官角色,再次执行此命令可能导致技能值或特质出现异常叠加,建议在执行前用 [has_advisor_role](/wiki/trigger/has_advisor_role) 类似的逻辑(或检查角色当前角色状态)做条件判断,确保只在角色尚未持有该职位时才执行。

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

add_corps_commander_role is commonly used in mods to dynamically unlock the corps commander position for a character—for example, transforming a specific person from a civilian advisor into a battlefield-ready commander after focus completion, or granting initial command capabilities to a newly generated character when an event triggers. The following example demonstrates adding a corps commander role to a designated character within a national scope through focus effects:

focus = {
    id = GER_promote_rommel
    # ...
    completion_reward = {
        add_corps_commander_role = {
            character = GER_Character_token
            traits = { brilliant_strategist }
            skill = 3
            attack_skill = 4
            defense_skill = 2
            planning_skill = 3
            logistics_skill = 2
        }
    }
}

Synergy

  • [create_corps_commander](/wiki/effect/create_corps_commander): If a character does not yet exist, you must first use this command to create the character and simultaneously grant the commander role; add_corps_commander_role is used to add a role type to an existing character. Each serves its purpose at different stages of a character's lifecycle.
  • [add_field_marshal_role](/wiki/effect/add_field_marshal_role): When designing character progression paths, you can use both in combination—first grant the corps commander role to accumulate experience, then add the field marshal role under specific conditions later, implementing a promotion logic.
  • [remove_unit_leader_role](/wiki/effect/remove_unit_leader_role): When you need to replace a character's role type, use this command first to remove the old role, then add the new corps commander role, avoiding conflicts from a character holding incompatible positions simultaneously.
  • [has_character](/wiki/trigger/has_character): Before executing, use this trigger to verify whether the target character exists in the current country, preventing script errors caused by missing characters.

Common Pitfalls

  1. Forgetting the character field in COUNTRY scope: The character = ... field can only be omitted when the script is already within that character's own CHARACTER scope. If you call this in a country scope without specifying the character token, the game will fail to locate the target character, the effect fails silently with no error message, making it extremely difficult to debug.
  2. Repeatedly adding the role to a character who already has a corps commander role: If a character already holds a corps commander role, executing this command again may cause skill values or traits to stack abnormally. It is recommended to use conditional logic similar to [has_advisor_role](/wiki/trigger/has_advisor_role) (or check the character's current role status) before execution to ensure the command only runs when the character does not yet have that position.