Files
TeslaRel410/restoration/source410/BT/EMITTER.HPP
T
CydandClaude Fable 5 b772e716fe BT410 Phase 5.3.15: the electrical charge model -- real charge, closed feedback loop
The emitter charge cycle is now the authentic electrical model end to end.

- WIRE-VERIFIED resource fix: the Emitter block is graphicLength /
  dischargeTime / seekVoltage[5] (FRACTIONS of the generator's rated voltage,
  -1 sentinel) / seekVoltageRecommendedIndex. The old two-field guess read
  seekVoltage[3]=0.99 as "dischargeTime 0.99s" -- the true PPC discharge is
  0.2s, and the calibration reads seekV={6000,7000,8000,9900} x rated 10000,
  recommended gear 2: the documented curve exactly.
- Ctor calibration (@004bb120): energyTotal=(dmg+heat)x1e7; EC pins
  E=0.5V^2EC to energyTotal at the recommended gear; voltageScale calibrates
  the exponential charge to reach seekV[rec] in the authored RechargeRate
  seconds cold; damageFraction = the damage share.
- TrackSeekVoltage (@004ba838) + ChargeTimeScale (@004b0d50): the charge
  integrates from the generator through the heat-stretched time scale, and
  the I2R loss heats the GENERATOR -- verified GeneratorA at 477.9K charging
  its PPC (BT411 predicted ~+480K) while the avionics generator idles at 77.
  Hot generators charge slower: the heat/firepower feedback loop is CLOSED.
- Emitter::ComputeOutputVoltage override (now virtual, as in the binary
  vtable): dial = level/seekV[gear], 0.01 snap, over-1 clamp.
- Sub-stepped Loading (1/60s slices -- the BT411 weapon-brick fix) + the
  documented-divergence overcharge rescue. VERIFIED: the PPC loads at level
  ~7920, inside the binary's exact [7920,8080] snap window.
- FireWeapon energy algebra (@004bace8): damage/heat = energy shares x
  chargeRatio^2. VERIFIED dmg=11.78 / heat=1.079e8 at ratio 0.9906. The
  heatCost x 1e7 partial is retired -- heat now comes from the energy.

Zero Fail; jams/shutdowns regressions stay live under spam.

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

163 lines
5.2 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;
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// 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