Chapter 4: Terrain Objects


Terrain Object Physics

Okay, sure, it's just a tree, but it still needs a Targetware .acm file to tell the Targetware Engine what physics properties it has. For an airplane, the .acm file contain the information that makes up a plane's Flight Model. For a terrain object, the .acm holds critical information on size, mass, and armor. Once you are finished building, texturing, and animating/assembling your terrain object, you need to build an .acm file for it. Don't worry--it's not terribly difficult, and you can copy an existing object's code to use as an example.

Header Section - [Graphics]

This section comes at or near the top of the .acm physics file. As you have probably guessed, it determines what 3D model will be used to represent the object, what kind of explosion it will give off when it dies (if any), and what kind of hit sprites it will give off when damaged. Here is an example from Target Rabaul, a simple RAAF tin barracks building:

[Graphics]
external = structures_a/barracks_t1.anm
tracers = /tr/particles/_tracer/tracers.par
explosion = /tr/particles/_explosion/ground_small.par
damage = /tr/particles/_explosion/hit2.par

Header Section - [Airplane]

Don't be put off by the [Airplane] label, all objects have this heading, whether they are hangars, tanks, ships, or trees. This section comes at or near the top of the .acm physics file, and sets the basic properties of the object. It tells the game engine what name to use when recording the destruction of the object in the buffer and log, how computer-controlled guns should view the object, and how many physics sub-sections make up the object. Here is more from the barracks above:

name = PTO Barracks, Type 1
target_type = soft ground
num_parts = 1

Of particular note here is the "target_type" line. This controls AI guns will react to the object. Valid types are as follows:

  • none
  • air
  • personnel
  • soft ground
  • hard ground
  • soft sea
  • hard sea
  • submarine

All airplanes will have the type "air", while a tank might have "hard ground", a barge "soft sea", and a battleship "hard sea". The caliber and type of gun will determin which types of targets it will engage. A 0.30 caliber light machine gun might only target soft ground, soft sea, personnel, and air targets, while a 14" naval gun might only fire on hard ground, or hard sea targets. The type "none" is appropriate for targets which you never want to see fired upon by AI, such as trees, shrubs, and other objects with no military value. Choose the type for your terrain object carefully.

Part Sections [Part x]

Depending on how simple or complex your object is, you will have one or more [part x] sections. If your object is a solid box-like shape, with no functionality other than as an unmoving mass of steel, then you will probably be able to get away with a single part. Let form and function be your guide to the number of parts you need. Make sure you check out existing objects from other mods, you may be able to use most or all of the code for your new object. Here is a sample code block from our barracks, which does, in fact, only have one part:

[Part 1]
name = main structure
type = Body
mass = 1000
location = 0, 0, 2.1
size = 6, 16.8, 4.2
critical = 1

The name, type, mass, location, and size are all as they are described in the Flight Model section of this Developers Guide. You must have at least one child part in your object with "critical = 1", or your object will never be destroyed, no matter how much damage it takes.

AA, MG Nests, Artillery, and Ship's Guns

If your object is going to have one or more guns mounted in it, you will need to define the gun's physics in the [Part x] sections. You must also specify, for each gun barrel in the object, which type of targets it should fire upon, by using the "valid_targets" line:

valid_targets = xxx [, xxx, ...]

List one or more target types on this line, separated by commas. (See above for a full list of possible target types). The example below is from a 20mm dual purpose anti-tank and anti-aircraft gun from Target Rabaul:

[Part 1]
#include /tr/objects/_guns/j_20mm_t98.acm
name = gun
type = flexgun
valid_targets = soft ground, soft sea, air, personnel, hard ground
location = 0, 0, 1.05
group = 1
max_ammo = 1000
mount_angle = 0, 45
track_left = 180
track_right = 180
track_up = 45
track_down = 45
track_rate = 90
track_distance = 7200
critical = 1

This gun has a fairly wide range of target types that it will shoot at, because of it's dual nature. A strickly anti-aircraft gun would simply have "air" as the only valid target listed, while a 75mm howitzer might have personnel, hard ground, and soft ground as possible targets.

Note that the physics of the actual gun mechanism itself are defined in a separate, shared file, which we have linked to with the "#include" line.

The track_left, track_right, track_up, track_down lines define the gun's ability to swing around, in degrees. The tracking rate is given in degrees per second. "Track_distance" defines both the tracking range, 7200 meters in this case, and the open fire range, which is one-half the tracking range (3600 meters in our example). The max_ammo line is required, but ground/sea gunners never run out of ammo in Targetware.