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
- 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.
- 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.