Many of the core game mechanics are trapped in a new binary format that CA has started using, some kind of database. Based on some work by alpaca, I've put together a short lesson on how to modify unit stats with a hex editor. This will have to suffice until ETW releases their modding tools or we come up with a way to read and edit the db files natively.
This lesson is not for the faint of heart, hex editing is a tricky business. A very good (unfortunately not free) tool is Hex Workshop which lets you select a range of bytes and interpret those as different data types. You pretty much select a range of numbers in powers of 2 (almost always 1, 2, or 4 bytes) and see what the value is. The strings in these db files are stored as BSTR UTF16, which means that the two bytes before every string are an unsigned short integer indicating the length of the string that follows, and each character in the string is two bytes (in English versions and most other Romantic languages, the second byte of each character will almost always be 00).
The lesson is in the color coding of the long riflemen statistics below. The following excerpt of binary is from the file at:
./data/db/unit_stats_land_tables/unit_stats_land
Bytes highlighted magenta are string lengths.
Bytes highlighted green are part of a UTF-16 string.
Red bytes are ones that are potentially interesting, but I haven't figured out what they are. They could be anything and any type, but usually they will be a single delimiter byte, a 2 byte short integer, a 4 byte float, or a 4 byte long integer.
The 4 cyan bytes are a long int that sets the normal unit size of long rifle men (80).
The 4 blue bytes are a long int that sets the base accuracy of the unit (60).
The 4 bright green bytes are a long int that sets the base reloading skill of the unit (15).
The 4 orange bytes are a long int that sets the amount of ammunition the unit has (15).
The 4 teal bytes are a long int that sets the melee attack of the unit (10).
The 4 brown bytes are a long int that sets the charge bonus of the unit (4).
The 4 gray bytes are a long int that sets the defense of the unit (8).
The 4 purple bytes are a long int that sets the morale of the unit (8).
This concludes today's Hex Editing 101 class. I may put together some more lessons on editing other db files.Code:000076a9h: 17 00 61 00 6D 00 65 00 72 00 69 00 63 00 61 00 ; ..a.m.e.r.i.c.a. 000076b9h: 73 00 5F 00 6C 00 6F 00 6E 00 67 00 5F 00 72 00 ; s._.l.o.n.g._.r. 000076c9h: 69 00 66 00 6C 00 65 00 5F 00 6D 00 65 00 6E 00 ; i.f.l.e._.m.e.n. 000076d9h: 50 00 00 00 00 00 00 00 00 00 00 00 0D 00 65 00 ; P.............e. 000076e9h: 75 00 72 00 6F 00 5F 00 6F 00 66 00 66 00 69 00 ; u.r.o._.o.f.f.i. 000076f9h: 63 00 65 00 72 00 31 00 00 00 12 00 65 00 75 00 ; c.e.r.1.....e.u. 00007709h: 72 00 6F 00 5F 00 6C 00 6F 00 6E 00 67 00 5F 00 ; r.o._.l.o.n.g._. 00007719h: 72 00 69 00 66 00 6C 00 65 00 6D 00 61 00 6E 00 ; r.i.f.l.e.m.a.n. 00007729h: 13 00 69 00 6E 00 66 00 61 00 6E 00 74 00 72 00 ; ..i.n.f.a.n.t.r. 00007739h: 79 00 5F 00 65 00 75 00 72 00 6F 00 5F 00 6C 00 ; y._.e.u.r.o._.l. 00007749h: 69 00 67 00 68 00 74 00 10 00 6D 00 61 00 6E 00 ; i.g.h.t...m.a.n. 00007759h: 5F 00 6D 00 75 00 73 00 6B 00 65 00 74 00 5F 00 ; _.m.u.s.k.e.t._. 00007769h: 73 00 61 00 62 00 72 00 65 00 12 00 78 00 5F 00 ; s.a.b.r.e...x._. 00007779h: 65 00 75 00 72 00 6F 00 5F 00 72 00 69 00 66 00 ; e.u.r.o._.r.i.f. 00007789h: 6C 00 65 00 5F 00 73 00 77 00 6F 00 72 00 64 00 ; l.e._.s.w.o.r.d. 00007799h: 03 00 00 00 07 00 6C 00 65 00 61 00 74 00 68 00 ; ......l.e.a.t.h. 000077a9h: 65 00 72 00 01 00 00 00 00 00 00 01 00 30 00 01 ; e.r..........0.. 000077b9h: 00 30 00 00 00 00 00 00 00 01 05 00 72 00 69 00 ; .0..........r.i. 000077c9h: 66 00 6C 00 65 00 3C 00 00 00 0F 00 00 00 01 00 ; f.l.e.<........ 000077d9h: 30 00 09 00 66 00 6C 00 69 00 6E 00 74 00 6C 00 ; 0...f.l.i.n.t.l. 000077e9h: 6F 00 63 00 6B 00 01 0C 00 6D 00 75 00 73 00 6B ; o.c.k....m.u.s.k 000077f9h: 00 65 00 74 00 5F 00 72 00 69 00 66 00 6C 00 65 ; .e.t._.r.i.f.l.e 00007809h: 00 0F 00 00 00 01 0A 00 66 00 6F 00 6F 00 74 00 ; ........f.o.o.t. 00007819h: 5F 00 72 00 69 00 66 00 6C 00 65 00 05 00 73 00 ; _.r.i.f.l.e...s. 00007829h: 77 00 6F 00 72 00 64 00 0A 00 00 00 04 00 00 00 ; w.o.r.d......... 00007839h: 08 00 00 00 00 00 00 00 0A 00 66 00 6F 00 6F 00 ; ..........f.o.o. 00007849h: 74 00 5F 00 73 00 77 00 6F 00 72 00 64 00 01 00 ; t._.s.w.o.r.d... 00007859h: 30 00 18 00 64 00 72 00 69 00 6C 00 6C 00 5F 00 ; 0...d.r.i.l.l._. 00007869h: 73 00 65 00 74 00 5F 00 69 00 6E 00 66 00 61 00 ; s.e.t._.i.n.f.a. 00007879h: 6E 00 74 00 72 00 79 00 5F 00 6C 00 69 00 67 00 ; n.t.r.y._.l.i.g. 00007889h: 68 00 74 00 05 00 65 00 6C 00 69 00 74 00 65 00 ; h.t...e.l.i.t.e. 00007899h: 08 00 00 00 03 00 00 00 CD CC 8C 3F 00 00 00 40 ; ........ÍÌŒ?...@ 000078a9h: CD CC 0C 40 00 00 80 40 00 00 00 00 00 00 00 00 ; ÍÌ.@..€@........ 000078b9h: 00 00 20 41 00 00 00 00 00 01 01 00 01 00 00 01 ; .. A............ 000078c9h: 01 01 01 01 00 00 00 00 48 42 00 00 96 42 00 00 ; ........HB..–B.. 000078d9h: C8 42 00 00 00 00 00 00 00 01 01 01 00 00 00 00 ; ÈB..............