Hi Everybody! Based on my
previous experiments with loading alternate terrains in the map generator, I've come up with some new code for placing map blocks on top of each other, similar to how the addUFO and addCraft commands work, but now with arbitrary map blocks! This code is all accessible through a tag in the mapscripts ruleset called
verticalLevels:alienDeployments:
- type: STR_MEDIUM_SCOUT
height: 8
mapScripts:
- type: DEFAULT # forest, mountain
commands:
- type: addUFO
- type: addCraft
- type: addBlock
size: [1, 1, 8]
verticalLevels:
- type: ground
size: [1, 1, 2]
terrain: XBASE
blocks: 20
- type: middle
size: [1, 1, 4]
- type: addBlock
size: 2
executions: 2
- type: fillArea
The snippet above produces the first result image I've attached below, where a forest map block sits atop the dirt fill from the base defense maps. Speaking of base defense maps, this new code will also work for those too - I've included some examples of a base in the desert at night, generated by the ruleset attached.
The verticalLevels tag can be defined for the mapscript commands
addBlock, addCraft, addUfo, and fillArea.
These definitions will supersede the blocks, groups, etc. definitions in the regular map script command in favor of their own. Each vertical level supports definitions of the following:
- type: ground - This defines the behavior of the level and how it's handled. "ground" is only used once and is placed at z = 0, "ceiling" is also only used once and is placed at the top if defined, "middle" is used to create filler levels in between the first two, "empty" allows for a filler level to contain no map block, "decoration" acts like middle but sets its vertical size to zero, causing the next map to be loaded directly over it, and "craft" is a marker for placing the craft/UFO in the addCraft/addUFO commands.
- groups: [6, 7, 8] - Works just like groups in regular commands, defining which groups of blocks are used in this particular level.
- blocks: 20 - Again, just like blocks in regular commands, it also overrides the groups tag.
- size: [1, 1, 4] - Perhaps the most important definition in a vertical level besides the type, this is how the engine recognizes the vertical extent of a particular level, since it is not specifically defined for most map blocks. The size is read in as [x, y, z], with z being the important bit here. Defaults to [1, 1, 1].
- maxRepeats: 1 - For the filler levels "middle", "empty", and "decoration", defines how many times they can be used in a given map chunk. Negative numbers remove any limit on the number of repeats. Defaults to -1.
- terrain: XBASE - Defines which terrain this particular level will use, see the documentation for the alternate terrain commands for more info. Defaults to the terrain from the deployment or mission.
Algorithm:
------------
Once the levels are defined in a particular command, the code populates a list of levels based on either the height of the map or the size in z defined in the command itself. The
"ground" and "ceiling" levels are added to the list first to reserve space for them. Next, the remaining levels are looped over in the order defined by the ruleset, adding them in between the ground and ceiling to fill out the chosen size for the command, stopping when either the maxRepeats are reached for each level and there are none left, or when no more levels can be added without going over the size of the map/command. Finally, the
"ceiling" level is given an offset to place it directly on top of the last filler level chosen. This method of filling the space in the vertical direction is why
defining the specific sizes for each level is important - the code relies on those definitions to determine how high above the previous level the next should be placed. With a size in z of 0, the next level will be placed at the same offset as the previous, often running into interesting terrain collision issues, but this can be and is leveraged by the
"decoration" level to allow for say a building to be placed on various kinds of terrain based on where in the geoscape the mission occurs. Other use examples might be adding
"empty" levels to addCraft/addUFO to make them hover over the terrain, or making your base have both above and below ground portions.
Base facilities:
------------
Speaking of the base terrain, the
verticalLevels tag can be placed directly on a facility definition to override the given map name and generate that particular facility's map as if it were an
addBlock command.
If used for a 2x2 facility though, it will require a 20x20 map block, not the four 10x10 blocks usually defined as in the hangar.Edit 171110: This is an official part of OXCE, so the links for my repository are deprecated. This post will remain for documentation.