/*
================
G_RunMissile
================
*/
void G_RunMissile( gentity_t *ent )
{
.
.
.
}
/*
=================
G_Suck //tute11.3
=================
*/
static void G_Suck( gentity_t *self )
{
gentity_t *target;
vec3_t start,dir,end;
target = NULL;
//check if there are any entity's within a radius of 500 units.
while ((target = findradius(target, self->r.currentOrigin, 500)) != NULL)
{
// target must not be vortex grenade
if (target == self)
continue;
// target must be a client
if (!target->client)
continue;
// target must not be the player who fired the vortex grenade
if (target == self->parent)
continue;
// target must be able to take damage
if (!target->takedamage)
continue;
// put target position in start
VectorCopy(target->r.currentOrigin, start);
// put grenade position in end
VectorCopy(self->r.currentOrigin, end);
// subtract start from end to get directional vector
VectorSubtract(end, start, dir);
VectorNormalize(dir);
// scale directional vector by 200 and add to the targets velocity
VectorScale(dir,200, target->client->ps.velocity);
// make targets move direction = to directional vector.
VectorCopy(dir, target->movedir);
}
self->nextthink = level.time + 20;
// check if vortext grenade is older than 20 seconds.
if (level.time > self->wait)
G_ExplodeMissile( self);
}
|