Leader modding

Version

Please help with verifying or updating older sections of this article. At least some were last verified for version 3.0.

This article is for the PC version of Stellaris only.

This page is about modding the Leaders.

## Overview

Leader Classes are defined at "common/leader\_classes/xxx.txt".

Actually, a leader can have separated set of traits for each leader class and will switch between them if their leader class is changed. A leader that becomes the empire ruler receives a new set of ruler traits, overwritting its previous traits and not even traits that increase the leader lifespan can affect the leader for now, before it's elected out from the seat and return to its previous class.

You must understand that:

* There are 6 kinds of **hard-code classes**, namely Ruler, Governor, Scientist, Admiral, General and Envoy, and 6 kinds of **shell classes** to define some moddable characteristics.
* Everywhere else that referencing to a leader class are referencing to **hard-code classes**, not the **shell classes**.
* Adding more **shell classes** doesn't make sense because they are never called by the game engine.
* Removing the **shell classes** doesn't crash the game but this kind of leaders can't be generated.

This article is talking about the modding of **shell classes**. There is no way to mod **hard-code classes**.

## Data Structure

All vanilla leader traits that can be given to a newly generated leader have trait cost 1.
Rulers have 2 trait points, making them to be generated with 2 traits.
Envoys have 0, making them to have no traits upon generation.
 **can\_govern\_planet = <yes/no>****can\_research = <yes/no>****can\_lead\_navy = <yes/no>****can\_lead\_army = <yes/no>****can\_rule\_empire = <yes/no>****can\_be\_envoy = <yes/no>** | Defines what kind of tasks can this leader be assigned to.
Making a leader to do something that's usually not its job will switch its **hard-code class** and it receives a new set of traits for that class if it doesn't have yet.

There is a few practical we can do with leader classes, for example:

* Modify the trait points of leaders to make them spawn with more traits.
* Add "produces" with "potential" to the economy units to implement something that make leaders to produce resources.

## Dynamic Modding

### How to scope to a leader

Use scopes like `leader` and `ruler` to scope to the leader that's leading something.

Use scopes like `every_owned_leader` and `every_pool_leader` to evaluate some Effects through all leaders in an Empire that meet some conditions. Envoys can't be scoped this way.

Since Stellaris v2.7.1, a few more statements have been implemented for Envoys.

* `any/every/random/count_envoy` can be used to scope to Envoys.
* `has_envoy_task = { task = harm_relations/improve_relations/galactic_community/federation (optional: who = country) }` to check Envoy assignment.
* `envoy_location_country` can be used on Envoys to scope to the Empire this Envoy is harming / improving relation with.
* `has_envoy_cooldown = yes/no` to check if an Envoy is at cooldown,

### How to make leaders spawn with a trait, like Psychic

Use the On-Actions `on_leader_spawned`, `on_ruler_set` and `on_ruler_back_to_pre_ruler_class` to manually add and remove traits of Leaders. See Event modding for details.

### How to modify leader starting age

These can be modified through species classes and species traits. See Species modding and Traits modding for details.

**Modding**