2 ===========================================================================
5 Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
7 This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
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.
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.
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/>.
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.
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.
26 ===========================================================================
29 #ifndef __GAME_PROJECTILE_H__
30 #define __GAME_PROJECTILE_H__
33 ===============================================================================
37 ===============================================================================
40 extern const idEventDef EV_Explode;
42 class idProjectile : public idEntity {
44 CLASS_PROTOTYPE( idProjectile );
47 virtual ~idProjectile();
51 void Save( idSaveGame *savefile ) const;
52 void Restore( idRestoreGame *savefile );
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 );
58 idEntity * GetOwner( void ) const;
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 );
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 );
73 static idVec3 GetVelocity( const idDict *projectile );
74 static idVec3 GetGravity( const idDict *projectile );
77 EVENT_DAMAGE_EFFECT = idEntity::EVENT_MAXEVENTS,
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 );
89 idEntityPtr<idEntity> owner;
91 struct projectileFlags_s {
92 bool detonate_on_world : 1;
93 bool detonate_on_actor : 1;
94 bool randomShaderSpin : 1;
96 bool noSplashDamage : 1;
103 renderLight_t renderLight;
104 qhandle_t lightDefHandle; // handle to renderer light def
110 idForce_Constant thruster;
111 idPhysics_RigidBody physicsObj;
113 const idDeclParticle * smokeFly;
117 int originalTimeGroup;
121 // must update these in script/doom_defs.script if changed
129 projectileState_t state;
134 void AddDefaultDamageEffect( const trace_t &collision, const idVec3 &velocity );
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 );
143 class idGuidedProjectile : public idProjectile {
145 CLASS_PROTOTYPE( idGuidedProjectile );
147 idGuidedProjectile( void );
148 ~idGuidedProjectile( void );
150 void Save( idSaveGame *savefile ) const;
151 void Restore( idRestoreGame *savefile );
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 );
157 void SetEnemy( idEntity *ent );
158 void Event_SetEnemy(idEntity *ent);
163 idEntityPtr<idEntity> enemy;
164 virtual void GetSeekPos( idVec3 &out );
179 class idSoulCubeMissile : public idGuidedProjectile {
181 CLASS_PROTOTYPE ( idSoulCubeMissile );
182 ~idSoulCubeMissile();
183 void Save( idSaveGame *savefile ) const;
184 void Restore( idRestoreGame *savefile );
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 );
191 virtual void GetSeekPos( idVec3 &out );
192 void ReturnToOwner( void );
193 void KillTarget( const idVec3 &dir );
196 idVec3 startingVelocity;
197 idVec3 endingVelocity;
206 const idDeclParticle * smokeKill;
209 struct beamTarget_t {
210 idEntityPtr<idEntity> target;
211 renderEntity_t renderEntity;
212 qhandle_t modelDefHandle;
215 class idBFGProjectile : public idProjectile {
217 CLASS_PROTOTYPE( idBFGProjectile );
222 void Save( idSaveGame *savefile ) const;
223 void Restore( idRestoreGame *savefile );
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 );
231 idList<beamTarget_t> beamTargets;
232 renderEntity_t secondModel;
233 qhandle_t secondModelDefHandle;
238 void Event_RemoveBeams();
243 ===============================================================================
247 ===============================================================================
250 class idDebris : public idEntity {
252 CLASS_PROTOTYPE( idDebris );
258 void Save( idSaveGame *savefile ) const; // archives object for save game file
259 void Restore( idRestoreGame *savefile ); // unarchives object from save game file
263 void Create( idEntity *owner, const idVec3 &start, const idMat3 &axis );
266 void Killed( idEntity *inflictor, idEntity *attacker, int damage, const idVec3 &dir, int location );
267 void Explode( void );
269 virtual bool Collide( const trace_t &collision, const idVec3 &velocity );
273 idEntityPtr<idEntity> owner;
274 idPhysics_RigidBody physicsObj;
275 const idDeclParticle * smokeFly;
277 const idSoundShader * sndBounce;
280 void Event_Explode( void );
281 void Event_Fizzle( void );
284 #endif /* !__GAME_PROJECTILE_H__ */