Some random map scripts I've created

I’ve created a few random map scripts over the past year and I thought I could share some of these maps on this forum, as well as brief explanations on created them. If you’re not familiar with random map scripting, check out the Definitive Random Map Scripting Guide. This post also talks a bit about land generation, which you read more about in this guide (h/t HankDeSuperNerd).

Infinity Stones

Download: AoE2 Mod Page, aoe2map

Can you take control of the hills of (essentially) infinite Stone?

Despite the name, there isn’t an infinite amount of Stone on this map. I found that 10 million resources was about the most you can go for each pile before stuff started glitching. To make sure each hill has Stone, I set the min_distance_group_placement property to 10 and made it only spawn on the gravel terrain on the top of the hill. Because each hill top had a diameter of less than 10 units, the “infinite” Stone piles would spawn on separate hills.

Stone miners work twice as fast, while Castles and Krepost have half HP. It’s also playable with AI. However, because the default AI was not programmed to focus on Stone mining and was not programmed to sell massive amounts of Stone, they ended up struggling to train Gold units.

Arena Island

Download: AoE2 Mod Page, aoe2map

It’s Arena, but on an island.

Being on an island, the starting area is smaller than regular Arena. Most resources are inside the walls, but extra herdables and resources are located outside the wall. Each player also starts with Sea Towers, to give you some protection from early naval rushes.

To create this map, I first set the base terrain to water in the land generation section. Then I created a ring of placeholder terrain, which in this was DIRT3. When I was creating this map, I simply copied the create_land ring from Arena-ception’s map. This ring, in turn, was created using TheMadCader’s MadLands utility.

After generating the ring, I used another create_land command to fill the middle with the main terrain, setting land_percent to 100 and land_position to 50 50. The ring of trees act like a dam, blocking the main terrain from spilling into the outside water. Finally, I used a create_player_lands to generate the starting player lands. I set the player land size and land percent to 0, though, so to maintain the island’s circular shape.

It’s in terrain generation where I give starting units space to spawn. First, I filled in all of DIRT3 over 20 units away from the starting player area with Forest terrain. Then, because I didn’t want DIRT3 to be the starting area terrain, I replaced DIRT3 with the player terrain, a terrain that varied based on map theme.

Houseboat Shallows

Download: AoE2 Mod Page, aoe2map

Like Houseboat, but with shallows.

The original Houseboat has two issues that makes it unplayable to the default AI: it requires the use of Transport Ships and the land around the TC is too small to build farms. Houseboat Shallows attempts to correct these issues by increasing the Houseboat size and by connecting the houseboat to the mainland with shallows. However, by making these changes, early game microing suddenly becomes much easier and Transport Ships a lot less useful. But they’re still useful if you want to quickly ferry away your Sheep before any enemies come along to steal them.

In both the original and my version of Houseboat, there is a strip of land surrounding the lakes that contains Gold, Stone, Forage Bushes and extra Sheep. The original Houseboat attempted to keep the number of strip resources the same for each player by using the temp_min_distance_group_placement property, but that didn’t always produced consistent results.

The set_place_for_every_player method is a much more effective way to ensure consistent player resources. However, that placement method only works if the terrain they’re being placed on is not separated from the player land origin by restricted terrain. In Houseboat, the strip is separated from the player land origin by water and shallows and Gold/Stone/etc cannot be placed on those terrains. Thus you can’t use this method… unless you also enable ignore_terrain_restrictions.

However, if you do enable ignore_terrain_restrictions, some resources, due to how they’re clumped, may spawn on water, even if you specifically specify that they should only spawn on the strip. To ensure this won’t happen, I created an additional 2 unit wide buffer between the strip and pond. You can take a look at the diagram below to see what I’m talking about:

Fortress Island

Download: AoE2 Mod Page, aoe2map

Like Fortress, but on an island.

Similar to Arena Island, Fortress Island has a smaller starting walled area compared to its regular counterpart. While all huntables and herdables are located inside the wall, most resources, especially Wood, are located outside the wall.

Impact Lake

Download: AoE2 Mod Page, aoe2map

A map with an impact crater lake in the middle, surrounded by a rim containing extra Stone and Gold.

This map looks simple, but creating concentric terrains at different elevations is actually more complex than you’d expect. In fact, I had to ask the experts on the RMS Discord for help in making this map (h/t TechChariot).

Like the forest ring on Arena Island, the crater rim was created using MadLands. Similar to Arena Island, the crater rim acted like a dam, this time preventing the surrounding land (base_elevation 5) from filling in the crater at the middle. Unlike in Arena Island, though, the surrounding land was generated using create_player_land instead of create_land.

