Main Page | Class Hierarchy | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals

g_missile.c File Reference

#include "g_local.h"

Include dependency graph for g_missile.c:

Include dependency graph

Go to the source code of this file.

Defines

#define MISSILE_PRESTEP_TIME   50

Functions

gentity_tfire_bfg (gentity_t *self, vec3_t start, vec3_t dir)
gentity_tfire_grapple (gentity_t *self, vec3_t start, vec3_t dir)
gentity_tfire_grenade (gentity_t *self, vec3_t start, vec3_t dir)
gentity_tfire_plasma (gentity_t *self, vec3_t start, vec3_t dir)
gentity_tfire_rocket (gentity_t *self, vec3_t start, vec3_t dir)
void G_BounceMissile (gentity_t *ent, trace_t *trace)
void G_ExplodeMissile (gentity_t *ent)
void G_MissileImpact (gentity_t *ent, trace_t *trace)
void G_RunMissile (gentity_t *ent)


Define Documentation

#define MISSILE_PRESTEP_TIME   50
 

Definition at line 25 of file g_missile.c.


Function Documentation

gentity_t* fire_bfg gentity_t self,
vec3_t  start,
vec3_t  dir
 

Definition at line 604 of file g_missile.c.

References gentity_s::classname, gentity_s::clipmask, entityShared_t::currentOrigin, gentity_s::damage, entityState_s::eType, G_Spawn(), gentity_t, level, gentity_s::methodOfDeath, gentity_s::nextthink, entityState_s::number, entityShared_t::ownerNum, gentity_s::parent, entityState_s::pos, gentity_s::r, entityShared_t::s, gentity_s::s, SnapVector, gentity_s::splashDamage, gentity_s::splashMethodOfDeath, gentity_s::splashRadius, entityShared_t::svFlags, gentity_s::target_ent, gentity_s::think, level_locals_t::time, trajectory_t::trBase, trajectory_t::trDelta, trajectory_t::trTime, trajectory_t::trType, VectorCopy, VectorNormalize(), VectorScale, and entityState_s::weapon.

Referenced by BFG_Fire().

00604                                                                 {
00605     gentity_t   *bolt;
00606 
00607     VectorNormalize (dir);
00608 
00609     bolt = G_Spawn();
00610     bolt->classname = "bfg";
00611     bolt->nextthink = level.time + 10000;
00612     bolt->think = G_ExplodeMissile;
00613     bolt->s.eType = ET_MISSILE;
00614     bolt->r.svFlags = SVF_USE_CURRENT_ORIGIN;
00615     bolt->s.weapon = WP_BFG;
00616     bolt->r.ownerNum = self->s.number;
00617     bolt->parent = self;
00618     bolt->damage = 100;
00619     bolt->splashDamage = 100;
00620     bolt->splashRadius = 120;
00621     bolt->methodOfDeath = MOD_BFG;
00622     bolt->splashMethodOfDeath = MOD_BFG_SPLASH;
00623     bolt->clipmask = MASK_SHOT;
00624     bolt->target_ent = NULL;
00625 
00626     bolt->s.pos.trType = TR_LINEAR;
00627     bolt->s.pos.trTime = level.time - MISSILE_PRESTEP_TIME;     // move a bit on the very first frame
00628     VectorCopy( start, bolt->s.pos.trBase );
00629     VectorScale( dir, 2000, bolt->s.pos.trDelta );
00630     SnapVector( bolt->s.pos.trDelta );          // save net bandwidth
00631     VectorCopy (start, bolt->r.currentOrigin);
00632 
00633     return bolt;
00634 }

Here is the call graph for this function:

gentity_t* fire_grapple gentity_t self,
vec3_t  start,
vec3_t  dir
 

Definition at line 681 of file g_missile.c.

