Files
TeslaRel410/restoration/source410/BT/EMITTER.HPP
T
CydandClaude Fable 5 bfff7fe874 BT410 Phase 5.3.22: the cockpit weapon-button column -- generator panel LIVE
The full per-receiver message chain, contiguous ids 3..0xb: PoweredSubsystem
4-8 (SelectGeneratorA-D + ToggleGeneratorMode, binary table @0x50F4EC)
chained on HeatSink's ToggleCooling(3); MechWeapon 9/10 (config buttons,
staged latch bodies); Emitter 0xb ToggleSeekVoltage (@0x511DB8).

SelectGenerator = release the old tap -> roster walk by generatorNumber ->
AttachToVoltageSource -> Connected; mode toggle cycles Manual->Auto->
(detach)->Manual; the seek dial steps the authored voltage ladder with wrap
(a step up re-enters Loading, charge persists).  All novice-locked.
Generator::UntapVoltageSource + PoweredSubsystem::DetachFromVoltageSource
added.  Dev harness: BT_PRESS_GEN=1..4 / BT_PRESS_SEEK.

Verified: PPC_1 retaps GeneratorB (tapped); seek index 2->3, target 9900V
(authored fraction x rated); novice presses INERT; missile fight 14/14 and
smoke green, zero faults.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-24 14:36:32 -05:00

178 lines
5.7 KiB
C++

//===========================================================================//
// File: emitter.hpp //
// Project: BattleTech //
// Contents: Implementation details for energy weapon emitters //
//---------------------------------------------------------------------------//
// Date Who Modification //
// -------- --- ---------------------------------------------------------- //
// //
//---------------------------------------------------------------------------//
// Copyright (C) 1995, Virtual World Entertainment, Inc. //
// All Rights reserved worldwide //
// This unpublished sourcecode is PROPRIETARY and CONFIDENTIAL //
//===========================================================================//
#if !defined(EMITTER_HPP)
# define EMITTER_HPP
# if !defined(MECHWEAP_HPP)
# include <mechweap.hpp>
# endif
//##################### Forward Class Declarations #######################
class Mech;
//###########################################################################
//####################### Emitter Model Resource ########################
//###########################################################################
//
// WIRE-VERIFIED layout: graphicLength, dischargeTime, then the SeekVoltage
// curve -- five FRACTIONS of the generator's rated voltage (-1 sentinel
// ends the list) -- and the recommended (default) gear index. (The earlier
// two-field guess read seekVoltage[3] = 0.99 as "dischargeTime 0.99 s".)
//
struct Emitter__SubsystemResource:
public MechWeapon::SubsystemResource
{
Scalar graphicLength;
Scalar dischargeTime;
Scalar seekVoltage[5];
int seekVoltageRecommendedIndex;
};
//###########################################################################
//############################## Emitter ################################
//###########################################################################
class Emitter:
public MechWeapon
{
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Shared Data Support
//
public:
static Derivation ClassDerivations;
static SharedData DefaultData;
static const HandlerEntry MessageHandlerEntries[];
static MessageHandlerSet MessageHandlers;
//
// The energy-weapon seek-voltage button (binary table @0x511DB8,
// id 0xb, chained after MechWeapon's 9/10; the ammo-weapon branch
// binds 0xb to EjectAmmo in ITS OWN table instead).
//
enum {
ToggleSeekVoltageMessageID = MechWeapon::NextMessageID, // 0xb
NextMessageID
};
void
ToggleSeekVoltageMessageHandler(ReceiverDataMessageOf<int> *message);
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Attribute Support. The energy-weapon family publishes past the MechWeapon
// table end (0x1C) -- the binary's emitter IDs run 0x1D+.
//
public:
enum {
ChargeLevelAttributeID = MechWeapon::NextAttributeID, // 0x1D
NextAttributeID
};
static const IndexEntry AttributePointers[];
static AttributeIndexSet AttributeIndex;
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Test Class Support
//
public:
static Logical
TestClass(Mech &);
Logical
TestInstance() const;
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Construction and Destruction
//
public:
typedef Emitter__SubsystemResource SubsystemResource;
Emitter(
Mech *owner,
int subsystem_ID,
SubsystemResource *subsystem_resource,
SharedData &shared_data = DefaultData
);
~Emitter();
static int
CreateStreamedSubsystem(
ResourceFile *resource_file,
NotationFile *model_file,
const char *model_name,
const char *subsystem_name,
SubsystemResource *subsystem_resource,
NotationFile *subsystem_file,
const ResourceDirectories *directories,
int passes = 1
);
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Weapon interface
//
public:
void
FireWeapon();
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Per-frame simulation (the beam-weapon fire state machine) and the
// electrical charge model: the Loading state integrates currentLevel
// toward the powering generator's voltage (TrackSeekVoltage); Loaded snaps
// when the recharge dial reaches 1.0 (level ~= the selected seek voltage).
//
public:
typedef void
(Emitter::*Performance)(Scalar time_slice);
void
SetPerformance(Performance performance)
{
Check(this);
activePerformance = (Simulation::Performance)performance;
}
void
EmitterSimulation(Scalar time_slice);
void
ResetFiringState();
void
TrackSeekVoltage(Scalar time_slice);
virtual void
ComputeOutputVoltage(); // the charge-voltage form (level/seekV)
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Local Data. chargeLevel is the ChargeLevel attribute alias of the raw
// charge voltage (currentLevel in the binary's naming).
//
protected:
Scalar chargeLevel; // the raw charge voltage (binary currentLevel @0x414)
Scalar dischargeTime;
Scalar dischargeTimer;
Scalar graphicLength;
Scalar seekRate;
Scalar energyCoefficient;
Scalar energyTotal;
Scalar damageFraction;
Scalar damagePortion;
Scalar heatPortion;
int firingActive;
int seekVoltageIndex;
int seekVoltageRecommendedIndex;
int minSeekVoltageIndex;
int maxSeekVoltageIndex;
Scalar seekVoltage[5];
};
#endif