float WP_NAPALMROCK = 128;
float IM_NAPALMROCK = 78;

void() NapalmRocketExplode =
{
	local entity fuel;
	local float tmp;
	
	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);

	tmp=0;
	while(tmp<10)
	{
		fuel=spawn();
		fuel.owner=self.owner;
		fuel.movetype=MOVETYPE_FLYMISSILE;
		fuel.solid=SOLID_BBOX;
		fuel.classname="napalm";
		fuel.think=SUB_Null;
  	fuel.avelocity='300 300 300';
		fuel.touch=NapalmTouch;
		fuel.takedamage=DAMAGE_AIM;
		fuel.health=1;
		fuel.th_die=NapalmDie;
		fuel.velocity=self.velocity;
		fuel.angles=vectoangles(fuel.velocity);
		makevectors(fuel.angles);
		fuel.velocity=fuel.velocity+v_right*100*crandom()+v_up*100*crandom();
		fuel.angles=vectoangles(fuel.velocity);
		setmodel(fuel,"progs/spike.mdl");
		setsize(fuel,'0 0 0','0 0 0');
		setorigin(fuel,self.origin);
		tmp=tmp+1;
	}
	BecomeExplosion();
};

void() NapalmRocketTouch =
{
	if (pointcontents(self.origin)==CONTENT_SKY)
	{
		remove(self);
		return;
	}
	NapalmRocketExplode();
};

void() W_FireNapalmRocket =
{
	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_napalm=self.ammo_napalm - 10;
	temp=floor(self.ammo_napalm/10);
	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,1000);
	missile.velocity=missile.velocity*1000;
	missile.classname="napalmrocket";
	missile.angles=vectoangles(missile.velocity);
	missile.touch=NapalmRocketTouch;
	missile.nextthink=time+0.2;
	missile.think=NapalmRocketExplode;
	setmodel(missile,"progs/missile.mdl");
	setsize(missile,'0 0 0','0 0 0');
	setorigin(missile,self.origin+v_forward*8+'0 0 16');
};