BattlePlanUpdate.h 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. /*
  2. ** Command & Conquer Generals Zero Hour(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. // //
  20. // (c) 2001-2003 Electronic Arts Inc. //
  21. // //
  22. ////////////////////////////////////////////////////////////////////////////////
  23. // FILE: BattlePlanUpdate.h //////////////////////////////////////////////////////////////////////////
  24. // Author: Kris Morness, September 2002
  25. // Desc: Update module to handle building states and battle plan execution & changes
  26. ///////////////////////////////////////////////////////////////////////////////////////////////////
  27. #pragma once
  28. #ifndef __BATTLE_PLAN_UPDATE_H_
  29. #define __BATTLE_PLAN_UPDATE_H_
  30. // INCLUDES ///////////////////////////////////////////////////////////////////////////////////////
  31. #include "Common/KindOf.h"
  32. #include "GameLogic/Module/SpecialPowerUpdateModule.h"
  33. // FORWARD REFERENCES /////////////////////////////////////////////////////////////////////////////
  34. class SpecialPowerModule;
  35. class ParticleSystem;
  36. class FXList;
  37. class AudioEventRTS;
  38. enum MaxHealthChangeType;
  39. enum CommandOption;
  40. //-------------------------------------------------------------------------------------------------
  41. //-------------------------------------------------------------------------------------------------
  42. class BattlePlanUpdateModuleData : public ModuleData
  43. {
  44. public:
  45. SpecialPowerTemplate *m_specialPowerTemplate;
  46. UnsignedInt m_bombardmentPlanAnimationFrames;
  47. UnsignedInt m_holdTheLinePlanAnimationFrames;
  48. UnsignedInt m_searchAndDestroyPlanAnimationFrames;
  49. UnsignedInt m_transitionIdleFrames;
  50. AsciiString m_bombardmentUnpackName;
  51. AsciiString m_bombardmentPackName;
  52. AsciiString m_bombardmentMessageLabel;
  53. AsciiString m_bombardmentAnnouncementName;
  54. AsciiString m_searchAndDestroyUnpackName;
  55. AsciiString m_searchAndDestroyIdleName;
  56. AsciiString m_searchAndDestroyPackName;
  57. AsciiString m_searchAndDestroyMessageLabel;
  58. AsciiString m_searchAndDestroyAnnouncementName;
  59. AsciiString m_holdTheLineUnpackName;
  60. AsciiString m_holdTheLinePackName;
  61. AsciiString m_holdTheLineMessageLabel;
  62. AsciiString m_holdTheLineAnnouncementName;
  63. UnsignedInt m_battlePlanParalyzeFrames;
  64. KindOfMaskType m_validMemberKindOf;
  65. KindOfMaskType m_invalidMemberKindOf;
  66. Real m_holdTheLineArmorDamageScalar;
  67. Real m_searchAndDestroySightRangeScalar;
  68. Real m_strategyCenterSearchAndDestroySightRangeScalar;
  69. Bool m_strategyCenterSearchAndDestroyDetectsStealth;
  70. Real m_strategyCenterHoldTheLineMaxHealthScalar;
  71. MaxHealthChangeType m_strategyCenterHoldTheLineMaxHealthChangeType;
  72. AsciiString m_visionObjectName; ///< name of object to create to reveal shroud to all players
  73. BattlePlanUpdateModuleData();
  74. static void buildFieldParse(MultiIniFieldParse& p);
  75. private:
  76. };
  77. enum TransitionStatus
  78. {
  79. TRANSITIONSTATUS_IDLE,
  80. TRANSITIONSTATUS_UNPACKING,
  81. TRANSITIONSTATUS_ACTIVE,
  82. TRANSITIONSTATUS_PACKING,
  83. };
  84. enum BattlePlanStatus
  85. {
  86. PLANSTATUS_NONE,
  87. PLANSTATUS_BOMBARDMENT,
  88. PLANSTATUS_HOLDTHELINE,
  89. PLANSTATUS_SEARCHANDDESTROY,
  90. };
  91. class BattlePlanBonuses : public MemoryPoolObject
  92. {
  93. MEMORY_POOL_GLUE_WITH_USERLOOKUP_CREATE(BattlePlanBonuses, "BattlePlanBonuses")
  94. public:
  95. Real m_armorScalar;
  96. Int m_bombardment; //Represents having weapon bonuses for bombardment plan
  97. Int m_searchAndDestroy; //Represents having weapon bonuses for searchAndDestroy plan
  98. Int m_holdTheLine; //Represents having weapon bonuses for holdTheLine plan
  99. Real m_sightRangeScalar;
  100. KindOfMaskType m_validKindOf;
  101. KindOfMaskType m_invalidKindOf;
  102. };
  103. EMPTY_DTOR(BattlePlanBonuses)
  104. #define ALL_PLANS 1000000 //Used when stacking or removing plans -- we only remove the bonuses when it's 0 or negative.
  105. //-------------------------------------------------------------------------------------------------
  106. /** The default update module */
  107. //-------------------------------------------------------------------------------------------------
  108. class BattlePlanUpdate : public SpecialPowerUpdateModule
  109. {
  110. MEMORY_POOL_GLUE_WITH_USERLOOKUP_CREATE( BattlePlanUpdate, "BattlePlanUpdate" )
  111. MAKE_STANDARD_MODULE_MACRO_WITH_MODULE_DATA( BattlePlanUpdate, BattlePlanUpdateModuleData );
  112. public:
  113. BattlePlanUpdate( Thing *thing, const ModuleData* moduleData );
  114. // virtual destructor prototype provided by memory pool declaration
  115. // SpecialPowerUpdateInterface
  116. virtual Bool initiateIntentToDoSpecialPower(const SpecialPowerTemplate *specialPowerTemplate, const Object *targetObj, const Coord3D *targetPos, const Waypoint *way, UnsignedInt commandOptions );
  117. virtual Bool isSpecialAbility() const { return false; }
  118. virtual Bool isSpecialPower() const { return true; }
  119. virtual Bool isActive() const {return m_status != TRANSITIONSTATUS_IDLE;}
  120. virtual SpecialPowerUpdateInterface* getSpecialPowerUpdateInterface() { return this; }
  121. virtual Bool doesSpecialPowerHaveOverridableDestinationActive() const { return false; } //Is it active now?
  122. virtual Bool doesSpecialPowerHaveOverridableDestination() const { return false; } //Does it have it, even if it's not active?
  123. virtual void setSpecialPowerOverridableDestination( const Coord3D *loc ) {}
  124. virtual Bool isPowerCurrentlyInUse( const CommandButton *command = NULL ) const;
  125. //Returns the currently active battle plan -- unpacked and ready... returns PLANSTATUS_NONE if in transition!
  126. BattlePlanStatus getActiveBattlePlan() const;
  127. virtual void onObjectCreated();
  128. virtual void onDelete();
  129. virtual UpdateSleepTime update();
  130. virtual CommandOption getCommandOption() const;
  131. protected:
  132. void setStatus( TransitionStatus status );
  133. void enableTurret( Bool enable );
  134. void recenterTurret();
  135. Bool isTurretInNaturalPosition();
  136. void setBattlePlan( BattlePlanStatus plan );
  137. void createVisionObject();
  138. BattlePlanStatus m_currentPlan; //The current battle plan displayed by the building (includes packing & unpacking)
  139. BattlePlanStatus m_desiredPlan; //The user desired battle plan
  140. BattlePlanStatus m_planAffectingArmy; //The current battle plan that is affecting troops!
  141. TransitionStatus m_status;
  142. UnsignedInt m_nextReadyFrame;
  143. SpecialPowerModuleInterface *m_specialPowerModule;
  144. Bool m_invalidSettings;
  145. Bool m_centeringTurret;
  146. BattlePlanBonuses* m_bonuses;
  147. AudioEventRTS m_bombardmentUnpack;
  148. AudioEventRTS m_bombardmentPack;
  149. AudioEventRTS m_bombardmentAnnouncement;
  150. AudioEventRTS m_searchAndDestroyUnpack;
  151. AudioEventRTS m_searchAndDestroyIdle;
  152. AudioEventRTS m_searchAndDestroyPack;
  153. AudioEventRTS m_searchAndDestroyAnnouncement;
  154. AudioEventRTS m_holdTheLineUnpack;
  155. AudioEventRTS m_holdTheLinePack;
  156. AudioEventRTS m_holdTheLineAnnouncement;
  157. // vision object - hang on to this so we can delete it on destruction
  158. ObjectID m_visionObjectID;
  159. };
  160. #endif