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.

21 comments:

  1. you need to explain in more detail bruh

    ReplyDelete
  2. okay the UWPDumper gave me an eror message "remote thread wait timeout: unable to find target thread"

    ReplyDelete
    Replies
    1. Bruh, you need to explain what you think isn't explained in enough detail.

      I didn't make, nor do I develop the UWPDumper. You'll have to report any issues with it on its github https://github.com/Wunkolo/UWPDumper

      Delete
    2. okay im gonna try to explain, since the UWPDumper shouldve dump the game in the local disk c/user/appdata/local/packages if im correct, the UWPDumper probably didn't know where to dump it since I think i dont have the halo packages folder in my pc, only the installation directory

      Delete
    3. maybe you can tell me the exact name inside the packages folder for halo wars definitive edition, so I can try make the folder and try if the UWPDumper will work

      Delete
    4. The package folder should be named something that begins with "Microsoft.BulldogThreshold" and ends with "8wekyb3d8bbwe" I think. Bulldog is the internal name of Definitive Edition (Hogan is the internal name for HW2).

      If you're not seeing Halo/Bulldog in the process list with UWPDumper, be sure you run the game first and then run the dumper.

      Also, the game is out on Steam now, I'd recommend getting it instead. No need to dump anything on Steam :). I'll be releasing an update to my tool tonight to support it. http://store.steampowered.com/app/459220/Halo_Wars_Definitive_Edition/

      Hope that helps!

      Delete
  3. I have an issue, when I try to drop the xgame_Final, it says "System.UnauthorizedAccessException:Access to the path 'c:(game file path) is denied

    ReplyDelete
    Replies
    1. You need to either run PhxGui with admin privileges or drop in a file that isn't located in a protected path like the C:\Program Files\ or such.

      Delete
    2. so it seems to be working except im getting this error

      Patch EXE finished with errors:
      ERROR Unrecongized file:
      SHA1=91EA739987715319CFDF1FC92BFA456BFA18C9B6
      File=C:\Halo wars\Halo Wars Definitive Edition\xgameFinal.exe

      Delete
    3. Also when i attempt to run the game after I finished all the phoenix stuff it gives me this error
      BFileManager::emptyNotifyQueue: Archive failed to load
      Expression: (null)
      File:D:\jenkinsSlave\workspace\BULLDOG_Package_Win64_Retail\Main\cide\xsystem\FileManager.cpp(2288)

      Delete
    4. If you didn't download Phoenix_20170428.7z from the github page, you're not using the latest version with Steam support

      Delete
    5. Thank you so much for your help up to this point, but when I run it, it still gives me the error even after updating the phoenix tool (this happens when trying to run the game)
      BFileManager::emptyNotifyQueue: Archive failed to load
      Expression: (null)
      File:D:\jenkinsSlave\workspace\BULLDOG_Package_Win64_Retail\Main\code\xsystem\FileManager.cpp(2288)

      Delete
  4. (EDIT) I fixed it, it was a really simple issue actually, i accidentally took xgame_Final out of the folder.
    Thank you so much for all the help bro I really appreciate what you're here for the Halo modding community :)

    ReplyDelete
    Replies
    1. Glad it was a simple fix. Enjoy :)! There's a discord group for modding the game if you're interested or need the help of others (note, I can only offer so much specific mod help though): https://discord.gg/UjfYKAN

      Delete
  5. I get a message saying Patch EXE finished with errors:
    ERROR unrecognized file when dragging the game executable into the tool.

    ReplyDelete
    Replies
    1. I can't help you unless you include the version number of both PhxGui and xgameFinal (or the SHA1 that the tool spits out).

      Delete
    2. This comment has been removed by the author.

      Delete
  6. How would one add new units to the game

    ReplyDelete
  7. UWPdumper crashes my game and leaves no files in the Temp_state folder

    ReplyDelete
  8. can i get the 3d models with this?

    ReplyDelete