diff options
Diffstat (limited to 'src/cgame')
-rw-r--r-- | src/cgame/cg_weapons.c | 29 |
1 files changed, 22 insertions, 7 deletions
diff --git a/src/cgame/cg_weapons.c b/src/cgame/cg_weapons.c index d5c91aa8..d3c52e13 100644 --- a/src/cgame/cg_weapons.c +++ b/src/cgame/cg_weapons.c @@ -1623,18 +1623,33 @@ Draws the mass driver trail ============== */ +#define MDRIVER_MUZZLE_OFFSET 48.0f + void CG_MassDriverFire( entityState_t *es ) { + vec3_t front, frontToBack; trailSystem_t *ts; + float length; ts = CG_SpawnNewTrailSystem( cgs.media.massDriverTS ); - if( CG_IsTrailSystemValid( &ts ) ) - { - CG_SetAttachmentPoint( &ts->frontAttachment, es->origin2 ); - CG_SetAttachmentPoint( &ts->backAttachment, es->pos.trBase ); - CG_AttachToPoint( &ts->frontAttachment ); - CG_AttachToPoint( &ts->backAttachment ); - } + if( !CG_IsTrailSystemValid( &ts ) ) + return; + + // trail front attaches to the player, needs to be pushed forward a bit + // so that it doesn't look like it shot out of the wrong location + VectorCopy( es->origin2, front ); + VectorSubtract( es->pos.trBase, front, frontToBack ); + length = VectorLength( frontToBack ); + if( length - MDRIVER_MUZZLE_OFFSET < 0.0f ) + return; + VectorScale( frontToBack, 1.0f / length, frontToBack ); + VectorMA( front, MDRIVER_MUZZLE_OFFSET, frontToBack, front ); + CG_SetAttachmentPoint( &ts->frontAttachment, front ); + CG_AttachToPoint( &ts->frontAttachment ); + + // trail back attaches to the impact point + CG_SetAttachmentPoint( &ts->backAttachment, es->pos.trBase ); + CG_AttachToPoint( &ts->backAttachment ); } |