LOFTEMPS.DAT

From UFOpaedia
Revision as of 11:33, 24 June 2010 by Bomb Bloke (talk | contribs)
Jump to navigation Jump to search

LOFTEMPS.DAT is found in the GEODATA folder. It contains "Line of Fire Templates", used to create 3D representations of the creatures and objects within the battlescape.

The file is made up of multiple 16x16 bitmaps (32 bytes each, one bit per pixel, where 1 is solid and 0 is empty). These are then double layered using the 12 LOF references for each and every tile defined in the MCD files, to create a 16x16x24 3D object.

Units are represented by a single LOF template, usually a round one, which is defined by offset 48 of the UNITREF.DAT record for that unit. This is stacked according to the unit's height (offset 49 or 50, depending on whether the unit is standing or kneeling), to create a cylinder shape. Note that "large" units, which cover four tiles, are made up of four such cylinders.

In UFO there are 112 entries, 3,584 bytes in total (or, in TFTD, 114 entries spanning 3,648 bytes). TFTD stores the LOFTEMPS tables in the TERRAIN folder, but also keeps a copy of UFO's version in its original location - though this old version is unused.


Template Usage

An example of a 3D tree made up of stacked LOF templates. Click for a larger view.

Both UFO and TFTD are presented as 2D games, that is to say, all the images on the screen are made up of sprites. In the battlescape, everything is shown from an isometric perspective.

However, the games are only presented in 2D - much of the actual processing is done on 3D objects (albeit primitive ones). These are defined by stacking the LOF templates stored on this file on top of each other.

When a soldier crouches next to a short wall, for example, he may no longer be able to see over it if his head is now below the top. Likewise, he may or may not be able to see through the slats of a picket fence, depending on what angle he views it from.

Likewise, these 3D objects also come into play when bullets fly though the air. If a unit is hiding behind a tree, the thick foliage will likely protect his head from a bullet aimed high - but a low flying shot may easily go past the thin trunk and get him in the legs.

A soldier's head is positioned slightly higher then the barrel of his gun. For this reason, it is possible for him to be able to see an alien (that is, he has a valid "line of sight"), but not shoot it (because he has a blocked "line of fire").


Template Oddities

Diagonal Processing

If two "solid" points of a template are placed next to each other, horizontally or vertically, then there will be no way to see/shoot between them. This is not the case, however, if they are only connected diagonally. This is why no diagonal "lines" of a single pixel in width exist within the template tables (as they would be very ineffective at blocking sight/bullets).

However, a problem occurs when placing two templates next to each other on the diagonal: You can't "widen" them at the meeting point, so at that exact spot there'll be two "solid" template points that only touch on the diagonal. Units can see/shoot right through these! Quite a few examples of this occur in the wall layout of the Lightning craft, while in (most) other cases such gaps are blocked off using additional tiles.

The below images show the contrast between the Lightning's design, and that of the Medium Scout. Putting aside for now the rather large gap in the north-facing wall of the Lighting's LOFTemps diagram (refer below for more on that), note that the diagonal "holes" (marked in red) do not exist in the Scout, due to the placement of pillars in the gaps. Click the images for a larger view.

(Note that despite this, it is still possible to see/shoot through most of those points if a unit stands in the same tile as a pillar - though the mechanics as to how that works really belongs on the Line of sight. Some of this page may get moved over there later, for now I consider both to be a "work in progress").

Lightning LOFTemps wall layout; top-down view.
Lightning as presented graphically.
Medium Scout LOFTemps wall layout; top-down view.
Medium Scout as presented graphically.

Also to come, more examples - rather more common ones, at that - showing how the points where ceilings meet walls are prone to the exact same problem. This is how your troopers can look out the non-existent windows of your SkyRanger, for eg.

Blatant LOFTemps Bugs

Yet more to come: example images of some of the most obvious LOFTemp errors in the MCD files - such as the floating wall of the Lightning, the big hole under the Triton's wing, the gap in the floor of the Supply Ship, etc...


Template Tables

UFO

Here are the 112, 16x16 bitmaps (white is solid):

Loftemps.png

TFTD

Here are the 114, 16x16 bitmaps (white is solid):

Loftemps TFTD.png


See Also