PageRenderTime 31ms CodeModel.GetById 0ms RepoModel.GetById 0ms app.codeStats 0ms

/neo/d3xp/Misc.h

https://bitbucket.org/stephenabritton/doom-3-bfg
C Header | 928 lines | 449 code | 243 blank | 236 comment | 0 complexity | 1200e99b879c6c37bf8e6bafc3595675 MD5 | raw file
  1. /*
  2. ===========================================================================
  3. Doom 3 BFG Edition GPL Source Code
  4. Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
  5. This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
  6. Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation, either version 3 of the License, or
  9. (at your option) any later version.
  10. Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. GNU General Public License for more details.
  14. You should have received a copy of the GNU General Public License
  15. along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
  16. In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
  17. If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
  18. ===========================================================================
  19. */
  20. #ifndef __GAME_MISC_H__
  21. #define __GAME_MISC_H__
  22. /*
  23. ===============================================================================
  24. idSpawnableEntity
  25. A simple, spawnable entity with a model and no functionable ability of it's own.
  26. For example, it can be used as a placeholder during development, for marking
  27. locations on maps for script, or for simple placed models without any behavior
  28. that can be bound to other entities. Should not be subclassed.
  29. ===============================================================================
  30. */
  31. class idSpawnableEntity : public idEntity {
  32. public:
  33. CLASS_PROTOTYPE( idSpawnableEntity );
  34. void Spawn();
  35. private:
  36. };
  37. /*
  38. ===============================================================================
  39. Potential spawning position for players.
  40. The first time a player enters the game, they will be at an 'initial' spot.
  41. Targets will be fired when someone spawns in on them.
  42. When triggered, will cause player to be teleported to spawn spot.
  43. ===============================================================================
  44. */
  45. class idPlayerStart : public idEntity {
  46. public:
  47. CLASS_PROTOTYPE( idPlayerStart );
  48. enum {
  49. EVENT_TELEPORTPLAYER = idEntity::EVENT_MAXEVENTS,
  50. EVENT_MAXEVENTS
  51. };
  52. idPlayerStart();
  53. void Spawn();
  54. void Save( idSaveGame *savefile ) const;
  55. void Restore( idRestoreGame *savefile );
  56. virtual bool ClientReceiveEvent( int event, int time, const idBitMsg &msg );
  57. private:
  58. int teleportStage;
  59. void Event_TeleportPlayer( idEntity *activator );
  60. void Event_TeleportStage( idEntity *player );
  61. void TeleportPlayer( idPlayer *player );
  62. };
  63. /*
  64. ===============================================================================
  65. Non-displayed entity used to activate triggers when it touches them.
  66. Bind to a mover to have the mover activate a trigger as it moves.
  67. When target by triggers, activating the trigger will toggle the
  68. activator on and off. Check "start_off" to have it spawn disabled.
  69. ===============================================================================
  70. */
  71. class idActivator : public idEntity {
  72. public:
  73. CLASS_PROTOTYPE( idActivator );
  74. void Spawn();
  75. void Save( idSaveGame *savefile ) const;
  76. void Restore( idRestoreGame *savefile );
  77. virtual void Think();
  78. private:
  79. bool stay_on;
  80. void Event_Activate( idEntity *activator );
  81. };
  82. /*
  83. ===============================================================================
  84. Path entities for monsters to follow.
  85. ===============================================================================
  86. */
  87. class idPathCorner : public idEntity {
  88. public:
  89. CLASS_PROTOTYPE( idPathCorner );
  90. void Spawn();
  91. static void DrawDebugInfo();
  92. static idPathCorner *RandomPath( const idEntity *source, const idEntity *ignore );
  93. private:
  94. void Event_RandomPath();
  95. };
  96. /*
  97. ===============================================================================
  98. Object that fires targets and changes shader parms when damaged.
  99. ===============================================================================
  100. */
  101. class idDamagable : public idEntity {
  102. public:
  103. CLASS_PROTOTYPE( idDamagable );
  104. idDamagable();
  105. void Save( idSaveGame *savefile ) const;
  106. void Restore( idRestoreGame *savefile );
  107. void Spawn();
  108. void Killed( idEntity *inflictor, idEntity *attacker, int damage, const idVec3 &dir, int location );
  109. virtual void Hide();
  110. virtual void Show();
  111. private:
  112. int count;
  113. int nextTriggerTime;
  114. void BecomeBroken( idEntity *activator );
  115. void Event_BecomeBroken( idEntity *activator );
  116. void Event_RestoreDamagable();
  117. };
  118. /*
  119. ===============================================================================
  120. Hidden object that explodes when activated
  121. ===============================================================================
  122. */
  123. class idExplodable : public idEntity {
  124. public:
  125. CLASS_PROTOTYPE( idExplodable );
  126. void Spawn();
  127. private:
  128. void Event_Explode( idEntity *activator );
  129. };
  130. /*
  131. ===============================================================================
  132. idSpring
  133. ===============================================================================
  134. */
  135. class idSpring : public idEntity {
  136. public:
  137. CLASS_PROTOTYPE( idSpring );
  138. void Spawn();
  139. virtual void Think();
  140. private:
  141. idEntity * ent1;
  142. idEntity * ent2;
  143. int id1;
  144. int id2;
  145. idVec3 p1;
  146. idVec3 p2;
  147. idForce_Spring spring;
  148. void Event_LinkSpring();
  149. };
  150. /*
  151. ===============================================================================
  152. idForceField
  153. ===============================================================================
  154. */
  155. class idForceField : public idEntity {
  156. public:
  157. CLASS_PROTOTYPE( idForceField );
  158. void Save( idSaveGame *savefile ) const;
  159. void Restore( idRestoreGame *savefile );
  160. void Spawn();
  161. virtual void Think();
  162. virtual void ClientThink( const int curTime, const float fraction, const bool predict ) ;
  163. private:
  164. idForce_Field forceField;
  165. void Toggle();
  166. void Event_Activate( idEntity *activator );
  167. void Event_Toggle();
  168. void Event_FindTargets();
  169. };
  170. /*
  171. ===============================================================================
  172. idAnimated
  173. ===============================================================================
  174. */
  175. class idAnimated : public idAFEntity_Gibbable {
  176. public:
  177. CLASS_PROTOTYPE( idAnimated );
  178. idAnimated();
  179. ~idAnimated();
  180. void Save( idSaveGame *savefile ) const;
  181. void Restore( idRestoreGame *savefile );
  182. void Spawn();
  183. virtual bool LoadAF();
  184. bool StartRagdoll();
  185. virtual bool GetPhysicsToSoundTransform( idVec3 &origin, idMat3 &axis );
  186. private:
  187. int num_anims;
  188. int current_anim_index;
  189. int anim;
  190. int blendFrames;
  191. jointHandle_t soundJoint;
  192. idEntityPtr<idEntity> activator;
  193. bool activated;
  194. int achievement;
  195. void PlayNextAnim();
  196. void Event_Activate( idEntity *activator );
  197. void Event_Start();
  198. void Event_StartRagdoll();
  199. void Event_AnimDone( int animIndex );
  200. void Event_Footstep();
  201. void Event_LaunchMissiles( const char *projectilename, const char *sound, const char *launchjoint, const char *targetjoint, int numshots, int framedelay );
  202. void Event_LaunchMissilesUpdate( int launchjoint, int targetjoint, int numshots, int framedelay );
  203. void Event_SetAnimation( const char *animName );
  204. void Event_GetAnimationLength();
  205. };
  206. /*
  207. ===============================================================================
  208. idStaticEntity
  209. ===============================================================================
  210. */
  211. class idStaticEntity : public idEntity {
  212. public:
  213. CLASS_PROTOTYPE( idStaticEntity );
  214. idStaticEntity();
  215. void Save( idSaveGame *savefile ) const;
  216. void Restore( idRestoreGame *savefile );
  217. void Spawn();
  218. void ShowEditingDialog();
  219. virtual void Hide();
  220. virtual void Show();
  221. void Fade( const idVec4 &to, float fadeTime );
  222. virtual void Think();
  223. virtual void WriteToSnapshot( idBitMsg &msg ) const;
  224. virtual void ReadFromSnapshot( const idBitMsg &msg );
  225. private:
  226. void Event_Activate( idEntity *activator );
  227. int spawnTime;
  228. bool active;
  229. idVec4 fadeFrom;
  230. idVec4 fadeTo;
  231. int fadeStart;
  232. int fadeEnd;
  233. bool runGui;
  234. };
  235. /*
  236. ===============================================================================
  237. idFuncEmitter
  238. ===============================================================================
  239. */
  240. class idFuncEmitter : public idStaticEntity {
  241. public:
  242. CLASS_PROTOTYPE( idFuncEmitter );
  243. idFuncEmitter();
  244. void Save( idSaveGame *savefile ) const;
  245. void Restore( idRestoreGame *savefile );
  246. void Spawn();
  247. void Event_Activate( idEntity *activator );
  248. virtual void WriteToSnapshot( idBitMsg &msg ) const;
  249. virtual void ReadFromSnapshot( const idBitMsg &msg );
  250. private:
  251. bool hidden;
  252. };
  253. /*
  254. ===============================================================================
  255. idFuncShootProjectile
  256. ===============================================================================
  257. */
  258. class idFuncShootProjectile : public idStaticEntity {
  259. public:
  260. CLASS_PROTOTYPE( idFuncShootProjectile );
  261. idFuncShootProjectile();
  262. void Save( idSaveGame *savefile ) const;
  263. void Restore( idRestoreGame *savefile );
  264. void Spawn();
  265. void Event_Activate( idEntity *activator );
  266. virtual void Think();
  267. virtual void WriteToSnapshot( idBitMsg &msg ) const;
  268. virtual void ReadFromSnapshot( const idBitMsg &msg );
  269. private:
  270. int mRespawnDelay;
  271. int mRespawnTime;
  272. float mShootSpeed;
  273. idVec3 mShootDir;
  274. idStr mEntityDefName;
  275. idEntityPtr< idEntity > mLastProjectile;
  276. };
  277. /*
  278. ===============================================================================
  279. idFuncSmoke
  280. ===============================================================================
  281. */
  282. class idFuncSmoke : public idEntity {
  283. public:
  284. CLASS_PROTOTYPE( idFuncSmoke );
  285. idFuncSmoke();
  286. void Spawn();
  287. void Save( idSaveGame *savefile ) const;
  288. void Restore( idRestoreGame *savefile );
  289. virtual void Think();
  290. void Event_Activate( idEntity *activator );
  291. private:
  292. int smokeTime;
  293. const idDeclParticle * smoke;
  294. bool restart;
  295. };
  296. /*
  297. ===============================================================================
  298. idFuncSplat
  299. ===============================================================================
  300. */
  301. class idFuncSplat : public idFuncEmitter {
  302. public:
  303. CLASS_PROTOTYPE( idFuncSplat );
  304. idFuncSplat();
  305. void Spawn();
  306. private:
  307. void Event_Activate( idEntity *activator );
  308. void Event_Splat();
  309. };
  310. /*
  311. ===============================================================================
  312. idTextEntity
  313. ===============================================================================
  314. */
  315. class idTextEntity : public idEntity {
  316. public:
  317. CLASS_PROTOTYPE( idTextEntity );
  318. void Spawn();
  319. void Save( idSaveGame *savefile ) const;
  320. void Restore( idRestoreGame *savefile );
  321. virtual void Think();
  322. private:
  323. idStr text;
  324. bool playerOriented;
  325. };
  326. /*
  327. ===============================================================================
  328. idLocationEntity
  329. ===============================================================================
  330. */
  331. class idLocationEntity : public idEntity {
  332. public:
  333. CLASS_PROTOTYPE( idLocationEntity );
  334. void Spawn();
  335. const char * GetLocation() const;
  336. private:
  337. };
  338. class idLocationSeparatorEntity : public idEntity {
  339. public:
  340. CLASS_PROTOTYPE( idLocationSeparatorEntity );
  341. void Spawn();
  342. private:
  343. };
  344. class idVacuumSeparatorEntity : public idEntity {
  345. public:
  346. CLASS_PROTOTYPE( idVacuumSeparatorEntity );
  347. idVacuumSeparatorEntity();
  348. void Spawn();
  349. void Save( idSaveGame *savefile ) const;
  350. void Restore( idRestoreGame *savefile );
  351. void Event_Activate( idEntity *activator );
  352. private:
  353. qhandle_t portal;
  354. };
  355. class idVacuumEntity : public idEntity {
  356. public:
  357. CLASS_PROTOTYPE( idVacuumEntity );
  358. void Spawn();
  359. private:
  360. };
  361. /*
  362. ===============================================================================
  363. idBeam
  364. ===============================================================================
  365. */
  366. class idBeam : public idEntity {
  367. public:
  368. CLASS_PROTOTYPE( idBeam );
  369. idBeam();
  370. void Spawn();
  371. void Save( idSaveGame *savefile ) const;
  372. void Restore( idRestoreGame *savefile );
  373. virtual void Think();
  374. void SetMaster( idBeam *masterbeam );
  375. void SetBeamTarget( const idVec3 &origin );
  376. virtual void Show();
  377. virtual void WriteToSnapshot( idBitMsg &msg ) const;
  378. virtual void ReadFromSnapshot( const idBitMsg &msg );
  379. private:
  380. void Event_MatchTarget();
  381. void Event_Activate( idEntity *activator );
  382. idEntityPtr<idBeam> target;
  383. idEntityPtr<idBeam> master;
  384. };
  385. /*
  386. ===============================================================================
  387. idLiquid
  388. ===============================================================================
  389. */
  390. class idRenderModelLiquid;
  391. class idLiquid : public idEntity {
  392. public:
  393. CLASS_PROTOTYPE( idLiquid );
  394. void Spawn();
  395. void Save( idSaveGame *savefile ) const;
  396. void Restore( idRestoreGame *savefile );
  397. private:
  398. void Event_Touch( idEntity *other, trace_t *trace );
  399. idRenderModelLiquid *model;
  400. };
  401. /*
  402. ===============================================================================
  403. idShaking
  404. ===============================================================================
  405. */
  406. class idShaking : public idEntity {
  407. public:
  408. CLASS_PROTOTYPE( idShaking );
  409. idShaking();
  410. void Spawn();
  411. void Save( idSaveGame *savefile ) const;
  412. void Restore( idRestoreGame *savefile );
  413. private:
  414. idPhysics_Parametric physicsObj;
  415. bool active;
  416. void BeginShaking();
  417. void Event_Activate( idEntity *activator );
  418. };
  419. /*
  420. ===============================================================================
  421. idEarthQuake
  422. ===============================================================================
  423. */
  424. class idEarthQuake : public idEntity {
  425. public:
  426. CLASS_PROTOTYPE( idEarthQuake );
  427. idEarthQuake();
  428. void Spawn();
  429. void Save( idSaveGame *savefile ) const;
  430. void Restore( idRestoreGame *savefile );
  431. virtual void Think();
  432. private:
  433. int nextTriggerTime;
  434. int shakeStopTime;
  435. float wait;
  436. float random;
  437. bool triggered;
  438. bool playerOriented;
  439. bool disabled;
  440. float shakeTime;
  441. void Event_Activate( idEntity *activator );
  442. };
  443. /*
  444. ===============================================================================
  445. idFuncPortal
  446. ===============================================================================
  447. */
  448. class idFuncPortal : public idEntity {
  449. public:
  450. CLASS_PROTOTYPE( idFuncPortal );
  451. idFuncPortal();
  452. void Spawn();
  453. void Save( idSaveGame *savefile ) const;
  454. void Restore( idRestoreGame *savefile );
  455. private:
  456. qhandle_t portal;
  457. bool state;
  458. void Event_Activate( idEntity *activator );
  459. };
  460. /*
  461. ===============================================================================
  462. idFuncAASPortal
  463. ===============================================================================
  464. */
  465. class idFuncAASPortal : public idEntity {
  466. public:
  467. CLASS_PROTOTYPE( idFuncAASPortal );
  468. idFuncAASPortal();
  469. void Spawn();
  470. void Save( idSaveGame *savefile ) const;
  471. void Restore( idRestoreGame *savefile );
  472. private:
  473. bool state;
  474. void Event_Activate( idEntity *activator );
  475. };
  476. /*
  477. ===============================================================================
  478. idFuncAASObstacle
  479. ===============================================================================
  480. */
  481. class idFuncAASObstacle : public idEntity {
  482. public:
  483. CLASS_PROTOTYPE( idFuncAASObstacle );
  484. idFuncAASObstacle();
  485. void Spawn();
  486. void Save( idSaveGame *savefile ) const;
  487. void Restore( idRestoreGame *savefile );
  488. private:
  489. bool state;
  490. void Event_Activate( idEntity *activator );
  491. };
  492. /*
  493. ===============================================================================
  494. idFuncRadioChatter
  495. ===============================================================================
  496. */
  497. class idFuncRadioChatter : public idEntity {
  498. public:
  499. CLASS_PROTOTYPE( idFuncRadioChatter );
  500. idFuncRadioChatter();
  501. void Spawn();
  502. void Save( idSaveGame *savefile ) const;
  503. void Restore( idRestoreGame *savefile );
  504. private:
  505. float time;
  506. void Event_Activate( idEntity *activator );
  507. void Event_ResetRadioHud( idEntity *activator );
  508. };
  509. /*
  510. ===============================================================================
  511. idPhantomObjects
  512. ===============================================================================
  513. */
  514. class idPhantomObjects : public idEntity {
  515. public:
  516. CLASS_PROTOTYPE( idPhantomObjects );
  517. idPhantomObjects();
  518. void Spawn();
  519. void Save( idSaveGame *savefile ) const;
  520. void Restore( idRestoreGame *savefile );
  521. virtual void Think();
  522. private:
  523. void Event_Activate( idEntity *activator );
  524. void Event_Throw();
  525. void Event_ShakeObject( idEntity *object, int starttime );
  526. int end_time;
  527. float throw_time;
  528. float shake_time;
  529. idVec3 shake_ang;
  530. float speed;
  531. int min_wait;
  532. int max_wait;
  533. idEntityPtr<idActor>target;
  534. idList<int> targetTime;
  535. idList<idVec3> lastTargetPos;
  536. };
  537. /*
  538. ===============================================================================
  539. idShockwave
  540. ===============================================================================
  541. */
  542. class idShockwave : public idEntity {
  543. public:
  544. CLASS_PROTOTYPE( idShockwave );
  545. idShockwave();
  546. ~idShockwave();
  547. void Spawn();
  548. void Think();
  549. void Save( idSaveGame *savefile ) const;
  550. void Restore( idRestoreGame *savefile );
  551. private:
  552. void Event_Activate( idEntity *activator );
  553. bool isActive;
  554. int startTime;
  555. int duration;
  556. float startSize;
  557. float endSize;
  558. float currentSize;
  559. float magnitude;
  560. float height;
  561. bool playerDamaged;
  562. float playerDamageSize;
  563. };
  564. /*
  565. ===============================================================================
  566. idFuncMountedObject
  567. ===============================================================================
  568. */
  569. class idFuncMountedObject : public idEntity {
  570. public:
  571. CLASS_PROTOTYPE( idFuncMountedObject );
  572. idFuncMountedObject();
  573. ~idFuncMountedObject();
  574. void Spawn();
  575. void Think();
  576. void GetAngleRestrictions( int &yaw_min, int &yaw_max, int &pitch );
  577. private:
  578. int harc;
  579. int varc;
  580. void Event_Touch( idEntity *other, trace_t *trace );
  581. void Event_Activate( idEntity *activator );
  582. public:
  583. bool isMounted;
  584. function_t * scriptFunction;
  585. idPlayer * mountedPlayer;
  586. };
  587. class idFuncMountedWeapon : public idFuncMountedObject {
  588. public:
  589. CLASS_PROTOTYPE( idFuncMountedWeapon );
  590. idFuncMountedWeapon();
  591. ~idFuncMountedWeapon();
  592. void Spawn();
  593. void Think();
  594. private:
  595. // The actual turret that moves with the player's view
  596. idEntity * turret;
  597. // the muzzle bone's position, used for launching projectiles and trailing smoke
  598. idVec3 muzzleOrigin;
  599. idMat3 muzzleAxis;
  600. float weaponLastFireTime;
  601. float weaponFireDelay;
  602. const idDict * projectile;
  603. const idSoundShader *soundFireWeapon;
  604. void Event_PostSpawn();
  605. };
  606. /*
  607. ===============================================================================
  608. idPortalSky
  609. ===============================================================================
  610. */
  611. class idPortalSky : public idEntity {
  612. public:
  613. CLASS_PROTOTYPE( idPortalSky );
  614. idPortalSky();
  615. ~idPortalSky();
  616. void Spawn();
  617. void Event_PostSpawn();
  618. void Event_Activate( idEntity *activator );
  619. };
  620. #endif /* !__GAME_MISC_H__ */