]> icculus.org git repositories - icculus/iodoom3.git/blob - neo/game/Misc.h
hello world
[icculus/iodoom3.git] / neo / game / 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 private:
165         int                                     count;
166         int                                     nextTriggerTime;
167
168         void                            BecomeBroken( idEntity *activator );
169         void                            Event_BecomeBroken( idEntity *activator );
170         void                            Event_RestoreDamagable( void );
171 };
172
173
174 /*
175 ===============================================================================
176
177   Hidden object that explodes when activated
178
179 ===============================================================================
180 */
181
182 class idExplodable : public idEntity {
183 public:
184         CLASS_PROTOTYPE( idExplodable );
185
186         void                            Spawn( void );
187
188 private:
189         void                            Event_Explode( idEntity *activator );
190 };
191
192
193 /*
194 ===============================================================================
195
196   idSpring
197
198 ===============================================================================
199 */
200
201 class idSpring : public idEntity {
202 public:
203         CLASS_PROTOTYPE( idSpring );
204
205         void                            Spawn( void );
206
207         virtual void            Think( void );
208
209 private:
210         idEntity *                      ent1;
211         idEntity *                      ent2;
212         int                                     id1;
213         int                                     id2;
214         idVec3                          p1;
215         idVec3                          p2;
216         idForce_Spring          spring;
217
218         void                            Event_LinkSpring( void );
219 };
220
221
222 /*
223 ===============================================================================
224
225   idForceField
226
227 ===============================================================================
228 */
229
230 class idForceField : public idEntity {
231 public:
232         CLASS_PROTOTYPE( idForceField );
233
234         void                            Save( idSaveGame *savefile ) const;
235         void                            Restore( idRestoreGame *savefile );
236
237         void                            Spawn( void );
238
239         virtual void            Think( void );
240
241 private:
242         idForce_Field           forceField;
243
244         void                            Toggle( void );
245
246         void                            Event_Activate( idEntity *activator );
247         void                            Event_Toggle( void );
248         void                            Event_FindTargets( void );
249 };
250
251
252 /*
253 ===============================================================================
254
255   idAnimated
256
257 ===============================================================================
258 */
259
260 class idAnimated : public idAFEntity_Gibbable {
261 public:
262         CLASS_PROTOTYPE( idAnimated );
263
264                                                         idAnimated();
265                                                         ~idAnimated();
266
267         void                                    Save( idSaveGame *savefile ) const;
268         void                                    Restore( idRestoreGame *savefile );
269
270         void                                    Spawn( void );
271         virtual bool                    LoadAF( void );
272         bool                                    StartRagdoll( void );
273         virtual bool                    GetPhysicsToSoundTransform( idVec3 &origin, idMat3 &axis );
274
275 private:
276         int                                             num_anims;
277         int                                             current_anim_index;
278         int                                             anim;
279         int                                             blendFrames;
280         jointHandle_t                   soundJoint;
281         idEntityPtr<idEntity>   activator;
282         bool                                    activated;
283
284         void                                    PlayNextAnim( void );
285
286         void                                    Event_Activate( idEntity *activator );  
287         void                                    Event_Start( void );
288         void                                    Event_StartRagdoll( void );
289         void                                    Event_AnimDone( int animIndex );
290         void                                    Event_Footstep( void );
291         void                                    Event_LaunchMissiles( const char *projectilename, const char *sound, const char *launchjoint, const char *targetjoint, int numshots, int framedelay );
292         void                                    Event_LaunchMissilesUpdate( int launchjoint, int targetjoint, int numshots, int framedelay );
293 };
294
295
296 /*
297 ===============================================================================
298
299   idStaticEntity
300
301 ===============================================================================
302 */
303
304 class idStaticEntity : public idEntity {
305 public:
306         CLASS_PROTOTYPE( idStaticEntity );
307
308                                                 idStaticEntity( void );
309
310         void                            Save( idSaveGame *savefile ) const;
311         void                            Restore( idRestoreGame *savefile );
312
313         void                            Spawn( void );
314         void                            ShowEditingDialog( void );
315         virtual void            Hide( void );
316         virtual void            Show( void );
317         void                            Fade( const idVec4 &to, float fadeTime );
318         virtual void            Think( void );
319
320         virtual void            WriteToSnapshot( idBitMsgDelta &msg ) const;
321         virtual void            ReadFromSnapshot( const idBitMsgDelta &msg );
322
323 private:
324         void                            Event_Activate( idEntity *activator );
325
326         int                                     spawnTime;
327         bool                            active;
328         idVec4                          fadeFrom;
329         idVec4                          fadeTo;
330         int                                     fadeStart;
331         int                                     fadeEnd;
332         bool                            runGui;
333 };
334
335
336 /*
337 ===============================================================================
338
339 idFuncEmitter
340
341 ===============================================================================
342 */
343
344 class idFuncEmitter : public idStaticEntity {
345 public:
346         CLASS_PROTOTYPE( idFuncEmitter );
347
348                                                 idFuncEmitter( void );
349
350         void                            Save( idSaveGame *savefile ) const;
351         void                            Restore( idRestoreGame *savefile );
352
353         void                            Spawn( void );
354         void                            Event_Activate( idEntity *activator );
355
356         virtual void            WriteToSnapshot( idBitMsgDelta &msg ) const;
357         virtual void            ReadFromSnapshot( const idBitMsgDelta &msg );
358
359 private:
360         bool                            hidden;
361
362 };
363
364
365 /*
366 ===============================================================================
367
368 idFuncSmoke
369
370 ===============================================================================
371 */
372
373 class idFuncSmoke : public idEntity {
374 public:
375         CLASS_PROTOTYPE( idFuncSmoke );
376
377                                                         idFuncSmoke();
378
379         void                                    Spawn( void );
380
381         void                                    Save( idSaveGame *savefile ) const;
382         void                                    Restore( idRestoreGame *savefile );
383
384         virtual void                    Think( void );
385         void                                    Event_Activate( idEntity *activator );
386
387 private:
388         int                                             smokeTime;
389         const idDeclParticle *  smoke;
390         bool                                    restart;
391 };
392
393
394 /*
395 ===============================================================================
396
397 idFuncSplat
398
399 ===============================================================================
400 */
401
402 class idFuncSplat : public idFuncEmitter {
403 public:
404         CLASS_PROTOTYPE( idFuncSplat );
405
406         idFuncSplat( void );
407
408         void                            Spawn( void );
409
410 private:
411         void                            Event_Activate( idEntity *activator );
412         void                            Event_Splat();
413 };
414
415
416 /*
417 ===============================================================================
418
419 idTextEntity
420
421 ===============================================================================
422 */
423
424 class idTextEntity : public idEntity {
425 public:
426         CLASS_PROTOTYPE( idTextEntity );
427
428         void                            Spawn( void );
429
430         void                            Save( idSaveGame *savefile ) const;
431         void                            Restore( idRestoreGame *savefile );
432
433         virtual void            Think( void );
434
435 private:
436         idStr                           text;
437         bool                            playerOriented;
438 };
439
440
441 /*
442 ===============================================================================
443
444 idLocationEntity
445
446 ===============================================================================
447 */
448
449 class idLocationEntity : public idEntity {
450 public:
451         CLASS_PROTOTYPE( idLocationEntity );
452
453         void                            Spawn( void );
454
455         const char *            GetLocation( void ) const;
456
457 private:
458 };
459
460 class idLocationSeparatorEntity : public idEntity {
461 public:
462         CLASS_PROTOTYPE( idLocationSeparatorEntity );
463
464         void                            Spawn( void );
465
466 private:
467 };
468
469 class idVacuumSeparatorEntity : public idEntity {
470 public:
471         CLASS_PROTOTYPE( idVacuumSeparatorEntity );
472
473                                                 idVacuumSeparatorEntity( void );
474
475         void                            Spawn( void );
476
477         void                            Save( idSaveGame *savefile ) const;
478         void                            Restore( idRestoreGame *savefile );
479
480         void                            Event_Activate( idEntity *activator );  
481
482 private:
483         qhandle_t                       portal;
484 };
485
486 class idVacuumEntity : public idEntity {
487 public:
488         CLASS_PROTOTYPE( idVacuumEntity );
489
490         void                            Spawn( void );
491
492 private:
493 };
494
495
496 /*
497 ===============================================================================
498
499   idBeam
500
501 ===============================================================================
502 */
503
504 class idBeam : public idEntity {
505 public:
506         CLASS_PROTOTYPE( idBeam );
507
508                                                 idBeam();
509
510         void                            Spawn( void );
511
512         void                            Save( idSaveGame *savefile ) const;
513         void                            Restore( idRestoreGame *savefile );
514
515         virtual void            Think( void );
516
517         void                            SetMaster( idBeam *masterbeam );
518         void                            SetBeamTarget( const idVec3 &origin );
519
520         virtual void            Show( void );
521
522         virtual void            WriteToSnapshot( idBitMsgDelta &msg ) const;
523         virtual void            ReadFromSnapshot( const idBitMsgDelta &msg );
524
525 private:
526         void                            Event_MatchTarget( void );
527         void                            Event_Activate( idEntity *activator );
528
529         idEntityPtr<idBeam>     target;
530         idEntityPtr<idBeam>     master;
531 };
532
533
534 /*
535 ===============================================================================
536
537   idLiquid
538
539 ===============================================================================
540 */
541
542 class idRenderModelLiquid;
543
544 class idLiquid : public idEntity {
545 public:
546         CLASS_PROTOTYPE( idLiquid );
547
548         void                            Spawn( void );
549
550         void                            Save( idSaveGame *savefile ) const;
551         void                            Restore( idRestoreGame *savefile );
552
553 private:
554         void                            Event_Touch( idEntity *other, trace_t *trace );
555
556
557         idRenderModelLiquid *model;
558 };
559
560
561 /*
562 ===============================================================================
563
564   idShaking
565
566 ===============================================================================
567 */
568
569 class idShaking : public idEntity {
570 public:
571         CLASS_PROTOTYPE( idShaking );
572
573                                                         idShaking();
574
575         void                                    Spawn( void );
576
577         void                                    Save( idSaveGame *savefile ) const;
578         void                                    Restore( idRestoreGame *savefile );
579
580 private:
581         idPhysics_Parametric    physicsObj;
582         bool                                    active;
583
584         void                                    BeginShaking( void );
585         void                                    Event_Activate( idEntity *activator );
586 };
587
588
589 /*
590 ===============================================================================
591
592   idEarthQuake
593
594 ===============================================================================
595 */
596
597 class idEarthQuake : public idEntity {
598 public:
599         CLASS_PROTOTYPE( idEarthQuake );
600                         
601                                                 idEarthQuake();
602
603         void                            Spawn( void );
604
605         void                            Save( idSaveGame *savefile ) const;
606         void                            Restore( idRestoreGame *savefile );
607
608         virtual void            Think( void );
609
610 private:
611         int                                     nextTriggerTime;
612         int                                     shakeStopTime;
613         float                           wait;
614         float                           random;
615         bool                            triggered;
616         bool                            playerOriented;
617         bool                            disabled;
618         float                           shakeTime;
619
620         void                            Event_Activate( idEntity *activator );
621 };
622
623
624 /*
625 ===============================================================================
626
627   idFuncPortal
628
629 ===============================================================================
630 */
631
632 class idFuncPortal : public idEntity {
633 public:
634         CLASS_PROTOTYPE( idFuncPortal );
635                         
636                                                 idFuncPortal();
637
638         void                            Spawn( void );
639
640         void                            Save( idSaveGame *savefile ) const;
641         void                            Restore( idRestoreGame *savefile );
642
643 private:
644         qhandle_t                       portal;
645         bool                            state;
646
647         void                            Event_Activate( idEntity *activator );
648 };
649
650 /*
651 ===============================================================================
652
653   idFuncAASPortal
654
655 ===============================================================================
656 */
657
658 class idFuncAASPortal : public idEntity {
659 public:
660         CLASS_PROTOTYPE( idFuncAASPortal );
661                         
662                                                 idFuncAASPortal();
663
664         void                            Spawn( void );
665
666         void                            Save( idSaveGame *savefile ) const;
667         void                            Restore( idRestoreGame *savefile );
668
669 private:
670         bool                            state;
671
672         void                            Event_Activate( idEntity *activator );
673 };
674
675 /*
676 ===============================================================================
677
678   idFuncAASObstacle
679
680 ===============================================================================
681 */
682
683 class idFuncAASObstacle : public idEntity {
684 public:
685         CLASS_PROTOTYPE( idFuncAASObstacle );
686                         
687                                                 idFuncAASObstacle();
688
689         void                            Spawn( void );
690
691         void                            Save( idSaveGame *savefile ) const;
692         void                            Restore( idRestoreGame *savefile );
693
694 private:
695         bool                            state;
696
697         void                            Event_Activate( idEntity *activator );
698 };
699
700
701 /*
702 ===============================================================================
703
704 idFuncRadioChatter
705
706 ===============================================================================
707 */
708
709 class idFuncRadioChatter : public idEntity {
710 public:
711         CLASS_PROTOTYPE( idFuncRadioChatter );
712
713                                                 idFuncRadioChatter();
714
715         void                            Spawn( void );
716
717         void                            Save( idSaveGame *savefile ) const;
718         void                            Restore( idRestoreGame *savefile );
719
720 private:
721         float                           time;
722         void                            Event_Activate( idEntity *activator );
723         void                            Event_ResetRadioHud( idEntity *activator );
724 };
725
726
727 /*
728 ===============================================================================
729
730   idPhantomObjects
731
732 ===============================================================================
733 */
734
735 class idPhantomObjects : public idEntity {
736 public:
737         CLASS_PROTOTYPE( idPhantomObjects );
738                         
739                                                 idPhantomObjects();
740
741         void                            Spawn( void );
742
743         void                            Save( idSaveGame *savefile ) const;
744         void                            Restore( idRestoreGame *savefile );
745
746         virtual void            Think( void );
747
748 private:
749         void                            Event_Activate( idEntity *activator );
750         void                            Event_Throw( void );
751         void                            Event_ShakeObject( idEntity *object, int starttime );
752
753         int                                     end_time;
754         float                           throw_time;
755         float                           shake_time;
756         idVec3                          shake_ang;
757         float                           speed;
758         int                                     min_wait;
759         int                                     max_wait;
760         idEntityPtr<idActor>target;
761         idList<int>                     targetTime;
762         idList<idVec3>          lastTargetPos;
763 };
764
765 #endif /* !__GAME_MISC_H__ */