Skip to content

Commit

Permalink
Misc tracer improvments:
Browse files Browse the repository at this point in the history
- Make tracers work with local client in both first and third person.
- Make tracers work with the shotgun.
- Don't spawn additional tracers inside the shotgun's muzzle partice system.
- Don't play a tracer sound as this makes the shotgung sound bad,
  • Loading branch information
Viech committed Dec 22, 2014
1 parent f6819ee commit 317523b
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 84 deletions.
33 changes: 1 addition & 32 deletions main/scripts/shotgun.particle
Original file line number Diff line number Diff line change
Expand Up @@ -127,37 +127,6 @@ ejector

ShotgunMuzzleFlash
{
ejector
{
particle
{
displacement 8 0 0 ~3

velocityType cent
velocityDir linear
velocityMagnitude 2500
velocity 1 0 0 ~10

accelerationType static
accelerationDir linear
accelerationMagnitude 500
acceleration 0 0 -1 0

parentVelocityFraction 0.0

radius 0 50 15
alpha 0 1.0 1.0
bounce 0
rotation 0 0 50
lifeTime 90

childTrailSystem shotgunsparks
}

count 5~50%
delay 0
period 0 1 4~10%
}
ejector
{
particle
Expand Down Expand Up @@ -252,4 +221,4 @@ ShotgunMuzzleFlash
delay 50
period 0 - ~0%
}
}
}
15 changes: 0 additions & 15 deletions main/scripts/shotgun.trail

This file was deleted.

1 change: 0 additions & 1 deletion src/gamelogic/cgame/cg_local.h
Original file line number Diff line number Diff line change
Expand Up @@ -1503,7 +1503,6 @@ typedef struct
qhandle_t disconnectSound;

// sounds
sfxHandle_t tracerSound;
sfxHandle_t weaponEmptyClick;
sfxHandle_t selectSound;
sfxHandle_t footsteps[ FOOTSTEP_TOTAL ][ 4 ];
Expand Down
1 change: 0 additions & 1 deletion src/gamelogic/cgame/cg_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1138,7 +1138,6 @@ static void CG_RegisterSounds( void )
cgs.media.alienL4ChargePrepare = trap_S_RegisterSound( "sound/player/level4/charge_prepare.wav", qtrue );
cgs.media.alienL4ChargeStart = trap_S_RegisterSound( "sound/player/level4/charge_start.wav", qtrue );

cgs.media.tracerSound = trap_S_RegisterSound( "sound/weapons/tracer.wav", qfalse );
cgs.media.selectSound = trap_S_RegisterSound( "sound/weapons/change.wav", qfalse );
cgs.media.turretSpinupSound = trap_S_RegisterSound( "sound/buildables/mgturret/spinup.wav", qfalse );
cgs.media.weaponEmptyClick = trap_S_RegisterSound( "sound/weapons/click.wav", qfalse );
Expand Down
51 changes: 16 additions & 35 deletions src/gamelogic/cgame/cg_weapons.c
Original file line number Diff line number Diff line change
Expand Up @@ -2389,27 +2389,18 @@ TODO: Put this into cg_event_weapon.c?

static qboolean CalcMuzzlePoint( int entityNum, vec3_t muzzle )
{
vec3_t forward;
centity_t *cent;

if ( entityNum < 0 || entityNum >= MAX_ENTITIES )
{
return qfalse;
}

if ( entityNum == cg.snap->ps.clientNum )
if ( entityNum == cg.predictedPlayerState.clientNum )
{
VectorCopy( cg.snap->ps.origin, muzzle );
muzzle[ 2 ] += cg.snap->ps.viewheight;
AngleVectors( cg.snap->ps.viewangles, forward, NULL, NULL );
VectorMA( muzzle, 14, forward, muzzle );

return qtrue;
cent = &cg.predictedPlayerEntity;
}

cent = &cg_entities[ entityNum ];

if ( !cent->currentValid )
else if ( !( cent = &cg_entities[ entityNum ] ) || !cent->currentValid )
{
return qfalse;
}
Expand Down Expand Up @@ -2532,37 +2523,34 @@ static void DrawEntityHitEffect( vec3_t origin, vec3_t normal, int targetNum )
}
}

#define TRACER_MIN_DISTANCE 100.0f

// TODO: Use a trail system to make the effect framerate independent.
static void DrawTracer( vec3_t source, vec3_t dest, float chance, float length, float width )
{
vec3_t forward, right;
polyVert_t verts[ 4 ];
vec3_t line;
float len, begin, end;
float distance, begin, end;
vec3_t start, finish;
vec3_t midpoint;

if ( random() >= chance )
{
return;
}

// tracer
VectorSubtract( dest, source, forward );
len = VectorNormalize( forward );
distance = VectorNormalize( forward );

// start at least a little ways from the muzzle
if ( len < 100 )
// Start at least a little away from the muzzle.
if ( distance < TRACER_MIN_DISTANCE )
{
return;
}

begin = 50 + random() * ( len - 60 );
end = begin + length;

if ( end > len )
{
end = len;
}
// Guarantee a minimum length of 1/4 * length.
begin = random() * Q_clamp( distance - 0.25f * length, TRACER_MIN_DISTANCE, distance );
end = Q_clamp( begin + length, begin, distance );

VectorMA( source, begin, forward, start );
VectorMA( source, end, forward, finish );
Expand Down Expand Up @@ -2607,13 +2595,6 @@ static void DrawTracer( vec3_t source, vec3_t dest, float chance, float length,
verts[ 3 ].modulate[ 3 ] = 255;

trap_R_AddPolyToScene( cgs.media.tracerShader, 4, verts );

midpoint[ 0 ] = ( start[ 0 ] + finish[ 0 ] ) * 0.5;
midpoint[ 1 ] = ( start[ 1 ] + finish[ 1 ] ) * 0.5;
midpoint[ 2 ] = ( start[ 2 ] + finish[ 2 ] ) * 0.5;

// add the tracer sound
trap_S_StartSound( midpoint, ENTITYNUM_WORLD, CHAN_AUTO, cgs.media.tracerSound );
}

/*
Expand All @@ -2622,7 +2603,7 @@ Performs the same traces the server did to locate local hit effects.
Keep this in sync with ShotgunPattern in g_weapon.c!
================
*/
static void ShotgunPattern( vec3_t origin, vec3_t origin2, int seed, int otherEntNum )
static void ShotgunPattern( vec3_t origin, vec3_t origin2, int seed, int attackerNum )
{
int i;
float r, u, a;
Expand Down Expand Up @@ -2650,15 +2631,15 @@ static void ShotgunPattern( vec3_t origin, vec3_t origin2, int seed, int otherEn
VectorMA( end, r, right, end );
VectorMA( end, u, up, end );

CG_Trace( &tr, origin, NULL, NULL, end, otherEntNum, MASK_SHOT, 0 );
CG_Trace( &tr, origin, NULL, NULL, end, attackerNum, MASK_SHOT, 0 );

if ( !( tr.surfaceFlags & SURF_NOIMPACT ) )
{
dummy.weapon = WP_SHOTGUN;
dummy.generic1 = WPM_PRIMARY;
dummy.eventParm = DirToByte( tr.plane.normal );
dummy.otherEntityNum = tr.entityNum;
dummy.otherEntityNum2 = 0; // TODO: Set attackerNum
dummy.otherEntityNum2 = attackerNum;
dummy.torsoAnim = 0; // Make sure it is not used uninitialized

if ( cg_entities[ tr.entityNum ].currentState.eType == ET_PLAYER ||
Expand Down

0 comments on commit 317523b

Please sign in to comment.