explode.h 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  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. // explode.h
  19. // Project: Nostril (aka Postal)
  20. //
  21. // History:
  22. // 01/17/97 BRH Started this weapon object.
  23. //
  24. // 02/24/97 JMI Changed declaration of m_sprite from CAlphaSprite2 to
  25. // CSprite2.
  26. //
  27. // 03/05/97 BRH Added ms_sProjectVelocity as default velocity to throw
  28. // other objects nearby.
  29. //
  30. // 03/13/97 JMI Load now takes a version number.
  31. //
  32. // 06/11/97 BRH Added m_u16ShooterID to store the shooter as it
  33. // passes the information along to the explosion message.
  34. //
  35. // 07/09/97 JMI Changed Preload() to take a pointer to the calling realm
  36. // as a parameter.
  37. //
  38. // 07/30/97 JMI Added m_u16ExceptID (an ID to except when sending
  39. // explosion messages).
  40. //
  41. //////////////////////////////////////////////////////////////////////////////
  42. //
  43. // Explosion.
  44. //
  45. //////////////////////////////////////////////////////////////////////////////
  46. #ifndef EXPLODE_H
  47. #define EXPLODE_H
  48. #include "RSPiX.h"
  49. #include "realm.h"
  50. #include "AlphaAnimType.h"
  51. #include "smash.h"
  52. // CExplode is a firey explosion weapon class
  53. class CExplode : public CThing
  54. {
  55. //---------------------------------------------------------------------------
  56. // Types, enums, etc.
  57. //---------------------------------------------------------------------------
  58. public:
  59. typedef enum
  60. {
  61. State_Idle,
  62. State_Fire,
  63. State_Find,
  64. State_Chase,
  65. State_Explode
  66. } CExplodeState;
  67. typedef RChannel<CAlphaAnim> ChannelAA;
  68. //---------------------------------------------------------------------------
  69. // Variables
  70. //---------------------------------------------------------------------------
  71. public:
  72. double m_dX;
  73. double m_dY;
  74. double m_dZ;
  75. U16 m_u16ShooterID;
  76. U16 m_u16ExceptID; // ID of object to except from explosion.
  77. protected:
  78. long m_lTimer; // General purpose timer
  79. long m_lPrevTime; // Previous update time
  80. CSprite2 m_sprite; // Sprite
  81. ChannelAA* m_pAnimChannel; // Alpha Explosion animation stored as a channel
  82. short m_sSuspend; // Suspend flag
  83. CSmash m_smash; // Collision class
  84. // Tracks file counter so we know when to load/save "common" data
  85. static short ms_sFileCount;
  86. static short ms_sBlastRadius;
  87. static short ms_sProjectVelocity;
  88. // "Constant" values that we want to be able to tune using the editor
  89. //---------------------------------------------------------------------------
  90. // Constructor(s) / destructor
  91. //---------------------------------------------------------------------------
  92. public:
  93. // Constructor
  94. CExplode(CRealm* pRealm)
  95. : CThing(pRealm, CExplodeID)
  96. {
  97. m_sSuspend = 0;
  98. m_u16ExceptID = CIdBank::IdNil;
  99. }
  100. public:
  101. // Destructor
  102. ~CExplode()
  103. {
  104. // Remove sprite from scene (this is safe even if it was already removed!)
  105. m_pRealm->m_scene.RemoveSprite(&m_sprite);
  106. m_pRealm->m_smashatorium.Remove(&m_smash);
  107. // Free resources
  108. FreeResources();
  109. }
  110. //---------------------------------------------------------------------------
  111. // Required static functions
  112. //---------------------------------------------------------------------------
  113. public:
  114. // Construct object
  115. static short Construct( // Returns 0 if successfull, non-zero otherwise
  116. CRealm* pRealm, // In: Pointer to realm this object belongs to
  117. CThing** ppNew) // Out: Pointer to new object
  118. {
  119. short sResult = 0;
  120. *ppNew = new CExplode(pRealm);
  121. if (*ppNew == 0)
  122. {
  123. sResult = -1;
  124. TRACE("CExplode::Construct(): Couldn't construct CExplode (that's a bad thing)\n");
  125. }
  126. return sResult;
  127. }
  128. //---------------------------------------------------------------------------
  129. // Optional static functions
  130. //---------------------------------------------------------------------------
  131. static short Preload(
  132. CRealm* prealm); // In: Calling realm.
  133. //---------------------------------------------------------------------------
  134. // Required virtual functions (implimenting them as inlines doesn't pay!)
  135. //---------------------------------------------------------------------------
  136. public:
  137. // Load object (should call base class version!)
  138. short Load( // Returns 0 if successfull, non-zero otherwise
  139. RFile* pFile, // In: File to load from
  140. bool bEditMode, // In: True for edit mode, false otherwise
  141. short sFileCount, // In: File count (unique per file, never 0)
  142. ULONG ulFileVersion); // In: Version of file format to load.
  143. // Save object (should call base class version!)
  144. short Save( // Returns 0 if successfull, non-zero otherwise
  145. RFile* pFile, // In: File to save to
  146. short sFileCount); // In: File count (unique per file, never 0)
  147. // Startup object
  148. short Startup(void); // Returns 0 if successfull, non-zero otherwise
  149. // Shutdown object
  150. short Shutdown(void); // Returns 0 if successfull, non-zero otherwise
  151. // Suspend object
  152. void Suspend(void);
  153. // Resume object
  154. void Resume(void);
  155. // Update object
  156. void Update(void);
  157. // Render object
  158. void Render(void);
  159. short Setup( // Returns 0 on success.
  160. short sX, // In: New x coord
  161. short sY, // In: New y coord
  162. short sZ, // In: New z coord
  163. U16 u16ShooterID, // In: Who is responsible for this explosion
  164. short sAnim = 0); // In: Which explosion to use, standard = 0,
  165. // grenade = 1 etc.
  166. // Called by editor to init new object at specified position
  167. short EditNew( // Returns 0 if successfull, non-zero otherwise
  168. short sX, // In: New x coord
  169. short sY, // In: New y coord
  170. short sZ); // In: New z coord
  171. // Called by editor to modify object
  172. short EditModify(void); // Returns 0 if successfull, non-zero otherwise
  173. // Called by editor to move object to specified position
  174. short EditMove( // Returns 0 if successfull, non-zero otherwise
  175. short sX, // In: New x coord
  176. short sY, // In: New y coord
  177. short sZ); // In: New z coord
  178. // Called by editor to update object
  179. void EditUpdate(void);
  180. // Called by editor to render object
  181. void EditRender(void);
  182. //---------------------------------------------------------------------------
  183. // Internal functions
  184. //---------------------------------------------------------------------------
  185. protected:
  186. // Get all required resources
  187. short GetResources(short sAnim = 0); // Returns 0 if successfull, non-zero otherwise
  188. // Free all resources
  189. short FreeResources(void); // Returns 0 if successfull, non-zero otherwise
  190. };
  191. #endif //DOOFUS_H
  192. ////////////////////////////////////////////////////////////////////////////////
  193. // EOF
  194. ////////////////////////////////////////////////////////////////////////////////