UNITPOS.DAT

From UFOpaedia
(Redirected from UNIPOS.DAT)
Jump to navigation Jump to search

Stores positioning information for units in the playing field. Each large unit takes four individual records, small units have one record each - there are 80 records of 14 values of one byte each, 1120 bytes in total. It goes hand in hand with UNITREF.DAT.

Comes in three flavours:

  • UNIPOS.DAT

Initially created by the GeoScape engine before tactical battles. Stored in the MISSDAT folder and contains info on all units that will be present in the coming mission (in an alive state - the deaths of aliens killed by exploding UFO power units isn't determined until later). Unlike the other two versions, this only contains the bare minimum number of records required to store the units it details.

All X-COM units are placed in their initial starting locations, assuming a drop-ship is present. All other units (aliens and civilians), however, are not placed until combat actually begins, but this file still contains empty records equal to the amount of units that remain.

  • UNITPOS.DAT

Created along with a battlescape save, contains the mid-mission state of the unit positioning table.

  • UNITPOS.DAT (MissDat version)

Appears in the MISSDAT folder at the end of combat (convention dictates that it should really be called UNIPOS2.DAT). Used to determine which troopers/tanks survived.

Note that records in UNITPOS.DAT do not correspond 1-to-1 to records in UNITREF.DAT: large units have 4 records in UNITPOS, and 1 record in UNITREF. Example:

UNITPOS.DAT            UNITREF.DAT
0: soldier A           0: soldier A
1: soldier B           1: soldier B
2: tank C upper left   2: tank C
3: tank C upper right  3: alien D
4: tank C lower left   4: ...
5: tank C lower right
6: alien D
7: ...

Structure

Offset
(Decimal)
Offset
(Hex)
Usage
0 0x00 Y position. 255 if unit specifically unused.
1 0x01 X position.
2 0x02 Z position. (0 is top level).
3 0x03 ???
4-7 0x04-0x07 A four byte value pointing to the memory location of the corresponding UNITREF.DAT record. Redundant when stored to disk (as it'd need to be re-written as soon as you load the game anyway).
8 0x08 Keeps track of the number of turns since this unit was last spotted by the enemy side. Increments by 1 at the start of the unit's turn, to a maximum of 255 (which is the starting value for your troopers at the beginning of combat). If seen, it resets to 0. A unit is counted as "seen" if an enemy "looks at" the unit during the enemy's turn, or the unit scores a non-psionic attack (damaging or otherwise) on an enemy that fails to kill it outright.

The other way to be seen is if the unit is successfully mind-controlled by the enemy side. Unsuccessful psionic attacks, or successful panic attacks, do not count.

For example, if agent Bob walks in front of an alien during X-COM's turn, he won't be "seen", even if the alien fires a reaction shot at him. If Bob shoots at the alien but misses completely, he still won't be spotted. If he uses an autoshot, which hits the alien three times before killing it, then he will be counted as spotted - even if he shot the alien in the back from over half way across the map.

So long as this value is less or equal to the intelligence stat of any given alien (offset 73 of the alien's UNITREF.DAT record), that alien will "know" where that particular unit is, and may launch psi attacks against him (assuming it has any psi skill).

Note: After turn twenty, this value will reset to 0 at the start of every alien turn, hence allowing them to use psionic attacks against whichever X-COM troopers they wish to target. It appears that later in the game (or against certain races), this may happen after the first turn (observed in a TFTD passenger ship terror mission, 1st Apr 2040, Tasoth race). Full knowledge of how aliens react to this value is unknown (in terms of movement patterns etc), though the Tactical Debug Mode is available for UFO CE if anyone wishes to research the matter. Conjecture indicates that most aliens will head towards spotted X-COM units, as many "come out of hiding" after the twentieth turn.

9 0x09 Owner flag. Possible values:
  0: X-Com
  1: Alien
  2: Civilian
  3: X-Com unit that was left behind on the previous stage of a multiple-stage mission.
10 0x0A Unit info flags. Bits (from left to right, 87654321):
  (  1) 1: 0 = Invisible, 1 = visible (i.e., unit has been spotted by the enemy).
  (  2) 2: 0 = Dead or unconscious, 1 = active.
  (  4) 3: 0 = Small unit, 1 = big unit.
  (  8) 4: 0 = Left section of unit, 1 = right side of unit.
  ( 16) 5: 0 = Upper side of unit, 1 = lower side of unit.
  ( 32) 6: Only seems to flag for certain tank parts. Could be where tank will fire from?
  ( 64) 7: 0 = Normal, 1 = under mind control.
  (128) 8: 1 = when unit has been hit by anything that would damage it { byte referred to during Alien AI phase.}

Ignore bits 4 and 5 if bit 3 is unflagged.

11 0x0B ??? Unknown, never seen it flag.
12 0x0C ??? Unknown, never seen it flag.
13 0x0D ??? Unknown, never seen it flag.

See Also