doom3-gpl
Doom 3 GPL source release
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Projectile.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_PROJECTILE_H__
30 #define __GAME_PROJECTILE_H__
31 
32 /*
33 ===============================================================================
34 
35  idProjectile
36 
37 ===============================================================================
38 */
39 
40 extern const idEventDef EV_Explode;
41 
42 class idProjectile : public idEntity {
43 public :
45 
46  idProjectile();
47  virtual ~idProjectile();
48 
49  void Spawn( void );
50 
51  void Save( idSaveGame *savefile ) const;
52  void Restore( idRestoreGame *savefile );
53 
54  void Create( idEntity *owner, const idVec3 &start, const idVec3 &dir );
55  virtual void Launch( const idVec3 &start, const idVec3 &dir, const idVec3 &pushVelocity, const float timeSinceFire = 0.0f, const float launchPower = 1.0f, const float dmgPower = 1.0f );
56  virtual void FreeLightDef( void );
57 
58  idEntity * GetOwner( void ) const;
59 #ifdef _D3XP
60  void CatchProjectile( idEntity* o, const char* reflectName );
61  int GetProjectileState( void );
62  void Event_CreateProjectile( idEntity *owner, const idVec3 &start, const idVec3 &dir );
63  void Event_LaunchProjectile( const idVec3 &start, const idVec3 &dir, const idVec3 &pushVelocity );
64  void Event_SetGravity( float gravity );
65 #endif
66 
67  virtual void Think( void );
68  virtual void Killed( idEntity *inflictor, idEntity *attacker, int damage, const idVec3 &dir, int location );
69  virtual bool Collide( const trace_t &collision, const idVec3 &velocity );
70  virtual void Explode( const trace_t &collision, idEntity *ignore );
71  void Fizzle( void );
72 
73  static idVec3 GetVelocity( const idDict *projectile );
74  static idVec3 GetGravity( const idDict *projectile );
75 
76  enum {
79  };
80 
81  static void DefaultDamageEffect( idEntity *soundEnt, const idDict &projectileDef, const trace_t &collision, const idVec3 &velocity );
82  static bool ClientPredictionCollide( idEntity *soundEnt, const idDict &projectileDef, const trace_t &collision, const idVec3 &velocity, bool addDamageEffect );
83  virtual void ClientPredictionThink( void );
84  virtual void WriteToSnapshot( idBitMsgDelta &msg ) const;
85  virtual void ReadFromSnapshot( const idBitMsgDelta &msg );
86  virtual bool ClientReceiveEvent( int event, int time, const idBitMsg &msg );
87 
88 protected:
90 
94  bool randomShaderSpin : 1;
95  bool isTracer : 1;
96  bool noSplashDamage : 1;
98 
99  float thrust;
101  float damagePower;
102 
104  qhandle_t lightDefHandle; // handle to renderer light def
109 
112 
115 
116 #ifdef _D3XP
117  int originalTimeGroup;
118 #endif
119 
120  typedef enum {
121  // must update these in script/doom_defs.script if changed
122  SPAWNED = 0,
123  CREATED = 1,
124  LAUNCHED = 2,
125  FIZZLED = 3,
128 
130 
131 private:
133 
134  void AddDefaultDamageEffect( const trace_t &collision, const idVec3 &velocity );
135 
136  void Event_Explode( void );
137  void Event_Fizzle( void );
138  void Event_RadiusDamage( idEntity *ignore );
139  void Event_Touch( idEntity *other, trace_t *trace );
140  void Event_GetProjectileState( void );
141 };
142 
144 public :
146 
147  idGuidedProjectile( void );
148  ~idGuidedProjectile( void );
149 
150  void Save( idSaveGame *savefile ) const;
151  void Restore( idRestoreGame *savefile );
152 
153  void Spawn( void );
154  virtual void Think( void );
155  virtual void Launch( const idVec3 &start, const idVec3 &dir, const idVec3 &pushVelocity, const float timeSinceFire = 0.0f, const float launchPower = 1.0f, const float dmgPower = 1.0f );
156 #ifdef _D3XP
157  void SetEnemy( idEntity *ent );
158  void Event_SetEnemy(idEntity *ent);
159 #endif
160 
161 protected:
162  float speed;
164  virtual void GetSeekPos( idVec3 &out );
165 
166 private:
171  float turn_max;
172  float clamp_dist;
173  bool burstMode;
174  bool unGuided;
175  float burstDist;
177 };
178 
180 public:
183  void Save( idSaveGame *savefile ) const;
184  void Restore( idRestoreGame *savefile );
185 
186  void Spawn( void );
187  virtual void Think( void );
188  virtual void Launch( const idVec3 &start, const idVec3 &dir, const idVec3 &pushVelocity, const float timeSinceFire = 0.0f, const float power = 1.0f, const float dmgPower = 1.0f );
189 
190 protected:
191  virtual void GetSeekPos( idVec3 &out );
192  void ReturnToOwner( void );
193  void KillTarget( const idVec3 &dir );
194 
195 private:
198  float accelTime;
200  bool killPhase;
207 };
208 
209 struct beamTarget_t {
213 };
214 
216 public :
218 
219  idBFGProjectile();
221 
222  void Save( idSaveGame *savefile ) const;
223  void Restore( idRestoreGame *savefile );
224 
225  void Spawn( void );
226  virtual void Think( void );
227  virtual void Launch( const idVec3 &start, const idVec3 &dir, const idVec3 &pushVelocity, const float timeSinceFire = 0.0f, const float launchPower = 1.0f, const float dmgPower = 1.0f );
228  virtual void Explode( const trace_t &collision, idEntity *ignore );
229 
230 private:
236 
237  void FreeBeams();
238  void Event_RemoveBeams();
239  void ApplyDamage();
240 };
241 
242 /*
243 ===============================================================================
244 
245  idDebris
246 
247 ===============================================================================
248 */
249 
250 class idDebris : public idEntity {
251 public :
253 
254  idDebris();
255  ~idDebris();
256 
257  // save games
258  void Save( idSaveGame *savefile ) const; // archives object for save game file
259  void Restore( idRestoreGame *savefile ); // unarchives object from save game file
260 
261  void Spawn( void );
262 
263  void Create( idEntity *owner, const idVec3 &start, const idMat3 &axis );
264  void Launch( void );
265  void Think( void );
266  void Killed( idEntity *inflictor, idEntity *attacker, int damage, const idVec3 &dir, int location );
267  void Explode( void );
268  void Fizzle( void );
269  virtual bool Collide( const trace_t &collision, const idVec3 &velocity );
270 
271 
272 private:
278 
279 
280  void Event_Explode( void );
281  void Event_Fizzle( void );
282 };
283 
284 #endif /* !__GAME_PROJECTILE_H__ */
void AddDefaultDamageEffect(const trace_t &collision, const idVec3 &velocity)
Definition: Projectile.cpp:696
idVec3 lightColor
Definition: Projectile.h:108
int lightEndTime
Definition: Projectile.h:107
static void DefaultDamageEffect(idEntity *soundEnt, const idDict &projectileDef, const trace_t &collision, const idVec3 &velocity)
Definition: Projectile.cpp:656
virtual void ReadFromSnapshot(const idBitMsgDelta &msg)
int qhandle_t
Definition: Lib.h:81
virtual void WriteToSnapshot(idBitMsgDelta &msg) const
idVec3 startingVelocity
Definition: Projectile.h:196
void Event_Touch(idEntity *other, trace_t *trace)
static bool ClientPredictionCollide(idEntity *soundEnt, const idDict &projectileDef, const trace_t &collision, const idVec3 &velocity, bool addDamageEffect)
float damagePower
Definition: Projectile.h:101
virtual void Launch(const idVec3 &start, const idVec3 &dir, const idVec3 &pushVelocity, const float timeSinceFire=0.0f, const float launchPower=1.0f, const float dmgPower=1.0f)
Definition: Projectile.cpp:306
CLASS_PROTOTYPE(idBFGProjectile)
virtual bool ClientReceiveEvent(int event, int time, const idBitMsg &msg)
CLASS_PROTOTYPE(idGuidedProjectile)
void Event_Fizzle(void)
void Explode(void)
GLint location
Definition: glext.h:3631
void Fizzle(void)
projectileState_t state
Definition: Projectile.h:129
renderEntity_t secondModel
Definition: Projectile.h:232
const idDeclParticle * smokeFly
Definition: Projectile.h:113
idPhysics_RigidBody physicsObj
Definition: Projectile.h:111
idEntityPtr< idEntity > owner
Definition: Projectile.h:273
renderLight_t renderLight
Definition: Projectile.h:103
virtual void GetSeekPos(idVec3 &out)
idEntityPtr< idEntity > owner
Definition: Projectile.h:89
Definition: Vector.h:316
virtual void Explode(const trace_t &collision, idEntity *ignore)
void Killed(idEntity *inflictor, idEntity *attacker, int damage, const idVec3 &dir, int location)
void Spawn(void)
Definition: Projectile.cpp:104
virtual void GetSeekPos(idVec3 &out)
const idEventDef EV_Explode
float thrust
Definition: Projectile.h:99
void KillTarget(const idVec3 &dir)
CLASS_PROTOTYPE(idProjectile)
void Create(idEntity *owner, const idVec3 &start, const idVec3 &dir)
Definition: Projectile.cpp:218
void Event_Fizzle(void)
struct idProjectile::projectileFlags_s projectileFlags
idEntityPtr< idEntity > target
Definition: Projectile.h:210
idForce_Constant thruster
Definition: Projectile.h:110
void Restore(idRestoreGame *savefile)
virtual void Think(void)
Definition: Projectile.cpp:476
virtual void Launch(const idVec3 &start, const idVec3 &dir, const idVec3 &pushVelocity, const float timeSinceFire=0.0f, const float power=1.0f, const float dmgPower=1.0f)
qhandle_t secondModelDefHandle
Definition: Projectile.h:233
int smokeFlyTime
Definition: Projectile.h:276
const idDeclParticle * smokeFly
Definition: Projectile.h:275
idVec3 lightOffset
Definition: Projectile.h:105
idEntityPtr< idEntity > enemy
Definition: Projectile.h:163
CLASS_PROTOTYPE(idDebris)
void Restore(idRestoreGame *savefile)
void Launch(void)
Definition: Dict.h:65
void Save(idSaveGame *savefile) const
void Spawn(void)
idPhysics_RigidBody physicsObj
Definition: Projectile.h:274
virtual void ClientPredictionThink(void)
void Spawn(void)
void Event_GetProjectileState(void)
Definition: Projectile.cpp:808
qhandle_t modelDefHandle
Definition: Projectile.h:212
void Restore(idRestoreGame *savefile)
void Event_RadiusDamage(idEntity *ignore)
Definition: Projectile.cpp:796
virtual ~idProjectile()
Definition: Projectile.cpp:284
void Save(idSaveGame *savefile) const
virtual bool Collide(const trace_t &collision, const idVec3 &velocity)
renderEntity_t renderEntity
Definition: Projectile.h:211
virtual void Launch(const idVec3 &start, const idVec3 &dir, const idVec3 &pushVelocity, const float timeSinceFire=0.0f, const float launchPower=1.0f, const float dmgPower=1.0f)
virtual bool Collide(const trace_t &collision, const idVec3 &velocity)
Definition: Projectile.cpp:530
virtual void Think(void)
Definition: Matrix.h:333
idList< beamTarget_t > beamTargets
Definition: Projectile.h:231
void Event_Explode(void)
tuple f
Definition: idal.py:89
static idVec3 GetGravity(const idDict *projectile)
int lightStartTime
Definition: Projectile.h:106
void Create(idEntity *owner, const idVec3 &start, const idMat3 &axis)
Definition: Str.h:116
void Save(idSaveGame *savefile) const
Definition: Projectile.cpp:118
static idVec3 GetVelocity(const idDict *projectile)
virtual void Launch(const idVec3 &start, const idVec3 &dir, const idVec3 &pushVelocity, const float timeSinceFire=0.0f, const float launchPower=1.0f, const float dmgPower=1.0f)
idVec3 endingVelocity
Definition: Projectile.h:197
const idSoundShader * sndBounce
Definition: Projectile.h:277
virtual void Explode(const trace_t &collision, idEntity *ignore)
Definition: Projectile.cpp:817
void Restore(idRestoreGame *savefile)
void Think(void)
CLASS_PROTOTYPE(idSoulCubeMissile)
virtual void Think(void)
void Event_Explode(void)
void ReturnToOwner(void)
qhandle_t lightDefHandle
Definition: Projectile.h:104
int smokeFlyTime
Definition: Projectile.h:114
void Event_RemoveBeams()
virtual void Killed(idEntity *inflictor, idEntity *attacker, int damage, const idVec3 &dir, int location)
Definition: Projectile.cpp:730
void Save(idSaveGame *savefile) const
const idDeclParticle * smokeKill
Definition: Projectile.h:206
virtual void FreeLightDef(void)
Definition: Projectile.cpp:294
GLuint start
Definition: glext.h:2845
void Save(idSaveGame *savefile) const
void Restore(idRestoreGame *savefile)
Definition: Projectile.cpp:156
void Fizzle(void)
Definition: Projectile.cpp:752
idEntity * GetOwner(void) const
Definition: Projectile.cpp:209
virtual void Think(void)
bool netSyncPhysics
Definition: Projectile.h:132