]> icculus.org git repositories - icculus/iodoom3.git/blob - neo/d3xp/Misc.h
hello world
[icculus/iodoom3.git] / neo / d3xp / Misc.h
1 /*
2 ===========================================================================
3
4 Doom 3 GPL Source Code
5 Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company. 
6
7 This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).  
8
9 Doom 3 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 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 Source Code.  If not, see <http://www.gnu.org/licenses/>.
21
22 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.
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( void );
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( void );
76
77         void                            Spawn( void );
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( void );
109
110         void                            Save( idSaveGame *savefile ) const;
111         void                            Restore( idRestoreGame *savefile );
112
113         virtual void            Think( void );
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( void );
134
135         static void                     DrawDebugInfo( void );
136
137         static idPathCorner *RandomPath( const idEntity *source, const idEntity *ignore );
138
139 private:
140         void                            Event_RandomPath( void );
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( void );
157
158         void                            Save( idSaveGame *savefile ) const;
159         void                            Restore( idRestoreGame *savefile );
160
161         void                            Spawn( void );
162         void                            Killed( idEntity *inflictor, idEntity *attacker, int damage, const idVec3 &dir, int location );
163
164 #ifdef _D3XP
165         virtual void            Hide( void );
166         virtual void            Show( void );
167 #endif
168
169 private:
170         int                                     count;
171         int                                     nextTriggerTime;
172
173         void                            BecomeBroken( idEntity *activator );
174         void                            Event_BecomeBroken( idEntity *activator );
175         void                            Event_RestoreDamagable( void );
176 };
177
178
179 /*
180 ===============================================================================
181
182   Hidden object that explodes when activated
183
184 ===============================================================================
185 */
186
187 class idExplodable : public idEntity {
188 public:
189         CLASS_PROTOTYPE( idExplodable );
190
191         void                            Spawn( void );
192
193 private:
194         void                            Event_Explode( idEntity *activator );
195 };
196
197
198 /*
199 ===============================================================================
200
201   idSpring
202
203 ===============================================================================
204 */
205
206 class idSpring : public idEntity {
207 public:
208         CLASS_PROTOTYPE( idSpring );
209
210         void                            Spawn( void );
211
212         virtual void            Think( void );
213
214 private:
215         idEntity *                      ent1;
216         idEntity *                      ent2;
217         int                                     id1;
218         int                                     id2;
219         idVec3                          p1;
220         idVec3                          p2;
221         idForce_Spring          spring;
222
223         void                            Event_LinkSpring( void );
224 };
225
226
227 /*
228 ===============================================================================
229
230   idForceField
231
232 ===============================================================================
233 */
234
235 class idForceField : public idEntity {
236 public:
237         CLASS_PROTOTYPE( idForceField );
238
239         void                            Save( idSaveGame *savefile ) const;
240         void                            Restore( idRestoreGame *savefile );
241
242         void                            Spawn( void );
243
244         virtual void            Think( void );
245
246 private:
247         idForce_Field           forceField;
248
249         void                            Toggle( void );
250
251         void                            Event_Activate( idEntity *activator );
252         void                            Event_Toggle( void );
253         void                            Event_FindTargets( void );
254 };
255
256
257 /*
258 ===============================================================================
259
260   idAnimated
261
262 ===============================================================================
263 */
264
265 class idAnimated : public idAFEntity_Gibbable {
266 public:
267         CLASS_PROTOTYPE( idAnimated );
268
269                                                         idAnimated();
270                                                         ~idAnimated();
271
272         void                                    Save( idSaveGame *savefile ) const;
273         void                                    Restore( idRestoreGame *savefile );
274
275         void                                    Spawn( void );
276         virtual bool                    LoadAF( void );
277         bool                                    StartRagdoll( void );
278         virtual bool                    GetPhysicsToSoundTransform( idVec3 &origin, idMat3 &axis );
279
280 private:
281         int                                             num_anims;
282         int                                             current_anim_index;
283         int                                             anim;
284         int                                             blendFrames;
285         jointHandle_t                   soundJoint;
286         idEntityPtr<idEntity>   activator;
287         bool                                    activated;
288
289         void                                    PlayNextAnim( void );
290
291         void                                    Event_Activate( idEntity *activator );  
292         void                                    Event_Start( void );
293         void                                    Event_StartRagdoll( void );
294         void                                    Event_AnimDone( int animIndex );
295         void                                    Event_Footstep( void );
296         void                                    Event_LaunchMissiles( const char *projectilename, const char *sound, const char *launchjoint, const char *targetjoint, int numshots, int framedelay );
297         void                                    Event_LaunchMissilesUpdate( int launchjoint, int targetjoint, int numshots, int framedelay );
298 #ifdef _D3XP
299         void                                    Event_SetAnimation( const char *animName );
300         void                                    Event_GetAnimationLength();
301 #endif
302 };
303
304
305 /*
306 ===============================================================================
307
308   idStaticEntity
309
310 ===============================================================================
311 */
312
313 class idStaticEntity : public idEntity {
314 public:
315         CLASS_PROTOTYPE( idStaticEntity );
316
317                                                 idStaticEntity( void );
318
319         void                            Save( idSaveGame *savefile ) const;
320         void                            Restore( idRestoreGame *savefile );
321
322         void                            Spawn( void );
323         void                            ShowEditingDialog( void );
324         virtual void            Hide( void );
325         virtual void            Show( void );
326         void                            Fade( const idVec4 &to, float fadeTime );
327         virtual void            Think( void );
328
329         virtual void            WriteToSnapshot( idBitMsgDelta &msg ) const;
330         virtual void            ReadFromSnapshot( const idBitMsgDelta &msg );
331
332 private:
333         void                            Event_Activate( idEntity *activator );
334
335         int                                     spawnTime;
336         bool                            active;
337         idVec4                          fadeFrom;
338         idVec4                          fadeTo;
339         int                                     fadeStart;
340         int                                     fadeEnd;
341         bool                            runGui;
342 };
343
344
345 /*
346 ===============================================================================
347
348 idFuncEmitter
349
350 ===============================================================================
351 */
352
353 class idFuncEmitter : public idStaticEntity {
354 public:
355         CLASS_PROTOTYPE( idFuncEmitter );
356
357                                                 idFuncEmitter( void );
358
359         void                            Save( idSaveGame *savefile ) const;
360         void                            Restore( idRestoreGame *savefile );
361
362         void                            Spawn( void );
363         void                            Event_Activate( idEntity *activator );
364
365         virtual void            WriteToSnapshot( idBitMsgDelta &msg ) const;
366         virtual void            ReadFromSnapshot( const idBitMsgDelta &msg );
367
368 private:
369         bool                            hidden;
370
371 };
372
373
374 /*
375 ===============================================================================
376
377 idFuncSmoke
378
379 ===============================================================================
380 */
381
382 class idFuncSmoke : public idEntity {
383 public:
384         CLASS_PROTOTYPE( idFuncSmoke );
385
386                                                         idFuncSmoke();
387
388         void                                    Spawn( void );
389
390         void                                    Save( idSaveGame *savefile ) const;
391         void                                    Restore( idRestoreGame *savefile );
392
393         virtual void                    Think( void );
394         void                                    Event_Activate( idEntity *activator );
395
396 private:
397         int                                             smokeTime;
398         const idDeclParticle *  smoke;
399         bool                                    restart;
400 };
401
402
403 /*
404 ===============================================================================
405
406 idFuncSplat
407
408 ===============================================================================
409 */
410
411 class idFuncSplat : public idFuncEmitter {
412 public:
413         CLASS_PROTOTYPE( idFuncSplat );
414
415         idFuncSplat( void );
416
417         void                            Spawn( void );
418
419 private:
420         void                            Event_Activate( idEntity *activator );
421         void                            Event_Splat();
422 };
423
424
425 /*
426 ===============================================================================
427
428 idTextEntity
429
430 ===============================================================================
431 */
432
433 class idTextEntity : public idEntity {
434 public:
435         CLASS_PROTOTYPE( idTextEntity );
436
437         void                            Spawn( void );
438
439         void                            Save( idSaveGame *savefile ) const;
440         void                            Restore( idRestoreGame *savefile );
441
442         virtual void            Think( void );
443
444 private:
445         idStr                           text;
446         bool                            playerOriented;
447 };
448
449
450 /*
451 ===============================================================================
452
453 idLocationEntity
454
455 ===============================================================================
456 */
457
458 class idLocationEntity : public idEntity {
459 public:
460         CLASS_PROTOTYPE( idLocationEntity );
461
462         void                            Spawn( void );
463
464         const char *            GetLocation( void ) const;
465
466 private:
467 };
468
469 class idLocationSeparatorEntity : public idEntity {
470 public:
471         CLASS_PROTOTYPE( idLocationSeparatorEntity );
472
473         void                            Spawn( void );
474
475 private:
476 };
477
478 class idVacuumSeparatorEntity : public idEntity {
479 public:
480         CLASS_PROTOTYPE( idVacuumSeparatorEntity );
481
482                                                 idVacuumSeparatorEntity( void );
483
484         void                            Spawn( void );
485
486         void                            Save( idSaveGame *savefile ) const;
487         void                            Restore( idRestoreGame *savefile );
488
489         void                            Event_Activate( idEntity *activator );  
490
491 private:
492         qhandle_t                       portal;
493 };
494
495 class idVacuumEntity : public idEntity {
496 public:
497         CLASS_PROTOTYPE( idVacuumEntity );
498
499         void                            Spawn( void );
500
501 private:
502 };
503
504
505 /*
506 ===============================================================================
507
508   idBeam
509
510 ===============================================================================
511 */
512
513 class idBeam : public idEntity {
514 public:
515         CLASS_PROTOTYPE( idBeam );
516
517                                                 idBeam();
518
519         void                            Spawn( void );
520
521         void                            Save( idSaveGame *savefile ) const;
522         void                            Restore( idRestoreGame *savefile );
523
524         virtual void            Think( void );
525
526         void                            SetMaster( idBeam *masterbeam );
527         void                            SetBeamTarget( const idVec3 &origin );
528
529         virtual void            Show( void );
530
531         virtual void            WriteToSnapshot( idBitMsgDelta &msg ) const;
532         virtual void            ReadFromSnapshot( const idBitMsgDelta &msg );
533
534 private:
535         void                            Event_MatchTarget( void );
536         void                            Event_Activate( idEntity *activator );
537
538         idEntityPtr<idBeam>     target;
539         idEntityPtr<idBeam>     master;
540 };
541
542
543 /*
544 ===============================================================================
545
546   idLiquid
547
548 ===============================================================================
549 */
550
551 class idRenderModelLiquid;
552
553 class idLiquid : public idEntity {
554 public:
555         CLASS_PROTOTYPE( idLiquid );
556
557         void                            Spawn( void );
558
559         void                            Save( idSaveGame *savefile ) const;
560         void                            Restore( idRestoreGame *savefile );
561
562 private:
563         void                            Event_Touch( idEntity *other, trace_t *trace );
564
565
566         idRenderModelLiquid *model;
567 };
568
569
570 /*
571 ===============================================================================
572
573   idShaking
574
575 ===============================================================================
576 */
577
578 class idShaking : public idEntity {
579 public:
580         CLASS_PROTOTYPE( idShaking );
581
582                                                         idShaking();
583
584         void                                    Spawn( void );
585
586         void                                    Save( idSaveGame *savefile ) const;
587         void                                    Restore( idRestoreGame *savefile );
588
589 private:
590         idPhysics_Parametric    physicsObj;
591         bool                                    active;
592
593         void                                    BeginShaking( void );
594         void                                    Event_Activate( idEntity *activator );
595 };
596
597
598 /*
599 ===============================================================================
600
601   idEarthQuake
602
603 ===============================================================================
604 */
605
606 class idEarthQuake : public idEntity {
607 public:
608         CLASS_PROTOTYPE( idEarthQuake );
609                         
610                                                 idEarthQuake();
611
612         void                            Spawn( void );
613
614         void                            Save( idSaveGame *savefile ) const;
615         void                            Restore( idRestoreGame *savefile );
616
617         virtual void            Think( void );
618
619 private:
620         int                                     nextTriggerTime;
621         int                                     shakeStopTime;
622         float                           wait;
623         float                           random;
624         bool                            triggered;
625         bool                            playerOriented;
626         bool                            disabled;
627         float                           shakeTime;
628
629         void                            Event_Activate( idEntity *activator );
630 };
631
632
633 /*
634 ===============================================================================
635
636   idFuncPortal
637
638 ===============================================================================
639 */
640
641 class idFuncPortal : public idEntity {
642 public:
643         CLASS_PROTOTYPE( idFuncPortal );
644                         
645                                                 idFuncPortal();
646
647         void                            Spawn( void );
648
649         void                            Save( idSaveGame *savefile ) const;
650         void                            Restore( idRestoreGame *savefile );
651
652 private:
653         qhandle_t                       portal;
654         bool                            state;
655
656         void                            Event_Activate( idEntity *activator );
657 };
658
659 /*
660 ===============================================================================
661
662   idFuncAASPortal
663
664 ===============================================================================
665 */
666
667 class idFuncAASPortal : public idEntity {
668 public:
669         CLASS_PROTOTYPE( idFuncAASPortal );
670                         
671                                                 idFuncAASPortal();
672
673         void                            Spawn( void );
674
675         void                            Save( idSaveGame *savefile ) const;
676         void                            Restore( idRestoreGame *savefile );
677
678 private:
679         bool                            state;
680
681         void                            Event_Activate( idEntity *activator );
682 };
683
684 /*
685 ===============================================================================
686
687   idFuncAASObstacle
688
689 ===============================================================================
690 */
691
692 class idFuncAASObstacle : public idEntity {
693 public:
694         CLASS_PROTOTYPE( idFuncAASObstacle );
695                         
696                                                 idFuncAASObstacle();
697
698         void                            Spawn( void );
699
700         void                            Save( idSaveGame *savefile ) const;
701         void                            Restore( idRestoreGame *savefile );
702
703 private:
704         bool                            state;
705
706         void                            Event_Activate( idEntity *activator );
707 };
708
709
710 /*
711 ===============================================================================
712
713 idFuncRadioChatter
714
715 ===============================================================================
716 */
717
718 class idFuncRadioChatter : public idEntity {
719 public:
720         CLASS_PROTOTYPE( idFuncRadioChatter );
721
722                                                 idFuncRadioChatter();
723
724         void                            Spawn( void );
725
726         void                            Save( idSaveGame *savefile ) const;
727         void                            Restore( idRestoreGame *savefile );
728
729 private:
730         float                           time;
731         void                            Event_Activate( idEntity *activator );
732         void                            Event_ResetRadioHud( idEntity *activator );
733 };
734
735
736 /*
737 ===============================================================================
738
739   idPhantomObjects
740
741 ===============================================================================
742 */
743
744 class idPhantomObjects : public idEntity {
745 public:
746         CLASS_PROTOTYPE( idPhantomObjects );
747                         
748                                                 idPhantomObjects();
749
750         void                            Spawn( void );
751
752         void                            Save( idSaveGame *savefile ) const;
753         void                            Restore( idRestoreGame *savefile );
754
755         virtual void            Think( void );
756
757 private:
758         void                            Event_Activate( idEntity *activator );
759         void                            Event_Throw( void );
760         void                            Event_ShakeObject( idEntity *object, int starttime );
761
762         int                                     end_time;
763         float                           throw_time;
764         float                           shake_time;
765         idVec3                          shake_ang;
766         float                           speed;
767         int                                     min_wait;
768         int                                     max_wait;
769         idEntityPtr<idActor>target;
770         idList<int>                     targetTime;
771         idList<idVec3>          lastTargetPos;
772 };
773
774 #ifdef _D3XP
775 /*
776 ===============================================================================
777
778 idShockwave
779
780 ===============================================================================
781 */
782 class idShockwave : public idEntity {
783 public:
784         CLASS_PROTOTYPE( idShockwave );
785
786         idShockwave();
787         ~idShockwave();
788
789         void                            Spawn( void );
790         void                            Think( void );
791
792         void                            Save( idSaveGame *savefile ) const;
793         void                            Restore( idRestoreGame *savefile );
794
795 private:
796         void                            Event_Activate( idEntity *activator );
797
798         bool                            isActive;
799         int                                     startTime;
800         int                                     duration;
801
802         float                           startSize;
803         float                           endSize;
804         float                           currentSize;
805
806         float                           magnitude;
807
808         float                           height;
809         bool                            playerDamaged;
810         float                           playerDamageSize;
811
812 };
813
814 /*
815 ===============================================================================
816
817 idFuncMountedObject
818
819 ===============================================================================
820 */
821 class idFuncMountedObject : public idEntity {
822 public:
823         CLASS_PROTOTYPE( idFuncMountedObject );
824
825         idFuncMountedObject();
826         ~idFuncMountedObject();
827
828         void                            Spawn( void );
829         void                            Think( void );
830
831         void                            GetAngleRestrictions( int &yaw_min, int &yaw_max, int &pitch );
832
833 private:
834         int                                     harc;
835         int                                     varc;
836
837         void                            Event_Touch( idEntity *other, trace_t *trace ); 
838         void                            Event_Activate( idEntity *activator );
839
840 public:
841         bool                            isMounted;
842         function_t      *               scriptFunction;
843         idPlayer *                      mountedPlayer;
844 };
845
846
847 class idFuncMountedWeapon : public idFuncMountedObject {
848 public:
849         CLASS_PROTOTYPE( idFuncMountedWeapon );
850
851         idFuncMountedWeapon();
852         ~idFuncMountedWeapon();
853
854         void                            Spawn( void );
855         void                            Think( void );
856
857 private:
858
859         // The actual turret that moves with the player's view
860         idEntity        *               turret;
861
862         // the muzzle bone's position, used for launching projectiles and trailing smoke
863         idVec3                          muzzleOrigin;
864         idMat3                          muzzleAxis;
865
866         float                           weaponLastFireTime;
867         float                           weaponFireDelay;
868
869         const idDict *          projectile;
870
871         const idSoundShader     *soundFireWeapon;
872
873         void                            Event_PostSpawn( void );
874 };
875
876 /*
877 ===============================================================================
878
879 idPortalSky
880
881 ===============================================================================
882 */
883 class idPortalSky : public idEntity {
884 public:
885         CLASS_PROTOTYPE( idPortalSky );
886
887         idPortalSky();
888         ~idPortalSky();
889
890         void                            Spawn( void );
891         void                            Event_PostSpawn();
892         void                            Event_Activate( idEntity *activator );
893 };
894
895 #endif /* _D3XP */
896
897 #endif /* !__GAME_MISC_H__ */