6.1 Configuration Files
All of the units and buildings in Dark Reign 2 are configured using a fairly simple scripting language. The unit files are referred to as "configs". This chapter will teach you how to create new config scripts. We will first take a look at a very basic config, the JDA grunt unit, or Guardian, and break it down.
Creating Objects
The first step to creating a unit is giving it an object name that will be recognized by the game. In this case:
CreateObjectType("jda.unit.guardian", "Unit")
The first two parts of the name "jda.unit.guardian" tells the game which side the config goes on (sprawler or jda) and whether it is a building or a standard unit. If we were making a sprawler structure, you would change the name to "sprawler.building.guardian". After the name, you need to specify any particular traits this unit is going to have. The guardian is the standard type, unit. Other possibilities include "Restore", "Trap", or "Wall". We'll get into what that means later.
Before moving on, you should make sure that this new unit is included in the "types_objects" file for this side. Open up "types_objects_jda.cfg" in data\packs\base\configs\objects\jda. You will see an entry for this unit at the top of the infantry section. If you were creating a new config, you would add it to the bottom of whichever type it is (Buildings, Infantry, Vehicles, Misc).
GameObj
Once the object is created, you need to make a new scope (using a "{") and add the GameObj.
GameObj()
{
ThinkInterval(1);
IdleTask("Tasks::UnitIdle");
Properties()
{
Add("Filter::Biological");
Add("Filter::Transportable");
Add("Filter::Unit");
Add("Filter::JDA");
}
}
This is the top level object from which all the other objects are built. You will see a GameObj in everything from mission scripts to rocks and trees on the map. Inside the GameObj, you can specify the following things:
ThinkInterval - This dictates the processing intervals for the object, or how often it thinks. Don't mess with it.
IdleTask - Pretty self-explanatory. This gives the idle task that the unit will perform when not carrying out an order. "UnitIdle" should be used for any standard combat unit. Other IdleTasks include "UnitConstructor" for buildings that produce units, "RestoreStatic" for buildings that heal, "TransportPad" for buildings that teleport, "UnitCollect" for Collectors, and so on. The best thing to do is to find a unit that performs a similar role and copy its IdleTask over.
Properties - This is where you specify filters, abilities, and other aspects of the unit. A few examples are provided for each.
Filters - Filters are used for several things. The multiplayer set-up screen uses them to screen out units of certain types. Healing units use it to determine whether or not they can restore (ex: Scavers can't heal "Filter::Biological", the Rumbler has "Filter::Biological", thus it can't be healed). Transports and Telepads use it to determine whether a unit can be loaded ("Filter::Transportable").
Ability - Abilities give units buttons on the context menu, such as "Recycle" and "Self Destruct". To give a unit the ability to self-destruct, just add "Ability::SelfDestruct". "Ability::StoreResource" is used by refineries, allowing them to collect resource and add money to the player's store. "Ability::Construction" is used by Rigs and Scavers, allowing them to construct other objects.
Provide - This is used primarily by the HQ, to specify that the building provides certain functions. "Provide::Radar" means that as long as one of these buildings exists and power is supplied, the played will have radar. "Provide::Cloaking" means that it allows cloaking units like traps and the fiend to work. "Provide::EnemyLOS" means that if an enemy spy enters the building, it will give the opponent LOS (Line Of Sight) on all of the player's units.
Client - This is used only in the context of "Client::FacilityBar". Put it on a building if you want it to appear on the facility bar on the bottom left corner of the screen when it is constructed.
All the other Obj's that you will add to this config are built off the GameObj. It is all object-oriented in this respect. The hierarchy looks like this:
GameObj
MapObj
PropObj
ResourceObj
ProjectileObj
ExplosionObj
UnitObj
RestoreObj
TransportObj
SpyObj
WallObj
TrapObj