
bullethole()
{
	level endon("wwx_gameover");
	self endon("disconnect");
	self endon("wwx_dead");
	self endon("wwx_spawned");

	if(!isDefined(self.wwx_bulletholes)) self.wwx_bulletholes = [];

	hole = self.wwx_bulletholes.size;
	
	self.wwx_bulletholes[hole] = newClientHudElem(self);
	self.wwx_bulletholes[hole].alignX = "center";
	self.wwx_bulletholes[hole].alignY = "middle";
	self.wwx_bulletholes[hole].x = 48 + randomInt(544);
	self.wwx_bulletholes[hole].y = 48 + randomInt(304);
	self.wwx_bulletholes[hole].color = (1,1,1);
	self.wwx_bulletholes[hole].alpha = 0.8 + randomFloat(0.2);

	xsize = 64 + randomInt(32);
	ysize = 64 + randomInt(32);

	if(randomInt(2)) self.wwx_bulletholes[hole] setShader("gfx/custom/bullethit_glass.tga", xsize, ysize);
	else self.wwx_bulletholes[hole] setShader("gfx/custom/bullethit_glass2.tga", xsize, ysize);

	self playLocalSound("glassbreak");

	if(level.wwx_bulletholes != 2) return;

	self thread fadeBullethole(hole);
}

fadeBullethole(hole)
{
	wait 5;

	if(isPlayer(self))
	{
		if(isDefined(self.wwx_bulletholes))
		{
			if(isDefined(self.wwx_bulletholes[hole]))
			{
				self.wwx_bulletholes[hole] fadeOverTime(1);
				self.wwx_bulletholes[hole].alpha = 0;
				wait 1;
				if(isPlayer(self) && isDefined(self.wwx_bulletholes[hole])) self.wwx_bulletholes[hole] destroy();
			}
		}
	}
}
