地图修改

本页面讲述的内容长期有效
(重定向自Map modding

游戏的地图是由若干层位图和描述地图内容的文本文件组成的。相关的文件位于/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文件。地形的列表可以参考 /Hearts of Iron IV/common/terrain/00_terrain.txt文件的底部。地形只影响地图和省份间路径的视觉效果;省份本身的地形由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) 外观最宽的河流

列表中的 0[2] 到 6[3] 在游戏机制中被识别为小河,后续直到 11[4] 被识别为大河。为了正确渲染,每一条河都必须被唯一标识,即只有一个起点(绿色/黄色)或一个终点(红色)。

如果两个省份之间的 路径 与一条河流的像素重叠,将会被视为跨河。如果它与多条不同类型的河流的像素相交叉,行进类型将由游戏实际行为决定。为了避免玩家困惑,省份的路径应该明确的穿越或者远离河流。

高度地图(Height map)

heightmap.bmp 决定了地图的3D网格。( 0, 0, 0 ) 表示最低点,(255, 255, 255) 表示最高点。海平面的高度为 (95, 95, 95),所以任何低于这个值的地形都会处于水下。

应当使高度平滑过渡,否则地图会出现锯齿状边缘。

heightmap.bmp 文件以灰度模式保存为一张8位的位图图片文件 (.BMP)。

法线贴图(Normal map)

world_normal.bmp 定义了3D凹凸贴图,用于给高度贴图正常生成阴影。

法线贴图可以使用 Nvidia 纹理工具 根据heightmap.bmp生成,或者使用Photoshop CC的 滤镜>3D>生成法线贴图 功能。

颜色地图(Color maps)

colormap_x.dds文件定义了应用于地图的整体颜色色调。如果没有colormap文件,所有的土地都会出现相同的整体颜色,不管地形类型如何。

它们应该是RGB模式,以.DDS格式保存,使用8.8.8.8 ARGB 32 bpp配置文件,没有mipmaps。

水体地图(Water map)

colormap_water.dds 控制应用于水体的颜色。

colormap_water.dds 文件应该是RGB模式,以.DDS格式保存,使用8.8.8.8 ARGB 32 bpp配置文件,没有mipmaps。


Adjacencies

邻接文件位于 /Hearts of Iron IV/map/adjacencies.csv 。作为一个以逗号分隔的文件,你可以用Excel或其他类似的程序,或者文本编辑器来打开它。默认的编码是ANSI。

该文件在省和河流地图所定义的正常连接的基础上,修改和增加了省与省之间的自定义毗邻关系。例如,它可以控制几个陆路不相连的省份之间的连接状态。一个岛屿通常不会与任何其他陆地省份相连,因为有海洋省份挡住了去路。邻接文件告诉游戏连接这些省份,允许陆地单位在它们之间行走。它还允许改变现有连接的属性,例如,使它们无法通行,改变它们的类型,或定义哪些省份被海峡挡住。

格式如下:

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;

对于普通的陆地连接,类型可以是空的,对于相应类型的连接,类型可以是 "river"/"large_river"/"sea"/"impassable" 。"through"字段定义了一个可以阻挡邻接的省份。当一个敌方单位控制这个省时,连接将不可用。-1则禁用此功能。地图坐标用于调整显示相邻关系的图形的起点和终点。如果不需要调整,用-1来代替实际的坐标。可以选择引用一个邻接规则来控制通过邻接的访问。

即使在其他项为空的情况下,文件也必须以包含负值的 from字段 和分号的行来结束,以防止启动时出现无限的挂起。

战略区域(Strategic Regions)

每个省都必须属于一个战略区域。如果你在游戏中与一个省互动,而该省不属于一个战略区域,那么你会遇到崩溃到桌面的情况。

一个战略区域可以包含来自多个州的省份,但一个州不应该在多个战略区域拥有省份,因为这可能会导致不稳定,并在error.log中显示警告。

战略区域的格式如下,例如:

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

战略区域的颜色是随机的。不过,你可以手动定义一个区域的颜色:

    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)

所有的地区都必须与一个补给区域相关联。每个补给区域可以包含任何数量的地区,而一个地区只能在一个补给区域中。

Supply areas are formatted as follows:

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

大陆(Continent)

可以在"map"文件夹的"continent.txt"文件中找到。大陆被用来定义AI区域。

所有地块必须属于某一个大陆,否则会遇到错误/崩溃。

原版游戏中的大陆是 (大陆后的数字是它们的ID):

欧洲(1)

北美洲(2)

南美洲(3)

大洋洲(4)

非洲(5)

亚洲(6)

中东(7)

(修改原因:原大陆和其ID可能有错误)

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