Thing3d.h 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774
  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. // Thing3d.h
  19. // Project: Postal
  20. //
  21. // This module implements the CThing3d class which is the class of generic
  22. // thing3d functionality for game thing3ds.
  23. //
  24. // History:
  25. //
  26. // 03/03/97 BRH,JMI Started this generic thing3d object to reduce the
  27. // amount of redundant code.
  28. //
  29. // 03/17/97 JMI Turned most of the CCharacter class into this CThing3d
  30. // class.
  31. //
  32. // 03/18/97 JMI Added DetachChild() and m_u16IdParent.
  33. //
  34. // 03/18/97 JMI Made On and While functions virtual.
  35. //
  36. // 03/19/97 JMI Added m_dExtRotVelY, m_dExtRotVelZ, and m_dRotZ.
  37. // Also, DetachChild() now returns a pointer to the detached
  38. // child.
  39. //
  40. // 03/21/97 JMI Added State_Launch, State_LaunchRelease, State_LaunchFinish,
  41. // and State_LaunchDone.
  42. //
  43. // 03/27/97 JMI Added State_GetUp, State_Duck, State_Rise.
  44. //
  45. // 04/02/97 JMI Removed m_pFire.
  46. //
  47. // 04/07/97 JMI Added State_Jump, State_JumpForward, State_Fall,
  48. // State_Land, and State_LandForward.
  49. //
  50. // 04/10/97 BRH Changed GetAttributes to two functions for the new
  51. // multi layred attribute maps. Now there is a
  52. // GetFloorAttributes and GetEffectAttributes that do
  53. // lookups on the two different attribute maps.
  54. //
  55. // 04/21/97 JMI Made MakeValidPosition() virtual.
  56. //
  57. // 04/23/97 BRH Added a few states for new enemy logic.
  58. //
  59. // 04/25/97 JMI Added State_Writhing for pre-execute dying dudes.
  60. //
  61. // 04/25/97 JMI Added a state for executing dudes, State_Execute.
  62. //
  63. // 04/29/97 JMI Added State_PutOutFire, State_PickUp, and State_PutDown.
  64. //
  65. // 05/06/97 BRH Added intermediate states for Popout and Run & Shoot
  66. //
  67. // 05/09/97 BRH Added walk and hide states for ostriches and others.
  68. //
  69. // 05/12/97 BRH Added a few more states for enemy logic.
  70. //
  71. // 05/14/97 JMI Added generic form of DetachChild(...).
  72. // Also, added generic PositionChild(...).
  73. //
  74. // 05/19/97 BRH Added StateNames array so that the names of the states
  75. // can be shown for thought balloons and refernced for
  76. // the logic tables.
  77. //
  78. // 05/20/97 BRH Added a few more states for victim logic.
  79. //
  80. // 05/21/97 BRH Added ShootRun state for an alternative to the shoot
  81. // animation. They will use this state when shooting while
  82. // running.
  83. //
  84. // 05/26/97 BRH Doubled the Default Hit Points to make the enemy guys
  85. // stronger.
  86. //
  87. // 05/29/97 JMI Added GetLayer().
  88. //
  89. // 05/30/97 JMI Added a generic function for adding a force vector to
  90. // the external force.
  91. //
  92. // 06/02/97 BRH Added another state for Hunting.
  93. //
  94. // 06/02/97 JMI Added State_Climb.
  95. //
  96. // 06/05/97 JMI Removed m_sHitPoints and added a CStockPile, m_stockpile,
  97. // instead.
  98. //
  99. // 06/13/97 JMI Added State_ObjectReleased.
  100. //
  101. // 06/15/97 JMI CThing3d() now Zero()s the m_stockpile b/c I removed its
  102. // constructor b/c I wanted CStockPile to be an aggregate type.
  103. //
  104. // 06/25/97 BRH Added 2D shadow sprite which will be drawn if there
  105. // is a resource for it and it is visible. Derived classes
  106. // can call PrepareShadow to load the default shadow and
  107. // make it visible. PrepareShadow will first check the
  108. // shadow sprite's image to make sure it is NULL before
  109. // loading the default shadow so that you can lad a different
  110. // shadow resource beforehand.
  111. //
  112. // 06/27/97 JMI Added GetSprite() which returns this thing's sprite or
  113. // NULL.
  114. //
  115. // 07/01/97 JMI Changed DetachChild() and PositionChild() to receive the
  116. // rigid body transform as a parameter rather than assume it
  117. // is m_panimCur->m_transRigid.
  118. // Also, added GetLinkPoint().
  119. //
  120. // 07/06/97 BRH Added a few states for victims to use.
  121. //
  122. // 07/09/97 JMI Added MaxStepUpThreshold, MaxForeVel, and MaxBackVel macro
  123. // enums.
  124. //
  125. // 07/17/97 BRH Added DelayShoot state.
  126. //
  127. // 07/18/97 JMI Added PlaySample() that will hook existing PlaySample()
  128. // calls in CThing3d derived classes and map them to
  129. // PlaySample() and, if they don't specify a volume, it will
  130. // use this object's distance to the ear.
  131. //
  132. // 07/21/97 JMI Added GetX(), GetY(), and GetZ().
  133. //
  134. // 08/01/97 BRH Added new state - AvoidFire and DangerNear
  135. //
  136. // 08/02/97 BRH Added virtual OnHelpMsg function.
  137. //
  138. // 08/03/97 BRH Changed DangerNear to Helping state.
  139. //
  140. // 08/06/97 JRD Added tri-axial local scaling to render process
  141. //
  142. // 08/08/97 BRH Added virtual GetSmash() function to return the smash
  143. // of a thing. Also added MarchNext state.
  144. //
  145. // 08/11/97 BRH Walk to next bouy.
  146. //
  147. // 08/12/97 BRH Initialized timers.
  148. //
  149. // 08/18/97 JMI Moved StartAnim() from CDude to CThing3d so more things
  150. // could use it.
  151. //
  152. // 08/18/97 JMI Added m_sLayerOverride which directs Render() to use the
  153. // specified layer rather than the one based on the
  154. // attributes.
  155. //
  156. // 08/24/97 JMI Changed ms_apt3dAttribCheck to ms_apt2dAttribCheckMedium[]
  157. // and added ms_apt2dAttribCheckSmall[],
  158. // ms_apt2dAttribCheckLarge[], and ms_apt2dAttribCheckHuge[].
  159. // Also, added pointer so that each object can choose one,
  160. // m_pap2dAttribCheckPoints.
  161. // Also, changed type of these arrays to local type Point2D.
  162. //
  163. ////////////////////////////////////////////////////////////////////////////////
  164. #ifndef THING3D_H
  165. #define THING3D_H
  166. ////////////////////////////////////////////////////////////////////////////////
  167. // Includes.
  168. ////////////////////////////////////////////////////////////////////////////////
  169. #include "thing.h"
  170. #include "realm.h"
  171. #include "StockPile.h"
  172. #include "AnimThing.h"
  173. class CThing3d : public CThing
  174. {
  175. /////////////////////////////////////////////////////////////////////////////
  176. // Typedefs/enums.
  177. /////////////////////////////////////////////////////////////////////////////
  178. public:
  179. // Macro within CThing3d namespace.
  180. enum
  181. {
  182. MaxStepUpThreshold = 15, // In realm units.
  183. MaxForeVel = 80, // In realm units per second.
  184. MaxBackVel = -60, // In realm units per second.
  185. DefHitPoints = 125,
  186. SoundHalfLife = 1000 // Default sound half life.
  187. };
  188. typedef enum
  189. {
  190. State_Idle, // Not rendering.
  191. State_Shot, // Hit by a simple projectile like a bullet.
  192. State_BlownUp, // Suffering the reprocussion of an explosion.
  193. State_Burning, // Currently on fire.
  194. State_Die, // Dying.
  195. State_Dead, // Dead.
  196. State_RunOver, // Run over by large object such as a car.
  197. State_Vomit, // Vomitting.
  198. State_Suicide, // Committing suicide.
  199. State_Persistent, // Returns to last persistent state.
  200. State_Stand, // Standing anim, if any.
  201. State_Throw, // Throwing.
  202. State_ThrowRelease, // Release thrown object.
  203. State_ThrowFinish, // Already released, finishing animation.
  204. State_ThrowDone, // Throw done, ready to move on. Transitional.
  205. State_Run, // Running.
  206. State_Shooting, // Shoot.
  207. State_RunAndShoot, // Run and shoot.
  208. State_Strafe, // Strafing when no forward movement.
  209. State_StrafeAndShoot, // Shooting while strafing when no forward movement.
  210. State_Launch, // Shoot using launcher weapons.
  211. State_LaunchRelease, // Release launched object.
  212. State_LaunchFinish, // Already released, finishing animation.
  213. State_LaunchDone, // Launch anim done. Transitional.
  214. State_GetUp, // Getting up.
  215. State_Duck, // Ducking.
  216. State_Rise, // Rising.
  217. State_Jump, // Jumping vertically.
  218. State_JumpForward, // Jump forward.
  219. State_Land, // Landing from vertical momentum only.
  220. State_LandForward, // Landing from vertical and forward momentum.
  221. State_Fall, // Falling through air.
  222. State_March, // Marching band
  223. State_Mingle, // Mill around after parade
  224. State_Panic, // Run around scared
  225. State_Load, // Load your weapon
  226. State_Patrol, // Patrol an area waiting for action
  227. State_Shoot, // Shoot your weapon
  228. State_Wait, // Wait
  229. State_Stop, // Stop walking/running
  230. State_Hunt, // Actively seek out a target.
  231. State_HuntNext, // Go to next bouy en route to final destination
  232. State_Engage, // At the end of the hunt, engage the Dude
  233. State_Guard, // Guard an area
  234. State_Reposition, // Moving to a new shooting position
  235. State_Retreat, // Fall back to a safe position
  236. State_PopBegin, // Begin the popout sequence
  237. State_PopWait, // Wait at safe location until Dude is near
  238. State_Popout, // Popout from a safe Bouy & shoot, then duck back
  239. State_PopShoot, // Shoot from the Popped-out location
  240. State_RunShootBegin, // Begin run and shoot sequence
  241. State_RunShootRun, // Run towards pylon
  242. State_RunShootWait, // After you reach the end, wait a bit
  243. State_RunShoot, // Run between cover bouys and shoot in between
  244. State_Delete, // Delete this thing3d next chance.
  245. State_Writhing, // Writhing in predeath, waiting to be executed.
  246. State_Execute, // Execute people.
  247. State_PutDown, // Put something down.
  248. State_PickUp, // Pick something up.
  249. State_PutOutFire, // Put out fire.
  250. State_Walk, // Walk around normally (probably for victims)
  251. State_Hide, // Hide so Dudes can't find you
  252. State_MoveNext, // Move to next bouy position.
  253. State_PositionSet, // Setup to get into position for fighting
  254. State_PositionMove, // Move to desired position for fighting
  255. State_HideBegin, // Move to hiding pylon
  256. State_ShootRun, // Shoot while running - for use with new animations
  257. State_HuntHold, // Hold when closest to Dude as possible on the bouy network.
  258. State_Climb, // Climbing (probably ladder or something).
  259. State_ObjectReleased, // An object was released, finish animation and return
  260. // to persistent state.
  261. State_PanicBegin, // Select a bouy to run to
  262. State_PanicContinue, // Continue to panic
  263. State_WalkBegin, // Select a bouy to stroll to
  264. State_WalkContinue, // Continue to walk
  265. State_DelayShoot, // Wait for timer, then shoot.
  266. State_AvoidFire, // Wait for fire to burn out before advancing
  267. State_Helping, // When someone nearby gets shot, shoot from where you are
  268. State_MarchNext, // March to next bouy.
  269. State_WalkNext, // Walk to next bouy
  270. // Insert additional states above this one.
  271. NumThing3dStates
  272. } State;
  273. // A 2D point. Used by the attrib check arrays.
  274. typedef struct
  275. {
  276. short sX;
  277. short sZ;
  278. } Point2D;
  279. //---------------------------------------------------------------------------
  280. // Variables
  281. //---------------------------------------------------------------------------
  282. public:
  283. // General position, motion and time variables
  284. double m_dX; // x coord.
  285. double m_dY; // y coord.
  286. double m_dZ; // z coord.
  287. double m_dVel; // Velocity.
  288. double m_dDeltaVel; // Change in velocity.
  289. double m_dAcc; // Acceleration.
  290. double m_dRot; // Rotation (in degrees, 0 to 359.999999) around Y.
  291. double m_dRotZ; // Rotation (in degrees, 0 to 359.999999) around Z.
  292. double m_dScaleX; // X-scale relative to scene scale
  293. double m_dScaleY; // Y-scale relative to scene scale
  294. double m_dScaleZ; // Z-scale relative to scene scale
  295. double m_dDrag; // Amount of deceleration that applies to internal
  296. // forces.
  297. double m_dExtHorzVel; // Velocity due to external force on X/Z plane.
  298. double m_dExtHorzDeltaVel; // Change in external force velocity.
  299. double m_dExtHorzRot; // Direction of m_dExternalHorzVel.
  300. double m_dExtHorzDrag; // Amount of deceleration that applies to external
  301. // forces.
  302. double m_dExtVertVel; // Vertical velocity due to external force.
  303. double m_dExtVertDeltaVel; // Change in external force vertical velocity.
  304. double m_dExtRotVelY; // Rate of rotation in degrees per second around
  305. // Y axis.
  306. double m_dExtRotVelZ; // Rate of rotation in degrees per second around
  307. // Z axis.
  308. long m_lTimer; // General purpose timer for states
  309. long m_lPrevTime; // Previous update time
  310. short m_sPrevHeight; // Previous height
  311. short m_sSuspend; // Suspend flag
  312. U16 m_u16IdFire; // ID of fire to carry around when you are burning.
  313. CSprite3 m_sprite; // 3D Sprite used to render the 3D Thing.
  314. CSprite2 m_spriteShadow; // 2D shadow sprite to be shown on the ground
  315. CSmash m_smash; // Smash for collision detection.
  316. // Animation specific variables.
  317. CAnim3D* m_panimCur; // Pointer to current animation.
  318. long m_lAnimTime; // Time from start of animation.
  319. long m_lAnimPrevUpdateTime; // Last time m_lAnimTime was updated.
  320. // Used to determine the delta time to add
  321. // to m_lAnimTime.
  322. RTransform m_trans; // Transform to apply on Render.
  323. State m_state; // Current state of this thing3d.
  324. short m_sBrightness; // Normal brightness level or dark if burnt
  325. bool m_bAboveTerrain; // true, if in the air, false if on terrain.
  326. U16 m_u16IdParent; // Instance ID of parent.
  327. CStockPile m_stockpile; // Stockpile of ammo and health.
  328. short m_sLayerOverride; // Layer override. If > 0, used instead of
  329. // layer dictated by attributes.
  330. const Point2D* m_pap2dAttribCheckPoints; // Points to the ms_apt3dAttribCheck*[]
  331. // that best reflects this object.
  332. //---------------------------------------------------------------------------
  333. // Static Variables
  334. //---------------------------------------------------------------------------
  335. public:
  336. static double ms_dDefaultSurfaceDrag; // Default drag along surfaces.
  337. static double ms_dDefaultAirDrag; // Default drag due to air friction.
  338. static short ms_sBurntBrightness; // Brightness level after being burnt
  339. static char* ms_apszStateNames[]; // Strings describing states, indexed by
  340. // the state enum.
  341. // These are arrays of pts to be checked on the attribute map for various
  342. // size of CThing3d derived things.
  343. static const Point2D ms_apt2dAttribCheckSmall[];
  344. static const Point2D ms_apt2dAttribCheckMedium[];
  345. static const Point2D ms_apt2dAttribCheckLarge[];
  346. static const Point2D ms_apt2dAttribCheckHuge[];
  347. //---------------------------------------------------------------------------
  348. // Constructor(s) / destructor
  349. //---------------------------------------------------------------------------
  350. protected:
  351. // Constructor
  352. CThing3d(CRealm* pRealm, CThing::ClassIDType id)
  353. : CThing(pRealm, id)
  354. {
  355. // Must call Zero() to initialize the stockpile since it has
  356. // no constructor.
  357. m_stockpile.Zero();
  358. m_state = State_Idle;
  359. m_panimCur = NULL;
  360. m_dExtHorzVel = 0.0;
  361. m_dExtHorzRot = 0.0;
  362. m_dExtHorzDrag = 0.0;
  363. m_dExtVertVel = 0.0;
  364. m_dExtRotVelY = 0.0;
  365. m_dExtRotVelZ = 0.0;
  366. m_dVel = 0.0;
  367. m_dAcc = 0.0;
  368. m_dRot = 0.0;
  369. m_dRotZ = 0.0;
  370. m_dScaleX = 1.0;
  371. m_dScaleY = 1.0;
  372. m_dScaleZ = 1.0;
  373. m_dDrag = 0.0;
  374. m_sprite.m_pthing = this;
  375. m_sSuspend = 0;
  376. m_sBrightness = 0;
  377. m_u16IdFire = CIdBank::IdNil;
  378. m_bAboveTerrain = false;
  379. m_stockpile.m_sHitPoints = DefHitPoints;
  380. m_u16IdParent = CIdBank::IdNil;
  381. m_spriteShadow.m_sInFlags = CSprite::InHidden;
  382. m_spriteShadow.m_pImage = NULL;
  383. m_spriteShadow.m_pthing = this;
  384. m_lAnimTime = 0;
  385. m_lTimer = 0;
  386. m_sLayerOverride = -1;
  387. // Default to the standard.
  388. m_pap2dAttribCheckPoints = ms_apt2dAttribCheckMedium;
  389. }
  390. public:
  391. // Destructor
  392. ~CThing3d()
  393. {
  394. // Remove sprite from scene (this is safe even if it was already removed!)
  395. m_pRealm->m_scene.RemoveSprite(&m_sprite);
  396. // Remove sprite from scene (this is safe even if it was already removed!)
  397. m_pRealm->m_scene.RemoveSprite(&m_spriteShadow);
  398. // Remove smash from smashatorium (this is safe even if it was already
  399. // removed).
  400. m_pRealm->m_smashatorium.Remove(&m_smash);
  401. // Free the shadow resource
  402. if (m_spriteShadow.m_pImage)
  403. rspReleaseResource(&g_resmgrGame, &(m_spriteShadow.m_pImage));
  404. }
  405. //---------------------------------------------------------------------------
  406. // Required static functions - None for this non-instantiable object.
  407. //---------------------------------------------------------------------------
  408. public:
  409. //---------------------------------------------------------------------------
  410. // Not necessarily required virtual functions (implementing them as inlines
  411. // doesn't pay!)
  412. //---------------------------------------------------------------------------
  413. public:
  414. // Load object (should call base class version!)
  415. short Load( // Returns 0 if successfull, non-zero otherwise
  416. RFile* pFile, // In: File to load from
  417. bool bEditMode, // In: True for edit mode, false otherwise
  418. short sFileCount, // In: File count (unique per file, never 0)
  419. ULONG ulFileVersion); // In: Version of file format to load.
  420. // Save object (should call base class version!)
  421. short Save( // Returns 0 if successfull, non-zero otherwise
  422. RFile* pFile, // In: File to save to
  423. short sFileCount); // In: File count (unique per file, never 0)
  424. // Startup object
  425. short Startup(void); // Returns 0 if successfull, non-zero otherwise
  426. // Shutdown object
  427. short Shutdown(void); // Returns 0 if successfull, non-zero otherwise
  428. // Suspend object
  429. void Suspend(void);
  430. // Resume object
  431. void Resume(void);
  432. // Render object
  433. void Render(void);
  434. // Called by editor to init new object at specified position
  435. short EditNew( // Returns 0 if successfull, non-zero otherwise
  436. short sX, // In: New x coord
  437. short sY, // In: New y coord
  438. short sZ); // In: New z coord
  439. // Called by editor to modify object
  440. short EditModify(void); // Returns 0 if successfull, non-zero otherwise
  441. // Called by editor to move object to specified position
  442. short EditMove( // Returns 0 if successfull, non-zero otherwise
  443. short sX, // In: New x coord
  444. short sY, // In: New y coord
  445. short sZ); // In: New z coord
  446. // Called by editor to render object
  447. void EditRender(void);
  448. // Give Edit a rectangle around this object
  449. void EditRect(RRect* pRect);
  450. // Called by editor to get the hotspot of an object in 2D.
  451. // (virtual (Overridden here)).
  452. void EditHotSpot( // Returns nothiing.
  453. short* psX, // Out: X coord of 2D hotspot relative to
  454. // EditRect() pos.
  455. short* psY); // Out: Y coord of 2D hotspot relative to
  456. // EditRect() pos.
  457. // Get the sprite for this thing. If there's more than one, pick one
  458. // or none to return.
  459. virtual // If you override this, do NOT call this base class.
  460. CSprite* GetSprite(void) // Returns the sprite for this thing or NULL.
  461. { return &m_sprite; }
  462. // Get the coordinates of this thing.
  463. virtual // Overriden here.
  464. double GetX(void) { return m_dX; }
  465. virtual // Overriden here.
  466. double GetY(void) { return m_dY; }
  467. virtual // Overriden here.
  468. double GetZ(void) { return m_dZ; }
  469. // Returns a pointer to the smash
  470. virtual
  471. CSmash* GetSmash(void)
  472. {
  473. return &m_smash;
  474. }
  475. //---------------------------------------------------------------------------
  476. // Useful generic thing3d message-specific functionality.
  477. //---------------------------------------------------------------------------
  478. public:
  479. // Process all messages currently in the message queue through
  480. // ProcessMessage().
  481. virtual // Override to implement additional functionality.
  482. void ProcessMessages(void);
  483. // Process the specified message. For most messages, this function
  484. // will call the equivalent On* function.
  485. virtual // Override to implement additional functionality.
  486. void ProcessMessage( // Returns nothing.
  487. GameMessage* pmsg); // Message to process.
  488. // Message handling functions ////////////////////////////////////////////
  489. // Handles a Shot_Message.
  490. virtual // Override to implement additional functionality.
  491. // Call base class to get default functionality.
  492. void OnShotMsg( // Returns nothing.
  493. Shot_Message* pshotmsg); // In: Message to handle.
  494. // Handles an Explosion_Message.
  495. virtual // Override to implement additional functionality.
  496. // Call base class to get default functionality.
  497. void OnExplosionMsg( // Returns nothing.
  498. Explosion_Message* pexplosionmsg); // In: Message to handle.
  499. // Handles a Burn_Message.
  500. virtual // Override to implement additional functionality.
  501. // Call base class to get default functionality.
  502. void OnBurnMsg( // Returns nothing.
  503. Burn_Message* pburnmsg); // In: Message to handle.
  504. // Handles an ObjectDelete_Message.
  505. virtual // Override to implement additional functionality.
  506. // Call base class to get default functionality.
  507. void OnDeleteMsg( // Returns nothing.
  508. ObjectDelete_Message* pdeletemsg); // In: Message to handle.
  509. // Handles a call for help message Help_Message
  510. virtual // Override to implement additional functionality
  511. // Call base class to get default functionality
  512. void OnHelpMsg( // Returns nothing
  513. Help_Message* phelpmsg); // In: Message to handle
  514. // Handles the put me down message
  515. virtual // Override to implemetn additional functionality
  516. // Call base class to get default functionality
  517. void OnPutMeDownMsg( // Returns nothing
  518. PutMeDown_Message* pputmedownmsg); // In: Message to handle
  519. //---------------------------------------------------------------------------
  520. // Useful generic thing3d state-specific functionality.
  521. //---------------------------------------------------------------------------
  522. public:
  523. // Implements basic one-time functionality for each time State_Shot is
  524. // entered.
  525. virtual // Override to implement additional functionality.
  526. // Call base class to get default functionality.
  527. void OnShot(void);
  528. // Implements basic functionality while being shot and returns true
  529. // until the state is completed.
  530. virtual // Override to implement additional functionality.
  531. // Call base class to get default functionality.
  532. bool WhileShot(void);
  533. // Implements basic functionality while being blown up and returns true
  534. // until the state is completed.
  535. virtual // Override to implement additional functionality.
  536. // Call base class to get default functionality.
  537. bool WhileBlownUp(void); // Returns true until state is complete.
  538. // Implements basic functionality while being on fire and returns true
  539. // until the state is completed.
  540. virtual // Override to implement additional functionality.
  541. // Call base class to get default functionality.
  542. bool WhileBurning(void); // Returns true until state is complete.
  543. // Implements basic functionality while being run over and returns true
  544. // until the state is completed.
  545. virtual // Override to implement additional functionality.
  546. // Call base class to get default functionality.
  547. bool WhileRunOver(void); // Returns true until state is complete.
  548. //---------------------------------------------------------------------------
  549. // Useful generic thing3d functionality.
  550. //---------------------------------------------------------------------------
  551. public:
  552. // Applies accelerations to velocities keeping them within specified
  553. // limits.
  554. void UpdateVelocities( // Returns nothing.
  555. double dSeconds, // Seconds since last update.
  556. double dMaxForeVel, // Maximum forward velocity.
  557. double dMaxBackVel); // Maximum backward velocity.
  558. // Applies velocities to positions.
  559. void GetNewPosition( // Returns nothing.
  560. double* pdNewX, // Out: New x position.
  561. double* pdNewY, // Out: New y position.
  562. double* pdNewZ, // Out: New z position.
  563. double dSeconds); // Seconds since last update.
  564. //#ifdef MOBILE
  565. // Applies velocities to positions, but take in angle of movement
  566. void GetNewPositionAngle( // Returns nothing.
  567. double* pdNewX, // Out: New x position.
  568. double* pdNewY, // Out: New y position.
  569. double* pdNewZ, // Out: New z position.
  570. double dSeconds, // Seconds since last update.
  571. double dAngle
  572. );
  573. //#endif
  574. // Determines if supplied position is valid tweaking it if necessary.
  575. virtual // Override to implement additional functionality.
  576. // Call base class to get default functionality.
  577. bool MakeValidPosition( // Returns true, if new position was validitable.
  578. // Returns false, if could not reach new position.
  579. double* pdNewX, // In: x position to validate.
  580. // Out: New x position.
  581. double* pdNewY, // In: y position to validate.
  582. // Out: New y position.
  583. double* pdNewZ, // In: z position to validate.
  584. // Out: New z position.
  585. short sVertTolerance = 0); // Vertical tolerance.
  586. // Deluxe does all for updating position.
  587. void DeluxeUpdatePosVel( // Returns nothing.
  588. double dSeconds); // In: Duration since last update in seconds.
  589. // Update fire animation's position.
  590. void UpdateFirePosition(void);
  591. // Get Floor attributes (height & floor attributes like nowalk, ladder, cliff)
  592. void GetFloorAttributes( // Returns nothing
  593. short sX, // In: X coord.
  594. short sZ, // In: Z coord.
  595. U16* pu16Attrib, // Out: Combined attributes, if not NULL
  596. short* psHeight); // Out: Max height, if not NULL
  597. // Get Effect attributes (effects attributes like light, camera, oil, blood)
  598. void GetEffectAttributes( // Returns nothing
  599. short sX, // In: X coord.
  600. short sZ, // In: Z coord.
  601. U16* pu16Attrib, // Out: Combined attributes, if not NULL
  602. short* psLightBits); // Out: Tally of light bits set, if not NULL.
  603. // Get the layer based on the attribute points array.
  604. void GetLayer(
  605. short sX, // In: X coord.
  606. short sZ, // In: Z coord.
  607. short* psLayer); // Out: Combined layer.
  608. // Detach the specified Thing3d.
  609. virtual // Override to implement additional functionality.
  610. // Call base class to get default functionality.
  611. CThing3d* DetachChild( // Returns ptr to the child or NULL, if none.
  612. U16* pu16InstanceId, // In: Instance ID of child to detach.
  613. // Out: CIdBank::IdNil.
  614. RTransform* ptrans); // In: Transform for positioning child.
  615. // Detach the specified child sprite (can be any sprite type).
  616. virtual // Override to implement additional functionality.
  617. // Call base class to get default functionality.
  618. void DetachChild( // Returns nothing.
  619. CSprite* psprite, // In: Child sprite to detach.
  620. RTransform* ptrans, // In: Transform for positioning child.
  621. double* pdX, // Out: New position of child.
  622. double* pdY, // Out: New position of child.
  623. double* pdZ); // Out: New position of child.
  624. // Position the specified child sprite (can be any sprite type).
  625. virtual // Override to implement additional functionality.
  626. // Call base class to get default functionality.
  627. void PositionChild( // Returns nothing.
  628. CSprite* psprite, // In: Child sprite to detach.
  629. RTransform* ptrans, // In: Transform for positioning child.
  630. double* pdX, // Out: New position of child.
  631. double* pdY, // Out: New position of child.
  632. double* pdZ); // Out: New position of child.
  633. // Get the link point specified by the provided transform.
  634. void GetLinkPoint( // Returns nothing.
  635. RTransform* ptrans, // In: Transform specifying point.
  636. double* pdX, // Out: Point speicfied.
  637. double* pdY, // Out: Point speicfied.
  638. double* pdZ); // Out: Point speicfied.
  639. // Add a force vector to this thing's external horizontal velocity vector.
  640. void AddForceVector( // Returns nothing.
  641. double dAddVel, // In: Magnitude of additional vector.
  642. short sRot); // In: Direction (in degrees) of additional vector.
  643. // Load the default shadow resource unless one has already been loaded
  644. // and set the shadow to visible
  645. virtual // Override to implement additional functionality
  646. // Call base class to get default functionality
  647. short PrepareShadow(void); // Returns SUCCESS if set successfully
  648. // Plays a sample and purges the resource after playing (as long as nobody
  649. // else has used the same sample resource).
  650. // Plays a sample with volume adjustment. This may require load from disk.
  651. // Also, if no initial volume is specified, the distance to the ear is used.
  652. void PlaySample( // Returns nothing.
  653. // Does not fail.
  654. SampleMasterID id, // In: Identifier of sample you want played.
  655. SampleMaster::SoundCategory eType, // In: Sound Volume Category for user adjustment
  656. short sInitialVolume = -1, // In: Initial Sound Volume (0 - 255)
  657. // Negative indicates to use the distance to the
  658. // ear to determine the volume.
  659. SampleMaster::SoundInstance* psi = NULL, // Out: Handle for adjusting sound volume
  660. long* plSampleDuration = NULL, // Out: Sample duration in ms, if not NULL.
  661. long lLoopStartTime = -1, // In: Where to loop back to in milliseconds.
  662. // -1 indicates no looping (unless m_sLoop is
  663. // explicitly set).
  664. long lLoopEndTime = 0, // In: Where to loop back from in milliseconds.
  665. // In: If less than 1, the end + lLoopEndTime is used.
  666. bool bPurgeSample = false); // In: Call ReleaseAndPurge rather than Release after playing
  667. // Start a CAnimThing.
  668. CAnimThing* StartAnim( // Returns ptr to CAnimThing on success; NULL otherwise.
  669. char* pszAnimResName, // In: Animation's resource name.
  670. short sX, // In: Position.
  671. short sY, // In: Position.
  672. short sZ, // In: Position.
  673. bool bLoop); // In: true to loop animation.
  674. };
  675. #endif // THING3D_H
  676. ////////////////////////////////////////////////////////////////////////////////
  677. // EOF
  678. ////////////////////////////////////////////////////////////////////////////////