National Focus modding

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

Focus Tree[edit | edit source]

focus_tree = {
	id = <focus tree id>
	
	country = {
		factor = 0
		
		modifier = {
			add = 10
			tag = <country tag> 
		}
	}

	default = <yes/no>

	reset_on_civil_war = <yes/no>

	shared_focus = <Shared Focus ID>

	continuous_focus_position = { x = <position> y = <position> }
	
	initial_show_position = {
		x = <integer>
		y = <integer>
		offset = {
			x = <integer>
			y = <integer>
			<trigger>
		}
	}
}
  • id is the focus tree id, which can be used to load a focus tree during the game. This can be any string you want.
  • factor is the base factor, leave it at 0 unless you are making a generic tree, in which case make it 1.
  • modifier changes the base factor to allow your selected country to load their focus tree.
  • tag is what sets which country has the focus tree. You can put multiple tags inside of an OR = {} block if you wish for a focus tree to be shared among multiple nations.
  • default is what defines whether a focus tree is generic or country-specific.
  • reset_on_civil_war If set to true, if a civil war occurs the breakout country will have the same focus tree and completed focuses as the original. If set to false, the civil war country will have the same focus tree but not the same completed focuses. Defaults to false.
  • shared_focus Optional. Will load any shared focuses you create.
  • continuous_focus_position Optional. Allows you to move the continuous focus box if your focus tree will go in the default area.
  • initial_show_position Optional. Decides the position of the camera when you first open the focus tree. The offset will modify the position if the trigger is true. There are 2 ways to do this:
initial_show_position = {
	x = <integer>
	y = <integer>
}

This will move the camera to the specified coordinates.

initial_show_position = {

focus = <focus ID>

}

This will move the camera to the position of the specified focus.

Focuses[edit | edit source]

focus = {
	id = <focus id>
	icon = <icon>

	cost = <number>

	allow_branch = {
		<trigger>
	}

	x = <position>
	y = <position>
	relative_position_id = <previous focus>
	offset = {
		x = <position>
		y = <position>
		trigger = {
			<trigger>
		}
	}

	prerequisite = {
		focus = <focus id>
	}

	mutually_exclusive = {
		focus = <focus id>
	}

	available = {
		<trigger>
	}

	bypass = {
		<trigger>
	}
	
	historical_ai = {
		<trigger>
	}
	
	cancel = {
		<trigger>
	}
	
	available_if_capitulated = <yes/no>
	cancel_if_invalid = <yes/no>
	continue_if_invalid = <yes/no>
	will_lead_to_war_with = <tag>
	search_filters = { <focus filters, separated by spaces if multiple> }

	select_effect = {
		<command>
	}
	
	completion_reward = {
		<effect>
	}
	
	complete_tooltip = {
		<effect>
	}

	ai_will_do = {
		factor = 1
		modifier = {
			<modifier>
		}
	}
}
  • id is the focus id. This can be any string you want.
  • icon is the picture that goes with the focus. The name is defined in goals.gfx in /Hearts of Iron IV/interface. To create a custom one you must follow the formatting in goals.gfx and add a shine in goals_shine.gfx in the same directory.
  • cost is how long the focus takes to complete. By default, it increases in sevens, so 1 would be 7 days, 10 would be 70 days, etc. Editable in the defines
  • allow_branch is used to hide branches depending on certain triggers. Used in base game focus trees of majors to hide DLC-exclusive branches. Is only checked when the focus tree is loaded or when the check is forcibly refreshed by the mark_focus_tree_layout_dirty effect. Optional.
  • x is the position on the focus tree horizontally.
  • y is the position on the focus tree vertically.
  • relative_position_id makes the x and y values relative to the defined focus, which allows for negative values. Optional.
  • prerequisite is what makes a previous focus required to complete the current focus. There are multiple ways for doing this.
prerequisite = {
	focus = generic_focus_1
}

Will require that the current focus only needs generic_focus_1 to be completed.

prerequisite = {
	focus = generic_focus_1
	focus = generic_focus_2
}

Will require that either generic_focus_1 and/or generic_focus_2 needs to be completed. Can have more than two.

prerequisite = {
	focus = generic_focus_1
}

prerequisite = {
	focus = generic_focus_2
}

