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

A save game file that has a record size of 124 bytes for UFO, or 132 for TFTD. Values are unsigned unless otherwise stated. Some bytes represent bitfields. There are 80 records (not all of them necessarily used) for a fixed file size of 9,920 bytes (or 10,560 for TFTD). It goes hand in hand with UNITPOS.DAT.

Comes in three flavours:


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.


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


Appears in the MISSDAT folder at the end of combat. Used to determine which troopers/tanks survived, statistic gains via experience, and which aliens need to be hauled off to the Alien Containment unit.

Values are presented according to byte offset (0 to 123 (or 131 for TFTD)) followed by the equivalent hex offset (0x00 to 0x7B (or 0x83 for TFTD)). Notes apply to both UFO and TFTD unless otherwise stated. Let us know what else you can find - refer to the bottom of the page for those values that're unknown, or to the talk page for further ideas as to what they could be.


0 0x00 Type of unit. Unit scream and movement sound effects are based on this and gender. Gender and flying abilities affect the sprites as well. Not turrets. Specifically: [53] & [54] (weapons in hands), [115] (gender) and [120] (other flags) affect the final screen image. If the unit is a large unit, this will also determine the appearance of the last three quarters of the unit. This does NOT affect: the flying ability of the unit, the soldier image in the inventory screen, or the special abilities for certain aliens.
     UFO                                        TFTD
  0: Male/female unarmored X-COM soldier     0: Male/female unarmored X-COM diver   
  1: Male/female personal armor soldier      1: Male/female plastic armor diver
  2: Power/flying suit soldier               2: Power/flying suit diver
  3: Tank                                    3: Tank
  4: Sectoid                                 4: Aquatoid
  5: Snakeman                                5: Gillman
  6: Ethereal                                6: Lobster Man
  7: Muton                                   7: Tasoth
  8: Floater                                 8: Calcinite
  9: Celatid                                 9: Deep One
 10: Silacoid                               0A: BioDrone
 11: Chryssalid                             0B: Tentaculat
 12: Reaper                                 0C: Triscene
 13: Sectopod                               0D: Hallucinoid
 14: Cyberdisc                              0E: Xarquid
 15: Male civilian                          0F: Male civilians
 16: Female civilian                        10: Female civilians
 17: Zombie                                 11: Zombie
255: Unused                                255: Unused

If the corresponding UNITPOS.DAT record is unused, then the record is unused.

1 0x01 Inventory paper doll image. File "UFOGRAPH\MAN_"+(char)(value + 48)+".SPK" will be used as the inventory sprite, unless the value is 0 or 1. In those cases, [115] and [116] are used to determine the picture.
0: No armor.
1: Personal armour.
2: Power suit.
3: Flying suit.
2-5 0x02-0x05 Four byte value pointing to RAM location of the PCK set used by the unit. Re-determined when the save game is loaded.
6-9 0x06-0x09 Four byte value pointing to RAM location of the TAB index for the PCK data used by the unit. Re-determined when the save game is loaded.
10 0x0A Unit facing. Does NOT control HWP turret direction; see [24].
  0: North     (up right)
  1: Northeast (right)
  2: East      (down right)
  3: Southeast (down)
  4: South     (down left)
  5: Southwest (left)
  6: West      (up left)
  7: Northwest (up)
11 0x0B Movement type. When entering a given map location, each tile is checked to see the TU requirements accordingly. MCD[39+UnitRef[11]] is the offset used. Note: By default, this is 0 for ALL unit types.
  0: Walking
  1: Sliding
  2: Flying
12 0x0C Current TUs.
13 0x0D Current Health. Health of 0 = Dead. Compare [42], [120].

