地图修改:修订间差异

本页面讲述的内容长期有效
无编辑摘要
(林登万移动页面Map modding地图修改
(没有差异)

2020年8月18日 (二) 00:09的版本

游戏的地图是由若干层位图和描述地图内容的文本文件组成的。相关的文件位于/Hearts of Iron IV/map/

default.map

文件default.map涉及组成地图的位图文件和文本文件。一个基本的版本如下所示:

definitions = "definition.csv"
provinces = "provinces.bmp"
positions = "positions.txt"
terrain = "terrain.bmp"
rivers = "rivers.bmp"
heightmap = "heightmap.bmp"
tree_definition = "trees.bmp"
continent = "continent.txt"
adjacency_rules = "adjacency_rules.txt"
adjacencies = "adjacencies.csv"
#climate = "climate.txt"
ambient_object = "ambient_object.txt"
seasons = "seasons.txt"

# Define which indices in trees.bmp palette which should count as trees for automatic terrain assignment
tree = { 3 4 7 10 }

所有的文件路径可以改变,但是需要与map/文件夹相关。接下来的部分中提到的都是默认文件路径。 default.map的名字本身是硬编码的(不要改动)。

地图的宽度和高度由provinces.bmp决定,并且都要是256的倍数。下列文件也需要有相同的分辨率:

  • heightmap.bmp
  • provinces.bmp
  • rivers.bmp
  • terrain.bmp

省份地图(Province Map)

definition.csv包括了游戏能够识别的省份,它的内容以下列方式排列:

province id; r value; g value; b value; province type (land/sea/lake); coastal (true/false); terrain (plains/hills/urban/etc); continent (int)

省份id和RGB值必须是独一无二的。有效的地形类型定义在/Hearts of Iron IV/common/terrain。大洲是一个从1起的到大洲列表的索引。例如:

7;212;179;179;sea;true;ocean;1 - a coastal sea province
114;40;15;15;land;false;plains;1 - an inland plains province
260;170;235;235;land;true;urban;1 - a coastal urban province

如果省份定义不完全,游戏会在用户目录里创造一份此文件的拷贝,任何不完全的或者遗漏的省份定义都会写入。在对原来的内容进行修改之前,删除这个拷贝或许是必要的。[1]

文件必须是Windows样式的行结尾(CRLF)!

provinces.bmp控制了地图上省份的位置和形状。每一个像素都属于与它的RGB色值相对应的省份。有相同像素边缘的省份在游戏中彼此相邻并连接。在debug模式开启的时候,它可能会警告下列情况:

  • "Map invalid X crossing. Please fix pixels at coords":四个省份有共同的顶点。游戏会连接左下和右上的省份,但是这对于玩家来说是很迷惑的,应当避免。
  • "Province X has TOO LARGE BOX. Perhaps pixels are spread around the world in provinces.bmp":省份的宽度/高度超过了地图总宽度/高度的1/8。这可能表示有两个省份无意使用了相同的颜色。
  • "Province X has only N pixels":省份的像素不多于NGraphics。MINIMUM_PROVINCE_SIZE_IN_PIXELS(默认为8)。这样的省份可能太小以致影响玩家的体验。

省份id应当尽可能地相邻,过大的间隔会让游戏崩溃。

文件provinces.bmp应当是RGB模式并且保存为24位位图文件(.BMP)并且没有色域信息。

地形地图(Terrain Map)

terrain.bmp是一个控制地形分配和纹理的8位索引模式的BMP文件。The indexes refer to the terrains at the bottom of /Hearts of Iron IV/common/terrain/00_terrain.txt. The terrain only affects the visuals of the map and paths between provinces; 省份本身的地形由definitions.csv定义。

树木地图(Tree map)

trees.bmp控制地图上树木的摆放。文件trees.bmp的分辨率影响树的密度。

文件trees.bmp应为索引模式并保存为8位位图(.BMP格式)。


河流地图(River map)

River Map Colour Scheme.png

rivers.bmp控制地图上的河流。该文件中的河流应当只有1像素宽。

文件rivers.bmp应为索引模式并保存为8位位图(.BMP格式)。

rivers.bmp文件中使用的颜色
Index 颜色 意义
0 (0, 255, 0) 河流的源头
1 (255, 0, 0) 流入源。用于把多条河流合并为一条干流。
2 (255, 252, 0) 流出源。用于把一条河流分流为多条支流。
3 (0, 225, 255) 外观最窄的河流
4 (0, 200, 255) 外观较窄的河流
5 (0, 150, 255)
6 (0, 100, 255) 外观较宽的河流
7 (0, 0, 255)
8 (0, 0, 225)
9 (0, 0, 200)
10 (0, 0, 150)
11 (0, 0, 100) 外观最宽的河流

Indexes 0[2] up to including 6[3] are treated as small rivers for game mechanics, indexes up to including 11[4] as large rivers. To correctly render, each river must have exactly one marker, either a start marker (green/yellow) or an end marker (red).

If the path between two provinces overlaps at least one river pixel, it is considered a river crossing. If it intersects multiple river pixels of different types, the crossing type is implementation defined. To avoid player confusion, province paths should either clearly cut or stay clear of a river.

高度地图(Height map)

heightmap.bmp determines the 3D mesh of the map. ( 0, 0, 0 ) is the lowest point, with (255, 255, 255) being the highest. The sea level is set at (95, 95, 95), so any values below that will be submerged.

Make the transitions between heights smooth, otherwise you will create noticeable jagged edges.

The heightmap.bmp file should be in Greyscale mode and saved as a 8-bit bitmap image file (.BMP).

Normal map

world_normal.bmp determines the 3D bump map. This is required to correctly add shadow to the height map.

Normal maps can be created with Nvidia's texture tools from the heightmap.bmp, or by using Filter > 3D > Generate Normal Map in Photoshop CC.

Color maps

The colormap_x.dds files define the overall color tint applied to the map. Without a colormap file, all land will appear the same overall color, regardless of terrain type.

They should be in RGB mode and saved in the .DDS format, using the 8.8.8.8 ARGB 32 bpp profile with no mipmaps.

Water map

colormap_water.dds controls the color tint applied to water.

The colormap_water.dds files should be in RGB mode and saved in the .DDS format, using the 8.8.8.8 ARGB 32 bpp profile with no mipmaps.


Adjacencies

The adjacencies file is found at /Hearts of Iron IV/map/adjacencies.csv. As a comma-separated file, you may open it with Excel or other similar programs, or a text editor. The default encoding is ANSI.

The file modifies and adds custom adjacencies between provinces on top of the normal connections defined by the provinces and rivers maps. For example it controls which provinces non-contiguously connect to other provinces. An island is normally not connected to any other land provinces, as there are sea provinces in the way. The adjacencies file tells the game to connect such provinces, allowing land units to walk between them. It also allows changing the properties of an existing connection, e.g. making them impassable, changing their type, or defining which provinces are gated by straits.

The format is as follows:

From;To;Type;Through;start_x;start_y;stop_x;stop_y;adjacency_rule_name;Comment
<province id>;<province id>;<type>;<province id>;<map coordinate>;<map coordinate>;<map coordinate>;<map coordinate>;<comment>
-1;

The type may be empty for a normal land connection, or "river"/"large_river"/"sea"/"impassable" for a connection of the respective type. The "through" field defines a province that can block the adjacency. While an enemy unit controls this province, the connection will be unavailable. -1 disables this feature. The map coordinates are used to adjust the starting and ending point of the graphic displaying the adjacency. If no adjustment is needed, use -1 in place of an actual coordinate. Optionally an adjacency rule can be referenced that controls access through the adjacency.

Even when otherwise empty, the file must be terminated with a line containing a negative from-field and a semicolon to prevent an infinite hang on start-up.

Strategic Regions

Every province must belong to a strategic region. If you interact with a province in-game and it does not belong to a state, you will experience a crash to desktop.

A strategic region may contain provinces from multiple states, but a state should not have provinces in multiple strategic regions as this can cause instabilities and will show a warning in error.log.

Strategic Regions are formatted as follows, in example:

strategic_region={
	id=18
	name="STRATEGICREGION_18"
	provinces={
		 2775 2799 2824 2847 2871 2895 2977 3528 4370 5929 7242 8450 8621 11748 12389 13004 13006 13007 
	}
}

The color of the strategic region is random. However, you can manually define an area's color:

    color = { <r>, <g>, <b> }

The color definition used the default RGB values, which range from 0 to 255 (i.e. not decimal RGB).

Supply areas

All states must be associated with a supply area. Each supply area can take any number of states, and each state should be in only one supply area.

Supply areas are formatted as follows:

supply_area={
	id=1
	name="SUPPLYAREA_1"
	value=12
	states={
		5 85 
	}
}

Continents

Found in continent.txt, located in the map folder, continents are used to group large swathes of provinces together as a traditional continent. Continents are used to define AI areas.

All land provinces must belong to a continent, otherwise you may experience errors/crashes.

The continents in the base game are (the number after the continent name is the ID):

Europe (2)

North America (3)

South America (4)

Africa (5)

Asia (6)

Middle East (7)

Pacific (8) (note that the pacific tag is only used for a few states near Australia, all the other pacific states are under the Asia tag)

Australia/Oceania (9)

Ambient Objects

The ambient_object.txt is used to define the cosmetic 3D objects found in the map. This includes the map frame, so don't simply empty the file if you want to remove the other objects.

The format for an ambient object is as follows:

# Used once for each graphical asset
type = {
    type = <string>         # Refers to the graphical asset in ambient_object.gfx
    use_animation= <yes/no> # Used set set if an object is animated or not
    scale = <float>         # Sets the scale of the asset. 1.0 is default size.
    time_duration=300.000   # Always set to 300 for animated objects, may be redundant
    
    always_visible = <yes>              # Used to force visibility
    visible_in_all_map_modes = <yes>    # Used to show is non-terrain mapmodes
    
    # Each instances is a separate object
    object = {
        name = <string>                 # Name does not have to be unique
        hidden_on_start = <yes/no>      # Whether the object is hidden (can be revealed with show_ambient_object)
        position = {
            <x>     # Horizontal coordinate
            <z>     # Height coordinate - 0.0 is base
            <y>     # Vertical coordinate
        }
        rotation = {
            <x>     # Horizontal rotation
            <z>     # Height rotation - this is used for most rotations
            <y>     # Vertical rotation
        }
    }
    
}

You can use the Nudge tool to place new instances and move objects, but if you want to add a new type, you must add it to the file first, then use the Nudge tool.

The ambient objects for the canals are found here. To link them to the canal definition in default.map, you need to make sure they share the same name (i.e. panama_canal).

Terrain Atlas

The terrain textures used for specific terrains are found in atlas0.dds and atlas_normal0.dds.

The association between the texture and terrain is found in /Hearts of Iron IV/common/terrain/00_terrain.txt. Within this file is the terrain scope which defines the terrain objects used by the game to interpret the terrain.bmp.

  • type is the terrain category assigned to provinces that are covered by the specified terrain in the terrain.bmp.
  • color is the indexed color from the terrain.bmp that represents this terrain object.
  • texture is the tile from the terrain atlas textures that this terrain object uses.

When the game automatically generates terrain (i.e. using the Nudger) these terrain objects are what control the assignment of terrain categories to provinces.

The atlas0.dds and atlas_normal0.dds must be saved in DXT5 with Mipmaps enabled.

It is possible to increase the size of the texture atlas. In constants.fxh in /Hearts of Iron IV/gfx/FX/, edit the MAP_NUM_TILES variable to match your new number of columns and rows (a setting of 5.0 will result in 5 x 5 = 25 texture indices, as opposed to the vanilla 4 x 4).

It is possible to increase the size of the texture tiles within the texture atlas. In pdxmap.shader in /Hearts of Iron IV/gfx/FX/, edit the TEXELS_PER_TILE variable to your new size.

Seasons

The seasons.txt file is used to define the color adjustments during the four seasons that pass in game. There are four seasons: winter, spring, summer and autumn.

The format for each is as follows:

<season> = {
    start_date = <date>      # 00.<month>.<day>, in numeric form, i.e. 00.12.01
    end_date = <date>
    
    # Applies to the northern hemisphere
    hsv_north = { <hsv> }    
    colorbalance_north = { <hsv> }
    
    # Applies to the equator
    hsv_center = { <hsv> }    
    colorbalance_center = { <hsv> }
    
    # Applies to the southern hemisphere
    hsv_south = { <hsv> }    
    colorbalance_south = { <hsv> }
}

The color format used is decimal HSV (Hue, Saturation, Value).

The seasons.txt file also controls the tree models visual appearance over the year.

Color map and city lights

/Hearts of Iron IV/map/terrain/colormap_rgb_cityemissivemask_a.dds serves two purposes. The RGB channels define the default coloring of the map, which gets modified by terrain. When making changes to the terrain or height map, this color map should be updated too to reflect the changes visually. The alpha channel is used for city lights at night. More opacity means stronger lights.

The file should have half the vertical and horizontal resolution of the map.

Sizes

It is possible to change the size of the map, with the majority of bitmap files requiring the same resolution.

  • The vertical and horizontal resolution should be a multiple of 256
  • world_normal.bmp should have half the vertical and horizontal resolution of the map
  • trees.bmp should have the vertical and horizontal resolution of the map at a ratio of 0.29296875
  • The maximum area of pixels does not exceed 13,107,200

It will be necessary to use the Nudge tool to adjust any ambient objects to suit the new map.

  1. forum:1153223
  2. NMilitary.RIVER_SMALL_START_INDEX
  3. NMilitary.RIVER_SMALL_STOP_INDEX
  4. NMilitary.RIVER_LARGE_STOP_INDEX