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.
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.
modded class but open to calls. Anything that would have been an override becomes a query plus a call.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.
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;
}
...
}
What gets engaged with what
| Kind | Engaged with | Notes |
|---|---|---|
| Aircraft | Missile salvo | a short delay before the first shot, longer at long range |
| Incoming ordnance (rockets, shells) | Gun burst | no delay – there is no time |
| Everything else | Not 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.
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 projectile | How 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. |
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);
}
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.
| Drone | Treated as | Consequences |
|---|---|---|
| Armed (explosive trigger on the root or a direct child) | Incoming ordnance | Incoming alarm, no lock-on time, no minimum-altitude rule, a straight path judged against the wider zone, hovering counts inside the zone's airspace. |
| Unarmed | Aircraft, flagged as a drone | Warning 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.
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.