DoR hacking: Pre-deployed units

Discussion of hacking, editing and developments in Advance Wars games.
Remember, no Rom Requests
Shuffles

DoR hacking: Pre-deployed units

Post by Shuffles » Tue Sep 08, 2009 10:49 pm

This is one of the easier things I've figured out from trying to hack Days of Ruin. No LZ77 decompression/recompression is required, which is good because it's that which tends to give me the most trouble. All that's needed is a hex editor, a program to unpack the ROM (I use dslazy) and some understanding of hex (There's a function on the Windows calculator for translating hex to decimal).

Once you unpack the ROM, the files for pre-deploys will be located in the dispos folder, within the data folder. There are files for each campaign mission, as well as some free-play and training maps, (though these are harder to distinguish which is which). Note that some missions, like 06 and 24, have additional files. These are for handling the additional units (both allied and enemy) which appear at certain points in the missions, such as the extra units deployed by Penny in the Great Owl/Pulsatrix mission, or Will's forces arriving in the last battle against Tabitha.

When you open a file with your hex editor (this is cmp03, mission 3), you'll get something like this. Adjust your hex editor to display rows of 16 bytes per line.

FE 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00
06 07 02 00 00 64 03 46 00 00 00 00 00 01 05 03
02 07 02 00 00 64 03 46 00 00 00 00 00 01 05 03
05 0B 07 00 00 64 06 46 00 00 00 00 00 01 04 02
03 0B 07 00 00 64 06 46 00 00 00 00 00 01 01 07
04 08 0A 00 00 64 06 32 00 00 00 00 00 01 03 06
FE 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00
03 05 01 00 00 64 00 63 00 00 00 00 00 01 0A 01
05 05 01 00 00 64 00 63 00 00 00 00 00 01 0E 02
0C 0A 03 00 00 64 00 46 00 00 00 00 00 01 0A 01
0F 0A 03 00 00 64 00 46 00 00 00 00 00 01 0A 01
0D 08 04 00 00 64 00 50 00 00 00 00 01 01 0F 03
0B 02 04 00 00 64 00 50 00 00 00 00 01 01 0F 03
0D 0B 04 00 00 64 00 50 00 00 00 00 01 01 0E 02
0C 07 07 00 00 64 06 46 00 00 00 00 01 01 0E 02
0F 02 0A 00 00 64 06 32 00 00 00 00 01 01 0E 02
FF 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

