Building modding:修订间差异

本页面所适用的版本可能已经过时,最后更新于1.11
(汉化)
无编辑摘要
 
(未显示同一用户的1个中间版本)
第1行: 第1行:
建筑物是使用省份的民用工厂建造的结构。
{{Version|1.11}}
{{需要翻译|译者=霜泽图书馆}}
A building is a structure built using Civilian factories in states or provinces.


== 建筑物 ==
== Buildings ==
{{SVersion|1.8}}
Buildings are defined within {{path|common/buildings/*.txt}}. Each building entry lies within the <code>buildings = { ... }</code> block, serving as its own block with arguments within defining the building, as this:
以下是一个通用建筑示例:
<pre>buildings = {
   my_building = {
     <...>
   }
}</pre>
 
=== Cost ===
Each building has a set price in industrial capacity required. This cost is defined with the lines of <code>base_cost = 1000</code> and <code>per_level_extra_cost = 100</code>.
 
base_cost is the primary cost to build the building, added to each building level, while per_level_extra_cost gets added for each building level in an arithmetic progression. With the example of 1000 base_cost and 100 per_level_extra_cost, the first level will cost 1000 IC to build, while the 5th level will cost 1400 IC, as 4 levels have been built before that.
 
By default, each civilian factory provides 5 IC per day<ref>BASE_FACTORY_SPEED &#61; 5 in common/defines/00_defines.lua</ref>, which can be taken into account when calculating the cost. For comparison, by default a civilian factory costs 10800 IC, while infrastructure costs 6000 IC.
 
Additionally, <code>infrastructure_construction_effect = yes</code>, if included, will make the building get the building speed boost from any infrastructure built in the state, with a +20% boost per infastructure level<ref>INFRA_MAX_CONSTRUCTION_COST_EFFECT &#61; 1 in common/defines/00_defines.lua means a +100% speed bonus for max infrastructure. By default, infrastructure has 5 max levels, making the boost be divided into 5 portions of 20%, depending on the building level.</ref>.
 
=== Used slots ===
In general, buildings fall into 3 categories by used building slots:
* Shared, which use the same, by default, 25 shared slots<ref>MAX_SHARED_SLOTS &#61; 25 in common/defines/00_defines.lua</ref> for each state, such as civilian and military factories.
* Non-shared, defined for states, but using slots that are unique for this building in particular, such as infrastructure or air bases.
* Provincial, which get built for each province, using slots that are unique for this building in particular, such as forts or naval bases.
If not specified otherwise, a building is assumed to be non-shared. The 3 categories have separate zones in the country construction view where they are located.<br/>
<code>provincial = yes</code>, if added, will make the building be considered provincial, while <code>shares_slots = yes</code> will make it be considered shared if added. These cannot be combined.


<pre>
Adding <code>max_level = 10</code> can set a max level to which this building can be built. If it is unspecified, it gets assumed to be 15<ref>MAX_BUILDING_LEVELS &#61; 15 in common/defines/00_defines.lua</ref> by default.
<building> = {
 
   base_cost = <int>        # 建设成本。
By default, all levels of the building are unlocked by default. However, if there are [[Technology modding|technologies]] that enable construction of this building to a specified level, it becomes impossible to build without obtaining at least one of these technologies. It is to be noted that the [[effect|add_building_construction effect]] or the [[state modding|starting state buildings]] can still be used to bypass the technological limit, while still not being possible to bypass the max level total.
   base_cost_conversion = <int>   # 要转换为该建筑的成本
   per_level_extra_cost = <int>   # 每次升级建筑的成本。
  
   max_level = <int>        # 建筑的最大等级
   value = <int>          # 建筑物的基本完好状态。根据所建建筑的等级。
 
   icon_frame = <int>        # GFX_buildings_strip中的建筑图标。
   show_on_map = <int>       # 当建造了一个建筑时要在地图上显示的<building>模型数量
   show_on_map_meshes = <int>    # 要显示的型号数。
   always_shown = yes        # 是否始终显示<building>模型。
   has_destroyed_mesh = yes     # 是否显示建筑的破坏
  
   shares_slots = yes              # 确定此建筑是否使用建筑槽。
   infrastructure_construction_effect = yes   # 确定此建筑是否受益于提高施工速度的基础设施。
   provincial = yes               # 确定此建筑是否为省级建筑。
   damage_factor = <float>           # 修改轰炸造成的伤害。
  
   only_costal = yes        # 将此建筑仅限于沿海省份/ 州。
   disabled_in_dmz = yes      # 限制此建筑,在DMZ省份下禁用。
  
   infrastructure = yes       # 确定是否将此建筑视为基础设施。
   air_base = yes          # 确定此建筑是否被视为空军基地
   is_port = yes          # 确定是否将此建筑视为港口。
   anti_air = yes          # 确定是否将此建筑视为防空装置。
   refinery = yes          # 确定此建筑是否被视为炼油厂。
   radar = yes           # 确定此建筑是否被视为雷达站。
   nuclear_reactor = yes      # 确定该建筑是否被视为核反应堆。
   military_production = <float>   # Adds X amount of MIC production.
   general_production = <float>   # Adds X amount of CIC production.
   naval_production = <float>    # Adds X amount of NIC production.
   land_fort = <int>        # Adds X amount of land fort.
   naval_fort = <int>        # Adds X amount of naval fort.
   rocket_production = <int>    # Adds X amount of rocket production.
   rocket_launch_capacity = <int>  # Adds X amount of rocket capacity.
   local_resources_<resource> = <int>  # Adds resources to state.
   air_defence = <float>        # Adds air defence to the state.
   nuclear_production_factor = <float> # Adds Nuke production factor to owner of state.
}
</pre>


有关游戏内[[Construction| 建筑]]请参阅[[Construction| 建筑]]
=== Additional arguments ===
<code>value = 3</code> decides the base health of a building for air bombing campaigns, which gets multiplied for each level of the building. Additionally, this also determines the price of the state to get during peace conferences or the cost in {{icon|political power|1}} to occupy.


== 本地化 ==
<code>damage_factor = 0.3</code> modifies the damage that this building gets from air bombing or land combat. Positive values increase it, while negatives decrease it.
{{SVersion|1.8}}
建筑遵循以下本地化


<pre>
<code>allied_build = yes</code>, if specified, makes the building count as an allied building, making its modifiers apply not just on the country that built it, but also its allies (i.e. subjects, overlord, and/or faction members).
<building>: ""
<building>_desc: ""
<building>_plural: ""
modifier_production_speed_<building>: ""
modifier_production_speed_<building>_desc: ""
modifier_production_speed_<building>_factor: ""
modifier_production_speed_<building>_factor_desc: ""
</pre>


== 界面 ==
<code>only_costal = yes</code> {{hover|Quoted exactly as written|(sic)}}, if specified, will make the building only be possible to build in either provinces that are [[Map modding#Province map|defined as coastal]] or states that contain any such provinces, depending on the type of the building.
{{SVersion|1.8}}
如果添加了新建筑,则需要更新建筑图标栏以包含该建筑的图标。此文件位于{{path|gfx/interface/buildings/building_icon_strip.dds}}.


图标本身需要46像素宽和高。它应该被附加到建筑图标条上,并且'''noOfFrames'''应该被更改以匹配新的图标数量。
<code>disabled_in_dmz = yes</code>, if added, will make the building impossible to build or use in states that are demilitarised zones.


以下是建筑图标的GFX定义文件 {{path|interface/countrystateview.gfx}}:
=== Icon ===
{{SVersion|1.11}}
The building icon is defined as <code>icon_frame = 10</code>. The integer shows which frame within the GFX_buildings_strip sprite gets used for this building.


By default, GFX_buildings_strip is defined within {{path|interface/countrystateview.gfx}}, however, it can be overwritten in any {{path|interface/*.gfx}} which is positioned later by filename order:
<pre>
<pre>
spriteType = {
spriteType = {
    name = "GFX_buildings_strip"
    name = "GFX_buildings_strip"
    textureFile = "gfx/interface/buildings/building_icon_strip.dds"
    textureFile = "gfx/interface/buildings/building_icon_strip.dds"
    noOfFrames = 14 # 每改造一栋建筑增加1
    noOfFrames = 16   # As of 1.11
}
}
</pre>
</pre>
The noOfFrames decides in how many frames the specified sprite is divided into, dividing the image horizontally into chunks of approximately equal width. If planning to add a new building icon rather than using a base game one, the building icon strip will need to be updated both in the noOfFrames and in the .dds file. By default, each building has a 46x46 resolution in pixels.
Within the building construction menu, buildings are divided into 3 zones depending on their used building slots category. In order to change where they are to adjust for new or missing buildings, the elements within the possible_constructions container in {{path|interface/countryconstructionsview.gui}} can have their positions changed.
=== Models ===
{{Main|Entity modding}}
There are several arguments related to models within buildings.<br/>
<code>show_on_map = 3</code> decides how many building models should there be per state or per province (depending on the building type) defined for the building. Each building construction will add one more model. If unspecified, will have no map models.<br/>
<code>show_on_map_meshes = 2</code> decides how many entities are used for each building model. By default assumed to be 1.<br/>
<code>always_shown = yes</code>, if specified, will make the building model appear regardless whether it's covered by the fog of war or not.<br/>
<code>has_destroyed_mesh = yes</code>, if specified, will make the game use a separate model if the building has been destroyed by air bombing or occupation.<br/>
<code>centered = yes</code>, if specified, will mak
In order to assign an entity to a building, it must have a name of <code>building_<building name></code>, like <code>building_my_building</code>, within the {{path|gfx/entities/*.asset}} file. If a building is set to use several entities, then the number will get appended in the end like <code>building_my_building_1</code>, starting with 1. If there's a destroyed mesh, then it'll append _destroyed in the end as <code>building_my_building_destroyed</code>


== 建筑类型 ==
The locations of building models for each state are defined in {{path|map/buildings.txt}}. An entry in that file is defined as such (If unspecified, assume a number with up to 2 decimal digits):
{{SVersion|1.9}}以下是自1.9.0起游戏中不同类型的建筑(可以在{{path|common/buildings/00_buildings.txt}} 找到):<pre>
<pre>State ID (integer); building ID (string); X position; Y position; Z position; Rotation; Adjacent sea province (integer)</pre>
buildings = {
*State ID defines which state the building is located in. Even for provincial buildings, this is the ID of the state, not the province. Instead, provincial buildings have several entries per state, with the XYZ position being used by the game to know which province it's for.
   # STATE BUILDINGS
*Building ID is defines which model is being located. While this includes each building, this also includes floating harbours as floating_harbor.
   infrastructure   = <int> # 0 to 10 | Sets the Infrastructure level.      (STATE)
*X, Y, and Z position represent the position on the map of the building model using the 3-dimensional Cartesian coordinate system. The X and Z positions are equivalent to the X and Y axes on the {{hover|map/provinces.bmp|province bitmap}} with 1 pixel equalling 1 unit, left-to-right and down-to-up respectively. This is also what the game uses to know which province it's for for provincial buildings. The Y position, on the scale of 0 to 25.5, can be calculated with the {{hover|map/heightmap.bmp|heightmap}} by taking the [[wp:Lightness|colour value]] of the pixel at that position and making it fit on the scale of 0 to 25.5 (Such as by dividing it by 10 if it's on the scale of 0 to 255).
   air_base      = <int> # 0 to 10 | Sets the Air Base level.         (STATE)
*Rotation is measured in radians. A rotation of 0 will result in the building model pointing in the same direction as the model is set, while positives will rotate it counter-clockwise and negatives will rotate it clockwise. A full rotation resulting in the same position as 0 is equal to the number π multiplied by 2, roughly 6.28.
   anti_air_building  = <int> # 0 to 5 | Sets the Anti-Air level.         (STATE)
*Adjacent sea province is only necessary to define for naval bases and floating harbours, in order to let the game know from which sea province ships or convoys can access the land province where it is located. If the building type is not a naval base, it should be left at 0.
   radar_station    = <int> # 0 to | Sets the Radar Station level.       (STATE)
It is preferable to generate the building models in the building section in the nudger, rather than filling it out manually. However, note that the game will crash if the currently-existing {{path|map/buildings.txt}} file is entirely empty, so there should be at least one definition, even if incorrect.


   # SHARED BUILDINGS
=== Effects ===
   arms_factory    = <int> # 0 to 20 | Sets the Military Factory level.     (STATE)
{{SVersion|1.11}}
   industrial_complex = <int> # 0 to 20 | Sets the Civilian Factory level.     (STATE)
Each building can accept any [[Modifiers#State_scope|state-scoped modifier]] within itself, applying that to the state when built. Some used in base game include <code>local_resources_<resource></code>, <code>air_defence</code> (for anti-air), and <code>nuclear_production_factor</code> (for nuclear reactors). In case of provincial buildings, province-level modifiers are accepted instead. This can also be used with [[Modifiers#Modifier tokens|modifier tokens]] to create a custom effect as a variable system. Adding <code>show_modifier = yes</code> will make the modifiers show up in the tooltip of the building.
   dockyard      = <int> # 0 to 20 | Sets the Naval Dockyard level.      (STATE)
   synthetic_refinery = <int> # 0 to 3  | Sets the Synthetic Refinery level.    (STATE)
   fuel_silo      = <int> # 0 to ∞  | Sets the Fuel Silo level.         (STATE)
   rocket_site     = <int> # 0 to 5  | Sets the Rocket Site level.       (STATE)
   nuclear_reactor   = <int> # 0 to 1  | Sets the Nuclear Reactor level.      (STATE)  


   # PROVINCE BUILDINGS
Aside from state-scoped modifiers, there are several other arguments to make the building have the same effect as a base game building or be considered one for the AI:
   <province id> = {
{| class="wikitable sortable" width="100%"
     naval_base   = <int> # 0 to 10 | Sets the Naval Base level.        (PROVINCE)
! width="10%" | Name
     bunker     = <int> # 0 to 10 | Sets the Land Fort level.         (PROVINCE)
! width="25%" | Effects
     coastal_bunker = <int> # 0 to 10 | Sets the Coastal Fort level.       (PROVINCE)
! width="25%" | Examples
! width="20%" | Type
! width="20%" | Notes
|-
|military_production
|Adds the specified amount of military factories to the controller.
|<pre>military_production = 0.5</pre>
|Flat.
|A value that's larger than 1 will be the same as 1 factory, but it can fall between 0 and 1.
|-
|general_production
|Adds the specified amount of civilian factories to the controller.
|<pre>general_production = 0.5</pre>
|Flat.
|A value that's larger than 1 will be the same as 1 factory, but it can fall between 0 and 1.
|-
|naval_production
|Adds the specified amount of dockyards to the controller.
|<pre>naval_production = 0.5</pre>
|Flat.
|A value that's larger than 1 will be the same as 1 factory, but it can fall between 0 and 1.
|-
|infrastructure
|Makes the building be marked as infrastructure.
|<pre>infrastructure = yes</pre>
|Boolean.
|Includes the construction speed bonus and extra resources.
|-
|air_base
|Makes the building be marked as an air base.
|<pre>air_base = yes</pre>
|Boolean.
|
|-
|supply_node
|Makes the building be marked as a supply node.
|<pre>supply_node = yes</pre>
|Boolean.
|
|-
|is_port
|Makes the building be marked as a naval port.
|<pre>is_port = yes</pre>
|Boolean.
|
|-
|land_fort
|Adds that many land forts to the province.
|<pre>land_fort = 1</pre>
|Flat.
|
|-
|naval_fort
|Adds that many coastal forts to the province.
|<pre>naval_fort = 1</pre>
|Flat.
|
|-
|refinery
|Makes the building be marked as a synthetic refinery.
|<pre>refinery = yes</pre>
|Boolean.
|
|-
|fuel_silo
|Makes the building be marked as a fuel silo.
|<pre>fuel_silo = yes</pre>
|Boolean.
|
|-
|radar
|Makes the building be marked as a radar station.
|<pre>radar = yes</pre>
|Boolean.
|
|-
|rocket_production
|Defines how much progress on rocket production is done daily.
|<pre>rocket_production = 5</pre>
|Flat.
|
|-
|rocket_launch_capacity
|Defines how many rockets the build can launch daily.
|<pre>rocket_launch_capacity = 5</pre>
|Flat.
|
|-
|nuclear_reactor
|Makes the building be marked as a nuclear reactor.
|<pre>nuclear_reactor = yes</pre>
|Boolean.
|
|}
=== Example ===
<pre>buildings = {
   my_provincial_building = {
     base_cost = 10000
     infrastructure_construction_effect = yes
    
     provincial = yes
     max_level = 3
    
     value = 1
    
     icon_frame = 17
    
     show_on_map = 1
     always_shown = yes
    
     army_attack_factor = 0.1
     army_defence_factor = 0.3
   }
   my_shared_building = {
     base_cost = 1000
     per_level_extra_cost = 200
     infrastructure_construction_effect = yes
    
     shares_slots = yes  # Max level of 15 since undefined
    
     value = 15
     only_costal = yes
    
     icon_frame = 18
    
     show_on_map = 3
     show_on_map_meshes = 3
     has_destroyed_mesh = yes
    
     military_production = 1
     general_production = 1
     naval_production = 1
    }
    }
}
   my_non_shared_building = {
     base_cost = 1000
     per_level_extra_cost = 2000
    
     max_level = 2
    
     value = 5
    
     icon_frame = 19   # No model is defined
    
     recruitable_population_factor = 0.5
   }
}</pre>
== Localization ==
{{SVersion|1.11}}
Buildings use the following localization keys, using my_building as an example:
<pre>
my_building: "My building"
my_building_desc: "My building's description"
my_building_plural: "My buildings"
modifier_production_speed_my_building_factor: "§Y$my_building$§! construction speed"
modifier_production_speed_my_building_factor_desc: "Modifies the speed of §Y$my_building$§! construction."
modifier_state_production_my_building_factor:0 "§Y$my_building$§! construction speed"
modifier_state_production_my_building_factor_desc:0 "Modifies the speed of §Y$my_building$§! construction in this state."
</pre>
</pre>
请注意,目前,工厂的产能似乎为20,而之前的产能是无限的(只要是整数)。
The first 3 are used for the building itself in various UI elements, while the last 4 are used to localise the modifiers automatically created for each building: <code>production_speed_<building>_factor</code> and <code>state_production_speed_<building>_factor</code>.
== Types ==
{{SVersion|1.12}}
These are the different types of buildings in the game as of 1.11 (Can also be found inside {{path|common/buildings/00_buildings.txt}}):
{| class = "wikitable sortable"
! class="unsortable" | Icon !! Localised name !! Internal name !! Maximum level !! Type
|- id="infrastructure"
| [[File:Infrastructure.png]]
| Infrastructure
| infrastructure
| 5
| Non-shared
|- id="arms_factory"
| [[File:Military factory.png]]
| Military factory
| arms_factory
| 20
| Shared
|- id="industrial_complex"
| [[File:Civilian factory.png]]
| Civilian factory
| industrial_complex
| 20
| Shared
|- id="air_base"
| [[File:Air base.png]]
| Air base
| air_base
| 10
| Non-shared
|- id="supply_node"
| [[File:Supply hub.png]]
| Supply hub
| supply_node
| 1
| Provincial
|- id="rail_way"
| [[File:Railway.png]]
| Railway
| rail_way
| {{hover|MAX_RAILWAY_LEVEL &#61; 5 in common/defines/00_defines.lua|5}}
| Provincial
|- id="naval_base"
| [[File:Naval base.png]]
| Naval base
| naval_base
| 10
| Provincial
|- id="bunker"
| [[File:Land fort.png]]
| Land fort
| bunker
| 10
| Provincial
|- id="coastal_bunker"
| [[File:Coastal fort.png]]
| Coastal fort
| coastal_bunker
| 10
| Provincial
|- id="dockyard"
| [[File:Naval dockyard.png]]
| Naval dockyard
| dockyard
| 20
| Shared
|- id="anti_air_building"
| [[File:Anti-air (building).png]]
| Anti-air
| anti_air_building
| 5
| Non-shared
|- id="synthetic_refinery"
| [[File:Synthetic refinery.png]]
| Synthetic refinery
| synthetic_refinery
| 3
| Shared
|- id="fuel_silo"
| [[File:Fuel silo.png]]
| Fuel silo
| fuel_silo
| 15
| Shared
|- id="radar_station"
| [[File:Radar station.png]]
| Radar station
| radar_station
| 6
| Non-shared
|- id="rocket_site"
| [[File:Rocket site.png]]
| Rocket site
| rocket_site
| 2
| Non-shared
|- id="nuclear_reactor"
| [[File:Nuclear reactor.png]]
| Nuclear reactor
| nuclear_reactor
| 1
| Non-shared
|}
Note that while railways and supply nodes are buildings, not all traditional building operations apply to them. Their starting level is defined [[Map_modding#Supply_nodes_and_railways|outside of state history]] and [[Effect#build_railway|a separate effect]] must be used to construct railways mid-game, with the default [[Effect#add_building_construction|add_building_construction]] or other building-related effects crashing the game.
 
== References ==
<references />
{{Modding navbox}}
{{Modding navbox}}
[[分类:Modding]]
[[分类:Modding]]

2024年8月10日 (六) 02:01的最新版本

A building is a structure built using Civilian factories in states or provinces.

Buildings

Buildings are defined within /Hearts of Iron IV/common/buildings/*.txt. Each building entry lies within the buildings = { ... } block, serving as its own block with arguments within defining the building, as this:

buildings = {
    my_building = {
        <...>
    }
}

Cost

Each building has a set price in industrial capacity required. This cost is defined with the lines of base_cost = 1000 and per_level_extra_cost = 100.

base_cost is the primary cost to build the building, added to each building level, while per_level_extra_cost gets added for each building level in an arithmetic progression. With the example of 1000 base_cost and 100 per_level_extra_cost, the first level will cost 1000 IC to build, while the 5th level will cost 1400 IC, as 4 levels have been built before that.

By default, each civilian factory provides 5 IC per day[1], which can be taken into account when calculating the cost. For comparison, by default a civilian factory costs 10800 IC, while infrastructure costs 6000 IC.

Additionally, infrastructure_construction_effect = yes, if included, will make the building get the building speed boost from any infrastructure built in the state, with a +20% boost per infastructure level[2].

Used slots

In general, buildings fall into 3 categories by used building slots:

  • Shared, which use the same, by default, 25 shared slots[3] for each state, such as civilian and military factories.
  • Non-shared, defined for states, but using slots that are unique for this building in particular, such as infrastructure or air bases.
  • Provincial, which get built for each province, using slots that are unique for this building in particular, such as forts or naval bases.

If not specified otherwise, a building is assumed to be non-shared. The 3 categories have separate zones in the country construction view where they are located.
provincial = yes, if added, will make the building be considered provincial, while shares_slots = yes will make it be considered shared if added. These cannot be combined.

Adding max_level = 10 can set a max level to which this building can be built. If it is unspecified, it gets assumed to be 15[4] by default.

By default, all levels of the building are unlocked by default. However, if there are technologies that enable construction of this building to a specified level, it becomes impossible to build without obtaining at least one of these technologies. It is to be noted that the add_building_construction effect or the starting state buildings can still be used to bypass the technological limit, while still not being possible to bypass the max level total.

Additional arguments

value = 3 decides the base health of a building for air bombing campaigns, which gets multiplied for each level of the building. Additionally, this also determines the price of the state to get during peace conferences or the cost in 政治点数政治点数 to occupy.

damage_factor = 0.3 modifies the damage that this building gets from air bombing or land combat. Positive values increase it, while negatives decrease it.

allied_build = yes, if specified, makes the building count as an allied building, making its modifiers apply not just on the country that built it, but also its allies (i.e. subjects, overlord, and/or faction members).

only_costal = yes (sic), if specified, will make the building only be possible to build in either provinces that are defined as coastal or states that contain any such provinces, depending on the type of the building.

disabled_in_dmz = yes, if added, will make the building impossible to build or use in states that are demilitarised zones.

Icon

The building icon is defined as icon_frame = 10. The integer shows which frame within the GFX_buildings_strip sprite gets used for this building.

By default, GFX_buildings_strip is defined within /Hearts of Iron IV/interface/countrystateview.gfx, however, it can be overwritten in any /Hearts of Iron IV/interface/*.gfx which is positioned later by filename order:

spriteType = {
    name = "GFX_buildings_strip"
    textureFile = "gfx/interface/buildings/building_icon_strip.dds"
    noOfFrames = 16     # As of 1.11
}

The noOfFrames decides in how many frames the specified sprite is divided into, dividing the image horizontally into chunks of approximately equal width. If planning to add a new building icon rather than using a base game one, the building icon strip will need to be updated both in the noOfFrames and in the .dds file. By default, each building has a 46x46 resolution in pixels.

Within the building construction menu, buildings are divided into 3 zones depending on their used building slots category. In order to change where they are to adjust for new or missing buildings, the elements within the possible_constructions container in /Hearts of Iron IV/interface/countryconstructionsview.gui can have their positions changed.

Models

主条目:Entity modding

There are several arguments related to models within buildings.
show_on_map = 3 decides how many building models should there be per state or per province (depending on the building type) defined for the building. Each building construction will add one more model. If unspecified, will have no map models.
show_on_map_meshes = 2 decides how many entities are used for each building model. By default assumed to be 1.
always_shown = yes, if specified, will make the building model appear regardless whether it's covered by the fog of war or not.
has_destroyed_mesh = yes, if specified, will make the game use a separate model if the building has been destroyed by air bombing or occupation.
centered = yes, if specified, will mak

In order to assign an entity to a building, it must have a name of building_<building name>, like building_my_building, within the /Hearts of Iron IV/gfx/entities/*.asset file. If a building is set to use several entities, then the number will get appended in the end like building_my_building_1, starting with 1. If there's a destroyed mesh, then it'll append _destroyed in the end as building_my_building_destroyed

The locations of building models for each state are defined in /Hearts of Iron IV/map/buildings.txt. An entry in that file is defined as such (If unspecified, assume a number with up to 2 decimal digits):

State ID (integer); building ID (string); X position; Y position; Z position; Rotation; Adjacent sea province (integer)
  • State ID defines which state the building is located in. Even for provincial buildings, this is the ID of the state, not the province. Instead, provincial buildings have several entries per state, with the XYZ position being used by the game to know which province it's for.
  • Building ID is defines which model is being located. While this includes each building, this also includes floating harbours as floating_harbor.
  • X, Y, and Z position represent the position on the map of the building model using the 3-dimensional Cartesian coordinate system. The X and Z positions are equivalent to the X and Y axes on the province bitmap with 1 pixel equalling 1 unit, left-to-right and down-to-up respectively. This is also what the game uses to know which province it's for for provincial buildings. The Y position, on the scale of 0 to 25.5, can be calculated with the heightmap by taking the colour value of the pixel at that position and making it fit on the scale of 0 to 25.5 (Such as by dividing it by 10 if it's on the scale of 0 to 255).
  • Rotation is measured in radians. A rotation of 0 will result in the building model pointing in the same direction as the model is set, while positives will rotate it counter-clockwise and negatives will rotate it clockwise. A full rotation resulting in the same position as 0 is equal to the number π multiplied by 2, roughly 6.28.
  • Adjacent sea province is only necessary to define for naval bases and floating harbours, in order to let the game know from which sea province ships or convoys can access the land province where it is located. If the building type is not a naval base, it should be left at 0.

It is preferable to generate the building models in the building section in the nudger, rather than filling it out manually. However, note that the game will crash if the currently-existing /Hearts of Iron IV/map/buildings.txt file is entirely empty, so there should be at least one definition, even if incorrect.

Effects

Each building can accept any state-scoped modifier within itself, applying that to the state when built. Some used in base game include local_resources_<resource>, air_defence (for anti-air), and nuclear_production_factor (for nuclear reactors). In case of provincial buildings, province-level modifiers are accepted instead. This can also be used with modifier tokens to create a custom effect as a variable system. Adding show_modifier = yes will make the modifiers show up in the tooltip of the building.

Aside from state-scoped modifiers, there are several other arguments to make the building have the same effect as a base game building or be considered one for the AI:

Name Effects Examples Type Notes
military_production Adds the specified amount of military factories to the controller.
military_production = 0.5
Flat. A value that's larger than 1 will be the same as 1 factory, but it can fall between 0 and 1.
general_production Adds the specified amount of civilian factories to the controller.
general_production = 0.5
Flat. A value that's larger than 1 will be the same as 1 factory, but it can fall between 0 and 1.
naval_production Adds the specified amount of dockyards to the controller.
naval_production = 0.5
Flat. A value that's larger than 1 will be the same as 1 factory, but it can fall between 0 and 1.
infrastructure Makes the building be marked as infrastructure.
infrastructure = yes
Boolean. Includes the construction speed bonus and extra resources.
air_base Makes the building be marked as an air base.
air_base = yes
Boolean.
supply_node Makes the building be marked as a supply node.
supply_node = yes
Boolean.
is_port Makes the building be marked as a naval port.
is_port = yes
Boolean.
land_fort Adds that many land forts to the province.
land_fort = 1
Flat.
naval_fort Adds that many coastal forts to the province.
naval_fort = 1
Flat.
refinery Makes the building be marked as a synthetic refinery.
refinery = yes
Boolean.
fuel_silo Makes the building be marked as a fuel silo.
fuel_silo = yes
Boolean.
radar Makes the building be marked as a radar station.
radar = yes
Boolean.
rocket_production Defines how much progress on rocket production is done daily.
rocket_production = 5
Flat.
rocket_launch_capacity Defines how many rockets the build can launch daily.
rocket_launch_capacity = 5
Flat.
nuclear_reactor Makes the building be marked as a nuclear reactor.
nuclear_reactor = yes
Boolean.

Example

buildings = {
    my_provincial_building = {
        base_cost = 10000
        infrastructure_construction_effect = yes
        
        provincial = yes
        max_level = 3
        
        value = 1
        
        icon_frame = 17
        
        show_on_map = 1
        always_shown = yes
        
        army_attack_factor = 0.1
        army_defence_factor = 0.3
    }
    my_shared_building = {
        base_cost = 1000
        per_level_extra_cost = 200
        infrastructure_construction_effect = yes
        
        shares_slots = yes  # Max level of 15 since undefined
        
        value = 15
        only_costal = yes
        
        icon_frame = 18
        
        show_on_map = 3
        show_on_map_meshes = 3
        has_destroyed_mesh = yes
        
        military_production = 1
        general_production = 1
        naval_production = 1
    }
    my_non_shared_building = {
        base_cost = 1000
        per_level_extra_cost = 2000
        
        max_level = 2
        
        value = 5
        
        icon_frame = 19     # No model is defined
        
        recruitable_population_factor = 0.5
    }
}

Localization

Buildings use the following localization keys, using my_building as an example:

 my_building: "My building"
 my_building_desc: "My building's description"
 my_building_plural: "My buildings"
 modifier_production_speed_my_building_factor: "§Y$my_building$§! construction speed"
 modifier_production_speed_my_building_factor_desc: "Modifies the speed of §Y$my_building$§! construction."
 modifier_state_production_my_building_factor:0 "§Y$my_building$§! construction speed"
 modifier_state_production_my_building_factor_desc:0 "Modifies the speed of §Y$my_building$§! construction in this state."

The first 3 are used for the building itself in various UI elements, while the last 4 are used to localise the modifiers automatically created for each building: production_speed_<building>_factor and state_production_speed_<building>_factor.

Types

These are the different types of buildings in the game as of 1.11 (Can also be found inside /Hearts of Iron IV/common/buildings/00_buildings.txt):

Icon Localised name Internal name Maximum level Type
Infrastructure.png Infrastructure infrastructure 5 Non-shared
Military factory.png Military factory arms_factory 20 Shared
Civilian factory.png Civilian factory industrial_complex 20 Shared
Air base.png Air base air_base 10 Non-shared
Supply hub.png Supply hub supply_node 1 Provincial
Railway.png Railway rail_way 5 Provincial
Land fort.png Land fort bunker 10 Provincial
Coastal fort.png Coastal fort coastal_bunker 10 Provincial
Naval dockyard.png Naval dockyard dockyard 20 Shared
Anti-air (building).png Anti-air anti_air_building 5 Non-shared
Synthetic refinery.png Synthetic refinery synthetic_refinery 3 Shared
Fuel silo.png Fuel silo fuel_silo 15 Shared
Radar station.png Radar station radar_station 6 Non-shared
Rocket site.png Rocket site rocket_site 2 Non-shared
Nuclear reactor.png Nuclear reactor nuclear_reactor 1 Non-shared

Note that while railways and supply nodes are buildings, not all traditional building operations apply to them. Their starting level is defined outside of state history and a separate effect must be used to construct railways mid-game, with the default add_building_construction or other building-related effects crashing the game.

References

  1. BASE_FACTORY_SPEED = 5 in common/defines/00_defines.lua
  2. INFRA_MAX_CONSTRUCTION_COST_EFFECT = 1 in common/defines/00_defines.lua means a +100% speed bonus for max infrastructure. By default, infrastructure has 5 max levels, making the boost be divided into 5 portions of 20%, depending on the building level.
  3. MAX_SHARED_SLOTS = 25 in common/defines/00_defines.lua
  4. MAX_BUILDING_LEVELS = 15 in common/defines/00_defines.lua