February 27, 2008 - 03:13
Adding a New Unit

This is the third installment of my tutorials.  As I learn how to mod Zero Hour, I will share my knowledge with you the reader.  Thus if you have read and understood my two previous tutorials, you should be ready for this one.  If not, I strongly recommend you ATLEAST follow steps one and two under this tutorial: http://www.ppmsite.com/forum/viewtopic.php?t=17904.

Tools Required:  XCC Utilities, Notepad

Step 1, Getting the Right File:  Assuming you already have your ZH directory setup (which you must have CommandSet.ini and CommandButton.ini), the next step is to get the ini file for your new unit to go into.  Fire up XCC Mixer, go to your ZH directory and enter INIZH.big.  I'm going to leave alot of experimentation for later up to you, but for know extract the file AmericaVehicle.ini to your ZH directory under data/ini/object (make sure it is in objects and not just ini!).  Once you have done this, you can close down XCC mixer and head on over and open the file you have just extracted.

Step 2, The ini, an Explanation:
The ini files hold alot of information for the game.  Nearly everything you see when playing has an ini entry and the ini defines nearly every interaction in the game from what unit uses what icon to how much damage a super weapon has.  Being almost like the DNA of the game, the ini has alot of data to hold.  The creators divided thm up to make them more managable (so you have AmericaVehicle.ini being separated from say Mouse.ini).  The reason I bring this up is because not all the vehicles have their codes in AmericaVehicle.ini.  So you will have to do some exploring along the way.  Most of the files can easily be told what they are by their names, so finding the .ini you should be an easy task.  Generally speaking, the codes ini are found in the .ini file that has the side's name followed by what is in it (AmericaVehicles.ini for example) or if it is the ini of a sub-faction, you can just look in the sub-faction's ini (like LaserGeneral.ini).

Step 3, Clone, and then Edit:
The easiest way to add a new unit is to clone an old one and then go from there.  When you create a new unit, try to think of what you want it to be and which old unit resembles it the closest.  For this tutorial, will will clone the first unit in the file and then go from there.  Open up AmericaVehicle.ini if you have not yet done so, and copy from the beginning of th humvee entry until the end (from the word "object" uo till the the final "end" before the big space).  Scroll all the way to the bottom of the page and paste it there.  All we have to do is change the entry name and the game will automatically recognize the new unit  (For this tutorial, rename the entry AmericaVehicleCannoncar.

Nows the fun part.  You can edit, anything you want to under this new entry, but remember somethings will cause the game to crash.  There are probably a few tags you should stick to at first until you get the hang of things:

SelectPortrait = SAHummer_L;this is an icon, u should probably only c/p from other units
ButtonImage = SAHummer;same as above

DisplayName = OBJECT:Humvee; the name that shows up when the cursor is over it.  Remember whatever you add here you must also add in the generals.csf

Weapon = PRIMARY xxxx ;add whatever weapons you want, but like all things, you should stick to c/p until you leanr how to make new ones.
Weapon = SECONDARY xxxx

(also note, weapon sets are the weapons a unit gets when it is upgraded or not.  This is a way to get a unit to get a new weapon if it purchases an upgrade)

BuildCost = ;self explanatory

   Object = AmericaWarFactory ;NOTE; this is what is required to exist in order to build the unit, NOT where the unit is built, that is controlled in COmmandSte.ini.

Those were just a few, and the greater exploring is up to you.  But for the purpose of this tutorial, I'll give you a few changes to make so you have something instant to test ingame.  Paste "CrusaderTankGun" over the humvee's primary gun, and change the build cost to only a 100 dollars.  Save the file and before closing it, copy the name that you gave the entry.  After that close it.

Step 4, Creating the Buttons:
Completing the second tutorial is a requirement before continueing.  Go to you Zero Hour directory and open up CommandSet.ini and CommandButton.ini.  Go to the CommandButton.ini and find the command "Command_ConstructAmericaVehicleHumvee".  Copy this entry and paste it somewhere (preferably at the bottom).  Now edit this entry to fit your new unit, most importanlty by editing the line "Object        = AmericaVehicleHumvee" from the humvee's entry name t the new unit's (in this case AmericaVehicleCannoncar).  Once you have finished, Copy the name of the entry, save and close.  Now for the final step before finishing; go to CommandSet.ini and find the building that you want your unit to be built at (in theis case, the american war factory).  Find the entry for the war factory and add a number to an empty slot (Line 10 is vacant).  Paste the name of the button entry, and you're good to go!.

Step 5, Testing and the Future:
I have shown you step by step of how to add a new unit.  But remember, I have only showed you how to add a new one, all the experimentation and exploring is up to you.  Thats what modding is all about.  The possibilities are nearly endless, so go out there and do something new!

If you have any questions posts them here...