Country creation

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

The Guide below presumes that you understand the basics of how to create a mod. This page should also help modders understand how to change some more specific aspects of a country.

Quick check-list[edit]

  • Define a unique 3-character country tag
  • Create a file in <yourmod>/common/countries
  • Create a file in <yourmod>/history/countries
  • Add localisation to <yourmod>/localisations
  • Add a large, medium and small flag for each ideology to <yourmod>/gfx/flags
  • Optional: Create an OOB file in <yourmod>/history/units
  • Optional: Add the country to the game

Country tag[edit]

Countries need a 3-character country tag. This is how a country is referred to in all of the game's script. All country tags must be unique. A country must not share a tag with any other country.

To create a tag, add a new file to <yourmod>/common/country_tags (or edit an existing file) and add something like the following:

SCO = "countries/Scotland.txt"

where

countries/Scotland.txt

is address of the country file that will be created/edited, located in <yourmod>/common/countries

Country file[edit]

Create a new file in the <yourmod>/common/countries folder. It is recommended one copies the file of a very similar country, then rename and edit it.

Graphical culture[edit]

Defines the set of graphics used for units. For Scotland this would be:

graphical_culture = commonwealth_gfx
graphical_culture_2d = commonwealth_2d

Color[edit]

This is the country's colour on the political map mode. It uses the RGB color scale.

color = { 2  10  222 }

colors.txt[edit]

Also, make sure that you add the country's color to <yourmod>/common/countries/colors.txt:

SCO = {
  color = rgb { 2  10  222 }
  color_ui = rgb { 255 255 155}
}

`color_ui` usually is a more intense version of the normal color. It is used to render the borders of the country (If borders look ugly, make sure you have done this right). Colors may also be specified in HSV format.

Country history[edit]

Create a file in the <yourmod>/history/countries folder. Alternatively, copy, rename, and edit a similar file. The file name should be <country tag - country name>, e.g. "SCO - Scotland". This file contains information about the history and various other default attributes of the country.

Capital city[edit]

Defines the capital city. Use the State ID of the state that contains the capital, not the province ID. In this case, 121 is Lothrian State, which contains Edinburgh.

capital = 121

Order of battle[edit]

This line will link to the 'Order of Battle' (OoB) file which will define the amount and location of units, their experience and equipment level, and also Air Wings the country has at the start. Starting production and unit templates are also defined there. All countries need an OoB link, but if the country is to be released one doesn't need to add one later on.

oob = "SCO_1936"

For ease of use, naval units are normally put into separate OOB. Also, due to significant changes made to naval units in the 'Man the Guns' DLC, countries normally use 2 separate naval OOBs, one for owners of the mentioned DLC, and one for those who don't own it, and have to use the old ship system (OOB usually distinquished by a _legacy suffix)

if = {
	limit= { has_dlc = "Man the Guns" }
		set_naval_oob = "SCO_1936_naval_mtg"
	else = {
		set_naval_oob = "SCO_1936_naval_legacy"
	}
}

Research slots[edit]

Defines the amount of research slots a country has access to at the start. Normally, major powers have 4 slots, minor countries in North America and Europe have 3 and minor countries in the rest of the world have 2. Defaults to 2 slots, if not specified.

set_research_slots = 3

Stability[edit]

Defines the stability percentage that a country will have at the start of the game. The number that is put here will be multiplied by 100 when applied to the country, so the max is 1 (100) and the minimum is 0 (0).

set_stability = 0.7

War support[edit]

Defines the war support percentage that a country will have at the start of the game. Like stability, the number will be multiplied by 100 when applied to the country, with the max being 1 (100) and minimum being 0 (0).

set_war_support = 0.5

Ideas[edit]

Sets Ideas country starts with (National Spirits, as well as advisors, companies & laws). A list of ideas can be found in /Hearts of Iron IV/common/ideas

Note that you don't have to add any ideas. Country will then start with no advisors, Civilian Economy and Volunteer Only conscription. This is an example:

add_ideas = {
		henschel
		GER_autarky_idea
		#laws
		war_economy
		extensive_conscription
}

Technology[edit]

Here the technology a country has from the start is declared. A list of technologies can be found in /Hearts of Iron IV/common/technologies.

set_technology = {
 	infantry_weapons = 1
	infantry_weapons1 = 1	
	tech_engineers = 1
	tech_mountaineers = 1
	motorised_infantry = 1
	gw_artillery = 1
	interwar_antiair = 1
	gwtank = 1
	basic_light_tank = 1
	basic_heavy_tank = 1
	early_fighter = 1
	fighter1 = 1
	early_bomber = 1
	tactical_bomber1 = 1
	strategic_bomber1 = 1
	CAS1 = 1
	naval_bomber1 = 1
}

