地圖修改

本頁面講述的內容長期有效

遊戲的地圖是由若干層位圖和描述地圖內容的文本文件組成的。相關的文件位於/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