// code author status: one line by Nick & most of the others by id & rest by me ;)

void() W_SetCurrentAmmo;
void() BecomeExplosion;
void(entity inflictor, entity attacker, float damage, entity ignore) T_ABombDamage;

void() ABomb_Explode =
{
	lightstyle(0, "m");
	bprint("it's the end of the world as we know it...\n");   //Tee Hee...
	self.effects=14; // EF_MUZZLEFLASH && EF_BRIGHTLIGHT && EF_DIMLIGHT
	T_ABombDamage(self, self.owner, 8000, world);
// 2nd "T_ABombDamage(self, self.owner, 8000, world);" might be used if wanting more reliability...

	sound (self, CHAN_WEAPON, "weapons/r_exp3.wav", 1, ATTN_NORM);
// get a real a-bomb sound and put it here...

//	self.origin = self.origin - 8*normalize(self.velocity);

	WriteByte (MSG_BROADCAST, SVC_TEMPENTITY); // explosion
	WriteByte (MSG_BROADCAST, TE_EXPLOSION);
	WriteCoord (MSG_BROADCAST, self.origin_x);
	WriteCoord (MSG_BROADCAST, self.origin_y);
	WriteCoord (MSG_BROADCAST, self.origin_z);

	BecomeExplosion (); // sprite and removal of the entity...
};

void() ABomb_Count1 =
{
//	sound (self, CHAN_WEAPON, "count1.wav", 1, ATTN_NORM);
	bprint ("Q   * ONE *   Q\n\n");
	self.nextthink = time + 1;
	self.think = ABomb_Explode;
};

void() ABomb_Count2 =
{
//	sound (self, CHAN_WEAPON, "count2.wav", 1, ATTN_NORM);
	bprint ("q   * two *   q\n");
	self.nextthink = time + 1;
	self.think = ABomb_Count1;
};

void() ABomb_Count3 =
{
//	sound (self, CHAN_WEAPON, "count3.wav", 1, ATTN_NORM);
	bprint ("\nQ  * three *  Q\n");
	self.nextthink = time + 1;
	self.think = ABomb_Count2;
};

void() ABomb_DoNothing =
{
//	prevent looping touch... I could use SUB_Null instead but who cares;)
};

void() ABomb_Touch =
{
	if(other == self.owner)			 //Don't explode if
		return;				 //you touch it
//	sound (self, CHAN_WEAPON, "count5.wav", 1, ATTN_NORM);
	bprint ("\nYou have five seconds to pray\n");
	self.nextthink = time + 2;
	self.think = ABomb_Count3;
	self.touch = ABomb_DoNothing;
	lightstyle(0, "zwtqnkheba");
};

void() ABomb_Count5 =
{
//	sound (self, CHAN_WEAPON, "count5.wav", 1, ATTN_NORM);
	bprint ("\nYou have five seconds to pray\n");
	self.nextthink = time + 2;
	self.think = ABomb_Count3;
	self.touch = ABomb_DoNothing;
	lightstyle(0, "zwtqnkheba");
};

void() ABomb_Count10 =
{
//	sound (self, CHAN_WEAPON, "endoftheworldin10seconds.wav", 1, ATTN_NORM);
	bprint ("End of the world in ten seconds...\n");
	self.nextthink = time + 5;
	self.think = ABomb_Count5;
	lightstyle(0, "zxusqomkig");
};
