Sunday, February 19, 2017

How To: Modding building commands in Halo Wars

So, Halo Wars Definitive Edition is on PC and with it, anyone can easily mod the game. Verses the 360 version which requires a modded Xbox. Yuck.

I was asked on Twitter how one could change what things are trained or researched in a building/socket. So that's the focus today. I may do some other simple guides in the future, if I get the time. However, it will always be time taken away from writing code. Would be nice to instead guide a minion with the drive to explore without full assistance, who would then write/vlog the guides for the everyman/lady.

Setting up


  1. You'll need to own and install Halo Wars Definitive Edition.
  2. You'll need to dump the game package using UWPDumper. Download the lastest x64 build here.
  3. With all the files dumped, you'll need to then uninstall the packed game.
  4. With the game uninstalled, you can put this bat file in the folder with the dumped game files to install the game 'loosely'. If you run into any errors, check that you have side loading enabled in your Windows settings. If you continue to run into an error at this point, try deleting the .p7x file from the dump directory.
  5. At this point you'll need the latest version of the PhxTools from github.
  6. Run PhxGui.exe. It's a simple drag-n-drop tool.
  7. Set the Game Version to DefinitiveEdition
  8. Select the directory for ERA Expand Path, where files will be extracted.
  9. Select the directory for ERA Build Output, where new ERA files will be placed.
  10. Now, drag-n-drop the xgameFinal.exe (one of the dumped game files) into the app.
  11. If the exe version is recognized, a back up will be made and the input will be modified to accept custom ERA files.
  12. From here, you'll need to drag-n-drop root.era, and the contained files will be extracted to the path in step 8.
  13. Go to the output path and open root.eradef file in a text editor that works with XML (you'll need to modify it later)
  14. Now view the "data" folder
  15. You want to find the files "objects.xml.xmb" and "techs.xml.xmb"
  16. Drag-n-drop these files to have PhxGui create the .xml versions of these files.
  17. Now find the files mentioned in step 15 in root.eradef and remove the ".xmb" extension so that the .xml files are referenced instead. Don't forget to save.
  18. Drag-n-drop root.eradef into PhxGui to have it spit out a new root.era to the directory mentioned in step 9.
  19. Assuming you didn't encounter any errors up to this point, you're ready to make changes to the files mentioned in step 15 to change the train/research options of buildings.

Changing build commands

Let's pretend you want to change what is trained out of the UNSC's barracks building. You'll want to open the objects.xml file in a text editor and search for an <Object> entry for unsc_bldg_barracks_01. Inside this element you'll find its <Command> elements. Refer to this excerpt for what you should be seeing.

There are various kinds of commands that a building can respond to. Research, Kill (self destruct), TrainSquad, etc. If you're wanting to mess with these different types, refer to other buildings. For now, let's just replace the command to train unsc_inf_marine_01 with unsc_veh_scorpion_01. These proto squads are defined in the squads.xml file (you'll need to convert the .xmb first), but you don't really need to change that file for command modding.

If the squad you were trying to train was say, a scarab or a unit that you don't normally have access to as the UNSC or leader you're playing with, you'd need to modify the techs.xml data. Specifically, the unsc_basic proto tech. See this doc for the stock unsc_basic data. Refer to it to figure out how to enable other proto squads for all UNSC leaders.

If you repeat step 18, after having saved any changes you made to the XML files, you'll have a root.era with your modifications in it. Back up the root.era that's in your game folder and then drop your custom root.era in.

Assuming there were no errors or mistakes up to this point, the next time you boot the game and play as the UNSC in Skirmish (campaign is a different beast), you should see the tank as the unit option in the barracks where the marines would normally be. It will still require the same amount of tech levels and cost as it normally would. Again, we're just changing the commands used to build units.

The End.

Sure, pictures or a video showing each step would have been nice, but I don't have the time to curate such a guide right now. So make like an explorer, and figure this brace new world out on your own and with others. Claim no land as your own, only territory for you and your fellow modder to brave share. No, I'm not communist, I just prefer to put the "kind" in mankind.