summaryrefslogtreecommitdiff
path: root/src/game/g_missile.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/game/g_missile.c')
-rw-r--r--src/game/g_missile.c114
1 files changed, 42 insertions, 72 deletions
diff --git a/src/game/g_missile.c b/src/game/g_missile.c
index 94381fdc..d7c44dcf 100644
--- a/src/game/g_missile.c
+++ b/src/game/g_missile.c
@@ -24,7 +24,8 @@ G_BounceMissile
================
*/
-void G_BounceMissile( gentity_t *ent, trace_t *trace ) {
+void G_BounceMissile( gentity_t *ent, trace_t *trace )
+{
vec3_t velocity;
float dot;
int hitTime;
@@ -33,18 +34,20 @@ void G_BounceMissile( gentity_t *ent, trace_t *trace ) {
hitTime = level.previousTime + ( level.time - level.previousTime ) * trace->fraction;
BG_EvaluateTrajectoryDelta( &ent->s.pos, hitTime, velocity );
dot = DotProduct( velocity, trace->plane.normal );
- VectorMA( velocity, -2*dot, trace->plane.normal, ent->s.pos.trDelta );
+ VectorMA( velocity, -2 * dot, trace->plane.normal, ent->s.pos.trDelta );
- if ( ent->s.eFlags & EF_BOUNCE_HALF ) {
+ if( ent->s.eFlags & EF_BOUNCE_HALF )
+ {
VectorScale( ent->s.pos.trDelta, 0.65, ent->s.pos.trDelta );
// check for stop
- if ( trace->plane.normal[2] > 0.2 && VectorLength( ent->s.pos.trDelta ) < 40 ) {
+ if( trace->plane.normal[ 2 ] > 0.2 && VectorLength( ent->s.pos.trDelta ) < 40 )
+ {
G_SetOrigin( ent, trace->endpos );
return;
}
}
- VectorAdd( ent->r.currentOrigin, trace->plane.normal, ent->r.currentOrigin);
+ VectorAdd( ent->r.currentOrigin, trace->plane.normal, ent->r.currentOrigin );
VectorCopy( ent->r.currentOrigin, ent->s.pos.trBase );
ent->s.pos.trTime = level.time;
}
@@ -57,7 +60,8 @@ G_ExplodeMissile
Explode a missile without an impact
================
*/
-void G_ExplodeMissile( gentity_t *ent ) {
+void G_ExplodeMissile( gentity_t *ent )
+{
vec3_t dir;
vec3_t origin;
@@ -66,8 +70,8 @@ void G_ExplodeMissile( gentity_t *ent ) {
G_SetOrigin( ent, origin );
// we don't have a valid direction, so just point straight up
- dir[0] = dir[1] = 0;
- dir[2] = 1;
+ dir[ 0 ] = dir[ 1 ] = 0;
+ dir[ 2 ] = 1;
ent->s.eType = ET_GENERAL;
@@ -77,13 +81,13 @@ void G_ExplodeMissile( gentity_t *ent ) {
ent->freeAfterEvent = qtrue;
-/* // splash damage
+ // splash damage
if ( ent->splashDamage ) {
if( G_RadiusDamage( ent->r.currentOrigin, ent->parent, ent->splashDamage, ent->splashRadius, ent
, ent->splashMethodOfDeath ) ) {
g_entities[ent->r.ownerNum].client->accuracy_hits++;
}
- }*/
+ }
trap_LinkEntity( ent );
}
@@ -95,33 +99,37 @@ G_MissileImpact
================
*/
-void G_MissileImpact( gentity_t *ent, trace_t *trace ) {
+void G_MissileImpact( gentity_t *ent, trace_t *trace )
+{
gentity_t *other;
qboolean hitClient = qfalse;
- other = &g_entities[trace->entityNum];
+ other = &g_entities[ trace->entityNum ];
// check for bounce
- if ( !other->takedamage &&
- ( ent->s.eFlags & ( EF_BOUNCE | EF_BOUNCE_HALF ) ) ) {
+ if( !other->takedamage &&
+ ( ent->s.eFlags & ( EF_BOUNCE | EF_BOUNCE_HALF ) ) )
+ {
G_BounceMissile( ent, trace );
G_AddEvent( ent, EV_GRENADE_BOUNCE, 0 );
return;
}
// impact damage
- if (other->takedamage) {
+ if( other->takedamage )
+ {
// FIXME: wrong damage direction?
- if ( ent->damage ) {
+ if( ent->damage )
+ {
vec3_t velocity;
BG_EvaluateTrajectoryDelta( &ent->s.pos, level.time, velocity );
- if ( VectorLength( velocity ) == 0 ) {
- velocity[2] = 1; // stepped on a grenade
- }
- G_Damage (other, ent, &g_entities[ent->r.ownerNum], velocity,
+ if( VectorLength( velocity ) == 0 )
+ velocity[ 2 ] = 1; // stepped on a grenade
+
+ G_Damage( other, ent, &g_entities[ ent->r.ownerNum ], velocity,
ent->s.origin, ent->damage,
- 0, ent->methodOfDeath);
+ 0, ent->methodOfDeath );
}
}
@@ -147,14 +155,15 @@ void G_MissileImpact( gentity_t *ent, trace_t *trace ) {
// is it cheaper in bandwidth to just remove this ent and create a new
// one, rather than changing the missile into the explosion?
- if ( other->takedamage && other->client ) {
+ if( other->takedamage && other->client )
+ {
G_AddEvent( ent, EV_MISSILE_HIT, DirToByte( trace->plane.normal ) );
ent->s.otherEntityNum = other->s.number;
- } else if( trace->surfaceFlags & SURF_METALSTEPS ) {
+ }
+ else if( trace->surfaceFlags & SURF_METALSTEPS )
G_AddEvent( ent, EV_MISSILE_MISS_METAL, DirToByte( trace->plane.normal ) );
- } else {
+ else
G_AddEvent( ent, EV_MISSILE_MISS, DirToByte( trace->plane.normal ) );
- }
ent->freeAfterEvent = qtrue;
@@ -166,12 +175,13 @@ void G_MissileImpact( gentity_t *ent, trace_t *trace ) {
G_SetOrigin( ent, trace->endpos );
// splash damage (doesn't apply to person directly hit)
- if ( ent->splashDamage ) {
+ if( ent->splashDamage )
+ {
if( G_RadiusDamage( trace->endpos, ent->parent, ent->splashDamage, ent->splashRadius,
- other, ent->splashMethodOfDeath ) ) {
- if( !hitClient ) {
- g_entities[ent->r.ownerNum].client->accuracy_hits++;
- }
+ other, ent->splashMethodOfDeath ) )
+ {
+ if( !hitClient )
+ g_entities[ ent->r.ownerNum ].client->accuracy_hits++;
}
}
@@ -221,10 +231,10 @@ void G_RunMissile( gentity_t *ent )
if( tr.fraction != 1 )
{
// never explode or bounce on sky
- if ( tr.surfaceFlags & SURF_NOIMPACT )
+ if( tr.surfaceFlags & SURF_NOIMPACT )
{
// If grapple, reset owner
- if (ent->parent && ent->parent->client && ent->parent->client->hook == ent)
+ if( ent->parent && ent->parent->client && ent->parent->client->hook == ent )
ent->parent->client->hook = NULL;
G_FreeEntity( ent );
@@ -289,46 +299,6 @@ gentity_t *fire_flamer( gentity_t *self, vec3_t start, vec3_t dir )
/*
=================
-fire_plasma
-
-=================
-*/
-gentity_t *fire_plasma( gentity_t *self, vec3_t start, vec3_t dir )
-{
- gentity_t *bolt;
-
- VectorNormalize (dir);
-
- bolt = G_Spawn();
- bolt->classname = "plasma";
- bolt->nextthink = level.time + 10000;
- bolt->think = G_ExplodeMissile;
- bolt->s.eType = ET_MISSILE;
- bolt->r.svFlags = SVF_USE_CURRENT_ORIGIN;
- bolt->s.weapon = WP_PLASMAGUN;
- bolt->r.ownerNum = self->s.number;
- bolt->parent = self;
- bolt->damage = 20;
- bolt->splashDamage = 15;
- bolt->splashRadius = 20;
- //bolt->methodOfDeath = MOD_FLAMER;
- //bolt->splashMethodOfDeath = MOD_FLAMER_SPLASH;
- bolt->clipmask = MASK_SHOT;
- bolt->target_ent = NULL;
-
- bolt->s.pos.trType = TR_LINEAR;
- bolt->s.pos.trTime = level.time - MISSILE_PRESTEP_TIME; // move a bit on the very first frame
- VectorCopy( start, bolt->s.pos.trBase );
- VectorScale( dir, 2000, bolt->s.pos.trDelta );
- SnapVector( bolt->s.pos.trDelta ); // save net bandwidth
-
- VectorCopy (start, bolt->r.currentOrigin);
-
- return bolt;
-}
-
-/*
-=================
fire_pulseRifle
=================