FireControl: the mount factor, AngularVelocity, TrackingRate and PMount, in the price, the freeze, Inspect and the HUD
PMount(AngularVelocity(source, target), TrackingRate(weapon, source)) multiplies HitProbability after the pFire gate; Fire freezes it into PendingShot.PFire; Inspect and the debug HUD show omega, rate and the factor. TrackingRate is the one product of the gun's rate and the ship's gear (ruling tracking-per-gun). Tracking(Entity) in metres still alone forgives the changes of vector (ruling jink-per-ship). Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
8cd71ed6da
commit
b6487afd95
2 changed files with 46 additions and 3 deletions
|
|
@ -193,6 +193,28 @@ public static class FireControl
|
|||
return system != null && system.Item.Active.Value ? system.Tracking : entity.ItemManager.GameplaySettings.UnaidedTracking;
|
||||
}
|
||||
|
||||
// Two trackings, two units. Tracking(Entity) above is the ship's targeting gear in METRES: how much changing of
|
||||
// vector a shooter forgives (PDeviation's tolerance). TrackingRate is a RATE in degrees per second: how fast the
|
||||
// gun's mount can swing, and it alone prices the angular term. The ship's metres never forgive the mount and the
|
||||
// gun's rate never forgives the jink (ruling jink-per-ship).
|
||||
//
|
||||
// How fast the target sweeps across the shooter's sky, in degrees per second: the component of the relative
|
||||
// velocity transverse to the line of sight over the range, floored at one metre so a target on top of the
|
||||
// shooter does not read infinite. Planar, allocation-free, and the one place this angle is computed.
|
||||
public static float AngularVelocity(float2 offset, float2 relativeVelocity)
|
||||
{
|
||||
var range = max(length(offset), 1f);
|
||||
return degrees(abs(offset.x * relativeVelocity.y - offset.y * relativeVelocity.x) / (range * range));
|
||||
}
|
||||
|
||||
public static float AngularVelocity(Entity source, Entity target) =>
|
||||
AngularVelocity((target.Position - source.Position).xz, target.Velocity - source.Velocity);
|
||||
|
||||
// The gun's rate times the ship's gear over the unaided baseline (ruling tracking-per-gun, "gun times ship"): the
|
||||
// one product of the two. An unauthored gun is +infinity and so is its rate.
|
||||
public static float TrackingRate(Weapon weapon, Entity source) =>
|
||||
weapon.Tracking * Tracking(source) / source.ItemManager.GameplaySettings.UnaidedTracking;
|
||||
|
||||
// Cut 3, the risk this map names explicitly: Combat.cs used to run its own first_order_intercept call to
|
||||
// aim, while the roll measured deviation against a separately-computed prediction -- two functions
|
||||
// claiming to answer the same question will eventually disagree, and an AI would then aim at one point and
|
||||
|
|
@ -324,7 +346,7 @@ public static class FireControl
|
|||
|
||||
var targetHull = source.ItemManager.GetData(target.Hull) as HullData;
|
||||
var (sil, pSpread, evasion) = Forecast(weapon, source, target, targetHull, Precision(source), range);
|
||||
return pFire * pSpread * sil.POnHull * PDeviation(evasion, Tracking(source));
|
||||
return pFire * PMount(AngularVelocity(source, target), TrackingRate(weapon, source)) * pSpread * sil.POnHull * PDeviation(evasion, Tracking(source));
|
||||
}
|
||||
|
||||
// Presentation only: the debug HUD's view of exactly the factors HitProbability multiplies. It computes
|
||||
|
|
@ -366,6 +388,9 @@ public static class FireControl
|
|||
diagnostic.POnHull = sil.POnHull;
|
||||
diagnostic.Evasion = evasion;
|
||||
diagnostic.PEvasion = PDeviation(evasion, diagnostic.Tracking);
|
||||
diagnostic.AngularVelocity = AngularVelocity(source, target);
|
||||
diagnostic.TrackingRate = TrackingRate(weapon, source);
|
||||
diagnostic.PMount = PMount(diagnostic.AngularVelocity, diagnostic.TrackingRate);
|
||||
|
||||
diagnostic.PBase = HitProbability(weapon, source, target);
|
||||
return diagnostic;
|
||||
|
|
@ -433,6 +458,17 @@ public static class FireControl
|
|||
public static float PDeviation(float deviation, float tolerance) =>
|
||||
tolerance <= 0f ? (deviation <= 0f ? 1f : 0f) : saturate(1f - deviation / tolerance);
|
||||
|
||||
// The mount's factor: the share of a shot that survives a target sweeping across the sky at `angularVelocity`
|
||||
// degrees per second against a gun whose mount follows `rate` degrees per second. Half at the rate, a sixteenth at
|
||||
// twice it: 0.5^((omega/rate)^2). An infinite rate (an unauthored gun) gives exactly 1; a rate of zero follows
|
||||
// nothing that moves.
|
||||
public static float PMount(float angularVelocity, float rate)
|
||||
{
|
||||
if (rate <= 0f) return angularVelocity <= 0f ? 1f : 0f;
|
||||
var ratio = angularVelocity / rate;
|
||||
return pow(.5f, ratio * ratio);
|
||||
}
|
||||
|
||||
// The commit price's deviation: what the target has already moved off the frozen forecast, plus what it can and
|
||||
// does move off the line of fire (Evasion). The second part applies at any flight time, so an instant weapon
|
||||
// (flight time 0, realized deviation 0) still feels a jinking target.
|
||||
|
|
@ -641,7 +677,8 @@ public static class FireControl
|
|||
// Solve is the one range and the one burst decision Inspect and the weapons' refusal check read too.
|
||||
var solution = Solve(weapon, item, source, target);
|
||||
if (solution.Outcome == FireOutcome.Refused) return 0;
|
||||
var pFire = solution.PFire;
|
||||
// The mount factor is frozen with the shooter-side probability: nothing at commit time re-reads the sweep.
|
||||
var pFire = solution.PFire * (solution.Engaged != null ? PMount(AngularVelocity(source, solution.Engaged), TrackingRate(weapon, source)) : 1f);
|
||||
var fireRange = solution.FireRange;
|
||||
var engaged = solution.Engaged;
|
||||
var travelDirection = solution.TravelDirection;
|
||||
|
|
@ -758,7 +795,7 @@ public static class FireControl
|
|||
}
|
||||
}
|
||||
|
||||
// R3/R4: the one roll. p_base was frozen at fire; the only thing measured live is how far the target has
|
||||
// R3/R4: the one roll. p_base was frozen at fire, PFire carrying the mount factor; the only thing measured live is how far the target has
|
||||
// actually strayed, by now, from where a straight-line projection of its fire-time velocity said it would
|
||||
// be -- forgiven by the targeting system's Tracking, likewise frozen at fire.
|
||||
//
|
||||
|
|
@ -1947,6 +1984,11 @@ public struct FireControlDiagnostic
|
|||
// The target's evasion along the shot (metres) and the share of the shot that survives it at this shooter's Tracking.
|
||||
public float Evasion;
|
||||
public float PEvasion;
|
||||
// The mount: how fast the target sweeps the shooter's sky (degrees per second), the rate this gun on this ship
|
||||
// follows (degrees per second) and the share of the shot that survives it.
|
||||
public float AngularVelocity;
|
||||
public float TrackingRate;
|
||||
public float PMount;
|
||||
public float PBase;
|
||||
// What a round from this weapon does (Solve): the forecast for a fused weapon, whose percentages above do
|
||||
// not describe it. BurstReach is read only when Outcome is Burst.
|
||||
|
|
|
|||
Loading…
Reference in a new issue