deathWad.h 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252
  1. ////////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright 2016 RWS Inc, All Rights Reserved
  4. //
  5. // This program is free software; you can redistribute it and/or modify
  6. // it under the terms of version 2 of the GNU General Public License as published by
  7. // the Free Software Foundation
  8. //
  9. // This program is distributed in the hope that it will be useful,
  10. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. // GNU General Public License for more details.
  13. //
  14. // You should have received a copy of the GNU General Public License along
  15. // with this program; if not, write to the Free Software Foundation, Inc.,
  16. // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  17. //
  18. // deathWad.h
  19. // Project: Nostril (aka Postal)
  20. //
  21. // History:
  22. // 07/30/97 JMI Started this weapon object from the CRocket.
  23. //
  24. ////////////////////////////////////////////////////////////////////////////////
  25. //
  26. // Wad vt wad-ded; wad-ding (1579) 1 a: to insert a wad into <~ a gun>
  27. // b: to hold in by a wad <~ a bullet in a gun> 2: to form into a wad or
  28. // wadding; esp : to roll or crush into a tight wad 3: to stuff or line with
  29. // some soft substance -- wad-der n
  30. //
  31. // This weapon is a wad of several ammunitions stuffed (or wadded) into a rocket
  32. // cylinder and a napalm canister. Fuel is used to propel the weapon, grenades
  33. // for extra (in addition to the rockets normal payload) explosive power, and
  34. // napalm for lasting fire(burn) power. The rocket cylinder stores the fuel and
  35. // provides the propulsion. The napalm canister stores the extra explosive/fire
  36. // powerload using some up with every collision. It is for these reasons this
  37. // weapon requires:
  38. // - exactly 1 rocket cylinder (including its original payload (solid fuel and
  39. // explosive power))
  40. // - exactly 1 napalm canister (including its original payload (let's call it
  41. // liquid fire) )
  42. // - at least 1 canister fluid fuel (e.g., from flame thrower) (more provides
  43. // greater distance).
  44. // - at least 1 grenade (more provides greater explosive power over longer
  45. // distances).
  46. //
  47. ////////////////////////////////////////////////////////////////////////////////
  48. #ifndef DEATHWAD_H
  49. #define DEATHWAD_H
  50. #include "weapon.h"
  51. #include "StockPile.h"
  52. // CDeathWad is an unguided projectile weapon class.
  53. class CDeathWad : public CWeapon
  54. {
  55. //---------------------------------------------------------------------------
  56. // Types, enums, etc.
  57. //---------------------------------------------------------------------------
  58. public:
  59. //---------------------------------------------------------------------------
  60. // Variables
  61. //---------------------------------------------------------------------------
  62. public:
  63. // Collision bits
  64. U32 m_u32CollideIncludeBits;
  65. U32 m_u32CollideDontcareBits;
  66. U32 m_u32CollideExcludeBits;
  67. CStockPile m_stockpile; // Arsenal.
  68. protected:
  69. CAnim3D m_anim; // 3D animation
  70. RTransform m_trans; // Transform
  71. CSmash m_smash; // Collision body.
  72. CSprite3 m_sprite; // 3D sprite to render this thing.
  73. bool m_bInsideTerrain; // true if we are inside terrain.
  74. SampleMaster::SoundInstance m_siThrust; // Looping thrust play instance.
  75. double m_dUnthrustedDistance; // Distance since last thrust feedback.
  76. // Tracks file counter so we know when to load/save "common" data
  77. static short ms_sFileCount;
  78. // Constant values for tuning.
  79. static const double ms_dAccInternal; // Internal acceleration.
  80. static const double ms_dMaxVelFore; // Maximum forward velocity
  81. static const double ms_dMaxVelBack; // Maximum backward velocity
  82. static const double ms_dTraversalRate; // Units moved each iteration while traversing the weapon path.
  83. static const double ms_dThrustDelta; // Distance between thrust feedbacks.
  84. static const short ms_sOffScreenDist; // Go off screen this far before blowing up
  85. static const long ms_lSmokeTimeToLive; // Time for smoke to stick around.
  86. static const long ms_lFireBallTimeToLive; // Time for fireball to stick around.
  87. static const short ms_sFinalExplosionStagger; // Amount to stagger final explosions.
  88. static const short ms_sCollisionRadius; // Collision radius.
  89. static const double ms_dKickVelocity; // Velocity for kick from launch.
  90. static const CStockPile ms_stockpileMax; // Max a WAD can hold.
  91. //---------------------------------------------------------------------------
  92. // Constructor(s) / destructor
  93. //---------------------------------------------------------------------------
  94. public:
  95. // Constructor
  96. CDeathWad(CRealm* pRealm)
  97. : CWeapon(pRealm, CDeathWadID)
  98. {
  99. m_sprite.m_pthing = this;
  100. m_smash.m_pThing = this;
  101. m_siThrust = 0;
  102. m_u16ShooterID = CIdBank::IdNil;
  103. m_stockpile.Zero();
  104. m_bInsideTerrain = false;
  105. m_u32CollideIncludeBits = 0;
  106. m_u32CollideDontcareBits = 0;
  107. m_u32CollideExcludeBits = 0;
  108. m_dUnthrustedDistance = 0.0;
  109. }
  110. public:
  111. // Destructor
  112. ~CDeathWad()
  113. {
  114. // Stop sound, if any.
  115. StopLoopingSample(m_siThrust);
  116. // Remove sprite from scene (this is safe even if it was already removed!)
  117. m_pRealm->m_scene.RemoveSprite(&m_sprite);
  118. m_pRealm->m_smashatorium.Remove(&m_smash);
  119. // Free resources
  120. FreeResources();
  121. }
  122. //---------------------------------------------------------------------------
  123. // Required static functions
  124. //---------------------------------------------------------------------------
  125. public:
  126. // Construct object
  127. static short Construct( // Returns 0 if successfull, non-zero otherwise
  128. CRealm* pRealm, // In: Pointer to realm this object belongs to
  129. CThing** ppNew) // Out: Pointer to new object
  130. {
  131. short sResult = 0;
  132. *ppNew = new CDeathWad(pRealm);
  133. if (*ppNew == 0)
  134. {
  135. sResult = -1;
  136. TRACE("CDeathWad::Construct(): Couldn't construct CDeathWad (that's a bad thing)\n");
  137. }
  138. return sResult;
  139. }
  140. //---------------------------------------------------------------------------
  141. // Optional static functions
  142. //---------------------------------------------------------------------------
  143. // Called before play begins to cache resources for this object
  144. static short Preload(
  145. CRealm* prealm); // In: Calling realm.
  146. public:
  147. void SetTransform(RTransform* pTransform)
  148. {
  149. m_sprite.m_ptrans = pTransform;
  150. };
  151. //---------------------------------------------------------------------------
  152. // Required virtual functions (implimenting them as inlines doesn't pay!)
  153. //---------------------------------------------------------------------------
  154. public:
  155. // Load object (should call base class version!)
  156. short Load( // Returns 0 if successfull, non-zero otherwise
  157. RFile* pFile, // In: File to load from
  158. bool bEditMode, // In: True for edit mode, false otherwise
  159. short sFileCount, // In: File count (unique per file, never 0)
  160. ULONG ulFileVersion); // In: Version of file format to load.
  161. // Save object (should call base class version!)
  162. short Save( // Returns 0 if successfull, non-zero otherwise
  163. RFile* pFile, // In: File to save to
  164. short sFileCount); // In: File count (unique per file, never 0)
  165. // Update object
  166. void Update(void);
  167. // Render object
  168. void Render(void);
  169. // Called by another object to set start a new deathwad
  170. short Setup(
  171. short sX,
  172. short sY,
  173. short sZ);
  174. // Get this class's sprite. Note that the type will vary.
  175. // This is a pure virtual function in the base class.
  176. virtual // Overriden here.
  177. CSprite* GetSprite(void) // Returns this weapon's sprite.
  178. {
  179. return &m_sprite;
  180. }
  181. // Feed the WAD prior to moving its state to State_Fire.
  182. void FeedWad(
  183. CStockPile* pstockpile); // In: Src for WAD's arsenal.
  184. //---------------------------------------------------------------------------
  185. // Internal functions
  186. //---------------------------------------------------------------------------
  187. protected:
  188. // Get all required resources
  189. short GetResources(void); // Returns 0 if successfull, non-zero otherwise
  190. // Free all resources
  191. short FreeResources(void); // Returns 0 if successfull, non-zero otherwise
  192. // Process messages in the message queue.
  193. void ProcessMessages(void);
  194. // Traverse the path until the inside terrain status changes or
  195. // the destination is reached.
  196. bool TraversePath( // Returns true, when destination reached; false,
  197. // if terrain change.
  198. short sSrcX, // In: Starting position.
  199. short sSrcY, // In: Starting position.
  200. short sSrcZ, // In: Starting position.
  201. bool* pbInTerrain, // In: true, if starting in terrain.
  202. // Out: true, if ending in terrain.
  203. short sDstX, // In: Destination position.
  204. short sDstZ, // In: Destination position.
  205. double* pdCurX, // Out: Position of inside terrain status change.
  206. double* pdCurZ); // Out: Position of inside terrain status change.
  207. // Generate an explosion at the current position.
  208. void Explosion(void);
  209. // Generate some thrust at the current position.
  210. void Thrust(void);
  211. // Generate the launch kick/debris.
  212. void Launch(void);
  213. };
  214. #endif //DOOFUS_H
  215. ////////////////////////////////////////////////////////////////////////////////
  216. // EOF
  217. ////////////////////////////////////////////////////////////////////////////////