Files
TeslaRel410/restoration/source410/BT/SEEKER.CPP
T
CydandClaude Fable 5 110ecec2ca BT410 Phase 5.3.18: flying missiles -- spawn/home/detonate LIVE, teardown open
The Missile entity family is reconstructed: Projectile : Mover gets a real
make-path ctor; Missile hosts the Seeker + MissleThruster roster (the
AUTHENTIC surviving SEEKER.HPP / MISTHRST.HPP interfaces -- the 1995
misspelling included) and flies the binary's guided integrator (@004bef78):
age/lifetime, seeker re-lead with the decoded loft constants
(200/50/300/0.1), thruster burn, steering (gain 4.0, deadband 1e-4), and
the proximity fuse delivering the cluster damage ONCE with the launcher as
inflictor.  Live-verified end-to-end: LAUNCH -> flight telemetry (thruster
visibly accelerating) -> DETONATE on the target ~0.9s out.

OPEN: the first ~Missile off the death row completes, then the frame
page-faults with EIP in the heap -- the first entity/subsystem teardown the
reconstructed sim has ever run.  The spawn path is therefore OPT-IN
(BT_MISSILE_FLIGHT=1); default SRM delivery stays the 5.3.18a instant-hit
cluster (verified 1:1, zero exceptions).  Forensics + engine truths
(SearchList crashes on non-directory ids; MakeMessages need FAMILY resource
ids; explosionModelFile is a model-list INDEX) in MISSILE.NOTES.md.

Also fixed on the way: the Subsystem NAME ctor left damageZone
UNINITIALIZED (latent garbage for every name-built subsystem).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-24 11:58:40 -05:00

196 lines
5.2 KiB
C++

//===========================================================================//
// File: seeker.cpp //
// Project: BattleTech Brick: Mech weapons //
// Contents: Seeker -- the missile's homing-guidance subsystem //
//---------------------------------------------------------------------------//
// Copyright (C) 1995, Virtual World Entertainment, Inc. //
// All Rights reserved worldwide //
// This unpublished sourcecode is PROPRIETARY and CONFIDENTIAL //
//===========================================================================//
//
// The class interface is the AUTHENTIC surviving CODE/BT/BT/SEEKER.HPP
// (07/12/95 GDU). Bodies reconstructed from the binary via the BT411
// decomp: ctor @004bec34, LeadTarget @004beae4 (constants .rdata
// @004bec18..28). The Subsystem base chain is the NAME ctor (binary
// FUN_0041c52c) with the shipped string "Seeker" @00512e1e.
//
#include <bt.hpp>
#pragma hdrstop
#if !defined(SEEKER_HPP)
# include <seeker.hpp>
#endif
#if !defined(MISSILE_HPP)
# include <missile.hpp>
#endif
//
// Lead/guidance tuning (binary .rdata, BT411-decoded).
//
static const Scalar SeekerLeadMinRange = 200.0f; // _DAT_004bec18
static const Scalar SeekerLeadFloor = 50.0f; // _DAT_004bec20
static const Scalar SeekerLeadMaxClamp = 300.0f; // _DAT_004bec24
static const Scalar SeekerLeadCoef = 0.1f; // _DAT_004bec28 (loft gain)
Derivation
Seeker::ClassDerivations(
Subsystem::ClassDerivations,
"Seeker"
);
const Seeker::IndexEntry
Seeker::AttributePointers[] =
{
ATTRIBUTE_ENTRY(Seeker, TargetPosition, targetPosition),
ATTRIBUTE_ENTRY(Seeker, RangeToTarget, rangeToTarget),
ATTRIBUTE_ENTRY(Seeker, RangeFromCreation, rangeFromCreation)
};
Seeker::AttributeIndexSet
Seeker::AttributeIndex(
ELEMENTS(Seeker::AttributePointers),
Seeker::AttributePointers,
Subsystem::AttributeIndex
);
Seeker::SharedData
Seeker::DefaultData(
Seeker::ClassDerivations,
Subsystem::MessageHandlers,
Seeker::AttributeIndex,
Seeker::StateCount
);
//
//#############################################################################
// Construction (binary @004bec34): snapshot the firing geometry -- the
// creation point, the homing target + aim offset, and the initial ranges.
//#############################################################################
//
Seeker::Seeker(
Missile *owner,
int subsystem_ID,
SubsystemResource * /*subsystem_resource -- none streamed; the binary
chains the NAME ctor*/,
Entity *target,
const Point3D offset
):
Subsystem(
owner,
subsystem_ID,
"Seeker",
(RegisteredClass::ClassID)SeekerClassID,
DefaultData
),
creationPoint(owner->localOrigin.linearPosition),
targetOffset(offset)
{
Check(owner);
targetEntity = target;
if (targetEntity == NULL)
{
targetPosition = targetOffset;
}
else
{
targetPosition.x =
targetOffset.x + targetEntity->localOrigin.linearPosition.x;
targetPosition.y =
targetOffset.y + targetEntity->localOrigin.linearPosition.y;
targetPosition.z =
targetOffset.z + targetEntity->localOrigin.linearPosition.z;
}
Vector3D delta;
delta.Subtract(targetPosition, creationPoint);
rangeToTarget = delta.Length();
startingRangeToTarget = rangeToTarget;
rangeFromCreation = 0.0f;
Check_Fpu();
}
Seeker::~Seeker()
{
}
Logical
Seeker::TestInstance() const
{
return IsDerivedFrom(ClassDerivations);
}
//
//#############################################################################
// LeadTarget (binary @004beae4): re-aim at the (moving) target each slice --
// refresh the aim point from the target's live position + offset, then past
// SeekerLeadMinRange loft the aim upward by SeekerLeadCoef x the clamped
// excess (the authored missile arc). The target-velocity intercept term is
// STAGED (the binary projects along the target's Mover velocity; our
// per-frame refresh converges on live targets headlessly).
//#############################################################################
//
void
Seeker::LeadTarget()
{
Check(this);
if (targetEntity == NULL)
{
return;
}
targetPosition.x =
targetOffset.x + targetEntity->localOrigin.linearPosition.x;
targetPosition.y =
targetOffset.y + targetEntity->localOrigin.linearPosition.y;
targetPosition.z =
targetOffset.z + targetEntity->localOrigin.linearPosition.z;
Vector3D toMissile;
toMissile.Subtract(
targetPosition,
GetEntity()->localOrigin.linearPosition
);
Scalar range = toMissile.Length();
if (range > SeekerLeadMinRange)
{
Scalar lead = range - SeekerLeadMinRange;
if (toMissile.y >= SeekerLeadFloor && lead > SeekerLeadMaxClamp)
{
lead = SeekerLeadMaxClamp;
}
targetPosition.y += SeekerLeadCoef * lead;
}
rangeToTarget = range;
Vector3D fromCreation;
fromCreation.Subtract(
GetEntity()->localOrigin.linearPosition,
creationPoint
);
rangeFromCreation = fromCreation.Length();
}
void
Seeker::FindTarget(Scalar /*time_slice*/)
{
Check(this);
LeadTarget();
}
void
Seeker::ResetToInitialState()
{
Check(this);
rangeToTarget = 0.0f;
rangeFromCreation = 0.0f;
startingRangeToTarget = 0.0f;
}