Hands-On Usage
gain_xp is commonly used in event reward scenarios, such as granting experience to a general after completing a specific mission (winning a campaign, completing a training event) to allow faster leveling. It can also be used in focus trees or decisions to reward elite generals trained by the player, combined with other buffs to enhance character progression immersion.
# General gains experience after completing a campaign mission event
country_event = {
id = my_mod.1
option = {
name = my_mod.1.a
# Grant experience to a general in this country
random_army_leader = {
limit = { is_corps_commander = yes }
gain_xp = 10
}
}
}
Synergy
[skill](/wiki/trigger/skill) — Check the general's current skill level before granting experience to avoid wasting event triggers on already maxed-out generals.
[add_skill_level](/wiki/effect/add_skill_level) — When needing to jump multiple levels at once, divide responsibilities between gain_xp and this effect: the latter provides precise experience accumulation control, the former directly raises levels. Their purposes are similar but mechanics differ; use as needed.
[add_trait](/wiki/effect/add_trait) — After experience growth triggers a level-up, simultaneously add traits to simulate the narrative effect of generals acquiring skill expertise through combat achievements.
[is_corps_commander](/wiki/trigger/is_corps_commander) / [is_field_marshal](/wiki/trigger/is_field_marshal) — Use in limit blocks to filter the correct general scope, ensuring experience is only granted to intended character types.
Common Pitfalls
- Cannot be used to deduct experience: This command only adds experience; passing negative values will not reduce experience as expected. If you need to lower a general's abilities, use
[add_skill_level](/wiki/effect/add_skill_level) with negative values instead or directly replace traits.
- Scope must be CHARACTER: Calling
gain_xp directly under a country scope causes script errors or silent failures. You must first enter the correct character scope via random_army_leader, specific_character, or similar methods before calling it.