#95: REVERT the salvo-damage hack; deliver the cluster the way the binary does

Supersedes the mislanch change in efc3e9f, which multiplied the lead round by
missileCount.  That produced roughly the right average total but as ONE lump on
ONE zone, with no scatter and no variance -- not what the arcade does.

WHAT THE BINARY DOES (all byte-verified):
  * MissileLauncher ctor @004bcff0:  burstCount = missileCount;
                                     damageAmount /= missileCount
  * FireWeapon @004bcc60 spawns exactly ONE Missile -- no loop, missileCount is
    never read there.  The salvo IS one cluster round.
  * Missile::Perform rolls how many of the cluster connect right before it
    dispatches (part_013.c:10082):  b = Random(n) + n/4, clamped to n
    -- i.e. between a quarter of the salvo and all of it.
  * It then dispatches DIRECTLY at the struck entity (FUN_004be078:
    param_2->Dispatch(&msg)) -- NOT through the shooter's message manager.
  * Mech::TakeDamageMessageHandler @0x4a0439-0x4a04d8 applies the hit
    burstCount times, RE-ROLLING the struck zone per burst.

Our handler already implements that loop faithfully (mech.cpp, task #80) -- I
wrongly believed it was missing, because the KB asserts as [T1] that "burstCount
is cosmetic for zone damage".  That is half right: DamageZone::TakeDamage really
does ignore burstCount (verified @0041e4e0), but the HANDLER honours it by
calling that function repeatedly.  KB corrected separately.

The actual defect was that the projectile impact path hardcoded burstCount = 1,
and -- worse -- routed damage through the SubsystemMessageManager, whose
consolidation rebuilds the record from a stream carrying only {damageType,
damageAmount, subsystemID}.  DamageInformation has no burstCount field, so the
cluster count was DROPPED in transit no matter what the round carried.

So: dispatch projectile damage directly, as the binary does, carrying the rolled
burst.  This also retires the #84 double explosion architecturally -- the second
blast came from the manager's bundled explosion, and projectiles no longer go
through the manager at all.  The MarkRoundDetonated suppression added in efc3e9f
is therefore dead and is removed.

ALL-WEAPON-CLASS AUDIT (scratchpad/night8/allweap.{sh,py}), one run, all classes
firing at once:
  EXPLOSIVE (missile)  38 zone applications, bursts spread 1x2,2x6,3x9,4x4,5x5,
                       6x12 across ELEVEN zones -- the [n/4..n] roll plus the
                       per-burst zone re-roll, i.e. the cluster scattering
  ENERGY    (beam)      8 applications, burst 1  -- unchanged, no regression
  type4                 8 applications, burst 1  -- unchanged
  COLLISION             0 applications reached armour -- divert intact
Explosions: 10 projectile impacts produce no bundled blast; direct-fire still
queues its own (11 made).

NOT yet verified: cross-pod delivery.  Dispatch reroutes to a replicant on its
own (and the binary relies on exactly that), but the manager routing is gone, so
MP damage should get a two-node run before this ships.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Joe DiPrima
2026-08-01 04:42:15 -05:00
co-authored by Claude Opus 5
parent efc3e9ff1a
commit 3b7c19c232
6 changed files with 144 additions and 119 deletions
+53 -33
View File
@@ -1694,41 +1694,61 @@ static void
Damage dmg;
dmg.damageType = (Enumeration)p.damageType; // issue: was hardcoded Explosive
dmg.damageAmount = p.damage;
dmg.burstCount = 1;
dmg.impactPoint = hitPos; // nearest approach, not the step end
// Route through the SHOOTER's SubsystemMessageManager with the
// firing launcher's roster index (task #7 bundling): the
// consolidation resolves roster[id]+0x3E4 = the weapon's
// ExplosionModelFile (mslhit/acanhit) and fires it AT the
// impact point -- the missing missile-hit explosion (the
// laser path always did this via SendDamageMessage; the
// projectile path bypassed the manager entirely).
SubsystemMessageManager *mgr = 0;
if (p.shooter != 0 && p.weaponSubsys >= 0 && BTIsRegisteredMech(p.shooter))
mgr = (SubsystemMessageManager *)((Mech *)p.shooter)->GetMessageManager();
if (mgr != 0)
//
// CLUSTER BURST (issue #95). A missile salvo is ONE arcade
// Missile entity carrying the PER-MISSILE amount (the launcher
// ctor does `damageAmount /= missileCount; burstCount =
// missileCount` @004bcff0) -- the salvo total is reconstituted
// at the RECEIVER, where Mech::TakeDamageMessageHandler applies
// the hit `burstCount` times, re-rolling the struck zone each
// burst (@0x4a0439-0x4a04d8; mech.cpp, already faithful).
//
// This site hardcoded burstCount = 1, so every salvo delivered
// one missile's worth -- an LRM 15 landing ~3 points instead of
// 50, exactly as players measured.
//
// How many of the cluster connect is ROLLED at impact, in the
// binary's Missile::Perform right before it dispatches
// (part_013.c:10082):
// n = burstCount
// b = Random(n) + n/4, clamped to n
// i.e. between a quarter of the salvo and all of it. That
// variance + the handler's per-burst zone re-roll IS the
// authentic spread; pre-multiplying the amount instead would
// dump the whole salvo on one zone with no scatter.
int bursts = (p.splashBurst > 0) ? p.splashBurst : 1;
if (bursts > 1)
{
// issue #84: this round already spawned its OWN detonation
// at hitPos above. Tell the manager, so the consolidation
// does not ALSO queue this weapon's explosion at the bundle's
// consolidated point a frame later -- the double blast
// players see as "once where the target was, again where it
// is". Direct-fire weapons never mark, so lasers/AC keep
// the bundled explosion they depend on.
mgr->MarkRoundDetonated(p.weaponSubsys);
Entity::TakeDamageMessage take_damage(
Entity::TakeDamageMessageID, sizeof(Entity::TakeDamageMessage),
p.shooter->GetEntityID(), -1 /*unaimed -> cylinder resolves*/,
dmg, p.weaponSubsys);
mgr->AddDamageMessage(tgt, &take_damage);
}
else
{
Entity::TakeDamageMessage take_damage(
Entity::TakeDamageMessageID, sizeof(Entity::TakeDamageMessage),
0 /*inflictor id: bring-up*/, -1 /*unaimed -> cylinder resolves*/, dmg);
tgt->Dispatch(&take_damage);
int rolled = Random(bursts) + (bursts >> 2);
if (rolled > bursts) rolled = bursts;
if (rolled < 1) rolled = 1;
bursts = rolled;
}
dmg.burstCount = bursts;
// DISPATCH DIRECTLY, as the binary's Missile does
// (Missile::Perform -> FUN_004be078: `param_2->Dispatch(&msg)`
// straight at the struck entity). A projectile hit does NOT go
// through the shooter's SubsystemMessageManager in the arcade.
//
// The port used to route it there (task #7) purely to borrow the
// manager's impact explosion, and that cost us both defects
// players reported this session:
// * the consolidation rebuilds the damage record from a stream
// carrying only {damageType, damageAmount, subsystemID} --
// DamageInformation has no burstCount field, so the CLUSTER
// COUNT was dropped in transit and every salvo applied once
// (issue #95); and
// * it queued a SECOND explosion at the bundle's consolidated
// point a frame later -- the double blast (issue #84).
// The round spawns its own detonation at hitPos above, so the
// manager buys us nothing here. Dispatch reroutes cross-pod for
// a replicant victim on its own.
Entity::TakeDamageMessage take_damage(
Entity::TakeDamageMessageID, sizeof(Entity::TakeDamageMessage),
(p.shooter != 0) ? p.shooter->GetEntityID() : EntityID::Null,
-1 /*unaimed -> cylinder resolves*/, dmg, p.weaponSubsys);
tgt->Dispatch(&take_damage);
// gauge scoring wave (Step 6): a projectile hit credits SCORE too
// (tgt == gEnemyMech here; local player is the viewpoint shooter).
BTPostDamageScore((Entity *)tgt, p.damage);
@@ -1755,7 +1775,7 @@ static void
DEBUG_STREAM << "[projectile] IMPACT damage=" << p.damage
<< " subsys=" << p.weaponSubsys
<< " v=" << p.speed << " burnLeft=" << p.burnLeft // #84 thrust evidence
<< (mgr ? " (msgmgr bundled)" : " (direct)")
<< " burst=" << dmg.burstCount << " (direct dispatch)"
<< " (zone cyl-resolved)\n" << std::flush;
// SPLASH (task #62): a detonating missile SALVO damages every