Keep in mind that those who own 'Man the Guns' DLC will need to use a different set of technologies for ships, therefore you have to set technologies for ships twice, like this:

if = {
	limit = { not = { has_dlc = "Man the Guns" } }
	set_technology = {
		early_submarine = 1
		early_destroyer = 1
	}
	set_naval_oob = "SCO_1936_naval_legacy"
}
if = {
	limit = { has_dlc = "Man the Guns" }
	set_technology = {
		basic_naval_mines = 1
		submarine_mine_laying = 1
		early_ship_hull_light = 1
		early_ship_hull_submarine = 1
		basic_ship_hull_submarine = 1
		basic_battery = 1
		basic_torpedo = 1
		basic_depth_charges = 1
	}
	set_naval_oob = "SCO_1936_naval_mtg"
}

Miscellaneous (optional)[edit]

Add starting political power:

add_political_power = 500

Adds this amount of trade convoys. Note: If present multiple times in the same file, these stack

set_convoys = 100

Add starting research bonus. Useful for example if you had to manually complete a complex National Focus that adds research bonus, and effects had to be applied individually. For example this is used in the Soviet history file.

add_tech_bonus = {
		bonus = 1.0
		uses = 2
		category = armor
}

Add wargoal:

create_wargoal = {
		type = take_state_focus
		target = POL
		generator = { 72 88 90 87 86 } # Zaolzie Krakow Kielce Lodz Poznan
}

Country and global flags:

set_global_flag = earhart_disappeared		#Global flags can be placed in any country's file
set_country_flag = sudetenland_acquired		#For Germany in 1939
USA = {		#country to which the event will happen
	country_event = { id = usa.50 days = 2 }	#triggers this event, 2 days from the start
	country_event = { id = usa.51 days = 2 }	
}

Opinion modifiers:

add_opinion_modifier = { target = POL modifier = refused_anti_comintern_pact_opinion }		

Modifiers have their effects defined in /Hearts of Iron IV/common/opinion_modifiers

Diplomacy[edit]

If the new country has any diplomatic relations, these can be declared here. It is recommended that one adds relations only in one file (not in both the faction leader's file and the minor ally's for instance).

Factions[edit]

Factions are defined by adding the following line:

create_faction = Clanintern

The country that belongs to the file this line is in will take the role of faction leader. Other countries may be added to the faction:

add_to_faction = IRE

Puppets of members should always be added to the faction as well, to prevent bugs.

Puppets[edit]

Puppets are defined as follows if the player has the 'Together for Victory' Expansion:

set_autonomy = {
	target = ENG
	autonomous_state = autonomy_integrated_puppet
}

and as follows if they don't:

puppet = ENG

In order to make the mod useable for both types of players an if-statement should be used:

if = {
	limit = {
		has_dlc = "Together for Victory"
	}
	set_autonomy = {
		target = ENG
		autonomous_state = autonomy_integrated_puppet
	}
	else = {
		puppet = ENG
	}
}

If the player has 'Together for Victory', Great Britain will be an integrated puppet, if not, they will be a regular (the only type of) puppet.

Other diplomatic actions[edit]

Guarantee Independence:
The country this file belongs to will guarantee the following TAG

give_guarantee = FRA

Non-aggression Pact:

diplomatic_relation = { country = USA relation = non_aggression_pact }

Starting trade:
The country this file belongs to will import preset amount of resource

create_import = {
		resource = tungsten
		factories = 1
		exporter = SWE
}

Military access:

give_military_access = IRE

Tech sharing[edit]

If the player has 'Together for Victory' one can add the country to a tech sharing group:

add_to_tech_sharing_group = haggis_investigators

An if-statement as shown above will be required to limit it to 'Together for Victory' owners and to prevent bugs with those that don't own it.

Set popularities[edit]

Defines the popularity of different parties in the country:

set_popularities = {
	democratic = 5
	communism = 80
	fascism = 10
	neutrality = 5
}

Set politics[edit]

Defines the ruling party and how elections work in a country:

set_politics = {
	ruling_party = communism
	last_election = "1932.11.8"
	election_frequency = 48
	elections_allowed = no
}

Note: Frequency is in months

Country leaders[edit]

Defines the leaders a country has. In theory adding a leader for only the starting ideology would be enough, as the other ones will be randomly generated, it is possible however, to define the leaders of all parties.

create_country_leader = {
	name = "Ronald McDonald"
	desc = "POLITICS_RONALD_MCDONALD_DESC"
	picture = "gfx/leaders/Europe/Portrait_Europe_Generic_land_3.dds"
	expire = "1965.1.1"
	ideology = fascism_ideology
	traits = {
		scary_clown
	}
}

