Misc.h (20394B)
1 /* 2 =========================================================================== 3 4 Doom 3 BFG Edition GPL Source Code 5 Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. 6 7 This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). 8 9 Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify 10 it under the terms of the GNU General Public License as published by 11 the Free Software Foundation, either version 3 of the License, or 12 (at your option) any later version. 13 14 Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful, 15 but WITHOUT ANY WARRANTY; without even the implied warranty of 16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 GNU General Public License for more details. 18 19 You should have received a copy of the GNU General Public License 20 along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>. 21 22 In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below. 23 24 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. 25 26 =========================================================================== 27 */ 28 29 #ifndef __GAME_MISC_H__ 30 #define __GAME_MISC_H__ 31 32 33 /* 34 =============================================================================== 35 36 idSpawnableEntity 37 38 A simple, spawnable entity with a model and no functionable ability of it's own. 39 For example, it can be used as a placeholder during development, for marking 40 locations on maps for script, or for simple placed models without any behavior 41 that can be bound to other entities. Should not be subclassed. 42 =============================================================================== 43 */ 44 45 class idSpawnableEntity : public idEntity { 46 public: 47 CLASS_PROTOTYPE( idSpawnableEntity ); 48 49 void Spawn(); 50 51 private: 52 }; 53 54 /* 55 =============================================================================== 56 57 Potential spawning position for players. 58 The first time a player enters the game, they will be at an 'initial' spot. 59 Targets will be fired when someone spawns in on them. 60 61 When triggered, will cause player to be teleported to spawn spot. 62 63 =============================================================================== 64 */ 65 66 class idPlayerStart : public idEntity { 67 public: 68 CLASS_PROTOTYPE( idPlayerStart ); 69 70 enum { 71 EVENT_TELEPORTPLAYER = idEntity::EVENT_MAXEVENTS, 72 EVENT_MAXEVENTS 73 }; 74 75 idPlayerStart(); 76 77 void Spawn(); 78 79 void Save( idSaveGame *savefile ) const; 80 void Restore( idRestoreGame *savefile ); 81 82 virtual bool ClientReceiveEvent( int event, int time, const idBitMsg &msg ); 83 84 private: 85 int teleportStage; 86 87 void Event_TeleportPlayer( idEntity *activator ); 88 void Event_TeleportStage( idEntity *player ); 89 void TeleportPlayer( idPlayer *player ); 90 }; 91 92 93 /* 94 =============================================================================== 95 96 Non-displayed entity used to activate triggers when it touches them. 97 Bind to a mover to have the mover activate a trigger as it moves. 98 When target by triggers, activating the trigger will toggle the 99 activator on and off. Check "start_off" to have it spawn disabled. 100 101 =============================================================================== 102 */ 103 104 class idActivator : public idEntity { 105 public: 106 CLASS_PROTOTYPE( idActivator ); 107 108 void Spawn(); 109 110 void Save( idSaveGame *savefile ) const; 111 void Restore( idRestoreGame *savefile ); 112 113 virtual void Think(); 114 115 private: 116 bool stay_on; 117 118 void Event_Activate( idEntity *activator ); 119 }; 120 121 122 /* 123 =============================================================================== 124 125 Path entities for monsters to follow. 126 127 =============================================================================== 128 */ 129 class idPathCorner : public idEntity { 130 public: 131 CLASS_PROTOTYPE( idPathCorner ); 132 133 void Spawn(); 134 135 static void DrawDebugInfo(); 136 137 static idPathCorner *RandomPath( const idEntity *source, const idEntity *ignore ); 138 139 private: 140 void Event_RandomPath(); 141 }; 142 143 144 /* 145 =============================================================================== 146 147 Object that fires targets and changes shader parms when damaged. 148 149 =============================================================================== 150 */ 151 152 class idDamagable : public idEntity { 153 public: 154 CLASS_PROTOTYPE( idDamagable ); 155 156 idDamagable(); 157 158 void Save( idSaveGame *savefile ) const; 159 void Restore( idRestoreGame *savefile ); 160 161 void Spawn(); 162 void Killed( idEntity *inflictor, idEntity *attacker, int damage, const idVec3 &dir, int location ); 163 164 virtual void Hide(); 165 virtual void Show(); 166 167 private: 168 int count; 169 int nextTriggerTime; 170 171 void BecomeBroken( idEntity *activator ); 172 void Event_BecomeBroken( idEntity *activator ); 173 void Event_RestoreDamagable(); 174 }; 175 176 177 /* 178 =============================================================================== 179 180 Hidden object that explodes when activated 181 182 =============================================================================== 183 */ 184 185 class idExplodable : public idEntity { 186 public: 187 CLASS_PROTOTYPE( idExplodable ); 188 189 void Spawn(); 190 191 private: 192 void Event_Explode( idEntity *activator ); 193 }; 194 195 196 /* 197 =============================================================================== 198 199 idSpring 200 201 =============================================================================== 202 */ 203 204 class idSpring : public idEntity { 205 public: 206 CLASS_PROTOTYPE( idSpring ); 207 208 void Spawn(); 209 210 virtual void Think(); 211 212 private: 213 idEntity * ent1; 214 idEntity * ent2; 215 int id1; 216 int id2; 217 idVec3 p1; 218 idVec3 p2; 219 idForce_Spring spring; 220 221 void Event_LinkSpring(); 222 }; 223 224 225 /* 226 =============================================================================== 227 228 idForceField 229 230 =============================================================================== 231 */ 232 233 class idForceField : public idEntity { 234 public: 235 CLASS_PROTOTYPE( idForceField ); 236 237 void Save( idSaveGame *savefile ) const; 238 void Restore( idRestoreGame *savefile ); 239 240 void Spawn(); 241 242 virtual void Think(); 243 virtual void ClientThink( const int curTime, const float fraction, const bool predict ) ; 244 private: 245 idForce_Field forceField; 246 247 void Toggle(); 248 249 void Event_Activate( idEntity *activator ); 250 void Event_Toggle(); 251 void Event_FindTargets(); 252 }; 253 254 255 /* 256 =============================================================================== 257 258 idAnimated 259 260 =============================================================================== 261 */ 262 263 class idAnimated : public idAFEntity_Gibbable { 264 public: 265 CLASS_PROTOTYPE( idAnimated ); 266 267 idAnimated(); 268 ~idAnimated(); 269 270 void Save( idSaveGame *savefile ) const; 271 void Restore( idRestoreGame *savefile ); 272 273 void Spawn(); 274 virtual bool LoadAF(); 275 bool StartRagdoll(); 276 virtual bool GetPhysicsToSoundTransform( idVec3 &origin, idMat3 &axis ); 277 278 private: 279 int num_anims; 280 int current_anim_index; 281 int anim; 282 int blendFrames; 283 jointHandle_t soundJoint; 284 idEntityPtr<idEntity> activator; 285 bool activated; 286 int achievement; 287 288 void PlayNextAnim(); 289 290 void Event_Activate( idEntity *activator ); 291 void Event_Start(); 292 void Event_StartRagdoll(); 293 void Event_AnimDone( int animIndex ); 294 void Event_Footstep(); 295 void Event_LaunchMissiles( const char *projectilename, const char *sound, const char *launchjoint, const char *targetjoint, int numshots, int framedelay ); 296 void Event_LaunchMissilesUpdate( int launchjoint, int targetjoint, int numshots, int framedelay ); 297 void Event_SetAnimation( const char *animName ); 298 void Event_GetAnimationLength(); 299 }; 300 301 302 /* 303 =============================================================================== 304 305 idStaticEntity 306 307 =============================================================================== 308 */ 309 310 class idStaticEntity : public idEntity { 311 public: 312 CLASS_PROTOTYPE( idStaticEntity ); 313 314 idStaticEntity(); 315 316 void Save( idSaveGame *savefile ) const; 317 void Restore( idRestoreGame *savefile ); 318 319 void Spawn(); 320 void ShowEditingDialog(); 321 virtual void Hide(); 322 virtual void Show(); 323 void Fade( const idVec4 &to, float fadeTime ); 324 virtual void Think(); 325 326 virtual void WriteToSnapshot( idBitMsg &msg ) const; 327 virtual void ReadFromSnapshot( const idBitMsg &msg ); 328 329 private: 330 void Event_Activate( idEntity *activator ); 331 332 int spawnTime; 333 bool active; 334 idVec4 fadeFrom; 335 idVec4 fadeTo; 336 int fadeStart; 337 int fadeEnd; 338 bool runGui; 339 }; 340 341 342 /* 343 =============================================================================== 344 345 idFuncEmitter 346 347 =============================================================================== 348 */ 349 350 class idFuncEmitter : public idStaticEntity { 351 public: 352 CLASS_PROTOTYPE( idFuncEmitter ); 353 354 idFuncEmitter(); 355 356 void Save( idSaveGame *savefile ) const; 357 void Restore( idRestoreGame *savefile ); 358 359 void Spawn(); 360 void Event_Activate( idEntity *activator ); 361 362 virtual void WriteToSnapshot( idBitMsg &msg ) const; 363 virtual void ReadFromSnapshot( const idBitMsg &msg ); 364 365 private: 366 bool hidden; 367 368 }; 369 370 371 /* 372 =============================================================================== 373 374 idFuncShootProjectile 375 376 =============================================================================== 377 */ 378 379 class idFuncShootProjectile : public idStaticEntity { 380 public: 381 CLASS_PROTOTYPE( idFuncShootProjectile ); 382 383 idFuncShootProjectile(); 384 385 void Save( idSaveGame *savefile ) const; 386 void Restore( idRestoreGame *savefile ); 387 388 void Spawn(); 389 void Event_Activate( idEntity *activator ); 390 391 virtual void Think(); 392 393 virtual void WriteToSnapshot( idBitMsg &msg ) const; 394 virtual void ReadFromSnapshot( const idBitMsg &msg ); 395 396 private: 397 int mRespawnDelay; 398 int mRespawnTime; 399 float mShootSpeed; 400 idVec3 mShootDir; 401 idStr mEntityDefName; 402 idEntityPtr< idEntity > mLastProjectile; 403 404 }; 405 406 407 /* 408 =============================================================================== 409 410 idFuncSmoke 411 412 =============================================================================== 413 */ 414 415 class idFuncSmoke : public idEntity { 416 public: 417 CLASS_PROTOTYPE( idFuncSmoke ); 418 419 idFuncSmoke(); 420 421 void Spawn(); 422 423 void Save( idSaveGame *savefile ) const; 424 void Restore( idRestoreGame *savefile ); 425 426 virtual void Think(); 427 void Event_Activate( idEntity *activator ); 428 429 private: 430 int smokeTime; 431 const idDeclParticle * smoke; 432 bool restart; 433 }; 434 435 436 /* 437 =============================================================================== 438 439 idFuncSplat 440 441 =============================================================================== 442 */ 443 444 class idFuncSplat : public idFuncEmitter { 445 public: 446 CLASS_PROTOTYPE( idFuncSplat ); 447 448 idFuncSplat(); 449 450 void Spawn(); 451 452 private: 453 void Event_Activate( idEntity *activator ); 454 void Event_Splat(); 455 }; 456 457 458 /* 459 =============================================================================== 460 461 idTextEntity 462 463 =============================================================================== 464 */ 465 466 class idTextEntity : public idEntity { 467 public: 468 CLASS_PROTOTYPE( idTextEntity ); 469 470 void Spawn(); 471 472 void Save( idSaveGame *savefile ) const; 473 void Restore( idRestoreGame *savefile ); 474 475 virtual void Think(); 476 477 private: 478 idStr text; 479 bool playerOriented; 480 }; 481 482 483 /* 484 =============================================================================== 485 486 idLocationEntity 487 488 =============================================================================== 489 */ 490 491 class idLocationEntity : public idEntity { 492 public: 493 CLASS_PROTOTYPE( idLocationEntity ); 494 495 void Spawn(); 496 497 const char * GetLocation() const; 498 499 private: 500 }; 501 502 class idLocationSeparatorEntity : public idEntity { 503 public: 504 CLASS_PROTOTYPE( idLocationSeparatorEntity ); 505 506 void Spawn(); 507 508 private: 509 }; 510 511 class idVacuumSeparatorEntity : public idEntity { 512 public: 513 CLASS_PROTOTYPE( idVacuumSeparatorEntity ); 514 515 idVacuumSeparatorEntity(); 516 517 void Spawn(); 518 519 void Save( idSaveGame *savefile ) const; 520 void Restore( idRestoreGame *savefile ); 521 522 void Event_Activate( idEntity *activator ); 523 524 private: 525 qhandle_t portal; 526 }; 527 528 class idVacuumEntity : public idEntity { 529 public: 530 CLASS_PROTOTYPE( idVacuumEntity ); 531 532 void Spawn(); 533 534 private: 535 }; 536 537 538 /* 539 =============================================================================== 540 541 idBeam 542 543 =============================================================================== 544 */ 545 546 class idBeam : public idEntity { 547 public: 548 CLASS_PROTOTYPE( idBeam ); 549 550 idBeam(); 551 552 void Spawn(); 553 554 void Save( idSaveGame *savefile ) const; 555 void Restore( idRestoreGame *savefile ); 556 557 virtual void Think(); 558 559 void SetMaster( idBeam *masterbeam ); 560 void SetBeamTarget( const idVec3 &origin ); 561 562 virtual void Show(); 563 564 virtual void WriteToSnapshot( idBitMsg &msg ) const; 565 virtual void ReadFromSnapshot( const idBitMsg &msg ); 566 567 private: 568 void Event_MatchTarget(); 569 void Event_Activate( idEntity *activator ); 570 571 idEntityPtr<idBeam> target; 572 idEntityPtr<idBeam> master; 573 }; 574 575 576 /* 577 =============================================================================== 578 579 idLiquid 580 581 =============================================================================== 582 */ 583 584 class idRenderModelLiquid; 585 586 class idLiquid : public idEntity { 587 public: 588 CLASS_PROTOTYPE( idLiquid ); 589 590 void Spawn(); 591 592 void Save( idSaveGame *savefile ) const; 593 void Restore( idRestoreGame *savefile ); 594 595 private: 596 void Event_Touch( idEntity *other, trace_t *trace ); 597 598 599 idRenderModelLiquid *model; 600 }; 601 602 603 /* 604 =============================================================================== 605 606 idShaking 607 608 =============================================================================== 609 */ 610 611 class idShaking : public idEntity { 612 public: 613 CLASS_PROTOTYPE( idShaking ); 614 615 idShaking(); 616 617 void Spawn(); 618 619 void Save( idSaveGame *savefile ) const; 620 void Restore( idRestoreGame *savefile ); 621 622 private: 623 idPhysics_Parametric physicsObj; 624 bool active; 625 626 void BeginShaking(); 627 void Event_Activate( idEntity *activator ); 628 }; 629 630 631 /* 632 =============================================================================== 633 634 idEarthQuake 635 636 =============================================================================== 637 */ 638 639 class idEarthQuake : public idEntity { 640 public: 641 CLASS_PROTOTYPE( idEarthQuake ); 642 643 idEarthQuake(); 644 645 void Spawn(); 646 647 void Save( idSaveGame *savefile ) const; 648 void Restore( idRestoreGame *savefile ); 649 650 virtual void Think(); 651 652 private: 653 int nextTriggerTime; 654 int shakeStopTime; 655 float wait; 656 float random; 657 bool triggered; 658 bool playerOriented; 659 bool disabled; 660 float shakeTime; 661 662 void Event_Activate( idEntity *activator ); 663 }; 664 665 666 /* 667 =============================================================================== 668 669 idFuncPortal 670 671 =============================================================================== 672 */ 673 674 class idFuncPortal : public idEntity { 675 public: 676 CLASS_PROTOTYPE( idFuncPortal ); 677 678 idFuncPortal(); 679 680 void Spawn(); 681 682 void Save( idSaveGame *savefile ) const; 683 void Restore( idRestoreGame *savefile ); 684 685 private: 686 qhandle_t portal; 687 bool state; 688 689 void Event_Activate( idEntity *activator ); 690 }; 691 692 /* 693 =============================================================================== 694 695 idFuncAASPortal 696 697 =============================================================================== 698 */ 699 700 class idFuncAASPortal : public idEntity { 701 public: 702 CLASS_PROTOTYPE( idFuncAASPortal ); 703 704 idFuncAASPortal(); 705 706 void Spawn(); 707 708 void Save( idSaveGame *savefile ) const; 709 void Restore( idRestoreGame *savefile ); 710 711 private: 712 bool state; 713 714 void Event_Activate( idEntity *activator ); 715 }; 716 717 /* 718 =============================================================================== 719 720 idFuncAASObstacle 721 722 =============================================================================== 723 */ 724 725 class idFuncAASObstacle : public idEntity { 726 public: 727 CLASS_PROTOTYPE( idFuncAASObstacle ); 728 729 idFuncAASObstacle(); 730 731 void Spawn(); 732 733 void Save( idSaveGame *savefile ) const; 734 void Restore( idRestoreGame *savefile ); 735 736 private: 737 bool state; 738 739 void Event_Activate( idEntity *activator ); 740 }; 741 742 743 /* 744 =============================================================================== 745 746 idFuncRadioChatter 747 748 =============================================================================== 749 */ 750 751 class idFuncRadioChatter : public idEntity { 752 public: 753 CLASS_PROTOTYPE( idFuncRadioChatter ); 754 755 idFuncRadioChatter(); 756 757 void Spawn(); 758 759 void Save( idSaveGame *savefile ) const; 760 void Restore( idRestoreGame *savefile ); 761 762 private: 763 float time; 764 void Event_Activate( idEntity *activator ); 765 void Event_ResetRadioHud( idEntity *activator ); 766 }; 767 768 769 /* 770 =============================================================================== 771 772 idPhantomObjects 773 774 =============================================================================== 775 */ 776 777 class idPhantomObjects : public idEntity { 778 public: 779 CLASS_PROTOTYPE( idPhantomObjects ); 780 781 idPhantomObjects(); 782 783 void Spawn(); 784 785 void Save( idSaveGame *savefile ) const; 786 void Restore( idRestoreGame *savefile ); 787 788 virtual void Think(); 789 790 private: 791 void Event_Activate( idEntity *activator ); 792 void Event_Throw(); 793 void Event_ShakeObject( idEntity *object, int starttime ); 794 795 int end_time; 796 float throw_time; 797 float shake_time; 798 idVec3 shake_ang; 799 float speed; 800 int min_wait; 801 int max_wait; 802 idEntityPtr<idActor>target; 803 idList<int> targetTime; 804 idList<idVec3> lastTargetPos; 805 }; 806 807 /* 808 =============================================================================== 809 810 idShockwave 811 812 =============================================================================== 813 */ 814 class idShockwave : public idEntity { 815 public: 816 CLASS_PROTOTYPE( idShockwave ); 817 818 idShockwave(); 819 ~idShockwave(); 820 821 void Spawn(); 822 void Think(); 823 824 void Save( idSaveGame *savefile ) const; 825 void Restore( idRestoreGame *savefile ); 826 827 private: 828 void Event_Activate( idEntity *activator ); 829 830 bool isActive; 831 int startTime; 832 int duration; 833 834 float startSize; 835 float endSize; 836 float currentSize; 837 838 float magnitude; 839 840 float height; 841 bool playerDamaged; 842 float playerDamageSize; 843 844 }; 845 846 /* 847 =============================================================================== 848 849 idFuncMountedObject 850 851 =============================================================================== 852 */ 853 class idFuncMountedObject : public idEntity { 854 public: 855 CLASS_PROTOTYPE( idFuncMountedObject ); 856 857 idFuncMountedObject(); 858 ~idFuncMountedObject(); 859 860 void Spawn(); 861 void Think(); 862 863 void GetAngleRestrictions( int &yaw_min, int &yaw_max, int &pitch ); 864 865 private: 866 int harc; 867 int varc; 868 869 void Event_Touch( idEntity *other, trace_t *trace ); 870 void Event_Activate( idEntity *activator ); 871 872 public: 873 bool isMounted; 874 function_t * scriptFunction; 875 idPlayer * mountedPlayer; 876 }; 877 878 879 class idFuncMountedWeapon : public idFuncMountedObject { 880 public: 881 CLASS_PROTOTYPE( idFuncMountedWeapon ); 882 883 idFuncMountedWeapon(); 884 ~idFuncMountedWeapon(); 885 886 void Spawn(); 887 void Think(); 888 889 private: 890 891 // The actual turret that moves with the player's view 892 idEntity * turret; 893 894 // the muzzle bone's position, used for launching projectiles and trailing smoke 895 idVec3 muzzleOrigin; 896 idMat3 muzzleAxis; 897 898 float weaponLastFireTime; 899 float weaponFireDelay; 900 901 const idDict * projectile; 902 903 const idSoundShader *soundFireWeapon; 904 905 void Event_PostSpawn(); 906 }; 907 908 /* 909 =============================================================================== 910 911 idPortalSky 912 913 =============================================================================== 914 */ 915 class idPortalSky : public idEntity { 916 public: 917 CLASS_PROTOTYPE( idPortalSky ); 918 919 idPortalSky(); 920 ~idPortalSky(); 921 922 void Spawn(); 923 void Event_PostSpawn(); 924 void Event_Activate( idEntity *activator ); 925 }; 926 927 928 #endif /* !__GAME_MISC_H__ */