Will require that both generic_focus_1 and generic_focus_2 need to be completed.

  • mutually_exclusive will make it so only one of the listed focuses can be done. Can have more than one. Optional.
  • available will make it so a focus can only be started if the following triggers are true. Optional.
  • bypass will make it so a focus will be skipped if the following triggers are true. Note that the rewards will not be given when the focus is bypassed instead of completed. Optional.
  • cancel will abort the focus if the triggers are true. Optional.
  • cancelable will make it so the user can cancel the focus once it starts. If false, cancel_if_invailid will make the focus pause instead. Defaults to true. Optional.
  • historical_ai is a trigger used when Historical Focus is enabled. It overrides the ai_strategy_plan focus lists, so an AI will skip this focus if triggers are false. Optional.
  • available_if_capitulated will make it so a focus can not be completed if the country has capitulated. Defaults to false. Optional.
  • cancel_if_invalid will make it so a focus will cancel if the trigger (available = { } ) is false. Defaults to true. Optional.
  • continue_if_invalid will make it so a focus will continue even if the triggers (available = { } ) become false. Defaults to false. Same as "cancel_if_invalid" but with an inverse logic. Optional.
  • will_lead_to_war_with is normally given to focuses granting wargoals (or generally expected to lead to a war). It will give the <tag> an UI warning about wargoal justification. It also prompts the AI to prepare for a war with ROOT country. Optional.
  • search_filters assigns the search filters to the focus, making it be highlighted if the player chooses the specified filter. Optional.
  • select_effect will make it so when a focus is selected, a command will be run. Will make the focus unable to be canceled. Optional.
  • ai_will_do will set the likelihood of the AI completing a focus. Defaults to one. If the focus is not at the start of a branch, the likelihood will increase by 50%. It will be proportionally reduced if the focus is mutually exclusive to another. It will be affected by focus_factor in AI strategy plans. The final percentage will be a number between 0 and the number you define.
  • completion_reward is the reward of the focus and will execute the effects inside for the country that did the focus.
  • complete_tooltip If specified, will overwrite the tooltip (The completion reward shown to the player) of the reward with the effects inside. It is assumed that the focus was already done when the complete_tooltip is calculated. Optional.
  • offset will modify the position of the focus by a certain amount if the trigger is true. Is only checked when the focus tree is loaded or when the check is forcibly refreshed by the mark_focus_tree_layout_dirty effect. Optional.

Focus filters[edit | edit source]

There is no set folder for focus filters. If a focus uses a focus filter, it will show up when viewing the focus tree. However, their localisation and GFX should be defined outside of the focus tree.

