Trait modding

From Crusader Kings II Wiki
Jump to: navigation, search
Traits are a major part of CKII and thus also for any overhaul mod. This article will explain everything you need to know about trait modding. Notepad++ is strongly recommended for modding traits, but Notepad or other plain text editors can also be used.

Definition[edit]

Traits must be defined in the folder common/traits/. To make the trait, you will first need to tell the game what effects it has. That will be done here. For this tutorial, a 'selfish' trait will be used as an example. To start off, give the trait a name:

selfish = {
}

Type[edit]

After defining the trait itself, you'll want to define its flags. The flags you can use are listed below.

The trait icons are grouped by type in-game, from left to right: education, caste_tier, undefined, lifestyle, personality, is_health. Inside a group, the order is based on the order the traits have been added to the character.

Flag Value Description Vanilla examples Code
agnatic bool Children of a father with this trait will always inherit the trait Sayyid  agnatic = yes
birth int Given number out of every 10000 characters born will receive this trait, (e.g., 100 = 1%) birth = 100
blinding bool The trait reflects permanent blinding of the character while imprisoned. In some cultures, this disinherits them. Blinded  blinding = yes
cached bool All characters that have this trait will be cached for more efficient event trigger evaluation (should be a limited number).

Then the character scope <trait_name> = {} can be use to scope to all characters with that trait.

