doom3-gpl
Doom 3 GPL source release
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Trigger.h
Go to the documentation of this file.
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_TRIGGER_H__
30 #define __GAME_TRIGGER_H__
31 
32 extern const idEventDef EV_Enable;
33 extern const idEventDef EV_Disable;
34 
35 /*
36 ===============================================================================
37 
38  Trigger base.
39 
40 ===============================================================================
41 */
42 
43 class idTrigger : public idEntity {
44 public:
46 
47  static void DrawDebugInfo( void );
48 
49  idTrigger();
50  void Spawn( void );
51 
52  const function_t * GetScriptFunction( void ) const;
53 
54  void Save( idSaveGame *savefile ) const;
55  void Restore( idRestoreGame *savefile );
56 
57  virtual void Enable( void );
58  virtual void Disable( void );
59 
60 protected:
61  void CallScript( void ) const;
62 
63  void Event_Enable( void );
64  void Event_Disable( void );
65 
67 };
68 
69 
70 /*
71 ===============================================================================
72 
73  Trigger which can be activated multiple times.
74 
75 ===============================================================================
76 */
77 
78 class idTrigger_Multi : public idTrigger {
79 public:
81 
82  idTrigger_Multi( void );
83 
84  void Spawn( void );
85 
86  void Save( idSaveGame *savefile ) const;
87  void Restore( idRestoreGame *savefile );
88 
89 #ifdef CTF
90 protected:
91 #else
92 private:
93 #endif
94 
95  float wait;
96  float random;
97  float delay;
98  float random_delay;
106 
107  bool CheckFacing( idEntity *activator );
108  void TriggerAction( idEntity *activator );
109  void Event_TriggerAction( idEntity *activator );
110  void Event_Trigger( idEntity *activator );
111  void Event_Touch( idEntity *other, trace_t *trace );
112 };
113 
114 
115 /*
116 ===============================================================================
117 
118  Trigger which can only be activated by an entity with a specific name.
119 
120 ===============================================================================
121 */
122 
124 public:
126 
127  idTrigger_EntityName( void );
128 
129  void Save( idSaveGame *savefile ) const;
130  void Restore( idRestoreGame *savefile );
131 
132  void Spawn( void );
133 
134 private:
135  float wait;
136  float random;
137  float delay;
142 
143  void TriggerAction( idEntity *activator );
144  void Event_TriggerAction( idEntity *activator );
145  void Event_Trigger( idEntity *activator );
146  void Event_Touch( idEntity *other, trace_t *trace );
147 };
148 
149 /*
150 ===============================================================================
151 
152  Trigger which repeatedly fires targets.
153 
154 ===============================================================================
155 */
156 
157 class idTrigger_Timer : public idTrigger {
158 public:
160 
161  idTrigger_Timer( void );
162 
163  void Save( idSaveGame *savefile ) const;
164  void Restore( idRestoreGame *savefile );
165 
166  void Spawn( void );
167 
168  virtual void Enable( void );
169  virtual void Disable( void );
170 
171 private:
172  float random;
173  float wait;
174  bool on;
175  float delay;
178 
179  void Event_Timer( void );
180  void Event_Use( idEntity *activator );
181 };
182 
183 
184 /*
185 ===============================================================================
186 
187  Trigger which fires targets after being activated a specific number of times.
188 
189 ===============================================================================
190 */
191 
192 class idTrigger_Count : public idTrigger {
193 public:
195 
196  idTrigger_Count( void );
197 
198  void Save( idSaveGame *savefile ) const;
199  void Restore( idRestoreGame *savefile );
200 
201  void Spawn( void );
202 
203 private:
204  int goal;
205  int count;
206  float delay;
207 
208  void Event_Trigger( idEntity *activator );
209  void Event_TriggerAction( idEntity *activator );
210 };
211 
212 
213 /*
214 ===============================================================================
215 
216  Trigger which hurts touching entities.
217 
218 ===============================================================================
219 */
220 
221 class idTrigger_Hurt : public idTrigger {
222 public:
224 
225  idTrigger_Hurt( void );
226 
227  void Save( idSaveGame *savefile ) const;
228  void Restore( idRestoreGame *savefile );
229 
230  void Spawn( void );
231 
232 private:
233  bool on;
234  float delay;
235  int nextTime;
236 
237  void Event_Touch( idEntity *other, trace_t *trace );
238  void Event_Toggle( idEntity *activator );
239 };
240 
241 
242 /*
243 ===============================================================================
244 
245  Trigger which fades the player view.
246 
247 ===============================================================================
248 */
249 
250 class idTrigger_Fade : public idTrigger {
251 public:
252 
254 
255 private:
256  void Event_Trigger( idEntity *activator );
257 };
258 
259 
260 /*
261 ===============================================================================
262 
263  Trigger which continuously tests whether other entities are touching it.
264 
265 ===============================================================================
266 */
267 
268 class idTrigger_Touch : public idTrigger {
269 public:
270 
272 
273  idTrigger_Touch( void );
274 
275  void Spawn( void );
276  virtual void Think( void );
277 
278  void Save( idSaveGame *savefile );
279  void Restore( idRestoreGame *savefile );
280 
281  virtual void Enable( void );
282  virtual void Disable( void );
283 
284  void TouchEntities( void );
285 
286 private:
288 
289  void Event_Trigger( idEntity *activator );
290 };
291 
292 #ifdef CTF
293 /*
294 ===============================================================================
295 
296  Trigger that responces to CTF flags
297 
298 ===============================================================================
299 */
300 class idTrigger_Flag : public idTrigger_Multi {
301 public:
302  CLASS_PROTOTYPE( idTrigger_Flag );
303 
304  idTrigger_Flag( void );
305  void Spawn( void );
306 
307 private:
308  int team;
309  bool player; // flag must be attached/carried by player
310 
311  const idEventDef * eventFlag;
312 
313  void Event_Touch( idEntity *other, trace_t *trace );
314 };
315 
316 #endif /* CTF */
317 
318 #endif /* !__GAME_TRIGGER_H__ */
float random_delay
Definition: Trigger.h:98
void TouchEntities(void)
Definition: Trigger.cpp:1137
void Event_Trigger(idEntity *activator)
Definition: Trigger.cpp:645
void Save(idSaveGame *savefile) const
Definition: Trigger.cpp:278
idTrigger_EntityName(void)
Definition: Trigger.cpp:533
void Event_Trigger(idEntity *activator)
Definition: Trigger.cpp:432
void Spawn(void)
Definition: Trigger.cpp:223
void Event_Trigger(idEntity *activator)
Definition: Trigger.cpp:907
void Event_Touch(idEntity *other, trace_t *trace)
Definition: Trigger.cpp:677
void Event_Touch(idEntity *other, trace_t *trace)
Definition: Trigger.cpp:1002
void Restore(idRestoreGame *savefile)
Definition: Trigger.cpp:297
void Save(idSaveGame *savefile) const
Definition: Trigger.cpp:547
bool triggerWithSelf
Definition: Trigger.h:105
void Restore(idRestoreGame *savefile)
Definition: Trigger.cpp:976
static void DrawDebugInfo(void)
Definition: Trigger.cpp:56
idTrigger_Hurt(void)
Definition: Trigger.cpp:954
void Event_Timer(void)
Definition: Trigger.cpp:813
void CallScript(void) const
Definition: Trigger.cpp:142
idTrigger_Multi(void)
Definition: Trigger.cpp:260
virtual void Disable(void)
Definition: Trigger.cpp:1214
idClipModel * clipModel
Definition: Trigger.h:287
void Spawn(void)
Definition: Trigger.cpp:990
idTrigger_Touch(void)
Definition: Trigger.cpp:1093
void Event_Touch(idEntity *other, trace_t *trace)
Definition: Trigger.cpp:469
float wait
Definition: Trigger.h:95
void Event_TriggerAction(idEntity *activator)
Definition: Trigger.cpp:418
void Spawn(void)
Definition: Trigger.cpp:1102
void TriggerAction(idEntity *activator)
Definition: Trigger.cpp:612
void Event_Disable(void)
Definition: Trigger.cpp:205
float delay
Definition: Trigger.h:234
CLASS_PROTOTYPE(idTrigger)
int nextTriggerTime
Definition: Trigger.h:99
void Event_Use(idEntity *activator)
Definition: Trigger.cpp:827
CLASS_PROTOTYPE(idTrigger_Timer)
CLASS_PROTOTYPE(idTrigger_Touch)
void Event_Toggle(idEntity *activator)
Definition: Trigger.cpp:1039
void Spawn(void)
Definition: Trigger.cpp:577
void Save(idSaveGame *savefile) const
Definition: Trigger.cpp:733
CLASS_PROTOTYPE(idTrigger_Fade)
void Restore(idRestoreGame *savefile)
Definition: Trigger.cpp:747
void Event_Trigger(idEntity *activator)
Definition: Trigger.cpp:1192
virtual void Enable(void)
Definition: Trigger.cpp:787
void Save(idSaveGame *savefile) const
Definition: Trigger.cpp:965
void Save(idSaveGame *savefile) const
Definition: Trigger.cpp:165
void Spawn(void)
Definition: Trigger.cpp:896
idStr offName
Definition: Trigger.h:177
void Save(idSaveGame *savefile) const
Definition: Trigger.cpp:874
bool triggerFirst
Definition: Trigger.h:104
void Spawn(void)
Definition: Trigger.cpp:764
virtual void Enable(void)
Definition: Trigger.cpp:121
bool CheckFacing(idEntity *activator)
Definition: Trigger.cpp:372
const function_t * scriptFunction
Definition: Trigger.h:66
CLASS_PROTOTYPE(idTrigger_Multi)
void TriggerAction(idEntity *activator)
Definition: Trigger.cpp:393
float random
Definition: Trigger.h:172
idStr requires
Definition: Trigger.h:100
CLASS_PROTOTYPE(idTrigger_EntityName)
void Restore(idRestoreGame *savefile)
Definition: Trigger.cpp:1128
idStr onName
Definition: Trigger.h:176
const function_t * GetScriptFunction(void) const
Definition: Trigger.cpp:156
CLASS_PROTOTYPE(idTrigger_Count)
CLASS_PROTOTYPE(idTrigger_Hurt)
Definition: Str.h:116
idTrigger_Timer(void)
Definition: Trigger.cpp:721
bool touchClient
Definition: Trigger.h:102
void Restore(idRestoreGame *savefile)
Definition: Trigger.cpp:178
void Event_Enable(void)
Definition: Trigger.cpp:196
void Event_TriggerAction(idEntity *activator)
Definition: Trigger.cpp:927
const idEventDef EV_Enable
void Event_Trigger(idEntity *activator)
Definition: Trigger.cpp:1061
idTrigger_Count(void)
Definition: Trigger.cpp:863
virtual void Disable(void)
Definition: Trigger.cpp:800
void Spawn(void)
Definition: Trigger.cpp:323
void Restore(idRestoreGame *savefile)
Definition: Trigger.cpp:885
float delay
Definition: Trigger.h:97
virtual void Think(void)
Definition: Trigger.cpp:1180
virtual void Enable(void)
Definition: Trigger.cpp:1205
float random
Definition: Trigger.h:96
void Restore(idRestoreGame *savefile)
Definition: Trigger.cpp:562
void Event_TriggerAction(idEntity *activator)
Definition: Trigger.cpp:631
void Save(idSaveGame *savefile)
Definition: Trigger.cpp:1119
bool touchOther
Definition: Trigger.h:103
virtual void Disable(void)
Definition: Trigger.cpp:131
const idEventDef EV_Disable