BT410 Phase 5.3.20: missiles fly on the AUTHENTIC 'mslhit' family

The explosionModelFile decode: SRM6's streamed value 17 is a real resource
FAMILY id -- 'mslhit', 3 members: VideoModel(225), AudioStreamList(227) and
an 8-byte GameModel(228) = { int 498, maxTimeOfFlight 5.0 }.  The round now
spawns on that family and reads the AUTHORED 5.0s lifetime (range 800 at
~160 u/s checks out); the owner-family fallback stays for content without a
projectile family (sanity band keeps the default there).

Two engine truths closed the wave: (1) collision volumes are the Mover
DEFAULT -- a projectile spawn MUST pass NoCollisionVolumeFlag or the ctor
demands a BoxedSolidStream member the family doesn't carry (SearchList
NULL -> Lock() page fault -- the crash that originally masqueraded as a
"model-list index"); (2) the @0x414938 SearchList crash is the
missing-MEMBER case (Check compiled out) -- probe families manually before
handing them to engine paths.  Resource type numbering mapped and recorded
(15=GameModel, 10=VideoModel, 20=DamageZoneStream, ...).  BT_MODEL_DUMP=1
keeps the raw family/record dump as a decode bench.

Verified: 20 launches -> 20 detonations on the mslhit family over 110s,
zero faults; smoke + novice green.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Cyd
2026-07-24 14:17:04 -05:00
co-authored by Claude Fable 5
parent fdf26d6e55
commit 76acc516e4
3 changed files with 601 additions and 334 deletions
+218 -2
View File
@@ -171,10 +171,226 @@ void
// our staged flight integration reads none of the Mover mass/drag.
//
{
//
// DEV one-shot (BT_MODEL_DUMP=1): raw-dump the mech's ModelList
// stream -- the decode bench for the explosionModelFile INDEX
// (SRM6 reads 17). The owner's make resourceID IS the
// ModelList record (CreatePlayerVehicle passes
// mech_res->resourceID).
//
{
static int dumped = 0;
if (!dumped && getenv("BT_MODEL_DUMP"))
{
dumped = 1;
ResourceDescription *ml =
application->GetResourceFile()->
FindResourceDescription(owner->GetResourceID());
if (ml != NULL)
{
ml->Lock();
unsigned char *raw =
(unsigned char *)ml->resourceAddress;
int size = ml->resourceSize;
DEBUG_STREAM << "[mdl] list res id=" << ml->resourceID
<< " type=" << ml->resourceType
<< " size=" << size
<< " count=" << *(int *)raw << endl;
int limit = (size < 640) ? size : 640;
for (int bb = 0; bb < limit; bb += 16)
{
DEBUG_STREAM << "[mdl] +" << bb << ":";
int cc;
for (cc = bb; cc < bb + 16 && cc < limit; ++cc)
{
DEBUG_STREAM << " " << (unsigned)raw[cc];
}
DEBUG_STREAM << " ";
for (cc = bb; cc < bb + 16 && cc < limit; ++cc)
{
char ch = (raw[cc] >= 32 && raw[cc] < 127)
? (char)raw[cc] : '.';
DEBUG_STREAM << ch;
}
DEBUG_STREAM << endl;
}
//
// Identify the members + the streamed
// explosionModelFile value by name/type.
//
int nn = *(int *)raw;
if (nn > 0 && nn < 40)
{
int *ids = (int *)(raw + 4);
for (int ee = 0; ee < nn; ++ee)
{
ResourceDescription *mm =
application->GetResourceFile()->
FindResourceDescription(ids[ee]);
DEBUG_STREAM << "[mdl] member[" << ee
<< "] id=" << ids[ee];
if (mm != NULL)
{
DEBUG_STREAM << " type=" << mm->resourceType
<< " name=" << mm->resourceName;
}
DEBUG_STREAM << endl;
}
}
{
ResourceDescription *ex =
application->GetResourceFile()->
FindResourceDescription(
explosionResourceID);
DEBUG_STREAM << "[mdl] explosionModelFile="
<< explosionResourceID;
if (ex != NULL)
{
DEBUG_STREAM << " -> type=" << ex->resourceType
<< " name=" << ex->resourceName
<< " size=" << ex->resourceSize;
}
else
{
DEBUG_STREAM << " -> NOT IN DIRECTORY";
}
DEBUG_STREAM << endl;
//
// Walk the explosion family's OWN members.
//
if (ex != NULL && ex->resourceType ==
ResourceDescription::ModelListResourceType)
{
ex->Lock();
int *xr = (int *)ex->resourceAddress;
int xn = xr[0];
DEBUG_STREAM << "[mdl] '" << ex->resourceName
<< "' members=" << xn << endl;
for (int xx = 0; xx < xn && xx < 16; ++xx)
{
ResourceDescription *xm =
application->GetResourceFile()->
FindResourceDescription(xr[1 + xx]);
DEBUG_STREAM << "[mdl] [" << xx
<< "] id=" << xr[1 + xx];
if (xm != NULL)
{
DEBUG_STREAM
<< " type=" << xm->resourceType
<< " name=" << xm->resourceName
<< " size=" << xm->resourceSize;
}
DEBUG_STREAM << endl;
//
// The GameModel member: dump as floats
// (the missile model record -- lifetime
// @+0x44, thrust @+0x48, mode @+0x50).
//
if (xm != NULL && xm->resourceType ==
ResourceDescription::GameModelResourceType)
{
xm->Lock();
float *fv = (float *)xm->resourceAddress;
int nf = xm->resourceSize / 4;
for (int ff = 0; ff < nf; ++ff)
{
DEBUG_STREAM << "[mdl] +"
<< (ff * 4)
<< " f=" << fv[ff]
<< " i=" << ((int *)fv)[ff]
<< endl;
}
xm->Unlock();
}
}
ex->Unlock();
}
}
DEBUG_STREAM << flush;
ml->Unlock();
}
}
}
//
// Resolve the round's resource FAMILY. The streamed
// explosionModelFile IS a family id after all (SRM6 = 17 =
// 'mslhit': VideoModel + AudioStreamList + an 8-byte GameModel
// {int 498, maxTimeOfFlight 5.0}). Guard: only use it when the
// family really carries a GameModel MEMBER -- the Mover base
// ctor SearchLists for one and CRASHES on a missing member
// (the walk runs off the family list). Fallback = the owner's
// family (GameModel provably present).
//
ResourceDescription::ResourceID round_family =
owner->GetResourceID();
if (explosionResourceID != ResourceDescription::NullResourceID)
{
ResourceDescription *family =
application->GetResourceFile()->
FindResourceDescription(explosionResourceID);
if (family != NULL
&& family->resourceType
== ResourceDescription::ModelListResourceType)
{
family->Lock();
int *members = (int *)family->resourceAddress;
int member_count = members[0];
Logical family_complete = True;
Logical has_game_model = False;
for (int mi = 0; mi < member_count; ++mi)
{
ResourceDescription *member =
application->GetResourceFile()->
FindResourceDescription(members[1 + mi]);
if (member == NULL)
{
//
// A member id absent from the directory makes
// the engine SearchList walk CRASH -- this
// family is unusable for the Mover make.
//
family_complete = False;
}
else if (member->resourceType
== ResourceDescription::GameModelResourceType)
{
has_game_model = True;
}
}
if (family_complete && has_game_model)
{
round_family = explosionResourceID;
//
// Keep the family RESIDENT (no Unlock): dropping a
// first-touch family back to lockCount 0 left the
// engine's re-Lock inside the Mover ctor reading a
// dead list (SearchList returned NULL on members we
// just resolved). The binary's launcher holds its
// projectile model locked for the mission anyway.
//
}
else
{
family->Unlock();
}
}
}
HostManager *host_manager = application->GetHostManager();
Check(host_manager);
Origin muzzle = owner->localOrigin;
//
// NoCollisionVolumeFlag is LOAD-BEARING: collision volumes are
// the Mover DEFAULT (IsCollisionVolume = the flag NOT set), and
// the ctor then demands a BoxedSolidStream member -- which a
// projectile family doesn't carry (SearchList NULL ->
// Lock() page fault). The round's collision is the world
// query / proximity fuse, not a boxed solid.
//
Mover::MakeMessage
spawn_round(
Entity::MakeMessageID,
@@ -182,8 +398,8 @@ void
EntityID(host_manager->GetLocalHostID()),
(Entity::ClassID)MissileClassID,
EntityID::Null,
owner->GetResourceID(),
Entity::DefaultFlags,
round_family,
Entity::DefaultFlags | Mover::NoCollisionVolumeFlag,
muzzle,
Motion::Identity,
Motion::Identity
+355 -324
View File
@@ -1,324 +1,355 @@
//===========================================================================//
// File: missile.cpp //
// Project: BattleTech Brick: Mech weapons //
// Contents: Missile -- the guided self-propelled projectile entity //
//---------------------------------------------------------------------------//
// Copyright (C) 1995, Virtual World Entertainment, Inc. //
// All Rights reserved worldwide //
// This unpublished sourcecode is PROPRIETARY and CONFIDENTIAL //
//===========================================================================//
//
// RECONSTRUCTED against the binary via the BT411 decomp (ctor @004bf5b4,
// MoveAndCollide @004bef78, allocator @004bf8bc) and the surviving
// SEEKER.HPP / MISTHRST.HPP. See MISSILE.NOTES.md for the staged pieces
// (flight constants pending the missile GameModel record decode; world
// collision + explosion entity are the render/effects wave).
//
#include <bt.hpp>
#pragma hdrstop
#if !defined(MISSILE_HPP)
# include <missile.hpp>
#endif
#if !defined(SEEKER_HPP)
# include <seeker.hpp>
#endif
#if !defined(MISTHRST_HPP)
# include <misthrst.hpp>
#endif
#if !defined(MECH_HPP)
# include <mech.hpp>
#endif
#if !defined(RANDOM_HPP)
# include <random.hpp>
#endif
//
// Guidance tuning (binary .rdata @004bf594..@004bf5b0, BT411-decoded).
// STAGED-DEFAULT flight envelope: lifetime / thrust come from the missile
// GameModel record (model +0x44 / +0x48) once that layout is decoded; until
// then the defaults below fly a believable SRM (fast, short-burn).
//
static const Scalar MissileSteerEps = 1.0e-4f; // _DAT_004bf598 steering deadband
static const Scalar MissileTurnGain = 4.0f; // _DAT_004bf5a4 turn rate gain (1/s)
static const Scalar MissileDriftGain = 0.1f; // _DAT_004bf5a8
static const Scalar DefaultLifetime = 10.0f; // model +0x44 (staged default)
static const Scalar DefaultFuseRadius = 20.0f; // proximity fuse (staged)
Derivation
Missile::ClassDerivations(
Projectile::ClassDerivations,
"Missile"
);
Missile::SharedData
Missile::DefaultData(
Missile::ClassDerivations,
Mover::MessageHandlers,
Mover::AttributeIndex,
1,
(Entity::MakeHandler)Missile::Make
);
Missile*
Missile::Make(MakeMessage *creation_message)
{
return new Missile(creation_message);
}
//
//#############################################################################
// Construction (binary @004bf5b4). Chains the Projectile base (Entity
// transform + Mover motion/model stream -- the MakeMessage's resourceID is
// the launcher's explosion/projectile GameModel). The subsystem roster is
// built in Launch(), which carries the target the binary's spawn descriptor
// delivered to the ctor.
//#############################################################################
//
Missile::Missile(
MakeMessage *creation_message,
SharedData &shared_data
):
Projectile(creation_message, shared_data)
{
Check(creation_message);
lifetime = DefaultLifetime;
ageFraction = 0.0f;
age = 0.0f;
detonationFlag = 0;
flightVelocity = Vector3D(0.0f, 0.0f, 0.0f);
fuseRadius = DefaultFuseRadius;
launcherEntityID = EntityID::Null;
telemetryCountdown = 0;
Check_Fpu();
}
Missile::~Missile()
{
if (getenv("BT_MECH_LOG"))
{
DEBUG_STREAM << "[msl] dtor (death row fry)" << endl << flush;
}
}
Logical
Missile::TestInstance() const
{
return IsDerivedFrom(ClassDerivations);
}
//
//#############################################################################
// Launch -- seed the flight (the binary ctor tail + spawn-descriptor
// unpack). Builds the two-subsystem roster (Seeker @004bec34 with the
// homing target, MissileThruster @004be7c4), aims the initial velocity at
// the target and installs the guided integrator as the per-frame
// Performance. Tail = SetValidFlag(), like every 1995 entity.
//#############################################################################
//
void
Missile::Launch(
Mech *launcher,
Entity *target,
Damage &damage,
Scalar launch_speed
)
{
Check(this);
Check(launcher);
launcherEntityID = launcher->GetEntityID();
damageData = damage;
//
// The 2-entry subsystem roster (binary this[0x49] = 2).
//
subsystemCount = SubsystemCount;
subsystemArray = new Subsystem *[SubsystemCount];
Register_Pointer(subsystemArray);
subsystemArray[SeekerSubsystem] =
new Seeker(this, SeekerSubsystem, NULL, target,
Point3D(0.0f, 0.0f, 0.0f));
Register_Object(subsystemArray[SeekerSubsystem]);
subsystemArray[MissileThrusterSubsystem] =
new MissileThruster(this, MissileThrusterSubsystem, NULL);
Register_Object(subsystemArray[MissileThrusterSubsystem]);
//
// Initial velocity: straight at the target's current position (the
// authored MuzzleVelocity up-tilt arc through the MOUNT frame is the
// muzzle wave -- the seeker converges either way).
//
if (target != NULL)
{
Vector3D aim;
aim.Subtract(
target->localOrigin.linearPosition,
localOrigin.linearPosition
);
Scalar range = aim.Length();
if (range > 0.01f)
{
flightVelocity.x = aim.x / range * launch_speed;
flightVelocity.y = aim.y / range * launch_speed;
flightVelocity.z = aim.z / range * launch_speed;
}
}
SetPerformance(&Missile::MoveAndCollide);
AlwaysExecute();
SetValidFlag();
if (getenv("BT_MECH_LOG"))
{
DEBUG_STREAM << "[msl] LAUNCH from " << launcherEntityID
<< " at (" << localOrigin.linearPosition.x
<< "," << localOrigin.linearPosition.y
<< "," << localOrigin.linearPosition.z
<< ") spd=" << launch_speed
<< " dmg=" << damageData.damageAmount
<< "x" << damageData.burstCount << endl << flush;
}
}
//
//#############################################################################
// MoveAndCollide (binary @004bef78) -- the guided per-frame integrator.
//
// 1. Age; past the lifetime the round fizzles (death row, no damage).
// 2. Re-lead the target (Seeker::FindTarget) + bleed the thruster burn.
// 3. Steer the velocity toward the Seeker's lead point (turn gain 4.0,
// deadband 1e-4) and integrate the position.
// 4. Proximity fuse: inside fuseRadius of the aim point the round
// DETONATES -- the cluster damage record lands on the target (random
// hull zone interim, same as the direct path) and the round retires.
// World-geometry collision (@0042291c) + the explosion entity
// (@004be078, ClassID 0x5C) are the render/effects wave.
//#############################################################################
//
void
Missile::MoveAndCollide(Scalar time_slice)
{
Check(this);
age += time_slice;
ageFraction = (age <= lifetime) ? age / lifetime : 1.0f;
if (age > lifetime)
{
if (getenv("BT_MECH_LOG"))
{
DEBUG_STREAM << "[msl] fizzle (lifetime) at ("
<< localOrigin.linearPosition.x << ","
<< localOrigin.linearPosition.y << ","
<< localOrigin.linearPosition.z << ")" << endl << flush;
}
CondemnToDeathRow();
Check_Fpu();
return;
}
Seeker *seeker =
(Seeker *)subsystemArray[SeekerSubsystem];
MissileThruster *thruster =
(MissileThruster *)subsystemArray[MissileThrusterSubsystem];
Check(seeker);
Check(thruster);
//
// The hosted subsystems are advanced FROM the integrator (the binary
// folds their work into this pass -- no separate roster tick).
//
seeker->FindTarget(time_slice);
thruster->MissileThrusterSimulation(time_slice);
//
// Steering: bend the velocity toward the seeker's lead point at
// MissileTurnGain per second, holding speed; the thruster adds pace
// while burning.
//
Vector3D toLead;
toLead.Subtract(seeker->targetPosition, localOrigin.linearPosition);
Scalar range = toLead.Length();
Scalar speed = flightVelocity.Length();
if (thruster->burnTimeRemaining > 0.0f)
{
speed += thruster->thrusterAcceleration * time_slice;
}
if (range > MissileSteerEps)
{
Scalar blend = MissileTurnGain * time_slice;
if (blend > 1.0f)
{
blend = 1.0f;
}
Vector3D desired;
desired.x = toLead.x / range * speed;
desired.y = toLead.y / range * speed;
desired.z = toLead.z / range * speed;
flightVelocity.x += (desired.x - flightVelocity.x) * blend;
flightVelocity.y += (desired.y - flightVelocity.y) * blend;
flightVelocity.z += (desired.z - flightVelocity.z) * blend;
}
localOrigin.linearPosition.x += flightVelocity.x * time_slice;
localOrigin.linearPosition.y += flightVelocity.y * time_slice;
localOrigin.linearPosition.z += flightVelocity.z * time_slice;
localToWorld = localOrigin;
//
// The proximity fuse (the BANKED seeker notes: fuse on the seeker's
// rangeToTarget).
//
seeker->rangeToTarget = range;
if (range <= fuseRadius && seeker->targetEntity != NULL)
{
Entity *victim = seeker->targetEntity;
int zone = -1;
if (victim->damageZoneCount > 0)
{
zone = Random(victim->damageZoneCount);
}
Entity::TakeDamageMessage
hit(
Entity::TakeDamageMessageID,
sizeof(Entity::TakeDamageMessage),
launcherEntityID,
zone,
damageData
);
victim->Dispatch(&hit);
if (getenv("BT_MECH_LOG"))
{
DEBUG_STREAM << "[msl] DETONATE on zone " << zone
<< " amount=" << damageData.damageAmount
<< " burst=" << damageData.burstCount
<< " after " << age << "s" << endl << flush;
}
CondemnToDeathRow();
Check_Fpu();
return;
}
if (getenv("BT_MECH_LOG") && --telemetryCountdown <= 0)
{
telemetryCountdown = 30;
DEBUG_STREAM << "[msl] t=" << age
<< " pos=(" << localOrigin.linearPosition.x
<< "," << localOrigin.linearPosition.y
<< "," << localOrigin.linearPosition.z
<< ") range=" << range
<< " spd=" << speed << endl << flush;
}
Check_Fpu();
}
//===========================================================================//
// File: missile.cpp //
// Project: BattleTech Brick: Mech weapons //
// Contents: Missile -- the guided self-propelled projectile entity //
//---------------------------------------------------------------------------//
// Copyright (C) 1995, Virtual World Entertainment, Inc. //
// All Rights reserved worldwide //
// This unpublished sourcecode is PROPRIETARY and CONFIDENTIAL //
//===========================================================================//
//
// RECONSTRUCTED against the binary via the BT411 decomp (ctor @004bf5b4,
// MoveAndCollide @004bef78, allocator @004bf8bc) and the surviving
// SEEKER.HPP / MISTHRST.HPP. See MISSILE.NOTES.md for the staged pieces
// (flight constants pending the missile GameModel record decode; world
// collision + explosion entity are the render/effects wave).
//
#include <bt.hpp>
#pragma hdrstop
#if !defined(MISSILE_HPP)
# include <missile.hpp>
#endif
#if !defined(SEEKER_HPP)
# include <seeker.hpp>
#endif
#if !defined(MISTHRST_HPP)
# include <misthrst.hpp>
#endif
#if !defined(MECH_HPP)
# include <mech.hpp>
#endif
#if !defined(RANDOM_HPP)
# include <random.hpp>
#endif
#if !defined(APP_HPP)
# include <app.hpp>
#endif
//
// Guidance tuning (binary .rdata @004bf594..@004bf5b0, BT411-decoded).
// STAGED-DEFAULT flight envelope: lifetime / thrust come from the missile
// GameModel record (model +0x44 / +0x48) once that layout is decoded; until
// then the defaults below fly a believable SRM (fast, short-burn).
//
static const Scalar MissileSteerEps = 1.0e-4f; // _DAT_004bf598 steering deadband
static const Scalar MissileTurnGain = 4.0f; // _DAT_004bf5a4 turn rate gain (1/s)
static const Scalar MissileDriftGain = 0.1f; // _DAT_004bf5a8
static const Scalar DefaultLifetime = 10.0f; // model +0x44 (staged default)
static const Scalar DefaultFuseRadius = 20.0f; // proximity fuse (staged)
Derivation
Missile::ClassDerivations(
Projectile::ClassDerivations,
"Missile"
);
Missile::SharedData
Missile::DefaultData(
Missile::ClassDerivations,
Mover::MessageHandlers,
Mover::AttributeIndex,
1,
(Entity::MakeHandler)Missile::Make
);
Missile*
Missile::Make(MakeMessage *creation_message)
{
return new Missile(creation_message);
}
//
//#############################################################################
// Construction (binary @004bf5b4). Chains the Projectile base (Entity
// transform + Mover motion/model stream -- the MakeMessage's resourceID is
// the launcher's explosion/projectile GameModel). The subsystem roster is
// built in Launch(), which carries the target the binary's spawn descriptor
// delivered to the ctor.
//#############################################################################
//
Missile::Missile(
MakeMessage *creation_message,
SharedData &shared_data
):
Projectile(creation_message, shared_data)
{
Check(creation_message);
lifetime = DefaultLifetime;
ageFraction = 0.0f;
age = 0.0f;
detonationFlag = 0;
flightVelocity = Vector3D(0.0f, 0.0f, 0.0f);
fuseRadius = DefaultFuseRadius;
launcherEntityID = EntityID::Null;
telemetryCountdown = 0;
//
// The authored flight envelope, from our family's GameModel record (the
// binary's ResolveModel). The 'mslhit' record is 8 bytes:
// { int 498, Scalar maxTimeOfFlight } -- SRM reads 5.0s (range 800 at
// ~160 u/s checks out). Sanity-banded: the owner-family fallback's
// GameModel is a MECH record whose +4 is a turn rate, and the band
// keeps the default in that case.
//
{
ResourceDescription *game_model =
application->GetResourceFile()->SearchList(
resourceID,
ResourceDescription::GameModelResourceType
);
if (game_model != NULL && game_model->resourceSize >= 8)
{
game_model->Lock();
Scalar authored =
((Scalar *)game_model->resourceAddress)[1];
if (authored > 0.5f && authored < 30.0f)
{
lifetime = authored;
}
game_model->Unlock();
}
}
Check_Fpu();
}
Missile::~Missile()
{
if (getenv("BT_MECH_LOG"))
{
DEBUG_STREAM << "[msl] dtor (death row fry)" << endl << flush;
}
}
Logical
Missile::TestInstance() const
{
return IsDerivedFrom(ClassDerivations);
}
//
//#############################################################################
// Launch -- seed the flight (the binary ctor tail + spawn-descriptor
// unpack). Builds the two-subsystem roster (Seeker @004bec34 with the
// homing target, MissileThruster @004be7c4), aims the initial velocity at
// the target and installs the guided integrator as the per-frame
// Performance. Tail = SetValidFlag(), like every 1995 entity.
//#############################################################################
//
void
Missile::Launch(
Mech *launcher,
Entity *target,
Damage &damage,
Scalar launch_speed
)
{
Check(this);
Check(launcher);
launcherEntityID = launcher->GetEntityID();
damageData = damage;
//
// The 2-entry subsystem roster (binary this[0x49] = 2).
//
subsystemCount = SubsystemCount;
subsystemArray = new Subsystem *[SubsystemCount];
Register_Pointer(subsystemArray);
subsystemArray[SeekerSubsystem] =
new Seeker(this, SeekerSubsystem, NULL, target,
Point3D(0.0f, 0.0f, 0.0f));
Register_Object(subsystemArray[SeekerSubsystem]);
subsystemArray[MissileThrusterSubsystem] =
new MissileThruster(this, MissileThrusterSubsystem, NULL);
Register_Object(subsystemArray[MissileThrusterSubsystem]);
//
// Initial velocity: straight at the target's current position (the
// authored MuzzleVelocity up-tilt arc through the MOUNT frame is the
// muzzle wave -- the seeker converges either way).
//
if (target != NULL)
{
Vector3D aim;
aim.Subtract(
target->localOrigin.linearPosition,
localOrigin.linearPosition
);
Scalar range = aim.Length();
if (range > 0.01f)
{
flightVelocity.x = aim.x / range * launch_speed;
flightVelocity.y = aim.y / range * launch_speed;
flightVelocity.z = aim.z / range * launch_speed;
}
}
SetPerformance(&Missile::MoveAndCollide);
AlwaysExecute();
SetValidFlag();
if (getenv("BT_MECH_LOG"))
{
DEBUG_STREAM << "[msl] LAUNCH from " << launcherEntityID
<< " at (" << localOrigin.linearPosition.x
<< "," << localOrigin.linearPosition.y
<< "," << localOrigin.linearPosition.z
<< ") spd=" << launch_speed
<< " dmg=" << damageData.damageAmount
<< "x" << damageData.burstCount << endl << flush;
}
}
//
//#############################################################################
// MoveAndCollide (binary @004bef78) -- the guided per-frame integrator.
//
// 1. Age; past the lifetime the round fizzles (death row, no damage).
// 2. Re-lead the target (Seeker::FindTarget) + bleed the thruster burn.
// 3. Steer the velocity toward the Seeker's lead point (turn gain 4.0,
// deadband 1e-4) and integrate the position.
// 4. Proximity fuse: inside fuseRadius of the aim point the round
// DETONATES -- the cluster damage record lands on the target (random
// hull zone interim, same as the direct path) and the round retires.
// World-geometry collision (@0042291c) + the explosion entity
// (@004be078, ClassID 0x5C) are the render/effects wave.
//#############################################################################
//
void
Missile::MoveAndCollide(Scalar time_slice)
{
Check(this);
age += time_slice;
ageFraction = (age <= lifetime) ? age / lifetime : 1.0f;
if (age > lifetime)
{
if (getenv("BT_MECH_LOG"))
{
DEBUG_STREAM << "[msl] fizzle (lifetime) at ("
<< localOrigin.linearPosition.x << ","
<< localOrigin.linearPosition.y << ","
<< localOrigin.linearPosition.z << ")" << endl << flush;
}
CondemnToDeathRow();
Check_Fpu();
return;
}
Seeker *seeker =
(Seeker *)subsystemArray[SeekerSubsystem];
MissileThruster *thruster =
(MissileThruster *)subsystemArray[MissileThrusterSubsystem];
Check(seeker);
Check(thruster);
//
// The hosted subsystems are advanced FROM the integrator (the binary
// folds their work into this pass -- no separate roster tick).
//
seeker->FindTarget(time_slice);
thruster->MissileThrusterSimulation(time_slice);
//
// Steering: bend the velocity toward the seeker's lead point at
// MissileTurnGain per second, holding speed; the thruster adds pace
// while burning.
//
Vector3D toLead;
toLead.Subtract(seeker->targetPosition, localOrigin.linearPosition);
Scalar range = toLead.Length();
Scalar speed = flightVelocity.Length();
if (thruster->burnTimeRemaining > 0.0f)
{
speed += thruster->thrusterAcceleration * time_slice;
}
if (range > MissileSteerEps)
{
Scalar blend = MissileTurnGain * time_slice;
if (blend > 1.0f)
{
blend = 1.0f;
}
Vector3D desired;
desired.x = toLead.x / range * speed;
desired.y = toLead.y / range * speed;
desired.z = toLead.z / range * speed;
flightVelocity.x += (desired.x - flightVelocity.x) * blend;
flightVelocity.y += (desired.y - flightVelocity.y) * blend;
flightVelocity.z += (desired.z - flightVelocity.z) * blend;
}
localOrigin.linearPosition.x += flightVelocity.x * time_slice;
localOrigin.linearPosition.y += flightVelocity.y * time_slice;
localOrigin.linearPosition.z += flightVelocity.z * time_slice;
localToWorld = localOrigin;
//
// The proximity fuse (the BANKED seeker notes: fuse on the seeker's
// rangeToTarget).
//
seeker->rangeToTarget = range;
if (range <= fuseRadius && seeker->targetEntity != NULL)
{
Entity *victim = seeker->targetEntity;
int zone = -1;
if (victim->damageZoneCount > 0)
{
zone = Random(victim->damageZoneCount);
}
Entity::TakeDamageMessage
hit(
Entity::TakeDamageMessageID,
sizeof(Entity::TakeDamageMessage),
launcherEntityID,
zone,
damageData
);
victim->Dispatch(&hit);
if (getenv("BT_MECH_LOG"))
{
DEBUG_STREAM << "[msl] DETONATE on zone " << zone
<< " amount=" << damageData.damageAmount
<< " burst=" << damageData.burstCount
<< " after " << age << "s" << endl << flush;
}
CondemnToDeathRow();
Check_Fpu();
return;
}
if (getenv("BT_MECH_LOG") && --telemetryCountdown <= 0)
{
telemetryCountdown = 30;
DEBUG_STREAM << "[msl] t=" << age
<< " pos=(" << localOrigin.linearPosition.x
<< "," << localOrigin.linearPosition.y
<< "," << localOrigin.linearPosition.z
<< ") range=" << range
<< " spd=" << speed << endl << flush;
}
Check_Fpu();
}
+28 -8
View File
@@ -55,20 +55,40 @@ app task, one delete per frame, not mid-walk).
- Resource IDs in MakeMessages must be FAMILY ids: the Mover base ctor runs
its own `SearchList(resourceID, GameModelResourceType)`, and member
resources resolve only through their family head.
- The streamed `explosionModelFile` is a small INDEX (SRM6 reads 17), a
model-list indirection like voltageSourceIndex/ammoBinIndex — decoding it
into the real projectile family is the projectile-model brick. Until then
the round spawns on the OWNER's family (GameModel member provably present;
our staged flight reads none of the Mover mass/drag).
- The streamed `explosionModelFile` IS a resource FAMILY id after all
(5.3.20 decode): SRM6's 17 = **'mslhit'** — a 3-member family:
VideoModel (id 225, 100 bytes), AudioStreamList (id 227), and an 8-byte
GameModel (id 228) = `{ int 498, Scalar maxTimeOfFlight }` — SRM reads
**5.0 s** (range 800 at ~160 u/s checks out). Resource TYPE numbering
(RESOURCE.HPP): 1 ModelList, 9 BoxedSolidStream, 10 VideoModel,
**15 GameModel**, 17 SubsystemModelStream, 18 GaugeImageStream,
20 DamageZoneStream, 21 SkeletonStream, 30 ExplosionTableStream. A
family's raw stream = `int count` + count member resource ids (what
SearchList walks).
- **NoCollisionVolumeFlag is LOAD-BEARING on projectile spawns**: collision
volumes are the Mover DEFAULT (`IsCollisionVolume()` = the flag NOT set),
and the ctor then demands a BoxedSolidStream member — which a projectile
family doesn't carry (SearchList NULL → Lock() page fault; the mech
family works because bhk1 carries blh_cv.sld). The round's collision is
the world query / proximity fuse.
- The original SearchList crash (@0x414938) is the missing-MEMBER case:
`Check(res)` on a member id that doesn't resolve is compiled out in opt
and the walk derefs NULL. Probe families manually (FindResourceDescription
per member) before handing them to engine paths.
- The spawn keeps the resolved family LOCKED (no Unlock) — the launcher
holds its projectile model resident, as the binary does.
## Staged / deferred
- Muzzle = mech origin; the authored MuzzleVelocity arc through the MOUNT
segment world frame (fire builder @0x4bcc60:8758-64, z NEGATED + mech
velocity) is the muzzle wave.
- Flight envelope defaults (lifetime 10s, burn 2s @120 u/s², launch 150 u/s,
fuse 20u) pending the missile GameModel record decode (model +0x44
lifetime, +0x48 thrust, +0x50 detonation mode).
- Lifetime is AUTHORED now (5.0 s from the mslhit GameModel, sanity-banded
[0.5, 30] so the owner-family fallback's mech record keeps the default);
burn (2s @120 u/s²), launch speed (150 u/s) and fuse radius (20u) remain
staged — BT411's model +0x44/+0x48/+0x50 offsets describe a bigger record
than the 8-byte 4.10 GameModel, so thrust/detonation-mode live elsewhere
(candidates: the VideoModel record's tail, or per-launcher resources).
- Cluster SPLASH + explosion entity (ClassID 0x5C @004be078), world-geometry
collision (@0042291c), target-velocity intercept lead, Missile
WriteUpdateRecord (tag 0x78) for MP replication.