PDA

View Full Version : [GEN/ZH] A beginner's guide to editing Generals



CodeCat
01-13-2004, 04:07 PM
Beginner's guide to editing Generals

This guide is meant for people that have never edited Generals before, or people who have edited it but without success. :) This is just a beginner's coding guide, since that is the most logical place to start. If you want to do modelling, I suggest waiting till later. Just getting an understanding of the game itself and its structure is more important now. Once you get the idea and you have messed around a bit, you can try modelling if you want to.

Note that I'm not covering Zero Hour in this guide. The fact that Zero Hour gets its data from two different places makes it a bit hard to understand for beginners. And Zero Hour has quite some stuff that makes it even harder to understand, and you don't want to start off running. Learn to walk first. Anyway, let's get started.

Getting your stuff together
Finding your stuff is the most important, if you can't find anything you're completely stuck already, so here's a short explanation of the game's storage method. All of the game's data is located in a few files in the main Generals or Zero Hour folder with the BIG extension. These files are archives which can have other files inside them, just like ZIP or RAR files. Just like with other archives, in order to get the files out, you need a utility to extract them. A common newbie mistake is editing the BIG files directly, but that will almost definitely mess the game up so you do NOT want to do that. To extract the contents from BIG files, you can use one of these utilities:

XCC Mixer (xccu.sourceforge.net) - this handy little program can also extract the files from the MIX files in older C&C games, and you can even view some of the files' contents without extracting them first.
FinalBIG (www.wagnerma.de) - not as versatile as XCC Mixer but it's good enough if extracting is all you need to do.There are other utilities out there, but these two work fine (I use XCC myself). If you absolutely need something different you can just do a search for "generals big extractor" and you're bound to find something.

Once you have these utilities, it's time to start looking through the BIG files themselves. Each BIG file has a different contents and at first it may be hard to find what you're looking for. But the names of the files usually give away quite a few hints as to what's inside them. Take your time to look through them and make mental notes of what you see.

What you're after right now is the INI files. These files allow you to customize the behaviour of the game, and this is where most of your editing will take place. So getting these out is the first step you should take. Boot up your BIG extractor and go to the most obvious location for INI files - INI.BIG. In most BIG extractors (such as the two above) when you look inside the BIG file, you see a list of files inside, but you also see what folder they go in. If you open up INI.BIG for example, you'll see that Upgrade.ini goes in the Data/INI folder. But FactionUnit.ini goes in Data/INI/Object. The Data folder is in your Generals folder, but if you look in Data you won't see an INI folder. If you need to extract something to a particular folder, but that folder doesn't exist, you'll have to make it. It is important to extract your files to the right folder or they won't work. For now, extract all INI files in INI.BIG to their proper locations, creating new folders as necessary.

The first step in editing
Right, now that that's done, you can actually start editing. But seeing all those INI files can make it seem like a daunting task to get it all working properly. This is partly true: the bigger your mod becomes, the harder it is to get it to work yet still maintaining a picture of what you are doing. So for the first few tries, just try to stick to one or two files at a time. The easiest place to start is FactionUnit.ini in Data/INI/Object. So open it up in your favourite text editor (anything better than notepad is HIGHLY recommended).

You'll see the file is quite large, and you may now realise finding your stuff will be even harder that you had imagined. There is indeed a ton of stuff in this file, but it is all pretty organised so you won't have too much difficulty hunting through it. Assuming you didn't scroll anywhere, you'll see a bit of text right at the top. Notice how all those lines start with a semicolon ( ; ). A semicolon indicates that all text after it up till the end of the line is "commented out", which means that the game will not read it. You can add your own comment to the file if necessary (very handy if you need to make notes to yourself or to others), and you can also easily disable parts of code by placing semicolons on the start of the lines. This method should be preferred over simply removing the code because it allows you to see what you changed to make things go wrong (if they go wrong that is), so simply removing the semicolons allows you to easily reactivate the code.

The next you'll see is

Object AmericaParachute
"Object" at the start of a line means you're defining a new object. This could be anything - a unit, a building, a tree, a missile, and even something invisible. The object definition goes on until

End
Everything concerning that particular object is in a block of data that starts with "Object" and finishes with "End". You NEED to put in an End for each block you start. If you forget and End somewhere you will definitely get in-game errors. So make a habit of putting in an End immediately after making a new block.
"AmericaParachute" is the name that the game uses internally for that object (which in this case is a parachute like the one used to paradrop rangers and such). You can make up any name you like if you create a new object, but don't change any of the existing ones because other parts of the game (INI's) refer to the unit with that particular name - so removing it will mean the game can't find it anymore.

For the purpose of this guide, use the search function of your text editor and search for "Object AmericaTankCrusader". This will bring you to the section that defines the USA Crusader Tank. You can see that the internal name reflects the real name of the unit very well. You can almost guess that the name for the Battlemaster is "ChinaTankBattlemaster". In most cases, if you are looking for a particular unit, just searching for its actual name but without the spaces in it will get you where you want to be.
Immediately below the name, you'll see some comment saying this is the "art" section. The developers at EA were so nice to group all the data for each unit together in "sections". These sections don't resemble anything other than an easy way to structurize the data for each object. You can ignore them if you want but why throw away a perfectly good tool? Better use them right?

