Origin modding pop creation / secondary species

Lamdarer

Recruit
40 Badges
Jan 12, 2020
8
0
  • Stellaris: Humanoids Species Pack
  • Stellaris: Leviathans Story Pack
  • Cities: Skylines - Natural Disasters
  • Crusader Kings II: Monks and Mystics
  • Cities: Skylines - Mass Transit
  • Europa Universalis IV: Mandate of Heaven
  • Surviving Mars
  • Hearts of Iron IV: Death or Dishonor
  • Hearts of Iron IV: Expansion Pass
  • Hearts of Iron IV: Together for Victory
  • Stellaris: Apocalypse
  • Europa Universalis IV: Rule Britannia
  • Surviving Mars: Digital Deluxe Edition
  • Cities: Skylines - Parklife
  • Stellaris: Distant Stars
  • Imperator: Rome Deluxe Edition
  • Crusader Kings III
  • Stellaris: Galaxy Edition
  • Europa Universalis IV: El Dorado
  • Crusader Kings II: Way of Life
  • Magicka 2
  • Europa Universalis IV: Common Sense
  • Crusader Kings II: Horse Lords
  • Cities: Skylines
  • Stellaris
  • Stellaris: Galaxy Edition
  • Europa Universalis IV: Art of War
  • Stellaris: Digital Anniversary Edition
  • Crusader Kings II: Reapers Due
  • Europa Universalis IV: Rights of Man
  • Europa Universalis IV
  • Stellaris: Megacorp
  • Cities: Skylines Deluxe Edition
  • Imperator: Rome
  • Age of Wonders III
  • Stellaris: Synthetic Dawn
  • Stellaris: Galaxy Edition
  • Stellaris - Path to Destruction bundle
  • Hearts of Iron IV: Cadet
  • Crusader Kings II
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:

Mr. Morague

Second Lieutenant
14 Badges
Dec 19, 2017
147
49
  • Stellaris
  • Stellaris: Digital Anniversary Edition
  • Stellaris: Leviathans Story Pack
  • Stellaris - Path to Destruction bundle
  • Stellaris: Humanoids Species Pack
  • Stellaris: Apocalypse
  • Stellaris: Distant Stars
  • Stellaris: Megacorp
  • Stellaris: Ancient Relics
  • Stellaris: Lithoids
  • Stellaris: Federations
  • Stellaris: Necroids
  • Stellaris: Nemesis
  • Stellaris: Synthetic Dawn
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:

oakenbrain

Recruit
Aug 10, 2021
1
0
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.