/*
==============================================================================

bazooka babe

==============================================================================
*/
$cd /raid/quake/id1/models/bazooka
$origin 0 0 -24
$base base
$skin skin
$scale 1

$frame pose
$frame idle01 idle02 idle03 idle04 idle05

$frame walk01 walk03 walk05 walk07 walk09 walk11 walk13 walk15 walk17 
$frame fire1 fire2 fire3 fire4 fire5 fire6 fire7 fire8 fire9 fire10

$frame pain01 pain02 pain03 pain04 pain05 pain06
$frame death01 death02 death03 death04 death05 death06 death07 death08 death09 death10
$frame death11 death12 death13 death14 death15 death16 death17 death18 death19 death20
$frame death21 death22 death23
$frame bpain01 bpain02 bpain03 bpain04 bpain05 bpain06 bpain07 bpain08 bpain09 bpain10 bpain11
$frame bdeath01 bdeath02 bdeath03 bdeath04 bdeath05 bdeath06 bdeath07 bdeath08 bdeath09 bdeath10 bdeath11 bdeath12 bdeath13 bdeath14

void() BabeRocketExplode =
{
	T_RadiusDamage (self,self.owner, 80, world);
	sound(self,CHAN_VOICE,"weapons/r_exp3.wav", 1,ATTN_NORM);
	
	WriteByte (MSG_BROADCAST,SVC_TEMPENTITY);
	WriteByte (MSG_BROADCAST,TE_TAREXPLOSION);
	WriteCoord (MSG_BROADCAST,self.origin_x);
	WriteCoord (MSG_BROADCAST,self.origin_y);
	WriteCoord (MSG_BROADCAST,self.origin_z);
	
	self.velocity = '0 0 0';
	self.touch = SUB_Null;
	setmodel (self,"progs/s_explod.spr");
	self.solid = SOLID_NOT;
	s_explode1 ();
};

void() BabeRocketExplodb =
{
	T_RadiusDamage (self,self.owner, 10, world);
	sound(self,CHAN_VOICE,"weapons/r_exp3.wav", 1,ATTN_NORM);
	
	WriteByte (MSG_BROADCAST,SVC_TEMPENTITY);
	WriteByte (MSG_BROADCAST,TE_TAREXPLOSION);
	WriteCoord (MSG_BROADCAST,self.origin_x);
	WriteCoord (MSG_BROADCAST,self.origin_y);
	WriteCoord (MSG_BROADCAST,self.origin_z);
	
	self.velocity = '0 0 0';
	self.touch = SUB_Null;
	setmodel (self,"progs/s_explod.spr");
	self.solid = SOLID_NOT;
	s_explode1 ();
};
void() BabeRocketTouch =
{
	if (other == self.owner)
		return;

	if (pointcontents(self.origin) == CONTENT_SKY)
	{
		remove(self);
		return;
	}
	sound (self,CHAN_VOICE,"enforcer/enfstop.wav", 1,ATTN_STATIC);
	if (self.velocity== '0 0 0')	
		self.avelocity = '0 0 0';

	if (other.health)
	{
		if (other.classname == "monster_bazooka")
		BabeRocketExplodb();
		else
		BabeRocketExplode();
		return;
	}

	else
	{
		WriteByte (MSG_BROADCAST,SVC_TEMPENTITY);
		WriteByte (MSG_BROADCAST,TE_TAREXPLOSION);
		WriteCoord (MSG_BROADCAST,self.origin_x);
		WriteCoord (MSG_BROADCAST,self.origin_y);
		WriteCoord (MSG_BROADCAST,self.origin_z);
	}
	remove(self);
};

void() BabeFireRocket =
{
	local	entity missile, mpuff;
	local   vector  org, vec;
	self.effects = self.effects | EF_MUZZLEFLASH;
	sound (self,CHAN_WEAPON,"weapons/sgun1.wav", 1,ATTN_NORM);
	
	makevectors (self.angles);

	org = self.origin + v_forward * 30 + v_right * 8.5 + '0 0 16';
	vec = normalize (vec);
	
	self.punchangle_x = -2;

	missile = spawn ();
	missile.owner = self;
	missile.movetype = MOVETYPE_FLYMISSILE;
	missile.solid = SOLID_BBOX;

// set missile speed

	makevectors (self.angles);
	
	missile.velocity = normalize(self.enemy.origin - self.origin);
	missile.velocity = missile.velocity * 1000;
	missile.angles = vectoangles(missile.velocity);
	missile.touch = BabeRocketTouch;
	
// set missile duration

	missile.nextthink = time + 5;
	missile.think = BabeRocketExplode;
	
	setmodel (missile, "progs/pulse.mdl");
	setsize (missile, '0 0 0', '0 0 0');
	setorigin (missile, self.origin + v_forward*8 + '0 0 16');
};	

