Wiki

effect · set_portraits

Definition

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

Description

set portraits for the target character. Syntax is similar to character files.

example:
set_portraits = {
		character = my_character # optional, use if not in a character scope		army = { small ="MySmallCharacterGFX"}
		civilian = { large ="MyLargeCharacterGFX" }
}

实战 · 配合 · 坑

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

实战用法

set_portraits 最常见于动态角色替换场景:当某个角色因剧情事件发生身份转变(如流亡、化妆潜伏、晋升换装)时,需要在不重建角色的情况下替换其头像。也可用于 DLC 风格的外观包 mod,根据玩家选择的国家外观分支动态切换领袖或将领的肖像资源。

# 某国领袖因政变改变身份后换装
country_event = {
    id = my_mod.5
    option = {
        name = my_mod.5.a
        set_portraits = {
            character = GER_my_leader
            civilian = { large = "GFX_my_leader_disguised_large" }
        }
    }
}

配合关系

  • [set_character_name](/wiki/effect/set_character_name):换装常伴随改名,两者配合可实现角色完整的"身份重塑",视觉与名称同步变更。
  • [add_country_leader_trait](/wiki/effect/add_country_leader_trait) / [remove_country_leader_trait](/wiki/effect/remove_country_leader_trait):肖像替换往往对应角色能力的变化,与特质增删联用使角色转变更完整。
  • [promote_character](/wiki/effect/promote_character):角色被提拔到新职位时,搭配 set_portraits 为其新身份配置专属头像,避免新旧职位共用同一张图显得突兀。
  • [has_character](/wiki/trigger/has_character):执行前先用此触发器确认目标角色确实存在于该国,防止脚本报错或静默失败。

常见坑

  1. 忘记 GFX 定义set_portraits 只负责指定 GFX 键名,若对应的 spriteType 未在 interface/*.gfx 文件中声明,游戏不会报错但会显示默认占位图,新手常误以为命令本身出了问题。
  2. 作用域混淆:在国家 scope 下使用时必须通过 character = <token> 指定目标角色;若已在角色 scope 内则可省略,但两者混用(既在角色 scope 又写 character =)并不会报错,却容易让逻辑意图不清晰,后期维护时造成误读。

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_portraits most commonly appears in dynamic character replacement scenarios: when a character undergoes an identity transformation due to a storyline event (such as exile, disguised infiltration, or promotion with costume change), their portrait needs to be swapped without rebuilding the character. It can also be used for DLC-style cosmetic mod packages, dynamically switching leader or general portraits based on the player's selected national appearance branch.

# Leader of a nation changes appearance after a coup
country_event = {
    id = my_mod.5
    option = {
        name = my_mod.5.a
        set_portraits = {
            character = GER_my_leader
            civilian = { large = "GFX_my_leader_disguised_large" }
        }
    }
}

Synergy

  • [set_character_name](/wiki/effect/set_character_name): Portrait changes often go hand-in-hand with renaming; using both together enables a complete "identity reinvention" with synchronized visual and name updates.
  • [add_country_leader_trait](/wiki/effect/add_country_leader_trait) / [remove_country_leader_trait](/wiki/effect/remove_country_leader_trait): Portrait replacement typically corresponds to changes in character abilities; combining these with trait additions/removals creates a more complete character transformation.
  • [promote_character](/wiki/effect/promote_character): When a character is promoted to a new position, pair set_portraits with exclusive portraits for their new role to avoid the awkwardness of sharing the same image across old and new positions.
  • [has_character](/wiki/trigger/has_character): Before execution, verify the target character actually exists in the country using this trigger to prevent script errors or silent failures.

Common Pitfalls

  1. Forgotten GFX definitions: set_portraits only specifies the GFX key name; if the corresponding spriteType is not declared in interface/*.gfx files, the game won't error but will display a default placeholder image. Beginners often mistakenly think the command itself is broken.
  2. Scope confusion: When used under country scope, the target character must be specified via character = <token>; if already within character scope it can be omitted, but mixing both (being in character scope while also writing character =) won't error but easily muddies intent and causes misreading during later maintenance.