References gentity_s::classname, gentity_s::clipmask, entityShared_t::currentOrigin, entityState_s::eType, G_Spawn(), gentity_t, level, gentity_s::methodOfDeath, gentity_s::nextthink, entityState_s::number, entityState_s::otherEntityNum, entityShared_t::ownerNum, gentity_s::parent, entityState_s::pos, gentity_s::r, entityShared_t::s, gentity_s::s, SnapVector, entityShared_t::svFlags, gentity_s::target_ent, gentity_s::think, level_locals_t::time, trajectory_t::trBase, trajectory_t::trDelta, trajectory_t::trTime, trajectory_t::trType, VectorCopy, VectorNormalize(), VectorScale, and entityState_s::weapon.

Referenced by Weapon_GrapplingHook_Fire().

00681                                                                     {
00682     gentity_t   *hook;
00683 
00684     VectorNormalize (dir);
00685 
00686     hook = G_Spawn();
00687     hook->classname = "hook";
00688     hook->nextthink = level.time + 10000;
00689     hook->think = Weapon_HookFree;
00690     hook->s.eType = ET_MISSILE;
00691     hook->r.svFlags = SVF_USE_CURRENT_ORIGIN;
00692     hook->s.weapon = WP_GRAPPLING_HOOK;
00693     hook->r.ownerNum = self->s.number;
00694     hook->methodOfDeath = MOD_GRAPPLE;
00695     hook->clipmask = MASK_SHOT;
00696     hook->parent = self;
00697     hook->target_ent = NULL;
00698 
00699     hook->s.pos.trType = TR_LINEAR;
00700     hook->s.pos.trTime = level.time - MISSILE_PRESTEP_TIME;     // move a bit on the very first frame
00701     hook->s.otherEntityNum = self->s.number; // use to match beam in client
00702     VectorCopy( start, hook->s.pos.trBase );
00703     VectorScale( dir, 800, hook->s.pos.trDelta );
00704     SnapVector( hook->s.pos.trDelta );          // save net bandwidth
00705     VectorCopy (start, hook->r.currentOrigin);
00706 
00707     self->client->hook = hook;
00708 
00709     return hook;
00710 }

Here is the call graph for this function:

gentity_t* fire_grenade gentity_t self,
vec3_t  start,
vec3_t  dir
 

Definition at line 562 of file g_missile.c.

References gentity_s::classname, gentity_s::clipmask, entityShared_t::currentOrigin, gentity_s::damage, entityState_s::eFlags, entityState_s::eType, G_Spawn(), gentity_t, level, gentity_s::methodOfDeath, gentity_s::nextthink, entityState_s::number, entityShared_t::ownerNum, gentity_s::parent, entityState_s::pos, gentity_s::r, entityShared_t::s, gentity_s::s, SnapVector, gentity_s::splashDamage, gentity_s::splashMethodOfDeath, gentity_s::splashRadius, entityShared_t::svFlags, gentity_s::target_ent, gentity_s::think, level_locals_t::time, trajectory_t::trBase, trajectory_t::trDelta, trajectory_t::trTime, trajectory_t::trType, VectorCopy, VectorNormalize(), VectorScale, and entityState_s::weapon.

Referenced by Use_Shooter(), and weapon_grenadelauncher_fire().

00562                                                                     {
00563     gentity_t   *bolt;
00564 
00565     VectorNormalize (dir);
00566 
00567     bolt = G_Spawn();
00568     bolt->classname = "grenade";
00569     bolt->nextthink = level.time + 2500;
00570     bolt->think = G_ExplodeMissile;
00571     bolt->s.eType = ET_MISSILE;
00572     bolt->r.svFlags = SVF_USE_CURRENT_ORIGIN;
00573     bolt->s.weapon = WP_GRENADE_LAUNCHER;
00574     bolt->s.eFlags = EF_BOUNCE_HALF;
00575     bolt->r.ownerNum = self->s.number;
00576     bolt->parent = self;
00577     bolt->damage = 100;
00578     bolt->splashDamage = 100;
00579     bolt->splashRadius = 150;
00580     bolt->methodOfDeath = MOD_GRENADE;
00581     bolt->splashMethodOfDeath = MOD_GRENADE_SPLASH;
00582     bolt->clipmask = MASK_SHOT;
00583     bolt->target_ent = NULL;
00584 
00585     bolt->s.pos.trType = TR_GRAVITY;
00586     bolt->s.pos.trTime = level.time - MISSILE_PRESTEP_TIME;     // move a bit on the very first frame
00587     VectorCopy( start, bolt->s.pos.trBase );
00588     VectorScale( dir, 700, bolt->s.pos.trDelta );
00589     SnapVector( bolt->s.pos.trDelta );          // save net bandwidth
00590 
00591     VectorCopy (start, bolt->r.currentOrigin);
00592 
00593     return bolt;
00594 }

