2012-11-26 18:58:24 +00:00
|
|
|
/*
|
|
|
|
===========================================================================
|
|
|
|
|
|
|
|
Doom 3 BFG Edition GPL Source Code
|
2012-11-28 15:47:07 +00:00
|
|
|
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
|
2012-11-26 18:58:24 +00:00
|
|
|
|
2012-11-28 15:47:07 +00:00
|
|
|
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
|
2012-11-26 18:58:24 +00:00
|
|
|
|
|
|
|
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
In addition, the Doom 3 BFG Edition 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 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
|
|
|
|
|
|
|
|
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.
|
|
|
|
|
|
|
|
===========================================================================
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __GAME_PROJECTILE_H__
|
|
|
|
#define __GAME_PROJECTILE_H__
|
|
|
|
|
|
|
|
/*
|
|
|
|
===============================================================================
|
|
|
|
|
|
|
|
idProjectile
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
===============================================================================
|
|
|
|
*/
|
|
|
|
|
|
|
|
extern const idEventDef EV_Explode;
|
|
|
|
|
2012-11-28 15:47:07 +00:00
|
|
|
class idProjectile : public idEntity
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
public :
|
|
|
|
CLASS_PROTOTYPE( idProjectile );
|
2012-11-28 15:47:07 +00:00
|
|
|
|
|
|
|
idProjectile();
|
2012-11-26 18:58:24 +00:00
|
|
|
virtual ~idProjectile();
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
void Spawn();
|
2012-11-28 15:47:07 +00:00
|
|
|
|
|
|
|
void Save( idSaveGame* savefile ) const;
|
|
|
|
void Restore( idRestoreGame* savefile );
|
|
|
|
|
|
|
|
void Create( idEntity* owner, const idVec3& start, const idVec3& dir );
|
|
|
|
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 );
|
2012-11-26 18:58:24 +00:00
|
|
|
virtual void FreeLightDef();
|
2012-11-28 15:47:07 +00:00
|
|
|
|
|
|
|
idEntity* GetOwner() const;
|
2012-11-26 18:58:24 +00:00
|
|
|
void CatchProjectile( idEntity* o, const char* reflectName );
|
|
|
|
int GetProjectileState();
|
2012-11-28 15:47:07 +00:00
|
|
|
void Event_CreateProjectile( idEntity* owner, const idVec3& start, const idVec3& dir );
|
|
|
|
void Event_LaunchProjectile( const idVec3& start, const idVec3& dir, const idVec3& pushVelocity );
|
2012-11-26 18:58:24 +00:00
|
|
|
void Event_SetGravity( float gravity );
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
virtual void Think();
|
2012-11-28 15:47:07 +00:00
|
|
|
virtual void Killed( idEntity* inflictor, idEntity* attacker, int damage, const idVec3& dir, int location );
|
|
|
|
virtual bool Collide( const trace_t& collision, const idVec3& velocity );
|
|
|
|
virtual void Explode( const trace_t& collision, idEntity* ignore );
|
2012-11-26 18:58:24 +00:00
|
|
|
void Fizzle();
|
2012-11-28 15:47:07 +00:00
|
|
|
|
|
|
|
static idVec3 GetVelocity( const idDict* projectile );
|
|
|
|
static idVec3 GetGravity( const idDict* projectile );
|
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
EVENT_DAMAGE_EFFECT = idEntity::EVENT_MAXEVENTS,
|
|
|
|
EVENT_MAXEVENTS
|
|
|
|
};
|
2012-11-28 15:47:07 +00:00
|
|
|
|
|
|
|
void SetLaunchedFromGrabber( bool bl )
|
|
|
|
{
|
|
|
|
launchedFromGrabber = bl;
|
|
|
|
}
|
|
|
|
bool GetLaunchedFromGrabber()
|
|
|
|
{
|
|
|
|
return launchedFromGrabber;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void DefaultDamageEffect( idEntity* soundEnt, const idDict& projectileDef, const trace_t& collision, const idVec3& velocity );
|
|
|
|
static bool ClientPredictionCollide( idEntity* soundEnt, const idDict& projectileDef, const trace_t& collision, const idVec3& velocity, bool addDamageEffect );
|
2012-11-26 18:58:24 +00:00
|
|
|
virtual void ClientPredictionThink();
|
|
|
|
virtual void ClientThink( const int curTime, const float fraction, const bool predict );
|
2012-11-28 15:47:07 +00:00
|
|
|
virtual void WriteToSnapshot( idBitMsg& msg ) const;
|
|
|
|
virtual void ReadFromSnapshot( const idBitMsg& msg );
|
|
|
|
virtual bool ClientReceiveEvent( int event, int time, const idBitMsg& msg );
|
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
void QueueToSimulate( int startTime );
|
|
|
|
virtual void SimulateProjectileFrame( int msec, int endTime );
|
|
|
|
virtual void PostSimulate( int endTime );
|
2012-11-28 15:47:07 +00:00
|
|
|
|
|
|
|
struct simulatedProjectile_t
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
simulatedProjectile_t(): projectile( NULL ), startTime( 0 ) {}
|
|
|
|
idProjectile* projectile;
|
|
|
|
int startTime;
|
|
|
|
};
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
static const int MAX_SIMULATED_PROJECTILES = 64;
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
// This list is used to "catch up" client projectiles to the current time on the server
|
|
|
|
static idArray< simulatedProjectile_t, MAX_SIMULATED_PROJECTILES > projectilesToSimulate;
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
protected:
|
|
|
|
idEntityPtr<idEntity> owner;
|
2012-11-28 15:47:07 +00:00
|
|
|
|
|
|
|
struct projectileFlags_s
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
bool detonate_on_world : 1;
|
|
|
|
bool detonate_on_actor : 1;
|
|
|
|
bool randomShaderSpin : 1;
|
|
|
|
bool isTracer : 1;
|
|
|
|
bool noSplashDamage : 1;
|
|
|
|
} projectileFlags;
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
bool launchedFromGrabber;
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
float thrust;
|
|
|
|
int thrust_end;
|
|
|
|
float damagePower;
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
renderLight_t renderLight;
|
|
|
|
qhandle_t lightDefHandle; // handle to renderer light def
|
|
|
|
idVec3 lightOffset;
|
|
|
|
int lightStartTime;
|
|
|
|
int lightEndTime;
|
|
|
|
idVec3 lightColor;
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
idForce_Constant thruster;
|
|
|
|
idPhysics_RigidBody physicsObj;
|
2012-11-28 15:47:07 +00:00
|
|
|
|
|
|
|
const idDeclParticle* smokeFly;
|
2012-11-26 18:58:24 +00:00
|
|
|
int smokeFlyTime;
|
|
|
|
bool mNoExplodeDisappear;
|
|
|
|
bool mTouchTriggers;
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
int originalTimeGroup;
|
2012-11-28 15:47:07 +00:00
|
|
|
|
|
|
|
typedef enum
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
// must update these in script/doom_defs.script if changed
|
|
|
|
SPAWNED = 0,
|
|
|
|
CREATED = 1,
|
|
|
|
LAUNCHED = 2,
|
|
|
|
FIZZLED = 3,
|
|
|
|
EXPLODED = 4
|
|
|
|
} projectileState_t;
|
|
|
|
|
|
|
|
projectileState_t state;
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
private:
|
|
|
|
|
|
|
|
idVec3 launchOrigin;
|
|
|
|
idMat3 launchAxis;
|
2012-11-28 15:47:07 +00:00
|
|
|
|
|
|
|
void AddDefaultDamageEffect( const trace_t& collision, const idVec3& velocity );
|
2012-11-26 18:58:24 +00:00
|
|
|
void AddParticlesAndLight();
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
void Event_Explode();
|
|
|
|
void Event_Fizzle();
|
2012-11-28 15:47:07 +00:00
|
|
|
void Event_RadiusDamage( idEntity* ignore );
|
|
|
|
void Event_Touch( idEntity* other, trace_t* trace );
|
2012-11-26 18:58:24 +00:00
|
|
|
void Event_GetProjectileState();
|
|
|
|
};
|
|
|
|
|
2012-11-28 15:47:07 +00:00
|
|
|
class idGuidedProjectile : public idProjectile
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
public :
|
|
|
|
CLASS_PROTOTYPE( idGuidedProjectile );
|
2012-11-28 15:47:07 +00:00
|
|
|
|
|
|
|
idGuidedProjectile();
|
|
|
|
~idGuidedProjectile();
|
|
|
|
|
|
|
|
void Save( idSaveGame* savefile ) const;
|
|
|
|
void Restore( idRestoreGame* savefile );
|
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
void Spawn();
|
|
|
|
virtual void Think();
|
2012-11-28 15:47:07 +00:00
|
|
|
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 );
|
|
|
|
void SetEnemy( idEntity* ent );
|
|
|
|
void Event_SetEnemy( idEntity* ent );
|
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
protected:
|
|
|
|
float speed;
|
|
|
|
idEntityPtr<idEntity> enemy;
|
2012-11-28 15:47:07 +00:00
|
|
|
virtual void GetSeekPos( idVec3& out );
|
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
private:
|
|
|
|
idAngles rndScale;
|
|
|
|
idAngles rndAng;
|
|
|
|
idAngles angles;
|
|
|
|
int rndUpdateTime;
|
|
|
|
float turn_max;
|
|
|
|
float clamp_dist;
|
|
|
|
bool burstMode;
|
|
|
|
bool unGuided;
|
|
|
|
float burstDist;
|
|
|
|
float burstVelocity;
|
|
|
|
};
|
|
|
|
|
2012-11-28 15:47:07 +00:00
|
|
|
class idSoulCubeMissile : public idGuidedProjectile
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
public:
|
2012-11-28 15:47:07 +00:00
|
|
|
CLASS_PROTOTYPE( idSoulCubeMissile );
|
2012-11-26 18:58:24 +00:00
|
|
|
~idSoulCubeMissile();
|
2012-11-28 15:47:07 +00:00
|
|
|
void Save( idSaveGame* savefile ) const;
|
|
|
|
void Restore( idRestoreGame* savefile );
|
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
void Spawn();
|
|
|
|
virtual void Think();
|
2012-11-28 15:47:07 +00:00
|
|
|
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 );
|
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
protected:
|
2012-11-28 15:47:07 +00:00
|
|
|
virtual void GetSeekPos( idVec3& out );
|
2012-11-26 18:58:24 +00:00
|
|
|
void ReturnToOwner();
|
2012-11-28 15:47:07 +00:00
|
|
|
void KillTarget( const idVec3& dir );
|
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
private:
|
|
|
|
idVec3 startingVelocity;
|
|
|
|
idVec3 endingVelocity;
|
|
|
|
float accelTime;
|
|
|
|
int launchTime;
|
|
|
|
bool killPhase;
|
|
|
|
bool returnPhase;
|
|
|
|
idVec3 destOrg;
|
|
|
|
idVec3 orbitOrg;
|
|
|
|
int orbitTime;
|
|
|
|
int smokeKillTime;
|
2012-11-28 15:47:07 +00:00
|
|
|
const idDeclParticle* smokeKill;
|
2012-11-26 18:58:24 +00:00
|
|
|
};
|
|
|
|
|
2012-11-28 15:47:07 +00:00
|
|
|
struct beamTarget_t
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
idEntityPtr<idEntity> target;
|
|
|
|
renderEntity_t renderEntity;
|
|
|
|
qhandle_t modelDefHandle;
|
|
|
|
};
|
|
|
|
|
2012-11-28 15:47:07 +00:00
|
|
|
class idBFGProjectile : public idProjectile
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
public :
|
|
|
|
CLASS_PROTOTYPE( idBFGProjectile );
|
2012-11-28 15:47:07 +00:00
|
|
|
|
|
|
|
idBFGProjectile();
|
|
|
|
~idBFGProjectile();
|
|
|
|
|
|
|
|
void Save( idSaveGame* savefile ) const;
|
|
|
|
void Restore( idRestoreGame* savefile );
|
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
void Spawn();
|
|
|
|
virtual void Think();
|
2012-11-28 15:47:07 +00:00
|
|
|
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 void Explode( const trace_t& collision, idEntity* ignore );
|
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
private:
|
|
|
|
idList<beamTarget_t, TAG_PROJECTILE> beamTargets;
|
|
|
|
renderEntity_t secondModel;
|
|
|
|
qhandle_t secondModelDefHandle;
|
|
|
|
int nextDamageTime;
|
|
|
|
idStr damageFreq;
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
void FreeBeams();
|
|
|
|
void Event_RemoveBeams();
|
|
|
|
void ApplyDamage();
|
|
|
|
};
|
|
|
|
|
2012-11-28 15:47:07 +00:00
|
|
|
class idHomingProjectile : public idProjectile
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
public :
|
|
|
|
CLASS_PROTOTYPE( idHomingProjectile );
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
idHomingProjectile();
|
|
|
|
~idHomingProjectile();
|
2012-11-28 15:47:07 +00:00
|
|
|
|
|
|
|
void Save( idSaveGame* savefile ) const;
|
|
|
|
void Restore( idRestoreGame* savefile );
|
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
void Spawn();
|
|
|
|
virtual void Think();
|
2012-11-28 15:47:07 +00:00
|
|
|
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 );
|
|
|
|
void SetEnemy( idEntity* ent );
|
2012-11-26 18:58:24 +00:00
|
|
|
void SetSeekPos( idVec3 pos );
|
2012-11-28 15:47:07 +00:00
|
|
|
void Event_SetEnemy( idEntity* ent );
|
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
protected:
|
|
|
|
float speed;
|
|
|
|
idEntityPtr<idEntity> enemy;
|
|
|
|
idVec3 seekPos;
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
private:
|
|
|
|
idAngles rndScale;
|
|
|
|
idAngles rndAng;
|
|
|
|
idAngles angles;
|
|
|
|
float turn_max;
|
|
|
|
float clamp_dist;
|
|
|
|
bool burstMode;
|
|
|
|
bool unGuided;
|
|
|
|
float burstDist;
|
|
|
|
float burstVelocity;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
===============================================================================
|
|
|
|
|
|
|
|
idDebris
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
===============================================================================
|
|
|
|
*/
|
|
|
|
|
2012-11-28 15:47:07 +00:00
|
|
|
class idDebris : public idEntity
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
public :
|
|
|
|
CLASS_PROTOTYPE( idDebris );
|
2012-11-28 15:47:07 +00:00
|
|
|
|
|
|
|
idDebris();
|
|
|
|
~idDebris();
|
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
// save games
|
2012-11-28 15:47:07 +00:00
|
|
|
void Save( idSaveGame* savefile ) const; // archives object for save game file
|
|
|
|
void Restore( idRestoreGame* savefile ); // unarchives object from save game file
|
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
void Spawn();
|
2012-11-28 15:47:07 +00:00
|
|
|
|
|
|
|
void Create( idEntity* owner, const idVec3& start, const idMat3& axis );
|
2012-11-26 18:58:24 +00:00
|
|
|
void Launch();
|
|
|
|
void Think();
|
2012-11-28 15:47:07 +00:00
|
|
|
void Killed( idEntity* inflictor, idEntity* attacker, int damage, const idVec3& dir, int location );
|
2012-11-26 18:58:24 +00:00
|
|
|
void Explode();
|
|
|
|
void Fizzle();
|
2012-11-28 15:47:07 +00:00
|
|
|
virtual bool Collide( const trace_t& collision, const idVec3& velocity );
|
|
|
|
|
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
private:
|
|
|
|
idEntityPtr<idEntity> owner;
|
|
|
|
idPhysics_RigidBody physicsObj;
|
2012-11-28 15:47:07 +00:00
|
|
|
const idDeclParticle* smokeFly;
|
2012-11-26 18:58:24 +00:00
|
|
|
int smokeFlyTime;
|
2012-11-28 15:47:07 +00:00
|
|
|
const idSoundShader* sndBounce;
|
|
|
|
|
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
void Event_Explode();
|
|
|
|
void Event_Fizzle();
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* !__GAME_PROJECTILE_H__ */
|