diff options
-rw-r--r-- | src/cgame/cg_buildable.c | 87 | ||||
-rw-r--r-- | src/cgame/cg_ents.c | 2 | ||||
-rw-r--r-- | src/cgame/cg_local.h | 9 | ||||
-rw-r--r-- | src/cgame/cg_main.c | 3 | ||||
-rw-r--r-- | src/cgame/cg_particles.c | 130 | ||||
-rw-r--r-- | src/cgame/cg_weapons.c | 9 |
6 files changed, 90 insertions, 150 deletions
diff --git a/src/cgame/cg_buildable.c b/src/cgame/cg_buildable.c index 42017cd5..84c8226b 100644 --- a/src/cgame/cg_buildable.c +++ b/src/cgame/cg_buildable.c @@ -605,87 +605,36 @@ static void CG_BuildableParticleEffects( centity_t *cent ) buildableTeam_t team = BG_FindTeamForBuildable( es->modelindex ); int health = es->generic1 & ~( B_POWERED_TOGGLEBIT | B_DCCED_TOGGLEBIT | B_SPAWNED_TOGGLEBIT ); float healthFrac = (float)health / B_HEALTH_SCALE; - int smokeTime, sparkTime, i, bleedBlobs; - vec3_t origin; - vec3_t acc = { 0.0f, 0.0f, 50.0f }; - vec3_t grav = { 0.0f, 0.0f, -DEFAULT_GRAVITY }; - vec3_t vel = { 0.0f, 0.0f, 0.0f }; - - VectorCopy( cent->lerpOrigin, origin ); if( team == BIT_HUMANS ) { - //hack to move particle origin away from ground - origin[ 2 ] += 8.0f; - - if( healthFrac < 0.33f && cent->buildableSmokeTime < cg.time ) + if( healthFrac < 0.33f && cent->buildablePS == NULL ) { - //smoke - smokeTime = healthFrac * 3 * MAX_SMOKE_TIME; - if( smokeTime < MIN_SMOKE_TIME ) - smokeTime = MIN_SMOKE_TIME; - - VectorSet( vel, 0.0f, 0.0f, 50.0f ); - - CG_LaunchSprite( origin, vel, acc, SMOKE_SPREAD, - 0.5f, 10.0f, 50.0f, 128.0f, 0.0f, - rand( ) % 360, cg.time, cg.time, - SMOKE_LIFETIME + ( crandom( ) * ( SMOKE_LIFETIME / 2 ) ), - cgs.media.smokePuffShader, qfalse, qfalse ); - - cent->buildableSmokeTime = cg.time + smokeTime; + cent->buildablePS = CG_SpawnNewParticleSystem( cgs.media.humanBuildableDamagedPS ); + CG_SetParticleSystemCent( cent->buildablePS, cent ); + CG_AttachParticleSystemToCent( cent->buildablePS ); } - - if( healthFrac < 0.2f && cent->buildableSparkTime < cg.time ) + else if( healthFrac >= 0.33f && cent->buildablePS != NULL ) { - //sparks - sparkTime = healthFrac * 5 * MAX_SPARK_TIME; - if( sparkTime < MIN_SPARK_TIME ) - sparkTime = MIN_SPARK_TIME; - - for( i = 0; i < 3; i++ ) - { - qhandle_t spark; - - if( rand( ) % 1 ) - spark = cgs.media.gibSpark1; - else - spark = cgs.media.gibSpark2; - - VectorSet( vel, 0.0f, 0.0f, 200.0f ); - VectorSet( grav, 0.0f, 0.0f, -DEFAULT_GRAVITY ); - - CG_LaunchSprite( origin, vel, grav, SPARK_SPREAD, - 0.6f, 4.0f, 2.0f, 255.0f, 0.0f, - rand( ) % 360, cg.time, cg.time, - SPARK_LIFETIME + ( crandom( ) * ( SPARK_LIFETIME / 2 ) ), - spark, qfalse, qfalse ); - } - - cent->buildableSparkTime = cg.time + sparkTime; + CG_DestroyParticleSystem( cent->buildablePS ); + cent->buildablePS = NULL; } } else if( team == BIT_ALIENS ) { - //bleed a bit if damaged - if( healthFrac < 0.33f && cent->buildableBleedTime < cg.time ) + if( healthFrac < 0.33f && cent->buildablePS == NULL ) { - VectorScale( es->origin2, 100.0f, vel ); - VectorSet( grav, 0.0f, 0.0f, -DEFAULT_GRAVITY/4 ); - - bleedBlobs = ( 1.0f - ( healthFrac * 3 ) ) * MAX_BLEED_BLOBS + 1; - - for( i = 0; i < bleedBlobs; i++ ) - { - CG_LaunchSprite( origin, vel, grav, BLEED_SPREAD, - 0.0f, 4.0f, 20.0f, 255.0f, 0.0f, - rand( ) % 360, cg.time, cg.time, - BLEED_LIFETIME + ( crandom( ) * ( BLEED_LIFETIME / 2 ) ), - cgs.media.greenBloodTrailShader, qfalse, qfalse ); - } - - cent->buildableBleedTime = cg.time + BLEED_TIME; + cent->buildablePS = CG_SpawnNewParticleSystem( cgs.media.alienBuildableDamagedPS ); + CG_SetParticleSystemCent( cent->buildablePS, cent ); + CG_SetParticleSystemNormal( cent->buildablePS, es->origin2 ); + CG_AttachParticleSystemToCent( cent->buildablePS ); } + else if( healthFrac >= 0.33f && cent->buildablePS != NULL ) + { + CG_DestroyParticleSystem( cent->buildablePS ); + cent->buildablePS = NULL; + } + } } diff --git a/src/cgame/cg_ents.c b/src/cgame/cg_ents.c index 758250a0..dda0e3e0 100644 --- a/src/cgame/cg_ents.c +++ b/src/cgame/cg_ents.c @@ -878,6 +878,8 @@ static void CG_CEntityPVSEnter( centity_t *cent ) cent->jetPackPS = NULL; cent->jetPackState = JPS_OFF; + + cent->buildablePS = NULL; } diff --git a/src/cgame/cg_local.h b/src/cgame/cg_local.h index 5988d22b..af572513 100644 --- a/src/cgame/cg_local.h +++ b/src/cgame/cg_local.h @@ -196,7 +196,9 @@ typedef struct pLerpValues_s //particle template typedef struct baseParticle_s { + vec3_t displacement; float randDisplacement; + float normalDisplacement; pMoveType_t velMoveType; pMoveValues_t velMoveValues; @@ -433,9 +435,7 @@ typedef struct centity_s //TA: buildableAnimNumber_t buildableAnim; //persistant anim number buildableAnimNumber_t oldBuildableAnim; //to detect when new anims are set - int buildableSmokeTime; - int buildableSparkTime; - int buildableBleedTime; + particleSystem_t *buildablePS; float lastFlareSrcRadius; //caching of likely flare source radius float lastFlareRadius; //caching of likely flare radius @@ -1192,6 +1192,9 @@ typedef struct sfxHandle_t buildableRepairedSound; qhandle_t poisonCloudPS; + + qhandle_t humanBuildableDamagedPS; + qhandle_t alienBuildableDamagedPS; } cgMedia_t; diff --git a/src/cgame/cg_main.c b/src/cgame/cg_main.c index 634e2b6c..d5b85231 100644 --- a/src/cgame/cg_main.c +++ b/src/cgame/cg_main.c @@ -794,6 +794,9 @@ static void CG_RegisterGraphics( void ) cgs.media.jetPackHoverPS = CG_RegisterParticleSystem( "jetPackHoverPS" ); cgs.media.jetPackAscendPS = CG_RegisterParticleSystem( "jetPackAscendPS" ); + cgs.media.humanBuildableDamagedPS = CG_RegisterParticleSystem( "humanBuildableDamagedPS" ); + cgs.media.alienBuildableDamagedPS = CG_RegisterParticleSystem( "alienBuildableDamagedPS" ); + // register the inline models cgs.numInlineModels = trap_CM_NumInlineModels( ); diff --git a/src/cgame/cg_particles.c b/src/cgame/cg_particles.c index 56f239de..52b9203e 100644 --- a/src/cgame/cg_particles.c +++ b/src/cgame/cg_particles.c @@ -145,6 +145,7 @@ static particle_t *CG_SpawnNewParticle( baseParticle_t *bp, particleEjector_t *p break; } + VectorAdd( p->origin, bp->displacement, p->origin ); for( j = 0; j <= 2; j++ ) p->origin[ j ] += ( crandom( ) * bp->randDisplacement ); @@ -193,6 +194,10 @@ static particle_t *CG_SpawnNewParticle( baseParticle_t *bp, particleEjector_t *p return NULL; VectorCopy( ps->attachment.normal, p->velocity ); + + //normal displacement + VectorNormalize( p->velocity ); + VectorMA( p->origin, bp->normalDisplacement, p->velocity, p->origin ); break; } @@ -521,7 +526,7 @@ static qboolean CG_ParseParticle( baseParticle_t *bp, char **text_p ) { char *token; float number, randFrac; - + int i; // read optional parameters while( 1 ) @@ -630,24 +635,15 @@ static qboolean CG_ParseParticle( baseParticle_t *bp, char **text_p ) } else if( !Q_stricmp( token, "velocity" ) ) { - token = COM_Parse( text_p ); - if( !token ) - break; - - bp->velMoveValues.dir[ 0 ] = atof_neg( token, qtrue ); - - token = COM_Parse( text_p ); - if( !token ) - break; - - bp->velMoveValues.dir[ 1 ] = atof_neg( token, qtrue ); - - token = COM_Parse( text_p ); - if( !token ) - break; + for( i = 0; i <= 2; i++ ) + { + token = COM_Parse( text_p ); + if( !token ) + break; + + bp->velMoveValues.dir[ i ] = atof_neg( token, qtrue ); + } - bp->velMoveValues.dir[ 2 ] = atof_neg( token, qtrue ); - token = COM_Parse( text_p ); if( !token ) break; @@ -660,24 +656,15 @@ static qboolean CG_ParseParticle( baseParticle_t *bp, char **text_p ) } else if( !Q_stricmp( token, "velocityPoint" ) ) { - token = COM_Parse( text_p ); - if( !token ) - break; - - bp->velMoveValues.point[ 0 ] = atof_neg( token, qtrue ); - - token = COM_Parse( text_p ); - if( !token ) - break; - - bp->velMoveValues.point[ 1 ] = atof_neg( token, qtrue ); - - token = COM_Parse( text_p ); - if( !token ) - break; + for( i = 0; i <= 2; i++ ) + { + token = COM_Parse( text_p ); + if( !token ) + break; + + bp->velMoveValues.point[ i ] = atof_neg( token, qtrue ); + } - bp->velMoveValues.point[ 2 ] = atof_neg( token, qtrue ); - token = COM_Parse( text_p ); if( !token ) break; @@ -734,24 +721,15 @@ static qboolean CG_ParseParticle( baseParticle_t *bp, char **text_p ) } else if( !Q_stricmp( token, "acceleration" ) ) { - token = COM_Parse( text_p ); - if( !token ) - break; - - bp->accMoveValues.dir[ 0 ] = atof_neg( token, qtrue ); - - token = COM_Parse( text_p ); - if( !token ) - break; - - bp->accMoveValues.dir[ 1 ] = atof_neg( token, qtrue ); - - token = COM_Parse( text_p ); - if( !token ) - break; + for( i = 0; i <= 2; i++ ) + { + token = COM_Parse( text_p ); + if( !token ) + break; + + bp->accMoveValues.dir[ i ] = atof_neg( token, qtrue ); + } - bp->accMoveValues.dir[ 2 ] = atof_neg( token, qtrue ); - token = COM_Parse( text_p ); if( !token ) break; @@ -764,42 +742,54 @@ static qboolean CG_ParseParticle( baseParticle_t *bp, char **text_p ) } else if( !Q_stricmp( token, "accelerationPoint" ) ) { - token = COM_Parse( text_p ); - if( !token ) - break; - - bp->accMoveValues.point[ 0 ] = atof_neg( token, qtrue ); + for( i = 0; i <= 2; i++ ) + { + token = COM_Parse( text_p ); + if( !token ) + break; + + bp->accMoveValues.point[ i ] = atof_neg( token, qtrue ); + } token = COM_Parse( text_p ); if( !token ) break; - bp->accMoveValues.point[ 1 ] = atof_neg( token, qtrue ); + CG_ParseValueAndVariance( token, NULL, &randFrac ); - token = COM_Parse( text_p ); - if( !token ) - break; + bp->accMoveValues.pointRandAngle = randFrac; + + continue; + } + /// + else if( !Q_stricmp( token, "displacement" ) ) + { + for( i = 0; i <= 2; i++ ) + { + token = COM_Parse( text_p ); + if( !token ) + break; + + bp->displacement[ i ] = atof_neg( token, qtrue ); + } - bp->accMoveValues.point[ 2 ] = atof_neg( token, qtrue ); - token = COM_Parse( text_p ); if( !token ) break; - + CG_ParseValueAndVariance( token, NULL, &randFrac ); - bp->accMoveValues.pointRandAngle = randFrac; - + bp->randDisplacement = randFrac; + continue; } - /// - else if( !Q_stricmp( token, "randomDisplacement" ) ) + else if( !Q_stricmp( token, "normalDisplacement" ) ) { token = COM_Parse( text_p ); if( !token ) break; - - bp->randDisplacement = atof_neg( token, qtrue ); + + bp->normalDisplacement = atof_neg( token, qtrue ); continue; } diff --git a/src/cgame/cg_weapons.c b/src/cgame/cg_weapons.c index 5a6fc802..ca8a2fb3 100644 --- a/src/cgame/cg_weapons.c +++ b/src/cgame/cg_weapons.c @@ -1639,15 +1639,8 @@ void CG_MissileHitWall( weapon_t weaponNum, weaponMode_t weaponMode, int clientN //create impact particle system if( ps ) { - vec3_t origin2; - particleSystem_t *partSystem = CG_SpawnNewParticleSystem( ps ); - - //move the origin out from the wall a bit - //so particles don't collide with it immediately - VectorMA( origin, 10.0f, dir, origin2 ); - CG_SetParticleSystemOrigin( partSystem, origin2 ); - + CG_SetParticleSystemOrigin( partSystem, origin ); CG_SetParticleSystemNormal( partSystem, dir ); CG_AttachParticleSystemToOrigin( partSystem ); } |