summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTim Angus <tim@ngus.net>2003-09-28 00:54:11 +0000
committerTim Angus <tim@ngus.net>2003-09-28 00:54:11 +0000
commitccbc3c206cf841d352d903feadd358a0dd3ee81e (patch)
tree6d67aa1581e24989bb8d726632cff3f1af6be1e7 /src
parent2c917c986c82fafafe2b58a61479657997d80718 (diff)
* Jetpack now uses new particle system
Diffstat (limited to 'src')
-rw-r--r--src/cgame/cg_buildable.c4
-rw-r--r--src/cgame/cg_ents.c3
-rw-r--r--src/cgame/cg_local.h16
-rw-r--r--src/cgame/cg_main.c4
-rw-r--r--src/cgame/cg_particles.c13
-rw-r--r--src/cgame/cg_players.c75
6 files changed, 74 insertions, 41 deletions
diff --git a/src/cgame/cg_buildable.c b/src/cgame/cg_buildable.c
index d0c286f4..42017cd5 100644
--- a/src/cgame/cg_buildable.c
+++ b/src/cgame/cg_buildable.c
@@ -282,12 +282,12 @@ void CG_InitBuildables( )
//animation.cfg
Com_sprintf( filename, sizeof( filename ), "models/buildables/%s/animation.cfg", buildableName );
if ( !CG_ParseBuildableAnimationFile( filename, i ) )
- Com_Printf( "Failed to load animation file %s\n", filename );
+ Com_Printf( S_COLOR_YELLOW "WARNING: failed to load animation file %s\n", filename );
//sound.cfg
Com_sprintf( filename, sizeof( filename ), "sound/buildables/%s/sound.cfg", buildableName );
if ( !CG_ParseBuildableSoundFile( filename, i ) )
- Com_Printf( "Failed to load sound file %s\n", filename );
+ Com_Printf( S_COLOR_YELLOW "WARNING: failed to load sound file %s\n", filename );
//models
for( j = 0; j <= 3; j++ )
diff --git a/src/cgame/cg_ents.c b/src/cgame/cg_ents.c
index c35b9281..758250a0 100644
--- a/src/cgame/cg_ents.c
+++ b/src/cgame/cg_ents.c
@@ -875,6 +875,9 @@ static void CG_CEntityPVSEnter( centity_t *cent )
//clear any particle systems from previous uses of this centity_t
cent->muzzlePS = NULL;
cent->muzzlePsTrigger = qfalse;
+
+ cent->jetPackPS = NULL;
+ cent->jetPackState = JPS_OFF;
}
diff --git a/src/cgame/cg_local.h b/src/cgame/cg_local.h
index 08df7337..5988d22b 100644
--- a/src/cgame/cg_local.h
+++ b/src/cgame/cg_local.h
@@ -114,6 +114,13 @@ typedef enum
IMPACTSOUND_FLESH
} impactSound_t;
+typedef enum
+{
+ JPS_OFF,
+ JPS_DESCENDING,
+ JPS_HOVERING,
+ JPS_ASCENDING
+} jetPackState_t;
//particle system stuff
#define MAX_SHADER_FRAMES 64
@@ -424,8 +431,6 @@ typedef struct centity_s
lerpFrame_t lerpFrame;
//TA:
- int jetTime; //limit jet count
-
buildableAnimNumber_t buildableAnim; //persistant anim number
buildableAnimNumber_t oldBuildableAnim; //to detect when new anims are set
int buildableSmokeTime;
@@ -443,6 +448,9 @@ typedef struct centity_s
particleSystem_t *muzzlePS;
qboolean muzzlePsTrigger;
+ particleSystem_t *jetPackPS;
+ jetPackState_t jetPackState;
+
qboolean valid;
qboolean oldValid;
} centity_t;
@@ -1143,6 +1151,10 @@ typedef struct
sfxHandle_t jetpackIdleSound;
sfxHandle_t jetpackAscendSound;
+ qhandle_t jetPackDescendPS;
+ qhandle_t jetPackHoverPS;
+ qhandle_t jetPackAscendPS;
+
//TA:
sfxHandle_t alienStageTransition;
sfxHandle_t humanStageTransition;
diff --git a/src/cgame/cg_main.c b/src/cgame/cg_main.c
index cee6422d..634e2b6c 100644
--- a/src/cgame/cg_main.c
+++ b/src/cgame/cg_main.c
@@ -790,6 +790,10 @@ static void CG_RegisterGraphics( void )
cgs.media.poisonCloudPS = CG_RegisterParticleSystem( "poisonCloud" );
+ cgs.media.jetPackDescendPS = CG_RegisterParticleSystem( "jetPackDescendPS" );
+ cgs.media.jetPackHoverPS = CG_RegisterParticleSystem( "jetPackHoverPS" );
+ cgs.media.jetPackAscendPS = CG_RegisterParticleSystem( "jetPackAscendPS" );
+
// register the inline models
cgs.numInlineModels = trap_CM_NumInlineModels( );
diff --git a/src/cgame/cg_particles.c b/src/cgame/cg_particles.c
index 57395c49..56f239de 100644
--- a/src/cgame/cg_particles.c
+++ b/src/cgame/cg_particles.c
@@ -131,6 +131,7 @@ static particle_t *CG_SpawnNewParticle( baseParticle_t *bp, particleEjector_t *p
if( !ps->attachment.tagValid )
return NULL;
+ AxisCopy( axisDefault, ps->attachment.re.axis );
CG_PositionRotatedEntityOnTag( &ps->attachment.re, &ps->attachment.parent,
ps->attachment.model, ps->attachment.tagName );
VectorCopy( ps->attachment.re.origin, p->origin );
@@ -403,6 +404,7 @@ qhandle_t CG_RegisterParticleSystem( char *name )
}
}
+ CG_Printf( S_COLOR_YELLOW "WARNING: failed to load particle system %s\n", name );
return 0;
}
@@ -1395,10 +1397,21 @@ Destroy a particle system
*/
void CG_DestroyParticleSystem( particleSystem_t *ps )
{
+ int i;
+ particleEjector_t *pe;
+
if( cg_debugParticles.integer >= 1 )
CG_Printf( "PS destroyed\n" );
ps->valid = qfalse;
+
+ for( i = 0; i < MAX_PARTICLE_EJECTORS; i++ )
+ {
+ pe = &particleEjectors[ i ];
+
+ if( pe->valid && pe->parent == ps )
+ pe->valid = qfalse;
+ }
}
/*
diff --git a/src/cgame/cg_players.c b/src/cgame/cg_players.c
index 297fe0f9..a08279bf 100644
--- a/src/cgame/cg_players.c
+++ b/src/cgame/cg_players.c
@@ -1386,8 +1386,6 @@ static void CG_PlayerNonSegAngles( centity_t *cent, vec3_t srcAngles, vec3_t non
//==========================================================================
-#define JET_LIFETIME 1500
-
/*
===============
CG_PlayerUpgrade
@@ -1396,15 +1394,6 @@ CG_PlayerUpgrade
static void CG_PlayerUpgrades( centity_t *cent, refEntity_t *torso )
{
int held, active;
- vec3_t acc = { 0.0f, 0.0f, 10.0f };
- vec3_t vel = { 0.0f, 0.0f, 0.0f };
- vec3_t origin;
- vec3_t forward = { 1.0f, 0.0f, 0.0f };
- vec3_t right = { 0.0f, 1.0f, 0.0f };
- vec3_t pvel;
- vec3_t angles;
- int addTime;
- float spread;
refEntity_t jetpack;
refEntity_t flash;
@@ -1432,27 +1421,45 @@ static void CG_PlayerUpgrades( centity_t *cent, refEntity_t *torso )
{
if( cent->currentState.pos.trDelta[ 2 ] > 10.0f )
{
+ if( cent->jetPackState != JPS_ASCENDING )
+ {
+ if( cent->jetPackPS != NULL )
+ CG_DestroyParticleSystem( cent->jetPackPS );
+
+ cent->jetPackPS = CG_SpawnNewParticleSystem( cgs.media.jetPackAscendPS );
+ cent->jetPackState = JPS_ASCENDING;
+ }
+
trap_S_AddLoopingSound( cent->currentState.number, cent->lerpOrigin,
vec3_origin, cgs.media.jetpackAscendSound );
- addTime = 70;
- vel[ 2 ] = -60.0f;
- spread = 30.0f;
}
else if( cent->currentState.pos.trDelta[ 2 ] < -10.0f )
{
+ if( cent->jetPackState != JPS_DESCENDING )
+ {
+ if( cent->jetPackPS != NULL )
+ CG_DestroyParticleSystem( cent->jetPackPS );
+
+ cent->jetPackPS = CG_SpawnNewParticleSystem( cgs.media.jetPackDescendPS );
+ cent->jetPackState = JPS_DESCENDING;
+ }
+
trap_S_AddLoopingSound( cent->currentState.number, cent->lerpOrigin,
vec3_origin, cgs.media.jetpackDescendSound );
- addTime = 90;
- vel[ 2 ] = -100.0f;
- spread = 5.0f;
}
else
{
+ if( cent->jetPackState != JPS_HOVERING )
+ {
+ if( cent->jetPackPS != NULL )
+ CG_DestroyParticleSystem( cent->jetPackPS );
+
+ cent->jetPackPS = CG_SpawnNewParticleSystem( cgs.media.jetPackHoverPS );
+ cent->jetPackState = JPS_HOVERING;
+ }
+
trap_S_AddLoopingSound( cent->currentState.number, cent->lerpOrigin,
vec3_origin, cgs.media.jetpackIdleSound );
- addTime = 80;
- vel[ 2 ] = -80.0f;
- spread = 15.0f;
}
memset( &flash, 0, sizeof( flash ) );
@@ -1464,30 +1471,24 @@ static void CG_PlayerUpgrades( centity_t *cent, refEntity_t *torso )
if( !flash.hModel )
return;
- angles[ YAW ] = 0;
- angles[ PITCH ] = 0;
- angles[ ROLL ] = 0;
- AnglesToAxis( angles, flash.axis );
+ AxisCopy( axisDefault, flash.axis );
CG_PositionRotatedEntityOnTag( &flash, &jetpack, jetpack.hModel, "tag_flash" );
trap_R_AddRefEntityToScene( &flash );
- if( cent->jetTime < cg.time )
+ if( cent->jetPackPS != NULL )
{
- VectorCopy( flash.origin, origin );
-
- VectorScale( cent->currentState.pos.trDelta, 0.75f, pvel );
- VectorAdd( vel, pvel, vel );
-
- CG_LaunchSprite( origin, vel, acc, spread,
- 0.5f, 4.0f, 20.0f, 128.0f, 0.0f,
- rand( ) % 360, cg.time, cg.time, JET_LIFETIME,
- cgs.media.smokePuffShader, qfalse, qfalse );
-
- //set next ball time
- cent->jetTime = cg.time + addTime;
+ CG_SetParticleSystemTag( cent->jetPackPS, jetpack, jetpack.hModel, "tag_flash" );
+ CG_SetParticleSystemCent( cent->jetPackPS, cent );
+ CG_AttachParticleSystemToTag( cent->jetPackPS );
}
}
+ else if( cent->jetPackPS != NULL )
+ {
+ CG_DestroyParticleSystem( cent->jetPackPS );
+ cent->jetPackState = JPS_OFF;
+ cent->jetPackPS = NULL;
+ }
}
}