void() babe_pain;
void() babe_stand      =[      $idle01,       babe_stand2    ] {
if (random() < 0.1)
	sound (self, CHAN_VOICE, "bazooka/when.wav", 1, ATTN_IDLE);
};
void() babe_stand2     =[      $idle01,       babe_stand3    ] {ai_stand();};
void() babe_stand3     =[      $idle02,       babe_stand4    ] {ai_stand();};
void() babe_stand4     =[      $idle02,       babe_stand5    ] {ai_stand();};
void() babe_stand5     =[      $idle03,       babe_stand6    ] {ai_stand();};
void() babe_stand6     =[      $idle03,       babe_stand7    ] {ai_stand();};
void() babe_stand7     =[      $idle04,       babe_stand8    ] {ai_stand();};
void() babe_stand8     =[      $idle04,       babe_stand9    ] {ai_stand();};
void() babe_stand9     =[      $idle05,       babe_stand10   ] {ai_stand();};
void() babe_stand10    =[      $idle05,       babe_stand11   ] {ai_stand();};
void() babe_stand11    =[      $idle05,       babe_stand12   ] {ai_stand();};
void() babe_stand12    =[      $idle04,       babe_stand13   ] {ai_stand();};
void() babe_stand13    =[      $idle04,       babe_stand14   ] {ai_stand();};
void() babe_stand14    =[      $idle03,       babe_stand15   ] {ai_stand();};
void() babe_stand15    =[      $idle03,       babe_stand16   ] {ai_stand();};
void() babe_stand16    =[      $idle02,       babe_stand17   ] {ai_stand();};
void() babe_stand17    =[      $idle02,       babe_stand18   ] {ai_stand();};
void() babe_stand18    =[      $idle01,       babe_stand     ] {ai_stand();};

void() babe_walk        =[      $walk01,        babe_walk1       ] {sound (self, CHAN_VOICE, "bazooka/step1.wav", 1, ATTN_IDLE); ai_walk(8);};
void() babe_walk1	=[      $walk03,	babe_walk2	] {ai_walk(0);};
void() babe_walk2	=[      $walk05,	babe_walk3	] {ai_walk(16);};
void() babe_walk3	=[      $walk07,	babe_walk4	] {ai_walk(20);};
void() babe_walk4	=[      $walk09,	babe_walk5	] {sound (self, CHAN_VOICE, "bazooka/step1.wav", 1, ATTN_IDLE); ai_walk(8);};
void() babe_walk5	=[      $walk11,	babe_walk6	] {ai_walk(0);};
void() babe_walk6	=[      $walk13,	babe_walk7	] {ai_walk(8);};
void() babe_walk7	=[      $walk15,	babe_walk8	] {ai_walk(16);};
void() babe_walk8	=[      $walk17,	babe_walk	] {ai_walk(20);};

void() babe_run         =[      $walk01,        babe_run1       ] {sound (self, CHAN_VOICE, "bazooka/step1.wav", 1, ATTN_IDLE); ai_run(8);};
void() babe_run1	=[      $walk03,	babe_run2	] {ai_face();};
void() babe_run2	=[      $walk05,	babe_run3	] {ai_run(16);};
void() babe_run3	=[      $walk07,	babe_run4	] {ai_run(20);};
void() babe_run4	=[      $walk09,	babe_run5	] {sound (self, CHAN_VOICE, "bazooka/step1.wav", 1, ATTN_IDLE); ai_run(8);};
void() babe_run5	=[      $walk11,	babe_run6	] {ai_face();};
void() babe_run6	=[      $walk13,	babe_run7	] {ai_run(8);};
void() babe_run7	=[      $walk15,	babe_run8	] {ai_run(16);};
void() babe_run8	=[      $walk17,	babe_run	] {ai_run(20);};

