Origin modding pop creation / secondary species

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

Lamdarer

Recruit
53 Badges
Jan 12, 2020
9
0
  • Stellaris: Apocalypse
  • Cities: Skylines - Natural Disasters
  • Crusader Kings II: Monks and Mystics
  • Cities: Skylines - Mass Transit
  • Europa Universalis IV: Mandate of Heaven
  • Europa Universalis IV: Third Rome
  • Surviving Mars
  • Hearts of Iron IV: Death or Dishonor
  • Europa Universalis 4: Emperor
  • Europa Universalis IV: Cradle of Civilization
  • Hearts of Iron IV: Expansion Pass
  • Stellaris: Humanoids Species Pack
  • Hearts of Iron IV: Together for Victory
  • Europa Universalis IV: Rule Britannia
  • Surviving Mars: Digital Deluxe Edition
  • Cities: Skylines - Parklife
  • Stellaris: Distant Stars
  • Europa Universalis IV: Dharma
  • Europa Universalis IV: Golden Century
  • Imperator: Rome Deluxe Edition
  • Crusader Kings III
  • Stellaris: Ancient Relics
  • Stellaris: Lithoids
  • Stellaris: Federations
  • Stellaris: Galaxy Edition
  • Cities: Skylines
  • Europa Universalis IV: El Dorado
  • Crusader Kings II: Way of Life
  • Magicka 2
  • Europa Universalis IV: Common Sense
  • Crusader Kings II: Horse Lords
  • Europa Universalis IV: Cossacks
  • Europa Universalis IV: Mare Nostrum
  • Stellaris
  • Europa Universalis IV: Res Publica
  • Stellaris: Galaxy Edition
  • Europa Universalis IV: Wealth of Nations
  • Europa Universalis IV: Conquest of Paradise
  • Crusader Kings II: Reapers Due
  • Europa Universalis IV: Rights of Man
  • Europa Universalis IV: Art of War
  • Stellaris: Digital Anniversary Edition
  • Stellaris: Leviathans Story Pack
  • Europa Universalis IV
  • Stellaris: Megacorp
  • Cities: Skylines Deluxe Edition
  • Stellaris: Synthetic Dawn
  • Stellaris: Galaxy Edition
  • Hearts of Iron IV: Cadet
  • Stellaris - Path to Destruction bundle
Hi,
what I want to do is to create a new origin that works similar to the Syncretic Evolution origin from vanilla.
On game start I obviously want to spawn the pops of the secondary species additional to the one of the first.
Currently I have one main problem: How to I select the secondary species?
I managed to let the player create both species exactly as with the vanilla origin, but when the game starts the pops that should be of the secondary species does not spawn instead a random species spawns(the following code is in the /common/events folder and is executed by an on_game_start_country prompt in the /common/on_actions folder):
Code:
namespace = restellar

country_event = {
    id = restellar.1
    hide_window = yes
    is_triggered_only = yes

    trigger = {
        has_origin =  origin_multi_syncretic_evolution
    }

    immediate = {
        random_owned_planet = {
            limit = { is_capital = yes }
           
            random_owned_species = {
                limit = {
                    has_species_flag = syncretic_species@root.owner
                }
                save_event_target_as = syncretic_species

                set_species_flag = syncretic_species@root.owner
                if = {
                    limit = {
                        prev.owner = {
                            has_origin = origin_multi_syncretic_evolution
                        }
                    }
                    set_citizenship_type = {
                        country = root.owner
                        type = citizenship_slavery
                    }
                }
            }
            #This spawns 12 pops of a secondary species
            if= {
                while = {
                    count = 12
                    create_pop = {
                        species = last_created_species
                        ethos = random
                    }
                }
            }

        }
    }
}

So I guess the problem is that I use "species = last_created_species" in the last block, but how exactly should I change that to spawn the actual secondary species?
I looked up the code of the vanilla game files and some other mods, thats why I choose "last_created_species" however I think I probably need to set a flag to the main species and scope to the country or so? But I am not sure how to do that.
Also one additional question: How exactly do I change the pop count of the primary species in general?
 
Last edited:
Three problems I see, though they may not be actual problems;

1. root.owner seems to be unnecessary here--the root will always be the country the event fires on, and adding owner to that doesn't seem necessary. Maybe try this.owner instead?

2. My understanding is that you're trying to make more of the syncretic species, but what I'm reading suggests you might be trying to make a secondary syncretic species? If the first is the case, maybe just doing
Code:
random_owned_species = {
    limit = {
        NOT = {
            is_same_value = this.owner_species
        }
    }
}
would be easier, as it should only be valid for your empire's main species.

3. last_created_species is typically best used within the same event as the species' creation, as it's possible other events generating new species can fire first otherwise. However, you could save the selected species as an event target and use that.
 
  • 1
Reactions:
This way works for me:

Code:
generate_custom_origin_start_pops = {
    if = {
        limit = { owner = { has_origin = origin_custom } }
      
        ## CLEAR ##
        while = {
            limit = { num_pops > 1 }
            random_owned_pop = {
                kill_pop = yes
            }
        }
      
        ## MAIN ##
        while = {
            count = 4
            create_pop = {
                species = owner_main_species
                ethos = random
            }
        }         

        ## SYNCRETIC ##
        last_created_species = { set_species_flag = syncretic_species@root.owner }         
        while = {
            count = 15
            create_pop = {
                species = last_created_species = {has_trait = trait_syncretic_citizens}
                ethos = random
                }
        } 
    }
}

Code:
planet_event = {
    id = custom_origin.0001
    is_triggered_only = yes
    hide_window = yes
  
    immediate = {
        generate_custom_origin_start_pops = yes
    }
}

Code:
empire_init_capital_planet = {
    events = { custom_origin.0001 }
}

Its essential to use empire_init_capital_planet action because exactly in this moment last_created_species is your syncretic species.