//===========================================================================// // File: mechweap.cpp // // Project: BattleTech Brick: Mech weapons // // Contents: MechWeapon -- the base weapon subsystem // //---------------------------------------------------------------------------// // Copyright (C) 1995, Virtual World Entertainment, Inc. // // All Rights reserved worldwide // // This unpublished sourcecode is PROPRIETARY and CONFIDENTIAL // //===========================================================================// #include #pragma hdrstop #if !defined(MECHWEAP_HPP) # include #endif #if !defined(MECH_HPP) # include #endif #if !defined(SEGMENT_HPP) # include #endif #include Derivation MechWeapon::ClassDerivations( PoweredSubsystem::ClassDerivations, "MechWeapon" ); // //############################################################################# // Message handlers. MechWeapon publishes no handlers of its own yet (the // weapon fire/damage handler wave), but the set MUST be a real defined object: // the surviving CODE PPC.CPP binds the inherited name (`PPC::MessageHandlers`) // into PPC::DefaultData, and a declared-but-undefined static links as a // zero-filled common block -- the same silent-NULL trap as the // Emitter::AttributeIndex crash (see MECHWEAP.NOTES.md). //############################################################################# // MechWeapon::MessageHandlerSet MechWeapon::MessageHandlers( 0, NULL, Subsystem::MessageHandlers ); MechWeapon::SharedData MechWeapon::DefaultData( MechWeapon::ClassDerivations, MechWeapon::MessageHandlers, Subsystem::AttributeIndex, Subsystem::StateCount ); MechWeapon::MechWeapon( Mech *owner, int subsystem_ID, SubsystemResource *subsystem_resource, SharedData &shared_data ): PoweredSubsystem(owner, subsystem_ID, subsystem_resource, shared_data) { Check(owner); Check_Pointer(subsystem_resource); rechargeRate = subsystem_resource->rechargeRate; weaponRange = subsystem_resource->weaponRange; damageAmount = subsystem_resource->damageAmount; damageType = subsystem_resource->damageType; heatCostToFire = subsystem_resource->heatCostToFire; targetWithinRange = False; damageData.damageType = damageType; damageData.damageAmount = damageAmount; // // REAR-FIRING resolve (the binary ctor tail @004b99a8): a weapon is // rear-mounted when its MOUNT SEGMENT's site name carries the 'b' (back) // marker -- the back gun ports (sitelbgunport / siterbgunport) are the only // port names containing it. Rear-mounted weapons fire only into the // LOOK-BACK view; everything else fires forward. The look-state commit // (Mech::CommitLookState) re-arms viewFireEnable on every view change; a // weapon spawns armed for the forward view. // rearFiring = False; { EntitySegment *mount = owner->GetSegment(GetSegmentIndex()); if (mount != NULL) { const char *mount_name = mount->GetName(); if (mount_name != NULL && strstr(mount_name, "b") != NULL) { rearFiring = True; } } } viewFireEnable = (rearFiring == False); if (getenv("BT_MECH_LOG")) { EntitySegment *mount = owner->GetSegment(GetSegmentIndex()); DEBUG_STREAM << "[weap] '" << GetName() << "' seg=" << GetSegmentIndex() << " mount="; if (mount != NULL) { DEBUG_STREAM << mount->GetName(); } else { DEBUG_STREAM << ""; } DEBUG_STREAM << " rear=" << (int)rearFiring << endl << flush; } Check_Fpu(); } MechWeapon::~MechWeapon() { } Logical MechWeapon::TestClass(Mech &) { return True; } Logical MechWeapon::TestInstance() const { return IsDerivedFrom(ClassDerivations); } // //############################################################################# // FireWeapon Abstract -- each concrete weapon (Emitter/PPC, ProjectileWeapon/ // Gauss/MissileLauncher) overrides this. Reaching the base is a bug. //############################################################################# // void MechWeapon::FireWeapon() { Fail("MechWeapon::FireWeapon -- should not be here (abstract)"); } // //############################################################################# // SendDamage Deliver this weapon's damage to a struck entity. The damage/ // networking path is not yet reconstructed. //############################################################################# // void MechWeapon::SendDamage(Entity *, Damage &) { Fail("MechWeapon::SendDamage -- mechweap.cpp not yet reconstructed"); } // //############################################################################# // CreateStreamedSubsystem Model-load-time construction. Not yet reconstructed. //############################################################################# // int MechWeapon::CreateStreamedSubsystem( ResourceFile *, NotationFile *, const char *, const char *, SubsystemResource *, NotationFile *, const ResourceDirectories *, int ) { Fail("MechWeapon::CreateStreamedSubsystem -- mechweap.cpp not yet reconstructed"); return 0; }