Difference between revisions of "UNITREF.DAT"

From UFOpaedia
Jump to navigation Jump to search
(→‎Structure: Relinking. Why, oh why must there always be multiple links to the same page on huge pages? Murphy's Law?)
Line 12: Line 12:
 
   4: Sectoid                                        4: Aquatoid
 
   4: Sectoid                                        4: Aquatoid
 
   5: Snakeman                                        5: Gillman
 
   5: Snakeman                                        5: Gillman
   6: Etheral                                         6: Lobster Man
+
   6: Ethereal                                         6: Lobster Man
 
   7: Muton                                          7: Tasoth
 
   7: Muton                                          7: Tasoth
 
   8: Floater                                        8: Calcinite
 
   8: Floater                                        8: Calcinite

Revision as of 04:03, 15 January 2010

UNITREF.DAT has a row width of 124 bytes for UFO, 132 for TFTD. Bytes are unsigned, except for Missions and Kills. 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). The same format is used by the files UNIREF.DAT and UNIREF2.DAT. These are images of UNITREF.DAT saved in MISSDAT as of, respectively, the beginning of the last "live" combat game (i.e., not loaded from a savegame) and the last finished combat.

Values are presented according to byte offset (0 to 123) followed by the equivalent hex offset (00 to 7B) in bold. Notes only apply to UFO (as opposed to TFTD) unless otherwise stated. Let us know what else you can find!!

Structure

0 / 00: 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                                       10: BioDrone
 11: Chryssalid                                     11: Tentaculat
 12: Reaper                                         12: Triscene
 13: Sectopod                                       13: Hallucinoid
 14: Cyberdisc                                      14: Xarquid
 15: Male civilian                                  15: Male civilians
 16: Female civilian                                16: Female civilians
 17: Zombie                                         17: Zombie
 18: Unused (but it made the sound of a tank?)
255: Unused

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

1 / 01: 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, unitref[115] and unitref[116] are used to determine the picture.

0: No armor.
1: Personal armour.
2: Power suit.
3: Flying suit.

2 / 02: Bitflags. NKF: Seems to be consistent with different character models. MTR: I pulled those out of Hobbes' savegame (see Note 4). There seems to be some differences. Could it be a dynamic byte instead of e.g. static relative to model or whatever?

     87654321
NKF: 00100100   36 Floater
     10000000  128 Personal armour
     10001100  140 Power suit/flying suits
     11101000  232 Reaper
 BB: 00010000   16 Hovertank/Plasma
     00111000   56 Psi unlocked soldier in flying suit
     00110000   48 Psi locked soldier in kevlar
     01010000   80 Aliens
     01010100   84 Cyberdisc
MTR: 00000100    4 Celatid
     00100100   36 Chryssalid, Civvie, Ethereal, Floater, Muton, Snakeman, 
     11011100  220 Sectoid                          PA Soldier, Tank/Laser
     11111000  248 Silacoid       
     
     (  1) 1: ?
     (  2) 2: ?
     (  4) 3: Common to Cyberdiscs
     (  8) 4: Common to flying suits
     ( 16) 5: Common to all units
     ( 32) 6: Common to X-COM troopers
     ( 64) 7: Common to all enemies
     (128) 8: ?

3 / 03: Bitflags:

     87654321
NKF: 00101110  46 Pers. armor
     10000101 133 Floater
     10111111 191 PS/FS
     11101100 236 Reaper
 BB: 00100100  36 Psi locked soldier in kevlar
     01010000  80 Hovertank/Plasma
     10000001 129 Cyberdisc
     10100101 165 Aliens
     10110101 181 Psi unlocked soldier in flying suit
MTR: 00000000   0 Chryssalid     - from Hobbes' savegame
     00000100   4 Celatid
     00100000  32 Floater
     00110000  48 Muton, Snakeman, Tank/Laser
     01110101 117 Sectoid
     10100000 160 Ethereal
     10110000 176 Civilian, PS (Power Suit) Soldier
    
     (  1) 1: ?
     (  2) 2: ?
     (  4) 3: Small units
     (  8) 4: ?
     ( 16) 5: Flying X-COM units
     ( 32) 6: Small units
     ( 64) 7: ?
     (128) 8: ?

4 / 04: Possible bitflags.

     87654321
NKF: 10010001 145 PS/FS
     10011011 155 PA Soldier, Floater, Reaper
 BB: 01100001  97 Hovertank/Plasma, Psi unlocked soldier in flying suit
     01100010  98 Psi locked soldier in kevlar, Cyberdisc, Aliens
MTR: 00100000  32 Silacoid       - Hobbes' game
     00100100  36 Celatid, PA Soldier, Tank/Laser
     00100101  37 Civilian, Muton, Snakeman
     01010011  83 Sectoid
     01011111  95 Chryssalid, Ethereal, Floater

5 / 05: Flags 1 for units in play, 0 otherwise. Possible bitflags.

