powerup.h 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  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/powerup.h $*
  25. * *
  26. * $Author:: Tom_s $*
  27. * *
  28. * $Modtime:: 10/25/01 2:44p $*
  29. * *
  30. * $Revision:: 43 $*
  31. * *
  32. *---------------------------------------------------------------------------------------------*
  33. * Functions: *
  34. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  35. #ifndef POWERUP_H
  36. #define POWERUP_H
  37. #ifndef ALWAYS_H
  38. #include "always.h"
  39. #endif
  40. #ifndef SIMPLEGAMEOBJ_H
  41. #include "simplegameobj.h"
  42. #endif
  43. class PowerUpGameObj;
  44. class AudibleSoundClass;
  45. class WeaponBagClass;
  46. /*
  47. ** PowerUpGameObjDef - Defintion class for a PowerUpGameObj
  48. */
  49. class PowerUpGameObjDef : public SimpleGameObjDef
  50. {
  51. public:
  52. PowerUpGameObjDef( void );
  53. virtual uint32 Get_Class_ID( void ) const;
  54. virtual PersistClass * Create( void ) const ;
  55. virtual bool Save( ChunkSaveClass &csave );
  56. virtual bool Load( ChunkLoadClass &cload );
  57. virtual const PersistFactoryClass & Get_Factory( void ) const;
  58. DECLARE_EDITABLE( PowerUpGameObjDef, SimpleGameObjDef );
  59. // Grant returns true if anything was granted that the grantee didn't already have
  60. bool Grant( SmartGameObj * obj, PowerUpGameObj * p_powerup = NULL, bool hud_display = true ) const ;
  61. int Get_Grant_Weapon_ID (void) const { return GrantWeaponID; }
  62. protected:
  63. int GrantShieldType;
  64. float GrantShieldStrength;
  65. float GrantShieldStrengthMax;
  66. float GrantHealth;
  67. float GrantHealthMax;
  68. int GrantWeaponID;
  69. bool GrantWeapon;
  70. int GrantWeaponRounds;
  71. bool GrantWeaponClips;
  72. bool Persistent;
  73. //bool IsCaptureTheFlag;
  74. int GrantKey;
  75. bool AlwaysAllowGrant;
  76. int GrantSoundID;
  77. StringClass GrantAnimationName;
  78. int IdleSoundID;
  79. StringClass IdleAnimationName;
  80. friend class PowerUpGameObj;
  81. };
  82. /*
  83. **
  84. */
  85. class PowerUpGameObj : public SimpleGameObj {
  86. public:
  87. PowerUpGameObj( void );
  88. virtual ~PowerUpGameObj( void );
  89. // Definitions
  90. virtual void Init( void );
  91. void Init( const PowerUpGameObjDef & definition );
  92. const PowerUpGameObjDef & Get_Definition( void ) const ;
  93. // Save / Load / Construction Factory
  94. virtual bool Save( ChunkSaveClass & csave );
  95. virtual bool Load( ChunkLoadClass & cload );
  96. virtual void On_Post_Load( void ); // MOVED
  97. virtual const PersistFactoryClass & Get_Factory( void ) const;
  98. // Think
  99. virtual void Think( void );
  100. void Grant( SmartGameObj * obj );
  101. // Type identification
  102. virtual PowerUpGameObj *As_PowerUpGameObj() { return this; }
  103. static PowerUpGameObj * Create_Backpack( ArmedGameObj * provider );
  104. // Network support
  105. virtual bool Is_Always_Dirty( void ) { return false; }
  106. //virtual void Get_Extended_Information( StringClass & description );
  107. virtual void Get_Description( StringClass & description );
  108. void Expire( void );
  109. protected:
  110. // State types
  111. enum
  112. {
  113. STATE_BECOMING_IDLE = 0,
  114. STATE_IDLING,
  115. STATE_GRANTING,
  116. STATE_EXPIRING,
  117. };
  118. void Set_State( int state );
  119. void Update_State( void );
  120. AudibleSoundClass * IdleSoundObj;
  121. int State;
  122. float StateEndTimer;
  123. // For backpacks, which can hold multiple weapons and ammo
  124. WeaponBagClass * WeaponBag;
  125. friend class PowerUpGameObjDef;
  126. };
  127. #endif // POWERUP_H