

by Zach Barth
zach at technical-difficulties.com
If you have questions, I'll help as best I can.
Explanation:
Sitting in my first CAD class and feeling slightly fiesty, I decided to crack open the data files of my newly aquired demo for Star Wars: Empire at War. An awesome game, I played through the demo's ONE mission with relative ease and enjoyment, but was dismayed at the fact that that was all the demo had to offer. Apparently, the force was with me.
Tools to edit in game text, check readme for usage
Download the Empire at War Demo from Gamespot
An example mod I made
Extract the files into the game's Data directory after backing up the originals.
Makes the Empire playable, uses new vehicles, opens a new planet.
Demo mods created with this hack
Config.meg - all the important data that makes configures the game (all the fun stuff!)
Everything else is really self explanatory. Movies are stored in the BINK video format (BIK), music is stored as MP3s, maps and models appear to be proprietary, and I haven't checked the rest (textures might be TGAs).
As far as I see it, each MEG file consists of four parts - the number of files in it, the file name list, the file info list, and the files themselves. The tricky thing is that each of the latter three segments can be in different orders - the file info segment points to a filename and the data. (This threw me off at first, with a movie called Vader_Loop2 showing a rebel trooper.)
All numbers are stored least significant byte first, meaning the long 0x12345678 is stored [78][56][34][12]
//begin MEG file
[4 BYTES - NUMBER OF ENTRIES]
[4 BYTES - NUMBER OF ENTRIES] (yup, it's there twice. beats me?)
for each file
[2 BYTES - LENGTH OF FILENAME] (n)
[n BYTES - FILENAME] (plain old ascii)
for each file
[4 BYTES - WTF VALUE] (see note below)
[4 BYTES - INDEX] (starts at zero, increases by one with each sequential file)
[4 BYTES - LENGTH OF DATA] (m)
[4 BYTES - START OF DATA] (where the actual file data starts within the MEG file)
[4 BYTES - FILENAME] (points to a name in the filename table, with the first being zero)
for each file
[m BYTES - DATA]
//end MEG file
So yeah, that's it. No encryption. No compression.
The wtf value is a value I can't quite figure out - it appears to be some sort of percentage, as it increases from 00000000 to FFFFFFFF (four bytes) regardless of if the MEG has 20 or 2000 files. When you extract a MEG, it saves the wtf value with the filename in the list, and is reinserted when you rebuild the MEG file. Because of this, all I've really done is edit files. When a new file needed to be created, I simply replaced the contents of an old one, such as just making changes to the demo mission to make my own.
Tools:You can use these tools (link above) I made to do all the extraction and insertion.
megExtractor.exe will extract all the files out, and megInserter.exe will rebuild the MEG file.
If you run megExtractor.exe and type Config, it'll attempt to load Config.meg, create a folder called Config, and will proceed to extract all the files into that folder.
Doing the same in megInserter.exe will create Config.meg out of all the files in the Config folder. Pretty straight forward.
Thus, to make changes, run megExtractor.exe, edit the files accordingly, and then run megInserter.exe - you'll have a new MEG file with your changes, ready to be dropped in the game's Data directory.
Some tips I picked up while browsing Config.meg:
- To enable play as the empire, simply move the Empire faction above the Rebel faction in DATA\XML\FACTIONS.XML (it disables the second faction by default for purposes of the demo).
- An incredible amount of content is available (around 2000 models). However, the limiting feature is the maps: there are only 5, and most of them come with units already on the map. Thus, for my test mod, I simply used the asteroids level's space map and replaced the tutorial maps with it with a different color background for each planet.
- You can configure the maps linked to a planet in DATA\XML\PLANETS.XML, and can configure if you can build on land with Planet_Surface_Accessible.
- The demo campaign is located in DATA\XML\CAMPAIGNS_SINGLEPLAYER.XML under the second instance of the word 'demo' (do a search). From here you can set home worlds, victory conditions, and starting units (including ones not used in the demo, like the Mon Calamari cruiser). To change which planets are shown, go into DATA\XML\STORY_SANDBOX_DEMO_REBEL.XML, which enables the view of planets and centers the camera (and I imagine lots of other stuff waiting to be enabled).
- Individal units are editable in GROUNDINFANTRY.XML, GROUNDVEHICLES.XML, and the SPACEUNITS*.XML files (along with some others), but the configurations for their groupings appear in files like SQUADRONS.XML and GROUNDCOMPANIES*.XML. The same thing applies for heroes.
And tons of other stuff I don't have time to list (need some sleep before economics class).
Overall, I'm impressed with Petroglyph. This is definately an incredible game - it just needs a bigger demo. Here's to hoping that they don't do anything about their data files in the final version of the game - with the looks of that it supports custom levels, modding will be a blast!