void() babe_fire1	=[	$fire1,		babe_fire2	] {
	if (random() < 0.2)
		sound (self, CHAN_VOICE, "bazooka/die.wav", 1, ATTN_NORM);
	else
		sound (self, CHAN_VOICE, "bazooka/stepstop.wav", 1, ATTN_IDLE);
ai_face();};
void() babe_fire2	=[	$fire2,		babe_fire3	] {ai_face();};
void() babe_fire3	=[	$fire3,		babe_fire4	] {ai_face();};
void() babe_fire4	=[	$fire4,		babe_fire5	] {ai_face();};
void() babe_fire5	=[	$fire5,		babe_fire6	] {ai_face();};
void() babe_fire6	=[	$fire5,		babe_fire7	] {ai_face();};
void() babe_fire7	=[	$fire6,		babe_fire8	] {ai_face();BabeFireRocket();};
void() babe_fire8	=[	$fire7,		babe_fire9	] {ai_face();};
void() babe_fire9	=[	$fire8,		babe_fire10	] {ai_face();};
void() babe_fire10	=[	$fire9,		babe_fire11	] {ai_face();};
void() babe_fire11	=[	$fire10,	babe_run	] {ai_face();};

void() babe_pain1	=[	$pain01,		babe_pain2	] {
if (random() < 0.5)
	sound (self, CHAN_VOICE, "bazooka/yeow.wav", 1, ATTN_IDLE);
else
	sound (self, CHAN_VOICE, "bazooka/ooaa.wav", 1, ATTN_IDLE);
};
void() babe_pain2	=[	$pain02,		babe_pain3	] {};
void() babe_pain3	=[	$pain03,		babe_pain4	] {ai_painforward(2);};
void() babe_pain4	=[	$pain04,		babe_pain5	] {ai_painforward(1);};
void() babe_pain5	=[	$pain05,		babe_pain6	] {};
void() babe_pain6	=[	$pain06,		babe_run	] {ai_painforward(2);};

void() babe_die1	=[	$death01,		babe_die2	] 
{ThrowGib ("progs/gib1.mdl", self.health);};
void() babe_die2	=[	$death02,		babe_die3	] {};
void() babe_die3	=[	$death03,		babe_die4	] {};
void() babe_die4	=[	$death04,		babe_die5	] {};
void() babe_die5	=[	$death05,		babe_die6	] {};
void() babe_die6	=[	$death06,		babe_die7	] {};
void() babe_die7	=[	$death07,		babe_die8	] {};
void() babe_die8	=[	$death08,		babe_die9	] {};
void() babe_die9	=[	$death09,		babe_die10	] {};
void() babe_die10	=[	$death10,		babe_die11	] {};
void() babe_die11	=[	$death11,		babe_die12	] {};
void() babe_die12	=[	$death12,		babe_die13	] {};
void() babe_die13	=[	$death13,		babe_die14	] {};
void() babe_die14	=[	$death14,		babe_die15	] 
{sound (self, CHAN_VOICE, "bazooka/stepstop.wav", 1, ATTN_IDLE);};
void() babe_die15	=[	$death15,		babe_die16	] 
{self.solid = SOLID_NOT;self.ammo_rockets = 2;DropBackpack();sound (self, CHAN_VOICE, "bazooka/dies2.wav", 1, ATTN_NORM);};
void() babe_die16	=[	$death16,		babe_die17	] {};
void() babe_die17	=[	$death17,		babe_die18	] {};
void() babe_die18	=[	$death18,		babe_die19	] {};
void() babe_die19	=[	$death19,		babe_die20	] {};
void() babe_die20	=[	$death20,		babe_die21	] {};
void() babe_die21	=[	$death21,		babe_die22	] {};
void() babe_die22	=[	$death23,		babe_die22	] {};
void() babe_die23	=[	$death23,		babe_die23	] {};

void() babe_bpain01	=[	$bpain01,		babe_bpain02	] {ai_back(2);
if (random() < 0.5)
	sound (self, CHAN_VOICE, "bazooka/grrr.wav", 1, ATTN_IDLE);
else
	sound (self, CHAN_VOICE, "bazooka/ahaia.wav", 1, ATTN_IDLE);
};
void() babe_bpain02	=[	$bpain02,		babe_bpain03	] {};
void() babe_bpain03	=[	$bpain03,		babe_bpain04	] {};
void() babe_bpain04	=[	$bpain04,		babe_bpain05	] {};
void() babe_bpain05	=[	$bpain05,		babe_bpain06	] {};
void() babe_bpain06	=[	$bpain06,		babe_bpain07	] {};
void() babe_bpain07	=[	$bpain07,		babe_bpain08	] {};
void() babe_bpain08	=[	$bpain08,		babe_bpain09	] {};
void() babe_bpain09	=[	$bpain09,		babe_bpain10	] {};
void() babe_bpain10	=[	$bpain10,		babe_bpain11	] {};
void() babe_bpain11	=[	$bpain11,		babe_run	] {};

