float IM_PHOSPHOR = 75;
float WP_PHOSPHOR = 16;

void() PhosphorExplode =
{
	local entity fire;
	fire=spawn();
	fire.owner=self.owner;
	fire.movetype=MOVETYPE_NONE;
	fire.solid=SOLID_NOT;
	fire.classname="phosphorflame";
	fire.nextthink=time+0.1;
	fire.think=FlameThink;
	fire.effects=EF_BRIGHTLIGHT;
	fire.blasttimer=time+10;
	fire.style=0;
	fire.frame=0;
	setmodel(fire,"progs/flame2.mdl");
	setsize(fire,'0 0 0','0 0 0');
	setorigin(fire,self.origin+'0 0 16');
	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);
	
	T_NewRadiusDamage(self,self.owner,20,world,50);
	BecomeExplosion();
};

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

void() W_FirePhosphor =
{
	local entity missile;

	if (self.currentammo<1)
	{
		self.weapon=W_BestWeapon();
		self.ef=0;
		W_SetCurrentAmmo();
		return;
	}	
	self.ammo_rockets=self.ammo_rockets - 10;
	self.currentammo=floor(self.ammo_rockets/10);
	sound(self,CHAN_WEAPON,"weapons/grenade.wav",1,ATTN_NORM);
	self.punchangle_x= -2;
	missile=spawn();
	missile.owner=self;
	missile.movetype=MOVETYPE_BOUNCE;
	missile.solid=SOLID_BBOX;
	missile.classname="phosphorbomb";
	makevectors(self.v_angle);
	if(self.v_angle_x)
		missile.velocity=v_forward*600+v_up*200+crandom()*v_right*10+crandom()*v_up*10;
	else
	{
		missile.velocity=aim(self,10000);
		missile.velocity=missile.velocity*600;
		missile.velocity_z=200;
	}
	missile.avelocity='300 300 300';
	missile.angles=vectoangles(missile.velocity);
	missile.touch=PhosphorTouch;
	missile.nextthink=time+2;
	missile.think=PhosphorExplode;
	setmodel(missile,"progs/grenade.mdl");
	setsize(missile,'0 0 0','0 0 0');
	setorigin(missile,self.origin);
};