Files
TeslaRel410/restoration/source410/BT/MECHMPPR.HPP
T
CydandClaude Fable 5 7b57f6b059 BT410 5.3.125: the pilot punches out -- the effectiveness census and EjectPilot complete the authentic message roster, 6 of 6
The combat-effectiveness census (@0049fa1c, the master perf's opening
call) runs at the top of every Simulate frame: a mech is combat-
INEFFECTIVE when its working weapons fall below the ctor-hardcoded
minimum of 2 (+0x448, part_012.c:15749 -- a weapon works when not
destroyed and not a dry launcher, fire state 7 == our NoAmmoState
exactly), when no generator survives (state != 1 and generator state !=
GeneratorFailed -- the binary's +0x210 != 4, our enum value matching),
when the aggregate bank's coolant fraction drops below 0.05 (@0049fb50),
or when limping without the crouch cell held.  Census corrections over
the first read: 0xBBE is the AGGREGATE HEATSINK BANK (coolant fraction,
not generator charge) and 0xBC1 is the GENERATOR (count, not coolant
units) -- both re-pinned through our own classID map.

EjectPilot (@0049f854, id 0x19) consumes it: only a CRIPPLED mech that
is not already dying may eject -- mode 10 (EJECTED, the reason
IsMechDestroyed tests >= 9), the mapper's eject latch (+0x258), and a
self-dispatched explosive TakeDamage (type 2, zone -1 through the
cylinder resolver at the mech's own position).  Staged with the decode
recorded: the damage amount (the binary reads a bound cell through
mapper+0x208 -- no game-side writer exists, the mapper binding-loop
decode will name it) and the score notify (@00429078 + app+0x20 vcall,
event code 5).

Soak (pod_render_eject.conf, BT_FORCE_CRIPPLED + BT_PRESS_EJECT): the
census reads the real roster (weapons=6 generators=4 bank=1.0), the
press runs the whole chain -- eject, vital kill through the cylinder
table, VehicleDead, +5s respawn, HEALED at a fresh drop zone --
crash-sig 0.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-08-07 13:39:24 -05:00

231 lines
7.5 KiB
C++

//===========================================================================//
// File: mechmppr.hpp //
// Project: BattleTech //
// Contents: Implementation details for the mech controls mapper //
//---------------------------------------------------------------------------//
// Date Who Modification //
// -------- --- ---------------------------------------------------------- //
// //
//---------------------------------------------------------------------------//
// Copyright (C) 1995, Virtual World Entertainment, Inc. //
// All Rights reserved worldwide //
// This unpublished sourcecode is PROPRIETARY and CONFIDENTIAL //
//===========================================================================//
#if !defined(MECHMPPR_HPP)
# define MECHMPPR_HPP
# if !defined(SUBSYSTM_HPP)
# include <subsystm.hpp>
# endif
# if !defined(CSTR_HPP)
# include <cstr.hpp>
# endif
# if !defined(CONTROLS_HPP)
# include <controls.hpp>
# endif
# if !defined(VECTOR2D_HPP)
# include <vector2d.hpp>
# endif
//##################### Forward Class Declarations #######################
class Mech;
//###########################################################################
//######################## MechControlsMapper ###########################
//###########################################################################
class MechControlsMapper:
public Subsystem
{
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// The duck button cell (binary mapper+0x25c) -- a device-poll write
// destination like the torso command cells; the master perf's duck
// driver reads it as the held-button gate. The streamed attribute
// binding id is still to be audited (BT_MAP_LOG) -- until a RES table
// binds it, BT_FORCE_DUCK drives it.
//
public:
int
DuckCommand()
{ Check(this); return duckCommand; }
int duckCommand;
//
// The ejection latch (binary mapper+0x258, right beside the duck
// cell): EjectPilot sets it 1 as the pilot punches out; the cockpit
// side reads it (consumer still to be identified).
//
int ejectLatch;
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Shared Data Support
//
public:
static Derivation ClassDerivations;
static SharedData DefaultData;
static const IndexEntry AttributePointers[];
static AttributeIndexSet AttributeIndex;
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Attribute IDs -- the control inputs the streamed mappings bind to.
// The chain ends at Subsystem::NextAttributeID == 2.
//
public:
enum {
MechControlsMapperPadFirstAttributeID = 2,
StickPositionAttributeID, // 3
ThrottlePositionAttributeID, // 4
PedalsPositionAttributeID, // 5
ReverseThrustAttributeID, // 6
SpeedDemandAttributeID, // 7
TurnDemandAttributeID, // 8
LookForwardAttributeID, // 9
LookLeftAttributeID, // a
LookRightAttributeID, // b
LookBehindAttributeID, // c
LookDownAttributeID, // d
TorsoUpAttributeID, // e
TorsoDownAttributeID, // f
TorsoLeftAttributeID, // 10
TorsoRightAttributeID, // 11
TorsoCenterAttributeID, // 12
ControlModeAttributeID, // 13
DisplayModeAttributeID, // 14
PilotArrayPageAttributeID, // 15
PilotArrayAttributeID, // 16
TargetRangeExponentAttributeID, // authored watcher
NextAttributeID
};
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Control modes
//
public:
enum ControlMode {
BasicMode = 0,
StandardMode,
VeteranMode
};
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Look states. A five-state machine off the pod's look buttons; on a state
// change InterpretControls calls Mech::CommitLookState, which re-aims the
// eyepoint from the model's authored look angles (and, once the weapon wave
// lands, re-arms the per-view weapon fire enables).
//
public:
enum LookState {
LookNone = 0,
LookLeftState,
LookRightState,
LookBehindState,
LookDownState
};
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Construction and Destruction
//
public:
MechControlsMapper(
Mech *owner,
int subsystem_ID,
CString subsystem_name,
RegisteredClass::ClassID class_ID,
SharedData &shared_data = DefaultData
);
~MechControlsMapper();
Logical
TestInstance() const;
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Per-frame control interpretation (the mapper's Performance): reads the
// engine-pushed raw input attributes (throttle / stick / pedals / buttons)
// and publishes the locomotion + aim demands the mech drive consumes.
//
public:
typedef void
(MechControlsMapper::*Performance)(Scalar time_slice);
void
SetPerformance(Performance performance)
{
Check(this);
activePerformance = (Simulation::Performance)performance;
}
void
InterpretControls(Scalar time_slice);
Mech*
GetMech() { Check(this); return (Mech *)GetEntity(); }
Scalar
GetSpeedDemand() const { Check(this); return speedDemand; }
Scalar
GetTurnDemand() const { Check(this); return turnDemand; }
//
// The LIMP machines write the demand cell DOWN to the damaged side's
// speed cap (binary GimpLegClipFinished @004a7970 preamble writes
// mapper+0x128 directly) -- a limping mech cannot command more speed
// than its limp figure carries.
//
void
SetSpeedDemand(Scalar demand)
{ Check(this); speedDemand = demand; }
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Local Data -- the published control inputs (the streamed mappings write
// these; InterpretControls, phase 5.3, reads them to drive the mech).
//
public:
//
// The POD ROSTER (binary mapper attributes PilotArrayPage/PilotArray,
// ids 15/16): the comm scoreboard's row source. Zero = no roster
// authored (a solo mission), which is why the shipped cockpit leaves
// that page blank.
//
int
GetPilotArray() const { Check(this); return pilotArray; }
int
GetPilotArrayPage() const { Check(this); return pilotArrayPage; }
protected:
ControlsJoystick stickPosition;
Scalar throttlePosition;
Scalar pedalsPosition;
ControlsButton reverseThrust;
Scalar speedDemand;
Scalar turnDemand;
ControlsButton lookForward;
ControlsButton lookLeft;
ControlsButton lookRight;
ControlsButton lookBehind;
ControlsButton lookDown;
ControlsButton torsoUp;
ControlsButton torsoDown;
ControlsButton torsoLeft;
ControlsButton torsoRight;
ControlsButton torsoCenter;
int controlMode;
int displayMode;
int pilotArrayPage;
int pilotArray;
int lookState;
int previousLookState;
//
// Takes one reserved word (Scalar and int are both 4 bytes here), so
// the class size and every existing offset stay exactly as they were.
//
Scalar targetRangeExponent; // authored watcher
int reserved[21];
};
#endif