Autonomy state modding

本页面所适用的版本可能已经过时,最后更新于1.10
秋起.讨论 | 贡献2024年8月9日 (五) 15:53的版本

Different levels of the autonomy system are defined in /Hearts of Iron IV/common/autonomous_states/*.txt, and new ones can be created.

Arguments

  • id is the ID of the autonomy state, unique to each one. It is necessary to define to distinguish it from other autonomy states.
  • default: If true, the game will attempt to make the 'puppet' option in peace deals as well as the 'puppet' effect use this autonomy state among other default autonomy states. By default, set to no.
  • is_puppet decides whether the subject is a puppet or not, making is_puppet and is_puppet_of triggers true in that case. By default, set to no.
  • use_overlord_color makes the subject have the same country color as the overlord.
  • min_freedom_level decides the order in which autonomy states are placed. The autonomy states with lower freedom levels have less autonomy than those with higher when the game places the autonomy states for the subject to lose or gain a level. This also decides how many autonomy points the subject needs to gain or lose a level, calculated by the difference between freedom levels multiplied by 5000. As such, it would take 500 points to go from an autonomous state with the min_freedom_level of 0.1 to being annexed.
  • manpower_influence decides how large of a portion of the subject's manpower the overlord can use in colonial divisions. Requires the 共赴胜利共赴胜利 DLC.
  • rule sets the game rules for the subject to either yes or no.
Game rule list 
The following game rules exist as possible options:
Internal name Localised name Notes
can_access_market Can access International Market (Puppets and Overlords can always access each other's market)
can_be_spymaster Can be Spy Master
can_boost_other_ideologies Can boost popularity of other ideologies
can_boost_own_ideology Can boost own party popularity in other countries
can_create_collaboration_government Can create collaboration governments
can_create_factions Can Create Factions
can_declare_war_on_same_ideology Can declare war on country with the same ideology group without a war goal
can_declare_war_without_wargoal_when_in_war Can declare war on a neighbor without a wargoal when at war with a major
can_decline_call_to_war Can decline call to war
can_force_government Can force government of another country to adopt the same ideology
can_generate_female_aces Women in your country are allowed to become military pilots
can_generate_female_country_leaders Can generate female country leaders
can_generate_female_unit_leaders Can generate female unit leaders
can_guarantee_other_ideologies Can guarantee other ideologies
can_join_factions Can join factions
can_join_factions_not_allowed_diplomacy Country's name is not allowed to join factions
can_join_opposite_factions Can Join Factions led by another Ideology
can_lower_tension Lowers World Tension with Guarantees
can_not_build_buildings CAN_NOT_BUILD_BUILDINGS Doesn't seem to work.
can_not_declare_war Can not declare wars Prevents generating wargoals, but not using existing ones.
can_occupy_non_war Can hold territory owned by a country they are not at war with
can_only_justify_war_on_threat_country Can justify war goals against a country that have not generated world tension
can_puppet Can puppet a country
can_send_volunteers Can send volunteer forces
can_use_kamikaze_pilots Can use kamikaze pilots
contributes_operatives Contributes Operatives to Spy Master: Yes Only has an effect for subjects.
units_deployed_to_overlord Control over deployed units go to overlord Only has an effect for subjects.
  • modifier sets the modifier for the subject. All country modifiers can apply.
  • ai_subject_wants_higher decides whether or not the AI subject focuses on gaining a higher autonomy. If set to 0, AI will never gain an autonomy level through the autonomy system.
  • ai_overlord_wants_lower decides whether or not the AI overlord focuses on gaining a lower autonomy for the subject. If set to 0, AI will never decrease the autonomy level through the autonomy system.
  • ai_overlord_wants_garrison decides the triggers when the AI overlord garrisons the subject's territory as if it was their own land.
  • allowed are the necessary triggers the subject must meet for the autonomy state to apply. The OVERLORD scope can be used to scope into the overlord.
  • use_for_peace_conference_weight decides the chance for a potential overlord to puppet the country in the peace deal, where ROOT is the subject and FROM is the overlord.
  • can_take_level sets the necessary triggers the subject must meet to be able to gain a level through the autonomy system.
  • can_lose_level sets the necessary triggers the subject must meet for the overlord to be able to decrease the autonomy level through the autonomy system.
  • peace_conference_initial_freedom is the initial freedom level of the country that gets set to this autonomy after a peace conference on a scale from 0 to 1. If not specified, assumed to be 0.5.
  • allowed_levels_filter decides which autonomy levels a country with this autonomous state can change to, alongside autonomy_free. If not specified, all levels will be allowed.

Icon

For the icon, the game will use a sprite named in the format of GFX_<autonomy state>_icon. An /Hearts of Iron IV/interface/*.gfx file containing such a definition may look like the following:

spriteTypes = {
    spriteType = {
        name = "GFX_autonomy_mod_new_icon"
        textureFile = "gfx/interface/autonomy/autonomy_mod_new_icon.dds"
    }
    spriteType = {
        name = "GFX_example_icon"
        texturefile = "another_folder/image_name.dds"
    }
}

Localisation

The localisation is set in an .yml file in the localisation/ folder. Using the prior example of autonomy_mod_new, a localisation entry will look like autonomy_mod_new:0 "Mod's new autonomy state"

It is possible to set a country-specific entry. An entry with GER_autonomy_mod_new:0 "New mod Germany" will make Germany have that name if its autonomy level is autonomy_mod_new. Similarly, ENG_FRA_autonomy_mod_new:0 "New mod French UK" will make the United Kingdom have that name if its overlord is France and the autonomy state is autonomy_mod_new.

Example

autonomy_state = {
	id = autonomy_example
	
	default = yes					#Will be a possible option for peace deals
	is_puppet = yes
	
	use_overlord_color = yes
	
	min_freedom_level = 0.2				#Puts it as 0.2 on the autonomy level scale, which is the same as an integrated puppet.

	peace_conference_initial_freedom = 0.9		#Close to independence
	
	manpower_influence = 0.9
	
	rule = {
		can_not_declare_war = yes
		can_decline_call_to_war = no
		units_deployed_to_overlord = yes
		can_be_spymaster = no
		contributes_operatives = no
		can_create_collaboration_government = no
	}
	
	modifier = {
		autonomy_manpower_share = 1.0
		can_master_build_for_us = 1
		extra_trade_to_overlord_factor = 1.0
		overlord_trade_cost_factor = -0.9
		cic_to_overlord_factor = 0.75
		mic_to_overlord_factor = 0.75
		research_sharing_per_country_bonus_factor = -0.5
	}
	
	ai_subject_wants_higher = {
		factor = 0.0
	}
	
	ai_overlord_wants_lower = {
		factor = 0.0
	}

	allowed = {
		has_dlc = "Together for Victory"
		OVERLORD = {
			tag = FRA
		}
	}

	allowed_levels_filter = {
		autonomy_example
		autonomy_example_1
		autonomy_example_2
	}

	use_for_peace_conference_weight = {
		base = 0
		modifier = {
			add = 10
			FROM = {
				has_wargoal_against = { target = ROOT type = puppet_wargoal_focus }
			}			# Adds 10 to the chance if the overlord has a wargoal to puppet the country.
		}
		modifier = {
			factor = 2
			tag = ENG	# Multiplies the chance by 2 if the subject is UK.	
		}
	}

	can_take_level = {
		OVERLORD = {
			NOT = {
				controls_state = 123
			}	# If the overlord does not control state 123, the subject can gain a level.
		}
	}

	can_lose_level = {
		OVERLORD = {
			controls_state = 123
		}	# If the overlord controls state 123, it can decrease the subject's autonomy level.
	}
}

Related defines

Certain Defines affect the autonomy system in a certain way. These are:

  • RESOURCE_SENT_AUTONOMY_DAILY_BASE Base autonomy gain from the overlord purchasing the subject's resources through trade.
  • RESOURCE_SENT_AUTONOMY_DAILY_FACTOR Autonomy gain multiplier from the overlord purchasing the subject's resources through trade.
  • WAR_SCORE_AUTONOMY_BASE Base autonomy gain from the subject gaining war score in a war.
  • WAR_SCORE_AUTONOMY_FACTOR Autonomy gain multiplier from the subject gaining war score in a war.
  • LL_TO_OVERLORD_AUTONOMY_DAILY_BASE Base autonomy gain from the subject lend-leasing to the overlord.
  • LL_TO_OVERLORD_AUTONOMY_DAILY_FACTOR Autonomy gain multiplier from the subject lend-leasing to the overlord.
  • LL_TO_PUPPET_AUTONOMY_DAILY_BASE Base autonomy gain from the overlord lend-leasing to the subject. Must be negative in order to lose autonomy.
  • LL_TO_PUPPET_AUTONOMY_DAILY_BASE Autonomy gain multiplier from the overlord lend-leasing to the subject. Must be negative in order to lose autonomy.
  • AUTONOMY_FREEDOM_FROM_CAPITULATE Upon the overlord capitulating, the subject receives a large gain to the autonomy progress.
  • ATTACHE_TO_SUBJECT_EFFECT Base autonomy gain from the overlord sending an attache to the subject. Must be negative in order to lose autonomy.
  • ATTACHE_TO_OVERLORD_EFFECT Base autonomy gain from the subject sending an attache to the overlord.
  • AUTONOMY_LEVEL_CHANGE_PP_COST_BASE The cost in political power to change between autonomy states.
  • AUTONOMY_LEVEL_CHANGE_PP_ANNEX The cost in political power to annex a subject.
  • AUTONOMY_LEVEL_CHANGE_PP_FREE The cost in political power to gain independence as a subject.
  • MAX_SCORE_DIFF_TO_CHANGE_AUTONOMY The maximum difference between the current freedom score and the cap for the next or previous level allowed for changing.
  • MASTER_BUILD_AUTONOMY_FACTOR Autonomy gain multiplier from the overlord building in the subject's states. Must be negative in order to lose autonomy.
  • AUTONOMOUS_TOTAL_SCORE The total amount of autonomy points between the country's annexation and independence.
  • AUTONOMOUS_SPILLOVER The amount that can be saved between levels.

Additional notes

When setting the autonomy level in the country's history file, it is possible that it will overwrite the party popularities and the ruling party of the subject. In order to prevent that to happening, it is recommended to scope into the overlord as

TAG = {
	if = {
		limit = {
			has_dlc = "Together for Victory"
		}
		set_autonomy = {
			target = TAG2
			autonomy_state = autonomy_mod_new
		}
	}
	else = {
		puppet = TAG2
	}
}

in the subject's history file, also putting it before defining the ruling party and popularities. Alternatively, the order of tags in /Hearts of Iron IV/common/country_tags/ can be changed so that the overlord is defined earlier than the subject.

If deciding to create a new autonomy system similar to Japan's unique autonomies, it is necessary to disable the default autonomy states so that they could not be used via allowed = {} in them or via allowed_levels_filter = {} in the new autonomies. Note that if you choose the second option, you would still need to disable the default autonomies so that they do not appear while puppeting.

If a new autonomy level should only be possible to be manually assigned via the set_autonomy effect, then it's possible to set up allowed as such, using the autonomy state with the id of autonomy_my_state:

allowed = {
    OR = {
        is_subject = no
        has_autonomy_state = autonomy_my_state
    }
}

That makes the autonomy state impossible to achieve through gaining or losing levels, as the allowed block is false if the subject has any other autonomy. This will ensure that set_autonomy will be possible to execute, as long as the target country is independent at the time, and that it wouldn't get cleared after being assigned, while it has that autonomy state.

When creating autonomy systems, avoid 2 different states having the same min_freedom_level.