Difference between revisions of "SOLDIER.DAT"

From UFOpaedia
Jump to navigation Jump to search
m (→‎General Notes: - tiny fix)
(→‎Structure: added more info to data corruption)
Line 15: Line 15:
 
  4 Colonel (COL)
 
  4 Colonel (COL)
 
  5 Commander (CDR)
 
  5 Commander (CDR)
 
+
6 Units in Entrance
 +
7 Units in Target Exit
 
<b>3 / 02</b> <i>(varies, FF)</i>: Base the soldier is at, using reference numbers from LOC.DAT. First base is always 0 (first entry in LOC.DAT). Value of FF means the soldier is being transferred.
 
<b>3 / 02</b> <i>(varies, FF)</i>: Base the soldier is at, using reference numbers from LOC.DAT. First base is always 0 (first entry in LOC.DAT). Value of FF means the soldier is being transferred.
  
Line 85: Line 86:
 
<b>62 / 3D</b> <i>(0-1?)</i>: Increase in Bravery (multiply by 10).
 
<b>62 / 3D</b> <i>(0-1?)</i>: Increase in Bravery (multiply by 10).
  
<b>63 / 3E</b> <i>(0-3)</i>: Armor. 0=None, 1=Personal Armor, 2=Power Armor, 3=Flying Suit.
+
<b>63 / 3E</b> <i>(0-3)</i>: Armor. 0=None, 1=Personal Armor, 2=Power Armor, 3=Flying Suit 4=Sectoid 5=Snakeman
 +
6=Ethereal 7=Muton 8=Floater 9=Celatid 10=Silacoid 11=Chryssalid (the rest is just parts of the big units and civilians)
  
 
<b>64 / 3F</b> <i>(0-24?)</i>: Most-recent month's Psi Lab training increase. Largest values for newly trained (16-24).
 
<b>64 / 3F</b> <i>(0-24?)</i>: Most-recent month's Psi Lab training increase. Largest values for newly trained (16-24).

Revision as of 14:47, 21 September 2005

General Notes

SOLDIER.DAT has a fixed structure of 250 entries of 68 bytes each. (Only a maximum of 250 soldiers can be had.) Thus it is always 17,000 bytes long (250x68).

In several places it uses Intel little-endian "Words". These are two bytes values with the low byte first, high byte second. Thus they can count over 255 (to 65,536). Sometimes they are "signed" however (8000h, when the highest bit is set), which makes the maximum positive value 32,767. It's of no concern in an ordinary game, but may be to hackers. "Signed" is noted below where applicable.

Values are presented according to byte count (1 to 68) followed by the equivalent hex offset (00 to 43) in bold, followed by the normal (non-hacked) range of values in italics. Most fields can be hacked up to FF, but sometimes it can make for weirdness!

Structure

1-2 / 00-01 (0-5, FFFF): Word set to Rank or FFFF if soldier is dead (or slot not yet used). These values are actually pointers within a text file, so if you change it to 7 it will say "SPACE AVAILABLE" as your rank. Strange stuff. Ranks are:

0 Recruit
1 Squaddie
2 Sargeant (SGT)
3 Captain (CPT)
4 Colonel (COL)
5 Commander (CDR)
6 Units in Entrance
7 Units in Target Exit

3 / 02 (varies, FF): Base the soldier is at, using reference numbers from LOC.DAT. First base is always 0 (first entry in LOC.DAT). Value of FF means the soldier is being transferred.

5-6 / 04-05 (varies, FFFF): Craft soldier is assigned to, using values from LOC.DAT. FFFF means not assigned to a craft.

7-8 / 06-07 (FFFF): Unknown. Presumed Word. Only ever seen to be FFFF.

9-10 / 08-09 (0+): Number of missions. Signed Word.

11-12 / 0A-0B (0+): Number of kills. Signed Word.

13-14 / 0C-0D (0+): Wound recovery days. Signed Word.

15-16 / 0E-0F (20+): Death Penalty (morale hit if this guy dies). Presumably a signed Word. Is equal to 20 + Missions + Rank Bonus, as follows:

 0  Recruit
 0? Squaddie (not yet tested)
 1  SGT
 3  CPT
 6  COL
10  CDR

Note: A test of hex-editing Missions and performing a combat (while not touching this field) did not cause this field to reflect the edited Missions value. This field simply added 1, as it normally would. So it doesn't appear to be computed from Missions; instead, both Missions and this field have a 1 added at the end of each mission. Presumably then, directly editing Rank would likewise not cause this to change.

17-37 / 10-24 (Text): Name, 21 characters long. Note that players can enter almost any keyboard character (unlike in Windows programs) because they are directly stored here instead of going through any Windows objects. Also FWIW, the 'ends' of player names are still kept here, if a new soldier in a slot has a shorter name than the previous soldier. The end of the current name is denoted by a null character (ASCII 00).

38-41 / 25-28 (0): Unknown. Four bytes that have only ever been seen to be 0, 0, 0, 0. Two unused Words?

42 / 29 (varies): Always 0 except for existing soldiers being transferred, in which case it equals the LOC.DAT value for destination base. New hirees on their way to a base will also have this set to 0, so if Byte 3 is set to FF and this byte is 0, you can't tell (from these two bytes alone) if it's an existing soldier going to your first base (LOC.DAT=0), or a new recruit going to any base. But the game knows where they're going, presumably via TRANSFER.DAT.

43 / 2A (50-60): Initial TUs.

44 / 2B (25-40): Initial Health.

45 / 2C (40-70): Initial Stamina.

46 / 2D (30-60): Initial Reaction.

47 / 2E (20-40): Initial Strength.

48 / 2F (40-70): Initial Firing Accuracy.

