Misc.h 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898
  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__ */