float IM_LIGHTROCK = 76;
float WP_LIGHTROCK = 32;

void() LightRockExplode =
{
	T_RadiusDamage(self,self.owner,30,world);
	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 ();
};

void() LightRockTouch =
{
	LightRockExplode();
};

void() LightRockThink = // has important parts of VHOLD's, with slight mods
{
	local entity head,selected;
  head = findradius(self.origin, 250);
 	if (self.t_width<time)
 	{
 		sound(self,CHAN_WEAPON,"weapons/lhit.wav",1,ATTN_NORM);
 		self.t_width=time+0.6;
 	}	
  while(head)
  {
		if( (head.health > 1) && (head != self) && (head != self.owner) && (head.classname != "door") && (head.classname != "misc_explobox") && !(head.items & IT_INVISIBILITY) )
	    {
        traceline(self.origin,head.origin,TRUE,self);
        if ( (trace_fraction >= 1) )
        {
          selected = head;
          if (head!=world)
          {
						WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
						WriteByte (MSG_BROADCAST, TE_LIGHTNING2);
						WriteEntity (MSG_BROADCAST, self);
						WriteCoord (MSG_BROADCAST, self.origin_x);
						WriteCoord (MSG_BROADCAST, self.origin_y);
						WriteCoord (MSG_BROADCAST, self.origin_z);
						WriteCoord (MSG_BROADCAST, head.origin_x);
						WriteCoord (MSG_BROADCAST, head.origin_y);
						WriteCoord (MSG_BROADCAST, head.origin_z);
						if (pointcontents(head.origin)==CONTENT_WATER)
							T_Damage(head,self,self.owner,400); // BIIIIG ZAP
						else
							T_Damage(head,self,self.owner,20);
					}
        }
      }
    head = head.chain;
  } 
	if (pointcontents(self.origin)==CONTENT_WATER) 	// Oh man this one hurts
	{
		T_NewRadiusDamage(self,self.owner,400,world,400);
		LightRockExplode();
	}
	self.nextthink=time+0.1;
};

void() W_FireLightRocket =
{
	local entity missile;
	local float temp;
	
	if (self.currentammo<1)
	{
		self.weapon=W_BestWeapon();
		self.ef=0;
		W_SetCurrentAmmo();
		return;
	}
	self.ammo_rockets=self.ammo_rockets - 1;
	self.ammo_cells=self.ammo_cells - 40;
	temp = floor(self.ammo_cells/40);
	self.currentammo=min(self.ammo_rockets,temp);
	sound(self,CHAN_WEAPON,"weapons/sgun1.wav",1,ATTN_NORM);
	self.punchangle_x= -2;
	missile=spawn();
	missile.owner=self;
	missile.movetype=MOVETYPE_FLYMISSILE;
	missile.solid=SOLID_BBOX;
	makevectors(self.v_angle);
	missile.velocity=aim(self,250);
	missile.velocity=missile.velocity*250;
	missile.angles=vectoangles(missile.velocity);
	missile.touch=LightRockTouch;
	missile.nextthink=time+0.5;
	missile.t_width=time+0.6;
	missile.think=LightRockThink;
	setmodel(missile,"progs/missile.mdl");
	setsize(missile,'0 0 0','0 0 0');
	setorigin(missile,self.origin+v_forward*8+'0 0 16');
};