cached = yes
can_hold_titles bool The trait prevents the character from holding any titles Horse  can_hold_titles = no
cannot_inherit bool The trait prevents the character from inheriting any titles Monk  cannot_inherit = yes
cannot_marry bool The trait prevents the character from marrying. See can_marry condition. Does not prevent concubinage. Monk  cannot_marry = yes
caste_tier int The trait is a caste trait, and caste_tier defines the order of the castes Brahmin  caste_tier = 3
customizer bool Blocks the trait from being available for selection in the Ruler Designer customizer = no
education bool The trait is an educational trait. See can_marry condition. Amateurish plotter  education = yes
attribute attribute Main attribute, in case of education traits. Amateurish plotter  attribute = intrigue
enatic bool Children of a mother with this trait will always inherit the trait enatic = yes
hidden bool Hidden traits are not shown in character view. hidden = yes
immortal bool Once this trait is applied, the character will no longer age nor die naturally (but can die from execution or the effect death). See immortal. immortal = yes
in_hiding bool The trait activates in_hiding status In hiding  in_hiding = yes
inbred bool The trait indicates that the character is inbred, affecting offspring and fertility and natural death causes Inbred  inbred = yes
incapacitating bool The character is weak and needs a regent Incapable  incapacitating = yes
inherit_chance int A newborn can inherit the trait from a parent (optional); if both parents have the trait, uses two trials of same chance inherit_chance = 15
both_parent_has_trait_inherit_chance int Dwarf  both_parent_has_trait_inherit_chance = 50
is_epidemic bool The trait is given by an epidemic outbreak. See has_epidemic condition. Tuberculosis  is_epidemic = yes
is_health bool The trait affects the health of a character, usually restricting certain events that require full health. See health_traits condition. Stressed  is_health = yes
is_illness bool The trait is a regular disease. See is_ill condition and cure_illness effect. Ill  is_illness = yes
leader bool The trait is a command/leadership trait. See can_have_more_leadership_traits condition. Light foot leader  leader = yes
leadership_traits int The character automatically receives X number of leadership traits (army command traits). leadership_traits = 1
childhood bool The trait is a childhood trait. Willful  childhood = yes
lifestyle bool The trait is a lifestyle choice. See lifestyle_traits condition. Scholar  lifestyle = yes
opposites List<trait> List of traits that cannot be held simultaneously with this trait opposites = { imbecile quick genius }
personality bool The trait is a personality trait (see trigger personality_traits = <min. count>) Lustful  personality = yes
prevent_decadence bool The trait prevents the Muslim character from accumulating decadence prevent_decadence = yes
priest bool The trait implies a theological education. See is_priest condition) Detached priest  priest = yes
pilgrimage bool The character is temporarily away and will need a regent but does not lose any wards On pilgrimage  pilgrimage = yes
random bool With random = no, the trait will not be given to randomly-generated characters (when the game starts or when characters are spawned other than by being born). random = yes is the default. Specific semantics vary with the general trait type. random = no
rebel_inherited bool ? rebel_inherited = yes
religious bool The trait is religious in nature and should be automatically discarded upon religion change. Note: it will also be discarded upon pagan reformation. Mutazilite  religious = yes
religious_branch religion The trait identifies a sect of that religion. This will also make the children inherit the trait on birth. Shaivist hindu  religious_branch = jain
ruler_designer_cost int Sets a custom cost (in years of ruler's age, positive or negative) for this trait in the Ruler Designer. ruler_designer_cost = -20
tolerates_<religion_group> bool The character tolerates characters of that religion group and is tolerated by them. <religion_group> is dynamic and may be a group not present in vanilla. Sympathy Christendom  tolerates_christian = yes

tolerates_jewish_group = yes
tolerates_muslim = yes
tolerates_pagan_group = yes
tolerates_zoroastrian_group = yes
tolerates_indian_group = yes

same_trait_visibility bool The trait will only be visible on other characters if the player also has it. Handy for things like secret societies, cults, and secret bears.

This is a shortcut for:

is_visible = { 
	OR = {
		character = FROM
		has_trait = <trait>
	}
}
Not used in vanilla same_trait_visibility = yes
hidden bool Used for technical traits needed to activate behaviors that are only possible with traits (incapacitating = yes, cannot_marry = yes, cannot_inherit = yes). N/A hidden = yes
hidden_from_others bool The trait will only be visible to the player who has the trait, even other players with the same trait won't see it.

This is a shortcut for is_visible = { character = FROM }.

Secretly Cathar  hidden_from_others = yes
is_visible conditions Conditions for the trait to be visible:
  • ROOT is the character with the trait
  • FROM the character looking at the trait

Typically a character should see its own traits, so at least character = FROM is used.

Secretly Catholic 
is_visible = {
  OR = {
    character = FROM
    society_member_of = secret_religious_society_catholic
    AND = {
      is_close_relative = FROM
      trait = secretly_catholic
    }
  }
}
vice bool Lustful  vice = yes
virtue bool Charitable  virtue = yes
succession_gfx bool Wounded  succession_gfx = yes
is_symptom bool Cough  is_symptom = yes

In the case of the 'selfish' trait, a personality flag would be used. Do note that it is possible to use multiple flags for a trait.

selfish = {
  personality = yes
}

Modifiers[edit]

Main article: Modifiers

After setting the trait's flags, you'll likely want to give it some character modifiers and/or a command modifier.


For 'selfish', a stewardship benefit and a diplomacy penalty would be appropriate.

selfish = {
  personality = yes
stewardship = 2 # The CKII engine doesn't recognize '+', simply write the number when giving positive numbers diplomacy = -1 }

Regarding relations, no one likes someone who is selfish, so in our case, we would have to add an opposite for charitable and a general_opinion:

 selfish = {
  personality = yes
stewardship = 2 # The CKII engine doesn't recognize '+', simply write the number when giving positive numbers diplomacy = -1
opposites = { trait = charitable }
opposite_opinion = -30 general_opinion = -10 }

Regarding AI Weights, which affect how non-player characters will act (most of which primarily affect strategic considerations), for the 'selfish' trait, an ai_rationality would be good.

selfish = {
  personality = yes
stewardship = 2 # The CKII engine doesn't recognize '+', simply write the number when giving positive numbers diplomacy = -1
opposites = { trait = charitable }
opposite_opinion = -30 general_opinion = -10
ai_rationality = -10 }

Potential[edit]

The potential section defines who can randomly start with the trait on campaign start, be randomly generated with the trait (for example via the employment decisions), or gain it randomly when coming of age. It does however not affect the outcomes of events giving the trait; even if the character does not meet the potential conditions he can still get the trait via events.

The potential section is simply one or more conditions. It is put immediately after the opening bracket of the trait. We might for example want to prevent the game from generating selfish children.

selfish = {
  potential = {
     age = 16 #This prevents anyone from under 16 being generated with the trait
  }
  personality = yes
stewardship = 2 # The CKII engine doesn't recognize '+', simply write the number when giving positive numbers diplomacy = -1
opposites = { trait = charitable } opposite_opinion = -30 general_opinion = -10
ai_rationality = -10 }

Compliments[edit]

Since Way of Life it is possible to add compliments and insults which can be in letters from other characters. These require localisation.

Flag Description Code
male_compliment

female_compliment

Compliments in a letter to a man/woman male_compliment = COMPL_SCHOLAR
male_compliment_adj

female_compliment_adj

Possitive Adjectives in a letter to a man/woman male_compliment_adj = COMPL_LEARNED
male_insult

female_insult

Insults in a letter to a man/woman male_insult = INSULT_TORTURER
male_insult_adj

female_insult_adj

Negative Adjectives in a letter to a man/woman male_insult_adj = INSULT_EVIL
child_compliment Compliments in a letter written by a child, used instead of the adult ones child_compliment = COMPL_SMARTY
child_compliment_adj Possitive adjectives in a letter written by a child, used instead of the adult ones child_compliment_adj = COMPL_CLEVER
child_insult Insults in a letter written by a child, used instead of the adult ones child_insult = INSULT_PEABRAIN
child_insult_adj Negative Adjectives in a letter written by a child, used instead of the adult ones child_insult_adj = INSULT_STUPID
selfish = {
  potential = {
     age = 16
  }
  personality = yes
  stewardship = 2
  diplomacy = -1
  opposites = {
     trait = charitable
  }
  
  opposite_opinion = -30
  general_opinion = -10
  ai_rationality = -10
  
  male_insult = INSULT_SELFCENTERED
  female_insult = INSULT_SELFCENTERED
  male_insult_adj = INSULT_SELFISH
  female_insult_adj = INSULT_SELFISH
}

Icon[edit]

Icons make traits easily recognizable to the player. An icon can be made in Photoshop or another image editor. It needs to be 24x24 pixels, and saved as a .dds or .tga file.

When you have your icon, save it in <yourmodfolder>\gfx\traits. Now create a file at <yourmodofolder>\interface\<yourmod>.gfx. You will use this file to tell the game where the icon is stored.

Start by adding this to the file:

spriteTypes = {
	spriteType = {
	
	}
}

Make sure that you never repeat the spriteTypes block! You should instead be adding spriteType (no "s" on the end) items inside its opening and closing { curly brackets/braces }.

Now, add a line for the name:

spriteType = {
  name = "GFX_trait_<nameofthetrait>"
}

Now you should add a line to tell the game where the icon is stored:

spriteType = {
  name = "GFX_trait_<nameofthetrait"
  texturefile = "gfx/traits/<nameofthetraiticon>.tga"
}

Add some standard lines at the end:

spriteType = {
 name = "GFX_trait_<nameofthetrait>"
 texturefile = "gfx/traits/<nameofthetrait>.tga"
 noOfFrames = 1
 norefcount = yes
 effectFile = "gfx/FX/buttonstate.lua"
}

For our 'selfish' trait, this would look like this:

spriteType = {
 name = "GFX_trait_selfish"
 texturefile = "gfx/traits/selfish.tga"
 noOfFrames = 1
 norefcount = yes
 effectFile = "gfx/FX/buttonstate.lua"
}

Save the file, and your trait should now have an icon.

Localisation[edit]

Main article: Localisation

Traits require the following localization keys:

  • <trait_name> : name of the trait
  • <trait_name>_desc : description of the trait
  • <trait_name>_death : in case the trait reduces heath (health = -1), used to describe the cause for premature "death by trait" (death_reason = death_trait). For instance:
ill_death;after a period of illness;d'une grave maladie;nach einer Zeit der Krankheit;;después de un período de enfermedad;;;;;;;;;x

If we do this with the selfish trait, we will get this:

selfish;Selfish;Égoïste;Selbstsüchtig;;Egoísta;;;;;;;;;x
selfish_desc;This character is Selfish and only thinks about himself;Ce personage est Égoïste et ne pense qu'a lui;German;;Spanish;;;;;;;;;x

Save the localisation as a .csv file. Once you have done that, you are done and you now have yourself a new trait!

See also[edit]

Modding
Common
Gfx/Sfx/localisation