Here is the call graph for this function:

gentity_t* fire_plasma gentity_t self,
vec3_t  start,
vec3_t  dir
 

Definition at line 521 of file g_missile.c.

References gentity_s::classname, gentity_s::clipmask, entityShared_t::currentOrigin, gentity_s::damage, entityState_s::eType, G_Spawn(), gentity_t, level, gentity_s::methodOfDeath, gentity_s::nextthink, entityState_s::number, entityShared_t::ownerNum, gentity_s::parent, entityState_s::pos, gentity_s::r, entityShared_t::s, gentity_s::s, SnapVector, gentity_s::splashDamage, gentity_s::splashMethodOfDeath, gentity_s::splashRadius, entityShared_t::svFlags, gentity_s::target_ent, gentity_s::think, level_locals_t::time, trajectory_t::trBase, trajectory_t::trDelta, trajectory_t::trTime, trajectory_t::trType, VectorCopy, VectorNormalize(), VectorScale, and entityState_s::weapon.

Referenced by Use_Shooter(), and Weapon_Plasmagun_Fire().

00521                                                                    {
00522     gentity_t   *bolt;
00523 
00524     VectorNormalize (dir);
00525 
00526     bolt = G_Spawn();
00527     bolt->classname = "plasma";
00528     bolt->nextthink = level.time + 10000;
00529     bolt->think = G_ExplodeMissile;
00530     bolt->s.eType = ET_MISSILE;
00531     bolt->r.svFlags = SVF_USE_CURRENT_ORIGIN;
00532     bolt->s.weapon = WP_PLASMAGUN;
00533     bolt->r.ownerNum = self->s.number;
00534     bolt->parent = self;
00535     bolt->damage = 20;
00536     bolt->splashDamage = 15;
00537     bolt->splashRadius = 20;
00538     bolt->methodOfDeath = MOD_PLASMA;
00539     bolt->splashMethodOfDeath = MOD_PLASMA_SPLASH;
00540     bolt->clipmask = MASK_SHOT;
00541     bolt->target_ent = NULL;
00542 
00543     bolt->s.pos.trType = TR_LINEAR;
00544     bolt->s.pos.trTime = level.time - MISSILE_PRESTEP_TIME;     // move a bit on the very first frame
00545     VectorCopy( start, bolt->s.pos.trBase );
00546     VectorScale( dir, 2000, bolt->s.pos.trDelta );
00547     SnapVector( bolt->s.pos.trDelta );          // save net bandwidth
00548 
00549     VectorCopy (start, bolt->r.currentOrigin);
00550 
00551     return bolt;
00552 }   

Here is the call graph for this function:

gentity_t* fire_rocket gentity_t self,
vec3_t  start,
vec3_t  dir
 

Definition at line 644 of file g_missile.c.