49 / 30 (50-80): Initial Throwing Accuracy.

50 / 31 (20-40): Initial Melee / Close Combat Accuracy. See Note 1.

51 / 32 (0-100): Psi Strength.

53 / 34 (5-10): Initial Bravery. Computed as 110-(10*ThisByte). E.g. if ThisByte=9, Bravery=20. So the lower this byte is, the better your Bravery is. Initial Bravery can be 10-60. Bravery always works in units of 10.

52 / 33 (0-100+): Current Psi Skill. 0 = has not yet had any Psi Lab training.

54 / 35 (0-30+): Increase in TUs. (Max total TUs possible (initial+increase) is approximately 80. See Note 2.)

55 / 36 (0-35+): Increase in Health. (Max total approx. 60)

56 / 37 (0-60+): Increase in Stamina. (Max total approx. 100)

57 / 38 (0-60+): Increase in Reaction. (Max total approx. 90)

58 / 39 (0-50+): Increase in Strength. (Max total approx. 70). Note that more than 64 here will make you unable to throw anything. Possibly the throwing distance function only checks the lowest 6(?) bits of current strength, or a high value otherwise pushes the XCOM equation out of allowable bounds.

59 / 3A (0-80+): Increase in Firing Accuracy. (Max total approx. 120)

60 / 3B (0-70?): Increase in Throwing Accuracy. (Max total approx. 120?)

61 / 3C (0-?): Increase in Melee/Close Combat Accuracy. See Note 1.

62 / 3D (0-1?): Increase in Bravery (multiply by 10).

63 / 3E (0-3): Armor. 0=None, 1=Personal Armor, 2=Power Armor, 3=Flying Suit 4=Sectoid 5=Snakeman 6=Ethereal 7=Muton 8=Floater 9=Celatid 10=Silacoid 11=Chryssalid (the rest is just parts of the big units and civilians)

64 / 3F (0-24?): Most-recent month's Psi Lab training increase. Largest values for newly trained (16-24).

65 / 40 (0,1): In Psi Lab training.

66 / 41 (0,1): Promotion flag (as of most recent combat). Reset as of next combat.

67 / 42 (0,1): 0=Male, 1=Female.

68 / 43 (0-3): Appearance (for loadout, no armor): 0=blonde, 1=brown hair, 2=Oriental, 3=African.

Notes

1) Melee or Close Combat Accuracy is a somewhat abandoned skill. It does not appear in display screens, but Byte 61 does increase when the stun rod is used. Also, secondary skills will increase when you do this, as they do for other primary skills. Given their placement in this file, then, it is presumed that this is a third 'accuracy' skill related to stun-rod use, with Byte 50 being the initial value and Byte 61 being the increase.

2) The possible values for skill increases (in a non-hacked game) depend both on the cap for each skill and on each soldiers' initial value. Thus the max possible value shown in the 'increase' range is for soldiers who started with the minimum initial skill.

3) Be careful of making total skill value (initial + increase) greater than 160 (A0h). This will make your skill bar wrap around the screen.

4) As can be seen, Armor is the only thing that 'stays with' a soldier. Yes, it's lost if you fire someone wearing it!

5) This work was done by hatfarm and MikeTheRed. More info welcomed!

For More Information

Addendum: Hex Workshop Structure Library

The following can be used to make an XCOMUFO.hsl file that will work with Hex Workshop (v4.23) available from www.BPSoft.com. This allows one to overlay a structure while viewing/editing SOLDIER.DAT and work in a more organized fashion. Tip: Set the data view window to 34 bytes wide, and each SOLDIER record will take exactly two display lines. (It won't let you set it to higher than 64, unfortunately.)

/***********************************************************************************
 * XCOMUFO.hsl - Structure definitions for XCOM UFO DEFENSE v1.4
 *    This structure def last edited Sept. 16, 2005
 *    Mike Fay mikestar@speedfactory.net
 *    MikeTheRed on www.xcomufo.com forums
 *    Also see the SOLDIER.DAT wiki at www.ufopaedia.org/index.php?title=SOLDIER.DAT
 ***********************************************************************************
 * Revision History:
 *  09/26/05 - MF - Original
 */

#include "standard-types.hsl"

// SOLDIER.DAT
struct SOLDIER_DAT 
{
   WORD Rank ;
   WORD BaseOrTransfer ;
   WORD Craft ;
   WORD UnknownFFFF;
   WORD Missions ;
   WORD Kills ;
   WORD WoundDays ;
   WORD DeathPenalty ;
   CHAR Name[21] ;
   WORD UnknownUnused1 ;
   WORD UnknownUnused2 ;
   UBYTE TransferBase ;
   UBYTE TUs_Init ;
   UBYTE Health_Init ;
   UBYTE Stam_Init ;
   UBYTE Rxns_Init ;
   UBYTE Str_Init ;
   UBYTE FAcc_Init ;
   UBYTE TAcc_Init ;
   UBYTE MAcc_Init ;
   UBYTE Psi_Str ;
   UBYTE Psi_Skill ;
   UBYTE Brave_Init ;
   UBYTE TUs_Inc ;
   UBYTE Health_Inc ;
   UBYTE Stam_Inc ;
   UBYTE Rxns_Inc ;
   UBYTE Str_Inc ;
   UBYTE FAcc_Inc ;
   UBYTE TAcc_Inc ;
   UBYTE MAcc_Inc ;
   UBYTE Brave_Inc ;
   UBYTE Armor ;
   UBYTE PsiLab_Inc ;
   UBYTE PsiLab_Flag ;
   UBYTE Promotion_Flag ;
   UBYTE Gender ;
   UBYTE Appearance ;
} ;