• 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.
Sorry if this is derailing the thread, but here it goes.

I used an init_effect in a system initializer file to spawn a primitive species on a scripted planet. While it does spawn that species as intended, it also renames the planet they're on to something completely random. Why would that be?

Here's the relevant code

Code:
planet = {
        name = "Earth"
        class = "pc_continental"
        orbit_distance = 20
        orbit_angle = 120
        size = 16
        starting_planet = yes
        home_planet = yes
        has_ring = no
        entity = "continental_planet_earth_entity"
        tile_blockers = none
        modifiers = none
      
        init_effect = {
            prevent_anomaly = yes
        }
        init_effect = {
            create_species = {
                        name = Human
                        plural = Humans
                        class = MAM
                        portrait = "human"
                        homeworld = THIS
                        traits = {
                            trait="trait_industrious"
                            trait="trait_natural_engineers"
                            trait="trait_adaptive"
                            trait="trait_intelligent"
                        }
                    }
                    create_country = {
                        name = "Systems Alliance"
                        government="primitive_feudalism"
                        species = last_created_species
                        ethos = {
                            ethic="ethic_inidivualist"
                            ethic="ethic_fanatic_materialist"      
                        }
                        flag = {
                            icon={
                                category="human"
                                file="flag_human_08.dds"
                            }
                            background={
                                category="backgrounds"
                                file="00_solid.dds"
                            }
                            colors={
                                "blue"
                                "black"
                                "null"
                                "null"
                            }
                        }
                        type = primitive
                    }
                    last_created_country = {
                        set_graphical_culture="mammalian_01"
                      
                    }
                    create_colony = {
                        owner = last_created_country
                        species = owner_main_species
                        ethos = owner
                    }
                    create_pop = {
                        species = owner_main_species
                        ethos = owner
                    }
                  
                    create_pop = {
                        species = owner_main_species
                        ethos = owner
                    }
                    create_pop = {
                        species = owner_main_species
                        ethos = owner
        }

            }          
      
        moon = {
            name = "Luna"
            class = "pc_barren_cold"
            size = 5
            orbit_distance = 12
            orbit_angle = 40
            has_ring = no
            entity = "cold_barren_planet_luna_entity"
        }
    }
 
Is there some way to force hyperlane connection between two specified systems (and remove unwanted ones) or did you just get really lucky with autogeneration algorithm?
Not who you originately asked, but there is a way, yes.

The following line of code can be used in your "setup scenarios" .txt file to add hyperlanes.
Code:
add_hyperlane = { from = "system_x" to = "system_y" }

You can use the following line at the beginning of your scenario file to stop the game from generating random hyperlanes:

Code:
    random_hyperlanes = no
 
  • 3
Reactions:
Sorry if this is derailing the thread, but here it goes.

I used an init_effect in a system initializer file to spawn a primitive species on a scripted planet. While it does spawn that species as intended, it also renames the planet they're on to something completely random. Why would that be?

Because settled planets are named by the country that settles it, as the country you created don't have a name_list assigned it takes a random planet name from a random name_list.
 
  • 2
Reactions:
For those of you trying to create an entire static galaxy, why not just do it exactly as mentioned here, then find out which star system was overwritten by the human player, and then just save edit? move the human player star system to where it is supposed to be and enter in the correct system where the human system spawned. You may need to manually remove and add hyperlanes to avoid oddness.
 
For those of you trying to create an entire static galaxy, why not just do it exactly as mentioned here, then find out which star system was overwritten by the human player, and then just save edit? move the human player star system to where it is supposed to be and enter in the correct system where the human system spawned. You may need to manually remove and add hyperlanes to avoid oddness.
Because that requires:
1) For you to close the game after starting the game.
2) Manual work
3) Starting up the game again

For most people any of these would be a no-no, even if they knew how to do the 2 part.
 
Because that requires:
1) For you to close the game after starting the game.
2) Manual work
3) Starting up the game again

For most people any of these would be a no-no, even if they knew how to do the 2 part.


