The energy weapons now run a live fire cycle, and the REAL trigger wiring is in place: the 1995 MechWeapon attribute table (binary @0x511890) is published with PINNED IDs, so the streamed per-mech fire-button mappings bind TriggerState (0x13) -> fireImpulse and the controls push writes the trigger into the weapon. - MECHWEAP: attribute enum + table (PercentDone 0x12, TriggerState 0x13, DistanceToTarget 0x14, TargetWithinRange 0x15, WeaponRange 0x16, EstimatedReadyTime 0x1A, RearFiring 0x1B, WeaponState 0x1C). Pads bridge the chain gap 2..0x11 -- LOAD-BEARING: AttributeIndexSet::Build leaves uncovered gap slots as uninitialized garbage, so every ID up to the max must be covered (they shrink to the authentic 0x0F..0x11 when the parent attribute waves land; SENSOR.HPP pins PoweredSubsystem::NextAttributeID at 0x0F). - MECHWEAP: fire-machine members (fireImpulse/previousFireImpulse, rechargeLevel, rangeToTarget, effectiveRange, estimatedReadyTime, recoil, weaponAlarm 0/2/3/4); CheckFireEdge (@004b9608, BIT-PATTERN int compare -- TriggerState carries raw ControlsButton ints whose release value is a float NaN; IEEE compare would latch the detector shut); ComputeOutputVoltage (@004b9c9c recharge dial). - EMITTER: EmitterSimulation (PARTIAL @004baa88) -- Firing/Loaded/Loading FSM on the weapon alarm, viewFireEnable gate at Loaded->Firing, recoil-decay recharge over the authored RechargeRate seconds; FireWeapon (PARTIAL @004bace8) discharge bookkeeping; ChargeLevel re-pinned to the authentic 0x1D; index re-chained to MechWeapon's. Deferred: electrical charge model (TrackSeekVoltage), heat dump, HasActiveTarget gate, beam/damage submission. - BT_FORCE_FIRE dev hook: trigger pulse whenever Loaded (auto-fire cadence). VERIFIED headlessly: forward view -- PPC_1/2 + ERMLaser_1 cycle FIRED->LOADED at the authored 0.6s/1s cadence, rear lasers silent; BT_FORCE_LOOK=3 -- ONLY the rear lasers (ERMLaser_2/3) fire. The view-fire x fire-FSM interlock holds both directions. Zero Fail. (SRM6 ballistic FSM = a later increment.) Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
214 lines
6.9 KiB
C++
214 lines
6.9 KiB
C++
//===========================================================================//
|
|
// File: mechweap.hpp //
|
|
// Project: BattleTech //
|
|
// Contents: Implementation details for mech weapons //
|
|
//---------------------------------------------------------------------------//
|
|
// Date Who Modification //
|
|
// -------- --- ---------------------------------------------------------- //
|
|
// //
|
|
//---------------------------------------------------------------------------//
|
|
// Copyright (C) 1995, Virtual World Entertainment, Inc. //
|
|
// All Rights reserved worldwide //
|
|
// This unpublished sourcecode is PROPRIETARY and CONFIDENTIAL //
|
|
//===========================================================================//
|
|
|
|
#if !defined(MECHWEAP_HPP)
|
|
# define MECHWEAP_HPP
|
|
|
|
# if !defined(POWERSUB_HPP)
|
|
# include <powersub.hpp>
|
|
# endif
|
|
|
|
# if !defined(DAMAGE_HPP)
|
|
# include <damage.hpp>
|
|
# endif
|
|
|
|
# if !defined(ALARM_HPP)
|
|
# include <alarm.hpp>
|
|
# endif
|
|
|
|
//##################### Forward Class Declarations #######################
|
|
class Mech;
|
|
|
|
//###########################################################################
|
|
//###################### MechWeapon Model Resource ######################
|
|
//###########################################################################
|
|
|
|
struct MechWeapon__SubsystemResource:
|
|
public PoweredSubsystem::SubsystemResource
|
|
{
|
|
Scalar rechargeRate;
|
|
Scalar weaponRange;
|
|
ResourceDescription::ResourceID
|
|
explosionModelFile;
|
|
Scalar damageAmount;
|
|
int damageType;
|
|
Scalar heatCostToFire;
|
|
Scalar pipPositionX;
|
|
Scalar pipPositionY;
|
|
int rearFiring;
|
|
};
|
|
|
|
//###########################################################################
|
|
//############################ MechWeapon ###############################
|
|
//###########################################################################
|
|
|
|
class MechWeapon:
|
|
public PoweredSubsystem
|
|
{
|
|
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
// Shared Data Support
|
|
//
|
|
public:
|
|
static Derivation ClassDerivations;
|
|
static SharedData DefaultData;
|
|
static MessageHandlerSet MessageHandlers;
|
|
|
|
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
// Attribute Support. The real IDs are PINNED to the 1995 binary numbering
|
|
// (table @0x511890, ids 0x12..0x1C): the streamed per-mech control mappings
|
|
// reference them by NUMBER -- TriggerState (0x13) is the fire-button binding.
|
|
// Our parent chain publishes nothing past Subsystem::NextAttributeID (2)
|
|
// yet, so pads bridge the gap 2..0x11 (they shrink to the authentic
|
|
// 0x0F..0x11 once the mechsub/heat/powersub attribute waves publish --
|
|
// SENSOR.HPP pins PoweredSubsystem::NextAttributeID at 0x0F). The pads are
|
|
// LOAD-BEARING: AttributeIndexSet::Build leaves unlisted gap slots as
|
|
// uninitialized garbage, so every ID up to the max must be covered.
|
|
//
|
|
public:
|
|
enum {
|
|
MechWeaponPadFirstAttributeID = Subsystem::NextAttributeID, // 2
|
|
PercentDoneAttributeID = 0x12,
|
|
TriggerStateAttributeID, // 0x13 -- the streamed fire-button binding
|
|
DistanceToTargetAttributeID, // 0x14
|
|
TargetWithinRangeAttributeID, // 0x15
|
|
WeaponRangeAttributeID, // 0x16
|
|
PipPositionAttributeID, // 0x17
|
|
PipColorAttributeID, // 0x18
|
|
PipExtendedRangeAttributeID, // 0x19
|
|
EstimatedReadyTimeAttributeID, // 0x1A
|
|
RearFiringAttributeID, // 0x1B
|
|
WeaponStateAttributeID, // 0x1C (binary table end)
|
|
NextAttributeID // 0x1D (the Emitter family starts here)
|
|
};
|
|
|
|
static const IndexEntry AttributePointers[];
|
|
static AttributeIndexSet AttributeIndex;
|
|
|
|
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
// Test Class Support
|
|
//
|
|
public:
|
|
static Logical
|
|
TestClass(Mech &);
|
|
Logical
|
|
TestInstance() const;
|
|
|
|
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
// Construction and Destruction
|
|
//
|
|
public:
|
|
typedef MechWeapon__SubsystemResource SubsystemResource;
|
|
|
|
MechWeapon(
|
|
Mech *owner,
|
|
int subsystem_ID,
|
|
SubsystemResource *subsystem_resource,
|
|
SharedData &shared_data = DefaultData
|
|
);
|
|
|
|
~MechWeapon();
|
|
|
|
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:
|
|
virtual void
|
|
FireWeapon();
|
|
|
|
void
|
|
SendDamage(
|
|
Entity *target,
|
|
Damage &damage
|
|
);
|
|
|
|
//
|
|
// View-fire gating (the look-state commit re-arms these): a weapon
|
|
// mounted on a back gun port (rearFiring) fires only into the LOOK-BACK
|
|
// view; the rest fire only in the forward view.
|
|
//
|
|
Logical
|
|
IsRearFiring() const { Check(this); return rearFiring; }
|
|
Logical
|
|
GetViewFireEnable() const { Check(this); return viewFireEnable; }
|
|
void
|
|
SetViewFireEnable(Logical enable){ Check(this); viewFireEnable = enable; }
|
|
|
|
//
|
|
// Fire state machine. The weapon state is carried in the weapon alarm
|
|
// level: 0 = Firing, 2 = Loaded (ready), 3 = Loading, 4 = the
|
|
// trigger-during-load blip. CheckFireEdge is the rising-edge detector
|
|
// on fireImpulse (binary @004b9608): TriggerState carries the raw
|
|
// ControlsButton INT bit-copied by the streamed direct mapping, so the
|
|
// compare works on the BIT PATTERNS as signed ints (sign-correct for
|
|
// the button ints AND genuine floats), reproducing the binary's x87
|
|
// semantics. ComputeOutputVoltage (@004b9c9c) is the recharge-dial
|
|
// writer.
|
|
//
|
|
enum {
|
|
FiringState = 0,
|
|
LoadedState = 2,
|
|
LoadingState = 3,
|
|
TriggerDuringLoadState = 4,
|
|
WeaponStateCount = 5
|
|
};
|
|
|
|
unsigned
|
|
GetWeaponState() { Check(this); return weaponAlarm.GetLevel(); }
|
|
Logical
|
|
CheckFireEdge();
|
|
void
|
|
ComputeOutputVoltage();
|
|
|
|
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
// Local Data
|
|
//
|
|
protected:
|
|
Scalar rechargeRate;
|
|
Scalar weaponRange;
|
|
Scalar damageAmount;
|
|
int damageType;
|
|
Scalar heatCostToFire;
|
|
int targetWithinRange;
|
|
Damage damageData;
|
|
Logical rearFiring;
|
|
Logical viewFireEnable;
|
|
//
|
|
// Fire-machine state (binary @0x31C/0x320/0x324/0x328/0x330/0x350/
|
|
// 0x3A4/0x3E8): the trigger sample pair, the recharge dial, targeting
|
|
// ranges, and the weapon-state alarm.
|
|
//
|
|
Scalar fireImpulse;
|
|
Scalar previousFireImpulse;
|
|
Scalar rechargeLevel;
|
|
Scalar rangeToTarget;
|
|
Scalar effectiveRange;
|
|
int estimatedReadyTime;
|
|
Scalar recoil;
|
|
AlarmIndicator weaponAlarm;
|
|
};
|
|
|
|
#endif
|