void(float dmg) spawn_touchblood;
void(entity targ,entity infl,entity atk,float dmg) T_Damage;

float WP_LASER = 8;
float IM_LASER = 73;

void() LaserTouch = 
{
	if (other==self.owner)
		return;
	if (pointcontents(self.origin) == CONTENT_SKY)
	{
		remove(self);
		return;
	}
	sound (self,CHAN_WEAPON,"enforcer/enfstop.wav",1,ATTN_NORM);
	if (other.health)
	{
		spawn_touchblood(15);
		T_Damage(other,self,self.owner,15);
	}
	else
	{
		WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
		WriteByte (MSG_BROADCAST, TE_GUNSHOT);
		WriteCoord (MSG_BROADCAST, self.origin_x);
		WriteCoord (MSG_BROADCAST, self.origin_y);
		WriteCoord (MSG_BROADCAST, self.origin_z);
	}
	remove(self);
};

void() W_FireLaser = 
{
	local entity shot;

	if (self.currentammo<1)
	{
		self.weapon=W_BestWeapon();
		self.ef=0;
		W_SetCurrentAmmo();
		return;
	}
	self.ammo_cells = self.ammo_cells - 4;
	self.currentammo = floor(self.ammo_cells/4);
	sound (self,CHAN_WEAPON,"enforcer/enfire.wav",1,ATTN_NORM);
	shot=spawn();
	shot.owner=self;
	shot.movetype=MOVETYPE_FLY;
	shot.solid=SOLID_BBOX;
	shot.effects=EF_DIMLIGHT;
	setmodel(shot,"progs/laser.mdl");
	setsize(shot,'0 0 0','0 0 0');
	setorigin(shot,self.origin+v_forward*8+'0 0 16');
	shot.velocity=v_forward*1000;
	shot.classname="laser";
	shot.angles=vectoangles(shot.velocity);
	shot.touch=LaserTouch;
	shot.think=SUB_Remove;
	shot.nextthink=time+6;
};
