[Guide] How I made my charters young again. Immortal trait.

  • We have updated our Community Code of Conduct. Please read through the new rules for the forum that are an integral part of Paradox Interactive’s User Agreement.

mellester1

Corporal
15 Badges
Oct 11, 2018
42
1
  • Europa Universalis IV
  • The Showdown Effect
  • Cities: Skylines
  • Stellaris
  • Hearts of Iron IV: Cadet
  • Stellaris: Digital Anniversary Edition
  • Europa Universalis IV: Third Rome
  • Europa Universalis IV: Rule Britannia
  • Europa Universalis IV: Golden Century
  • Imperator: Rome
  • Crusader Kings II
  • Europa Universalis IV: Conquest of Paradise
  • Europa Universalis IV: Wealth of Nations
  • Europa Universalis IV: Call to arms event
  • Europa Universalis IV: Res Publica
Desktop_Screenshot_2019.05.10_-_20.53.39.80_2.png
Desktop_Screenshot_2019.05.10_-_20.56.01.42_2.png


LATE EDIT: I changed my approach, see below. I recommend currently adding the dna_modifier to gfx\portraits\portrait_modifiers\AB_Imortal.txt not a trait

So i managed to make a trait that will remove 50 years of someone live and make them look young again.
It works like this.
Every character has genes that determine How it looks. The most important ones are defined in "common\genes\00_genes.txt"
In it there is a special age gene. whos strength will determine how the person looks in old age.
A few things to note
  • There are 5 different sub age genes. old_1 to old_5. one will be picked at random
  • By default the MAX_AGE is 100. a 101 year old will look the same as a 100 year old
  • every sub_age gene is split up in again male,boy,female,girl. whe can ignore the boy and girl parts.
  • Most statements and conditions like if = {}. I have not gotten to work in _genes.txt. so we need a difrent trick
  • Instead we can use "required_tags = not(unaging)" to disable certain looks we don't like for our immortal charter. However this is limited to morph sub-gene decals, settings, and texture_overrides. will be important.
So we cant use condition like one would want to do

Code:
if = {
     limit = {
      NOT = { has_trait = imortal}
     age < 50
               }
      }
#aging code here
}
 
Last edited:

mellester1

Corporal
15 Badges
Oct 11, 2018
42
1
  • Europa Universalis IV
  • The Showdown Effect
  • Cities: Skylines
  • Stellaris
  • Hearts of Iron IV: Cadet
  • Stellaris: Digital Anniversary Edition
  • Europa Universalis IV: Third Rome
  • Europa Universalis IV: Rule Britannia
  • Europa Universalis IV: Golden Century
  • Imperator: Rome
  • Crusader Kings II
  • Europa Universalis IV: Conquest of Paradise
  • Europa Universalis IV: Wealth of Nations
  • Europa Universalis IV: Call to arms event
  • Europa Universalis IV: Res Publica
But we have a way around it.
Take a look a the blind trait already in the game

Code:
blind = {
    type = health
    finesse = -3
    dna_modifiers = {
        accessory = {
            mode = replace     #overwrite this gene in the dna with the specified template and value
    
            gene = eye_accessory
            template = blindfold_1
            value = 1
        }
    }
}
It is a trait that modifies the dna of a person.
This works nicely if say you wanna change the skin color of a charter to blue and have a blue man group trait in you game.
However when you try and do

