Skip to content

Commit

Permalink
playertrails
Browse files Browse the repository at this point in the history
  • Loading branch information
Warfork committed Sep 13, 2023
1 parent 709bd81 commit 7b3bab2
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 0 deletions.
35 changes: 35 additions & 0 deletions source/cgame/cg_effects.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -550,6 +550,41 @@ static void CG_ClearParticles( void )
( p )->fog = true \
)

extern cvar_t *cg_playerTrailsColor;

void CG_AddLinearTrail( centity_t *cent, float lifetime )
{
cparticle_t *p;
float r, g, b;

if( cg_numparticles + 1 > MAX_PARTICLES )
return;

if( cg_playerTrailsColor->string != NULL && sscanf( cg_playerTrailsColor->string, "%f %f %f", &r, &g, &b ) == 3 ) {
if( r < 0.0f )

This comment has been minimized.

Copy link
@learn-more

learn-more Sep 13, 2023

Collaborator
clamp( r, 0.0f, 1.0f );
clamp( g, 0.0f, 1.0f );
clamp( b, 0.0f, 1.0f );
r = 0.0f;
if( r > 1.0f )
r = 1.0f;
if( g < 0.0f )
g = 0.0f;
if( g > 1.0f )
g = 1.0f;
if( b < 0.0f )
b = 0.0f;
if( b > 1.0f )
b = 1.0f;
} else {
r = 0.0f;
g = 1.0f;
b = 0.0f;
}

p = &particles[cg_numparticles++];
CG_InitParticle( p, 1.0f, 1.0f, r, g, b, NULL );
VectorCopy( cent->ent.origin, p->org );
p->alphavel = -( 1.0f / lifetime );
}

/*
* CG_ParticleEffect
*
Expand Down
2 changes: 2 additions & 0 deletions source/cgame/cg_local.h
Original file line number Diff line number Diff line change
Expand Up @@ -924,6 +924,7 @@ extern cvar_t *cg_predictLaserBeam;
extern cvar_t *cg_voiceChats;
extern cvar_t *cg_shadows;
extern cvar_t *cg_showSelfShadow;
extern cvar_t *cg_showPlayerTrails;
extern cvar_t *cg_laserBeamSubdivisions;
extern cvar_t *cg_projectileAntilagOffset;
extern cvar_t *cg_raceGhosts;
Expand Down Expand Up @@ -1153,6 +1154,7 @@ void CG_ParticleEffect2( const vec3_t org, const vec3_t dir, float r, float g, f
void CG_ParticleExplosionEffect( const vec3_t org, const vec3_t dir, float r, float g, float b, int count );
void CG_BlasterTrail( const vec3_t start, const vec3_t end );
void CG_FlyEffect( centity_t *ent, const vec3_t origin );
void CG_AddLinearTrail( centity_t *cent, float lifetime );
void CG_ElectroIonsTrail( const vec3_t start, const vec3_t end, const vec4_t color );
void CG_ElectroIonsTrail2( const vec3_t start, const vec3_t end, const vec4_t color );
void CG_ElectroWeakTrail( const vec3_t start, const vec3_t end, const vec4_t color );
Expand Down
5 changes: 5 additions & 0 deletions source/cgame/cg_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ cvar_t *cg_predictLaserBeam;
cvar_t *cg_voiceChats;
cvar_t *cg_shadows;
cvar_t *cg_showSelfShadow;
cvar_t *cg_showPlayerTrails;
cvar_t *cg_playerTrailsColor;
cvar_t *cg_laserBeamSubdivisions;
cvar_t *cg_projectileAntilagOffset;
cvar_t *cg_raceGhosts;
Expand Down Expand Up @@ -822,6 +824,9 @@ static void CG_RegisterVariables( void )
cg_voiceChats = trap_Cvar_Get( "cg_voiceChats", "1", CVAR_ARCHIVE );
cg_shadows = trap_Cvar_Get( "cg_shadows", "1", CVAR_ARCHIVE );

cg_showPlayerTrails = trap_Cvar_Get( "cg_showPlayerTrails", "0", CVAR_ARCHIVE );
cg_playerTrailsColor = trap_Cvar_Get( "cg_playerTrailsColor", "0.0 1.0 0.0", CVAR_ARCHIVE );

cg_laserBeamSubdivisions = trap_Cvar_Get( "cg_laserBeamSubdivisions", "10", CVAR_ARCHIVE );
cg_projectileAntilagOffset = trap_Cvar_Get( "cg_projectileAntilagOffset", "1.0", CVAR_ARCHIVE );

Expand Down
3 changes: 3 additions & 0 deletions source/cgame/cg_pmodels.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1315,6 +1315,9 @@ void CG_AddPModel( centity_t *cent )

CG_AddHeadIcon( cent );

if( cg_showPlayerTrails->value )
CG_AddLinearTrail( cent, cg_showPlayerTrails->value );

// add teleporter sfx if needed
CG_PModel_SpawnTeleportEffect( cent );

Expand Down

0 comments on commit 7b3bab2

Please sign in to comment.