Weapons dump firing heat into their own sinks, sinks conduct through the Condenser bank into the central HeatSink, temperatures drive the degradation/ failure alarms, and every powered subsystem tracks its generator through the electrical state machine. Verified: the authentic fire-discipline game -- a PPC spikes 77->709K per shot, relaxes to 441K across its 5s reload, and sustained fire climbs 441->674->838->960K, brushing the authored 1000K degradation threshold. All calibration values match the BT411 audit exactly (central bank 1.39e6, PPC sink 174000, thresholds 77/1000/2000). - HEAT: HeatSinkSimulation (@004ad924 absorb->T->load->conduct->alarm), ConductHeat/ComputeHeatFlow (@004ad8ac/@004ad9ec two-body equilibrium relaxation; flow==0 exactly at uniform T), UpdateHeatLoad (15-sample filter); heat-state enum + accessors; installed by the HeatSink ctor. - WIRE-VERIFIED: HeatSink resource gains linkedSinkIndex -- THE missing ancestry int that shifted every descendant block +1 (voltageSourceIndex had been reading the linked-sink index: "power sources" appeared to be Condensers). Conduction topology wired from it at construction: weapons->Condensers1-6->central; Generators->Condensers; Reservoir->central. - MECHWEAP resource: authentic pip tail (pipPosition int + pipColor 3 floats + pipExtendedRange int) per the BT411 verified overlay; with linkedSinkIndex this closes the whole +3 alignment mystery (ProjectileWeapon pad deleted). True bhk1 reads: PPC recharge 5.0s (not 1.0), discharge 0.99s, range 900. - POWERSUB: ctor resolves voltageSourceIndex -> GeneratorA-D (wire-verified), taps via Generator::TapVoltageSource (-1 when full); PoweredSubsystemSimulation (@004b0bd0) electrical FSM (Starting/NoVoltage/Shorted/GeneratorOff/Ready); GeneratorSimulation partial (start/short-recovery timers). - Weapons: power step at sim head; Loading recharge gated on electrical Ready (authentic @4bbdf5); FireWeapon dumps firing heat. HEAT UNITS: the chain is 1e7-native with TWO authoring conventions -- energy weapons store small (PPC=11, x1e7 from the energy algebra), ballistics store native (SRM6=5.06e7, dumped raw; double-scaling it was the bring-up runaway-temperature bug). - SENSOR: authentic gating (@004b1c4c) -- power step, electrical-Ready gate, heat-state switch (Degradation x0.5 / Failure 0). Verified Ready + 100%. Deferred: coolant depletion/venting, the novice HeatModelOff gate, the charge model (TrackSeekVoltage/voltage sag/I2R), weapon gate 1 + jam roll, the central sink's forward-linked drain. Zero Fail across fire + neutral runs. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
228 lines
5.6 KiB
C++
228 lines
5.6 KiB
C++
//===========================================================================//
|
|
// File: sensor.cpp //
|
|
// Project: BattleTech Brick: Mech subsystems //
|
|
// Contents: Sensor -- the radar / targeting subsystem //
|
|
//---------------------------------------------------------------------------//
|
|
// Copyright (C) 1995, Virtual World Entertainment, Inc. //
|
|
// All Rights reserved worldwide //
|
|
// This unpublished sourcecode is PROPRIETARY and CONFIDENTIAL //
|
|
//===========================================================================//
|
|
|
|
#include <bt.hpp>
|
|
#pragma hdrstop
|
|
|
|
#if !defined(SENSOR_HPP)
|
|
# include <sensor.hpp>
|
|
#endif
|
|
|
|
#if !defined(MECH_HPP)
|
|
# include <mech.hpp>
|
|
#endif
|
|
|
|
//
|
|
//#############################################################################
|
|
// Shared data support
|
|
//#############################################################################
|
|
//
|
|
Derivation
|
|
Sensor::ClassDerivations(
|
|
PoweredSubsystem::ClassDerivations,
|
|
"Sensor"
|
|
);
|
|
|
|
Sensor::SharedData
|
|
Sensor::DefaultData(
|
|
Sensor::ClassDerivations,
|
|
Subsystem::MessageHandlers,
|
|
Subsystem::AttributeIndex,
|
|
Subsystem::StateCount
|
|
);
|
|
|
|
//
|
|
//#############################################################################
|
|
// The radar / targeting subsystem. A non-replicant (master) instance runs the
|
|
// per-frame SensorSimulation.
|
|
//#############################################################################
|
|
//
|
|
Sensor::Sensor(
|
|
Mech *owner,
|
|
int subsystem_ID,
|
|
SubsystemResource *subsystem_resource
|
|
):
|
|
PoweredSubsystem(owner, subsystem_ID, subsystem_resource, DefaultData)
|
|
{
|
|
Check(owner);
|
|
Check_Pointer(subsystem_resource);
|
|
|
|
radarPercent = 1.0f; // RadarBaseline
|
|
selfTest = False;
|
|
badVoltage = False;
|
|
|
|
//
|
|
// Install the per-frame performance unless the owner is a replicant copy
|
|
// (which is driven by console updates instead).
|
|
//
|
|
if (owner->GetInstance() != Entity::ReplicantInstance)
|
|
{
|
|
SetPerformance(&Sensor::SensorSimulation);
|
|
}
|
|
|
|
Check_Fpu();
|
|
}
|
|
|
|
//
|
|
//#############################################################################
|
|
//#############################################################################
|
|
//
|
|
Sensor::~Sensor()
|
|
{
|
|
}
|
|
|
|
//
|
|
//#############################################################################
|
|
//#############################################################################
|
|
//
|
|
Logical
|
|
Sensor::TestClass(Mech &)
|
|
{
|
|
return True;
|
|
}
|
|
|
|
Logical
|
|
Sensor::TestInstance() const
|
|
{
|
|
return IsDerivedFrom(ClassDerivations);
|
|
}
|
|
|
|
//
|
|
//#############################################################################
|
|
//#############################################################################
|
|
//
|
|
void
|
|
Sensor::ResetToInitialState()
|
|
{
|
|
Check(this);
|
|
|
|
radarPercent = 1.0f; // RadarBaseline
|
|
selfTest = False;
|
|
badVoltage = False;
|
|
|
|
PoweredSubsystem::ResetToInitialState(True);
|
|
}
|
|
|
|
//
|
|
//#############################################################################
|
|
// Per-frame radar / targeting update. Not yet reconstructed -- fires only once
|
|
// the mech is ticking.
|
|
//#############################################################################
|
|
//
|
|
void
|
|
Sensor::SensorSimulation(Scalar time_slice)
|
|
{
|
|
Check(this);
|
|
|
|
//
|
|
// The authentic per-frame sensor update (binary @004b1c4c): the
|
|
// PoweredSubsystem step first, then radarPercent = baseline - structural
|
|
// damage, gated by the electrical Ready state and the heat state.
|
|
// (Still deferred: the novice-mode HeatModelOff gate -- the player
|
|
// experience switch -- joins with the player-link accessor wave.)
|
|
//
|
|
PoweredSubsystemSimulation(time_slice);
|
|
|
|
radarPercent = 1.0f - GetSubsystemDamageLevel(); // RadarBaseline - zoneDamage
|
|
if (radarPercent < 0.0f)
|
|
{
|
|
radarPercent = 0.0f;
|
|
}
|
|
selfTest = True;
|
|
|
|
if (GetVoltageState() == Ready)
|
|
{
|
|
badVoltage = False;
|
|
}
|
|
else
|
|
{
|
|
badVoltage = True;
|
|
radarPercent = 0.0f;
|
|
}
|
|
|
|
switch (GetHeatState())
|
|
{
|
|
case NormalHeat:
|
|
selfTest = True;
|
|
break;
|
|
|
|
case DegradationHeat:
|
|
radarPercent *= 0.5f; // HeatDegradationScale
|
|
selfTest = True;
|
|
break;
|
|
|
|
case FailureHeat:
|
|
radarPercent = 0.0f;
|
|
selfTest = False;
|
|
break;
|
|
|
|
default:
|
|
break;
|
|
}
|
|
|
|
{
|
|
//
|
|
// One-shot confirmation that the engine's per-frame entity/roster tick
|
|
// (Entity::PerformAndWatch) has engaged -- i.e. the mission reached
|
|
// RunningMission and the mech is being simulated each frame.
|
|
//
|
|
static int firstTick = 0;
|
|
if (!firstTick && getenv("BT_MECH_LOG"))
|
|
{
|
|
firstTick = 1;
|
|
DEBUG_STREAM << "[tick] roster live (first Sensor frame), radarPercent="
|
|
<< radarPercent << " voltState=" << GetVoltageState()
|
|
<< endl << flush;
|
|
}
|
|
}
|
|
|
|
Check_Fpu();
|
|
}
|
|
|
|
//
|
|
//#############################################################################
|
|
// Damage / death.
|
|
//#############################################################################
|
|
//
|
|
void
|
|
Sensor::TakeDamage(Damage &damage)
|
|
{
|
|
Check(this);
|
|
PoweredSubsystem::TakeDamage(damage);
|
|
}
|
|
|
|
void
|
|
Sensor::DeathReset(Logical /*full_recovery*/)
|
|
{
|
|
Check(this);
|
|
ResetToInitialState();
|
|
}
|
|
|
|
//
|
|
//#############################################################################
|
|
// CreateStreamedSubsystem Model-load-time construction. Not yet reconstructed
|
|
// (see MECHSUB.NOTES.md -- the 4.10 subsystem stream format).
|
|
//#############################################################################
|
|
//
|
|
int
|
|
Sensor::CreateStreamedSubsystem(
|
|
NotationFile *,
|
|
const char *,
|
|
const char *,
|
|
SubsystemResource *,
|
|
NotationFile *,
|
|
const ResourceDirectories *,
|
|
int
|
|
)
|
|
{
|
|
Fail("Sensor::CreateStreamedSubsystem -- sensor.cpp not yet reconstructed");
|
|
return 0;
|
|
}
|