钢铁雄心 IV 中文离线资料库

Autonomy state模组制作

原页面:Autonomy state modding

本页中文翻译进度 60%,未译部分暂保留英文原文。

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

参数

  • id is the ID of the autonomy state, unique to each one. It is necessary to define to distinguish it from other autonomy states.
  • 默认: 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[1]. 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.
  • rule sets the game rules for the subject to either yes or no.
游戏规则列表
以下游戏规则作为可选项存在:
内部名称 本地化名称 备注
can_access_market 可访问国际市场(傀儡国与宗主国始终可以访问彼此的市场)
can_be_spymaster 可成为特工大师
can_boost_other_ideologies 可提升其他意识形态的支持率
can_boost_own_ideology 可提升本国政党在其他国家的支持率
can_create_collaboration_government 可建立合作政府
can_create_factions 可创建阵营
can_declare_war_on_same_ideology 可在没有战争目标的情况下向同一意识形态组的国家宣战
can_declare_war_without_wargoal_when_in_war 在与主要国家交战时,可在没有战争目标的情况下向邻国宣战
can_decline_call_to_war 可拒绝参战号召
can_force_government 可迫使其他国家政府采纳相同意识形态
can_generate_female_aces 允许本国女性成为军事飞行员
can_generate_female_country_leaders 可生成女性国家领袖
can_generate_female_unit_leaders 可生成女性部队指挥官
can_guarantee_other_ideologies 可保障其他意识形态
can_join_factions 可加入阵营
can_join_factions_not_allowed_diplomacy 国家名称不被允许加入阵营
can_join_opposite_factions 可加入由其他意识形态领导的阵营
can_lower_tension 通过保障独立降低世界紧张度
can_not_build_buildings CAN_NOT_BUILD_BUILDINGS 似乎不起作用。
can_not_declare_war 无法宣战 阻止制造战争目标,但不阻止使用已有战争目标。
can_occupy_non_war 可占据未与其交战的国家所拥有的领土
can_only_justify_war_on_threat_country 可对没有产生世界紧张度的国家制造战争目标
can_puppet 可将一个国家变为傀儡国
can_send_volunteers 可派遣志愿军
can_use_kamikaze_pilots 可使用神风飞行员
contributes_operatives 向特工大师提供特工:是 仅对附庸国生效。
units_deployed_to_overlord 已部署部队的控制权归宗主国 仅对附庸国生效。
  • modifier sets the modifier for the subject. All country 修正 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.

图标

Sprite 通用概览
为了加载 GFX,游戏使用 sprite 系统。sprite 是一种代码定义,它把一个名称附加到一个图像文件上,并且可以选择性地添加额外信息,例如动画、帧数、图像的加载方式等等。这意味着 把图像放进 gfx 文件夹并不足以让它生效,一个 sprite 也必须使用该图像文件。

Sprites are defined in any /Hearts of Iron IV/interface/*.gfx file (this is separate from gfx/interface/), opened with a text editor. To create a new .gfx file, a text file can be created and renamed to change the extension (on Windows, the Windows Explorer needs to show the extensions, which it doesn't by default). In particular, sprites are defined within a spriteTypes = { ... } block, as to separate from fonts and map arrows also defined in that folder, while the simplest sprite with the least mandatory properties is a spriteType = { ... }. The simplest sprite definition looks like the following:

spriteTypes = {
    spriteType = {
        name = GFX_first_sprite                         # In some cases, beginning with GFX_ is mandatory for it to work.
        texturefile = gfx/interface/folder/filename.dds # The folder and filename don't matter, as long as they are correct
    }                                                   # Only the forward slash '/' (can be doubled as '//') can be used to separate folders.
    spriteType = {                                      # The image doesn't have to be .dds, as .tga and .png are acceptable.
        name = GFX_second_sprite
        texturefile = gfx/interface/folder2/filename2.dds
        noOfFrames = 2 # Splits the image into 2 halves, which may be switched between dynamically in GUI
    }
}

In this case, this creates a sprite with the name of GFX_first_sprite and attaches the /Hearts of Iron IV/gfx/interface/folder/filename.dds image to it, and a second sprite similarly. The second sprite will be split into 2 frames: this is decided by having the left half of the image as the first frame and the right half as the second frame (more frames would further split the image horizontally). This doesn't make the sprite animated, just turns on the option to switch between the two halves as needed. GFX_second_sprite:1 serves as a reference to the first frame, and GUI can be set up to change the shown frame depending on context, such as with radio stations.
In order to add animation, a frameAnimatedSpriteType is used.

要修改某个 sprite,从来都不是必须复制基础游戏文件。如果在不同文件中对同名 sprite 存在重复定义,游戏将优先使用稍后根据文件名求值的那个,较旧的 sprite 会被完全忽略。可以通过把替换文件名的首字符设为 ASCII 字符表中较靠后的符号来确保这一点。通常为此使用小写字母 'z'。例如,要把GFX_idea_traits_strip中的帧数改为 10,可以在模组的modname/interface/zz_replace.gfx文件中定义一个同名、含 10 帧的 sprite,而不必复制基础游戏文件。由于大多数 .gfx 文件定义了用户界面的组成部分,在游戏大版本更新时复制它们可能导致模组已加载的文件缺少 sprite,这在游戏内会显示为默认图像,即默认的错误狗。为了减轻检查界面文件的负担,最好永远不要复制 .gfx 文件,除非更多新增内容会主动损害模组,例如interface/subuniticons.gfx的情况

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"
    }
}

本地化文件

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.

示例

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 定义文件 affect the autonomy system in a certain way. These are:

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

补充说明

For a country to start the game as a subject, this can be done using the set_autonomy effect in the history files. When doing this, it is preferable to do it in the subject's history file scoping to the overlord's tag, as shown below.

TAG = {
    set_autonomy = {
        target = TAG2
        autonomy_state = autonomy_mod_new
    }
}

Autonomy effects are known to overwrite the political setup of a country, both in terms of leaders, ruling party and popularities. Therefore it has to be placed in the lines before recruiting characters and defining politics. Setting the autonomy level in the overlord's history file is one of the main sources of issues of ideologies being incorrect, due to the overwriting political definitions for the same reason. This happens due to the loading order, but it is not recommended to make changes to the countries' loading order for this purpose.

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.

参考资料

  1. ↑ NDefines.NCountry.AUTONOMOUS_TOTAL_SCORE = 5000 中的 定义文件。
模组制作
文档 效果 • 触发器 • 定义文件 • 修正项 • 修正项列表 • 作用域 • 本地化文件 • 事件钩子 • 数据结构(标记、事件目标、国家标签别名、变量、数组)
脚本 成就 • AI • AI 焦点 • 自治领 • 力量均势 • 书签/剧本 (游戏规则) • 建筑 • 角色与特质 • 外观标签 • 国家 • 师 • 决议 • 学说 • 装备 • 事件 • 阵营 • 理念 • 意识形态 • 军事工业组织 • 国策 • 资源 • 脚本化 GUI • 科技与学说 • 单位
地图 地图 • 州 • 补给区域 • 战略区域
图形 界面 • 图形资源 • 实体 • 后期特效 • 粒子 • 字体
外观 肖像 • 名称列表 • 音乐 • 音效
其他 控制台指令 • 疑难排查 • 模组结构 • 模组 • 地图编辑器