Post news RSS Unit coding

I'll show you how to fully add a unit in game and what some of the coding means

Posted by on

well lets get started, I'll be using a plain zh unit for this tutorial extract everything in the inizh and zrtzh files, for good measure do this in the reg generals too if you want to edit that stuff.
First youll need your model, lets use a laser crusader for this tutorial.



Next we'll code the unit, I'll just copy + paste the code and break it down by module
you'll find the laser crusader in data/ini/object/lasergeneral.ini

Ok if youre looking at your code there once you've found it.
Objectname = suchandsuch this is for coding purposes, you'll want to use the exact name when refering to it in the code, it has nothing to do with the display name in game
select portrait, this is the image thats in the far left when you select the unit
Button image, this is the image that shows when the unit is inside of something to show you what spot hes taking up

then upgrade cameos, those are there to let you know what upgrades are available for this unit, and upgrade condition will un-grey them

now our first module, the draw module, this tell the game how to render this unit when hes on the battlefield and how he looks not how he works.
you have your default model, or undamaged nothing going on, then youre boning and grouping comes into play for the turret and muzzles
you'll see a hide sub-object for the laser-crusader, this is to hide a group in game normally, a upgrade can reveal it, like on the Humvee when you upgrade it to have a tow launcher, the tow-launcher subgroup will show
then you have condition states for damaged and really damaged where you select which modle to use, theres one for a hulk as well

then a track-marks code, here you select what tracks to use, theyre hiding in the art folder somewhere, and how they should act, just play with the code to get a feel for it.

Now we hit how the unit is presented to the player, the design parameters
Display name is what it shows ingame when you scroll over it, which can be overridden in some other file
side and editorsorting is for world builder, to help the mapper locate it, basically saying youll find this unit under laser general vehicles
weaponsets, now were to the good stuff, theres a weapon ini where you define weapon sets, how much damage it does ect, well talk about that later
theres condition sets for the weaponsets, like say when its heroic you want it to use a different weapon, or when theres an upgrade it will use a different one. This unit only has 1 weapon in each set, but you can have up to 3

Armour sets, again these are defined in another ini, armour ini which tells the unit how much damage to take from different damage types, like a tank isnt going to take damage from a sniper for example.
the damage fx is also another outside ini, but it basicly defines what happens when the tnk is attacked, what sparks and such should fly off
buildcost/time should be self explanatory, in dollars and seconds

now this is tricky, vision range and shroud clearing range, vision range is what the unit can see, if he cant see it he wont shoot at it, and shroud is what you see as a commander, what he reveals, you can make the vision range bigger than the shroud, so if other units are infront of him he can shoot past his shroud range

power production, negative values with a - infront consume or use energy, if they dont have the - infront and it has a number, it makes that much power

prerequisites, what the player must have in order to build the unit, such as an upgrade generals power building ect

exp req and exp value, value is how much points he gives the enemy when he dies and required is how much he needs to be promoted
is trainable = yes means he can be promoted, if = no means he wont be promoted
crusher and crush-able level, crusher means how big is he? can he smash trees other units ect. crushable means what is he

Command set, ill go into command set laer and youll under stand this much better

audio parameters, what noise to make when

engineering parameters, my favorite of the sections, tells the game what this guy can do.

Radar priority, how it is shown on the radar
kindof are important, it tells the game what the unit is, look at a bunch of units to get the idea

body module, theres a few kinds, like immortal for special units and active for most, it defines how much health the unit has.
maxhealth is his max health 100%, initial is what he rolls out of the factory with, if its less than max he will be damaged if it is more than max then he will have extra health until it is blasted away

subdual damage is a special damage type which shuts off the unit, like the emp weapons use this, here you define how much it takes to shut off the unit, how quickly it will recover and how much by

ai update modules can have a lot of values in them, this one is for the turret and how fast it can turn, controlled weaponslot is if the unit has more than 1 weapon in his weapon set, it cant fire these weapons at the same time, if you put none here then he can fire all at the same time

auto acquire enemies, this means if an enemy comes close enough will i automatically blast him, or must i be ordered to blast him

locomoters are defined by another outside ini, and you can have several for different stages of the unit, its how the aurora can go really fast when he bombs then slows down, he has a normal and aggresive

mass, i havent really figured out what this does, i think it refers to how fast the unit falls.

here we see a list of ocl or object creation lists, that are triggered by upgrades, as you see they allow the unit to build drones

production update, if you want it to be able toi build stuff then he needs this module with a max que of more than 0, the games max is 9 so if you put more than that well too bad 9 is the cap

then we see an xp scaler for an upgrade

then a health upgrade for a different upgrade, theres is something similar for weapons

then we have some death conditions, ocl are used when the unit dies to spawn debris all over the place, and you can use different condition sets for this, like if an overlord runs him over a truuet flying thorugh the overlord wouldn't make sense would it.

then we see a behavoir module for being damaged which starts up some smoke effects
then some more death fx

eject pilot is another ocl to make the little promotion guy appear when the tank dies

another health upgrade

flammable update, this basically means, if hes attack by fire, he will catch fire and take this damage for this time

then finally we have geometry, which defines how big the unit is, you can make him super sized or micro-machine if you play with these values

Ill write the explanations for the other ini later

Comments
dhannemon13
dhannemon13 - - 350 comments

use picture, please ( i confused ) :P

Reply Good karma Bad karma+1 vote
Delta_6
Delta_6 - - 725 comments

Since When He Make this???

Reply Good karma Bad karma+1 vote
Post a comment
Sign in or join with:

Only registered members can share their thoughts. So come on! Join the community today (totally free - or sign in with your social account on the right) and join in the conversation.