ostrich.h 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  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. // ostrich.h
  19. // Project: Nostril (aka Postal)
  20. //
  21. // History:
  22. //
  23. // 05/09/97 BRH Started the ostrich object from the band file.
  24. //
  25. ////////////////////////////////////////////////////////////////////////////////
  26. #ifndef OSTRICH_H
  27. #define OSTRICH_H
  28. #include "RSPiX.h"
  29. #include "doofus.h"
  30. // COstrich is the object for the ostriches wandering about in the game.
  31. class COstrich : public CDoofus
  32. {
  33. //---------------------------------------------------------------------------
  34. // Types, enums, etc.
  35. //---------------------------------------------------------------------------
  36. protected:
  37. //---------------------------------------------------------------------------
  38. // Variables
  39. //---------------------------------------------------------------------------
  40. protected:
  41. CCharacter::State m_ePreviousState; // State variable to remember what he was
  42. // Doing before he was shot, etc.
  43. CAnim3D* m_pPreviousAnim; // Previous state's animation
  44. CAnim3D m_animStand; // Stand animation
  45. CAnim3D m_animHide; // Hide head in sand
  46. CAnim3D m_animWalk; // Marching animation
  47. CAnim3D m_animRun; // Running away animation
  48. CAnim3D m_animShot; // Shot dead animation
  49. CAnim3D m_animBlownup; // Blown up by explosion
  50. CAnim3D m_animDie; // Fall down dead
  51. short m_sRotDirection; // Which direction to rotate to avoid walls
  52. // Tracks file counter so we know when to load/save "common" data
  53. static short ms_sFileCount;
  54. // "Constant" values that we want to be able to tune using the editor
  55. static double ms_dExplosionVelocity;// How high he will get blown up.
  56. static double ms_dMaxMarchVel; // How fast to march
  57. static double ms_dMaxRunVel; // Hos fast to run
  58. static long ms_lStateChangeTime; // How long to go before changing states
  59. static short ms_sStartingHitPoints; // How many hit points to start with
  60. //---------------------------------------------------------------------------
  61. // Constructor(s) / destructor
  62. //---------------------------------------------------------------------------
  63. protected:
  64. // Constructor
  65. COstrich(CRealm* pRealm)
  66. : CDoofus(pRealm, COstrichID)
  67. {
  68. m_sRotDirection = 0;
  69. }
  70. public:
  71. // Destructor
  72. ~COstrich()
  73. {
  74. // Remove sprite from scene (this is safe even if it was already removed!)
  75. m_pRealm->m_scene.RemoveSprite(&m_sprite);
  76. m_pRealm->m_smashatorium.Remove(&m_smash);
  77. // Free resources
  78. FreeResources();
  79. }
  80. //---------------------------------------------------------------------------
  81. // Required static functions
  82. //---------------------------------------------------------------------------
  83. public:
  84. // Construct object
  85. static short Construct( // Returns 0 if successfull, non-zero otherwise
  86. CRealm* pRealm, // In: Pointer to realm this object belongs to
  87. CThing** ppNew) // Out: Pointer to new object
  88. {
  89. short sResult = 0;
  90. *ppNew = new COstrich(pRealm);
  91. if (*ppNew == 0)
  92. {
  93. sResult = -1;
  94. TRACE("COstrich::Construct(): Couldn't construct COstrich (that's a bad thing)\n");
  95. }
  96. return sResult;
  97. }
  98. //---------------------------------------------------------------------------
  99. // Required virtual functions (implimenting them as inlines doesn't pay!)
  100. //---------------------------------------------------------------------------
  101. public:
  102. // Load object (should call base class version!)
  103. short Load( // Returns 0 if successfull, non-zero otherwise
  104. RFile* pFile, // In: File to load from
  105. bool bEditMode, // In: True for edit mode, false otherwise
  106. short sFileCount, // In: File count (unique per file, never 0)
  107. ULONG ulFileVersion); // In: Version of file format to load.
  108. // Save object (should call base class version!)
  109. short Save( // Returns 0 if successfull, non-zero otherwise
  110. RFile* pFile, // In: File to save to
  111. short sFileCount); // In: File count (unique per file, never 0)
  112. // Startup object
  113. short Startup(void); // Returns 0 if successfull, non-zero otherwise
  114. // Update object
  115. void Update(void);
  116. // Render object
  117. void Render(void);
  118. // Called by editor when a new object is created
  119. short EditNew(short sX, short sY, short sZ);
  120. // Called by editor to modify object
  121. short EditModify(void); // Returns 0 if successfull, non-zero otherwise
  122. // Called by editor to render object
  123. // void EditRender(void);
  124. //---------------------------------------------------------------------------
  125. // Message handlers that are called by CCharacter ProcessMessage(). These
  126. // have code to set the correct animation, state, etc for these messages
  127. //---------------------------------------------------------------------------
  128. public:
  129. void OnShotMsg(Shot_Message* pMessage);
  130. void OnBurnMsg(Burn_Message* pMessage);
  131. void OnExplosionMsg(Explosion_Message* pMessage);
  132. void OnPanicMsg(Panic_Message* pMessage);
  133. //---------------------------------------------------------------------------
  134. // Useful generic character state-specific functionality.
  135. //---------------------------------------------------------------------------
  136. public:
  137. // Implements basic one-time functionality for each time State_Dead is
  138. // entered.
  139. void OnDead(void);
  140. //---------------------------------------------------------------------------
  141. // Internal functions
  142. //---------------------------------------------------------------------------
  143. protected:
  144. // Get all required resources
  145. short GetResources(void); // Returns 0 if successfull, non-zero otherwise
  146. // Free all resources
  147. short FreeResources(void); // Returns 0 if successfull, non-zero otherwise
  148. // Initalize the object - this should be called after the resources are loaded
  149. short Init(void);
  150. // Go through the message queue and change the state if necessary
  151. void ProcessMessages(void);
  152. // Send panic message to other band members
  153. void AlertFlock(void);
  154. // Change randomly to one of the normal states, Walk, Stand, Hide
  155. void ChangeRandomState(void);
  156. };
  157. #endif //OSTRICH_H
  158. ////////////////////////////////////////////////////////////////////////////////
  159. // EOF
  160. ////////////////////////////////////////////////////////////////////////////////