Mech phase 2: reconstruct ProjectileWeapon + MissileLauncher + AmmoBin -- weapon family complete

ProjectileWeapon (: MechWeapon) -- ballistic (ammo-fed) base: ammo-bin link,
tracer/eject/jam/lead members. MissileLauncher (: ProjectileWeapon) -- salvo
launcher, using the surviving CODE MISLANCH.HPP (missileCount + per-salvo damage
split). AmmoBin (: HeatWatcher) -- ammo store with cook-off heat. All ctors chain
their parents + init from resource; fire paths staged.

Weapon family now COMPLETE: MechWeapon -> {Emitter -> PPC, GaussRifle;
ProjectileWeapon -> MissileLauncher} + AmmoBin. The surviving PPC.CPP/GAUSS.CPP
link against the reconstructed Emitter base. BT: 36 ok.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Cyd
2026-07-20 00:27:08 -05:00
co-authored by Claude Fable 5
parent 7338b10474
commit 1cab46ae72
5 changed files with 460 additions and 0 deletions
+82
View File
@@ -0,0 +1,82 @@
//===========================================================================//
// File: ammobin.cpp //
// Project: BattleTech Brick: Mech weapons //
// Contents: AmmoBin -- ammunition store with cook-off heat //
//---------------------------------------------------------------------------//
// 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(AMMOBIN_HPP)
# include <ammobin.hpp>
#endif
#if !defined(MECH_HPP)
# include <mech.hpp>
#endif
Derivation
AmmoBin::ClassDerivations(
HeatWatcher::ClassDerivations,
"AmmoBin"
);
AmmoBin::SharedData
AmmoBin::DefaultData(
AmmoBin::ClassDerivations,
Subsystem::MessageHandlers,
Subsystem::AttributeIndex,
Subsystem::StateCount
);
AmmoBin::AmmoBin(
Mech *owner,
int subsystem_ID,
SubsystemResource *resource,
SharedData &shared_data
):
HeatWatcher(owner, subsystem_ID, resource, shared_data),
ammoAlarm(6)
{
Check(owner);
Check_Pointer(resource);
ammoCount = resource->ammoCount;
initialAmmoCount = resource->ammoCount;
feedRate = resource->feedRate;
feedTimer = 0.0f;
ammoClassID = resource->ammoClassID;
ammoModelFile = resource->ammoModelFile;
explosionModelFile = resource->explosionModelFile;
heatPerRound = resource->heatPerRound;
cookOffArmed = 0;
cookOffTime = 0;
reserved = 0;
for (int i = 0; i < 12; ++i)
{
cookOffState[i] = 0;
}
Check_Fpu();
}
AmmoBin::~AmmoBin()
{
}
Logical
AmmoBin::TestClass(Mech &)
{
return True;
}
Logical
AmmoBin::TestInstance() const
{
return IsDerivedFrom(ClassDerivations);
}
+85
View File
@@ -0,0 +1,85 @@
//===========================================================================//
// File: ammobin.hpp //
// Project: BattleTech Brick: Mech weapons //
// Contents: AmmoBin -- an ammunition store (with cook-off heat) //
//---------------------------------------------------------------------------//
// Copyright (C) 1995, Virtual World Entertainment, Inc. //
// All Rights reserved worldwide //
// This unpublished sourcecode is PROPRIETARY and CONFIDENTIAL //
//===========================================================================//
#if !defined(AMMOBIN_HPP)
# define AMMOBIN_HPP
# if !defined(HEAT_HPP)
# include <heat.hpp>
# endif
//##################### Forward Class Declarations #######################
class Mech;
//###########################################################################
//###################### AmmoBin Model Resource ########################
//###########################################################################
struct AmmoBin__SubsystemResource:
public HeatWatcher::SubsystemResource
{
int ammoClassID;
int ammoModelFile;
int explosionModelFile;
int ammoCount;
Scalar feedRate;
Scalar heatPerRound;
};
//###########################################################################
//############################## AmmoBin ###############################
//###########################################################################
class AmmoBin:
public HeatWatcher
{
public:
static Derivation ClassDerivations;
static SharedData DefaultData;
static Logical
TestClass(Mech &);
Logical
TestInstance() const;
int GetAmmoCount() const { return ammoCount; }
public:
typedef AmmoBin__SubsystemResource SubsystemResource;
AmmoBin(
Mech *owner,
int subsystem_ID,
SubsystemResource *subsystem_resource,
SharedData &shared_data = DefaultData
);
~AmmoBin();
protected:
int ammoCount;
int initialAmmoCount;
Scalar feedTimer;
Scalar feedRate;
int ammoClassID;
int ammoModelFile;
int explosionModelFile;
Scalar heatPerRound;
int cookOffArmed;
int cookOffTime;
int reserved;
AlarmIndicator ammoAlarm;
//
// Cook-off heat-source registration state (advanced by the heat sim).
// Reserved until the per-frame path is reconstructed.
//
int cookOffState[12];
};
#endif
+116
View File
@@ -0,0 +1,116 @@
//===========================================================================//
// File: mislanch.cpp //
// Project: BattleTech Brick: Mech weapons //
// Contents: MissileLauncher -- a projectile weapon that fires missile salvos //
//---------------------------------------------------------------------------//
// 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(MISLANCH_HPP)
# include <mislanch.hpp>
#endif
#if !defined(MECH_HPP)
# include <mech.hpp>
#endif
Derivation
MissileLauncher::ClassDerivations(
ProjectileWeapon::ClassDerivations,
"MissileLauncher"
);
MissileLauncher::SharedData
MissileLauncher::DefaultData(
MissileLauncher::ClassDerivations,
Subsystem::MessageHandlers,
Subsystem::AttributeIndex,
Subsystem::StateCount
);
MissileLauncher::MissileLauncher(
Mech *owner,
int subsystem_ID,
SubsystemResource *subsystem_resource,
SharedData &default_data
):
ProjectileWeapon(owner, subsystem_ID, subsystem_resource, default_data)
{
Check(owner);
Check_Pointer(subsystem_resource);
missileCount = subsystem_resource->missileCount;
//
// A salvo delivers missileCount missiles; split the per-shot damage across
// the salvo. (The per-missile launch mechanics live in FireWeapon, staged.)
//
if (missileCount > 0)
{
damageData.burstCount = missileCount;
damageData.damageAmount = damageData.damageAmount / (Scalar)missileCount;
}
Check_Fpu();
}
MissileLauncher::~MissileLauncher()
{
}
Logical
MissileLauncher::TestInstance() const
{
return IsDerivedFrom(ClassDerivations);
}
//
//#############################################################################
// Damage / death.
//#############################################################################
//
void
MissileLauncher::TakeDamage(Damage &damage)
{
Check(this);
ProjectileWeapon::TakeDamage(damage);
}
void
MissileLauncher::DeathReset(Logical /*full_reset*/)
{
Check(this);
}
//
// The missile-salvo discharge. Not yet reconstructed.
//
void
MissileLauncher::FireWeapon()
{
Fail("MissileLauncher::FireWeapon -- mislanch.cpp not yet reconstructed");
}
//
// Model-load-time construction. Not yet reconstructed.
//
Logical
MissileLauncher::CreateStreamedSubsystem(
ResourceFile *,
NotationFile *,
const char *,
const char *,
SubsystemResource *,
NotationFile *,
const ResourceDirectories *,
int
)
{
Fail("MissileLauncher::CreateStreamedSubsystem -- mislanch.cpp not yet reconstructed");
return False;
}
+90
View File
@@ -0,0 +1,90 @@
//===========================================================================//
// File: projweap.cpp //
// Project: BattleTech Brick: Mech weapons //
// Contents: ProjectileWeapon -- ballistic (ammo-fed) weapon base //
//---------------------------------------------------------------------------//
// 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(PROJWEAP_HPP)
# include <projweap.hpp>
#endif
#if !defined(MECH_HPP)
# include <mech.hpp>
#endif
Derivation
ProjectileWeapon::ClassDerivations(
MechWeapon::ClassDerivations,
"ProjectileWeapon"
);
ProjectileWeapon::SharedData
ProjectileWeapon::DefaultData(
ProjectileWeapon::ClassDerivations,
Subsystem::MessageHandlers,
Subsystem::AttributeIndex,
Subsystem::StateCount
);
ProjectileWeapon::ProjectileWeapon(
Mech *owner,
int subsystem_ID,
SubsystemResource *subsystem_resource,
SharedData &shared_data
):
MechWeapon(owner, subsystem_ID, subsystem_resource, shared_data),
ammoBinLink()
{
Check(owner);
Check_Pointer(subsystem_resource);
tracerInterval = subsystem_resource->tracerInterval;
minTimeOfFlight = subsystem_resource->minTimeOfFlight;
minJamChance = subsystem_resource->minJamChance;
minVoltagePercentToFire = subsystem_resource->minVoltagePercentToFire;
tracerCounter = 0;
ejectState = 0;
totalTimeToEject = 0.0f;
timeToEject = 0.0f;
percentOfEject = 0.0f;
tracerModelHandle = 0;
leadPosition = Point3D(0.0f, 0.0f, 0.0f);
launchVelocity = Vector3D(0.0f, 0.0f, 0.0f);
tracerOrigin = Vector3D(0.0f, 0.0f, 0.0f);
Check_Fpu();
}
ProjectileWeapon::~ProjectileWeapon()
{
}
Logical
ProjectileWeapon::TestClass(Mech &)
{
return True;
}
Logical
ProjectileWeapon::TestInstance() const
{
return IsDerivedFrom(ClassDerivations);
}
//
// The ballistic discharge (ammo feed, jam roll, tracer, projectile spawn).
// Not yet reconstructed.
//
void
ProjectileWeapon::FireWeapon()
{
Fail("ProjectileWeapon::FireWeapon -- projweap.cpp not yet reconstructed");
}
+87
View File
@@ -0,0 +1,87 @@
//===========================================================================//
// File: projweap.hpp //
// Project: BattleTech Brick: Mech weapons //
// Contents: ProjectileWeapon -- the ballistic (ammo-fed) weapon base //
//---------------------------------------------------------------------------//
// Copyright (C) 1995, Virtual World Entertainment, Inc. //
// All Rights reserved worldwide //
// This unpublished sourcecode is PROPRIETARY and CONFIDENTIAL //
//===========================================================================//
#if !defined(PROJWEAP_HPP)
# define PROJWEAP_HPP
# if !defined(MECHWEAP_HPP)
# include <mechweap.hpp>
# endif
# if !defined(POINT3D_HPP)
# include <point3d.hpp>
# endif
//##################### Forward Class Declarations #######################
class Mech;
//###########################################################################
//################ ProjectileWeapon Model Resource #####################
//###########################################################################
struct ProjectileWeapon__SubsystemResource:
public MechWeapon::SubsystemResource
{
int tracerInterval;
int ammoBinIndex;
Scalar minTimeOfFlight;
Scalar minVoltagePercentToFire;
Scalar minJamChance;
Scalar muzzleVelocity;
int missileCount;
};
//###########################################################################
//######################### ProjectileWeapon ###########################
//###########################################################################
class ProjectileWeapon:
public MechWeapon
{
public:
static Derivation ClassDerivations;
static SharedData DefaultData;
static Logical
TestClass(Mech &);
Logical
TestInstance() const;
virtual void
FireWeapon();
public:
typedef ProjectileWeapon__SubsystemResource SubsystemResource;
ProjectileWeapon(
Mech *owner,
int subsystem_ID,
SubsystemResource *subsystem_resource,
SharedData &shared_data = DefaultData
);
~ProjectileWeapon();
protected:
SubsystemConnection ammoBinLink;
int tracerInterval;
int tracerCounter;
int ejectState;
Scalar totalTimeToEject;
Scalar timeToEject;
Scalar percentOfEject;
Scalar minJamChance;
Scalar minTimeOfFlight;
Scalar minVoltagePercentToFire;
Vector3D launchVelocity;
Vector3D tracerOrigin;
Point3D leadPosition;
int tracerModelHandle;
};
#endif