PageRenderTime 48ms CodeModel.GetById 23ms RepoModel.GetById 0ms app.codeStats 0ms

/neo/game/Misc.h

https://bitbucket.org/peanut64/iodoom3-copy-original
C++ Header | 765 lines | 358 code | 201 blank | 206 comment | 0 complexity | 460b18b3d8194380e8a7ab348c18ad74 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. private:
  110. int count;
  111. int nextTriggerTime;
  112. void BecomeBroken( idEntity *activator );
  113. void Event_BecomeBroken( idEntity *activator );
  114. void Event_RestoreDamagable( void );
  115. };
  116. /*
  117. ===============================================================================
  118. Hidden object that explodes when activated
  119. ===============================================================================
  120. */
  121. class idExplodable : public idEntity {
  122. public:
  123. CLASS_PROTOTYPE( idExplodable );
  124. void Spawn( void );
  125. private:
  126. void Event_Explode( idEntity *activator );
  127. };
  128. /*
  129. ===============================================================================
  130. idSpring
  131. ===============================================================================
  132. */
  133. class idSpring : public idEntity {
  134. public:
  135. CLASS_PROTOTYPE( idSpring );
  136. void Spawn( void );
  137. virtual void Think( void );
  138. private:
  139. idEntity * ent1;
  140. idEntity * ent2;
  141. int id1;
  142. int id2;
  143. idVec3 p1;
  144. idVec3 p2;
  145. idForce_Spring spring;
  146. void Event_LinkSpring( void );
  147. };
  148. /*
  149. ===============================================================================
  150. idForceField
  151. ===============================================================================
  152. */
  153. class idForceField : public idEntity {
  154. public:
  155. CLASS_PROTOTYPE( idForceField );
  156. void Save( idSaveGame *savefile ) const;
  157. void Restore( idRestoreGame *savefile );
  158. void Spawn( void );
  159. virtual void Think( void );
  160. private:
  161. idForce_Field forceField;
  162. void Toggle( void );
  163. void Event_Activate( idEntity *activator );
  164. void Event_Toggle( void );
  165. void Event_FindTargets( void );
  166. };
  167. /*
  168. ===============================================================================
  169. idAnimated
  170. ===============================================================================
  171. */
  172. class idAnimated : public idAFEntity_Gibbable {
  173. public:
  174. CLASS_PROTOTYPE( idAnimated );
  175. idAnimated();
  176. ~idAnimated();
  177. void Save( idSaveGame *savefile ) const;
  178. void Restore( idRestoreGame *savefile );
  179. void Spawn( void );
  180. virtual bool LoadAF( void );
  181. bool StartRagdoll( void );
  182. virtual bool GetPhysicsToSoundTransform( idVec3 &origin, idMat3 &axis );
  183. private:
  184. int num_anims;
  185. int current_anim_index;
  186. int anim;
  187. int blendFrames;
  188. jointHandle_t soundJoint;
  189. idEntityPtr<idEntity> activator;
  190. bool activated;
  191. void PlayNextAnim( void );
  192. void Event_Activate( idEntity *activator );
  193. void Event_Start( void );
  194. void Event_StartRagdoll( void );
  195. void Event_AnimDone( int animIndex );
  196. void Event_Footstep( void );
  197. void Event_LaunchMissiles( const char *projectilename, const char *sound, const char *launchjoint, const char *targetjoint, int numshots, int framedelay );
  198. void Event_LaunchMissilesUpdate( int launchjoint, int targetjoint, int numshots, int framedelay );
  199. };
  200. /*
  201. ===============================================================================
  202. idStaticEntity
  203. ===============================================================================
  204. */
  205. class idStaticEntity : public idEntity {
  206. public:
  207. CLASS_PROTOTYPE( idStaticEntity );
  208. idStaticEntity( void );
  209. void Save( idSaveGame *savefile ) const;
  210. void Restore( idRestoreGame *savefile );
  211. void Spawn( void );
  212. void ShowEditingDialog( void );
  213. virtual void Hide( void );
  214. virtual void Show( void );
  215. void Fade( const idVec4 &to, float fadeTime );
  216. virtual void Think( void );
  217. virtual void WriteToSnapshot( idBitMsgDelta &msg ) const;
  218. virtual void ReadFromSnapshot( const idBitMsgDelta &msg );
  219. private:
  220. void Event_Activate( idEntity *activator );
  221. int spawnTime;
  222. bool active;
  223. idVec4 fadeFrom;
  224. idVec4 fadeTo;
  225. int fadeStart;
  226. int fadeEnd;
  227. bool runGui;
  228. };
  229. /*
  230. ===============================================================================
  231. idFuncEmitter
  232. ===============================================================================
  233. */
  234. class idFuncEmitter : public idStaticEntity {
  235. public:
  236. CLASS_PROTOTYPE( idFuncEmitter );
  237. idFuncEmitter( void );
  238. void Save( idSaveGame *savefile ) const;
  239. void Restore( idRestoreGame *savefile );
  240. void Spawn( void );
  241. void Event_Activate( idEntity *activator );
  242. virtual void WriteToSnapshot( idBitMsgDelta &msg ) const;
  243. virtual void ReadFromSnapshot( const idBitMsgDelta &msg );
  244. private:
  245. bool hidden;
  246. };
  247. /*
  248. ===============================================================================
  249. idFuncSmoke
  250. ===============================================================================
  251. */
  252. class idFuncSmoke : public idEntity {
  253. public:
  254. CLASS_PROTOTYPE( idFuncSmoke );
  255. idFuncSmoke();
  256. void Spawn( void );
  257. void Save( idSaveGame *savefile ) const;
  258. void Restore( idRestoreGame *savefile );
  259. virtual void Think( void );
  260. void Event_Activate( idEntity *activator );
  261. private:
  262. int smokeTime;
  263. const idDeclParticle * smoke;
  264. bool restart;
  265. };
  266. /*
  267. ===============================================================================
  268. idFuncSplat
  269. ===============================================================================
  270. */
  271. class idFuncSplat : public idFuncEmitter {
  272. public:
  273. CLASS_PROTOTYPE( idFuncSplat );
  274. idFuncSplat( void );
  275. void Spawn( void );
  276. private:
  277. void Event_Activate( idEntity *activator );
  278. void Event_Splat();
  279. };
  280. /*
  281. ===============================================================================
  282. idTextEntity
  283. ===============================================================================
  284. */
  285. class idTextEntity : public idEntity {
  286. public:
  287. CLASS_PROTOTYPE( idTextEntity );
  288. void Spawn( void );
  289. void Save( idSaveGame *savefile ) const;
  290. void Restore( idRestoreGame *savefile );
  291. virtual void Think( void );
  292. private:
  293. idStr text;
  294. bool playerOriented;
  295. };
  296. /*
  297. ===============================================================================
  298. idLocationEntity
  299. ===============================================================================
  300. */
  301. class idLocationEntity : public idEntity {
  302. public:
  303. CLASS_PROTOTYPE( idLocationEntity );
  304. void Spawn( void );
  305. const char * GetLocation( void ) const;
  306. private:
  307. };
  308. class idLocationSeparatorEntity : public idEntity {
  309. public:
  310. CLASS_PROTOTYPE( idLocationSeparatorEntity );
  311. void Spawn( void );
  312. private:
  313. };
  314. class idVacuumSeparatorEntity : public idEntity {
  315. public:
  316. CLASS_PROTOTYPE( idVacuumSeparatorEntity );
  317. idVacuumSeparatorEntity( void );
  318. void Spawn( void );
  319. void Save( idSaveGame *savefile ) const;
  320. void Restore( idRestoreGame *savefile );
  321. void Event_Activate( idEntity *activator );
  322. private:
  323. qhandle_t portal;
  324. };
  325. class idVacuumEntity : public idEntity {
  326. public:
  327. CLASS_PROTOTYPE( idVacuumEntity );
  328. void Spawn( void );
  329. private:
  330. };
  331. /*
  332. ===============================================================================
  333. idBeam
  334. ===============================================================================
  335. */
  336. class idBeam : public idEntity {
  337. public:
  338. CLASS_PROTOTYPE( idBeam );
  339. idBeam();
  340. void Spawn( void );
  341. void Save( idSaveGame *savefile ) const;
  342. void Restore( idRestoreGame *savefile );
  343. virtual void Think( void );
  344. void SetMaster( idBeam *masterbeam );
  345. void SetBeamTarget( const idVec3 &origin );
  346. virtual void Show( void );
  347. virtual void WriteToSnapshot( idBitMsgDelta &msg ) const;
  348. virtual void ReadFromSnapshot( const idBitMsgDelta &msg );
  349. private:
  350. void Event_MatchTarget( void );
  351. void Event_Activate( idEntity *activator );
  352. idEntityPtr<idBeam> target;
  353. idEntityPtr<idBeam> master;
  354. };
  355. /*
  356. ===============================================================================
  357. idLiquid
  358. ===============================================================================
  359. */
  360. class idRenderModelLiquid;
  361. class idLiquid : public idEntity {
  362. public:
  363. CLASS_PROTOTYPE( idLiquid );
  364. void Spawn( void );
  365. void Save( idSaveGame *savefile ) const;
  366. void Restore( idRestoreGame *savefile );
  367. private:
  368. void Event_Touch( idEntity *other, trace_t *trace );
  369. idRenderModelLiquid *model;
  370. };
  371. /*
  372. ===============================================================================
  373. idShaking
  374. ===============================================================================
  375. */
  376. class idShaking : public idEntity {
  377. public:
  378. CLASS_PROTOTYPE( idShaking );
  379. idShaking();
  380. void Spawn( void );
  381. void Save( idSaveGame *savefile ) const;
  382. void Restore( idRestoreGame *savefile );
  383. private:
  384. idPhysics_Parametric physicsObj;
  385. bool active;
  386. void BeginShaking( void );
  387. void Event_Activate( idEntity *activator );
  388. };
  389. /*
  390. ===============================================================================
  391. idEarthQuake
  392. ===============================================================================
  393. */
  394. class idEarthQuake : public idEntity {
  395. public:
  396. CLASS_PROTOTYPE( idEarthQuake );
  397. idEarthQuake();
  398. void Spawn( void );
  399. void Save( idSaveGame *savefile ) const;
  400. void Restore( idRestoreGame *savefile );
  401. virtual void Think( void );
  402. private:
  403. int nextTriggerTime;
  404. int shakeStopTime;
  405. float wait;
  406. float random;
  407. bool triggered;
  408. bool playerOriented;
  409. bool disabled;
  410. float shakeTime;
  411. void Event_Activate( idEntity *activator );
  412. };
  413. /*
  414. ===============================================================================
  415. idFuncPortal
  416. ===============================================================================
  417. */
  418. class idFuncPortal : public idEntity {
  419. public:
  420. CLASS_PROTOTYPE( idFuncPortal );
  421. idFuncPortal();
  422. void Spawn( void );
  423. void Save( idSaveGame *savefile ) const;
  424. void Restore( idRestoreGame *savefile );
  425. private:
  426. qhandle_t portal;
  427. bool state;
  428. void Event_Activate( idEntity *activator );
  429. };
  430. /*
  431. ===============================================================================
  432. idFuncAASPortal
  433. ===============================================================================
  434. */
  435. class idFuncAASPortal : public idEntity {
  436. public:
  437. CLASS_PROTOTYPE( idFuncAASPortal );
  438. idFuncAASPortal();
  439. void Spawn( void );
  440. void Save( idSaveGame *savefile ) const;
  441. void Restore( idRestoreGame *savefile );
  442. private:
  443. bool state;
  444. void Event_Activate( idEntity *activator );
  445. };
  446. /*
  447. ===============================================================================
  448. idFuncAASObstacle
  449. ===============================================================================
  450. */
  451. class idFuncAASObstacle : public idEntity {
  452. public:
  453. CLASS_PROTOTYPE( idFuncAASObstacle );
  454. idFuncAASObstacle();
  455. void Spawn( void );
  456. void Save( idSaveGame *savefile ) const;
  457. void Restore( idRestoreGame *savefile );
  458. private:
  459. bool state;
  460. void Event_Activate( idEntity *activator );
  461. };
  462. /*
  463. ===============================================================================
  464. idFuncRadioChatter
  465. ===============================================================================
  466. */
  467. class idFuncRadioChatter : public idEntity {
  468. public:
  469. CLASS_PROTOTYPE( idFuncRadioChatter );
  470. idFuncRadioChatter();
  471. void Spawn( void );
  472. void Save( idSaveGame *savefile ) const;
  473. void Restore( idRestoreGame *savefile );
  474. private:
  475. float time;
  476. void Event_Activate( idEntity *activator );
  477. void Event_ResetRadioHud( idEntity *activator );
  478. };
  479. /*
  480. ===============================================================================
  481. idPhantomObjects
  482. ===============================================================================
  483. */
  484. class idPhantomObjects : public idEntity {
  485. public:
  486. CLASS_PROTOTYPE( idPhantomObjects );
  487. idPhantomObjects();
  488. void Spawn( void );
  489. void Save( idSaveGame *savefile ) const;
  490. void Restore( idRestoreGame *savefile );
  491. virtual void Think( void );
  492. private:
  493. void Event_Activate( idEntity *activator );
  494. void Event_Throw( void );
  495. void Event_ShakeObject( idEntity *object, int starttime );
  496. int end_time;
  497. float throw_time;
  498. float shake_time;
  499. idVec3 shake_ang;
  500. float speed;
  501. int min_wait;
  502. int max_wait;
  503. idEntityPtr<idActor>target;
  504. idList<int> targetTime;
  505. idList<idVec3> lastTargetPos;
  506. };
  507. #endif /* !__GAME_MISC_H__ */