summaryrefslogtreecommitdiff
path: root/src/cgame/cg_weapons.c
diff options
context:
space:
mode:
authorMichael Levin <risujin@fastmail.fm>2009-10-03 11:17:37 +0000
committerTim Angus <tim@ngus.net>2013-01-03 00:14:51 +0000
commita0c96de3cd2b5fd1b57276caafc07e17a54d001a (patch)
tree62bd36fdfa3e4a6fb6878898010d7cf3711f0a3a /src/cgame/cg_weapons.c
parent6916f8fb5d3a19bf0bdfb84948b19445954306d9 (diff)
Some more work on the Mass Driver:
* Fixed a bug in SnapVectorTowards which would snap incorrectly if the point was below the world origin. Also added an analogous function to work with normals (SnapVectorNormal). * Added weapon.cfg to source control to set alwaysImpact (to show flash along with blood spurt when hitting a player). * The maximum number of hits allowed moved to tremulous.h, set MDRIVER_MAX_HITS. * Since a the visual effects changed, removed old massDriverFire() function and toggle switch.
Diffstat (limited to 'src/cgame/cg_weapons.c')
-rw-r--r--src/cgame/cg_weapons.c29
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 );
}