6 / 06: Possible bitflags.

     87654321
NKF: 00000000   0 Reaper
     00010000  16 Pers. armor
     00100000  32 PS/FS
     01010000  80 Floater
 BB: 01000000  64 Psi unlocked soldier in flying suit
     01010000  80 Hovertank/Plasma
     11000100 196 Aliens
     11010100 212 Cyberdisc
     11101000 232 Psi locked soldier in kevlar
MTR: 00000100   4 Chryssalid        - Hobbes' game
     01000000  64 Floater
     10000100 132 Muton
     10000100 132 Snakeman
     10010100 148 Ethereal
     10011000 152 Tank/Laser
     10011100 156 Soldier psi locked in a power suit
     10101000 168 Celatid
     10101100 172 Sectoid
     11011000 216 Civilian
     11100100 228 Silacoid
     
     (  1) 1: ?
     (  2) 2: ?
     (  4) 3: Enemies
     (  8) 4: ?
     ( 16) 5: Large units
     ( 32) 6: ?
     ( 64) 7: Always flagged?
     (128) 8: ?

7 / 07: NKF:

     87654321
 BB: 00000000   0 Hovertank/Plasma
     00010000  16 Cyberdisc
     00010001  17 Psi unlocked flying suit troopers
     00101011  43 Sectoid
     00101101  45 Psi locked kevlar troopers
MTR: 01001110  78 Chryssalid, Floater    - Hobbes' game
     01111011 123 Tank/Laser
     01111100 124 PA Soldier 
     01111101 125 Sectoid
     01111110 126 Civilian
     11001011 203 Ethereal
     11011111 223 Celatid, Silacoid
     11111011 251 Muton, Snakeman
     
     (  1) 1: Small units
     (  2) 2: Small aliens
     (  4) 3: Psi locked kevlar troopers
     (  8) 4: ?
     ( 16) 5: ?
     ( 32) 6: ?
     ( 64) 7: ?
     (128) 8: ?

8 / 08: Same for all units? (171) (11000011)

     87654321
MTR: 00010011  19 Celatid, Silacoid   - from Hobbes
     00011110  30 Civilian, Muton, Snakeman, PA Soldier, Tank/Laser
     01001110  78 Sectoid
     01011001  89 Chryssalid, Ethereal, Floater
Zaimoni: Bit 3 (significance 4) sometimes changes during alien turn/patrol AI.

9 / 09: Always 0?

10 / 0A: Unit facing. Does NOT control HWP turret direction; see [024].

  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 / 0B: 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 / 0C: Current TUs

13 / 0D: 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 / 0E: Current Stun level how much falloff of paralysis every turn? What determines it?

15 / 0F: Current Energy

16 / 10: Current Reactions NKF: affected by health percentage

17 / 11: Strength

18 / 12: Current Front Armour

19 / 13: Current Left Armour

20 / 14: Current Right Armour

21 / 15: Current Rear Armour

22 / 16: Current Under Armour


"Base" means the original (total) value (as carried forward from geoscape) - Also see Note 1 re: Base soldier stat values.

23 / 17: Base Firing accuracy. Current value = this * [013]/[026] (percent health)

