PageRenderTime 59ms CodeModel.GetById 25ms RepoModel.GetById 0ms app.codeStats 1ms

/mpgame/Misc.h

https://gitlab.com/tanner-deluca/mod-quake-4
C Header | 974 lines | 484 code | 249 blank | 241 comment | 0 complexity | 47caf713b8534acae6cdf23505e5881e MD5 | raw file
  1. #ifndef __GAME_MISC_H__
  2. #define __GAME_MISC_H__
  3. /*
  4. ===============================================================================
  5. idSpawnableEntity
  6. A simple, spawnable entity with a model and no functionable ability of it's own.
  7. For example, it can be used as a placeholder during development, for marking
  8. locations on maps for script, or for simple placed models without any behavior
  9. that can be bound to other entities. Should not be subclassed.
  10. ===============================================================================
  11. */
  12. class idSpawnableEntity : public idEntity {
  13. public:
  14. CLASS_PROTOTYPE( idSpawnableEntity );
  15. void Spawn( void );
  16. private:
  17. };
  18. /*
  19. ===============================================================================
  20. Potential spawning position for players.
  21. The first time a player enters the game, they will be at an 'initial' spot.
  22. Targets will be fired when someone spawns in on them.
  23. When triggered, will cause player to be teleported to spawn spot.
  24. ===============================================================================
  25. */
  26. class idPlayerStart : public idEntity {
  27. public:
  28. CLASS_PROTOTYPE( idPlayerStart );
  29. enum {
  30. EVENT_TELEPORTPLAYER = idEntity::EVENT_MAXEVENTS,
  31. EVENT_TELEPORTITEM,
  32. EVENT_MAXEVENTS
  33. };
  34. idPlayerStart( void );
  35. void Spawn( void );
  36. void Save( idSaveGame *savefile ) const;
  37. void Restore( idRestoreGame *savefile );
  38. virtual bool ClientReceiveEvent( int event, int time, const idBitMsg &msg );
  39. private:
  40. int teleportStage;
  41. void Event_TeleportEntity( idEntity *activator, bool predicted, idVec3& prevOrigin = vec3_origin );
  42. void Event_Teleport( idEntity *activator );
  43. void Teleport( idEntity* other );
  44. void Event_TeleportStage( idPlayer *player );
  45. void Event_ResetCamera( idPlayer *player );
  46. void TeleportPlayer( idPlayer *player );
  47. };
  48. /*
  49. ===============================================================================
  50. Non-displayed entity used to activate triggers when it touches them.
  51. Bind to a mover to have the mover activate a trigger as it moves.
  52. When target by triggers, activating the trigger will toggle the
  53. activator on and off. Check "start_off" to have it spawn disabled.
  54. ===============================================================================
  55. */
  56. class idActivator : public idEntity {
  57. public:
  58. CLASS_PROTOTYPE( idActivator );
  59. void Spawn( void );
  60. void Save( idSaveGame *savefile ) const;
  61. void Restore( idRestoreGame *savefile );
  62. virtual void Think( void );
  63. private:
  64. bool stay_on;
  65. void Event_Activate( idEntity *activator );
  66. };
  67. /*
  68. ===============================================================================
  69. Path entities for monsters to follow.
  70. ===============================================================================
  71. */
  72. class idPathCorner : public idEntity {
  73. public:
  74. CLASS_PROTOTYPE( idPathCorner );
  75. void Spawn( void );
  76. static void DrawDebugInfo( void );
  77. static idPathCorner *RandomPath( const idEntity *source, const idEntity *ignore );
  78. private:
  79. void Event_RandomPath( void );
  80. };
  81. // RAVEN BEGIN
  82. // bdube: jump points
  83. /*
  84. ===============================================================================
  85. Debug Jump Point
  86. ===============================================================================
  87. */
  88. class rvDebugJumpPoint : public idEntity {
  89. public:
  90. CLASS_PROTOTYPE( rvDebugJumpPoint );
  91. void Spawn();
  92. };
  93. /*
  94. ===============================================================================
  95. Object that fires targets and changes shader parms when damaged.
  96. ===============================================================================
  97. */
  98. class idDamagable : public idEntity {
  99. public:
  100. CLASS_PROTOTYPE( idDamagable );
  101. idDamagable( void );
  102. void Save( idSaveGame *savefile ) const;
  103. void Restore( idRestoreGame *savefile );
  104. void Spawn( void );
  105. void Killed( idEntity *inflictor, idEntity *attacker, int damage, const idVec3 &dir, int location );
  106. // RAVEN BEGIN
  107. // abahr:
  108. virtual void Damage( idEntity *inflictor, idEntity *attacker, const idVec3 &dir, const char *damageDefName, const float damageScale, const int location );
  109. int invincibleTime;
  110. // RAVEN BEGIN
  111. // abahr: changed to protected
  112. protected:
  113. int stage;
  114. int stageNext;
  115. const idDict* stageDict;
  116. int stageEndTime;
  117. int stageEndHealth;
  118. int stageEndSpeed;
  119. //jshepard: used to end a stage if a moveable is on the ground (for falling objects)
  120. bool stageEndOnGround;
  121. //jshepard: we want to activate certain objects when triggered-- falling blocks yes, barrels no.
  122. bool activateStageOnTrigger;
  123. virtual void ExecuteStage ( void );
  124. void UpdateStage ( void );
  125. idVec3 GetStageVector ( const char* key, const char* defaultString = "" ) const;
  126. float GetStageFloat ( const char* key, const char* defaultString = "" ) const;
  127. int GetStageInt ( const char* key, const char* defaultString = "" ) const;
  128. // RAVEN END
  129. int count;
  130. int nextTriggerTime;
  131. void BecomeBroken( idEntity *activator );
  132. void Event_BecomeBroken( idEntity *activator );
  133. void Event_RestoreDamagable( void );
  134. };
  135. /*
  136. ===============================================================================
  137. Hidden object that explodes when activated
  138. ===============================================================================
  139. */
  140. class idExplodable : public idEntity {
  141. public:
  142. CLASS_PROTOTYPE( idExplodable );
  143. void Spawn( void );
  144. private:
  145. void Event_Explode( idEntity *activator );
  146. };
  147. /*
  148. ===============================================================================
  149. idSpring
  150. ===============================================================================
  151. */
  152. class idSpring : public idEntity {
  153. public:
  154. CLASS_PROTOTYPE( idSpring );
  155. void Spawn( void );
  156. void Save( idSaveGame *savefile ) const;
  157. void Restore( idRestoreGame *savefile );
  158. virtual void Think( void );
  159. private:
  160. idEntityPtr<idEntity> ent1;
  161. idEntityPtr<idEntity> ent2;
  162. int id1;
  163. int id2;
  164. idVec3 p1;
  165. idVec3 p2;
  166. idForce_Spring spring;
  167. void Event_LinkSpring( void );
  168. };
  169. /*
  170. ===============================================================================
  171. idForceField
  172. ===============================================================================
  173. */
  174. class idForceField : public idEntity {
  175. public:
  176. CLASS_PROTOTYPE( idForceField );
  177. void Save( idSaveGame *savefile ) const;
  178. void Restore( idRestoreGame *savefile );
  179. void Spawn( void );
  180. virtual void Think( void );
  181. // RAVEN BEGIN
  182. // kfuller: idDamagable may want to change some things on the fly
  183. void SetExplosion(float force) { forceField.Explosion(force); }
  184. // RAVEN END
  185. // RAVEN BEGIN
  186. // bdube: made force field protected
  187. protected:
  188. idForce_Field forceField;
  189. private:
  190. // RAVEN END
  191. void Toggle( void );
  192. void Event_Activate( idEntity *activator );
  193. void Event_Toggle( void );
  194. void Event_FindTargets( void );
  195. };
  196. // RAVEN BEGIN
  197. // bdube: jump pads
  198. /*
  199. ===============================================================================
  200. rvJumpPad
  201. ===============================================================================
  202. */
  203. class rvJumpPad : public idForceField {
  204. public:
  205. CLASS_PROTOTYPE( rvJumpPad );
  206. rvJumpPad ( void );
  207. void Spawn( void );
  208. void Think( void );
  209. private:
  210. int lastEffectTime;
  211. void Event_FindTargets( void );
  212. enum {
  213. EVENT_JUMPFX = idEntity::EVENT_MAXEVENTS,
  214. EVENT_MAXEVENTS
  215. };
  216. bool ClientReceiveEvent( int event, int time, const idBitMsg &msg );
  217. idMat3 effectAxis;
  218. };
  219. // RAVEN END
  220. /*
  221. ===============================================================================
  222. idAnimated
  223. ===============================================================================
  224. */
  225. class idAnimated : public idAFEntity_Gibbable {
  226. public:
  227. CLASS_PROTOTYPE( idAnimated );
  228. idAnimated();
  229. ~idAnimated();
  230. void Save( idSaveGame *savefile ) const;
  231. void Restore( idRestoreGame *savefile );
  232. void Spawn( void );
  233. virtual bool LoadAF( const char* keyname );
  234. bool StartRagdoll( void );
  235. virtual bool GetPhysicsToSoundTransform( idVec3 &origin, idMat3 &axis );
  236. // RAVEN BEGIN
  237. // bdube: script
  238. void Think ( void );
  239. virtual void Damage( idEntity *inflictor, idEntity *attacker, const idVec3 &dir, const char *damageDefName, const float damageScale, const int location );
  240. virtual bool ShouldConstructScriptObjectAtSpawn( void ) const;
  241. // RAVEN END
  242. private:
  243. int num_anims;
  244. int current_anim_index;
  245. int anim;
  246. int blendFrames;
  247. jointHandle_t soundJoint;
  248. idEntityPtr<idEntity> activator;
  249. bool activated;
  250. // RAVEN BEGIN
  251. // bdube: script variables
  252. // script control
  253. idThread * scriptThread;
  254. idStr state;
  255. idStr idealState;
  256. int animDoneTime[ANIM_NumAnimChannels];
  257. // Script state management
  258. void UpdateScript( void );
  259. void SetState( const char *statename, int blend );
  260. void CallHandler ( const char* handler );
  261. // RAVEN END
  262. void PlayNextAnim( void );
  263. void Event_Activate( idEntity *activator );
  264. void Event_Start( void );
  265. void Event_StartRagdoll( void );
  266. void Event_AnimDone( int animIndex );
  267. void Event_Footstep( void );
  268. void Event_LaunchMissiles( const char *projectilename, const char *sound, const char *launchjoint, const char *targetjoint, int numshots, int framedelay );
  269. void Event_LaunchMissilesUpdate( int launchjoint, int targetjoint, int numshots, int framedelay );
  270. // RAVEN BEGIN
  271. // kfuller: added
  272. void Event_SetAnimState( const char* state, int blendframes );
  273. void Event_PlayAnim( int channel, const char *animname );
  274. void Event_PlayCycle( int channel, const char *animname );
  275. void Event_AnimDone2( int channel, int blendFrames );
  276. // RAVEN END
  277. };
  278. /*
  279. ===============================================================================
  280. idStaticEntity
  281. ===============================================================================
  282. */
  283. class idStaticEntity : public idEntity {
  284. public:
  285. CLASS_PROTOTYPE( idStaticEntity );
  286. idStaticEntity( void );
  287. void Save( idSaveGame *savefile ) const;
  288. void Restore( idRestoreGame *savefile );
  289. void Spawn( void );
  290. void ShowEditingDialog( void );
  291. virtual void Hide( void );
  292. virtual void Show( void );
  293. void Fade( const idVec4 &to, float fadeTime );
  294. virtual void Think( void );
  295. virtual void WriteToSnapshot( idBitMsgDelta &msg ) const;
  296. virtual void ReadFromSnapshot( const idBitMsgDelta &msg );
  297. private:
  298. void Event_Activate( idEntity *activator );
  299. int spawnTime;
  300. bool active;
  301. idVec4 fadeFrom;
  302. idVec4 fadeTo;
  303. int fadeStart;
  304. int fadeEnd;
  305. bool runGui;
  306. };
  307. /*
  308. ===============================================================================
  309. idFuncEmitter
  310. ===============================================================================
  311. */
  312. class idFuncEmitter : public idStaticEntity {
  313. public:
  314. CLASS_PROTOTYPE( idFuncEmitter );
  315. idFuncEmitter( void );
  316. void Save( idSaveGame *savefile ) const;
  317. void Restore( idRestoreGame *savefile );
  318. void Spawn( void );
  319. void Event_Activate( idEntity *activator );
  320. virtual void WriteToSnapshot( idBitMsgDelta &msg ) const;
  321. virtual void ReadFromSnapshot( const idBitMsgDelta &msg );
  322. private:
  323. bool hidden;
  324. };
  325. // RAVEN BEGIN
  326. // bdube: not using
  327. #if 0
  328. // RAVEN END
  329. /*
  330. ===============================================================================
  331. idFuncSmoke
  332. ===============================================================================
  333. */
  334. class idFuncSmoke : public idEntity {
  335. public:
  336. CLASS_PROTOTYPE( idFuncSmoke );
  337. idFuncSmoke();
  338. void Spawn( void );
  339. void Save( idSaveGame *savefile ) const;
  340. void Restore( idRestoreGame *savefile );
  341. virtual void Think( void );
  342. void Event_Activate( idEntity *activator );
  343. private:
  344. int smokeTime;
  345. const idDeclParticle * smoke;
  346. bool restart;
  347. };
  348. // RAVEN BEGIN
  349. // bdube: not using
  350. #endif
  351. // RAVEN END
  352. /*
  353. ===============================================================================
  354. idFuncSplat
  355. ===============================================================================
  356. */
  357. class idFuncSplat : public idFuncEmitter {
  358. public:
  359. CLASS_PROTOTYPE( idFuncSplat );
  360. idFuncSplat( void );
  361. void Spawn( void );
  362. private:
  363. void Event_Activate( idEntity *activator );
  364. void Event_Splat();
  365. };
  366. /*
  367. ===============================================================================
  368. idTextEntity
  369. ===============================================================================
  370. */
  371. class idTextEntity : public idEntity {
  372. public:
  373. CLASS_PROTOTYPE( idTextEntity );
  374. void Spawn( void );
  375. void Save( idSaveGame *savefile ) const;
  376. void Restore( idRestoreGame *savefile );
  377. virtual void Think( void );
  378. virtual void ClientPredictionThink( void );
  379. private:
  380. idStr text;
  381. bool playerOriented;
  382. };
  383. /*
  384. ===============================================================================
  385. idLocationEntity
  386. ===============================================================================
  387. */
  388. class idLocationEntity : public idEntity {
  389. public:
  390. CLASS_PROTOTYPE( idLocationEntity );
  391. void Spawn( void );
  392. const char * GetLocation( void ) const;
  393. private:
  394. };
  395. class idLocationSeparatorEntity : public idEntity {
  396. public:
  397. CLASS_PROTOTYPE( idLocationSeparatorEntity );
  398. void Spawn( void );
  399. private:
  400. };
  401. class idVacuumSeparatorEntity : public idEntity {
  402. public:
  403. CLASS_PROTOTYPE( idVacuumSeparatorEntity );
  404. idVacuumSeparatorEntity( void );
  405. void Spawn( void );
  406. void Save( idSaveGame *savefile ) const;
  407. void Restore( idRestoreGame *savefile );
  408. void Event_Activate( idEntity *activator );
  409. private:
  410. qhandle_t portal;
  411. };
  412. class idVacuumEntity : public idEntity {
  413. public:
  414. CLASS_PROTOTYPE( idVacuumEntity );
  415. void Spawn( void );
  416. private:
  417. };
  418. // RAVEN BEGIN
  419. // abahr
  420. class rvGravitySeparatorEntity : public idEntity {
  421. public:
  422. CLASS_PROTOTYPE( rvGravitySeparatorEntity );
  423. rvGravitySeparatorEntity( void );
  424. void Spawn( void );
  425. void Save( idSaveGame *savefile ) const;
  426. void Restore( idRestoreGame *savefile );
  427. void Event_Activate( idEntity *activator );
  428. private:
  429. qhandle_t portal;
  430. };
  431. class rvGravityArea : public idEntity {
  432. public:
  433. ABSTRACT_PROTOTYPE( rvGravityArea );
  434. void Spawn( void );
  435. virtual int GetArea() const { return area; }
  436. virtual const idVec3 GetGravity( const idVec3& origin, const idMat3& axis, int clipMask, idEntity* passEntity ) const = 0;
  437. virtual const idVec3 GetGravity( const idEntity* ent ) const = 0;
  438. virtual const idVec3 GetGravity( const rvClientEntity* ent ) const = 0;
  439. void Save( idSaveGame *savefile ) const;
  440. void Restore( idRestoreGame *savefile );
  441. bool IsEqualTo( const rvGravityArea* area ) const;
  442. bool operator==( const rvGravityArea* area ) const;
  443. bool operator==( const rvGravityArea& area ) const;
  444. bool operator!=( const rvGravityArea* area ) const;
  445. bool operator!=( const rvGravityArea& area ) const;
  446. protected:
  447. int area;
  448. };
  449. class rvGravityArea_Static : public rvGravityArea {
  450. public:
  451. CLASS_PROTOTYPE( rvGravityArea_Static );
  452. void Spawn( void );
  453. virtual const idVec3 GetGravity( const idVec3& origin, const idMat3& axis, int clipMask, idEntity* passEntity ) const { return gravity; }
  454. virtual const idVec3 GetGravity( const idEntity* ent ) const { return gravity; }
  455. virtual const idVec3 GetGravity( const rvClientEntity* ent ) const { return gravity; }
  456. void Save( idSaveGame *savefile ) const;
  457. void Restore( idRestoreGame *savefile );
  458. protected:
  459. idVec3 gravity;
  460. };
  461. class rvGravityArea_SurfaceNormal : public rvGravityArea {
  462. public:
  463. CLASS_PROTOTYPE( rvGravityArea_SurfaceNormal );
  464. virtual const idVec3 GetGravity( const idVec3& origin, const idMat3& axis, int clipMask, idEntity* passEntity ) const;
  465. virtual const idVec3 GetGravity( const idEntity* ent ) const;
  466. virtual const idVec3 GetGravity( const rvClientEntity* ent ) const;
  467. protected:
  468. virtual const idVec3 GetGravity( const idPhysics* physics ) const;
  469. };
  470. // RAVEN END
  471. /*
  472. ===============================================================================
  473. idBeam
  474. ===============================================================================
  475. */
  476. class idBeam : public idEntity {
  477. public:
  478. CLASS_PROTOTYPE( idBeam );
  479. idBeam();
  480. void Spawn( void );
  481. void Save( idSaveGame *savefile ) const;
  482. void Restore( idRestoreGame *savefile );
  483. virtual void Think( void );
  484. void SetMaster( idBeam *masterbeam );
  485. void SetBeamTarget( const idVec3 &origin );
  486. virtual void Show( void );
  487. virtual void WriteToSnapshot( idBitMsgDelta &msg ) const;
  488. virtual void ReadFromSnapshot( const idBitMsgDelta &msg );
  489. private:
  490. void Event_MatchTarget( void );
  491. void Event_Activate( idEntity *activator );
  492. idEntityPtr<idBeam> target;
  493. idEntityPtr<idBeam> master;
  494. };
  495. /*
  496. ===============================================================================
  497. idLiquid
  498. ===============================================================================
  499. */
  500. class idRenderModelLiquid;
  501. class idLiquid : public idEntity {
  502. public:
  503. CLASS_PROTOTYPE( idLiquid );
  504. void Spawn( void );
  505. void Save( idSaveGame *savefile ) const;
  506. void Restore( idRestoreGame *savefile );
  507. private:
  508. void Event_Touch( idEntity *other, trace_t *trace );
  509. idRenderModelLiquid *model;
  510. };
  511. /*
  512. ===============================================================================
  513. idShaking
  514. ===============================================================================
  515. */
  516. class idShaking : public idEntity {
  517. public:
  518. CLASS_PROTOTYPE( idShaking );
  519. idShaking();
  520. ~idShaking();
  521. void Spawn( void );
  522. void Save( idSaveGame *savefile ) const;
  523. void Restore( idRestoreGame *savefile );
  524. private:
  525. idPhysics_Parametric physicsObj;
  526. bool active;
  527. void BeginShaking( void );
  528. void Event_Activate( idEntity *activator );
  529. };
  530. /*
  531. ===============================================================================
  532. idEarthQuake
  533. ===============================================================================
  534. */
  535. class idEarthQuake : public idEntity {
  536. public:
  537. CLASS_PROTOTYPE( idEarthQuake );
  538. idEarthQuake();
  539. void Spawn( void );
  540. void Save( idSaveGame *savefile ) const;
  541. void Restore( idRestoreGame *savefile );
  542. virtual void Think( void );
  543. // RAVEN BEGIN
  544. // kfuller: look for fx entities and the like that may want to be triggered when a mortar round (aka earthquake) goes off
  545. protected:
  546. void AffectNearbyEntities(float affectRadius);
  547. // RAVEN END
  548. private:
  549. int nextTriggerTime;
  550. int shakeStopTime;
  551. float wait;
  552. float random;
  553. bool triggered;
  554. bool playerOriented;
  555. bool disabled;
  556. float shakeTime;
  557. void Event_Activate( idEntity *activator );
  558. };
  559. /*
  560. ===============================================================================
  561. idFuncPortal
  562. ===============================================================================
  563. */
  564. class idFuncPortal : public idEntity {
  565. public:
  566. CLASS_PROTOTYPE( idFuncPortal );
  567. idFuncPortal();
  568. void Spawn( void );
  569. void Save( idSaveGame *savefile ) const;
  570. void Restore( idRestoreGame *savefile );
  571. private:
  572. qhandle_t portal;
  573. bool state;
  574. void Event_Activate( idEntity *activator );
  575. };
  576. /*
  577. ===============================================================================
  578. idFuncAASPortal
  579. ===============================================================================
  580. */
  581. class idFuncAASPortal : public idEntity {
  582. public:
  583. CLASS_PROTOTYPE( idFuncAASPortal );
  584. idFuncAASPortal();
  585. void Spawn( void );
  586. void Save( idSaveGame *savefile ) const;
  587. void Restore( idRestoreGame *savefile );
  588. private:
  589. bool state;
  590. void Event_Activate( idEntity *activator );
  591. };
  592. /*
  593. ===============================================================================
  594. idFuncAASObstacle
  595. ===============================================================================
  596. */
  597. class idFuncAASObstacle : public idEntity {
  598. public:
  599. CLASS_PROTOTYPE( idFuncAASObstacle );
  600. idFuncAASObstacle();
  601. void Spawn( void );
  602. void Save( idSaveGame *savefile ) const;
  603. void Restore( idRestoreGame *savefile );
  604. void SetState ( bool _state );
  605. private:
  606. bool state;
  607. void Event_Activate( idEntity *activator );
  608. };
  609. /*
  610. ===============================================================================
  611. idFuncRadioChatter
  612. ===============================================================================
  613. */
  614. class idFuncRadioChatter : public idEntity {
  615. public:
  616. CLASS_PROTOTYPE( idFuncRadioChatter );
  617. idFuncRadioChatter();
  618. void Spawn( void );
  619. void Save( idSaveGame *savefile ) const;
  620. void Restore( idRestoreGame *savefile );
  621. static void RepeatLast ( void );
  622. private:
  623. static idEntityPtr<idFuncRadioChatter> lastRadioChatter;
  624. float time;
  625. bool isActive;
  626. void Event_Activate( idEntity *activator );
  627. void Event_ResetRadioHud( idEntity *activator );
  628. void Event_IsActive( void );
  629. };
  630. /*
  631. ===============================================================================
  632. idPhantomObjects
  633. ===============================================================================
  634. */
  635. class idPhantomObjects : public idEntity {
  636. public:
  637. CLASS_PROTOTYPE( idPhantomObjects );
  638. idPhantomObjects();
  639. void Spawn( void );
  640. void Save( idSaveGame *savefile ) const;
  641. void Restore( idRestoreGame *savefile );
  642. virtual void Think( void );
  643. private:
  644. void Event_Activate( idEntity *activator );
  645. void Event_Throw( void );
  646. void Event_ShakeObject( idEntity *object, int starttime );
  647. int end_time;
  648. float throw_time;
  649. float shake_time;
  650. idVec3 shake_ang;
  651. float speed;
  652. int min_wait;
  653. int max_wait;
  654. idEntityPtr<idActor>target;
  655. idList<int> targetTime;
  656. idList<idVec3> lastTargetPos;
  657. };
  658. /*
  659. ===============================================================================
  660. rvFuncSaveGame
  661. ===============================================================================
  662. */
  663. class rvFuncSaveGame : public idEntity {
  664. public:
  665. CLASS_PROTOTYPE( rvFuncSaveGame );
  666. void Spawn( void );
  667. void Event_Activate ( idEntity *activator );
  668. private:
  669. };
  670. #endif /* !__GAME_MISC_H__ */