band.h 9.1 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. // band.h
  19. // Project: Postal
  20. //
  21. // History:
  22. //
  23. // 03/04/97 BRH Started the marching band guy based on CDoofus so that it
  24. // can use the NavNet and which is now derived from CCharacter.
  25. // This will be the first guy written based on CCharacter
  26. // that will use many of the CCharacter functions for updating.
  27. //
  28. // 03/13/97 JMI Load now takes a version number.
  29. //
  30. // 03/18/97 JMI Added m_idChildItem to handle the storage of child items.
  31. // Also, uncommented Render() proto.
  32. //
  33. // 03/18/97 JMI Added proto for OnDead() override.
  34. //
  35. // 06/04/97 JMI Now aborts ms_pBandSongSound, if not NULL, in destructor.
  36. // Also, added ms_bDonePlaying so marchers know when to not
  37. // restart ms_pBandSongSound.
  38. //
  39. // 06/08/97 JMI Added override for WhileDying() and WhileShot().
  40. //
  41. // 06/24/97 JMI Removed m_sRotateDir member of CBand (it is already defined
  42. // in CDoofus base class).
  43. //
  44. // 07/17/97 JMI Changed ms_pBandSongSound to ms_siBandSongInstance.
  45. // Now uses new SampleMaster interface for volume and play
  46. // instance reference.
  47. //
  48. // 07/31/97 BRH Set the default value of the destination bouy to 1 in
  49. // the constructor.
  50. //
  51. // 08/12/97 JMI Now one band member maintains the volume for the band
  52. // sample.
  53. //
  54. ////////////////////////////////////////////////////////////////////////////////
  55. #ifndef BAND_H
  56. #define BAND_H
  57. #include "RSPiX.h"
  58. #include "doofus.h"
  59. // CBand is a class of marching band members for the parade
  60. class CBand : public CDoofus
  61. {
  62. //---------------------------------------------------------------------------
  63. // Types, enums, etc.
  64. //---------------------------------------------------------------------------
  65. protected:
  66. //---------------------------------------------------------------------------
  67. // Variables
  68. //---------------------------------------------------------------------------
  69. protected:
  70. CCharacter::State m_ePreviousState; // State variable to remember what he was
  71. // Doing before he was shot, etc.
  72. CAnim3D* m_pPreviousAnim; // Previous state's animation
  73. CAnim3D m_animStand; // Stand animation
  74. CAnim3D m_animMarch; // Marching animation
  75. CAnim3D m_animRun; // Running away animation
  76. CAnim3D m_animShot; // Shot dead animation
  77. CAnim3D m_animBlownup; // Blown up by explosion
  78. CAnim3D m_animOnFire; // Running while on fire
  79. U16 m_idChildItem; // ID of child item or CIdBank::IdNil.
  80. // Tracks file counter so we know when to load/save "common" data
  81. static short ms_sFileCount;
  82. // "Constant" values that we want to be able to tune using the editor
  83. static double ms_dCloseToBouy; // How close to be to a bouy to consider yourself 'there'
  84. static double ms_dMingleBouyDist; // How close to be to a bouy when mingling around
  85. static double ms_dExplosionVelocity;// How high he will get blown up.
  86. static double ms_dMaxMarchVel; // How fast to march
  87. static double ms_dMaxRunVel; // Hos fast to run
  88. static long ms_lMingleTime; // How long to mingle before moving
  89. static short ms_sStartingHitPoints; // How many hit points to start with
  90. static SampleMaster::SoundInstance ms_siBandSongInstance; // sound played during band march.
  91. static U16 ms_idBandLeader; // The person who adjusts the band sound
  92. // volume or IdNil.
  93. // This value indicates whether the marchers have stopped playing in this level.
  94. static bool ms_bDonePlaying;
  95. //---------------------------------------------------------------------------
  96. // Constructor(s) / destructor
  97. //---------------------------------------------------------------------------
  98. protected:
  99. // Constructor
  100. CBand(CRealm* pRealm)
  101. : CDoofus(pRealm, CBandID)
  102. {
  103. m_ucNextBouyID = 1;
  104. m_ucDestBouyID = 1;
  105. m_idChildItem = CIdBank::IdNil;
  106. m_bCivilian = true;
  107. }
  108. public:
  109. // Destructor
  110. ~CBand()
  111. {
  112. // Remove sprite from scene (this is safe even if it was already removed!)
  113. m_pRealm->m_scene.RemoveSprite(&m_sprite);
  114. m_pRealm->m_smashatorium.Remove(&m_smash);
  115. // Free resources
  116. FreeResources();
  117. // If sample playing . . .
  118. if (ms_siBandSongInstance != 0)
  119. {
  120. AbortSample(ms_siBandSongInstance);
  121. ms_siBandSongInstance = 0;
  122. }
  123. }
  124. //---------------------------------------------------------------------------
  125. // Required static functions
  126. //---------------------------------------------------------------------------
  127. public:
  128. // Construct object
  129. static short Construct( // Returns 0 if successfull, non-zero otherwise
  130. CRealm* pRealm, // In: Pointer to realm this object belongs to
  131. CThing** ppNew) // Out: Pointer to new object
  132. {
  133. short sResult = 0;
  134. *ppNew = new CBand(pRealm);
  135. if (*ppNew == 0)
  136. {
  137. sResult = -1;
  138. TRACE("CBand::Construct(): Couldn't construct CBand (that's a bad thing)\n");
  139. }
  140. return sResult;
  141. }
  142. //---------------------------------------------------------------------------
  143. // Required virtual functions (implimenting them as inlines doesn't pay!)
  144. //---------------------------------------------------------------------------
  145. public:
  146. // Load object (should call base class version!)
  147. short Load( // Returns 0 if successfull, non-zero otherwise
  148. RFile* pFile, // In: File to load from
  149. bool bEditMode, // In: True for edit mode, false otherwise
  150. short sFileCount, // In: File count (unique per file, never 0)
  151. ULONG ulFileVersion); // In: Version of file format to load.
  152. // Save object (should call base class version!)
  153. short Save( // Returns 0 if successfull, non-zero otherwise
  154. RFile* pFile, // In: File to save to
  155. short sFileCount); // In: File count (unique per file, never 0)
  156. // Startup object
  157. short Startup(void); // Returns 0 if successfull, non-zero otherwise
  158. // Update object
  159. void Update(void);
  160. // Render object
  161. void Render(void);
  162. // Called by editor when a new object is created
  163. short EditNew(short sX, short sY, short sZ);
  164. // Called by editor to modify object
  165. short EditModify(void); // Returns 0 if successfull, non-zero otherwise
  166. // Called by editor to render object
  167. // void EditRender(void);
  168. //---------------------------------------------------------------------------
  169. // Message handlers that are called by CCharacter ProcessMessage(). These
  170. // have code to set the correct animation, state, etc for these messages
  171. //---------------------------------------------------------------------------
  172. public:
  173. void OnShotMsg(Shot_Message* pMessage);
  174. void OnBurnMsg(Burn_Message* pMessage);
  175. void OnExplosionMsg(Explosion_Message* pMessage);
  176. void OnPanicMsg(Panic_Message* pMessage);
  177. //---------------------------------------------------------------------------
  178. // Useful generic character state-specific functionality.
  179. //---------------------------------------------------------------------------
  180. public:
  181. // Implements basic one-time functionality for each time State_Dead is
  182. // entered.
  183. void OnDead(void);
  184. // Implements basic functionality while dying and returns true
  185. // until the state is completed.
  186. virtual // Overriden here.
  187. bool WhileDying(void); // Returns true until state is complete.
  188. // Implements basic functionality while being shot and returns true
  189. // until the state is completed.
  190. virtual // Overriden here.
  191. bool WhileShot(void); // Returns true until state is complete.
  192. //---------------------------------------------------------------------------
  193. // Internal functions
  194. //---------------------------------------------------------------------------
  195. protected:
  196. // Get all required resources
  197. short GetResources(void); // Returns 0 if successfull, non-zero otherwise
  198. // Free all resources
  199. short FreeResources(void); // Returns 0 if successfull, non-zero otherwise
  200. // Initalize the object - this should be called after the resources are loaded
  201. short Init(void);
  202. // Go through the message queue and change the state if necessary
  203. void ProcessMessages(void);
  204. // Send panic message to other band members
  205. void AlertBand(void);
  206. // Drop item and apply appropriate forces.
  207. void DropItem(void); // Returns nothing.
  208. };
  209. #endif //BAND_H
  210. ////////////////////////////////////////////////////////////////////////////////
  211. // EOF
  212. ////////////////////////////////////////////////////////////////////////////////