24 / 18: Base Throwing accuracy. Current value = this * [013]/[026] (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 [010].

25 / 19: Base TUs

26 / 1A: Base Health

27 / 1B: Base Energy

28 / 1C: Base Reactions

29 / 1D: Base Front Armour

30 / 1E: Base Left Armour

31 / 1F: Base Right Armour

32 / 20: Base Rear Armour

33 / 21: Base Under Armour

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

34 / 22: Always 0?

35 / 23: 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 / 24: Always 0?

37 / 25: Psi skill. Psi stats not displayed/usable until this is greater then 0.

38 / 26: Item to create when unit is unconcious/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 / 27: "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 / 28: 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 / 29: BombBloke: Something to do with large units. Changes during gameplay. Have seen values of 2, 3, 5, 6.

42 / 2A: Rank. Affects morale loss and interface icon (hull for tanks). Only X-COM troopers display rank icons.

   X-COM
     0: Rookie   Civvies are 0 too
     1: Squaddie
     2: Sergeant
     3: Captain
     4: Colonel
     5: Commander
   255: Dead/unused
   
   Aliens
     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 / 2B: 0 or 1? In Hobbes' savegame, civvies and sectoids are 1. All others are 0 (soldiers, aliens, terrorists, tank).

MTR: If the next byte is "aggression", and civvies and sectoids have a 1 here, could this be "cowardliness"? Likelihood to panic; to do something dumb/random? We've all seen civvies running around in a mad / random panic.

44 / 2C: Alien aggression. The higher it is, the less likely an alien will take cover. Maximum of 2. MTR: This is true for aliens in Hobbes game, but soldiers have values from 4 to 254. Garbage? Delete this comment if so.

45 / 2D: 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 / 2E: HWP turret image. Only used (and only appears) if unit type [00]=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 / 2F: This is a direct copy of offset[48] from the MCD record (see TERRAIN) of the tile the unit is standing on. A signed byte.

48 / 30: Values for this byte always equal [52] and are:

  2  (5 pixels):  Sectoid
  3  (7 pixels):  Celatid, Chryssalid, Civvie, Ethereal, Floater, Muton, Snake, Soldier
  4  (9 pixels):  Cyberdisc, Hovertank, Reaper, Sectopod, Tank
  5 (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.

The unit Float number (Unitref[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 / 31: Standing height.

50 / 32: Kneeling height.

51 / 33: Floating height. A unit 'floats' this high above the ground, thus allowing shots to fly underneath. The heighest point of a unit can be found by adding this to the units height stat. Does this have an effect on explosive damage?

52 / 34: Always the same as [48] in all known saved games. XCOMmies are trying to test its significance, as seen at Talk:UNITREF.DAT#Offsets_0x30_&_0x34 ([48] and [52]).

53 / 35 and 54 / 36: Image index for item in left and right hand, respectively. 255 for none. Indexes into obdata.dat, not obpos.dat.

NKF: If there is no item in the unit's hands, but these 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 / 37: 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. I'm not sure about 13 as the Zombie's stats haven't been found yet, but I think there is a category in the DM's for it.

 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 / 38: Melee Accuracy (SOLDIER.DAT bytes 50 (initial) & 60 (increase) added together)

57 / 39: Psionic Strength

58 / 3A: Current Morale. Base morale is hardcoded to 100.

59 / 3B: Bravery = 110 - (10 * value)

60 / 3C: 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 / 3D: Unitref[062] 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 / 3E: Visibility via motion scanner. The bigger it is, the bigger the blip. Test this one out for values.

63 / 3F: Number of Fatal Wounds to head.

64 / 40: Number of fatal wounds to torso.

65 / 41: Number of fatal wounds to right arm.

66 / 42: Number of fatal wounds to left arm.

67 / 43: Number of fatal wounds to right leg.

68 / 44: Number of fatal wounds to left leg.

69 / 45 and 70 / 46: 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

71 / 47: NKF: Always 16 for XCom units, 1 for cyberdisc, 0 for others? Perhaps involves mobile lighting - see the Talk page.

72 / 48: Always 0? May be paired with [71].

73 / 49: 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 / 4A: NKF: Could be the unit spotted icon identifier? Could point to visible enemy units?

MikeTheRed: XCOMs always have 0, but Mutons have values of 0-3 (usually 0 or 2, and often fluctuating) in a firing squad situation.

75 / 4B: Always 0?

76-77 / 4C-4D: 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 / 4E-4F: 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 / 50: 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 / 51: 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 / 52: Melee Accuracy experience counter, for number of times stun rod has been used (not stun bombs).

83 / 53: Throwing Accuracy experience counter, for number of times unit has thrown any object.

84 / 54: 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 / 55: 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-111 / 56-6F: Unit's Name. Standard string ended by null byte. The rest can hold garbage.

112 / 70: 0; sometimes 1 for aliens.

113 / 71: 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.

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

114 / 72: If not 0, then unit is on fire, and will burn for this amount of turns.

115 / 73: Gender: 0 = male, 1 = female.

116 / 74: Hair/skin colour (for inventory; all other units = 0):

  0: Blond caucasian
  1: Brunette caucasian
  2: Asian
  3: Black

117 / 75: 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 / 76: Ammo for [117] turret weapon

119 / 77: Movement related? Large unit related? Possible bitfield.

MTR: 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 / 78: Unit bit flags, mainly re: mobility. They do NOT affect the soldier in inventory screen: (Mix of notes by BB and NKF)

   (  1) 1: 1 = Dead.  This was only set for 2 of 3 dead aliens in my current game.
                       [13] (Health=0) is the most reliable indicator for me. -MikeTheRed
   (  2) 2: 1 = Unit can fly.
   (  4) 3: 1 = Unit is flying. (Toggles leg sprites for power armour.)
   (  8) 4: ??? Seems to flag if the unit has 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?

121 / 79: Possible Values: 0 or 16. All units in unitref.dat get a value of 0 except for the second unit in the list which gets 16. Doesn't matter if the second unit is a soldier, a tank, or an alien. It's always 16. Editing it to 0 doesn't crash the game or have any dire consequences.

122 / 7A: Always 0?

123 / 7B: Always 0?

Notes

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?
  Firing sprite offset?
  Inventory lockout? All mind controlled units are locked out.
  Kneel lockout?
  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 99 values.
  Unknown values (25 in total):
  [002] [003] [004] [005] [006] [007] [008] [009] [034]
  [036] [041] [043] [052] [069] [070] [071] [072] [074] 
  [075] [112] [119] [120] [121] [122] [123]

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