Only once, by the mod creator, after the rest of their galaxy is made. Once you've already spent dozens of hours making the mod, adding another 15 minutes is next to nothing. For players, all they need to do is download the save file and load it. A bit harder than subscribing to a mod in the Steam Workshop, for sure, but not much.
 
Yeah... this block is in an event. And there are a lot more possibilities. Look up special system initializers and crisis events.

Just tested it out. If you add random tile blockers like a normal player has on their own homeworld, it sometimes squashes the pops. So sometimes the AI player - or another human player if you did this for multiplayer - would only have 3 pops to start, for example. Only reasonable workaround seems to be to allow all players to start on a clean 4X4 homeworld. Or use scripting to make sure the pops don't get squashed somehow?

If you set each prescripted species with its own flags, you can shove a call for the initializer into game_start.txt, in game_start.1 if the human player is not playing as that species. Then create the species and government in an init_effect, don't use the create colony. That way, the species can spawn in as AI, in the custom solar system, and have proper 100 percent habitability on their own homeworld.


EDIT: create resources first, then put down the capital building, then the neighbouring buildings, then the tile blockers, then add the pops, and they auto spawn on the best tiles and don't get squashed by the tile blockers.
 
@poopchute, in answer to your question about the save edit: it's because it totally breaks immersion to fiddle about with the save game like that. I'm prepared to put work into the front end, so I can start the game the way I want to, but once that game's been started it's untouchable. No save edits, no reloads, nothing. I do see that to edit the save game is technically not much more, but it's actually a world away from the way I want to play.

Also, it wouldn't work for those wanting to create mods for other people. You could hardly include save edit instructions as part of the installation procedure ;-)
 
Also, it wouldn't work for those wanting to create mods for other people. You could hardly include save edit instructions as part of the installation procedure ;-)

All people would need to do is download the save file, put it into their saves folder, and load it.

Yes, it is really frustrating that making static galaxies and custom systems for non-player-one's is so difficult. I recently figured out that after you make the custom system for the AI player, you have to manually give them their leaders, starting ships, everything manually. Would be so nice if they could just use the prescripted_species_systems.txt
 
  • 1
Reactions:
Save editing is not really a long term solution as that save (or those saves) would need to be recreated and edited each time there is a new patch, either for the main game or the mod in question.
 
  • 3
Reactions:
It's not ideal, but you could make the player spawn in and then they use the console to switch to the AI country that theyshould've been. Maybe do some "kill_country" while you're there
 
That may be true, but who wants to use the console when playing a game? I only use the console when I'm testing something. I never touch the console during normal games. Its certainly far from ideal, and if that's the only way, then I think the devs need to provide additional options.
 
  • 1
Reactions:
Oh, I absolutely agree. It's a huge design overlook and the devs should work on it. I'm just saying that the console is the easiest way to go around the restrictions of the game.
 
Considering that it is at the moment not possible to either place player or AI empires from scripts, other than resorting to the console I decided to simply not try to set up a full galaxy and just have the galaxy and then have pre-scripted nations spawn in it at random locations. Actual scenarios would have to come later when someone figured out how that stuff works and paradox expanded the modifiability...

However I ran into a problem here as well.

Currently I have the entire galaxy filled with pre-scripted systems. Each system has a position and an unique system initializer. Then I have a bunch of pre-scripted empires, each with a special initializer as well. I though this would work to avoid the generator all together, as it is incapable of placing randomly generated and player created empires into my pre-scripted galaxy, on proper planets. (They usually will inhabit gas giants and toxic worlds....)

And in general this works most of the time, but the game will regularly crash when it tries to create the galaxy or if it survives that it will crash sometime after...

The only error message that I get is this:

Code:
[16:41:48][galaxy_generator.cpp:2058]: Could not find starting systems for all empires. Too few systems have spawn_weight!

Does anyone else have this problem? Or know how to add spawn_weight to systems? This seems like it could fix the issue of placing pre-scripted empires, but I have not found any spawn_weight modifier/trigger anywhere...

Edit: And just adding it to the galaxy setup file does not work.
 
