RIM-116 & Phalanx
The gun variant
A very fast-firing gun against incoming ordnance, in an engine that cannot represent every round as an entity. Build it as a subclass: almost everything about an air defence mount is not weapon-specific.
Inheritance, not a second component
Both mounts share nearly everything: target acquisition, faction assignment, supply from their own container, damage grades with repair, status lamp, alarm, radar coverage, battery logic, slewing. That is a couple of thousand lines nobody maintains twice – a correction to the damage logic would have to be made in two places, and the second would eventually be forgotten.
Remarkably little is weapon-specific, and that little is what the subclass contains. The moving parts map one to one:
| Missile mount | Gun mount | Motion |
|---|---|---|
| turret entity | turret with the arms | traverse |
| box entity | cradle with radome and gun | elevation |
| – | barrel cluster | rotation – new in the subclass |
The cradle carries the radome, which is correct: it sits on the gun's frame and has to move with it.
class MyAD_GunMount : MyAD_Mount
{
protected IEntity m_Barrels; // the only new moving part
override int AmmoPerUnit() { return 100; } // supply cost per reload step
override float FireRateVsOrdnance() { return 4500; } // rounds per minute (example value)
// everything else - tracking, factions, damage, lamps, radar - is inherited unchanged
}
One projectile stands for several rounds
At four thousand rounds per minute that is dozens of entities per second per mount, which is not viable. Let one visible projectile represent a number of rounds: deduct the ammunition accordingly and give the projectile prefab matching damage.
void MyAD_GunMount_Fire()
{
SpawnProjectile(m_Muzzle);
m_iRounds -= ROUNDS_PER_PROJECTILE; // one visible projectile = several real rounds
}
Reverse-engineer the damage from the target rather than guessing it: if a helicopter has a known hull value and only part of the requested damage lands, work back from “two hits should bring it down” to the figure for the cone centre.
Sound has to follow the gun, not the burst
A single shot is very short and needs a small tail to sound like a burst at all. Make the tail too long and short bursts sound longer than the weapon visibly fires – fire sound, muzzle flash and tracers come apart. Keep the tail just long enough to join single shots, then play a separate spin-down sound.
It catches shells in the ascent
With the ballistic predictor from the fire control page, mortar rounds are intercepted on the way up rather than on the way down. Let the gun open fire with a larger aim tolerance than the launcher, because a gun fires while still slewing.