Configuration Files

UnitObj (6.3)

The next section of the config is called the UnitObj, and as the name implies, it defines the more complex nature of a unit or building on the map.

  UnitObj()
  {
    TopSpeed(45);
    TurnSpeed(1440);

    SeeingRange(65);

    ResponseEvents()
    {
      Add("Attack")
      {
        Add("army.unit.grunt_attack-1.wav");
        Add("army.unit.grunt_attack-2.wav");
        Add("army.unit.grunt_attack-3.wav");
        Add("army.unit.grunt_attack-4.wav");
      }
      Add("Attacked")
      {
        Add("army.unit.grunt_attacked-0.wav");
        Add("army.unit.grunt_attacked-1.wav");
        Add("army.unit.grunt_attacked-2.wav");
      }
      Add("Move")
      {
        Add("army.unit.grunt_move-0.wav");
        Add("army.unit.grunt_move-1.wav");
        Add("army.unit.grunt_move-2.wav");
        Add("army.unit.grunt_move-3.wav");
        Add("army.unit.grunt_move-4.wav");
        Add("army.unit.grunt_move-5.wav");
        Add("army.unit.grunt_move-6.wav");
      }
      Add("Select")
      {
        Add("army.unit.grunt_select-0.wav");
        Add("army.unit.grunt_select-1.wav");
        Add("army.unit.grunt_select-2.wav");
        Add("army.unit.grunt_select-3.wav");
        Add("army.unit.grunt_select-4.wav");
        Add("army.unit.grunt_select-5.wav");
      }
      Add("Spotted")
      {
        Add("army.unit.grunt_spotted-0.wav");
        Add("army.unit.grunt_spotted-1.wav");
      }
    }

    Constructor("army.building.barracks1");
    ConstructionTime(10);
    CreateSource("resource.blob.infantry1");
    CommandCost(1);
    ResourceCost()
    {
      Add("Plastic", 50);
      Add("Electricity", 0);
    }
    Prereqs()
    {
      Add("army.building.barracks1");
    }

    Weapon("army.weapon.grunt");
  }

TopSpeed - This is the top speed in kilometers per hour at which a unit moves across a flat surface. For reference, a speed of 28.8 will make a unit move at exactly 1 cell per second.

TurnSpeed - This is the speed in degrees per second at which a unit rotates. It is best not to exceed 1440.

SeeingRange - This is the distance in meters at which a unit can see. The number is rounded down to the nearest 8 meter cell, thus a range of 89 meters would become 11 cells.

ResponseEvents - These are the sound files a unit will play when an event occurs involving it. You can specify any sound file, even custom ones, so units can have unique voices. The events that use this method are the following:

Note that if a unit doesn't have any sounds specified, then that alert will be silent if it comes from this unit. The two exceptions to this are "Spotted", which has a default Narrator line, and "Attacked", which can be overridden with the "Base under attack" Narrator line using the GameObj properties, as seen in Chapter 1: Creating Objects.

Constructor - Specifies which unit it is being constructed by.

ConstructionTime - How long it takes for the unit to be constructed.

CreateSource - Which type of plastic blob this unit leaves behind on death. When dying, a unit will drop up to 50% of its purchase price into a blob. If the is filled to the max, any overflow is discarded. Also, while electricity blobs do not exist naturally, they would also work in the same way.

CommandCost - This is the value of the unit as it affects the unit limit. The default limit is 70. Everything the player can own costs 1 towards the limit, even things they can't normally build, such as Heroes.

ResourceCost - This specifies what the unit costs to build.

Prereqs - This lists which units must already be constructed by the player in order to build this unit. It is not necessary to list every unit in the build tree, just the highest level. For example, if a unit requires an hq3 and a barracks2, you would only list those two buildings and not the hq1, hq2, and barracks1 that are needed to get there.

Weapon - This defines the weapon that is attached to this unit. The weapon is its own object. We will go through the weapon part of the config a little later in Chapter 5: Creating a Weapon.

These are just the ones used by the Grunt, but there are also several more different attributes you can use under UnitObj:

FireIndirect - This entry doesn't appear in the Grunts's config. It is used for units that do not need to have direct line-of-sight on something in order to fire at it - namely artillery. Put in "FireIndirect(1);" to give a unit the ability to fire at objects using the LOS of other units.
TODO: This behaves significantly different in AMRTS. Figure out the exact implications of using this attribute!

SeeingHeight - TODO: What does this do? Used by the AA Gun and the bug jar in Mission 14???.

Upgrades - This lists the upgrades to a building. Upgrades are their own objects, meaning they can have their own UnitObj and possibly prereqs.

MoveIntoRange - TODO: What does this do? Used by Snipers, Mine Sweepers, Medics, and the Bulldozer???

Wound - This setting is for Hero units. Set this to 1, and when the unit dies, instead of leaving being destroyed, it plays its animation called "Wounded". Then it becomes intangible and sticks around forever.

AutoTargetable - Setting this to 0 will prevent a player's units from automatically acquring this unit as a target. Used by Barbed Wire Posts. Units controlled by computer players will ignore this property.

Altitude - This will make the unit fly or hover above the ground at the specified altitude.
TODO: Accepts two numbers, what's the difference?

RefundConstructor - Set this to 1 for a building, and when it recycles it will generate a new copy of the unit used to buy it. For example, recycle and HQ to get a free Bulldozer.

Selectable - Setting this to 0 means this unit cannot be selected, and it's name and healthbar will not be visible either.

Companion - When a building has finished construction, it will come with this unit for free. For example, a Resource Depot comes with a free Dump Truck.