← Home SEEBIE90 DOCS
Download PDF
The RIM-116 & Phalanx mod is published under the Arma Public License (APL)Example code is free to useSuggestions: Discord to the author

RIM-116 & Phalanx

Target acquisition Changed

A world query rather than a hook on the projectile – because the projectile classes cannot be extended at all. Classification then has to separate a helicopter from its own bench seat.

In plain wordsThe mount sweeps the area for things to shoot, then sorts them into aircraft, incoming rockets and shells.

Why a world query and not a hook

Projectile and ProjectileMoveComponent live in scripts/Game/generated/ and cannot be extended with modded class – attempting it aborts the entire script module, not just that class. Their proto external methods are still callable, though, so the velocity can be read straight off a found projectile instead of being estimated from two samples.

NoteThis is the general shape of the limitation: engine classes are closed to modded class but open to calls. Anything that would have been an override becomes a query plus a call.
Example code – free to use
void MyAD_Tracker_Scan()
{
	m_aFound.Clear();
	GetGame().GetWorld().QueryEntitiesBySphere(m_vOrigin, m_fRadius, OnCandidate, null, EQueryEntitiesFlags.DYNAMIC);
}

vector MyAD_Tracker_VelocityOf(IEntity ent)
{
	ProjectileMoveComponent move = ProjectileMoveComponent.Cast(ent.FindComponent(ProjectileMoveComponent));
	if (move)
		return move.GetVelocity();		// callable even where modded class is not

	Physics phys = ent.GetPhysics();
	if (phys && phys.IsDynamic())
		return phys.GetVelocity();

	return vector.Zero;
}

An attachment is not an aircraft

A helicopter was tracked as four targets, and the mount shot at the bench seat. Seats and turrets satisfy “enterable and above ground”, so they classified as aircraft in their own right. The fix is one check at the top of classification – the same hierarchy test that fixes countermeasure detection on the chaff page.

Example code – free to use
MyAD_ETargetKind MyAD_Tracker_Classify(IEntity ent)
{
	// an entity with a parent is part of something else: a seat, a turret, a loaded flare
	if (ent.GetParent())
	{
		m_iRejectedAttachments++;
		return MyAD_ETargetKind.NONE;
	}

	...
}
NoteThe counter is not decoration. A scan report that lists how many candidates were rejected as attachments is the only way to see that a rejection rule is firing – and the only way to notice when it over-fires.
PitfallIn Reforger that single test separates a helicopter from its seats, a launcher from its loaded flares and a vehicle from its turret. It is also the easiest to forget, because everything in the world looks like a top-level entity until you ask.

What gets engaged with what

KindEngaged withNotes
AircraftMissile salvoa short delay before the first shot, longer at long range
Incoming ordnance (rockets, shells)Gun burstno delay – there is no time
Everything elseNot engaged–

Add a dead zone around the mount and a minimum altitude: targets inside either are tracked but not fired at. Both should be per-weapon values rather than shared constants, because a gun and a launcher disagree about what “too close” means.

PitfallA curve scale that looks like a range is not an engagement range. Keep the distance at which a lock-on time curve saturates apart from the distance at which the weapon is allowed to fire – they were conflated once.

Only what ends inside the battery is a targetNew

“The distance is shrinking” is true for every projectile in the half-space in front of the mount. The first version engaged tank rounds and dart penetrators that merely flew in the general direction of the mount, and the alarm and the gun bursts that followed made no sense to the players. The alarm reads the same target list as the weapon, so one filter in the tracker silences both.

The rule that worked is a protected zone for the whole battery, not a circle around each mount: a cylinder around the centre of all mounts in the network, reaching a margin beyond the outermost one and a height above the highest. A projectile is a target only if its path ends inside that cylinder. What flies over does not count.