The first line (FF 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00) states that all of the following units will be on faction 1 (In this case red, under Brenner's command). A few lines down we get FF 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00, which states that the following units are faction 2, the bandits. A pre-deploy file always seems to end with a null faction line (FF 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00). I have not yet experimented with adding new factions - I believe the core rules for a mission (factions and their commanders, the mission terms, the terrain set, fog of war, the weather, etc) are handled in an as now undetermined location.

So within each faction, each line of 16 bytes contains the data for a single unit. To insert a new unit into a mission just insert a new line within the desired faction and set up the bytes accordingly (I haven't checked if there's a limit to the number of units you're allowed). I'll now list each byte and it's function for the first unit in the file, the right-hand-side Mech unit at square 06 07.

(06 07 02 00 00 64 03 46 00 00 00 00 00 01 05 03)

06 - The unit's X Coordinate on the map
07 - The unit's Y Coordinate on the map
02 - The unit type. 02 is for the Mech (Full list below)
00 - This byte is used to determine whether the unit is carrying something, or being carried itself (check out the Landers in mission 23)
00 - The unit's rank (00 being default, 03 being Veteran)
64 - This is the unit's HP, out of 100, in hex (64 being 100, full health)
03 - The unit's remaining ammunition for it's main gun. This is always 00 for units which don't use ammo, like Infantry
46 - This is the unit's remaining fuel, in hex (46 being 70, max for the Mech)
00 - The number of the 1st unit transported (descending: used by the Landers in mission 23)
00 - The number of the 2nd unit transported (descending: used by the Landers in mission 23)
00 - If the unit is being commandeered by the CO, this byte will be 01
00 - Currently unknown... (It could be used to determine if a Sub starts out dived or not. One to look into... :? )
00 - The unit's individual AI (from what I understand, 00 is default (attack), 01 is all-out attack, 06 is stop, and 08 is defense)
01 - Not entirely sure what this, but it's normally set to 01. An exception appears to be the loaded units in mission 23, which are 00
05 -
03 - The last two bytes... I have no idea what they do, but in some instances they're the same as coordinates X and Y respectively

...And that's the limits of my knowledge in the most fascinating field of pre-deploy hacking, so anyone feel free to try to fill in some of the gaps. Have fun messing about with this, just don't ask me about where to get ROMs. :P

EDIT: Forgot to add the unit list for the 3rd byte, which is as follows:
01- Infantry
02 - Mech/Bazooka
03 - Bike
04 - Recon
05 - Flare
06 - Antiair
07 - Tank
08 - Med. Tank
09 - War Tank/Mega Tank
0A - Artillery
0B - Rockets
0C - Missiles
0D - Rig/Mobile Wrkshp
0E - Fighter/Interceptor
0F - Bomber
10 - Duster/Fighter
11 - Seaplane
12 - B-Copter
13 - T-Copter
14 - Battleship
15 - Carrier
16 - Submarine
17 - Cruiser
18 - Lander
19 - Gunboat
1A - Antitank

User avatar
Xenesis
Tri-Star CO
Tri-Star CO
Rank: Hydrocarbon Inspector
3DS Code: 2535-4646-7163
Location: 0x020232DD

Re: DoR hacking: Pre-deployed units

Post by Xenesis » Wed Sep 09, 2009 1:09 am

Nicely done! One thing I did notice when I was looking into the awdor unit in ram data is that it's almost identical to aw2's with a few minor additions (notably the ranks).

The separators and team identifiers of the predeployed unit sets appear to be identical to aw2, I'd do a comparison but my notes on the subject are approximately half a world away. It would not surprise me one bit if most of the data structures such as maps and the like are conserved. The unit carrying byte is likely to show whether a unit is not just transporting, but being transported, dived and in wait mode.
IST wrote:Even the worst individual needs to discover the joys of a chicken statue that is also a pregnant blonde housewife.

Shuffles

Re: DoR hacking: Pre-deployed units

Post by Shuffles » Wed Sep 09, 2009 4:52 am

I've actually looked into map editing a bit as well, but it's a bit more of hassle. .map files stored within the map folder in data need LZ77 decompression. At some point during the decomp/recomp process, two bytes seem to get missed off the end of the file (I use GBADecmp), and have to be added to the .map before everything is repacked to an NDS.

Trying to edit a map with a hex editor is a long and arduous process (without mentioning the 50 or so different tiles which need to mapped individually to make seas and coasts), and although the dimensions are stated in the first two bytes of the file, I've had no luck yet changing the size of a map without the ROM crashing when I try to play it. Each pair of bytes following the dimension bytes in the decompressed map contains the data for one tile, in order, starting from the top left corner and going across in rows. I'll do a brief list of some of the tiles I know:

01 00 - Plain
02 00 - Wasteland
86 00 - Forest
20 00 - Mountain
81 01 - Ruin
C2 01 - Neutral City
C7 01 - Red City
CC 01 - Black City
C1 01 - Neutral Factory
C6 01 - Red Factory
CB 01 - Black Factory
C5 01 - Red HQ
CA 01 - Black HQ
And I could list the Sea tiles I've found, but I'd be here all day... :lol:
(I also figure the Talon Gun and Owl Nest have their own tilesets (in addition to Normal, Desert, Ruin, etc) As some of their tiles share byte-pairs with some Sea tiles. How to change mission tilesets is not yet known, so we can't go nuts with Laser Turrets just yet. I also believe this holds true for the flowers in the Fear Experiment and the sky view from the cliff. Note that none of these missions have any Seas.)

There goes a very brief tutorial into map editing. Anyone feel free to look into this some more. I reckon finding where the core mission settings are handled (tileset used, triggers for messages, mission terms, etc) will be the next big step. :)

Who is online

Users browsing this forum: Multivac [Bot] and 0 guests