MAD/MTD Modding: Import new objects into a level

  • In this tutorial I will show you how to use the HoW Archive Editor to add new objects to the MAD/MTD files. I recommend everyone going thru this tutorial and try to reproduce my steps to learn how it works.

    In this tutorial I will show you how to use the HoW Archive Editor to add new objects to the MAD/MTD files. I recommend everyone going thru this tutorial and try to reproduce my steps to learn how it works.

    First of all, you can place all of the objects that are mentionned in the MAD/MTD files without any problems on the map. You simply need to modify the POG file a bit (check the POG tutorial for more info). But what if you want to add an object that is not initially used in that level ? If you try to place an object in your level that is not mentionned in the MAD/MTD files it will either simply not appear or have some weird textures or even no textures at all. Our goal is to add a heavy artillery in the DESVAL (Mission 18: I Spy). Of course in the original mission this map does not contain a heavy artillery, but we want to add it anyway.


    Without editing the MAD/MTD

    1.) First you need to modify the DESVAL.POG and add a heavy artillery on the map. You can also just download my DESVAL.POG (look my second post in this thread). Then go to your HogsOfWar\Maps folder and copy the GUNS.MAD, guns.mtd, DESVAL.MAD, desval.mtd files. Create a folder "extracted" somewhere, create two other folders inside "GUNS" and "DESVAL". Move the 2 guns files in the GUNS folder and the desval files in the DESVAL folder.

    2.) Open the HoW Archive Editor, open the 4 files "Open MTD/MAD" and "extract" them all.


    3.) Go in your GUNS folder, you will find a MAD and a mtd folder there containing all the extracted files. In the MAD folder, copy the 3 files BIG_GUN.FAC, BIG_GUN.NO2, BIG_GUN.VTX. Now go back to your DESVAL folder and paste the 3 files in the MAD folder there.

    4.) Do the same thing with the mtd files. Go in the GUNS folder, go in the mtd folder, you will find 16 files called BIGN000.TIM to BIGN016.TIM. Copy them all and paste them into the DESVAL mtd folder.

    5.) Now that you have moved all the files in their correct position you need to modify the log.ini files. Go to the GUNS folder and then in the MAD folder. Scroll thru the files and you will find a file called "log.ini". Open it with Notepad++. In this file you need to search the 3 BIG_GUN files you moved before. Select the 3 lines, now in Notepad++ go to Edit ==> Paste Special ==> Copy Binary Content.


    Now switch to the DESVAL folder, in the MAD folder. You will find there a log.ini as well. Open it in Notepad++. Now you need to paste the binary content at the end of the file, directly after the last object "Grass2". After the "NUL" signs you will see 2 numbers. The first number is the offset, the second number is the size. You have to change to offset so that it fits in the archive correcty. The formula is: "last_object_offset + last_object_size = new_object_offset". 78732+600=79332, 79332+1280=80612, 80612+2560=83172. After you have modified the offsets correctly, save and close the log.ini file.


    6.) Now you need to do the same thing with the mtd files. Go in the GUNS>mtd folder, open log.ini. It can be a bit tricky to find all the texture files, you can open them with the TIMViewer and take a look at them. You can also figure out all the textures of an object with the .FAC file (explained later in this tutorial).


    There are a lot of files. All the files called BIGNxxx.TIM are the textures of the heavy artillery. The files surrounded by yellow are already inside the DESVAL mtd so you don't need to copy them. The files surrounded by red are missing, you need to copy them: Edit ==> Paste Special ==> Copy Binary Content.

    Now go in DESVAL>mtd, open log.ini and paste the binary content at the end of the file again. Now you need to edit the offset values again with the same formula: "last_object_offset + last_object_size = new_object_offset". After that, save and close the file.


    7.) Now there is one last thing to do that is a bit time consuming, you need to remap the textures to the object. If you try to open the game at the moment, the heavy artillery will be there, but the textures will be completely messed up. So now you need to fix the textures. Open GUNS>mtd>log.ini again, and scroll down to find the NEW textures that were missing. You need to take note of the line-numbers of those textures.


    You need to calculate the texture ID: "TextureID = LineNumber - 2". Your lines go from 44 to 55, this means that your texture IDs go from 42 to 53. Now you need to convert those numbers in hexadecimal (search on google for decimal-hexadecimal): 42 = 2A, 43 = 2B, 44 = 2C, ..., 53 = 35. Note all those hexadecimal numbers down.

    Open DESVAL>mtd>log.ini again, scroll to the very end, take note of the lines. In this example it's 145 to 156, so the texture IDs are from 143 to 154 !

    Convert all the numbers to hexadecimal numbers: 143 = 8F, ..., 154 = 9A and write them down.


    8.) Write your conversion table, to keep track of the values.

    9.) Now go in the folder DESVAL>MAD and open the file BIG_GUN.FAC with Hex-Editor MX.

    Here is an overview of the .FAC format, it will help you to find the correct values to edit.

    Now you need to replace all the values like you have written it in your conversion table. 1 Byte is represented by 2 digits in HEX-Editor MX. The .FAC format will help you to count the bytes, but don't worry, you will figure out a pattern after a while so you don't need to count them all.


    Replace the values by that pattern, the first 4 values are the triangle textures, they are right under each other and very easy to find. To find the next quadrilateral-byte, move 4 bytes to the left and 2 bytes down every time. On the picture, the value 2C (in blue) isnt replaced yet, in that case you would need to write 91 instead. It can take a while until you have replaced all the values of the file...


    There is also an easier way to modify all the values. You could use the "Search & Replace" feature by Hex-Editor MX. However there is some danger, it could potentially replace wrong values ! For example, maybe there is another value "2A 00 00 00" in the file that is NOT a texture ID ? In that case, it would screw up your whole file. So be careful !

    Oh and by the way, if you find a value that is not part of your conversion table (not between 2A and 35 in this example) then it means that you forgot a texture ! You can also do it the other way around, first open the .FAC file and search all the texture IDs, this way you won't forget any textures !

    When you have edited all the values, safe your file and close the Hex-Editor.

    9.) Finally you can repack the files again ! Open the Hogs of War Archive Editor. This time choose "Open Ini" and then click on "Pack". Don't change the path when you repack the files, otherwise the tool crashes !


    Now check the DESVAL>MAD and DESVAL>mtd folder. You will find there a packed DESVAL.MAD and desval.mtd file. Copy those files and paste them in your HogsofWar > maps folder (replace or backup the old MAD/mtd files).

    10.) You can start your game, launch the mission and see the result !


    You can repeat this method to add all the objects to a level you want. If you have any questions, write them down in this thread. I placed the heavy artillery a bit too low in the ground as you can see. ^^