For my Bravery experience point testing, I killed 15 of 16 aliens by setting this to zero, and my soldiers to 0 Morale. When I loaded the savegame, the aliens were still "alive" (i.e., up), then all died when I ended this turn. So death is probably only checked when injury happens, and at end of turn... to truly kill them dead on the ground through savegame editing must take more. And arg - when they all died, my soldiers all went to 100 Morale! So I edited them back to 0 Morale. But guess what... then all the aliens died again at the end of next turn, even though they were all on the ground (I heard screams, and all soldiers' Morale went to 100 again). What the heck? The aliens stayed down after that, though. --MikeTheRed 16:01, 3 November 2006 (PST)

Update: UNITPOS.DAT offset 10 bit 2 should be used to kill a unit entirely dead. Thanks, NKF & BB - MTR

While the game kills characters when Health<=Fatal Wounds (__ dies message), XComUtil will recover them based if their health is greater than 0. Haven't tested an unmodified game. --Zaimoni 11:52, 14 April 2007 (CDT)
14 0x0E Current Stun level how much falloff of paralysis every turn? What determines it?
15 0x0F Current Energy
16 0x10 Current Reactions NKF: affected by health percentage
17 0x11 Strength
18 0x12 Current Front Armour
19 0x13 Current Left Armour
20 0x14 Current Right Armour
21 0x15 Current Rear Armour
22 0x16 Current Under Armour
"Base" means the original (total) value (as carried forward from geoscape) - Also see Note 1 re: Base soldier stat values.
23 0x17 Base Firing accuracy. Current value = this * [13]/[26] (percent health)
24 0x18 Base Throwing accuracy. Current value = this * [13]/[26] (percent health)

Note: Tanks (turreted units?) always have 0 throwing accuracy. They use this for turret facing, relative to unit facing. 0 means it's facing forwards. Additional values are clockwise increments; see [10].

25 0x19 Base TUs
26 0x1A Base Health
27 0x1B Base Energy
28 0x1C Base Reactions
These Base Armour values are used to show the starting armor value in the Attributes screen (so you can readily see if it's been damaged
29 0x1D Base Front Armour
30 0x1E Base Left Armour
31 0x1F Base Right Armour
32 0x20 Base Rear Armour
33 0x21 Base Under Armour
34 0x22 Supposedly this was going to be Health Recharge which would function like the Energy Recharge. Always 0 and ignored by game.
35 0x23 Energy to recharge each turn. Equals recruit initial TUs/3 (SOLDIER.DAT[43], not total base TUs). This is a signed byte. See Time Units and Energy Usage; also see [45] (energy usage when walking/turning). BombBloke: Is this affected by damage?
36 0x24 Supposedly this was going to be Armor Recharge which would function like the Energy Recharge. Always 0 and probably unused, but needs testing.
37 0x25 Psi skill. Psi stats not displayed/usable until this is greater then 0.
38 0x26 Item to create when unit is unconscious/dead (index into obdata.dat).

NKF: If you set this value to that of a usable item, the item that is created in place of the unconscious or dead soldier can be used like the ordinary item. Elerium pods, for example, can be recovered for 50 elerium each after the battle. Weapons can be used as you normally use them, etc.

For unconscious 'units', the item will be treated as the unconscious body - it will retain the name of the unconscious unit when looked at via the inventory screen. Picking up and using the 'item' will work, but when the unit wakes up, the 'item' image in the soldier's hands is not cleared, even though the item no longer 'exists' in the soldier's hands. Using this 'item' will just crash the battlescape.

Actually, I do not even want to think about what would happen if you 'prime' a grenade/stunned body.

39 0x27 "Soldier value" a.k.a. victory points. You gain (or lose, as the case may be) score at the end of combat according to this value when the unit dies.
  • For X-COM units: A soldier with 42 will be worth -42 points if killed. Note this doesn't seem to apply if the soldier is killed when unconscious. The soldier just vanishes.
  • For aliens: A commander with 35 will give you +35 points if killed.
  • This value is the same as SOLDIER.DAT bytes 15-16 (a Word) and equals:
   20 + Missions + Rank Bonus
   with Rank Bonus as follows: SGT +1, CPT +3, COL +6, CDR +10

Note that although this equation holds true, the value is not actually computed per se. Instead, 1 is added directly to it each mission, as is a rank-bonus delta if you advance (e.g. COL to CDR, delta +4). In other words, hacking the Missions or Rank fields does not affect this value.

40 0x28 Index into SOLDIER.DAT, so game knows what to update. 255 = does not belong to anyone (i.e., it's not a soldier). NKF: This byte is critical for player controlled units. If this doesn't refer to anything, the unit ceases to exist at the end of the game. If it points to a valid soldier entry in soldier.dat, the soldier.dat entry will be updated.
41 0x29 Animation frame counter for the unit. Used by eg Celatids and Silacoids.
42 0x2A Rank. Affects morale loss and interface icon (hull for tanks). Only X-COM troopers display rank icons.
     0: Rookie   Civvies are 0 too
     1: Squaddie
     2: Sergeant
     3: Captain
     4: Colonel
     5: Commander
   255: Dead/unused
     1: Commander
     2: Leader
     3: Engineer
     4: Medic
     5: Navigator
     6: Soldier
     7: Terrorist
   255: Dead/unused
   Hull shape for X-COM tanks:
     0: Treaded
     1: Hover

I don't see 255 set for three dead mutons in a current game... [13] (Health=0) seems to be the only reliable death indicator for them. Compare [120]. -MikeTheRed

43 0x2B Called "deployment" with values of 0 or 1 (0=normal, 1=special).
0: Only those locations specified for units of the appropriate rank, size, and flying ability are used. 
1: Civilian spawn points are used, ignoring a unit's rank, but still selected by the unit's size and flying ability.

As result - Commanders/leaders can occasionally be spawned outside of the UFO craft (and ramble around the UFO) and not in the "control room", which has an exclusive commander spawn node.

44 0x2C Alien aggression. The higher it is, the less likely an alien will take cover. Maximum of 2. 0=Cautious,1=Normal,2=Aggressive MTR: This is true for aliens in Hobbes game, but soldiers have values from 4 to 254. Garbage? Delete this comment if so. This determines the amount of the unit's TUs that are devoted to shooting: 0=50%,1=60%,2=66%.
45 0x2D Used to calculate energy loss when walking or turning as: INT( TUs / 2[45] ). See Energy#Usage; compare [35] (energy recharge per turn). Set this byte to 4 to ensure no energy use whatsoever (maximum map tile TU cost is 12). In Hobbes game, many aliens are 0 and all soldiers are 1, but a dozen aliens have higher values ranging all the way up to 112! Garbage and/or the game doesn't care if they are garbage?
46 0x2E HWP turret image. Only used (and only appears) if unit type [0]=3 (X-COM tanks):
   0: Cannon
   1: Rocket
   2: Laser
   3: Plasma
   4: Blaster
   5,6: ? Blanks

Note: For non-tanks, this controls the inventory layout. Only 0 and 1 are valid. 0 is the standard layout seen on all soldiers. 1 is an alternate layout that may have been intended for custom tank equipment. Larger values only crash the game due to missing files. Also see [113] and [117].

47 0x2F This is a direct copy of offset[48] from the MCD record of the tile the unit is standing on. A signed byte.
48 0x30 Values for this byte always equal [52] and are:
  2  (3x3 square; legacy 5 pixels):  Sectoid
  3  (5x5 square, corners removed; legacy 7 pixels):  Celatid, Chryssalid, Civvie,
     Ethereal, Floater, Muton, Snake, Soldier
  4  (7x7 octagon; legacy 9 pixels):  Cyberdisc, Hovertank, Reaper, Sectopod, Tank
  5 (9x9 square, Ls with 3-pixel legs removed; legacy 11 pixels):  Silacoid

Based on copious research by Bomb_Bloke, Seb76, Zombie, and others, this has been found to be a LOF Template look-up for the shape of targets; Loftemps 2 to 5 define the "3D" shape of units relative to Line Of Fire as a cylinder, where 2 (Sectoid) is a thin cylinder and 5 (Silacoid) is very wide. The pixel width of each "silhoutte" that LOFTEMPS.DAT corresponds to has been added to the list above (see LOFTemps images 2-5). Tiles are 16 pixels wide in the X or Y direction (that's what this byte is about), and 24 pixels high (compare [49]).

This cylindrical shape is used in conjunction with height [49] to define the silhouette that targets present to a shooter. Combine the pixel-width cross-section from Loftemps with height to find the cross-sectional area presented to shooters (sorted on increasing cross-section):

                    LOF     LOF             Cross    Percent
                   Lookup  Width   Height  Section   of 384    Float   4x?
Type               UR[48]  Pixels  UR[49] Pxls X Ht  (16x24)   UR[51]
----               ------  ------  ------ ---------  -------   ------  ---
Sectoid               2       5      16       80      20.8%       -     -
Celatid               3       7      12       84      21.9%       6     -
Soldier (Kneeling)    3       7      14       98      25.5%       -     -
Hovertank             4       9      12      108      28.1%       6    Yes
Silacoid              5      11      10      110      28.6%       -     -
Snakeman              3       7      18      126      32.8%       -     -
Zombie                3       7      18      126      32.8%       -     -
Ethereal              3       7      20      140      36.5%       -     -
Cyberdisc             4       9      15      135      35.2%       2    Yes
Chryssalid            3       7      21      147      38.3%       -     -
Civilian              3       7      21      147      38.3%       2     -
Floater               3       7      21      147      38.3%       2     -
Muton                 3       7      21      147      38.3%       -     -
Tank                  4       9      16      144      37.5%       -    Yes
Soldier               3       7      22      154      40.1%       -     -
Reaper                4       9      23      207      53.9%       -    Yes
Sectopod              4       9      23      207      53.9%       -    Yes

Units take up an amount of the whole tile (as seen in cross-section by a shooter) as shown in the "Percent of 384" column. In reality, though, the accuracy of shots makes this a more complex topic than the percents suggest. Also, dividing by 384 is an oversimplification, since it implies a directly rectangular shot (shooting right down the X or Y axis). While it's useful to see, keep in mind that this column only shows relative numbers.

Zaimoni: actual cross section depends on shot facing. The table is close to correct for pure diagonal shots, so leaving alone for now.

The unit Float number ([51], below) is shown simply for convenience. It does not enter into the cross-sectional computations. "4x" units actually consist of four units grouped in tight 2x2 formation (making their cross section effectively much larger then the percentage stated).

Note that causing an X-Com soldier to kneel causes their cross section to fall by 36.36~% of that of when they are standing.

49 0x31 Standing height.
50 0x32 Kneeling height.
51 0x33 Floating height. A unit 'floats' this high above the ground, thus allowing shots to fly underneath. The highest point of a unit can be found by adding this to the units height stat. Does this have an effect on explosive damage?
52 0x34 "Radius" of LOF Template. Always the same as [48] in all known saved games. More info can be found at Talk:UNITREF.DAT#Offsets_0x30_&_0x34 ([48] and [52]).
53 0x35 Image index for item in left hand. 255 for none. Indexes into OBDATA.DAT, not OBPOS.DAT.
54 0x36 Image index for item in right hand. 255 for none. Indexes into OBDATA.DAT, not OBPOS.DAT.
NKF: If there is no item in the unit's hands, but one of the above two bytes are set, the 'image' that represents the item will still be displayed in the battlescape. If these phantom items are clicked on, the game crashes. If the image is not the right type for the real item in hand, the ammo count doesn't get displayed. Otherwise, it'll work as normal.
55 0x37 Damage Modifier Category

This field is simply a look-up table, or more directly, a way to categorize the units into similar groups. The actual modifiers are listed in the executable. A value of 1 indicates the first DM category, a value of 4 indicates the 4th, etc. The values of 2 and 3 are not seen in the alien stats as they refer to X-COM soldier armor info.

 Value    Unit Type(s)
   0      Terrain and Items
   1      Civilian, Sectoid, Celatid, Floater
   2      Personal Armor
   3      Power Suit, Flying Suit
   4      Tanks, Hovertanks
   5      Snakemen
   6      Ethereal
   7      Muton
   8      Silacoid
   9      Chryssalid
  10      Reaper
  11      Sectopod
  12      Cyberdisc
  13      Zombie
56 0x38 Melee Accuracy (SOLDIER.DAT bytes 50 (initial) & 60 (increase) added together)
57 0x39 Psionic Strength
58 0x3A Current Morale. Base morale is hardcoded to 100.
59 0x3B Bravery = 110 - (10 * this value)
60 0x3C Panic mode. This takes effect at the start of the unit's next turn. Since it is cleared at that point, you'll never see it at anything other then 0 in the save files. You can manually change it to other values to force a specific panic attack on the next turn.
  0: None
  1: Freeze
  2: Running
  3: Berserk
61 0x3D [62] will increment by this amount whenever the unit moves.
  3: Sectiod                                    - Hobbes
  4: Soldiers, civs, and all other aliens (but Hobbes had no Large aliens)
 30: Tank/Laser
62 0x3E Visibility via motion scanner. The bigger it is, the bigger the blip. Test this one out for values.
63 0x3F Number of Fatal Wounds to head.
64 0x40 Number of fatal wounds to torso.
65 0x41 Number of fatal wounds to right arm.
66 0x42 Number of fatal wounds to left arm.
67 0x43 Number of fatal wounds to right leg.
68 0x44 Number of fatal wounds to left leg.
69-70 0x45-0x46 Indexes into ROUTES.DAT. To start with, aliens will be located at the same position as the node indicated by byte 69.
For patrol AI (no X-COM units sighted in turn 1, either X-COM or alien):
Byte 69 is the index of the node of the start of the planned move.
Byte 70 is the index of the node of the end of the planned move.
Note that the move may be multi-turn, and byte 69 is not guaranteed to update during a multi-turn move. I think it will if the alien ends its move on a node, however. -- Zaimoni
For AI mode 2:
Byte 70 is the UNITPOS reference number for this unit's target. - Tycho
71 0x47 Unit lighting: always 16 for XCom units, 0 for most aliens but 1 for cyberdisc. If greater than 1, it is set to 1 when unit inactive - see the Talk page.
72 0x48 The amount of Morale that has been restored using the Medkit's painkillers. The amount that can be restored is equal to the maximum health of the unit (index 26) minus their current health (index 13) further minus this.
73 0x49 Intelligence. Rated from 2 - 8. Indicates for how many turns the alien will know the location of spotted soldiers. Hey - why do humans have zero intelligence? :(
74 0x4A AI Mode. Zaimoni found Here that the values are
5:Returning to UFO.
255 (-1): Makes the program recalculate the AI mode.
75 0x4B Unknown. With that said, the only item remaining on my list is called "lightdirect" or direction of light for a unit (0=all around, 1=direction unit facing). Unused by game code and always 0. Maybe it was for a hand-held light source, or a armor-mounted flashlight?
76-77 0x4C-0x4D Mission count. Signed integer (low byte, high byte) also found in SOLDIER.DAT MTR: Wonder why they bothered to put this in Unitref since this will never change during a mission; compare how soldier stats are actually read from SOLDIER (not UNITREF) on return to geoscape. Is Missions shown anywhere on the combatscape?
78-79 0x4E-0x4F Kill count. Signed integer (low byte, high byte) also found in SOLDIER.DAT. Number of kills this unit has made for ALL missions, not just this one. This one can vary "unpredictably" and thus is the only byte known to directly carry forward into the geoscape / Soldier.Dat!
80 0x50 Reactions experience counter, for number of reaction shots. It doesn't matter if they hit the target; reactions still count. See Note 2 re: Experience counters. (Also note: Aliens do not use experience counters.)

NKF: Where does death by fire (overexposure rather than incendiary shell impact) fit into the experience counters? It becomes a non-assigned kill, I guess, like death by wounds, or death by a grenade that hasn't got an owner?

81 0x51 Firing Accuracy experience counter, for number of hits on an enemy (lethal or not, grenades or bullets). Each Autoshot hit counts as 1, so you can get 3 hits from one Autoshot burst. Likewise, grenades and blaster bombs can hit multiple targets with one explosion. Also, if you miss the intended target but hit a different alien, it still counts. Finally, if your shot actually has zero Damage, it does still count as a hit. (Not due to armor blockage; a pure roll of 0 coming out of the gun.)
82 0x52 Melee Accuracy experience counter, for number of times stun rod has been used (not stun bombs).
83 0x53 Throwing Accuracy experience counter, for number of times unit has thrown any object.
84 0x54
Psionic Skill experience counter, for number of psi attacks performed. 1 is added if attempt was unsuccessful, 3 if it was successful. Note: if this value goes over 255, all psi experience is lost. That's 85 successful psis (255/3). So be careful of marathon psi'ing (a minimum of 43 turns at 2 psis/turn, 29 turns at 3/turn).
85 0x55 Bravery experience counter, for number of times unit has resisted panicking, despite Morale < 50. Being mind-controlled, panicking, or going berserk does not increase this stat -- although Panic Unit attacks will reduce Morale to the point where panic checks will be performed by the game.
86-110 0x56-0x6E Unit's Name. Standard string ended by null byte. The rest can hold garbage.
111 0x6F Called "BigFire". If true (value of 1) then the unit is currently firing a weapon. It reverts back to 0 afterwards - determines whether to render the gun and firing arm in the "pointing weapon" position, or whether the weapon is being held against the chest. If manually set to a value above 0, the unit will hold its weapon out until such time as it actually uses it.

Note that this value is only used by units holding two-handed weapons. A unit holding for eg a pistol will always point the weapon, and uses a different arm sprite for the purposes of doing so (regardless of whether or not the weapon is being fired).

112 0x70 Called "Finished". If true (value of 1) signifies that the unit finished AI actions for current turn.
113 0x71 If 1, then you can't use the inventory button and the unit will be immune to stun. Used for tanks. Mind controlled units don't use this but their button disables anyway.

BombBloke: This is the only way to access tank inventories.

  • Tank/Cannon has a normal inventory and uses man_1m0.spk.
  • Tank/Rocket Launcher has a different layout and uses man_1m0.spk.
  • Tank/Laser Cannon uses man_œ.spk, which doesn't exist normally. Providing this file still crashes.
  • Hovertank/Plasma simply crashes.
  • Hovertank/Launcher simply crashes.

[1] actually determines the inventory screen used, might be worth playing with that. [46] determines the layout.

114 0x72 If not 0, then unit is on fire, and will burn for this amount of turns.
115 0x73 Gender: 0 = male, 1 = female.
116 0x74 Hair/skin colour (for inventory; all other units = 0):
  0: Blond caucasian
  1: Brunette caucasian
  2: Asian
  3: Black
117 0x75 Turret weapon. Over-rides hand held weapon. Turret images are not centered; that would be impossible because they aren't all 'objects' (e.g. Celatid). (Mix of notes by BB and NKF)
                                                      F.A.  TUs        F.A.  TUs
  0: HWP cannon (bigobs[40])....................Aimed  90%  80%   Snap  60%  33%
  1: HWP rocket (bigobs[42])....................Aimed 115%  75%   Snap  55%  45%
  2: HWP laser (bigobs[54]).....................Aimed  85%  75%   Snap  50%  33%
  3: HWP plasma cannon (bigobs[43]).............Aimed 100%  60%   Snap  86%  30%
  4: HWP blaster (bigobs[43]) (looks like ordinary cannon?)......Aimed 120%  80%
  5: Celatid plasma cannon (bigobs[38]).........Aimed 110%  60%   Snap  75%  30%
  6: Cyberdisc plasma cannon (bigobs[34]).......Aimed 110%  60%   Snap  75%  30%
  7: Sectopod Laser* cannon (bigobs[34])as cyberdisk, above, plus Auto  50%  35%
 22: Invalid - Incredibly powerful armour piercing shell. Overpowering.
255: Unused

Note: This item will take precendence over any item carried in the hand slots. It can be installed on non-tanks, but then the unit won't be able to use any carried weapons or items. This weapon is NOT affected by the kneeling modifier, but it is affected by the current unit's accuracy stat. Also note, this byte does NOT determine the turret image for HWPs in the battlescape.

[*]The damage type for the Sectopod is indeed set to (3)laser in the executable! Graphical/sound effects of a turret weapon is set there as well, via a reference to a weapon in OBDATA.DAT (HWP Cannon=4=Heavy Cannon, Sectopod=34=Heavy Plasma) When I changed HWP Cannon to 2, it looked/sounded like rifle fire - Crus8r

Also see [46], [113], and [118].

118 0x76 Ammo for [117] turret weapon
119 0x77 [Garbage unused by game] Movement related? Large unit related? Possible bitfield.
00000000   0 Chryssalid(2), Civilian(9), Ethereal(2), Floater(2), Muton, 
00000001   1 Muton, PA Soldier(2)                   Sectoid(2), Silacoid(2), 
00000011   3 PA Soldier                            PA Soldier(2), Tank/Laser
00000101   5 Snakeman
00001010  10 Celatid             - Hobbes game - could have some garbage
00001101  13 Muton, PA Soldier     (parens) is count, if more than 1 unit
00010011  19 Snakeman
00100110  38 PA Soldier
00101010  42 Muton(3)
00110001  49 Muton
00110010  50 PA Soldier
00110101  53 Silacoid(2)
00111011  59 Celatid
00111111  63 Silacoid
01001110  78 PA Soldier
01100111 103 PA Soldier
01111111 127 Muton
10010000 144 Muton
11000000 192 Celatid
11111110 254 Muton
120-123 0x78-0x7B Unit bit flags (32bit), mainly re: mobility. They do NOT affect the soldier in inventory screen: (Mix of notes by BB and NKF)
(  1) 1: 1 = Unit moving.
(  2) 2: 1 = Unit can fly.
(  4) 3: 1 = Unit is flying. (Toggles leg sprites for power armour.)
(  8) 4: 1 = Has been to this unit in next unit loop. Or to put it another way, has the unit been selected this turn.
( 16) 5: 1 = Unit has been disabled for selection.
             (Stops the unit tab button from selecting this soldier.)
( 32) 6: 0 = Unit has left hand object selected, 1 = right hand object selected.
( 64) 7: 1 = Unit is kneeling.
(128) 8: 1 = Unit is wearing power/flying suit. (Can't be stunned by smoke flag? 
             Seems to work for fire, too.)

If a unit is carrying something in either hand, it is impossible to get him to appear as if he is carrying nothing - in the game, at least. If he is carrying nothing, bit 6 can flag (as though the unit was using it's right hand item). But maybe it's just the order of dropped items affecting this?

Note: A unit is only considered as flying if it is not on the ground. For example, a hover tank is not always considered as flying.

What if a hovertank is half on the ground, half in the air? What about a treaded tank, or large alien unit? What about units in lifts?

124-125 0x7C-0x7D TFTD ONLY - Bubble animation count for soldiers. Can be 0 to 16 (0x0F).
126-127 0x7E-0x7F TFTD ONLY - Bubble animation delay, skips this amount of frames.
128-129 0x80-0x81 TFTD ONLY - Bubble animation enable. (0=disable, 1=enable) - [unused by game - taken from "underwater" flag]
130-131 0x82-0x83 TFTD ONLY - Called "floorabove" flag. Is there a floor above unit? (0=no, 1=yes) [unused by game - calculated on-fly]


1) The original/base values for soldier stats (offsets [23]-[28], etc.) correspond to the initial+increase bytes from Soldier.Dat (bytes 43-62). Changes to these Unitref bytes are lost when the mission ends; instead, XCOM re-reads them from Soldier at that time. This makes sense because base soldier stats don't change during a mission per se (although they might increase when the mission ends); in this way, the programmers didn't have to bother with separately storing and/or adding initial+increase during combat. (It's also why you don't see the initial+increase in the soldier stat display during combat, that you can see back at base.) On a practical note, if you are testing soldier stat increases versus experience counters, change the experience counters in Unitref, but change the soldier stats in Soldier. (IOW, it doesn't matter what the soldier stats are in the combat mission.)

The Kill count (offset [78-79]) is the only Unitref value I know of that is directly carried forward into the geoscape and Soldier.dat. However, some others do indirectly carry forward, for example: experience (offsets [80]-[85]) causes stat and rank increases, and decreased health (offset [26] - offset [13]) means hospital time. And, of course, death is permanent. Heh.

2) Experience counters (offsets [80]-[85]) determine the likelihood of soldier stat increases at the end of the combat mission, according to the formula for Primary Stats shown here. The Bravery counter (offset [85]) affects Bravery as shown here.

Also, if at least one of the experience counters (except Throws) has a count, your secondary stats will increase, as discussed here. All you need is at least a 1 in offsets [80]-[82] or [84]-[85]; more than 1 and/or multiple counters has no additional effect.

3) BombBloke's additional "To be Done" notes - can we cross some of these off yet?

  Need to research:
  Stun recovery rate, does it exist?
  Hand to hand attacks
  Offset of weapon from unit image? 
  Based on unit height and nothing else. There may be values to determine what arm sprites to use,
  but I doubt it.
  Firing sprite offset? 
  Probably just based on unit height and some hardcoded values in the executable.
  Inventory lockout? All mind controlled units are locked out.
  Kneel lockout? 
  Probably the same as above, I seem to remember that using XcomUtil to "swap sides" would make it
  possible to kneel small alien units.
  Aliens seen? Not used in unitref.dat, only in unitpos.dat. -Zombie 23:48, 29 September 2006 (PDT)
  Whether a unit slides/floats/hovers/rolls/walks (movement noise)? Set according to unit type.
  What else? The more to look for, the easier it is...
  Know 119 values.
  Unknown values (5 in total):
  [075 / 0x4B] - Always 0?
  [119 / 0x77] - No idea, possible bitfield, could be anything.
  [121 / 0x79] - Second unit gets a value of 16. Everyone else gets 0. No obvious purpose.
  [122 / 0x7A] - Always 0?
  [123 / 0x7B] - Always 0?

4) Hobbes posted a savegame with a TON of different aliens in it here (message 6). Interesting for testing. But note it was made with XCOMUTIL and there may(?) be concerns over vailidity of unit info - see Talk:UNITREF.DAT.

5) A Hex Workshop Structure Library for UNITREF.DAT created by Danial is here.

For More Information

Return to Saved Game Files