References gentity_s::classname, gentity_s::clipmask, entityShared_t::currentOrigin, gentity_s::damage, entityState_s::eType, G_Spawn(), gentity_t, level, gentity_s::methodOfDeath, gentity_s::nextthink, entityState_s::number, entityShared_t::ownerNum, gentity_s::parent, entityState_s::pos, gentity_s::r, entityShared_t::s, gentity_s::s, SnapVector, gentity_s::splashDamage, gentity_s::splashMethodOfDeath, gentity_s::splashRadius, entityShared_t::svFlags, gentity_s::target_ent, gentity_s::think, level_locals_t::time, trajectory_t::trBase, trajectory_t::trDelta, trajectory_t::trTime, trajectory_t::trType, VectorCopy, VectorNormalize(), VectorScale, and entityState_s::weapon.

Referenced by Use_Shooter(), and Weapon_RocketLauncher_Fire().

00644                                                                    {
00645     gentity_t   *bolt;
00646 
00647     VectorNormalize (dir);
00648 
00649     bolt = G_Spawn();
00650     bolt->classname = "rocket";
00651     bolt->nextthink = level.time + 1;
00652     bolt->think = G_ExplodeMissile;
00653     bolt->s.eType = ET_MISSILE;
00654     bolt->r.svFlags = SVF_USE_CURRENT_ORIGIN;
00655     bolt->s.weapon = WP_ROCKET_LAUNCHER;
00656     bolt->r.ownerNum = self->s.number;
00657     bolt->parent = self;
00658     bolt->damage = 1000;
00659     bolt->splashDamage = 1000;
00660     bolt->splashRadius = 1200;
00661     bolt->methodOfDeath = MOD_ROCKET;
00662     bolt->splashMethodOfDeath = MOD_ROCKET_SPLASH;
00663     bolt->clipmask = MASK_SHOT;
00664     bolt->target_ent = NULL;
00665 
00666     bolt->s.pos.trType = TR_LINEAR;
00667     bolt->s.pos.trTime = level.time - MISSILE_PRESTEP_TIME;     // move a bit on the very first frame
00668     VectorCopy( start, bolt->s.pos.trBase );
00669     VectorScale( dir, 900, bolt->s.pos.trDelta );
00670     SnapVector( bolt->s.pos.trDelta );          // save net bandwidth
00671     VectorCopy (start, bolt->r.currentOrigin);
00672 
00673     return bolt;
00674 }

Here is the call graph for this function:

void G_BounceMissile gentity_t ent,
trace_t trace
 

Definition at line 33 of file g_missile.c.

References BG_EvaluateTrajectoryDelta(), entityShared_t::currentOrigin, DotProduct, entityState_s::eFlags, trace_t::endpos, trace_t::fraction, G_SetOrigin(), gentity_t, level, cplane_s::normal, trace_t::plane, entityState_s::pos, level_locals_t::previousTime, gentity_s::r, gentity_s::s, level_locals_t::time, trajectory_t::trBase, trajectory_t::trDelta, trajectory_t::trTime, vec3_t, VectorAdd, VectorCopy, VectorLength(), VectorMA, and VectorScale.

Referenced by G_MissileImpact().

00033                                                        {
00034     vec3_t  velocity;
00035     float   dot;
00036     int     hitTime;
00037 
00038     // reflect the velocity on the trace plane
00039     hitTime = level.previousTime + ( level.time - level.previousTime ) * trace->fraction;
00040     BG_EvaluateTrajectoryDelta( &ent->s.pos, hitTime, velocity );
00041     dot = DotProduct( velocity, trace->plane.normal );
00042     VectorMA( velocity, -2*dot, trace->plane.normal, ent->s.pos.trDelta );
00043 
00044     if ( ent->s.eFlags & EF_BOUNCE_HALF ) {
00045         VectorScale( ent->s.pos.trDelta, 0.65, ent->s.pos.trDelta );
00046         // check for stop
00047         if ( trace->plane.normal[2] > 0.2 && VectorLength( ent->s.pos.trDelta ) < 40 ) {
00048             G_SetOrigin( ent, trace->endpos );
00049             return;
00050         }
00051     }
00052 
00053     VectorAdd( ent->r.currentOrigin, trace->plane.normal, ent->r.currentOrigin);
00054     VectorCopy( ent->r.currentOrigin, ent->s.pos.trBase );
00055     ent->s.pos.trTime = level.time;
00056 }