One can add a custom portrait by adding it in in DDS-format, which may require Gimp or Paint.net to edit.

A list of traits can be found in /Hearts of Iron IV/common/country_leader. It is possible to add more there as well.

Military leaders[edit]

Custom army leaders may be defined here:

create_corps_commander = {
 	name = "Sean McHaggis"
 	portrait_path = "gfx/leaders/Europe/Portrait_Europe_Generic_land_4.dds"
 	traits = { panzer_leader fortress_buster }
 	attack_skill = 4
	defense_skill = 2
	planning_skill = 1
	logistics_skill = 2
}

As well as naval leaders:

create_navy_leader = {
 	name = "James McSeafarer"
 	portrait_path = "gfx/leaders/Europe/Portrait_Europe_Generic_navy_1.dds"
 	traits = { blockade_runner superior_tactician }
 	attack_skill = 3
	defense_skill = 3
	maneuvering_skill = 5
	coordination_skill = 2
}

Variants (optional)[edit]

Special variants on equipment available for this country from the start can be defined as well:

create_equipment_variant = {
	name = "Haggis Class"
	type = submarine_1
	upgrades = {
		sub_engine_upgrade = 3
		sub_stealth_upgrade = 2
		sub_torpedo_upgrade = 2
	}
}
create_equipment_variant = {
		name = "Scotfire"
		type = fighter_equipment_1
		upgrades = {
			plane_gun_upgrade = 3
			plane_range_upgrade = 0  
			plane_engine_upgrade = 3
			plane_reliability_upgrade = 3
		}
}
create_equipment_variant = {
		name = "Tanktoon 2"
		type = light_tank_equipment_2
		upgrades = {
			tank_gun_upgrade = 5
			tank_armor_upgrade = 1  
			tank_engine_upgrade = 2
			tank_reliability_upgrade = 0
		}
		obsolete = yes	#optional, marks the unit as obsolete and hides the unit from the UI
}

Localisation[edit]

Link to main page Localisation

Add the localisation for your new country to the following file (it is generally recommended to always create a new, separate file, to avoid overwrites of vanilla files)

<yourmod>/localisation/mynewscotland_l_<language>.yml

where <language> can be either English, German, Spanish, French, Polish, Russian or Brazilian Portuguese. A file can be created for each language for better coverage across the supported languages.

Define the localisation for the country's name and its adjective as follows for every ideology:

SCO_communism: "People's Republic of Scotland"
SCO_communism_DEF: "The People's Republic of Scotland" #For events
SCO_ADJ: "Scottish"

Make sure the .yml file is encoded as UTF-8-BOM. This is easy to check and to change in Notepad++ or other similar programs.

Note: Do not mistake the correct letter _l_ ( L ) with a letter i ( I ), or number 1 ( One ), it's a common mistake, causing localisations to not show up, without any evident cause.

Flag[edit]

Each country need 12 flags: 4 flags, 1 for each ideology, including non-aligned, and 3 sizes for each: Standard, Medium, Small. Each flag needs to be a TGA-file with the name of the country tag and the ideology the flag is meant for. The flag file format is 32-bits and uncompressed.

However, if you do not wish to make a flag for each ideology, it is also an option to create a single flag for each size and just name it the country tag without naming an ideology. For example, "SCO.tga" would appear as the flag of Scotland if there is not a particular flag for the current ideology.

Size-requirement
Standard 82x52 pixel
Medium 41x26 pixel
Small 10x7 pixel

All flags are located in /Hearts of Iron IV/gfx/flags. For the purpose of this mode, place them in <yourmod>/gfx/flags, each flag size into the corresponding folder.

Order of battle (optional)[edit]

If the country will exist at the start, an order of battle is necessary for the country to have an army. Create a new file in /Hearts of Iron IV/history/units or copy one from a similar country. It must be named exactly the way it's linked in the country's history file. Specific names of different types of units and their support companies can be found in /Hearts of Iron IV/common/units.

Division template[edit]

First the default division template will be defined, simply set up what regiments will fill the country's divisions:

division_template = {
	name = "Blueskirt Division"

	regiments = {
		infantry = { x = 0 y = 0 }
		infantry = { x = 0 y = 1 }
		infantry = { x = 0 y = 2 }
		infantry = { x = 1 y = 0 }
		infantry = { x = 1 y = 1 }
		infantry = { x = 1 y = 2 }
		infantry = { x = 2 y = 0 }
		infantry = { x = 2 y = 1 }
		infantry = { x = 2 y = 2 }
		infantry = { x = 3 y = 0 }
		infantry = { x = 3 y = 1 }
	}
}

