dude.h 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931
  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. // dude.h
  19. // Project: Postal
  20. //
  21. // History:
  22. // 01/27/97 JMI Added EditRect() override to make this object clickable.
  23. //
  24. // 02/07/97 JMI Removed m_pipe and m_sScreenRadius. Added m_sCurRadius
  25. // to represent the radius of the dude's current frame.
  26. //
  27. // 02/10/97 JMI Changed 3D stuff to use the new CAnim3D encapsulation
  28. // class. I suppose that eventually we will have several
  29. // of these per 3D thing.
  30. //
  31. // 02/11/97 JMI Moved CAnim3D to thing.h from dude.h.
  32. //
  33. // 02/11/97 JMI Added an EditHotSpot() override.
  34. //
  35. // 02/11/97 JMI Added the 3D animation for throwing and an associated
  36. // rigid body transform for a grenade.
  37. //
  38. // 02/12/97 JMI Fixed EditRect().
  39. //
  40. // 02/14/97 JMI Moved EditRect() and EditHotSpot() bodies into the CPP.
  41. // I was getting annoyed compiling half the project for each
  42. // little tweak while experimenting.
  43. //
  44. // 02/16/97 JMI Added Stand animation member.
  45. //
  46. // 02/18/97 MJR Added fast velocity members.
  47. //
  48. // 02/18/97 JMI Added a CBulletFest member, a GetCollisionSphere()
  49. // override, and a CSmash member.
  50. //
  51. // 02/19/97 JMI Added some states.
  52. //
  53. // 02/19/97 JMI Added proto for new ReleaseGrenade() member.
  54. //
  55. // 02/19/97 JMI Added StateDamage and m_sHitPoints.
  56. //
  57. // 02/26/97 JMI Now sets m_sprite.m_pthing = this on construction.
  58. //
  59. // 03/03/97 JMI Added last persistent state member.
  60. //
  61. // 03/03/97 JMI Added states for strafing and multiweapon logic.
  62. //
  63. // 03/03/97 JMI Changed m_pGrenade to m_pWeapon (a CWeapon* instead of
  64. // a CGrenade*) so more weapons can be handle generically.
  65. //
  66. // 03/03/97 JMI Now CDude is based upon CCharacter.
  67. // Not much base class functionality utilized yet, though.
  68. //
  69. // 03/04/97 JMI Now utilizes more of the base class functionality.
  70. // All CCharacter::Edit*() functions are used.
  71. // Moved stuff I was incorrectly doing in Render() into
  72. // Update() so CDude now uses CCharacter::Render().
  73. //
  74. // 03/04/97 JMI Added ProcessMessages() to service the message queue.
  75. //
  76. // 03/05/97 JMI Removed ProcessMessages() (now base class is fine).
  77. //
  78. // 03/05/97 JMI Removed ReleaseWeapon() now uses CCharacter::ShootWeapon().
  79. //
  80. // 03/05/97 JMI Added m_lLastShotTime representing the last time the dude
  81. // was shot.
  82. //
  83. // 03/05/97 JMI Added m_animSuicide.
  84. // Made m_sDudeNum public.
  85. // Made SetState() public.
  86. // Added StartBrainSplat() and m_bBrainSplatted.
  87. //
  88. // 03/06/97 JMI OnSuicideMsg() override.
  89. //
  90. // 03/13/97 JMI Added EditModify() member function.
  91. // Also, added m_sNumFireBombs/Missiles/Napalms.
  92. // Load now takes a version number.
  93. //
  94. // 03/13/97 JMI Added DrawStatus() member function,
  95. // m_lStatusUpdateDoneTime, m_print, and GetWeaponInfo().
  96. //
  97. // 03/13/97 JMI Changed default hitpoints to 500.
  98. //
  99. // 03/14/97 JMI Added ms_dVertVelJump.
  100. //
  101. // 03/21/97 JMI Added firing over the shoulder weapon animation,
  102. // m_animLaunch.
  103. //
  104. // 03/27/97 JMI Added many animations.
  105. //
  106. // 04/03/97 JMI Added color index members for font.
  107. //
  108. // 04/07/97 JMI Added jumps and fall components.
  109. //
  110. // 04/21/97 JMI Incorporated Mike's new crawler thinger for smooth rubbin'
  111. // and slidin' up against schtuff.
  112. //
  113. // 04/21/97 JMI Added override of WhileBlownUp().
  114. //
  115. // 04/24/97 JMI Added shotgun weapon components.
  116. //
  117. // 04/25/97 JMI Added a state for executing dudes.
  118. //
  119. // 04/25/97 JMI Added flame thrower weapon support. Required fuel ammo
  120. // info and special case on release of flamage.
  121. //
  122. // 04/28/97 JMI Removed PrepareWeapon() override since the base class
  123. // version now handles bullet oriented weapons.
  124. // Also, moved FireBullets() to base class, CCharacter.
  125. //
  126. // 04/29/97 JMI Added m_animPickPut for picking up and putting things down.
  127. // Also, added mine weapon. You cannot choose the type now,
  128. // though (it's the default which is proximity).
  129. //
  130. // 04/29/97 JMI Changed DefNumFuel to 10,000.
  131. //
  132. // 04/30/97 JMI Changed Mine enum value to ProximityMine, TimedMine,
  133. // RemoteMine, and BouncingBettyMine.
  134. //
  135. // 05/02/97 JMI Added m_bGenericEvent1.
  136. //
  137. // 05/04/97 BRH Change number of CDudes from being baseed on the STL
  138. // container size to based on m_asClassNumThings][CDudeID],
  139. // now that the STL version of the things lists has been
  140. // taken out of realm completely.
  141. //
  142. // 05/08/97 JMI Added the NoWeapon weapon.
  143. //
  144. // 05/09/97 JMI Added m_psnd which we use to track which RSnd is
  145. // playing our sample. This is useful for weapons like the
  146. // flame thrower which play a sound and then keep it looping
  147. // until they're done.
  148. //
  149. // 05/13/97 JMI Added DefNumHeatseekers, Heatseeker, and m_sNumHeatseekers.
  150. //
  151. // 05/14/97 JMI Added m_u16IdChild, m_szMessages, and Message() proto.
  152. //
  153. // 05/20/97 BRH Added GetHealth() function for the AI logic tables to
  154. // access.
  155. //
  156. // 05/22/97 JMI Added CDudeAnim3D so we could use Get() but have it not
  157. // load textures (they are loaded separately so the dude
  158. // color can be changed by the user).
  159. // Also, added m_sTextureIndex which is used to determine the
  160. // texture this dude is to use for all his animations.
  161. // Also, made enums and typedefs public.
  162. //
  163. // 05/23/97 JMI Update() was nearly a thousand lines and that was just
  164. // too damned much. So I broke it up a bit.
  165. // Also, changed FireCurrentWeapon() to ArmWeapon() which
  166. // takes as a parameter the weapon to arm.
  167. //
  168. // 05/23/97 JMI m_sTextureIndex is now set in the constructor to 0, just
  169. // in case.
  170. //
  171. // 05/23/97 JMI Changed reference to CThing::CAnim3D to CAnim3D.
  172. // Also, enhanced CDudeAnim3D to handle events.
  173. //
  174. // 05/26/97 JMI Added m_lLastYellTime.
  175. //
  176. // 05/26/97 JMI Added m_sOrigHitPoints so dude can show percentage based
  177. // on initial hitpoints.
  178. //
  179. // 05/29/97 JMI Added a Revive() function which is the best way to revive
  180. // a dude that has died.
  181. // Added a timer for changing weapons that use the same input.
  182. //
  183. // 05/30/97 JMI Added SprayCannon enum and m_inputLast.
  184. //
  185. // 06/02/97 JMI Added climb state.
  186. //
  187. // 06/02/97 JMI Removed climb state.
  188. //
  189. // 06/05/97 JMI Removed m_sHitPoints and m_sNum*. Now uses CThing3d's
  190. // m_stockpile instead.
  191. //
  192. // 06/07/97 JMI Made m_sOrigHitPoints and Init() public.
  193. //
  194. // 06/08/97 BRH Added targeting sprite to the dude to help show
  195. // what he is aiming at.
  196. //
  197. // 06/09/97 JMI Removed m_inputLast and m_lLastWeaponChangeTime which are
  198. // no longer necessary now that we can use the auto-repeat
  199. // feature with the new event driven rspGetKeyStatusArray()
  200. // used by input.cpp.
  201. // Also, added m_animIdle and m_lNextIdleTime.
  202. //
  203. // 06/11/97 JMI Added handy functions, SetWeapon(), NextWeapon(), and
  204. // PrevWeapon().
  205. //
  206. // 06/11/97 JMI Added DropPowerUp().
  207. //
  208. // 06/12/97 JMI Added ms_apszAmmoNames to differentiate between weapons
  209. // and ammo strings.
  210. //
  211. // 06/12/97 JMI Added m_bUpdateStatus.
  212. //
  213. // 06/15/97 JMI Added more DefNum* type macros for dudes' stockpiles.
  214. //
  215. // 06/16/97 JMI Added MessageChange() and m_lMsgUpdateDoneTime.
  216. //
  217. // 06/16/97 JMI Added parms to make ShootWeapon() comply with virtual
  218. // base class version.
  219. // Also, m_bClearedStatus.
  220. //
  221. // 06/16/97 JMI Added m_u16KillerId to track who killed this dude.
  222. //
  223. // 06/17/97 JMI Added m_u8LastEvent to track the last animation event
  224. // and PlayStep() to play a step noise at the proper time.
  225. // Also, added OnExecute().
  226. //
  227. // 06/25/97 JMI Added m_idVictim.
  228. //
  229. // 06/25/97 JMI Replaced m_lStatusUpdateDoneTime with
  230. // m_lNextStatusUpdateTime and removed m_bUpdateStatus.
  231. //
  232. // 07/01/97 JMI Added new rigid bodies to CDudeAnim3D and moved its
  233. // function defs into dude.cpp.
  234. // Also, added m_idFlagItem.
  235. //
  236. // 07/07/97 JMI DrawStatus() now returns true if it drew to the provide
  237. // image.
  238. //
  239. // 07/15/97 JMI Moved CDude() and ~CDude() from dude.h to dude.cpp.
  240. //
  241. // 07/15/97 JMI Added TakePowerup().
  242. //
  243. // 07/16/97 JMI Made DropPowerUp() return the newly created powerup.
  244. // Also, added CreateCheat().
  245. //
  246. // 07/16/97 JMI Changed the order of the weapons.
  247. //
  248. // 07/17/97 JMI Changed m_psnd to m_siLastPlayInstance.
  249. // Now uses new SampleMaster interface for volume and play
  250. // instance reference.
  251. //
  252. // 07/18/97 JMI Now UpdateFontColors() takes a CRealm* to match the palette
  253. // to the hood of.
  254. //
  255. // 07/21/97 JMI Now TakePowerUp() returns the powerup if it persisted.
  256. // Also, added ms_apszWeaponStatusFormats[].
  257. //
  258. // 07/21/97 JMI Added OnWeaponDestroyed() override of CCharacter version.
  259. // Also, added m_weaponShooting.
  260. //
  261. // 07/23/97 JMI Added DefHasNapalmLauncher enum.
  262. //
  263. // 07/25/97 JMI Added option to Revive() to allow him to revive in-place
  264. // (rather than warping in).
  265. // Added m_bDead and IsDead() which are true when the dude
  266. // is dead.
  267. //
  268. // 07/25/97 JMI Added StartAnim() which starts a CAnimThing.
  269. //
  270. // 07/29/97 JMI Added GetCurrentWeapon().
  271. // Made Set/Next/PrevWeapon() functions public.
  272. //
  273. // 07/29/97 JMI Changed IsDude() to IsDead(). Major typo.
  274. //
  275. // 07/30/97 JMI Added DefHasDeathWadLauncher and DeathWad.
  276. // Also, added m_sDeadMsgNum.
  277. //
  278. // 08/04/97 JMI Added array of weapon anims, m_aanimWeapons[], and
  279. // a sprite for showing the current weapon, m_spriteWeapon.
  280. // Also, condensed ms_apszAmmoNames, ms_apszWeaponNames,
  281. // ms_apszWeaponStatusFormats, and ms_apszWeaponResNames
  282. // into ms_awdWeapons.
  283. //
  284. // 08/05/97 JMI Added an ID to Message(). The idea being that, when the
  285. // same message ID is specified w/i a certain amount of time,
  286. // the more recent message is ignored.
  287. //
  288. // 08/07/97 JMI Added DefHasDoubleBarrel and DoubleBarrel.
  289. // Also, added sMinAmmoRequired to weapon details database.
  290. //
  291. // 08/07/97 JMI Added m_animBackpack and m_spriteBackpack for his backpack
  292. // when he has it.
  293. //
  294. // 08/08/97 JMI Removed m_siLastPlayInstance.
  295. //
  296. // 08/08/97 JMI Added TossPowerUp().
  297. // Also, changed TakePowerup() to TakePowerUp().
  298. //
  299. // 08/10/97 JMI Added m_dLastCrawledToPosX, Z which are the last position
  300. // successfully crawled to by the crawler (except on the
  301. // first iteration where they are simply set to the dude's
  302. // starting point). In TRACENASSERT mode, an ASSERT is
  303. // generated if the position gets modified by other than the
  304. // crawler. In release mode, it sets him back to the last
  305. // successful crawled position.
  306. // Added a function to set m_dX, Y, & Z, SetPosition().
  307. //
  308. // 08/12/97 JMI Removed unused anims: m_animJump, JumpForward, Land,
  309. // LandForward, Fall.
  310. //
  311. // 08/14/97 BRH Added static collision bits to be passed as the default
  312. // bits for weapons that the dude shoots. The default
  313. // arguments in the ShootWeapon are unreliable and may
  314. // get set to the bits of the base class default args.
  315. // Also changed call of WhileHoldingWeapon to include
  316. // these default collision bits.
  317. //
  318. // 08/17/97 JMI Got rid of m_szMessages and all message related functions
  319. // and variables from CDude since we are now using the toolbar
  320. // for dude status feedback to the user. This includes:
  321. // MsgTypeInfo, m_lNextStatusUpdateTime, m_lMsgUpdateDoneTime,
  322. // m_print, m_bClearedStatus, m_szMessages[], m_sDeadMsgNum,
  323. // ms_amtfMessages[], ms_u8FontForeIndex, ms_u8FontBackIndex,
  324. // ms_u8FontShadowIndex, DrawStatus(), StatusChange(),
  325. // MessageChange(), Message(), UpdateFontColors(),
  326. // CPowerUp::ms_apszPowerUpTypeNames[],
  327. // CPowerUp::GetDescription(), and some strings and a string
  328. // array in localize.*.
  329. //
  330. // 08/18/97 JMI Moved StartAnim() from CDude to CThing3d so more things
  331. // could use it.
  332. //
  333. // 08/18/97 JMI Added m_bInvincible which gets set via cheat.
  334. //
  335. // 08/28/97 BRH Added OnPutMeDownMsg to handle the message sent from the
  336. // flag to drop it.
  337. //
  338. // 08/30/97 JMI Removed m_idFlagItem (now uses the sprite list and, for
  339. // flag child sprites, updates them all).
  340. // Also, added GetNextFlag(), DropAllFlags().
  341. //
  342. // 09/03/97 JMI Changed the ShootWeapon() default parameters to use the
  343. // CDude statics for bits (ms_u32CollideBits*).
  344. //
  345. // 11/21/97 JMI Removed version of ShootWeapon() that took 3 default
  346. // parameters and replaced it with a version that takes no
  347. // parameters so we could control the defaults from within the
  348. // CPP.
  349. //
  350. // 12/08/97 JMI Added an option for DropPowerUp() to only drop the
  351. // currently selected weapon.
  352. //
  353. ////////////////////////////////////////////////////////////////////////////////
  354. #ifndef DUDE_H
  355. #define DUDE_H
  356. #include "RSPiX.h"
  357. #include "realm.h"
  358. #include "game.h"
  359. #include "weapon.h"
  360. #include "character.h"
  361. #include "crawler.h"
  362. #include "input.h"
  363. #include "PowerUp.h"
  364. #include "flag.h"
  365. // First shot at a dude, which is a player-controlled character
  366. class CDude : public CCharacter
  367. {
  368. //---------------------------------------------------------------------------
  369. // Types, enums, etc.
  370. //---------------------------------------------------------------------------
  371. public:
  372. // Macros.
  373. enum
  374. {
  375. MaxTextures = 8,
  376. DefHitPoints = 500,
  377. DefNumBullets = 50,
  378. DefNumGrenades = 5,
  379. DefNumFireBombs = 5,
  380. DefNumMissiles = 3,
  381. DefNumNapalms = 3,
  382. DefNumShells = 25,
  383. DefNumFuel = 50,
  384. DefNumMines = 3,
  385. DefNumHeatseekers = 3,
  386. DefHasMachineGun = 1,
  387. DefHasLauncher = 0,
  388. DefHasShotgun = 0,
  389. DefHasSprayCannon = 0,
  390. DefHasFlamer = 0,
  391. DefHasNapalmLauncher = 0,
  392. DefHasDeathWadLauncher = 0,
  393. DefHasDoubleBarrel = 0,
  394. DefKevlarLayers = 0,
  395. DefHasBackpack = 0
  396. };
  397. typedef enum
  398. {
  399. CurrentWeapon = -1,
  400. NoWeapon,
  401. SemiAutomatic,
  402. ShotGun,
  403. SprayCannon,
  404. Grenade,
  405. Rocket,
  406. Heatseeker,
  407. FireBomb,
  408. Napalm,
  409. FlameThrower,
  410. ProximityMine,
  411. TimedMine,
  412. RemoteMine,
  413. BouncingBettyMine,
  414. DeathWad,
  415. DoubleBarrel,
  416. NumWeaponTypes
  417. } WeaponType;
  418. typedef enum
  419. {
  420. MsgIdPickedUpPowerUp,
  421. MsgIdDontHaveExecuteWeapon,
  422. MsgIdDontHaveWeaponButHaveAmmo,
  423. MsgIdDontHaveWeaponOrAmmo,
  424. MsgIdDontHaveSuicideWeapon,
  425. NumMsgTypes
  426. } MsgId;
  427. typedef struct
  428. {
  429. char* pszWeaponName;
  430. char* pszAmmoName;
  431. char* pszStatusFormat;
  432. char* pszWeaponResName;
  433. short sMinAmmoRequired;
  434. } WeaponDetails;
  435. // This special version overrides the CAnim3D Get(char*, char*, short).
  436. class CDudeAnim3D : public CAnim3D
  437. {
  438. public:
  439. ChanTransform* m_ptransLeft; // Rigid body transforms for left hand.
  440. ChanTransform* m_ptransRight; // Rigid body transforms for right hand.
  441. ChanTransform* m_ptransBack; // Rigid body transforms for his backpack.
  442. // Get the various components of this animation from the resource names
  443. // specified in the provided array of pointers to strings.
  444. virtual // Overridden here.
  445. short Get( // Returns 0 on success.
  446. char* pszBaseFileName, // In: Base string for resource filenames.
  447. char* pszRigidName, // In: String to add for rigid transform channel
  448. // or NULL for none.
  449. char* pszEventName, // In: String to add for event states channel
  450. // or NULL for none.
  451. short sLoopFlags); // In: Looping flags to apply to all channels
  452. // in this anim.
  453. // Release all resources.
  454. virtual // Overridden here.
  455. void Release(void); // Returns nothing.
  456. };
  457. //---------------------------------------------------------------------------
  458. // Variables
  459. //---------------------------------------------------------------------------
  460. public:
  461. short m_sDudeNum; // This dude's number for multiplayer mode
  462. short m_sTextureIndex; // This dude's texture index. Used as an
  463. // index into m_aptextures[].
  464. short m_sOrigHitPoints; // Initial hitpoints.
  465. bool m_bTargetingHelpEnabled; // Show targeting sprite when enabled.
  466. // INPUT HACK. Normally we can't move in one direction while facing another. Android version
  467. // works by reading input while calculating the dude's velocity, but we can't do that with
  468. // keyboard input. Thus, these dude-only "twinstick" rotational values.
  469. bool m_bUseRotTS; // TRUE if we should use m_dRotTS to calculate velocity instead of m_dRot
  470. double m_dRotTS; // Direction we want to go when twinsticking
  471. // Actual joystick inputs
  472. double m_dJoyMoveVel;
  473. double m_dJoyMoveAngle;
  474. bool m_bJoyFire;
  475. double m_dJoyFireAngle;
  476. protected:
  477. CDudeAnim3D m_animStand; // Standing animation.
  478. CDudeAnim3D m_animRun; // Running animation.
  479. CDudeAnim3D m_animThrow; // Throwing animation.
  480. CDudeAnim3D m_animDie; // Dying animation.
  481. CDudeAnim3D m_animShoot; // Shooting animation.
  482. CDudeAnim3D m_animRunShoot; // Running and shooting animation.
  483. CDudeAnim3D m_animDamage; // Received damage animation.
  484. CDudeAnim3D m_animBurning; // Dude's on fire.
  485. CDudeAnim3D m_animStrafe; // Dude strafing with no forward movement.
  486. CDudeAnim3D m_animStrafeShoot; // Dude strafing and shooting with no forward movement.
  487. CDudeAnim3D m_animSuicide; // Dude commits suicide.
  488. CDudeAnim3D m_animLaunch; // Dude launches something with over the shoulder weapon.
  489. CDudeAnim3D m_animBlownUp; // Dude gets blown up.
  490. CDudeAnim3D m_animGetUp; // Dude gets up.
  491. CDudeAnim3D m_animDuck; // Dude ducks.
  492. CDudeAnim3D m_animRise; // Dude rises from duck.
  493. CDudeAnim3D m_animExecute; // Dude executes a victim/enemy.
  494. CDudeAnim3D m_animPickPut; // Dude picks something up or puts something down
  495. // depending upon direction played.
  496. CDudeAnim3D m_animIdle; // Dude hangs out -- idle animation.
  497. CAnim3D m_aanimWeapons[NumWeaponTypes]; // Weapons' anims.
  498. CSprite3 m_spriteWeapon; // Weapons' sprite.
  499. CAnim3D m_animBackpack; // Backpack's anim.
  500. CSprite3 m_spriteBackpack; // Backpack's sprite.
  501. ChanTexture* m_aptextures[MaxTextures]; // Colors for all dude animations.
  502. State m_statePersistent; // Last persistent state. For example,
  503. // StateBurning is persistent. He may get
  504. // shot and switch to damage state, but he
  505. // should switch back to burning when done.
  506. bool m_bBrainSplatted; // If true, brain has been splatted.
  507. bool m_bJumpVerticalTrigger; // If true, vertical acceleration for jump
  508. // has been applied.
  509. bool m_bGenericEvent1; // Generic event that can be used by
  510. // any state to note if it has or has not
  511. // yet been triggered.
  512. long m_lNextBulletTime; // Next time a bullet can be fired.
  513. long m_lLastShotTime; // Last time the dude was shot.
  514. long m_lLastYellTime; // Last time the dude yelled in pain
  515. // from being shot or something.
  516. long m_lNextIdleTime; // Idle animation timer.
  517. WeaponType m_weapontypeCur; // Dude's current weapon type.
  518. WeaponType m_weaponShooting; // The weapon type the dude is currently
  519. // shooting (or about to shoot).
  520. CCrawler m_crawler; // The device that allows us to slide
  521. // along edges and stuff.
  522. U16 m_u16IdChild; // ID of generic child item.
  523. // Used by State_PickUp currently.
  524. CSprite2 m_TargetSprite; // Targeting sprite to show what he is aiming
  525. // at.
  526. U16 m_u16KillerId; // Instance ID of our killer.
  527. U8 m_u8LastEvent; // Last anim event.
  528. U16 m_idVictim; // Instance ID of victim to be executed or
  529. // used as human shield.
  530. bool m_bDead; // true, if dead; false otherwise.
  531. double m_dLastCrawledToPosX; // Last position successfully crawled to.
  532. double m_dLastCrawledToPosZ; // Last position successfully crawled to.
  533. bool m_bInvincible; // Dude does not loose health when invincible.
  534. // Tracks file counter so we know when to load/save "common" data
  535. static short ms_sFileCount;
  536. //---------------------------------------------------------------------------
  537. // Static Variables
  538. //---------------------------------------------------------------------------
  539. public:
  540. // "Constant" values that we want to be able to tune using the editor
  541. static double ms_dAccUser; // Acceleration due to user
  542. static double ms_dAccDrag; // Drag on user velocity.
  543. static double ms_dMaxVelFore; // Maximum forward velocity
  544. static double ms_dMaxVelBack; // Maximum backward velocity
  545. static double ms_dMaxVelForeFast; // Maximum forward velocity
  546. static double ms_dMaxVelBackFast; // Maximum backward velocity
  547. static double ms_dDegPerSec; // Degrees of rotation per second
  548. static double ms_dVertVelJump; // Velocity of jump.
  549. // Weapon details database.
  550. static WeaponDetails ms_awdWeapons[NumWeaponTypes];
  551. // Dude's default stockpile.
  552. static CStockPile ms_stockpileDefault;
  553. // Dude's default weapon collision bits ie. what its weapons can hit
  554. static U32 ms_u32CollideBitsInclude; // Bits that determine a collision
  555. static U32 ms_u32CollideBitsDontcare; // Bits that are ignored for collision
  556. static U32 ms_u32CollideBitsExclude; // Bits that invalidate collision
  557. //---------------------------------------------------------------------------
  558. // Constructor(s) / destructor
  559. //---------------------------------------------------------------------------
  560. protected:
  561. // Constructor
  562. CDude(CRealm* pRealm);
  563. public:
  564. // Destructor
  565. ~CDude();
  566. //---------------------------------------------------------------------------
  567. // Required static functions
  568. //---------------------------------------------------------------------------
  569. public:
  570. // Construct object
  571. static short Construct( // Returns 0 if successfull, non-zero otherwise
  572. CRealm* pRealm, // In: Pointer to realm this object belongs to
  573. CThing** ppNew) // Out: Pointer to new object
  574. {
  575. short sResult = 0;
  576. *ppNew = new CDude(pRealm);
  577. if (*ppNew == 0)
  578. {
  579. sResult = -1;
  580. TRACE("CDude::Construct(): Couldn't construct CDude!\n");
  581. }
  582. return sResult;
  583. }
  584. //---------------------------------------------------------------------------
  585. // Required virtual functions (implimenting them as inlines doesn't pay!)
  586. //---------------------------------------------------------------------------
  587. public:
  588. // Load object (should call base class version!)
  589. short Load( // Returns 0 if successfull, non-zero otherwise
  590. RFile* pFile, // In: File to load from
  591. bool bEditMode, // In: True for edit mode, false otherwise
  592. short sFileCount, // In: File count (unique per file, never 0)
  593. ULONG ulFileVersion); // In: File version being loaded.
  594. // Save object (should call base class version!)
  595. short Save( // Returns 0 if successfull, non-zero otherwise
  596. RFile* pFile, // In: File to save to
  597. short sFileCount); // In: File count (unique per file, never 0)
  598. // Startup object
  599. short Startup(void); // Returns 0 if successfull, non-zero otherwise
  600. // Shutdown object
  601. short Shutdown(void); // Returns 0 if successfull, non-zero otherwise
  602. // Suspend object
  603. void Suspend(void);
  604. // Resume object
  605. void Resume(void);
  606. // Update object
  607. void Update(void);
  608. // Render object
  609. void Render(void);
  610. // Called by editor to init new object at specified position
  611. short EditNew( // Returns 0 if successfull, non-zero otherwise
  612. short sX, // In: New x coord
  613. short sY, // In: New y coord
  614. short sZ); // In: New z coord
  615. // Called by editor to modify object
  616. short EditModify(void); // Returns 0 if successfull, non-zero otherwise
  617. //---------------------------------------------------------------------------
  618. // Other functions
  619. //---------------------------------------------------------------------------
  620. public:
  621. // Return the X position
  622. double GetX()
  623. {return m_dX;};
  624. // Return the Y position
  625. double GetY()
  626. {return m_dY;};
  627. // Return the Z position
  628. double GetZ()
  629. {return m_dZ;};
  630. // Return the dude's hit points
  631. short GetHealth()
  632. {return m_stockpile.m_sHitPoints;};
  633. // Sets a new state based on supplied state enum. Will set animation ptr
  634. // to proper animation for state and reset animation timer.
  635. bool SetState( // Returns true if new state realized, false otherwise.
  636. State state); // New state.
  637. // Gets info on specified weapon.
  638. void GetWeaponInfo( // Returns nothing.
  639. WeaponType weapon, // In: Weapon type to query.
  640. ClassIDType* pidWeapon, // Out: CThing class ID of weapon.
  641. short** ppsNum); // Out: Ptr to the weapon's counter.
  642. // Determines if supplied position is valid tweaking it if necessary.
  643. virtual // Overridden here.
  644. bool MakeValidPosition( // Returns true, if new position was validitable.
  645. // Returns false, if could not reach new position.
  646. double* pdNewX, // In: x position to validate.
  647. // Out: New x position.
  648. double* pdNewY, // In: y position to validate.
  649. // Out: New y position.
  650. double* pdNewZ, // In: z position to validate.
  651. // Out: New z position.
  652. short sVertTolerance = 0); // Vertical tolerance.
  653. // Shoot current weapon.
  654. // This should be done when the character releases the weapon it's
  655. // shooting.
  656. virtual // Overriden here.
  657. CWeapon* ShootWeapon( // Returns the weapon ptr or NULL.
  658. CSmash::Bits bitsInclude,
  659. CSmash::Bits bitsDontcare,
  660. CSmash::Bits bitsExclude);
  661. CWeapon* ShootWeapon(void); // Returns the weapoin ptr or NULL.
  662. // Determine if the dude is dead.
  663. bool IsDead(void) // Returns true, if dead; false otherwise.
  664. {
  665. return m_bDead;
  666. }
  667. // Message handling functions ////////////////////////////////////////////
  668. // Handles a Shot_Message.
  669. virtual // Override to implement additional functionality.
  670. // Call base class to get default functionality.
  671. void OnShotMsg( // Returns nothing.
  672. Shot_Message* pshotmsg); // In: Message to handle.
  673. // Handles an Explosion_Message.
  674. virtual // Override to implement additional functionality.
  675. // Call base class to get default functionality.
  676. void OnExplosionMsg( // Returns nothing.
  677. Explosion_Message* pexplosionmsg); // In: Message to handle.
  678. // Handles a Burn_Message.
  679. virtual // Override to implement additional functionality.
  680. // Call base class to get default functionality.
  681. void OnBurnMsg( // Returns nothing.
  682. Burn_Message* pburnmsg); // In: Message to handle.
  683. // Handles an ObjectDelete_Message.
  684. virtual // Override to implement additional functionality.
  685. // Call base class to get default functionality.
  686. void OnDeleteMsg( // Returns nothing.
  687. ObjectDelete_Message* pdeletemsg); // In: Message to handle.
  688. // Handles a Suicide_Message.
  689. virtual // Override to implement additional functionality.
  690. // Call base class to get default functionality.
  691. void OnSuicideMsg( // Returns nothing.
  692. Suicide_Message* psuicidemsg); // In: Message to handle.
  693. // Handles a PutMeDown_Message
  694. virtual // Override to implement additional functionality
  695. // Call base calss to get default functionality
  696. void OnPutMeDownMsg( // Returns nothing
  697. PutMeDown_Message* pputmedownmsg); //In: Message to handle
  698. // State handling functions /////////////////////////////////////////////
  699. // Implements basic functionality while being blown up and returns true
  700. // until the state is completed.
  701. virtual // Overriden here.
  702. bool WhileBlownUp(void); // Returns true until state is complete.
  703. // Execute the nearest writhing guy, if any.
  704. void OnExecute(void); // Returns nothing.
  705. // Implements one-time functionality for when a weapon is destroyed while
  706. // we were moving it (i.e., before we let go or ShootWeapon()'ed it).
  707. // This can occur when a weapon, while traveling along our rigid body,
  708. // enters terrain.
  709. virtual // Overriden here.
  710. void OnWeaponDestroyed(void);
  711. // Other functions //////////////////////////////////////////////////////
  712. // Revive a dead dude. This is a more graceful way than just setting
  713. // his state. This will restore hitpoints and make him animate to a
  714. // standing position. If bWarp is true, he'll use a warp when available.
  715. void Revive( // Returns nothing.
  716. bool bWarpIn = true); // In: true, to warp in, false to just get up.
  717. // Initialize dude. Must be done before dude is used.
  718. short Init(void); // Returns 0 if successfull, non-zero otherwise
  719. // Next weapon please.
  720. void NextWeapon(void);
  721. // Previous weapon please.
  722. void PrevWeapon(void);
  723. // Set the current weapon.
  724. bool SetWeapon( // Returns true if weapon could be set as current.
  725. WeaponType weapon, // In: New weapon to attempt to make the current.
  726. bool bSetIfNoAmmo = true); // In: true to set weapon (even if no ammo).
  727. // Get the current weapon the dude has ready to use.
  728. WeaponType GetCurrentWeapon(void);
  729. //---------------------------------------------------------------------------
  730. // Internal functions
  731. //---------------------------------------------------------------------------
  732. protected:
  733. // Kill dude
  734. void Kill(void);
  735. // Get all required resources
  736. short GetResources(void); // Returns 0 if successfull, non-zero otherwise
  737. // Free all resources
  738. void FreeResources(void);
  739. // Update the animation radius based on current frame.
  740. void UpdateRadius(void); // Returns and accepts nothing.
  741. // Fire specified weapon type.
  742. void ArmWeapon( // Returns nothing.
  743. WeaponType weapon = CurrentWeapon); // In: Weapon to fire.
  744. // Receive damage.
  745. void Damage( // Returns nothing.
  746. short sHitPoints, // Hit points of damage to do.
  747. U16 u16ShooterId); // In: Thing responsible for damage.
  748. // Start the brain splat anim on its way.
  749. void StartBrainSplat(void); // Returns nothing.
  750. // Attempts user motivated state transitions.
  751. void ProcessInput( // Returns nothing.
  752. double* pdMaxForeVel, // Out: Maximum forward velocity.
  753. double* pdMaxBackVel, // Out: Maximum backward velocity.
  754. short* psStrafeAngle); // Out: Strafe angle.
  755. // Applies accelerations, velocities, reacts to terrain obstructions, etc.
  756. void ProcessForces( // Returns nothing.
  757. long lCurTime, // In: Current game time.
  758. double dMaxForeVel, // Out: Maximum forward velocity.
  759. double dMaxBackVel, // Out: Maximum backward velocity.
  760. short sStrafeAngle); // Out: Strafe angle.
  761. // If the targeting aid is enabled, this function will look for a target
  762. // and if it finds one, it will show the Targeting sprite on the target.
  763. void ShowTarget(void);
  764. // Drop a powerup with the settings described by the specified stockpile.
  765. CPowerUp* DropPowerUp( // Returns new powerup on success; NULL on failure.
  766. CStockPile* pstockpile, // In: Settings for powerup.
  767. bool bCurWeaponOnly); // In: true, if only the current weapon should be
  768. // in the powerup; false, if all.
  769. // Create a cheat powerup.
  770. CPowerUp* CreateCheat( // Returns new powerup on success; NULL on failure.
  771. CStockPile* pstockpile); // In: Settings for powerup.
  772. // Play a step noise if the event is different from the last.
  773. void PlayStep(void); // Returns nothing.
  774. // Find someone to execute.
  775. bool FindExecutee(void); // Returns true, if we found one; false, otherwise.
  776. // Track executee.
  777. bool TrackExecutee( // Returns true to persist, false, if we lost the target.
  778. double dSeconds); // In: Seconds since last iteration.
  779. // Take a powerup.
  780. void TakePowerUp( // Returns nothing.
  781. CPowerUp** pppowerup); // In: Power up to take from.
  782. // Out: Ptr to powerup, if it persisted; NULL otherwise.
  783. // Break a powerup open and toss it.
  784. void TossPowerUp( // Returns nothing.
  785. CPowerUp* ppowerup, // In: Powerup to toss.
  786. short sVelocity); // In: Velocity of toss.
  787. // Make sure warp can access this function.
  788. friend class CWarp;
  789. // Sets the dude's position. It is very important that the dude is not
  790. // moved by outside things, other than the warp.
  791. void SetPosition( // Returns nothing.
  792. double dX, // In: New position for dude.
  793. double dY, // In: New position for dude.
  794. double dZ); // In: New position for dude.
  795. // Get the next child flag item after the specified flag item.
  796. CFlag* GetNextFlag( // Returns the next flag item after pflag.
  797. CFlag* pflag); // In: The flag to get the follower of.
  798. // NULL for first child flag.
  799. // Drop all child flag items.
  800. void DropAllFlags(
  801. GameMessage* pmsg); // In: Message to pass to flags.
  802. };
  803. #endif //DUDE_H
  804. ////////////////////////////////////////////////////////////////////////////////
  805. // EOF
  806. ////////////////////////////////////////////////////////////////////////////////