Here is the call graph for this function:

void G_ExplodeMissile gentity_t ent  ) 
 

Definition at line 66 of file g_missile.c.

References gclient_s::accuracy_hits, BG_EvaluateTrajectory(), gentity_s::client, entityShared_t::currentOrigin, DirToByte(), entityState_s::eType, EV_MISSILE_MISS, gentity_s::freeAfterEvent, G_AddEvent(), g_entities, G_RadiusDamage(), G_SetOrigin(), gentity_t, level, entityShared_t::ownerNum, gentity_s::parent, entityState_s::pos, gentity_s::r, gentity_s::s, SnapVector, gentity_s::splashDamage, gentity_s::splashMethodOfDeath, gentity_s::splashRadius, level_locals_t::time, trap_LinkEntity(), and vec3_t.

Referenced by G_MoverPush().

00066                                         {
00067     vec3_t      dir;
00068     vec3_t      origin;
00069 
00070     BG_EvaluateTrajectory( &ent->s.pos, level.time, origin );
00071     SnapVector( origin );
00072     G_SetOrigin( ent, origin );
00073 
00074     // we don't have a valid direction, so just point straight up
00075     dir[0] = dir[1] = 0;
00076     dir[2] = 1;
00077 
00078     ent->s.eType = ET_GENERAL;
00079     G_AddEvent( ent, EV_MISSILE_MISS, DirToByte( dir ) );
00080 
00081     ent->freeAfterEvent = qtrue;
00082 
00083     // splash damage
00084     if ( ent->splashDamage ) {
00085         if( G_RadiusDamage( ent->r.currentOrigin, ent->parent, ent->splashDamage, ent->splashRadius, ent
00086             , ent->splashMethodOfDeath ) ) {
00087             g_entities[ent->r.ownerNum].client->accuracy_hits++;
00088         }
00089     }
00090 
00091     trap_LinkEntity( ent );
00092 }

Here is the call graph for this function:

void G_MissileImpact gentity_t ent,
trace_t trace
 

Definition at line 269 of file g_missile.c.

References gclient_s::accuracy_hits, entityState_s::angles, BG_EvaluateTrajectoryDelta(), gentity_s::classname, gentity_s::client, entityShared_t::currentOrigin, gentity_s::damage, gentity_s::die, DirToByte(), EF_BOUNCE, entityState_s::eFlags, trace_t::endpos, gentity_s::enemy, trace_t::entityNum, ET_PLAYER, entityState_s::eType, EV_GRENADE_BOUNCE, EV_MISSILE_HIT, EV_MISSILE_MISS, EV_MISSILE_MISS_METAL, EV_PROXIMITY_MINE_STICK, gentity_s::freeAfterEvent, G_AddEvent(), G_BounceMissile(), G_Damage(), g_entities, G_InvulnerabilityEffect(), G_RadiusDamage(), G_SetOrigin(), G_Spawn(), gentity_t, playerState_s::grapplePoint, gentity_s::health, level, LogAccuracyHit(), entityShared_t::maxs, gentity_s::methodOfDeath, entityShared_t::mins, gentity_s::movedir, gentity_s::nextthink, cplane_s::normal, entityState_s::number, entityState_s::origin, entityState_s::otherEntityNum, entityShared_t::ownerNum, gentity_s::parent, trace_t::plane, playerState_s::pm_flags, entityState_s::pos, gclient_s::ps, qboolean, gentity_s::r, gentity_s::s, SnapVectorTowards(), gentity_s::splashDamage, gentity_s::splashMethodOfDeath, gentity_s::splashRadius, strcmp(), trace_t::surfaceFlags, gentity_s::takedamage, gentity_s::target_ent, gentity_s::think, level_locals_t::time, trap_LinkEntity(), trajectory_t::trBase, trajectory_t::trDelta, trajectory_t::trType, v, vec3_t, vectoangles(), VectorClear, VectorCopy, VectorLength(), VectorNormalize(), VectorSet, and entityState_s::weapon.