As can be seen, this division exists solely out of infantry. Example of more advanced unit template from Germany, which will use german infantry names:

division_template = {
	name = "Infanterie-Division"
	division_names_group = GER_Inf_01

	regiments = {
		infantry = { x = 0 y = 0 }
		infantry = { x = 0 y = 1 }
		infantry = { x = 0 y = 2 }
   		infantry = { x = 1 y = 0 }
		infantry = { x = 1 y = 1 }
		infantry = { x = 1 y = 2 }
  		infantry = { x = 2 y = 0 }
		infantry = { x = 2 y = 1 }
		infantry = { x = 2 y = 2 }
	}
	support = {
		engineer = { x = 0 y = 0 }
		artillery = { x = 0 y = 1 }
	}
}

Division placement[edit]

Division can be placed as follows:

units = {
	division= {	
		name = "1st Blueskirt Division"
		location = 9392 # Edinburgh
		division_template = "Blueskirt Division"
		start_experience_factor = 0.2   #optional, otherwise starts with 0 expereince
		start_equipment_factor = 0.3    #optional, otherwise starts with equipment factor of 1 (maximum)

	}
}

The name is simply the name the game shows for the division, the location is where the division is on the map, the template links to the template defined above and start_experience_ and _equipment_factors define how much experience and equipment the division has. Alternatevely you can use the automatic naming using a predefined list of names.

         division= {
		division_name = {
				is_name_ordered = yes
				name_order = 35
		}
		location = 6488
		division_template = "Infanterie-Division"
		start_experience_factor = 0.1                                                 #optional, otherwise starts with 0 expereince
		force_equipment_variants = { infantry_equipment_0 = { owner = "GER" } }       #optional, replaces equipment with a specific variant (for example to give obsolete equipment to garrison units)
	}

Air wings[edit]

Air wings are not placed into a specific province, but rather a State.

air_wings = {
	121 = { 	# Edinburgh
		tac_bomber_equipment_0 = { owner = "SCO" amount = 72 }
			start_experience_factor = 0.2	#optional, otherwise starts with 0 expereince
		fighter_equipment_1 = { owner = "SCO"  version_name = "Scotfire" amount = 150 }		#version_name is optional
			start_experience_factor = 0.5			
	}
}

version_name defines a specific variant of that type of equipment to be used. It first needs to be defined in the same file.

Adding history for other Bookmarks (optional)[edit]

If you want to edit something about your country, but only want it applied after a specific date (as in 1939 bookmark for example), you have to add these lines to the history file:

1939.1.1 = {
#There you can add anything, in the same format as described earlier
	oob = "SCO_1939"	#Usually another oob is used for later bookmarks, only the latest one will be loaded
	set_technology = {
		atomic_research = 1 
		nuclear_reactor = 1 
		nukes = 1
	}	
}

National Focus[edit]

National Focuses can be completed in two ways: If you want the effects to apply, then use:

complete_national_focus = army_effort

If you want to just bypass the focus (often used for more complex focuses, like 'Demand Sudetenland', and apply effect manually, without triggering all the associated events), use:

unlock_national_focus = GER_demand_sudetenland

Specific cases[edit]

Cancelling a relation that is activated earlier (like a guarantee to FRA used earlier):

diplomatic_relation = {
	country = FRA
	relation = guarantee
	active = no
}

Removing previously used idea:

remove_ideas = {
	great_depression	
}

Things to remember[edit]

  • The date used must be at least 1 day before the actual bookmark start date, multiple dates can be used
  • Ideas are added, Laws are replaced by the latest loaded
  • Technologies only have to be applied once, add only extra technologies to the later bookmarks
  • If a National Focus triggers an event, or adds effect, completing it by history file does not apply these, they have to be triggered separately
  • Country leader is chosen based on corresponding ideology, if multiple are present, the one located lower in the file is chosen

Adding the country to the game[edit]

There are three ways to implement the new country into the game.

  • Using events
  • By national focus
  • Editing state history

Adding countries by event or national focus[edit]

Main article: Event Modding

There are multiple ways to add a country's presence by event or national focus. Here are two:

set_state_owner = 119

Using this script in an event option or national focus reward, when scoped to the new country, will cause the province to be owned by the new country. If it is occupied by a third power and the new country is at war with them however, the region will remain occupied.

transfer_state = 119

This script will change both the ownership and control to the scoped state. If a third country occupies it it will go to the new country regardless of the state of relations between it and the occupying power.

Adding countries with state history[edit]

Change the owner and cores in province history files so that they include the new country either by default or in defined bookmarks (for instance only in 1939)