NeutronMissileUpdate.h 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  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: NeutronMissileUpdate.h
  24. // Author: Michael S. Booth, December 2001
  25. // Desc: Missile behavior
  26. #pragma once
  27. #ifndef _MISSILE_UPDATE_H_
  28. #define _MISSILE_UPDATE_H_
  29. #include "GameClient/RadiusDecal.h"
  30. #include "Common/GameType.h"
  31. #include "Common/GlobalData.h"
  32. #include "GameLogic/Module/UpdateModule.h"
  33. #include "GameLogic/Module/DieModule.h"
  34. #include "Common/INI.h"
  35. #include "WWMath/Matrix3D.h"
  36. enum ParticleSystemID;
  37. class FXList;
  38. //-------------------------------------------------------------------------------------------------
  39. class NeutronMissileUpdateModuleData : public UpdateModuleData
  40. {
  41. public:
  42. Real m_initialDist;
  43. Real m_maxTurnRate;
  44. Real m_forwardDamping;
  45. Real m_relativeSpeed;
  46. Real m_targetFromDirectlyAbove; ///< aim first for dest+offset, then dest
  47. Real m_specialAccelFactor;
  48. UnsignedInt m_specialSpeedTime;
  49. Real m_specialSpeedHeight;
  50. Real m_specialJitterDistance;
  51. const FXList* m_launchFX; ///< FXList to do when missile 'launches'
  52. const FXList* m_ignitionFX; ///< FXList to do when missile 'ignites'
  53. RadiusDecalTemplate m_deliveryDecalTemplate;
  54. Real m_deliveryDecalRadius;
  55. NeutronMissileUpdateModuleData();
  56. static void buildFieldParse(MultiIniFieldParse& p);
  57. };
  58. //-------------------------------------------------------------------------------------------------
  59. /**
  60. * This module encapsulates missile behavior.
  61. */
  62. class NeutronMissileUpdate : public UpdateModule,
  63. public DieModuleInterface,
  64. public ProjectileUpdateInterface
  65. {
  66. MEMORY_POOL_GLUE_WITH_USERLOOKUP_CREATE( NeutronMissileUpdate, "NeutronMissileUpdate" )
  67. MAKE_STANDARD_MODULE_MACRO_WITH_MODULE_DATA( NeutronMissileUpdate, NeutronMissileUpdateModuleData );
  68. public:
  69. NeutronMissileUpdate( Thing *thing, const ModuleData* moduleData );
  70. static Int getInterfaceMask() { return UpdateModule::getInterfaceMask() | (MODULEINTERFACE_DIE); }
  71. // BehaviorModule
  72. virtual DieModuleInterface* getDie() { return this; }
  73. // DieModuleInterface
  74. virtual void onDie( const DamageInfo *damageInfo );
  75. virtual ProjectileUpdateInterface* getProjectileUpdateInterface() { return this; }
  76. enum MissileStateType
  77. {
  78. PRELAUNCH,
  79. LAUNCH, ///< released from plane, falling
  80. ATTACK, ///< fly toward victim
  81. DEAD
  82. };
  83. virtual void projectileLaunchAtObjectOrPosition(const Object *victim, const Coord3D* victimPos, const Object *launcher, WeaponSlotType wslot, Int specificBarrelToUse, const WeaponTemplate* detWeap, const ParticleSystemTemplate* exhaustSysOverride);
  84. virtual void projectileFireAtObjectOrPosition( const Object *victim, const Coord3D *victimPos, const WeaponTemplate *detWeap, const ParticleSystemTemplate* exhaustSysOverride );
  85. virtual Bool projectileIsArmed() const { return m_isArmed; } ///< return true if the missile is armed and ready to explode
  86. virtual ObjectID projectileGetLauncherID() const { return m_launcherID; } ///< Return firer of missile. Returns 0 if not yet fired.
  87. virtual Bool projectileHandleCollision( Object *other );
  88. virtual const Coord3D *getVelocity() const { return &m_vel; } ///< get current velocity
  89. virtual void setFramesTillCountermeasureDiversionOccurs( UnsignedInt frames ) {}
  90. virtual void projectileNowJammed() {}
  91. virtual UpdateSleepTime update();
  92. virtual void onDelete( void );
  93. private:
  94. MissileStateType m_state; ///< the behavior state of the missile
  95. Coord3D m_targetPos; ///< the position of the target
  96. Coord3D m_intermedPos;
  97. ObjectID m_launcherID; ///< ID of object that launched us (zero if not yet launched)
  98. WeaponSlotType m_attach_wslot; ///< where to fire the missile from
  99. Int m_attach_specificBarrelToUse; ///< where to fire the missile from
  100. Coord3D m_accel;
  101. Coord3D m_vel;
  102. UnsignedInt m_stateTimestamp; ///< time of state change
  103. Bool m_isLaunched;
  104. Bool m_isArmed; ///< if true, missile will explode on contact
  105. Real m_noTurnDistLeft; ///< when zero, ok to start turning
  106. Bool m_reachedIntermediatePos;
  107. UnsignedInt m_frameAtLaunch;
  108. Real m_heightAtLaunch;
  109. RadiusDecal m_deliveryDecal;
  110. const ParticleSystemTemplate* m_exhaustSysTmpl;
  111. void doLaunch( void ); ///< implement LAUNCH state
  112. void doAttack( void ); ///< implement ATTACK state
  113. void detonate(); ///< blow it up. (usually only called by MissileCollide)
  114. };
  115. #endif // _MISSILE_UPDATE_H_