Referenced by G_RunMissile().

00269                                                        {
00270     gentity_t       *other;
00271     qboolean        hitClient = qfalse;
00272 #ifdef MISSIONPACK
00273     vec3_t          forward, impactpoint, bouncedir;
00274     int             eFlags;
00275 #endif
00276     other = &g_entities[trace->entityNum];
00277 
00278     // check for bounce
00279     if ( !other->takedamage &&
00280         ( ent->s.eFlags & ( EF_BOUNCE | EF_BOUNCE_HALF ) ) ) {
00281         G_BounceMissile( ent, trace );
00282         G_AddEvent( ent, EV_GRENADE_BOUNCE, 0 );
00283         return;
00284     }
00285 
00286 #ifdef MISSIONPACK
00287     if ( other->takedamage ) {
00288         if ( ent->s.weapon != WP_PROX_LAUNCHER ) {
00289             if ( other->client && other->client->invulnerabilityTime > level.time ) {
00290                 //
00291                 VectorCopy( ent->s.pos.trDelta, forward );
00292                 VectorNormalize( forward );
00293                 if (G_InvulnerabilityEffect( other, forward, ent->s.pos.trBase, impactpoint, bouncedir )) {
00294                     VectorCopy( bouncedir, trace->plane.normal );
00295                     eFlags = ent->s.eFlags & EF_BOUNCE_HALF;
00296                     ent->s.eFlags &= ~EF_BOUNCE_HALF;
00297                     G_BounceMissile( ent, trace );
00298                     ent->s.eFlags |= eFlags;
00299                 }
00300                 ent->target_ent = other;
00301                 return;
00302             }
00303         }
00304     }
00305 #endif
00306     // impact damage
00307     if (other->takedamage) {
00308         // FIXME: wrong damage direction?
00309         if ( ent->damage ) {
00310             vec3_t  velocity;
00311 
00312             if( LogAccuracyHit( other, &g_entities[ent->r.ownerNum] ) ) {
00313                 g_entities[ent->r.ownerNum].client->accuracy_hits++;
00314                 hitClient = qtrue;
00315             }
00316             BG_EvaluateTrajectoryDelta( &ent->s.pos, level.time, velocity );
00317             if ( VectorLength( velocity ) == 0 ) {
00318                 velocity[2] = 1;    // stepped on a grenade
00319             }
00320             G_Damage (other, ent, &g_entities[ent->r.ownerNum], velocity,
00321                 ent->s.origin, ent->damage, 
00322                 0, ent->methodOfDeath);
00323         }
00324     }
00325 
00326 #ifdef MISSIONPACK
00327     if( ent->s.weapon == WP_PROX_LAUNCHER ) {
00328         if( ent->s.pos.trType != TR_GRAVITY ) {
00329             return;
00330         }
00331 
00332         // if it's a player, stick it on to them (flag them and remove this entity)
00333         if( other->s.eType == ET_PLAYER && other->health > 0 ) {
00334             ProximityMine_Player( ent, other );
00335             return;
00336         }
00337 
00338         SnapVectorTowards( trace->endpos, ent->s.pos.trBase );
00339         G_SetOrigin( ent, trace->endpos );
00340         ent->s.pos.trType = TR_STATIONARY;
00341         VectorClear( ent->s.pos.trDelta );
00342 
00343         G_AddEvent( ent, EV_PROXIMITY_MINE_STICK, trace->surfaceFlags );
00344 
00345         ent->think = ProximityMine_Activate;
00346         ent->nextthink = level.time + 2000;
00347 
00348         vectoangles( trace->plane.normal, ent->s.angles );
00349         ent->s.angles[0] += 90;
00350 
00351         // link the prox mine to the other entity
00352         ent->enemy = other;
00353         ent->die = ProximityMine_Die;
00354         VectorCopy(trace->plane.normal, ent->movedir);
00355         VectorSet(ent->r.mins, -4, -4, -4);
00356         VectorSet(ent->r.maxs, 4, 4, 4);
00357         trap_LinkEntity(ent);
00358 
00359         return;
00360     }
00361 #endif
00362 
00363     if (!strcmp(ent->classname, "hook")) {
00364         gentity_t *nent;
00365         vec3_t v;
00366 
00367         nent = G_Spawn();
00368         if ( other->takedamage && other->client ) {
00369 
00370             G_AddEvent( nent, EV_MISSILE_HIT, DirToByte( trace->plane.normal ) );
00371             nent->s.otherEntityNum = other->s.number;
00372 
00373             ent->enemy = other;
00374 
00375             v[0] = other->r.currentOrigin[0] + (other->r.mins[0] + other->r.maxs[0]) * 0.5;
00376             v[1] = other->r.currentOrigin[1] + (other->r.mins[1] + other->r.maxs[1]) * 0.5;
00377             v[2] = other->r.currentOrigin[2] + (other->r.mins[2] + other->r.maxs[2]) * 0.5;
00378 
00379             SnapVectorTowards( v, ent->s.pos.trBase );  // save net bandwidth
00380         } else {
00381             VectorCopy(trace->endpos, v);
00382             G_AddEvent( nent, EV_MISSILE_MISS, DirToByte( trace->plane.normal ) );
00383             ent->enemy = NULL;
00384         }
00385 
00386         SnapVectorTowards( v, ent->s.pos.trBase );  // save net bandwidth
00387 
00388         nent->freeAfterEvent = qtrue;
00389         // change over to a normal entity right at the point of impact
00390         nent->s.eType = ET_GENERAL;
00391         ent->s.eType = ET_GRAPPLE;
00392 
00393         G_SetOrigin( ent, v );
00394         G_SetOrigin( nent, v );
00395 
00396         ent->think = Weapon_HookThink;
00397         ent->nextthink = level.time + FRAMETIME;
00398 
00399         ent->parent->client->ps.pm_flags |= PMF_GRAPPLE_PULL;
00400         VectorCopy( ent->r.currentOrigin, ent->parent->client->ps.grapplePoint);
00401 
00402         trap_LinkEntity( ent );
00403         trap_LinkEntity( nent );
00404 
00405         return;
00406     }
00407 
00408     // is it cheaper in bandwidth to just remove this ent and create a new
00409     // one, rather than changing the missile into the explosion?
00410 
00411     if ( other->takedamage && other->client ) {
00412         G_AddEvent( ent, EV_MISSILE_HIT, DirToByte( trace->plane.normal ) );
00413         ent->s.otherEntityNum = other->s.number;
00414     } else if( trace->surfaceFlags & SURF_METALSTEPS ) {
00415         G_AddEvent( ent, EV_MISSILE_MISS_METAL, DirToByte( trace->plane.normal ) );
00416     } else {
00417         G_AddEvent( ent, EV_MISSILE_MISS, DirToByte( trace->plane.normal ) );
00418     }
00419 
00420     ent->freeAfterEvent = qtrue;
00421 
00422     // change over to a normal entity right at the point of impact
00423     ent->s.eType = ET_GENERAL;
00424 
00425     SnapVectorTowards( trace->endpos, ent->s.pos.trBase );  // save net bandwidth
00426 
00427     G_SetOrigin( ent, trace->endpos );
00428 
00429     // splash damage (doesn't apply to person directly hit)
00430     if ( ent->splashDamage ) {
00431         if( G_RadiusDamage( trace->endpos, ent->parent, ent->splashDamage, ent->splashRadius, 
00432             other, ent->splashMethodOfDeath ) ) {
00433             if( !hitClient ) {
00434                 g_entities[ent->r.ownerNum].client->accuracy_hits++;
00435             }
00436         }
00437     }
00438 
00439     trap_LinkEntity( ent );
00440 }