The ART section is not the easiest place to start, so go further down to the DESIGN parameters. Look around there and you're bound to notice some familiar things, such as BuildCost and BuildTime:

BuildCost = 900
BuildTime = 10.0 ;in seconds

You might want to start changing those right away, and hey why not, the best way to learn is to try it out. So just set BuildCost to something rediculously cheap or expensive, whatever you want. You're the modder so you're in charge. Then go a bit further down to the ENGINEERING section. You'll see a nice setting there:

Body = ActiveBody ModuleTag_02
MaxHealth = 480
InitialHealth = 480
End

Ignore the Body part for now. MaxHealth says how much health the unit can have at most (or how strong it is). InitialHealth sets how much health the unit has when you build it. Normally you would want to have InitialHealth and MaxHealth the same, so just set them both to whatever you want. For some fun, set it to 10000. Congratulations, you just made a near-indestructable tank. ;)

That's all you need to do for now. After all, it's a start, and you need to start small. So now, after saving your modified version of FactionUnit.ini, just load up Generals and start a skirmish game as USA. You didn't change anything other than the Crusader tank's cost, build time and health, so nothing else will be different. Once you get your War Factory up you can select the Crusader and you will immediately see its new price. Click on it and you will also see the change in build time (if you changed it that is). Once it's done, send it off to the enemy or shoot at it yourself, and you can see the difference in health if you changed it significantly enough. You can now pat yourself on the back for making your very first mod!

The next step
Ok, this mod was a bit simple. So let's try something slightly more advanced. Close Generals when you're done playing with your fancy new Crusader, and open FactionUnit.ini again. Go back to the Crusader's section, and to DESIGN parameters. Take a look at the "WeaponSet" part. You can see that WeaponSet itself has an "End" to finish it, just like "Object". Anything between "WeaponSet" and "End" contains all the data that concerns any weapons the unit may have. In the case of the Crusader, you see:

WeaponSet
Conditions = None
Weapon = PRIMARY CrusaderTankGun
End

I took out the comment because it's not used in the game and in this example it's not important. The important part here is the "Weapon" setting. This is basically saying which weapon the tank has. After the "=" it says PRIMARY, which indicates that the weapon is in the unit's primary weapon slot. Each unit has three weapon slots: PRIMARY, SECONDARY and TERTIARY. Unless the unit has more than one weapon you will usually only use PRIMARY. After PRIMARY you see the name of the weapon. This name refers to a section in another INI file, for weapons this is Weapon.ini, located in Data/INI. So go there and open up Weapon.ini.

You'll see a structure that is reasonably similar to the one in FactionUnit.ini. Except the blocks don't start with "Object" but with "Weapon", which is probably quite obvious because this file contains weapons and not objects. Anyway, we're looking for the Crusader tank's weapon. The Weapon line in FactionUnit.ini refers to a weapon called "CrusaderTankGun", so search for it and you'll soon find it.

You'll see a small block that contains all the data for the Crusader's weapon. The first and probably most important setting is:

PrimaryDamage = 60.0
This sets the amount of damage the weapon does with each shot. Use your imagination (or not :) ) and set it to something different. Set it to something really big (1000+) for some interesting results. You can also set it to 1 and watch the Crusader take 10 minutes to destroy anything ;).
The second setting is:

PrimaryDamageRadius = 5.0
This controls the size of the circular area that the damage will be applied to, to simulate an explosion. Set it really big and watch the tank damage half a screen full of units with each shot. You can even set it to 0, and that would mean that the Crusader will only damage something if it is a direct hit, which is unlikely in this case.
A bit down, you'll see:

AttackRange = 150.0
This is another important setting because it controls how far the weapon can shoot. The distance is 1/10th of the units world builder uses, so 150 in this case equals 15 in world builder. You can set the range really tiny and it will have to get really close to be able to shoot anything. Make it really big (5000 for example) and the tank can shoot through half the map.
The last important setting is:

DelayBetweenShots = 2000
This sets how long the tank must wait between shots. It is measured in milliseconds so 1000 ms = 1 second. If you set this to 200 or less you will have a tank that fires rapid-fire tank shells, which can look quite funny. You can also set it to something like 120000 and then the tank has to wait two minutes before firing another shot. Just play around with it.

Right, save and close Weapon.ini, and also close FactionUnit.ini (even though we didn't change anything this time). Load up Generals again and play a USA skirmish game. Have your Crusader attack something and see how far it can shoot or how much damage it does in one shot. It all depends on what you changed it to, after all it's your choice.

Doing it yourself
The next step is getting stuck in, browsing through the code, changing things as you see fit, and then loading up Generals to see what effects your changes have. Editing is a thing that is best learned by looking and trying, not by reading. You have to do it to understand it. Once you get the hang of the basics, there are other guides out there (I'm sure) that will get you through the more specific problems. And if your game crashes, you can often get a hint in the direction of the fault by looking at the ReleaseCrashInfo.txt file in My Documents/Command and Conquer Generals. And if that doesn't even help, then there's always these boards right?

Good luck and have fun!