PageRenderTime 54ms CodeModel.GetById 8ms RepoModel.GetById 0ms app.codeStats 0ms

/neo/d3xp/Misc.h

https://bitbucket.org/peanut64/iodoom3-copy-original
C++ Header | 897 lines | 434 code | 234 blank | 229 comment | 0 complexity | 245b07b0d699526f52158d890480e68d MD5 | raw file
Possible License(s): GPL-3.0, BSD-3-Clause, Unlicense, CC0-1.0, GPL-2.0
  1. /*
  2. ===========================================================================
  3. Doom 3 GPL Source Code
  4. Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
  5. This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
  6. Doom 3 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 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 Source Code. If not, see <http://www.gnu.org/licenses/>.
  16. In addition, the Doom 3 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 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( void );
  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( void );
  53. void Spawn( void );
  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( void );
  75. void Save( idSaveGame *savefile ) const;
  76. void Restore( idRestoreGame *savefile );
  77. virtual void Think( void );
  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( void );
  91. static void DrawDebugInfo( void );
  92. static idPathCorner *RandomPath( const idEntity *source, const idEntity *ignore );
  93. private:
  94. void Event_RandomPath( void );
  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( void );
  105. void Save( idSaveGame *savefile ) const;
  106. void Restore( idRestoreGame *savefile );
  107. void Spawn( void );
  108. void Killed( idEntity *inflictor, idEntity *attacker, int damage, const idVec3 &dir, int location );
  109. #ifdef _D3XP
  110. virtual void Hide( void );
  111. virtual void Show( void );
  112. #endif
  113. private:
  114. int count;
  115. int nextTriggerTime;
  116. void BecomeBroken( idEntity *activator );
  117. void Event_BecomeBroken( idEntity *activator );
  118. void Event_RestoreDamagable( void );
  119. };
  120. /*
  121. ===============================================================================
  122. Hidden object that explodes when activated
  123. ===============================================================================
  124. */
  125. class idExplodable : public idEntity {
  126. public:
  127. CLASS_PROTOTYPE( idExplodable );
  128. void Spawn( void );
  129. private:
  130. void Event_Explode( idEntity *activator );
  131. };
  132. /*
  133. ===============================================================================
  134. idSpring
  135. ===============================================================================
  136. */
  137. class idSpring : public idEntity {
  138. public:
  139. CLASS_PROTOTYPE( idSpring );
  140. void Spawn( void );
  141. virtual void Think( void );
  142. private:
  143. idEntity * ent1;
  144. idEntity * ent2;
  145. int id1;
  146. int id2;
  147. idVec3 p1;
  148. idVec3 p2;
  149. idForce_Spring spring;
  150. void Event_LinkSpring( void );
  151. };
  152. /*
  153. ===============================================================================
  154. idForceField
  155. ===============================================================================
  156. */
  157. class idForceField : public idEntity {
  158. public:
  159. CLASS_PROTOTYPE( idForceField );
  160. void Save( idSaveGame *savefile ) const;
  161. void Restore( idRestoreGame *savefile );
  162. void Spawn( void );
  163. virtual void Think( void );
  164. private:
  165. idForce_Field forceField;
  166. void Toggle( void );
  167. void Event_Activate( idEntity *activator );
  168. void Event_Toggle( void );
  169. void Event_FindTargets( void );
  170. };
  171. /*
  172. ===============================================================================
  173. idAnimated
  174. ===============================================================================
  175. */
  176. class idAnimated : public idAFEntity_Gibbable {
  177. public:
  178. CLASS_PROTOTYPE( idAnimated );
  179. idAnimated();
  180. ~idAnimated();
  181. void Save( idSaveGame *savefile ) const;
  182. void Restore( idRestoreGame *savefile );
  183. void Spawn( void );
  184. virtual bool LoadAF( void );
  185. bool StartRagdoll( void );
  186. virtual bool GetPhysicsToSoundTransform( idVec3 &origin, idMat3 &axis );
  187. private:
  188. int num_anims;
  189. int current_anim_index;
  190. int anim;
  191. int blendFrames;
  192. jointHandle_t soundJoint;
  193. idEntityPtr<idEntity> activator;
  194. bool activated;
  195. void PlayNextAnim( void );
  196. void Event_Activate( idEntity *activator );
  197. void Event_Start( void );
  198. void Event_StartRagdoll( void );
  199. void Event_AnimDone( int animIndex );
  200. void Event_Footstep( void );
  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. #ifdef _D3XP
  204. void Event_SetAnimation( const char *animName );
  205. void Event_GetAnimationLength();
  206. #endif
  207. };
  208. /*
  209. ===============================================================================
  210. idStaticEntity
  211. ===============================================================================
  212. */
  213. class idStaticEntity : public idEntity {
  214. public:
  215. CLASS_PROTOTYPE( idStaticEntity );
  216. idStaticEntity( void );
  217. void Save( idSaveGame *savefile ) const;
  218. void Restore( idRestoreGame *savefile );
  219. void Spawn( void );
  220. void ShowEditingDialog( void );
  221. virtual void Hide( void );
  222. virtual void Show( void );
  223. void Fade( const idVec4 &to, float fadeTime );
  224. virtual void Think( void );
  225. virtual void WriteToSnapshot( idBitMsgDelta &msg ) const;
  226. virtual void ReadFromSnapshot( const idBitMsgDelta &msg );
  227. private:
  228. void Event_Activate( idEntity *activator );
  229. int spawnTime;
  230. bool active;
  231. idVec4 fadeFrom;
  232. idVec4 fadeTo;
  233. int fadeStart;
  234. int fadeEnd;
  235. bool runGui;
  236. };
  237. /*
  238. ===============================================================================
  239. idFuncEmitter
  240. ===============================================================================
  241. */
  242. class idFuncEmitter : public idStaticEntity {
  243. public:
  244. CLASS_PROTOTYPE( idFuncEmitter );
  245. idFuncEmitter( void );
  246. void Save( idSaveGame *savefile ) const;
  247. void Restore( idRestoreGame *savefile );
  248. void Spawn( void );
  249. void Event_Activate( idEntity *activator );
  250. virtual void WriteToSnapshot( idBitMsgDelta &msg ) const;
  251. virtual void ReadFromSnapshot( const idBitMsgDelta &msg );
  252. private:
  253. bool hidden;
  254. };
  255. /*
  256. ===============================================================================
  257. idFuncSmoke
  258. ===============================================================================
  259. */
  260. class idFuncSmoke : public idEntity {
  261. public:
  262. CLASS_PROTOTYPE( idFuncSmoke );
  263. idFuncSmoke();
  264. void Spawn( void );
  265. void Save( idSaveGame *savefile ) const;
  266. void Restore( idRestoreGame *savefile );
  267. virtual void Think( void );
  268. void Event_Activate( idEntity *activator );
  269. private:
  270. int smokeTime;
  271. const idDeclParticle * smoke;
  272. bool restart;
  273. };
  274. /*
  275. ===============================================================================
  276. idFuncSplat
  277. ===============================================================================
  278. */
  279. class idFuncSplat : public idFuncEmitter {
  280. public:
  281. CLASS_PROTOTYPE( idFuncSplat );
  282. idFuncSplat( void );
  283. void Spawn( void );
  284. private:
  285. void Event_Activate( idEntity *activator );
  286. void Event_Splat();
  287. };
  288. /*
  289. ===============================================================================
  290. idTextEntity
  291. ===============================================================================
  292. */
  293. class idTextEntity : public idEntity {
  294. public:
  295. CLASS_PROTOTYPE( idTextEntity );
  296. void Spawn( void );
  297. void Save( idSaveGame *savefile ) const;
  298. void Restore( idRestoreGame *savefile );
  299. virtual void Think( void );
  300. private:
  301. idStr text;
  302. bool playerOriented;
  303. };
  304. /*
  305. ===============================================================================
  306. idLocationEntity
  307. ===============================================================================
  308. */
  309. class idLocationEntity : public idEntity {
  310. public:
  311. CLASS_PROTOTYPE( idLocationEntity );
  312. void Spawn( void );
  313. const char * GetLocation( void ) const;
  314. private:
  315. };
  316. class idLocationSeparatorEntity : public idEntity {
  317. public:
  318. CLASS_PROTOTYPE( idLocationSeparatorEntity );
  319. void Spawn( void );
  320. private:
  321. };
  322. class idVacuumSeparatorEntity : public idEntity {
  323. public:
  324. CLASS_PROTOTYPE( idVacuumSeparatorEntity );
  325. idVacuumSeparatorEntity( void );
  326. void Spawn( void );
  327. void Save( idSaveGame *savefile ) const;
  328. void Restore( idRestoreGame *savefile );
  329. void Event_Activate( idEntity *activator );
  330. private:
  331. qhandle_t portal;
  332. };
  333. class idVacuumEntity : public idEntity {
  334. public:
  335. CLASS_PROTOTYPE( idVacuumEntity );
  336. void Spawn( void );
  337. private:
  338. };
  339. /*
  340. ===============================================================================
  341. idBeam
  342. ===============================================================================
  343. */
  344. class idBeam : public idEntity {
  345. public:
  346. CLASS_PROTOTYPE( idBeam );
  347. idBeam();
  348. void Spawn( void );
  349. void Save( idSaveGame *savefile ) const;
  350. void Restore( idRestoreGame *savefile );
  351. virtual void Think( void );
  352. void SetMaster( idBeam *masterbeam );
  353. void SetBeamTarget( const idVec3 &origin );
  354. virtual void Show( void );
  355. virtual void WriteToSnapshot( idBitMsgDelta &msg ) const;
  356. virtual void ReadFromSnapshot( const idBitMsgDelta &msg );
  357. private:
  358. void Event_MatchTarget( void );
  359. void Event_Activate( idEntity *activator );
  360. idEntityPtr<idBeam> target;
  361. idEntityPtr<idBeam> master;
  362. };
  363. /*
  364. ===============================================================================
  365. idLiquid
  366. ===============================================================================
  367. */
  368. class idRenderModelLiquid;
  369. class idLiquid : public idEntity {
  370. public:
  371. CLASS_PROTOTYPE( idLiquid );
  372. void Spawn( void );
  373. void Save( idSaveGame *savefile ) const;
  374. void Restore( idRestoreGame *savefile );
  375. private:
  376. void Event_Touch( idEntity *other, trace_t *trace );
  377. idRenderModelLiquid *model;
  378. };
  379. /*
  380. ===============================================================================
  381. idShaking
  382. ===============================================================================
  383. */
  384. class idShaking : public idEntity {
  385. public:
  386. CLASS_PROTOTYPE( idShaking );
  387. idShaking();
  388. void Spawn( void );
  389. void Save( idSaveGame *savefile ) const;
  390. void Restore( idRestoreGame *savefile );
  391. private:
  392. idPhysics_Parametric physicsObj;
  393. bool active;
  394. void BeginShaking( void );
  395. void Event_Activate( idEntity *activator );
  396. };
  397. /*
  398. ===============================================================================
  399. idEarthQuake
  400. ===============================================================================
  401. */
  402. class idEarthQuake : public idEntity {
  403. public:
  404. CLASS_PROTOTYPE( idEarthQuake );
  405. idEarthQuake();
  406. void Spawn( void );
  407. void Save( idSaveGame *savefile ) const;
  408. void Restore( idRestoreGame *savefile );
  409. virtual void Think( void );
  410. private:
  411. int nextTriggerTime;
  412. int shakeStopTime;
  413. float wait;
  414. float random;
  415. bool triggered;
  416. bool playerOriented;
  417. bool disabled;
  418. float shakeTime;
  419. void Event_Activate( idEntity *activator );
  420. };
  421. /*
  422. ===============================================================================
  423. idFuncPortal
  424. ===============================================================================
  425. */
  426. class idFuncPortal : public idEntity {
  427. public:
  428. CLASS_PROTOTYPE( idFuncPortal );
  429. idFuncPortal();
  430. void Spawn( void );
  431. void Save( idSaveGame *savefile ) const;
  432. void Restore( idRestoreGame *savefile );
  433. private:
  434. qhandle_t portal;
  435. bool state;
  436. void Event_Activate( idEntity *activator );
  437. };
  438. /*
  439. ===============================================================================
  440. idFuncAASPortal
  441. ===============================================================================
  442. */
  443. class idFuncAASPortal : public idEntity {
  444. public:
  445. CLASS_PROTOTYPE( idFuncAASPortal );
  446. idFuncAASPortal();
  447. void Spawn( void );
  448. void Save( idSaveGame *savefile ) const;
  449. void Restore( idRestoreGame *savefile );
  450. private:
  451. bool state;
  452. void Event_Activate( idEntity *activator );
  453. };
  454. /*
  455. ===============================================================================
  456. idFuncAASObstacle
  457. ===============================================================================
  458. */
  459. class idFuncAASObstacle : public idEntity {
  460. public:
  461. CLASS_PROTOTYPE( idFuncAASObstacle );
  462. idFuncAASObstacle();
  463. void Spawn( void );
  464. void Save( idSaveGame *savefile ) const;
  465. void Restore( idRestoreGame *savefile );
  466. private:
  467. bool state;
  468. void Event_Activate( idEntity *activator );
  469. };
  470. /*
  471. ===============================================================================
  472. idFuncRadioChatter
  473. ===============================================================================
  474. */
  475. class idFuncRadioChatter : public idEntity {
  476. public:
  477. CLASS_PROTOTYPE( idFuncRadioChatter );
  478. idFuncRadioChatter();
  479. void Spawn( void );
  480. void Save( idSaveGame *savefile ) const;
  481. void Restore( idRestoreGame *savefile );
  482. private:
  483. float time;
  484. void Event_Activate( idEntity *activator );
  485. void Event_ResetRadioHud( idEntity *activator );
  486. };
  487. /*
  488. ===============================================================================
  489. idPhantomObjects
  490. ===============================================================================
  491. */
  492. class idPhantomObjects : public idEntity {
  493. public:
  494. CLASS_PROTOTYPE( idPhantomObjects );
  495. idPhantomObjects();
  496. void Spawn( void );
  497. void Save( idSaveGame *savefile ) const;
  498. void Restore( idRestoreGame *savefile );
  499. virtual void Think( void );
  500. private:
  501. void Event_Activate( idEntity *activator );
  502. void Event_Throw( void );
  503. void Event_ShakeObject( idEntity *object, int starttime );
  504. int end_time;
  505. float throw_time;
  506. float shake_time;
  507. idVec3 shake_ang;
  508. float speed;
  509. int min_wait;
  510. int max_wait;
  511. idEntityPtr<idActor>target;
  512. idList<int> targetTime;
  513. idList<idVec3> lastTargetPos;
  514. };
  515. #ifdef _D3XP
  516. /*
  517. ===============================================================================
  518. idShockwave
  519. ===============================================================================
  520. */
  521. class idShockwave : public idEntity {
  522. public:
  523. CLASS_PROTOTYPE( idShockwave );
  524. idShockwave();
  525. ~idShockwave();
  526. void Spawn( void );
  527. void Think( void );
  528. void Save( idSaveGame *savefile ) const;
  529. void Restore( idRestoreGame *savefile );
  530. private:
  531. void Event_Activate( idEntity *activator );
  532. bool isActive;
  533. int startTime;
  534. int duration;
  535. float startSize;
  536. float endSize;
  537. float currentSize;
  538. float magnitude;
  539. float height;
  540. bool playerDamaged;
  541. float playerDamageSize;
  542. };
  543. /*
  544. ===============================================================================
  545. idFuncMountedObject
  546. ===============================================================================
  547. */
  548. class idFuncMountedObject : public idEntity {
  549. public:
  550. CLASS_PROTOTYPE( idFuncMountedObject );
  551. idFuncMountedObject();
  552. ~idFuncMountedObject();
  553. void Spawn( void );
  554. void Think( void );
  555. void GetAngleRestrictions( int &yaw_min, int &yaw_max, int &pitch );
  556. private:
  557. int harc;
  558. int varc;
  559. void Event_Touch( idEntity *other, trace_t *trace );
  560. void Event_Activate( idEntity *activator );
  561. public:
  562. bool isMounted;
  563. function_t * scriptFunction;
  564. idPlayer * mountedPlayer;
  565. };
  566. class idFuncMountedWeapon : public idFuncMountedObject {
  567. public:
  568. CLASS_PROTOTYPE( idFuncMountedWeapon );
  569. idFuncMountedWeapon();
  570. ~idFuncMountedWeapon();
  571. void Spawn( void );
  572. void Think( void );
  573. private:
  574. // The actual turret that moves with the player's view
  575. idEntity * turret;
  576. // the muzzle bone's position, used for launching projectiles and trailing smoke
  577. idVec3 muzzleOrigin;
  578. idMat3 muzzleAxis;
  579. float weaponLastFireTime;
  580. float weaponFireDelay;
  581. const idDict * projectile;
  582. const idSoundShader *soundFireWeapon;
  583. void Event_PostSpawn( void );
  584. };
  585. /*
  586. ===============================================================================
  587. idPortalSky
  588. ===============================================================================
  589. */
  590. class idPortalSky : public idEntity {
  591. public:
  592. CLASS_PROTOTYPE( idPortalSky );
  593. idPortalSky();
  594. ~idPortalSky();
  595. void Spawn( void );
  596. void Event_PostSpawn();
  597. void Event_Activate( idEntity *activator );
  598. };
  599. #endif /* _D3XP */
  600. #endif /* !__GAME_MISC_H__ */