Here is the call graph for this function:

void G_RunMissile gentity_t ent  ) 
 

Definition at line 447 of file g_missile.c.

References BG_EvaluateTrajectory(), gentity_s::client, gentity_s::clipmask, gentity_s::count, entityShared_t::currentOrigin, ENTITYNUM_NONE, entityState_s::eType, G_FreeEntity(), G_MissileImpact(), G_RunThink(), gentity_t, gclient_s::hook, level, entityShared_t::maxs, entityShared_t::mins, entityState_s::number, entityShared_t::ownerNum, gentity_s::parent, entityState_s::pos, gentity_s::r, gentity_s::s, gentity_s::target_ent, level_locals_t::time, tr, trap_LinkEntity(), trap_Trace(), vec3_t, VectorCopy, and entityState_s::weapon.

Referenced by G_RunFrame().

00447                                     {
00448     vec3_t      origin;
00449     trace_t     tr;
00450     int         passent;
00451 
00452     // get current position
00453     BG_EvaluateTrajectory( &ent->s.pos, level.time, origin );
00454 
00455     // if this missile bounced off an invulnerability sphere
00456     if ( ent->target_ent ) {
00457         passent = ent->target_ent->s.number;
00458     }
00459 #ifdef MISSIONPACK
00460     // prox mines that left the owner bbox will attach to anything, even the owner
00461     else if (ent->s.weapon == WP_PROX_LAUNCHER && ent->count) {
00462         passent = ENTITYNUM_NONE;
00463     }
00464 #endif
00465     else {
00466         // ignore interactions with the missile owner
00467         passent = ent->r.ownerNum;
00468     }
00469     // trace a line from the previous position to the current position
00470     trap_Trace( &tr, ent->r.currentOrigin, ent->r.mins, ent->r.maxs, origin, passent, ent->clipmask );
00471 
00472     if ( tr.startsolid || tr.allsolid ) {
00473         // make sure the tr.entityNum is set to the entity we're stuck in
00474         trap_Trace( &tr, ent->r.currentOrigin, ent->r.mins, ent->r.maxs, ent->r.currentOrigin, passent, ent->clipmask );
00475         tr.fraction = 0;
00476     }
00477     else {
00478         VectorCopy( tr.endpos, ent->r.currentOrigin );
00479     }
00480 
00481     trap_LinkEntity( ent );
00482 
00483     if ( tr.fraction != 1 ) {
00484         // never explode or bounce on sky
00485         if ( tr.surfaceFlags & SURF_NOIMPACT ) {
00486             // If grapple, reset owner
00487             if (ent->parent && ent->parent->client && ent->parent->client->hook == ent) {
00488                 ent->parent->client->hook = NULL;
00489             }
00490             G_FreeEntity( ent );
00491             return;
00492         }
00493         G_MissileImpact( ent, &tr );
00494         if ( ent->s.eType != ET_MISSILE ) {
00495             return;     // exploded
00496         }
00497     }
00498 #ifdef MISSIONPACK
00499     // if the prox mine wasn't yet outside the player body
00500     if (ent->s.weapon == WP_PROX_LAUNCHER && !ent->count) {
00501         // check if the prox mine is outside the owner bbox
00502         trap_Trace( &tr, ent->r.currentOrigin, ent->r.mins, ent->r.maxs, ent->r.currentOrigin, ENTITYNUM_NONE, ent->clipmask );
00503         if (!tr.startsolid || tr.entityNum != ent->r.ownerNum) {
00504             ent->count = 1;
00505         }
00506     }
00507 #endif
00508     // check think function after bouncing
00509     G_RunThink( ent );
00510 }

Here is the call graph for this function:


Generated on Thu Aug 25 13:56:09 2005 for Quake III Arena by  doxygen 1.3.9.1