Kind of projectileHow its path is judged
Unpowered (mortar, artillery)A real ballistic path with gravity, sampled down to the terrain. The impact point has to lie inside the cylinder. A straight line would be wrong – a shell climbs before it falls.
Powered (rocket, missile)A straight path, but against a cylinder of three times the radius, because they steer. It counts when the path enters the cylinder below its upper edge.
Unpowered and very fast (tank round, dart)Not engaged at all: above a speed limit nothing here can intercept them in time.
Example code – free to use
bool MyAD_Tracker_EndsInZone(vector pos, vector vel, bool powered)
{
	float radius = m_fZoneRadius;
	if (powered)
		radius *= 3;			// they correct their course, so look at a wider circle

	if (!powered)
	{
		// walk the ballistic path until it meets the ground, then test the interpolated impact point
		vector impact = MyAD_Ballistics.ImpactPoint(pos, vel);
		return vector.DistanceXZ(impact, m_vZoneCentre) <= radius;
	}

	// straight line: does it cross the cylinder below the upper edge?
	return MyAD_Math.LineEntersCylinder(pos, vel, m_vZoneCentre, radius, m_fZoneTop);
}
NoteThe margin has a floor. A zone that reaches only to the outermost mount would let a shell that lands beside the launcher through, so the mod never goes below 150 m. A margin of zero switches the zone off.
PitfallTest the path maths before the game does. Re-creating the logic in a few lines of script outside the engine and running two dozen cases through it caught real faults – tanks fire with elevation, so a horizontal shot lands 800 m short, and a sphere around one mount counted every overflight. The test can be as wrong as the code, so interpret every deviation before changing either.

A drone is neither an aircraft nor a missileNew

Drones in the common drone mods are plain entities with a rigid body and a damage model – no vehicle, no seats. Classifying them by name alone lets items and crew through, so the build comes first and the name only second: no parent, not a character, belongs to a faction, a dynamic body of at most half a tonne, has a damage model. The order is about cost: classification runs for every moving object in every sweep.

What a drone is then depends on one question: does it carry an explosive trigger? For the engine, an armed drone is ordnance.

DroneTreated asConsequences
Armed (explosive trigger on the root or a direct child)Incoming ordnanceIncoming alarm, no lock-on time, no minimum-altitude rule, a straight path judged against the wider zone, hovering counts inside the zone's airspace.
UnarmedAircraft, flagged as a droneWarning buzzer like a vehicle, but no lock-on time – that time exists to warn a pilot. Can be engaged down to a low altitude.
On the ground (under 2 m)Not a target–

Speed at every movement

A drone's physics speed may be zero on the server even while it moves, so the speed has to be measured. The first idea, a difference from frame to frame, is wrong: replicated positions arrive in steps, and a difference between two frames alternates between zero and a very large number. Measure only when the position has actually changed, divide by the time since the last movement, and smooth the result.

Example code – free to use
float MyAD_Tracker_DroneSpeed(IEntity drone, vector pos, float physicsSpeed)
{
	if (physicsSpeed >= 0.5)
		return physicsSpeed;				// usable physics wins

	MyAD_Track track = GetTrack(drone);
	float now = GetGame().GetWorld().GetWorldTime();

	if (pos != track.m_vLastPos)				// only when it really moved
	{
		float dt = (now - track.m_fLastMoveTime) * 0.001;
		if (dt > 1.0)
			track.m_fSpeed = 0;			// long pause: start over
		else if (dt > 0)
			track.m_fSpeed = 0.6 * (vector.Distance(pos, track.m_vLastPos) / dt) + 0.4 * track.m_fSpeed;

		track.m_vLastPos = pos;
		track.m_fLastMoveTime = now;
	}
	else if (now - track.m_fLastMoveTime > 500)
		track.m_fSpeed = 0;				// no new position for half a second

	return track.m_fSpeed;
}

Who shoots at a drone

A launcher missile is a poor answer to a drone that weighs a kilo. The rule that came out: a launcher engages drones only when no gun stands in the network, and then with at most one missile. Ballistic lead for gravity is switched off for drones, since they fly under their own power.

NoteThe scan report counts drones, drones with usable physics and drones with an estimated speed. Whether a server reports zero physics speed for a steered drone was not known in advance, and these counters are how it is answered.
PitfallNot every combination has been measured in a running game. The scan report is the way to find out on your own server before relying on the numbers.
Example code on this page is free to use in your own projects (credit appreciated). The RIM-116 & Phalanx mod is published under the Arma Public License (APL). Suggestions: Discord. Arma Reforger / Enfusion are trademarks of Bohemia Interactive.
Impressum · Privacy Policy