void(entity sucker) Suck2 =
{
   local entity suckee;
   local vector suckdir, suckforce;
   local float suckdist, dist,num;

   dist = 500;

   suckee = findradius(sucker.origin, dist); //find the victims
   while(suckee)
   {
      if (suckee.health || !(suckee.flags & FL_ONGROUND))
      {
         if (suckee.solid != SOLID_BSP && !(self.owner == suckee) && sucker != suckee)
         {
            if (suckee.classname != "player")
               suckee.flags = suckee.flags-(suckee.flags & FL_ONGROUND);
            suckdir = sucker.origin - suckee.origin;
            suckdist = vlen (suckdir);
            suckdir = normalize (suckdir);
            suckforce = suckdir * 0.8 * (dist - suckdist); //increased from 0.25
            suckee.velocity = suckee.velocity + suckforce;
				if (suckee.health < 25)
					T_Damage(suckee,self, self.owner,P5DAMAGE);
				else
					T_Damage(suckee,self, self.owner,P1DAMAGE);
         }
      }
      suckee = suckee.chain;
   }

	self.wait = self.wait - 0.1;

	if (self.wait <= 0) 
	{
		self.think = BigQ2Boom;
		self.nextthink = time;
	}
};


//start to suck!


//suck or explode? let me think...
void() Suck_Think2 =
{
   self.nextthink = time + 0.1;
	self.wait = self.wait - 0.1; //8 second till detonation
   Suck2(self);
};

void () GravBombTouch = {

   local float damg;

   if ( (other == self.owner) ) {

      return ;

   }
   //pointcontents takes an origin vector and returns a float
   if ( (pointcontents (self.origin) == CONTENT_SKY) ) {

      remove (self);
      return ;

   }

   if (other.solid == SOLID_BSP)
   {
/*
   T_RadiusDamage2 (self,self.owner,250.000,150,world);
   self.origin = (self.origin - (FL_CLIENT * normalize (self.velocity)));
   WriteByte (MSG_BROADCAST,SVC_TEMPENTITY);
   WriteByte (MSG_BROADCAST,TE_EXPLOSION);
   WriteCoord (MSG_BROADCAST,self.origin_x);
   WriteCoord (MSG_BROADCAST,self.origin_y);
   WriteCoord (MSG_BROADCAST,self.origin_z);
   BecomeExplosion ();
*/
	BigQ2Boom();
   }
   else return;

};



void () W_FireGravBomb = {

   local entity missile;

	if (!(self.ringofpower_time)) self.currentammo = self.ammo_rockets = (self.ammo_rockets - 5);
	sound (self,CHAN_WEAPON,"weapons/sgun1.wav",TRUE,ATTN_NORM);
   self.punchangle_x = CONTENT_SOLID;
   missile = spawn ();
   missile.owner = self;
   missile.movetype = MOVETYPE_FLYMISSILE;
   missile.solid = SOLID_BBOX;
   missile.classname = "gravbomb";
   makevectors (self.v_angle);
   missile.velocity = b_aim(self.origin);
   missile.velocity = (missile.velocity * 500.000);
   missile.angles = vectoangles (missile.velocity);

  	missile.touch = GravBombTouch;

   missile.nextthink = (time + 0.2);
   missile.think = Suck_Think2;
   missile.wait = 8;
   setmodel (missile,"progs/missile.mdl");
   setsize (missile,VEC_ORIGIN,VEC_ORIGIN);
   setorigin (missile,((self.origin + (v_forward * 16)) + '0.000 0.000 16.000' + v_right*12));

};

