State modding

From Hearts of Iron 4 Wiki
Jump to navigation Jump to search

States (and their history) are defined in /Hearts of Iron IV/history/states/*.txt.

Each state is typically stored in its own file, although you can store multiple state definitions within the same file, as the ID is defined within the state definition, rather than the file title (as in Europa Universalis 4).

Here is a generic example of a state:

state = {
	id = <id>
	name = <localization key>
	manpower = <int>
	state_category = <category>
	buildings_max_level_factor = <float>
	impassable = <bool>
	provinces = {
		<province ids>
	resources = {
		<resource> = <int>
	history = {
		owner = <TAG>

                controller = <TAG>

		add_core_of = <TAG>

		add_claim_by = <TAG>

		victory_points = {
			<province id> <points>
		buildings = {
			<building> = <amount>

			<province id> = {
				<building> = <amount>
  • id defines the numerical id used by the state. The state IDs must be added sequentially, skipping numbers will cause crashes.
  • name defines the localization key the state uses. You can use a non-localized string (i.e. "Paris"), but it is best practice to use localized strings.
  • manpower defines the manpower provided to the owner of the state. Typically values are as low as 10,000 in wasteland type states, and as high as 2,000,000 in highly populated states.
  • state_category defines the state category used by the state. These categories are found in /Hearts of Iron IV/common/state_category/*.txt.
  • buildings_max_level_factor defines how many extra building slots should be added to the state in addition to the state category base amount.
  • impassable if the state is impassable or not. Optional, no by default.
  • provinces scope defines which provinces belong to the state.
  • resources scope defines the resources found in the state and the amount of said resources. Resources are found in /Hearts of Iron IV/common/resources/*.txt.
  • history scope defines the effects to execute when the state is loaded during history setup. Typically this is used to add ownership with owner = <tag> and add_core_of = <tag>.
  • owner sets the owner of the state. Note that this is not an effect, unlike add_core_of.
  • controller sets the controller of the state. Optional, will be owner by default.
  • add_core_of sets the state as a core of the specified tag.
  • add_claim_by grants a claim on the state to the specified tag.
  • victory_points scope is nested within the history scope and defines the victory point for a state. Multiple victory points require multiple scopes. IMPORTANT: If you enter a province ID that does not exist, the game may crash while 'creating checksum' without generating a relevant error to the error log.
  • buildings scope is nested within the history scope, and defines which state buildings are set in the state during history setup. Buildings are found in /Hearts of Iron IV/common/buildings/*.txt. Provincal buildings are added by adding the specific province you want to add the building in as a scope.

Building types[edit | edit source]

See building types for different building types in the base game.

State Categories[edit | edit source]

The base game state categories and their corresponding number of building slots

  • wasteland (Wasteland): 0
  • enclave (Enclave): 0
  • tiny_island (Tiny Island): 0
  • small_island (Small Island): 1
  • pastoral (Pastoral Region): 1
  • rural (Rural Region): 2
  • town (Developed Rural Region): 4
  • large_town (Sparse Urban Region): 5
  • city (Urban Region): 6
  • large_city (Dense Urban Region): 8
  • metropolis (Metropolis Region): 10
  • megalopolis (Megalopolis Region): 12

State categories can be added in /Hearts of Iron IV/common/state_category/*.txt. A definition of a state category follows this pattern:

	<category ID> = {
		color = { <RGB code> }
		<state modifiers>

Category ID is the ID that can be used to set the category. The color decides which colour is used for the state on the state map mode. The state modifiers, including local_building_slots, are the modifiers that are applied to the state which has that category. The list can be seen in the modifiers page.

The set_state_category = category_id effect can be used to change the state category of a state mid-game.