Localisation is defined in /Hearts of Iron IV/localisation/*_l_<language>.yml. Both shared focuses and regular focus trees go into a regular text file in /Hearts of Iron IV/common/national_focus. In localisation, a focus filter called FOCUS_FILTER_MOD will need an entry with FOCUS_FILTER_MOD:0 "Focus filter name".

GFX is defined in /Hearts of Iron IV/interface/*.gfx. The above example of FOCUS_FILTER_MOD would use a spritetype with this inside:

	spriteType = {
		name = "GFX_FOCUS_FILTER_MOD"
		texturefile = "gfx/interface/focusview/filter/<filename>"
	}

As such, a GFX_<filter name> sprite is automatically used for the focus filter.

Focus icons[edit | edit source]

Focus icons, unlike other GFX, require 2 definitions in the /Hearts of Iron IV/interface/*.gfx files instead of 1: there needs to be a sprite and a shine. The sprite is used in the focus description and for unavailable or completed focuses in the national focus tree view, while the shine is used for available focuses, and for the focus in progress seen in the politics and diplomacy views. If one is missing, the default GFX_focus_unknown icon will be shown instead.
An example of a sprite definition:

	SpriteType = {
		name = "GFX_<sprite name>"
		texturefile = "gfx/interface/goals/<filename>"			
	}

Note that the filename must include the extension, such as .dds. A shine would look like

	SpriteType = {
		name = "GFX_<sprite name>_shine"
		texturefile = "gfx/interface/goals/<filename>"
				effectFile = "gfx/FX/buttonstate.lua"
		animation = {
			animationmaskfile = "gfx/interface/goals/<filename>"
			animationtexturefile = "gfx/interface/goals/shine_overlay.dds" 	# <- the animated file
			animationrotation = -90.0		# -90 clockwise 90 counterclockwise(by default)
			animationlooping = no			# yes or no ;)
			animationtime = 0.75				# in seconds
			animationdelay = 0			# in seconds
			animationblendmode = "add"       #add, multiply, overlay
			animationtype = "scrolling"      #scrolling, rotating, pulsing
			animationrotationoffset = { x = 0.0 y = 0.0 }
			animationtexturescale = { x = 1.0 y = 1.0 } 
		}

		animation = {
			animationmaskfile = "gfx/interface/goals/<filename>"
			animationtexturefile = "gfx/interface/goals/shine_overlay.dds" 	# <- the animated file
			animationrotation = 90.0		# -90 clockwise 90 counterclockwise(by default)
			animationlooping = no			# yes or no ;)
			animationtime = 0.75				# in seconds
			animationdelay = 0			# in seconds
			animationblendmode = "add"       #add, multiply, overlay
			animationtype = "scrolling"      #scrolling, rotating, pulsing
			animationrotationoffset = { x = 0.0 y = 0.0 }
			animationtexturescale = { x = 1.0 y = 1.0 } 
		}
		legacy_lazy_load = no
	}

The name for the shine must be exactly the same as for the sprite, but with _shine added in the end. The only necessary edits that need to be done for a shine to be working correctly are changing the file path in texturefile and 2 animationmaskfiles as well as the shine's name. While optional to change, Graphical Asset Modding explains the arguments in additional detail.

Examples and Locations[edit | edit source]

Shared Focus[edit | edit source]

Put shared focuses in their own files. There is no line required before the shared focuses

shared_focus = {
	id = shared_1
	x = 10
	y = 0

	completion_reward = {
		army_experience = 10
	}
}

shared_focus = {
	id = shared_2
	relative_position_id = shared_1 # Will link to the first one, allowing for whole branches to be applied at once
	x = 0
	y = 1

	completion_reward = {
		naval_experience = 10
	}
}

Using Shared Focus[edit | edit source]

The file name does not matter, but follow the formatting below.

focus_tree = {
	id = lithuania_focus
	country = {
		base = 0
		modifier = {
			add = 10
			tag = LIT
		}
	}
	shared_focus = shared_1

	focus = {
		id = LIT_focus_1
		x = 10
		completion_reward = {
			navy_experience = 10
		}
	}
	focus = {
		id = LIT_focus_2
		prerequisite = { focus = LIT_focus_1 }
		relative_position_id = LIT_focus_1
		y = 10
		completion_reward = {
			navy_experience = 10
		}
	}
}

Continuous focuses[edit | edit source]

Continuous focuses are defined in /Hearts of Iron IV/common/continuous_focus. They are focuses which grant constant effect while selected and can't be completed.

Focus palettes[edit | edit source]

While in the base game each country has the same selection of continuous focuses, it is possible to assign different selections of them depending on the circumstances. An example of a continuous focus palette looks like this:

continuous_focus_palette = {
	id = XXX_mod_focus
	
	country = {
		factor = 0
		modifier = {
			tag = TAG
			add = 10
		}
	}
	
	default = no
	reset_on_civilwar = no
			
	position = { x = 50 y = 1000 }
  • id decides the unique ID of the palette.
  • country assigns the values of the palettes to each country, picking the one with the highest value. It works the same as in national focuses. Note that the check is only checked when loading the focus palette.
  • default marks the focus palette as default. It is unknown if this has uses in continuous focus palettes, but avoid having less than or more than 1 default palette.
  • reset_on_civilwar will make the value check be refreshed when the country enters a civil war.
  • position changes the default position of the box with continuous focuses. It will get overwritten by a similar argument in the national focus trees.

Focuses[edit | edit source]

An example of a continuous focus looks like this:

	focus = {
		id = XXX_mod_focus
		
		icon = GFX_goal_mod_icon
		
		enable = {
			tag = GER
		}
		
		available = {
			has_war = no
		}
		
		modifier = {
			stability_weekly = 0.01
		}
		
		idea = XXX_mod_idea
		
		select_effect = {
			set_country_flag = doing_continuous_focus
		}
		
		cancel_effect = {
			clr_country_flag = doing_continuous_focus
		}
		
		ai_will_do = {
			factor = 1
		}
		
		supports_ai_strategy = ai_focus_peaceful
		
		daily_cost = 0.5
		
		available_if_capitulated = yes
	}

*id assigns the ID of the focus. It is also used in localisation.

  • icon assigns the icon to the focus. Like in normal focuses, a shine sprite is also necessary for the focus icon sprite to work.
  • enable is the collection of triggers that decide when the focus is visible.
  • available is the collection of triggers that decide when the focus can be taken.
  • modifier applies the following modifiers to the country when the focus is being taken.
  • idea will assign the specified idea to the country while it is active, removing it when canceled. This can be helpful if you want to apply a bonus that can't go inside modifier, such as targeted modifiers or equipment bonuses.
  • select_effect will execute the effects inside once the focus is selected.
  • cancel_effect will execute the effects inside when the focus is no longer selected.
  • ai_will_do assigns a weight to AI doing the focus. More info in the AI modding article.
  • supports_ai_strategy will make the AI prioritise this continuous focus if it has the specified AI focus.
  • daily_cost is the value of political power that's subtracted daily when the continuous focus is selected.
  • available_if_capitulated decides if you can do this focus while the country has capitulated or not.