Building modding

From Stellaris Wiki
Jump to navigation Jump to search

Version

Outliner top.png
This article may contain outdated information that is inaccurate for the current version of the game. It was last updated for 2.2.

This article is for the PC version of Stellaris only.

Buildings are one of the most commonly modded assets in the game. These buildings not only cost, produce, and/or require resources to maintain, but can also provide unique modifiers and research technology.

Building Basics[edit]

Most basic buildings requires two components; a text document containing the attributes and modifiers of a building located in the common/building folder and another text document containing the names and descriptions of said building in the localisation folder. The file path is extremely name sensitive, so its important that the common and localisation folder is spelled exactly as it is written.

Creating a Simple Building[edit]

The creation of a new custom building begins with the text document located at the commons/building folder of the mod. Create a text document with a text editor like Notepad++ and begin creating a building. The first step is to create an ID name for said building. It would look like this;

building_name = { }

building_name is the ID name of the building. Typically, most buildings usually does around three or four things; they cost, produce, upgrade or require certain technology or resources.

Building Cost, Upkeep and Production[edit]

Buildings require a cost for construction and the time required to be finished. For building time, add the line "base_buildtime = ", adding a number at the end of the equal sign. The number added is based upon in-game days, so the number 100 would equal 100 days to build. To make a building cost certain resources, you would add the line "resources = { cost = { } }". Inside the bracket, you would add certain resources which are required for the building to be made. This also applies to upkeep and production.

building_name = { 
	base_buildtime = 240	

	resources = {
            category = planet_buildings
            cost = {
		minerals = 100
		energy = 100
            }
            upkeep = {
                energy = 2
            }
            produces = {
                food = 4
                minerals = 2
            }
	}
}

The above code says that "building_name" is a planet building with an upkeep of 2 energy credits which requires 100 minerals and 100 energy to build and would take 240 days to complete. After its contruction it provides 2 minerals and 4 food per month. Other types of resouces like influence or unity can also be added to the cost, upkeep and produces section.

Resources Production via Jobs[edit]

Most buildings don´t directly provide resources, though, but instead increase the resource production by adding jobs. This can be done by using the line "planet_modifier = {}" and adding "job_name_add = " with the number of jobs to add. However, since hive minds and normal empires use different kinds of jobs "triggered_planet_modifier = {}" should be used. This only applies the modifier if the trigger in "potential = {}" is true. In this case we use triggers which check wether the country is a regular empire or a hive mind.

building_name = { 
	base_buildtime = 240	

	resources = {
            category = planet_buildings
            cost = {
		minerals = 100
		energy = 100
            }
            upkeep = {
                energy = 2
            }
	}

        triggered_planet_modifier = {
            potential = {
                 exists = owner
                 owner = { is_regular_empire = yes }
            }
	    modifier = {
	         job_farmer_add = 2
	    }
        }

	triggered_planet_modifier = {
	     potential = {
		exists = owner
		owner = { is_gestalt = yes }
	     }
	     modifier = {
		job_agri_drone_add = 2
	     }
	}
}

The above code shows that "building_name" provides 2 farmer jobs for regular empires and 2 agri drone jobs for hive minds. If you want to use your own jobs, you first need to create one in the "common/pop_jobs" folder.

You can also use other modifiers to change the growth speed, ethics attraction and much more. See the modifiers page for more details. If you want to apply an empire-wide modifier use "country_modifier" or "triggered_country_modifier" instead.

Building Upgrades[edit]

Many buildings also have an upgrade option which typically improves the attributes it produces. Before a building can be upgraded, you must create its upgraded counterpart. Typically, you would duplicate the first building and simply change the ID name. For instance, if I were to duplicate the first building, and if it will have multiple further upgrades, I would rename each new building as "building_name_1", "building_name_2", etc. Once the second building has been created and all necessary improvements have been made, return to the first building and add the code "upgrades = { }". Inside the bracket, you would add the name of the second building which the first building will upgrade to.

building_name = { 
	base_buildtime = 240	

	resources = {
            category = planet_buildings
            cost = {
		minerals = 100
		energy = 100
            }
            upkeep = {
                energy = 2
            }
	}

        triggered_planet_modifier = {
            potential = {
                 exists = owner
                 owner = { is_regular_empire = yes }
            }
	    modifier = {
	         job_farmer_add = 2
	    }
        }

	triggered_planet_modifier = {
	     potential = {
		exists = owner
		owner = { is_gestalt = yes }
	     }
	     modifier = {
		job_agri_drone_add = 2
	     }
	}

	upgrades = {
		building_name_1
	}
}

building_name_1 = { 
	base_buildtime = 240	

	resources = {
            category = planet_buildings
            cost = {
		minerals = 100
		energy = 100
            }
            upkeep = {
                energy = 3
            }
	}

        triggered_planet_modifier = {
            potential = {
                 exists = owner
                 owner = { is_regular_empire = yes }
            }
	    modifier = {
	         job_farmer_add = 3
	    }
        }

	triggered_planet_modifier = {
	     potential = {
		exists = owner
		owner = { is_gestalt = yes }
	     }
	     modifier = {
		job_agri_drone_add = 3
	     }
	}
}

The code above shows two buildings, the first building have the upgrades code which allows it to be tranformed into "building_name_1", which provides more jobs.

Naming Building[edit]

Naming the buildings is much simpler to do, as it is simply a matter of connecting the building ID with a YML document. Either copy a YML file from the main game or create your own and put it in the localisation folder (IMPORTANT NOTE: The folder must be spelled Localisation instead of Localization otherwise it won't be able to connect to the file). Once a YML document is created, using an editing tool like Notepad++, simply add at the top this line "l_english:". Afterwards, beneath it, you would write down the id of the building created in the common/building folder. To create the name of the building, simply type ("building_id:0 "Name") with the building_id being the id name of the building of course and the name of the building inside the quoatation marks. To add the building description, do the same exact thing except you'd add a "_desc" after the building id.

l_english:

 building_city:0 "Urban City"
 building_city_desc:0 "Populated urban center where the planet's population reside."
 

The code shown above shows the building id "building_city" having the name of "Urban City". Below it, the code also adds a description of the building by adding the "_desc" at the end of the id.