Side note, if you take a look at my uploaded script, the create_player_land command is placed before all the crater rim stuff, despite that not making any logical sense if the crater rim is suppose to act like some sort of dam. The script still works properly if the create_player_land command is placed after the crater rim generation, indicating that the game might read create_player_land commands before other create_land commands. However, the Definitive RMS Guide doesn’t mention anything of the like, so I don’t know for sure.

Four Ponds

Download: AoE2 Mod Page, aoe2map

Like Four Lakes, but all the water is now in the middle. Additionally, the area between the four ponds contains extra Boars, Stone and Gold, as well as a Relic.

The bodies of water was created using the left_border, right_border, top_border and bottom_border properties. To make the sure ponds were circular, I set land_percent to 100. Otherwise, it’s a pretty simple map.

Nomad World Tour

Download: AoE2 Mod Page, aoe2map

Nomad, but on maps you know.

There are 21 potential map styles, ranging from Atacama to Wolf Hill (minus the Wolves). I added min_distance_to_map_edge 10 to Villager spawns to decrease likelihood of trapped Villagers. None, of the map style, though, will resemble default Nomad or Land Nomad. Check the description on the download page for all the potential generations.

Like with regular Meadows, the Meadows style in this map script uses two create_player_land commands to create the spawn area and the main woodline. I discovered that if the woodline and non-woodline create_player_lands have the same land_id, the map will spawn 6 starting villagers instead of the default 3. That why I set the land_id in the woodline create_player_land command to 500.

Random Arabia

Download: AoE2 Mod Page, aoe2map

Like Megarandom-style starts, but wished that all the maps to look more like Arabia? Well, Random Arabia is the map for you!

You will always start with a Town Center, a standard number of Villagers and at least 1 scouting unit. You will also start with a Forage bush and near Stone/Gold. The objects that may vary include:

  • Scout numbers and/or type. Your scout can be your civilization’s standard starting Scout, but it can also be a Serjeant or even a Flaming Camel.
  • The second building, if it spawns. All buildings except for Mill, Mining/Lumber Camp, Docks and Caravanserais can spawn.
  • Extra resources. Far Gold may or may not spawn, while extra resources may spawn scattered across the map.

What is guaranteed is that you will never have the vanilla 1 TC, 3-6 Villagers, 1 Scout start.

Regarding the map layout, there’s a 30% chance that the map will be land Arabia, a 30% chance that there be oases inside the forests, a 20% chance that the map will be Cenotes-style, a 10% chance that the map will resemble Kawsasan, and a 10% chance that there will be a center lake.

I also gave all players close woodlines. To do this, I had to use a bunch of placeholder terrain:

  1. In land_generation, I used the create_player_land to create player spawn area with BEACH terrain. With base_size 13 (for non-Kawasan style generations) and land_percent 4, the player spawn area is about 15-20 tiles.
  2. Moving to the terrain_generation section, I used a create_terrain command to change one random player’s land from BEACH to DLC_ROCk.
  3. Then I created a 25 tile clump of forest, with set_avoid_player_start_areas enabled. If you recall, the player spawn area has a radius of about 15-20 tiles, while set_avoid_player_start_areas by default prevents terrain from spawning within 13 tiles of the starting area. In turn, the forest clump that will be created will be between 13 to 20 tiles, which is reasonable for starting woodlines.
  4. I originally wanted the second forest clump to have some spacing to the first clump. To do this, I used another create_terrain command to place a 20 clump of ROAD placeholder terrain on top of DLC_ROCK, with spacing_to_other_terrain_types set to 1
  5. After placing the ROAD terrain, I placed forest terrain on top of the ROAD terrain. With that, a second clump of forest should in theory should be generated near player spawn. However, I found spacing_to_other_terrain_types 1 caused this second clump to be incredibly small due to the spawn area’s relatively small size. Therefore, I ended up setting spacing_to_other_terrain_types to 0, which actually makes the ROAD terrain placement unnecessary.

After these steps, I had the following block of code:

create_terrain DLC_ROCK
{
base_terrain BEACH
number_of_clumps 1
land_percent 100
}

create_terrain FOREST_MAIN
{
base_terrain DLC_ROCK
number_of_clumps 1
number_of_tiles 25
spacing_to_other_terrain_types 0
set_avoid_player_start_areas
clumping_factor 20
}

create_terrain ROAD
{
base_terrain DLC_ROCK
number_of_clumps 1
number_of_tiles 20
spacing_to_other_terrain_types 0
set_avoid_player_start_areas 
clumping_factor 20
}

create_terrain FOREST_MAIN
{
base_terrain ROAD
number_of_clumps 1
number_of_tiles 25
}

create_terrain TERRAIN_MAIN
{
base_terrain DLC_ROCK
number_of_clumps 1
land_percent 100
}

If there are non-contiguous terrain, such as player spawn terrain, the create_terrain command will only create terrain in one of those areas. Therefore, I copied this block of code eight more times to fill in the rest of the player lands. You’ll notice that means there will be nine, instead of eight, copies of this block of code in this RMS. This is done to reduce the chance something like this happening.

