void () ProximityTouch =
{
	if (other.takedamage == DAMAGE_AIM)
	{
		GrenadeExplode();
		return;
	}
	sound (self, CHAN_WEAPON, "weapons/bounce.wav", 1, ATTN_NORM);
	if (self.velocity == '0 0 0')
		self.avelocity = '0 0 0';
};

void () Proximity =
{
	local entity head;

	head = findradius(self.origin,100);
	while(head)
	{
		if ( (head.health > 1) && (head.classname == "player") && !(head.items & IT_INVISIBILITY) )
		{
			self.nextthink = time + 0.1;
			sound (self, CHAN_WEAPON, "weapons/arm.wav", 1, ATTN_NORM);
			self.think = GrenadeExplode;
			return;
		}
		head = head.chain;
	}
	self.nexthink = time + 0.25;
};

void() DropBomb =
{
	local entity item;

	if (self.ammo_rockets == <2)
		return;
	self.ammo_rockets = self.ammo_rockets - 2;
	self.flags = self.flags | FL_ATTACKED;
	sound (self, CHAN_WEAPON, "weapons/bounce.wav", 1, ATTN_NORM);
	item = spawn();
	item.owner = self;
	makevectors(self.v_angle);
	setorigin(item,self.origin + '0 0 16');
	item.velocity = aim(self,500);
	item.velocity = item.velocity * 100;
	item.flags = FL_ITEM;
	item.solid = SOLID_TRIGGER;
	item.classname = "proximity";
	item.movetype = MOVETYPE_BOUNCE;
	setmodel (item, "progs/grenade.mdl");
	setsize (item, '-16 -16 0', '16 16 56');
	item.touch = ProximityTouch;
	item.nexthink = time + 3;
	item.think = Proximity;
	W_SetCurrentAmmo();
};