EMPUpdate.h 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  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: EMPUpdate.h ///////////////////////////////////////////////////////////////////////
  24. // Author: Mark Lorenzen Sept. 2002
  25. // Desc: Update that makes the electromagnetic pulse field grow, fade and disable junk
  26. ///////////////////////////////////////////////////////////////////////////////////////////////////
  27. #pragma once
  28. #ifndef __EMPUPDATE_H_
  29. #define __EMPUPDATE_H_
  30. // INCLUDES ///////////////////////////////////////////////////////////////////////////////////////
  31. #include "GameLogic/Module/UpdateModule.h"
  32. #include "GameLogic/Module/DieModule.h"
  33. #include "GameLogic/Weapon.h"
  34. //-------------------------------------------------------------------------------------------------
  35. class EMPUpdateModuleData : public UpdateModuleData
  36. {
  37. public:
  38. UnsignedInt m_lifeFrames;
  39. UnsignedInt m_startFadeFrame;
  40. UnsignedInt m_disabledDuration;
  41. Real m_startScale; ///< how big I start drawing
  42. Real m_targetScaleMin; ///< how big I change to by the time I'm done
  43. Real m_targetScaleMax; ///< how big I change to by the time I'm done
  44. //Real m_spinRateMax; ///< how fast may I spin?
  45. RGBColor m_startColor;
  46. RGBColor m_endColor;
  47. const ParticleSystemTemplate *m_disableFXParticleSystem;
  48. Real m_sparksPerCubicFoot; //<just like it sounds
  49. Real m_effectRadius;
  50. Int m_rejectMask;
  51. KindOfMaskType m_victimKindOf;
  52. KindOfMaskType m_victimKindOfNot;
  53. Bool m_doesNotAffectMyOwnBuildings;
  54. EMPUpdateModuleData()
  55. {
  56. m_lifeFrames = 1;
  57. m_startFadeFrame = 0;
  58. m_startScale = 1.0f;
  59. m_targetScaleMax = 1.0f;
  60. m_targetScaleMin = 1.0f;
  61. m_startColor.setFromInt(0xffffffff);
  62. m_endColor.setFromInt (0x00000000);
  63. //m_spinRateMax = 0.0f;
  64. m_disabledDuration = 0;
  65. m_disableFXParticleSystem = NULL;
  66. m_sparksPerCubicFoot = 0.001f;
  67. m_effectRadius = 200;
  68. m_rejectMask = 0;
  69. m_doesNotAffectMyOwnBuildings = FALSE;
  70. m_victimKindOf.clear();
  71. m_victimKindOfNot.clear();
  72. }
  73. static void buildFieldParse(MultiIniFieldParse& p)
  74. {
  75. UpdateModuleData::buildFieldParse(p);
  76. static const FieldParse dataFieldParse[] =
  77. {
  78. { "Lifetime", INI::parseDurationUnsignedInt, NULL, offsetof( EMPUpdateModuleData, m_lifeFrames ) },
  79. { "StartFadeTime", INI::parseDurationUnsignedInt, NULL, offsetof( EMPUpdateModuleData, m_startFadeFrame ) },
  80. { "StartScale", INI::parseReal, NULL, offsetof( EMPUpdateModuleData, m_startScale ) },
  81. { "DisabledDuration", INI::parseDurationUnsignedInt, NULL, offsetof( EMPUpdateModuleData, m_disabledDuration ) },
  82. //{ "SpinRateMax", INI::parseReal, NULL, offsetof( EMPUpdateModuleData, m_spinRateMax ) },
  83. { "TargetScaleMax", INI::parseReal, NULL, offsetof( EMPUpdateModuleData, m_targetScaleMax ) },
  84. { "TargetScaleMin", INI::parseReal, NULL, offsetof( EMPUpdateModuleData, m_targetScaleMin ) },
  85. { "StartColor", INI::parseRGBColor, NULL, offsetof( EMPUpdateModuleData, m_startColor ) },
  86. { "EndColor", INI::parseRGBColor, NULL, offsetof( EMPUpdateModuleData, m_endColor ) },
  87. { "DisableFXParticleSystem", INI::parseParticleSystemTemplate, NULL, offsetof( EMPUpdateModuleData, m_disableFXParticleSystem ) },
  88. { "SparksPerCubicFoot", INI::parseReal, NULL, offsetof( EMPUpdateModuleData, m_sparksPerCubicFoot ) },
  89. { "EffectRadius", INI::parseReal, NULL, offsetof( EMPUpdateModuleData, m_effectRadius ) },
  90. { "DoesNotAffect", INI::parseBitString32, TheWeaponAffectsMaskNames, offsetof(EMPUpdateModuleData, m_rejectMask) },
  91. { "DoesNotAffectMyOwnBuildings", INI::parseBool, NULL, offsetof( EMPUpdateModuleData, m_doesNotAffectMyOwnBuildings ) },
  92. { "VictimRequiredKindOf", KindOfMaskType::parseFromINI, NULL, offsetof( EMPUpdateModuleData, m_victimKindOf ) },
  93. { "VictimForbiddenKindOf", KindOfMaskType::parseFromINI, NULL, offsetof( EMPUpdateModuleData, m_victimKindOfNot ) },
  94. { 0, 0, 0, 0 }
  95. };
  96. p.add(dataFieldParse);
  97. }
  98. };
  99. //-------------------------------------------------------------------------------------------------
  100. //-------------------------------------------------------------------------------------------------
  101. class EMPUpdate : public UpdateModule
  102. {
  103. MEMORY_POOL_GLUE_WITH_USERLOOKUP_CREATE( EMPUpdate, "EMPUpdate" )
  104. MAKE_STANDARD_MODULE_MACRO_WITH_MODULE_DATA( EMPUpdate, EMPUpdateModuleData )
  105. public:
  106. EMPUpdate( Thing *thing, const ModuleData* moduleData );
  107. // virtual destructor prototype provided by memory pool declaration
  108. UnsignedInt getDieFrame() { return m_dieFrame; }
  109. virtual UpdateSleepTime update( void );
  110. void doDisableAttack( void );
  111. protected:
  112. UnsignedInt m_dieFrame; ///< frame we die on
  113. UnsignedInt m_tintEnvFadeFrames;///< param for tint envelope
  114. UnsignedInt m_tintEnvPlayFrame;///< which frame to trigger the tint envelope
  115. Real m_targetScale; ///How big will I get
  116. //Real m_spinRate; ///HowMuch To Spin each frame;
  117. Real m_currentScale; ///< how big I am drawing this frame
  118. //static Bool s_lastInstanceSpunPositive;/// so that only every other instance spins positive direction
  119. };
  120. //-------------------------------------------------------------------------------------------------
  121. class LeafletDropBehaviorModuleData : public UpdateModuleData
  122. {
  123. public:
  124. UnsignedInt m_delayFrames;
  125. UnsignedInt m_disabledDuration;
  126. Real m_radius;
  127. const ParticleSystemTemplate *m_leafletFXParticleSystem;
  128. LeafletDropBehaviorModuleData()
  129. {
  130. m_delayFrames = 1;
  131. m_disabledDuration = 0;
  132. m_radius = 60.0f;
  133. m_leafletFXParticleSystem = NULL;
  134. }
  135. static void buildFieldParse(MultiIniFieldParse& p)
  136. {
  137. UpdateModuleData::buildFieldParse(p);
  138. static const FieldParse dataFieldParse[] =
  139. {
  140. { "Delay", INI::parseDurationUnsignedInt, NULL, offsetof( LeafletDropBehaviorModuleData, m_delayFrames ) },
  141. { "DisabledDuration", INI::parseDurationUnsignedInt, NULL, offsetof( LeafletDropBehaviorModuleData, m_disabledDuration ) },
  142. { "AffectRadius", INI::parseReal, NULL, offsetof( LeafletDropBehaviorModuleData, m_radius ) },
  143. { "LeafletFXParticleSystem", INI::parseParticleSystemTemplate, NULL, offsetof( LeafletDropBehaviorModuleData, m_leafletFXParticleSystem ) },
  144. { 0, 0, 0, 0 }
  145. };
  146. p.add(dataFieldParse);
  147. }
  148. };
  149. //-------------------------------------------------------------------------------------------------
  150. //-------------------------------------------------------------------------------------------------
  151. class LeafletDropBehavior : public UpdateModule,
  152. public DieModuleInterface
  153. {
  154. MEMORY_POOL_GLUE_WITH_USERLOOKUP_CREATE( LeafletDropBehavior, "LeafletDropBehavior" )
  155. MAKE_STANDARD_MODULE_MACRO_WITH_MODULE_DATA( LeafletDropBehavior, LeafletDropBehaviorModuleData )
  156. public:
  157. LeafletDropBehavior( Thing *thing, const ModuleData* moduleData );
  158. // virtual destructor prototype provided by memory pool declaration
  159. virtual UpdateSleepTime update( void );
  160. void doDisableAttack( void );
  161. // BehaviorModule
  162. virtual DieModuleInterface* getDie() { return this; }
  163. // DieModuleInterface
  164. virtual void onDie( const DamageInfo *damageInfo );
  165. protected:
  166. UnsignedInt m_startFrame; ///< frame we die on
  167. Bool m_fxFired; ///< have we done our fx yet
  168. };
  169. #endif // __EMPUPDATE_H_