Finally, you cannot nest start_random codes. For example, on this map, there’s a 75% chance that you’ll spawn with a second building. If you don’t spawn with a second building, then you’ll always spawn with 2 scouts. If you do spawn with a second building, then there’s a 50% you’ll spawn with 2+ scouts and another 50% chance you’ll spawn with only 1. The following block of code won’t work:

/* This will not work! */
start_random
	percent_chance 25 #define SEC_BUILD_NO /* No second building */
		start_random
			percent_chance 0 #define FIRST_SCOUT_SINGLE /* Spawn 1 scout */
			percent_chance 100 #define FIRST_SCOUT_MULT /* Spawns 2+ scouts */
		end_random
	percent_chance 75 #define SEC_BUILD_YES /* Spawns second building */
		start_random
			percent_chance 50 #define FIRST_SCOUT_SINGLE
			percent_chance 50 #define FIRST_SCOUT_MULT
		end_random
end_random

Instead, it should be arranged like this:

start_random
	percent_chance 25 #define SEC_BUILD_NO
	percent_chance 75 #define SEC_BUILD_YES
end_random

if SEC_BUILD_YES
	start_random
		percent_chance 50 #define FIRST_SCOUT_SINGLE
		percent_chance 50 #define FIRST_SCOUT_MULT
	end_random
	else
	start_random
		percent_chance 100 #define FIRST_SCOUT_MULT
	end_random
endif

Nomad Lakes

Download: AoE2 Mod Page, aoe2map

Like Nomad, but with lakes

A spinoff/spiritual sequel to Nomad World Tour, this map has three features that will vary:

  • Map border: 40% chance it will be empty land, 40% it will be forest, 20% chance it will an unbuildable terrain
  • Edge lakes: 40% there will be four corner lakes, 30% there will be Budapest-style lakes, 30% there won’t be any edge lakes
  • Middle Lakes: There could be one, two, four or an equivalent player number of lakes. If there are four edge lakes, then there’s a chance there won’t be any middle lake(s).

Like Land Nomad or African Clearing, I wanted Nomad Lakes to have a border around the map to prevent villagers from being trapped on the map’s edge. To do this, I used create_land to create land to fill the map with the main terrain bounded by a 4% offset from the map’s edges. This main terrain is where all the forests will be placed:

create_land
{
terrain_type TERRAIN_MAIN
land_percent 100
base_size 1

if EDGE_FOREST
	top_border 4
	left_border 4
	right_border 4
	bottom_border 4
else
	top_border 4
	left_border 4
	right_border 4
	bottom_border 4	
endif

if TINY_MAP
	border_fuzziness 60
else
	border_fuzziness 40  
endif
  
if STYLE_CENTERLAKE
	land_position 50 80
else
    land_position 50 50
endif

base_size 0
} 	

You’ll notice that this create_land command has land_position attributes, even though I’m essentially filling the whole map with TERRAIN_MAIN. This is because if you don’t specify land_position, then the game will randomly choose a land_position within the defined border. This means that sometimes, the land_position the game chooses will overlap with a lake that was also created with a create_land command, leading to protrusions and other unsightly annoyances. Setting land_position to outside the lake boundaries can reduce the amount of irregularities, though they will still pop up from time to time. In general, the game tends to struggle when it comes to overlapping lands generated with the create_land command.

1 Like

I recently added Budapest-style lakes to Nomad Lakes and I found something interesting when trying to add those lakes.

If you look closely at the Budapest minimap, you’ll notice that the northwest and southeast lakes tends to be pinched at the map’s edge:

Left minimap lakes have border_fuzziness 15 and clumping_factor 15, while the right minimap lakes lakes have border_fuzziness 100 and clumping_factor 40.

No one knows why this pinching feature doesn’t impact the NE and SW sides of a map, but to get rid of this feature for the NW and SE sides, you need to extend the lake borders past the map boundaries. In other words, you will need to use negative values in your border attributes (h/t Chrazini from the RMS Discord). For example, to get rid of the pinching in the northwest lake, I used the following borders:

  left_border			   30
  right_border			   30
  top_border               -25 /* 0 on default Budapest */
  bottom_border            90

But remember, if you don’t specify land_position, then the game will randomly choose a land_position within the defined border. This includes areas outside the map boundaries. But if the game places land_position outside the map boundary, the game crashes. Therefore, for each lake, I have to specify a land_position inside the map.

Overall, to get Budapest-style lakes without the pinching, I used the following block of code:

create_land /* NE lake */
{
  terrain_type  WATER
  land_percent                     100
  number_of_tiles 99999
  left_border                      90
  right_border                     -25
  top_border                       30
  bottom_border                    30
  base_size                        1
  border_fuzziness              15
  clumping_factor                15
  land_position 99 50
  zone 1
}