Last edited:
Considering that it is at the moment not possible to either place player or AI empires from scripts, other than resorting to the console I decided to simply not try to set up a full galaxy and just have the galaxy and then have pre-scripted nations spawn in it at random locations. Actual scenarios would have to come later when someone figured out how that stuff works and paradox expanded the modifiability...

However I ran into a problem here as well.

Currently I have the entire galaxy filled with pre-scripted systems. Each system has a position and an unique system initializer. Then I have a bunch of pre-scripted empires, each with a special initializer as well. I though this would work to avoid the generator all together, as it is incapable of placing randomly generated and player created empires into my pre-scripted galaxy, on proper planets. (They usually will inhabit gas giants and toxic worlds....)

And in general this works most of the time, but the game will regularly crash when it tries to create the galaxy or if it survives that it will crash sometime after...

The only error message that I get is this:

Code:
[16:41:48][galaxy_generator.cpp:2058]: Could not find starting systems for all empires. Too few systems have spawn_weight!

Does anyone else have this problem? Or know how to add spawn_weight to systems? This seems like it could fix the issue of placing pre-scripted empires, but I have not found any spawn_weight modifier/trigger anywhere...

I don't know if I misread, but it's definitely possible to spawn in Empires (and primivites) in scripted systems via the System initializerrs.


Code:
tikkun_initializer = {
    name = "Tikkun"
    max_instances = 1
    asteroids_distance = 60
  
    planet = {
        name = "Tikkun"
        class = "pc_k_star"
        orbit_distance = 0
        orbit_angle = 1
        size = 30
        has_ring = no
    }
  
    planet = {
        name =  "Rannoch"
        class = "pc_arid"
        orbit_distance = 30
        orbit_angle = -110
        size = 20
        has_ring = no
      
        init_effect = {
            prevent_anomaly = yes
        }
        init_effect = {
            create_species = {
                        name = Quarian
                        plural = Quarians
                        class = MAM
                        portrait = "human"
                        homeworld = THIS
                        traits = {
                            trait="trait_industrious"
                            trait="trait_natural_engineers"
                            trait="trait_adaptive"
                            trait="trait_intelligent"
                        }
                    }
                    create_country = {
                        name = "Quarian civilization"
                        government="primitive_feudalism"
                        species = last_created_species
                        name_list = "Quarian1"
                        ethos = {
                            ethic="ethic_inidivualist"
                            ethic="ethic_fanatic_materialist"      
                        }
                        flag = {
                            icon={
                                category="special"
                                file="primitive.dds"
                            }
                            background={
                                category="backgrounds"
                                file="new_dawn.dds"
                            }
                            colors={
                                "turquoise"
                                "green"
                                "null"
                                "null"
                            }
                        }
                        type = primitive

                    }
                    last_created_country = {
                        set_graphical_culture= preindustrial_01
                        set_country_flag = iron_age
                        set_primitive_age = iron_age
                    }
                  
                    create_colony = {
                        owner = last_created_country
                        species = owner_main_species
                        ethos = owner
                    }
                    random_tile = {
                        limit = {
                            has_blocker = no
                            has_grown_pop = no
                            has_growing_pop = no
                        }
                        create_pop = {
                            species = last_created
                            ethos = owner
                        }
                    }
                    random_tile = {
                        limit = {
                            has_blocker = no
                            has_grown_pop = no
                            has_growing_pop = no
                        }
                        create_pop = {
                            species = last_created
                            ethos = owner
                        }
                    }
                    random_tile = {
                        limit = {
                            has_blocker = no
                            has_grown_pop = no
                            has_growing_pop = no
                        }
                        create_pop = {
                            species = last_created
                            ethos = owner
                        }
                    }
                    random_tile = {
                        limit = {
                            has_blocker = no
                            has_building = no
                            has_grown_pop = yes
                        }
                        set_building = "building_primitive_farm"
                        add_resource = {
                            resource = food
                            amount = 1
                            replace = yes
                        }
                    }
                    random_tile = {
                        limit = {
                            has_blocker = no
                            has_building = no
                            has_grown_pop = yes
                        }
                        set_building = "building_primitive_farm"
                        add_resource = {
                            resource = food
                            amount = 1
                            replace = yes
                        }
                    }
                    random_tile = {
                        limit = {
                            has_blocker = no
                            has_building = no
                            has_grown_pop = yes
                        }
                        set_building = "building_primitive_farm"
                        add_resource = {
                            resource = food
                            amount = 1
                            replace = yes
                        }
                    }                  
                    random_tile = {
                        limit = {
                            has_blocker = no
                            has_building = no
                            has_grown_pop = yes
                        }
                        set_building = "building_primitive_farm"
                        add_resource = {
                            resource = food
                            amount = 1
                            replace = yes
                        }
                    }
                    random_tile = {
                        limit = { has_building = "building_colony_shelter" }
                        remove_building = yes
                    }
                    create_army = {
                                    name = "Primitive Army"
                                    owner = last_created
                                    species = last_created
                                    type = "primitive_army"
                                }
                    create_army = {
                                    name = "Primitive Army"
                                    owner = last_created
                                    species = last_created
                                    type = "primitive_army"
                                }
                    create_army = {
                                    name = "Primitive Army"
                                    owner = last_created
                                    species = last_created
                                    type = "primitive_army"
                                }
                }
    }  
  
  
    planet = {
        name =  "Adas"
        class = "pc_barren"
        orbit_distance = 60
        orbit_angle = 140
        size = 14
        has_ring = no
    }  
  
    planet = {
        name =  "Kaddi"
        class = "pc_barren_cold"
        orbit_distance = 20
        orbit_angle = 35
        size = 28
        has_ring = no
    }  
  
    planet = {
        name =  "Haza"
        class = "pc_gas_giant"
        orbit_distance = 20
        orbit_angle = -80
        size = 22
        has_ring = no
    }  
}

