armedgameobj.h 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. /*
  2. ** Command & Conquer Renegade(tm)
  3. ** Copyright 2025 Electronic Arts Inc.
  4. **
  5. ** This program is free software: you can redistribute it and/or modify
  6. ** it under the terms of the GNU General Public License as published by
  7. ** the Free Software Foundation, either version 3 of the License, or
  8. ** (at your option) any later version.
  9. **
  10. ** This program is distributed in the hope that it will be useful,
  11. ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. ** GNU General Public License for more details.
  14. **
  15. ** You should have received a copy of the GNU General Public License
  16. ** along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. /***********************************************************************************************
  19. *** Confidential - Westwood Studios ***
  20. ***********************************************************************************************
  21. * *
  22. * Project Name : Commando *
  23. * *
  24. * $Archive:: /Commando/Code/Combat/armedgameobj.h $*
  25. * *
  26. * $Author:: Tom_s $*
  27. * *
  28. * $Modtime:: 9/17/01 4:18p $*
  29. * *
  30. * $Revision:: 23 $*
  31. * *
  32. *---------------------------------------------------------------------------------------------*
  33. * Functions: *
  34. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  35. #ifndef ARMEDGAMEOBJ_H
  36. #define ARMEDGAMEOBJ_H
  37. #ifndef ALWAYS_H
  38. #include "always.h"
  39. #endif
  40. #ifndef PHYSICALGAMEOBJ_H
  41. #include "physicalgameobj.h"
  42. #endif
  43. #ifndef MUZZLERECOIL_H
  44. #include "muzzlerecoil.h"
  45. #endif
  46. /*
  47. **
  48. */
  49. class WeaponClass;
  50. class WeaponBagClass;
  51. /*
  52. ** ArmedGameObjDef - Defintion class for a ArmedGameObj
  53. */
  54. class ArmedGameObjDef : public PhysicalGameObjDef
  55. {
  56. public:
  57. ArmedGameObjDef( void );
  58. // virtual uint32 Get_Class_ID( void ) const;
  59. // virtual PersistClass * Create( void ) const ;
  60. virtual bool Save( ChunkSaveClass &csave );
  61. virtual bool Load( ChunkLoadClass &cload );
  62. // virtual const PersistFactoryClass & Get_Factory( void ) const;
  63. DECLARE_EDITABLE( ArmedGameObjDef, PhysicalGameObjDef );
  64. protected:
  65. float WeaponTiltRate;
  66. float WeaponTiltMin;
  67. float WeaponTiltMax;
  68. float WeaponTurnRate;
  69. float WeaponTurnMin;
  70. float WeaponTurnMax;
  71. float WeaponError;
  72. int WeaponDefID;
  73. int SecondaryWeaponDefID;
  74. safe_int WeaponRounds;
  75. friend class ArmedGameObj;
  76. };
  77. /*
  78. **
  79. */
  80. class ArmedGameObj : public PhysicalGameObj {
  81. public:
  82. // Constructor and Destructor
  83. ArmedGameObj( void );
  84. virtual ~ArmedGameObj( void );
  85. // Definitions
  86. void Init( const ArmedGameObjDef & definition );
  87. void Copy_Settings( const ArmedGameObjDef & definition );
  88. void Re_Init( const ArmedGameObjDef & definition );
  89. const ArmedGameObjDef & Get_Definition( void ) const ;
  90. // Save / Load
  91. virtual bool Save( ChunkSaveClass & csave );
  92. virtual bool Load( ChunkLoadClass & cload );
  93. virtual void On_Post_Load( void );
  94. // State import/export
  95. virtual void Import_Frequent( BitStreamClass & packet );
  96. virtual void Export_Frequent( BitStreamClass & packet );
  97. virtual void Import_State_Cs( BitStreamClass & packet );
  98. virtual void Export_State_Cs( BitStreamClass & packet );
  99. // Thinking
  100. virtual void Post_Think();
  101. // Weapon
  102. WeaponClass * Get_Weapon( void );
  103. WeaponBagClass * Get_Weapon_Bag( void ) { return WeaponBag; }
  104. bool Muzzle_Exists( int index = 0 );
  105. virtual const Matrix3D &Get_Muzzle( int index = 0 );
  106. void Start_Recoil( int muzzle_index,float recoil_scale,float recoil_time );
  107. float Get_Weapon_Error( void ) { return Get_Definition().WeaponError; }
  108. // Targeting
  109. Vector3 Get_Targeting_Pos( void ) { return TargetingPos; }
  110. virtual bool Set_Targeting( const Vector3 & pos, bool do_tilt = true );
  111. // Type identification
  112. virtual ArmedGameObj *As_ArmedGameObj( void ) { return this; }
  113. protected:
  114. WeaponBagClass * WeaponBag; // Weapon & Ammo collection
  115. private:
  116. Vector3 TargetingPos;
  117. int MuzzleA0Bone; // YUCK!!!
  118. int MuzzleA1Bone;
  119. int MuzzleB0Bone;
  120. int MuzzleB1Bone;
  121. enum { MAX_MUZZLES = 4 };
  122. MuzzleRecoilClass MuzzleRecoilController[MAX_MUZZLES];
  123. void Init_Muzzle_Bones( void );
  124. };
  125. #endif // ARMEDGAMEOBJ_H