create_land /* SW lake */
{
  terrain_type  WATER
  land_percent                     100
  number_of_tiles 99999
  left_border                      -25
  right_border                     90
  top_border                       30
  bottom_border                    30
  base_size                        1
  border_fuzziness                15
  clumping_factor                 15
  zone 2
  land_position 1 50
}
create_land /* SE lake */
{
  terrain_type  WATER
  land_percent                     100
  number_of_tiles 99999
  left_border			   30
  right_border			   30
  top_border                       90
  bottom_border                    -25
  base_size                        1
  border_fuzziness              15
  clumping_factor                15
  zone 3
  land_position 50 99
}

create_land /* NW lake */
{
  terrain_type  WATER
  land_percent                     100
  number_of_tiles 99999
  left_border			   30
  right_border			   30
  top_border                       -25
  bottom_border                    90
  base_size                        1
  border_fuzziness              15
  clumping_factor                15
  zone 4
  land_position 50 1
}

This block of code generated the following lakes:

Like in the previous screenshot, left minimap lakes have border_fuzziness 15 and clumping_factor 15, while the right minimap lakes lakes have border_fuzziness 100 and clumping_factor 40.

If you take a look at the Nomad Lakes code, you’ll notice that, for all the lakes, I use border_fuzziness 100 and clumping_factor 40 instead of having both attributes be 15. This is because if the lakes had a fuzzier boundary, and if the map border was a forest, I found that a thin line of trees would sometimes spawn at the lakes’ edges. As I intended for players to dock on those lakes in the early games, having forests blocking lakes would obviously not be a good thing.

1 Like

Shock Troops Arabia and Shock Troops Arena

Download: AoE2 Mod Page, aoe2map (Arena), aoe2map (Arabia)

Like Arabia and Arena, but everyone starts with 13 Villagers, 2 TCs and 31 soldiers. What could go wrong?

My proof of concept of a RMS where you start with a bunch of military units and Villgers. Players start with the following:

  • 2 TCs
  • 8 Army Tents
  • 13 Villagers
  • 10 Camel Scouts
  • 10 Skirmishers
  • 10 Spearmen
  • 1 Default scouting unit
  • 1 Battering Ram (Arena)

The reason for starting with 10 Camel Scouts instead of 10 Scout Cavalry has to do with the SCOUT constant. SCOUT is the Scout Cavalry’s internal unit name, but the default .dat file contains an effect that upgrades all SCOUT objects to Camel Scouts or Eagle Scouts if the player is playing as the Gurjaras or a Mesoamerican civilization respectively. Because starting with 10 Eagle Scouts is a bit OP, I decided instead to make those extra scouting units be Camel Scouts.

The second Town Center is scripted to spawn on the closest woodline while staying at least 15 units away from the primary TC. As you know in Arena, the woodline inside the walls are inconsistent, while there’s also usually a safe cove that spawns behind the player’s base. In turn, when using default Arena attributes for the create_player_land command, the second TC would have an inconsistent spawning location. Sometimes, the second TC would spawn safely in the back cove, while other times it would dangerously spawn in front of the forward walls.

To deal with issue, I changed land_percent attribute from 20 to 0 and increased the base_size value from 12 to 17. This in turn created perfectly square-shaped bases without any coves and back walls, which in turn led to the 2nd TC always spawning inside the wall. It makes the map look less aesthetically pleasing, but I think it’s an understandable tradeoff.

Nomad Rivers and Nomad Valley

Download: AoE2 Mod Page, aoe2map (Rivers), aoe2map (Valley)

Like Nomad, but on Rivers and Valley (or is it Wade?)

For both maps, there will always an island in the middle containing extra mines or Forage Bushes. On Nomad Rivers, all islands are connected to each other by shallows, while on Valley, shallows replaces Beach/Ice terrain. Valley shallows contain huntables (50% chance Deer, 50% chance Boar) and Shore Fish. There’s also a 50% chance that player lands in Nomad Valley will be elevated Wade-style.

In Nomad Valley, Shore Fish spawn inside the pools of water in the shallows, even though by default they’re only allowed to spawn off shallow shores. To get around this, I first place a terrain blocker (ID 1613) object in the pools of water, using the terrain blocker as a placeholder; terrain blockers do not have terrain restrictions. Then I spawn the Shore Fish using the second_object attribute. This is the same method Wade uses to spawn Shore Fish in their shallows.

Overall, my create_object command looked like the following:

#const TERRAIN_BLOCKER 1613

create_object TERRAIN_BLOCKER
{
if ASIAN_MAP
 second_object DLC_BOXTURTLE
else
 second_object SHORE_FISH
endif
number_of_objects  9320
temp_min_distance_group_placement  5
terrain_to_place_on WATER
}