void() babe_bdeath01	=[	$bdeath01,		babe_bdeath02	] {};
void() babe_bdeath02	=[	$bdeath02,		babe_bdeath03	] {};
void() babe_bdeath03	=[	$bdeath03,		babe_bdeath04	] {};
void() babe_bdeath04	=[	$bdeath04,		babe_bdeath05	] {};
void() babe_bdeath05	=[	$bdeath05,		babe_bdeath06	] {};
void() babe_bdeath06	=[	$bdeath06,		babe_bdeath07	] {};
void() babe_bdeath07	=[	$bdeath07,		babe_bdeath08	] {
self.solid = SOLID_NOT;self.ammo_rockets = 2;DropBackpack();};
void() babe_bdeath08	=[	$bdeath08,		babe_bdeath09	] {};
void() babe_bdeath09	=[	$bdeath09,		babe_bdeath10	] {};
void() babe_bdeath10	=[	$bdeath10,		babe_bdeath11	] {};
void() babe_bdeath11	=[	$bdeath11,		babe_bdeath12	] {};
void() babe_bdeath12	=[	$bdeath12,		babe_bdeath13	] {};
void() babe_bdeath13	=[	$bdeath13,		babe_bdeath14	] {};
void() babe_bdeath14	=[	$bdeath14,		babe_bdeath14	] {};

void() babe_die =
{
	if (self.health < -35)
	{
		sound (self, CHAN_VOICE, "player/udeath.wav", 1, ATTN_NORM);
		ThrowHead ("progs/h_babe.mdl", self.health);
		ThrowGib ("progs/gib1.mdl", self.health);
		ThrowGib ("progs/gib2.mdl", self.health);
		ThrowGib ("progs/gib3.mdl", self.health);
		return;
	}
	if (random() < 0.5)
	sound (self, CHAN_VOICE, "bazooka/dies1.wav", 1, ATTN_IDLE);
	else
	sound (self, CHAN_VOICE, "bazooka/dies3.wav", 1, ATTN_IDLE);
		
	if (random() > 0.5)
		babe_die1 ();
	else
		babe_bdeath01 ();
};

void() babe_pain =
{
	if (self.pain_finished > time)
				return;

self.velocity_x = -50 - 50 * random();
self.velocity_y = 0;
self.velocity_z = 5 + 2 * random();
self.flags = self.flags - (self.flags & FL_ONGROUND);
	self.pain_finished = time + 2 - random();
	if (random() > 0.5)
		babe_pain1 ();
	else
		babe_bpain01 ();
};

//=================================================================

/*QUAKED monster_bazooka (1 0 0) (-16 -16 -24) (16 16 40) Ambush
*/
void() monster_bazooka =
{
	if (deathmatch)
	{
		remove(self);
		return;
	}
	precache_model2 ("progs/bazooka.mdl");
	precache_model2 ("progs/h_babe.mdl");	
	precache_model2 ("progs/pulse.mdl");	
	precache_sound2 ("bazooka/step1.wav");
	precache_sound2 ("enforcer/enfstop.wav");
	precache_sound2 ("bazooka/grrr.wav");
	precache_sound2 ("bazooka/ahaia.wav");
	precache_sound2 ("bazooka/yeow.wav");
	precache_sound2 ("bazooka/ooaa.wav");
	precache_sound2 ("bazooka/when.wav");
	precache_sound2 ("bazooka/dies1.wav");
	precache_sound2 ("bazooka/dies2.wav");
	precache_sound2 ("bazooka/dies3.wav");
	precache_sound2 ("bazooka/die.wav");
	precache_sound2 ("bazooka/stepstop.wav");
	precache_sound2 ("weapons/sgun1.wav");
	
	self.solid = SOLID_SLIDEBOX;
	self.movetype = MOVETYPE_STEP;
	
	setmodel (self, "progs/bazooka.mdl");
	setsize (self, '-16 -16 -24', '16 16 40'); 
	self.health = 150;
	
	self.th_stand = babe_stand;
	self.th_walk = babe_walk;
	self.th_run = babe_run;
	self.th_die = babe_die;
	self.th_pain = babe_pain;
	self.th_missile = babe_fire1;

	self.think = walkmonster_start;
	self.nextthink = time + 0.1 + random ()*0.1;	
};

	
 
 