I could also be wrong here, but I believe that using
Code:
starting_planet = no
home_planet = no

in the system initializer would also stop randomly spawning empires from spawning on the specific planet.
 
I don't know if I misread, but it's definitely possible to spawn in Empires (and primivites) in scripted systems via the System initializerrs.

I am aware that this is possible, but that is not what I meant. You can't place the player in this way and you can't spawn AI empires created by the game or pre-scripted by us this way.

When I have a script for an empire that the player can choose there is no way for me to easily get this empire into the game if he does not choose it. The way you described is a lot of work, to create an empire like that. In addition not everything is possible like this, for example there does not seem to be an easy way to create and assign a ruler to this country...
 
I am aware that this is possible, but that is not what I meant. You can't place the player in this way and you can't spawn AI empires created by the game or pre-scripted by us this way.

When I have a script for an empire that the player can choose there is no way for me to easily get this empire into the game if he does not choose it. The way you described is a lot of work, to create an empire like that. In addition not everything is possible like this, for example there does not seem to be an easy way to create and assign a ruler to this country...

Definitely not easy, but you can certainly have a list of prescripted races, and if they are not selected by the player, you can spawn them in using a method similar to G33kh4n's. in game_start.txt (mod version not overwrite original!) or a similar file in same folder within mod, inside event game_start.1:
if = {
limit = {
NOT = {
any_country = {
has_country_flag = krogan
}
}
}
random_system = {
spawn_system = { initializer = "krogan_init" }
}
}

Make sure you put:
flags = { krogan }
inside the prescripted_species.txt, and set spawn_enabled to no. I'm looking into using empire_init instead, so the races appear in the center of clusters the same as if they are game generated.

There is an example of a fleet being created with an admiral being assigned inside special_system_initializers.txt, so I think it is just a matter of figuring out the syntax for creating all the leaders for AI controlled custom species:

create_leader = {
type = admiral
species = owner_main_species
name = random
skill = 100
}
then create fleet, then create ships in the fleet, then:
assign_leader = last_created_leader

It looks like mostly copy-paste-edit work once you get the first species laid out.
 
helpful thread!!

I have one question, can you specify the exact Graphical Culture / Ship Type the spawned AI can use? and based on 1.2 how do we specify the FTL and Weapons technology used, as well as set the Ruler Titles?

Thanks