- <government_mechanic_id> = { #自定义政府互动的专用ID,可在政府改革文件(例如01_government_reforms_monarchies)中搭配government_abilities使用
- alert_icon_gfx = <icon> #定义该机制使用的通知图标位于哪个 GFX 图标条中(本体默认使用gfx\interface\alerticons_government_mechanics.dds)
- alert_icon_index = <int> #在上述图标条alert_icon_gfx中该机制的图标索引
- available = <trigger> #触发条件
-
- powers = { #政府互动中的进度条功能
- <government_power_type_id> = { #自定义进度条功能
- gui = <string> #interface文件夹中对应的GUI界面。默认而言,如果非绑定专一的互动,会使用government_shared_power;如果为专一互动绑定,会默认显示在该互动下方。New versions of this will need to contain the same elements so they can be filled in.
- min = <int> #进度条最小值 - 通常是0
- max = <int> #进度条中能保存的最大值
- default = <int> #默认重置后的初始值,通常是0
- reset_on_new_ruler = yes/no #定义新君主是否重置进度条数值,填yes将会重置,不然新君主将保持已积累之数量
- base_monthly_growth = <float> #定义月度增长浮动数值,默认为0
- development_scaled_monthly_growth = <float> #defines the amount of monthly growth you get from development scaled by Development/COUNTRY_DEVELOPMENT_SCALE (i.e. was in country_development)
- monarch_power = <adm/mil/dip> #指定哪一项君主能力来获得进度加成,无此意则不写。
- scaled_modifier = { #可选的触发条件来为进度条增加动态修正,可以写好几个。
- trigger = <trigger> #触发条件
- modifier = <modifier> #修正
- start_value = <int> #可选,定义只因从何数值起,修正才开始作用。例如,设定为5,则进度为5以下这些修正为0%不作用。如果设定比end_value高,将功能类似于反向修正reverse_scaled_modifier
- end_value = <int> #可选,默认为100。决定上述修正能触发的封顶进度。例如,设定为90,则进度达到90,修正能100%加成,尽管超过进度90,修正也只能100%加成。如果设定比start_value低,将功能类似于反向修正reverse_scaled_modifier
- extend_beyond_value = <yes/no> #可选,默认为yes。决定修正能在start_value - end_value数值之外依旧有效。In other words if set to 'no', if the modifier goes 'outside' 100% (it's capped at 100% still), it will set it to 0%. This way you can create independent value ranges.
- }
- reverse_scaled_modifier = { #可选的触发条件来为进度条增加反向动态修正,可以写好几个。
- trigger = <trigger> #触发条件
- modifier = <modifier> #修正
- start_value = <int> #可选,默认为0
- end_value = <int> #可选,默认为100
- extend_beyond_value = <yes/no> #可选,默认为yes
- }
- range_modifier = { #optional country modifier that doesn't scale but is applied fully when in range.
- trigger = <trigger>
- modifier = <modifier>
- start_value = <int> #Optional, default is 0. Must be lower or equal to end_value
- end_value = <int> #Optional, default is 100. Must be bigger or equal to start_value
- }
- on_max_reached = <effect> #进度最大值能效果effect
- on_min_reached = <effect> #进度最小值能效果effect
- is_good = <yes/no> #这进度条....是可取的吗?is this power....desirable?
- }
- <government_power_type_id> = { #自定义进度条功能
- }
- powers = { #政府互动中的进度条功能
-
- #关于该进度条的修正生成:(仅供查阅,以下段落不需要写在文件里)
- #monthly_<government_power_type_id> = <float> #月度<government_power_type_id>进度增长
- #<government_power_type_id>_gain_modifier = <float> #Modifies the gain from the add_government_power effect
- #for each of these, you'll need to add a string for the generated modifier id and an icon.
-
- #关于进度条的效果生成:(仅供查阅,以下段落不需要写在文件里)
- #add_government_power = { #增加<government_power_type_id>进度
- #mechanic_type = <government_mechanic_id>
- #power_type = <government_power_type_id>
- #value = <float>
- #}
- #add_government_power_scaled_to_seats = { #增加根据席位数量加成的<government_power_type_id>进度
- #mechanic_type = <government_mechanic_id>
- #power_type = <government_power_type_id>
- #value = <float>
- #}
- #set_government_power = { #设置<government_power_type_id>为指定的数值
- #mechanic_type = <government_mechanic_id>
- #power_type = <government_power_type_id>
- #value = <float>
- #}
- #freeze_government_power = { #冻结<government_power_type_id>进度数值不变
- #mechanic_type = <government_mechanic_id>
- #power_type = <government_power_type_id>
- #}
- #unfreeze_government_power = { #取消冻结<government_power_type_id>进度数值不变
- #mechanic_type = <government_mechanic_id>
- #power_type = <government_power_type_id>
- #}
-
- #关于进度条的触发生成:(仅供查阅,以下段落不需要写在文件里)
- #has_government_power = { #返回真,如果该国有至少 X <government_power_type_id>进度数值
- #mechanic_type = <government_mechanic_id>
- #power_type = <government_power_type_id>
- #value = <float>
- #}
- #government_power_frozen = { #返回真,如果该国已冻结<government_power_type_id>进度数值
- #mechanic_type = <government_mechanic_id>
- #power_type = <government_power_type_id>
- #}
-
- interactions = { #政府互动,可以写任意数量
- <government_power_interaction_id> = { #自定义政府互动
- gui = <string> #link to the gui that will be used to display this power. By default, it will be government_interaction_type if not specified. New versions of this will need to contain the same elements so they can be filled in.
- icon = <gfx icon name> #Defines how the icon of the button should look like.
- cost_type = <progress_type_id> # which progress type we're spending (if any)
- cost = <int> #Defines how much progress you need to press the button. If pressed, it drains <int> amount of progress from the progress bar.
- trigger = { <country triggers> } #Defines the triggers needed for the button to be used. At default, it is empty which means there are no triggers greying the button out
- effect = { <country effects> } #Defines the effects happening when you press the button
- cooldown_years = <int> #Defines the cooldown years for this one button.
- cooldown_token = <any token> #defines the cooldown to use. If not specified, it will use the id of the action, so the cooldown will be unique to the action. This is useful if actions are to be mutually exclusive
- cooldown_desc = <string key> #defines the string to use for the name of the cooldown. If not specified, it will use the name of the interaction.
- ai_chance = <mtth> #mean time to happen, used to test to see how interested the AI is in doing this interaction
- }
- <government_power_interaction_id> = { #自定义政府互动
- }
- interactions = { #政府互动,可以写任意数量
- }
- 理论上,政府互动可以写任意数量,但需确认游戏中的界面GUI都能显示到哦
Government mechanics, as of game version 1.35, are fully scriptable in common/government_mechanics
. Some features, such as range modifiers and defining ranges for scaled modifiers was only added in 1.35.4.
A government mechanic must have a unique name and can include as many powers and interactions as wanted. Additionally a gov mechanic can include the following:
- a sprite type and frame within that sprite type used for the alert for being able to use an interaction
- a trigger for the mechanic to be available
Mechanics must be enabled in a government_abilities = { }
section in a government reform.
General Format
Definition
The general formatting looks like this:
<government_mechanic_name> = { alert_icon_gfx = <sprite_type_name> alert_icon_index = <integer> available = { # Triggers } powers = { # Powers } interactions = { # Interactions } }
Base Game Example Code
prussian_militarization_mechanic_1 = { alert_icon_gfx = GFX_alerticons_government_mechanics alert_icon_index = 10 available = { has_dlc = "Domination" tag = PRU NOT = { has_country_flag = enable_second_mil_level_flag } NOT = { has_country_flag = enable_third_mil_level_flag } } powers = { prussian_militarized_society_1 = { max = 100 scaled_modifier = { modifier = { discipline = 0.05 manpower_recovery_speed = 0.1 land_maintenance_modifier = -0.2 monthly_prussian_militarized_society_1 = -0.1 } } } } interactions = { boost_militarization = { gui = prussian_militarization_gov_mech_1_2 cost_type = prussian_militarized_society_1 center = no trigger = { mil_power = 50 not = { has_government_power = { mechanic_type = prussian_militarization_mechanic_1 power_type = prussian_militarized_society_1 value = 100 } } } effect = { add_government_power = { mechanic_type = prussian_militarization_mechanic_1 power_type = prussian_militarized_society_1 value = 10 } add_mil_power = -50 } cooldown_years = 0 ai_chance = { factor = 0 modifier = { factor = 10 not = { has_government_power = { mechanic_type = prussian_militarization_mechanic_1 power_type = prussian_militarized_society_1 value = 90 } } mil_power = 500 } } } } }
本地化
Every government mechanic's name has to be localized. The string is as follows:
ability_<government_mechanic_name>: "Name"
.
This localisation will be shown in the tooltip of the government reform that enables the mechanic, showing the text Enables <name> Ability
.
Alert icon
Definition
The alert icon sprite and frame are specified like this in the mechanic:
alert_icon_gfx = <sprite_type_name> alert_icon_index = <number>
Interface Definition
The sprite type can be defined in a .gfx
file in the interface
folder in the following way:
spriteTypes = { spriteType = { name = "GFX_alerticons_government_mechanics" texturefile = "gfx//interface//alerticons_government_mechanics.dds" noOfFrames = 17 loadType = "INGAME" alwaystransparent = yes } }
Available trigger
The trigger must be met for the mechanic to be available. Note that the mechanic still has to be enabled by a government reform! The triggers will only be checked when picking a government reform. Also note that even if the trigger of the mechanic is not met, the tooltip of the reform will still say that it enables the mechanic.
available = { # Triggers Here }
Powers
Definition
The powers section can have as many powers as you want. Powers follow this formatting:
powers = { <government_power_name> = { gui = <string> # refers to a windowType in a .gui file in the interface folder [optional] min = <integer> # defines the minimum value of the power (left side of the progressbar) [optional, 0 by default] max = <integer> # defines the maximum value of the power (right side of the progressbar) default = <integer> # defines the start value as well as the reset value for the rule to reset on new ruler [optional, 0 by default] reset_on_new_ruler = <yes/no> # sets whether the power value gets reset whenever a new ruler is chosen [optional, no is default] base_monthly_growth = <float> # defines the base monthly change of the power [optional, 0 by default] development_scaled_monthly_growth = <float> # defines a monthly change of the power based on the total development of the country [optional, 0 by default] monarch_power = <adm/mil/dip> # defines whether there is a power gain from one of the three ruler stats [optional] show_before_interactions = <yes/no> # defines whether the power bar will show above or below the interactions in the interface [optional, no is default] # scaled modifier works the following way: # modifiers * (distance between current value and end_value)/100 [e.g. if current value is -50 and end_value is -100, this value here is 50] # you can have as many scaled modifier sections as you want # [optional] scaled_modifier = { start_value = <float> # sets the start value for the scaling [optional, min is default] end_value = <float> # sets the end value for the scaling [optional, max is default] extend_beyond_value = <yes/no> # defines whether the scaled modifier also applies outside of the range (but then with its max/min value for the range defined) [optional, yes is default] trigger = { # Triggers Here } modifier = { # Modifiers Here } } # reverse scaled modifier works the following way: # modifiers * (distance between current value and end_value)/100 [e.g. if current value is -50 and end_value is 0, this value here is 50] # you can have as many reverse scaled modifier sections as you want # [optional] reverse_scaled_modifier = { start_value = <float> # sets the start value for the scaling [optional, min is default] end_value = <float> # sets the end value for the scaling [optional, max is default] extend_beyond_value = <yes/no> # defines whether the scaled modifier also applies outside of the range (but then with its max/min value for the range defined) [optional, yes is default] trigger = { # Triggers Here } modifier = { # Modifiers Here } } # range modifier is applied in the specified range and when the triggers are met, in constrast to scaled and reverse scaled modifier range modifier is applied as defined, there is no scaling applied # you can have as many range modifier sections as you want # [optional] range_modifier = { start_value = <float> # sets the value where the modifier starts to apply [optional, min is default] end_value = <float> # sets the value where the modifier stops to apply [optional, max is default] trigger = { # Triggers Here } modifier = { # Modifiers Here } } # on max reach is an effect section that is executed when the power reaches the max value [optional] on_max_reached = { # Effects Here } # on min reach is an effect section that is executed when the power reaches the max value [optional] on_min_reached = { # Effects Here } is_good = <yes/no> # defines whether power gain modifiers are displayed in green or red [optional, yes is default] } }
The value you use for development_scaled_monthly_growth
is multiplied by the country's Development divided by 600
[1].
Modifiers
For each power the game creates two modifiers that can be used in any country and province (applying to the owner) modifier section:
monthly_<government_power_name> # additive, adds to the monthly change of the power <government_power_name>_gain_modifier # multiplicative, affects effects that add power
You have to add localisation as well as an icon for each. The localisation strings and icon names are the same as the modifier names. The icons must be put into the gfx/interface/ideas_EU4
folder.
本地化
Each power has two localisation strings, the name and the description:
<government_power_name>: "Name" <government_power_name>_desc: "Description"
The description can use customizable localization and localisation bracket commands to be more dynamic.
Usage in Triggers
There are two triggers associated with government powers. To check if a country has a specified amount of power, the following trigger is used:
has_government_power = { mechanic_type = <government_mechanic_name> power_type = <government_power_name> value = <float> }
To check if a country has a specified power frozen, the following trigger is used:
government_power_frozen = { mechanic_type = <government_mechanic_name> power_type = <government_power_name> }
Usage in Effects
There are five effects associated with government powers. To affect the power value, the following effects can be used:
add_government_power = { # adds the specified amount of power mechanic_type = <government_mechanic_name> power_type = <government_power_name> value = <float> } add_government_power_scaled_to_seats = { # adds the specified amount of power scaled to the amount of parliament seats the country has mechanic_type = <government_mechanic_name> power_type = <government_power_name> value = <float> } set_government_power = { # sets the power to the specified amount mechanic_type = <government_mechanic_name> power_type = <government_power_name> value = <float> }
To freeze - meaning the power cannot be changed anymore, neither by effects nor monthly modifiers nor reset on ruler - or unfreeze a power, the following effects can be used:
freeze_government_power = { mechanic_type = <government_mechanic_name> power_type = <government_power_name> } unfreeze_government_power = { mechanic_type = <government_mechanic_name> power_type = <government_power_name> }
互动
定义
There can be as many interactions as you want inside the interactions section. Interactions follow this format:
interactions = { <government_mechanic_interaction_name> = { gui = <string> # refers to a windowType in a .gui file in the interface folder [optional] center = <yes/no> # defines where the button's gui's starting position is (which then is further changed by the position of the element inside the gui) [optional, yes is default] icon = <sprite_type_name> # defines the sprite type to use for the button icon [optional, the sprite defined in the gui is used by default] cost_type = <government_power_name> # defines which power should be used as cost [optional] cost = <integer> # how much of the specified power is needed to use the interaction, when the interaction is used this much of the specified power is removed [optional] # the triggers that must be met to be able to see the button [optional] # even if not visible it will still occupy its space in the ui, meaning the ui will behave the same way whether the button is visible or not potential = { # Triggers Here } # the triggers that must be met to be able to click the button [optional] trigger = { # Triggers Here } # the effects that are executed when clicking the button effect = { # Effects Here } cooldown_years = <integer> # defines the cooldown of the interaction in years [optional] cooldown_token = <string> # defines a token to use for the cooldown, used if you want multiple actions to share a cooldown [optional, by default each action will have its own cooldown] cooldown_desc = <string> # defines a loc string that will be inserted at the start of the tooltip for the cooldown [optional] ai_chance = { factor = <float> modifier = { factor = <float> # Triggers Here } # ... } } }
本地化
Each interaction has two localisation strings, the name and the description:
<government_mechanic_interaction>: "Name" <government_mechanic_interaction>_desc: "Description"
GUI Set Up
General Information
While specifying a gui container for the powers and interactions is optional, doing so will allow for much more customization. The gui code would be done within a .gui
file in the interface
folder (and possibly within a subfolder inside it, e.g. government_mechanics
).
Whether you can assign a gui to a power depends on how your interactions are set up. Under the following circumstances you can assign a gui to a power:
- no interactions exist
- no interaction uses the power as
cost_type
- at least two interactions use the power as
cost_type
Should those not be the case, the power itself will not be able to get a gui assigned. Instead the gui assigned to the interaction will also include the gui elements for the power.
While those three gui elements must be present in their respective windowType
, you can add additional ones freely, such as additional icons or texts. Note however that these cannot be dynamic, but can be used to display fixed text etc. Since you can assign a different gui per interaction, this allows you to have different button texts, for example.
The size
attribute of the windowTypes
defines two things:
- how much space you have until elements inside are cut off
- positioning of later elements
For 2. this means that the starting position of the second interaction is defined by the size
of the windowType
used by the first. So e.g. if the size
uses an x
value of 100, then the second interaction button will be 100px to the right of the first. The y
value defines the vertical offset. This also applies to the starting positions of the powers.
Note that there will always be three buttons in a row. You cannot have a new row start after fewer or more!
Combined GUI for Power and Interaction
For a case where the power and interaction use a combined gui, the windowType
would have to include all three required gui elements:
guiTypes = { windowType = { name = "prussian_militarization_gov_mech_1_2" size = { x = 300 y = 82 } moveable = 0 # bar and frame for the power type associated with this interaction (if it's unique to the interaction - if not, these will be hidden) iconType = { name = "government_power_bar" spriteType = "GFX_prussian_militarization_power_bar" position = { x = 16 y = 49 } } # Frame iconType = { name = "government_power_bar_frame" spriteType = "GFX_prussian_militarization_frame" position = { x = 0 y = 0 } alwaystransparent = yes } ### interaction button guiButtonType = { name = "government_interaction_button" quadTextureSprite = "GFX_prussian_militarization_upgrade" position = { x = 10 y = 5 } buttonFont = "vic_18" clicksound = back_click } } }
The name of the windowType
can be chosen freely and is used for the gui attribute in the government mechanic file. The names of the two iconTypes as well as the guiButtonType
must be as shown above. They are linked to hardcoded functions that apply the right interaction and power to them.
Individual GUI for Power
In the case of having an individual gui for a power, this would only include the two iconTypes
and not the guiButtonType
.
guiTypes = { windowType = { name = "prussian_militarization_gov_mech_3_power" size = { x = 300 y = 72 } moveable = 0 # background / the eagle iconType = { name = "government_power_bar" spriteType = "GFX_prussian_militarization_power_bar" position = { x = 16 y = 49 } } # Frame iconType = { name = "government_power_bar_frame" spriteType = "GFX_prussian_militarization_frame" position = { x = 0 y = 0 } alwaystransparent = yes } } }
Individual GUI for Interaction
In the case of having an individual gui for an interaction, this would only include the guiButtonType
.
guiTypes = { windowType = { name = "prussian_militarization_gov_mech_3_interaction" size = { x = 100 y = 50 } moveable = 0 # Interaction button, graphics replaced from the interaction icon specification guiButtonType = { name = "government_interaction_button" quadTextureSprite = "GFX_russian_ability_ADM" buttonFont = "vic_18" clicksound = back_click } } }
Sprite Types for Progressbars
Should you consider making a gui for a power, you may want to have a unique looking progress bar. The sprite type for a progressbar is defined like this:
spriteTypes = { progressbartype = { name = "GFX_prussian_militarization_power_bar" color = { 1.0 0.0 0.0 } colortwo = { 1.0 1.0 1.0 } textureFile1 = "gfx/interface/government_mechanics/prussian_militarization/prussian_progress_bar.dds" textureFile2 = "gfx/interface/government_mechanics/prussian_militarization/prussian_progress_bar_empty.dds" size = { x = 260 y = 20 } effectFile = "gfx/FX/progress.lua" } }
The name
is used for the sprite type in the gui icon, the two textureFiles
define the bar and its background texture. The size
defines the size in the ui and thus also how many pixel of the bar each percent of progress is. This size
should generally be kept the same as the actual image size.
参考
文档 | 效果指令 • 触发条件 • 修正 • 作用域 • 变量 • 本地化 • 可定制的本地化 |
脚本 | 顾问 • 时代 • 书签 • 建筑 • 宣战理由 • 殖民区域 • 新建国家 • 文化 • 决议 • 定义 • 外交行动 • 灾难 • 阶层• 事件 • 派系 • 政府 • 政府互动(1.35) • 伟大工程 • 历史 • 理念组 • 思潮 • 任务树 • 修正 • 自定义国家 • 政策 • 宗教 • 叛军 • 附属国类型 • 科技 • 贸易公司 • 商品 • 单位 • 旗舰 |
地图 | 地图 • 随机新世界 • 贸易节点 |
图形 | 3D模型 • 界面 • 贴图库 • 字体 • 粒子特效 • 着色器 • 兵模 |
音频 | 音乐 • 音效 |
其它 | 控制台指令 • 校验码 • JoroDox模组制作工具 • Mod文件结构 • Mod错误调试 • 验证器 • 运行文件 |
教程 | 添加省份 • 成就修改 • On actions • 模组制作 |