Code:
    dna_modifiers = {
        morph = {
            mode = replace
            gene = age
                        template = old_1
                       value = 0.5
}}
to turn your pop into a 50 year old. It will print out a error in the log that you are not allowed to modifiers this special gene.
so we need a work around.
Basically we need to make a new gene that disables or reverses the effects of aging.
And then we add that to the character.
There is a nice example already in the genes.txt. namely
Code:
special_genes = {
morph_genes={
      gene_tags = {
            no_hair = { index = 0 set_tags = "no_hair" }
}}
this gene is found at the bottom of _genes.txt. All it does is set a "tag" which will turn of or enable those other genes that required_tags = "no_hair".
This way you can very easily make a shame trait. so that you can shave all those people that failed the nation.
So we can make our own.

Code:
        gene_tags = {
            no_hair = { index = 0 set_tags = "no_hair" }
            unaging ={   index = 1  set_tags = "unaging"}
This look like a simple solution but there is a problem.
When we go and add the required_tags = "not(unaging)" we run in to a problem.
Every sub_gene and every person type has 4 effects for aging.
  • setting = { animation_curve = { ... } }
  • a skin decal
  • a hair hsv shift (grey hair)
  • a skin hsv shift
We can only use required_tags = "not(unaging)" for the setting block and the Decal.
The hair_hsv_shift_curve function is not used anywhere else but the age gene and cant be affected by tags or wrapped in a settings block. So as far as I know you can only tweak the numbers and outright disable aging for everyone in the world. But not for specific people and groups.

So a another work around needs to be found.
because hair_hsv_shift_curve cant be on a disabled. We can do the next best thing.
And add another hair_hsv_shift_curve but with the negative values. this will Undo the effects of aging for only the characters with that new gene we add by trait.
Code:
        gene_tags = {
            no_hair = { index = 0 set_tags = "no_hair" }
            # full_hair = { index = 1 set_tags = "full_hair" }
            unaging ={
            index = 1
            set_tags = "unaging"
            #set_tags = "test1,test3"
            male = {
                    hair_hsv_shift_curve = {
                        #age    {hsv change} 
                        { 0.35    { 0.0 0.0 0.0 } }
                        { 0.6   { 0.0 0.5 -0.3 } }
                    }
                    skin_hsv_shift_curve = {
                    #age    {hsv change} 
                    { 0.55    { 0.0 0.0 0.0 } }
                    { 0.8   { 0.0 0.1 -0.02 } }
                }
            }               
        }
So now we make a trait that adds this gene.

Code:
unaging = {
    type = health
    dna_modifiers = {
        morph = {
            mode = add    #add this gene in the dna with the specified template and value
            gene = gene_tags
            template = unaging
            value = 0.5 #removes 50 years of aging. Max age is 100 so a 150 year will look like a 50 year old too
        } 
    }
}

I have omitted the parts needed for females. I leave that as a exercise to the reader
 
Last edited:

Blood Royal

General
37 Badges
Jun 1, 2007
2.199
543
  • Crusader Kings II: Monks and Mystics
  • Crusader Kings II: Conclave
  • Stellaris
  • Stellaris: Galaxy Edition
  • Stellaris: Galaxy Edition
  • Stellaris: Galaxy Edition
  • Stellaris Sign-up
  • Hearts of Iron IV: Cadet
  • Crusader Kings II: Reapers Due
  • Hearts of Iron IV: Together for Victory
  • Crusader Kings II: Horse Lords
  • Stellaris - Path to Destruction bundle
  • Hearts of Iron IV: Death or Dishonor
  • Crusader Kings II: Jade Dragon
  • Hearts of Iron IV: Expansion Pass
  • Stellaris: Apocalypse
  • Imperator: Rome Deluxe Edition
  • Imperator: Rome
  • Crusader Kings III
  • Europa Universalis IV: Wealth of Nations
  • Crusader Kings II: Charlemagne
  • Crusader Kings II: Legacy of Rome
  • Crusader Kings II: The Old Gods
  • Crusader Kings II: The Republic
  • Crusader Kings II: Sunset Invasion
  • Crusader Kings II: Sword of Islam
  • Europa Universalis IV
  • Europa Universalis IV: Art of War
  • Crusader Kings II
  • Victoria: Revolutions
  • Victoria 2
  • Victoria 2: A House Divided
  • Victoria 2: Heart of Darkness
  • War of the Roses
  • 500k Club
  • Crusader Kings II: Way of Life
  • Europa Universalis IV: Common Sense
Wow, this is HUGE!

I didn't think it was possible, and not for lack of trying :)

Awesome work, now I can really differentiate aging for elves, dwarves, etc. and still have humans age as normal. Up to now in my LOTR mod I've had to disable all aging for everyone at age 30.
 

mellester1

Corporal
15 Badges
Oct 11, 2018
42
1
  • Europa Universalis IV
  • The Showdown Effect
  • Cities: Skylines
  • Stellaris
  • Hearts of Iron IV: Cadet
  • Stellaris: Digital Anniversary Edition
  • Europa Universalis IV: Third Rome
  • Europa Universalis IV: Rule Britannia
  • Europa Universalis IV: Golden Century
  • Imperator: Rome
  • Crusader Kings II
  • Europa Universalis IV: Conquest of Paradise
  • Europa Universalis IV: Wealth of Nations
  • Europa Universalis IV: Call to arms event
  • Europa Universalis IV: Res Publica
dna_modifiers = { value = #scripted_valuehere?}
dna modifier only accepts Literal values so so you cant use scripted values. So they have the gene be stronger or weaker depending on the age of the charter some other tricks need to bo used
 
Last edited:

mellester1

Corporal
15 Badges
Oct 11, 2018
42
1
  • Europa Universalis IV
  • The Showdown Effect
  • Cities: Skylines
  • Stellaris
  • Hearts of Iron IV: Cadet
  • Stellaris: Digital Anniversary Edition
  • Europa Universalis IV: Third Rome
  • Europa Universalis IV: Rule Britannia
  • Europa Universalis IV: Golden Century
  • Imperator: Rome
  • Crusader Kings II
  • Europa Universalis IV: Conquest of Paradise
  • Europa Universalis IV: Wealth of Nations
  • Europa Universalis IV: Call to arms event
  • Europa Universalis IV: Res Publica
update this what I ended up with to gradually fix the aging problem

Code:
#\gfx\portraits\portrait_modifiers\AB_Imortal.txt
Unaging_group1 = {
    Unaging1 = {
        dna_modifiers = {
            morph = {
                mode = add   #add a new gene in the dna with the specified template and value
                gene = gene_tags
                template = unaging
                # a value of 0.5 would remove 50 years of age from a char.
                #Max age for portraits is 100 so a 400 year old char will look like 50 too
                value = 0.2
            }  
        }
        weight = {
            base = 0
            modifier = {
                add = 1
                AND = {
                    char_is_unaging_trigger = yes
                    age >= 50
                }
            }
        }
    }
}

Unaging_group2 = {
    Unaging2 = {
        dna_modifiers = {
            morph = {
                mode = add    #add a new gene in the dna with the specified template and value
                gene = gene_tags
                template = unaging
                # a value of 0.5 would remove 50 years of age from a char.
                #Max age for portraits is 100 so a 400 year old char will look like 50 too
                value = 0.4
            }  
        }
        weight = {
            base = 0
            modifier = {
                add = 1
                AND = {
                char_is_unaging_trigger = yes
                age >= 70
                }
            }
        }
    }
}
Unaging_group3 = {
    Unaging3 = {
        dna_modifiers = {
            morph = {
                mode = add    #add a new gene in the dna with the specified template and value
                gene = gene_tags
                template = unaging
                # a value of 0.5 would remove 50 years of age from a char.
                #Max age for portraits is 100 so a 400 year old char will look like 50 too
                value = 0.6
            }  
        }
        weight = {
            base = 0
            modifier = {
                add = 1
                AND = {
                char_is_unaging_trigger = yes
                age >= 90
                }
            }
        }
    }
}
 
Last edited:

mellester1

Corporal
15 Badges
Oct 11, 2018
42
1
  • Europa Universalis IV
  • The Showdown Effect
  • Cities: Skylines
  • Stellaris
  • Hearts of Iron IV: Cadet
  • Stellaris: Digital Anniversary Edition
  • Europa Universalis IV: Third Rome
  • Europa Universalis IV: Rule Britannia
  • Europa Universalis IV: Golden Century
  • Imperator: Rome
  • Crusader Kings II
  • Europa Universalis IV: Conquest of Paradise
  • Europa Universalis IV: Wealth of Nations
  • Europa Universalis IV: Call to arms event
  • Europa Universalis IV: Res Publica
How did you use the char_is_unaging_trigger?
Code:
#common\scripted_triggers\01_trait_groups.txt
char_is_vampire_trigger = {
    OR = {
has_trait = vampire
has_trait = brujah
#more traits here        
}
}


# determine if age should not affect a char
char_is_unaging_trigger = {
    OR = {
char_is_vampire_trigger = yes
#more traits here
}
}

Triggers are are checks to see if the a person has a certain trait
 

Shalassan

Private
64 Badges
Jun 14, 2017
16
2
  • Surviving Mars: First Colony Edition
  • Hearts of Iron IV: Cadet
  • Crusader Kings II: Reapers Due
  • Stellaris: Digital Anniversary Edition
  • Stellaris: Leviathans Story Pack
  • Cities: Skylines - Natural Disasters
  • Hearts of Iron IV: Together for Victory
  • Crusader Kings II: Monks and Mystics
  • Stellaris - Path to Destruction bundle
  • Steel Division: Normandy 44
  • Cities: Skylines - Mass Transit
  • Surviving Mars
  • Hearts of Iron IV: Death or Dishonor
  • Cities: Skylines - Campus
  • Cities: Skylines - Green Cities
  • Crusader Kings II: Jade Dragon
  • Hearts of Iron IV: Expansion Pass
  • Stellaris: Apocalypse
  • Surviving Mars: Digital Deluxe Edition
  • Cities: Skylines - Parklife
  • Surviving Mars: First Colony Edition
  • Cities: Skylines Industries
  • Stellaris: Megacorp
  • Crusader Kings II: Holy Fury
  • Imperator: Rome
  • Hearts of Iron IV: Expansion Pass
  • Cities: Skylines - Snowfall
  • Battle for Bosporus
  • Hearts of Iron IV: La Resistance
  • Crusader Kings II: Rajas of India
  • Stellaris: Nemesis
  • Crusader Kings II: Sons of Abraham
  • Crusader Kings III: Royal Edition
  • Crusader Kings III
  • Hearts of Iron IV: No Step Back
  • Stellaris: Federations
  • Age of Wonders: Planetfall
  • Cities: Skylines
  • Hearts of Iron IV: By Blood Alone
  • Europa Universalis IV: El Dorado
  • Crusader Kings II: Way of Life
  • Magicka 2
  • Crusader Kings II: Horse Lords
  • Cities: Skylines - After Dark
  • Crusader Kings II: Conclave
  • Imperator: Rome - Magna Graecia
  • Magicka
  • Europa Universalis IV
  • Darkest Hour
  • Crusader Kings II: The Old Gods
Hello,

So basically you use \gfx\portraits\portrait_modifiers\ to add/change the new gene "unaging" if i understand all correctly?
So i have a few questions with this.
First the Unaging gene is definied this way

Code:
                  hair_hsv_shift_curve = {
                        #age    {hsv change}
                        { 0.35    { 0.0 0.0 0.0 } }
                        { 0.6   { 0.0 0.5 -0.3 } }
                    }
                    skin_hsv_shift_curve = {
                        #age    {hsv change}
                        { 0.55    { 0.0 0.0 0.0 } }
                        { 0.8    { 0.0 0.1 -0.02 } }
Not absolutely sure what it means but to my understanding with a gene strength of 0.35 or less the color won't be changed and at 0.6 saturation will go up by 50% and light reduced by 30.
The normal aging is
Code:
                        #age    {hsv change}
                        { 0.45  { 0.0 0.0 0.0 } }
                        { 0.65   { 0.0 -1 0.3 } }
                    }
                    skin_hsv_shift_curve = {
                        #age    {hsv change}
                        { 0.55  { 0.0 0.0 0.0 } }
                        { 0.8   { 0.0 -0.1 0.02 } }
So that means hairs will still loose 50% of saturation right? (-1+0.5) and it might not be noticeable on blond or black hairs but what with red or fancy colors? Shouldn't the unaging code be the exact opposite of the aging code?

The second question is more about LoTR mod as it's using this trick i wanted to see how it was done actually in game to understand perfectly how it works. And i've seen a bit of code not in this thread. The aging genes have been modified this way :
Code:
                    setting = {
                                            required_tags = "not(unaging)" #added code in LOTR
                                            attribute = "bs_old5"    value = { min = 0.0 max = 1.0 }
                        animation_curve = {
                            {0.0 0.0}
                            { 0.3 0 }
                            { 0.8 1.0 }
                        }
                    }
                    decal = {
                        required_tags = "not(unaging)" #added code in LOTR
                        type = skin
                        atlas_pos = { 3 1 }
                        alpha_curve = {
                            { 0.32  0.0 }
                            { 0.75   1.0 }
                        }
                    }
So i was wondering what those required_tags = "not(unaging)" were doing, are they working at all? If they are effectively preventing the aging mechanic then the scripted portrait is useless, and if the portrait is required, then this part do not really seem useful right? So i wanted to know if there was some sort of reason i don't understand yet before starting to mess too much with something i don't completely understand so far.