Battlescape Map Generation
The two engines need to communicate with each other - When battle begins, the GeoScape engine needs to state the particulars such as which troops and aliens are present, and what the mission goals are. The Tactical engine then needs to piece together the map and place the units.
This page aims to state the steps taken during this process, so as to have all the relevant wiki articles listed in the one place.
Typically, a battlescape map is 50 wide by 50 units long by 4 units high, with the maximum battlescape size being 10k units. There are a small handful of exceptions to this.
Battles against a small or medium scout are fought on maps only 40x40x4. X-COM bases are 60x60x2, as is the Cydonia underground base. Standard alien bases are 50x50x2.
Usually two or three large map modules (2x2) will make it into each battlescape. All alien bases contain a command center module, though the Cydonia base contains a brain module instead; a third of the randomly-selected modules in such bases are of type 7 (an empty junction point, can be seen here).
X-COM bases are built according to how you set them up.
Regarding roads in terror missions, these always go from one side of the map to the other. There is a 25% chance of two roads appearing (both a horizontal and a vertical), a 25% chance of just a W/E road appearing, and a 50% chance of just a N/S road appearing (that is to say, at least one road will be present in any given terror map).
Artifact stage 1: 50x50x4
Colony stage 1: 60x60x4
Crashed plane: 50x50x4 (Regardless of the size of the Alien Sub present on the map). These maps will always have a cockpit to the east, a tail to the west, and various parts in the middle set out according to the shape of a large plane.
Shipping missions: 30x70x4
Port: 50x50x4 If PORT20 is present it will always be placed on the upper right side of the map. PORT2-9 will fill the upper left side to make the shore line.
Island: 50x50x4 ISLAND4, 5 and 7 will be placed on the lower left side of the map to make the coastline.
The GeoScape engine plays it's part by creating five data files in the MissDat folder:
This file holds information on the map's terrain and dimensions, as well as the types of X-COM/Alien craft present and where they are located.
It also contains a list of the map modules in the order that should be used to build the complete world map.
Only certain modules are used as landing sites for the craft present. For each terrain, these are:
UFO TFTD 0: Jungle - 0, 1, 2 0: Seabed - 0, 1 1: Farm - 0, 7,11 1: Pipes - 0 2: Forest - 0, 1 2: Crashed Plane - 0 3: X-COM Base - N/A 3: Atlantis - 0, 1 4: Alien Base - N/A 4: Mu - 0 5: Urban - 3, 4 5: Sunken Galleon - 13,14,15,16 6: Desert - 0, 1, 2 6: Sunken Liner - 0, 1 7: Mountains - 0, 1, 2 7: Volcanic - 0 8: Polar - 0, 1, 2 8: Coral - 0 9: Mars - 0 9: Artefact Site Stage 1 - 0 10: Artefact Site Stage 2 - N/A 11: Cargo Ship - 0 12: Port Attack - 0, 1 13: Island Attack - 0, 1 14: Colony Stage 2 - N/A 15: T'leth Stage 1 - N/A 16: T'leth Stage 2 - N/A 17: T'leth Stage 3 - N/A 18: X-COM Base - N/A 19: Passenger Ship Stage 1 - 1 20: Passenger Ship Stage 2 - N/A 21: Colony Stage 1 - 0, 2, 6
Ships take up rectangular layouts of modules, depending on their size:
UFO TFTD 0 - SkyRanger - 1x2 0 - Triton - 1x2 1 - Lightning - 2x1 1 - Hammerhead - 1x1 2 - Avenger - 1x2 2 - Leviathan - 1x2 3 - Interceptor - 1x1 3 - Barracuda - 1x1 4 - Firestorm - 1x1 4 - Manta - 1x1 5 - Small Scout - 1x1 5 - Survey Ship - 1x1 6 - Medium Scout - 1x1 6 - Escort - 1x1 7 - Large Scout - 2x2 7 - Cruiser - 2x2 8 - Harvestor - 2x2 8 - Heavy Cruiser - 2x2 9 - Abductor - 2x2 9 - Hunter - 2x2 10 - Terror Ship - 3x2 10 - Battleship - 2x3 11 - Battleship - 3x3 11 - Dreadnought - 3x3 12 - Supply Ship - 3x2 12 - Fleet Supply Cruiser - 2x3
Unlike GeoData.Dat (which is primarily used for map generation), most Mission.Dat values are used for end-of-combat results.
It does, however, determine the mission type (Base attack/defense, UFO sites, etc), whether a UFO is present, and the lighting levels. It also holds info on what alien equipment has been researched (and hence can be used by your soldiers) plus the language the Tactical game engine should use. For TFTD, there's also a value determining the depth of the battle (surface, shallow water, deep water, etc).
Contains all the initial equipment that you and the aliens have brought to the battle. If an X-COM craft is present in the map, your equipment is all set to be at the location of your first unit (which can be determined according to the craft location set in GeoData.Dat).
ToDo: Check how X-COM equipment is placed in the case of base missions (which have no dropship).
Alien equipment is assigned to each alien present, then Elerium-115 is placed where ever UPSs can be found (again according to GeoData.Dat. An exception is in alien bases, where every second UPS lacks elerium).
Lists the initial location records of units in play. All units are always alive (including aliens apparently killed by UPS explosions) here.
Usually the location of each unit is unset at this stage, though the exception to this is when you have a dropship present. The GeoScape engine will place each of your troopers/HWPs in their correct location when writing this file (hence the actual spawn nodes for X-COM craft are seldom used).
Here we have the initial statistics of all units in play. Again, all units are alive and well at this stage of map generation.
ToDo: Double check that this file does in fact match the initial UNITREF.DAT.
Having read in all the information about the battle, it's up to the Tactical engine to actually put it altogether and present the mission to the player. The files listed below are only actually written to disk if you save the game, but these are likely the order in which they're created in memory:
The modules listed in GeoData.Dat are put together to create a full sized battlescape map. Once this is done, first X-COM then alien crafts are merged into the map (if need be).
The files stored in the routes folder are loaded in the order defined in GeoData.Dat (again with the X-COM/alien craft being loaded last). These define the spawn points on the map (which the aliens will also patrol between prior to spotting your units).
ToDo: Check if map modules that contain craft have their usual nodes loaded or not. Doubt they do.
At this stage units are placed on the map. If a dropship is present, X-COM units will already have been placed by the GeoScape engine and so the Tactical leaves them alone.
ToDo: Check if there's a value somewhere that determines this, or if the game just goes by whether a dropship is present.
Different unit types tend to spawn on certain nodes: For example, you'll usually find alien commanders in the command center of alien bases. However, if there aren't enough nodes to follow this rule you might find unit types outside their usual areas. If there is a severe node shortage some aliens might not be placed at all (their equipment remains in the object table however, and can still be recovered if you win the mission).
If the mission is against a crashed UFO, all UPSs present in the craft have a 75% chance to explode (assuming the detonation of another UPS doesn't destroy them first). This is performed during a hidden "first turn" (actual game play always begins at turn 2).
Because UPS explosions tend to have very high damage ratings (above any other tactical weapon in the game), they tend to obliterate anything nearby. This always results in the Elerium-115 that was placed in them being destroyed, often causes massive damage to the insides of the UFO, and usually kills any aliens unfortunate enough to be in the blast's path.
For some reason though, the game will often have aliens still alive within a medium scout, despite an almost point blank proximity to the blast. Furthermore, these aliens will either be at full health, or dead. Maximum health and species of alien do not matter, the game merely gives nearby aliens a % chance to die or escape unharmed. This check is only performed on aliens which were determined to be within the blast affects. The blast does NOT DO DAMAGE to aliens. It either kills them, or leaves them unharmed. As proof, on Superhuman difficulty, it is pretty common to see Mutons survive a Blaster Bomb impact, albeit with major damage. However, you will NEVER see a damaged Muton upon beginning a UFO Recovery mission... they start either at full health, or dead, nothing in between. In addition Sectoids and Mutons have similar survival probabilities. In conclusion, it is clear that the UPS explosion is NOT treated the same as a normal explosion in regards to units...
In addition, due to limitations of the game engine (as well as to challenge the player), the aliens will always have at least one or two units left alive. The number of surviving aliens also appears to be randomly determined.
The UPS explosions go off with variable force, as opposed to conventional blasts which never vary. They propagate and deal damage to terrain in the usual manner.
The check to see whether the craft crashed or not is determined by the relevant LOC.DAT record (as defined by MISSION.DAT). The amount of damage done to the craft has no effect on the amount of power supplies that will explode, nor how much damage they'll do.
The final stage before battle begins is where you, the user, get to choose your loadout for your soldiers. You're presented with all items in the initial "equipment pile" and allowed to distribute them as you wish (without the need to ration TUs).
Once this is done, the battle is on!