$cd id1/models/fish
$origin 0 0 24
$base base		
$skin skin

$frame fishc 
$frame fishd

void() swimmonster_start;

void() f_stand1  =[      $fishc, f_stand2 ] {ai_stand();};
void() f_stand2  =[      $fishc, f_stand3 ] {ai_stand();};
void() f_stand3  =[      $fishc, f_stand4 ] {ai_stand();};
void() f_stand4  =[      $fishc, f_stand5 ] {ai_stand();};
void() f_stand5  =[      $fishc, f_stand6 ] {ai_stand();};
void() f_stand6  =[      $fishc, f_stand7 ] {ai_stand();};
void() f_stand7  =[      $fishc, f_stand8 ] {ai_stand();};
void() f_stand8  =[      $fishc, f_stand9 ] {ai_stand();};
void() f_stand9  =[      $fishc, f_stand10  ] {ai_stand();};
void() f_stand10 =[      $fishc, f_stand11 ] {ai_stand();};
void() f_stand11 =[      $fishc, f_stand12 ] {ai_stand();};
void() f_stand12 =[      $fishc, f_stand13 ] {ai_stand();};
void() f_stand13 =[      $fishc, f_stand14 ] {ai_stand();};
void() f_stand14 =[      $fishc, f_stand15 ] {ai_stand();};
void() f_stand15 =[      $fishc, f_stand16 ] {ai_stand();};
void() f_stand16 =[      $fishc, f_stand17 ] {ai_stand();};
void() f_stand17 =[      $fishc, f_stand18 ] {ai_stand();};
void() f_stand18 =[      $fishc, f_stand1 ] {ai_stand();};

void() f_walk1  =[      $fishc, f_walk2 ] {ai_walk(8);};
void() f_walk2  =[      $fishc, f_walk3 ] {ai_walk(8);};
void() f_walk3  =[      $fishc, f_walk4 ] {ai_walk(8);};
void() f_walk4  =[      $fishc, f_walk5 ] {ai_walk(8);};
void() f_walk5  =[      $fishc, f_walk6 ] {ai_walk(8);};
void() f_walk6  =[      $fishc, f_walk7 ] {ai_walk(8);};
void() f_walk7  =[      $fishc, f_walk8 ] {ai_walk(8);};
void() f_walk8  =[      $fishc, f_walk9 ] {ai_walk(8);};
void() f_walk9  =[      $fishc, f_walk10  ] {ai_walk(8);};
void() f_walk10 =[      $fishc, f_walk11 ] {ai_walk(8);};
void() f_walk11 =[      $fishc, f_walk12 ] {ai_walk(8);};
void() f_walk12 =[      $fishc, f_walk13 ] {ai_walk(8);};
void() f_walk13 =[      $fishc, f_walk14 ] {ai_walk(8);};
void() f_walk14 =[      $fishc, f_walk15 ] {ai_walk(8);};
void() f_walk15 =[      $fishc, f_walk16 ] {ai_walk(8);};
void() f_walk16 =[      $fishc, f_walk17 ] {ai_walk(8);};
void() f_walk17 =[      $fishc, f_walk18 ] {ai_walk(8);};
void() f_walk18 =[      $fishc, f_walk1 ] {ai_walk(8);};

void() f_run1  =[      $fishc, f_run2 ] {ai_run(12);
	if (random() < 0.5)
		sound (self, CHAN_VOICE, "fish/idle.wav", 1, ATTN_NORM);
};
void() f_run2  =[      $fishc, f_run3 ] {ai_run(12);};
void() f_run3  =[      $fishc, f_run4 ] {ai_run(12);};
void() f_run4  =[      $fishc, f_run5 ] {ai_run(12);};
void() f_run5  =[      $fishc, f_run6 ] {ai_run(12);};
void() f_run6  =[      $fishc, f_run7 ] {ai_run(12);};
void() f_run7  =[      $fishc, f_run8 ] {ai_run(12);};
void() f_run8  =[      $fishc, f_run9 ] {ai_run(12);};
void() f_run9  =[      $fishc, f_run1 ] {ai_run(12);};

void() fish_melee =
{
	local vector	delta;
	local float 	ldmg;

	if (!self.enemy)
		return;		// removed before stroke
		
	delta = self.enemy.origin - self.origin;

	if (vlen(delta) > 60)
		return;
		
	sound (self, CHAN_VOICE, "fish/bite.wav", 1, ATTN_NORM);
	ldmg = (random() + random()) * 3;
	T_Damage (self.enemy, self, self, ldmg);
};

void() f_attack1        =[      $fishc,       f_attack2 ] {ai_charge(10);};
void() f_attack2        =[      $fishc,       f_attack3 ] {ai_charge(10);};
void() f_attack3        =[      $fishc,       f_attack4 ] {fish_melee();};
void() f_attack4        =[      $fishc,       f_attack5 ] {ai_charge(10);};
void() f_attack5        =[      $fishc,       f_attack6 ] {ai_charge(10);};
void() f_attack6        =[      $fishc,       f_attack7 ] {ai_charge(10);};
void() f_attack7        =[      $fishc,       f_attack8 ] {ai_charge(10);};
void() f_attack8        =[      $fishc,       f_attack9 ] {ai_charge(10);};
void() f_attack9        =[      $fishc,       f_attack10] {fish_melee();};
void() f_attack10       =[      $fishc,      f_attack11] {ai_charge(10);};
void() f_attack11       =[      $fishc,      f_attack12] {ai_charge(10);};
void() f_attack12       =[      $fishc,      f_attack13] {ai_charge(10);};
void() f_attack13       =[      $fishc,      f_attack14] {ai_charge(10);};
void() f_attack14       =[      $fishc,      f_attack15] {ai_charge(10);};
void() f_attack15       =[      $fishc,      f_attack16] {fish_melee();};
void() f_attack16       =[      $fishc,      f_attack17] {ai_charge(10);};
void() f_attack17       =[      $fishc,      f_attack18] {ai_charge(10);};
void() f_attack18       =[      $fishc,      f_run1    ] {ai_charge(10);};

void() f_death1 =[      $fishd,        f_death2        ] {
sound (self, CHAN_VOICE, "fish/death.wav", 1, ATTN_NORM);
};
void() f_death2 =[      $fishd,        f_death3        ] {};
void() f_death3 =[      $fishd,        f_death4        ] {};
void() f_death4 =[      $fishd,        f_death5        ] {};
void() f_death5 =[      $fishd,        f_death6        ] {};
void() f_death6 =[      $fishd,        f_death7        ] {};
void() f_death7 =[      $fishd,        f_death8        ] {};
void() f_death8 =[      $fishd,        f_death9        ] {};
void() f_death9 =[      $fishd,        f_death10       ] {};
void() f_death10 =[      $fishd,       f_death11       ] {};
void() f_death11 =[      $fishd,       f_death12       ] {};
void() f_death12 =[      $fishd,       f_death13       ] {};
void() f_death13 =[      $fishd,       f_death14       ] {};
void() f_death14 =[      $fishd,       f_death15       ] {};
void() f_death15 =[      $fishd,       f_death16       ] {};
void() f_death16 =[      $fishd,       f_death17       ] {};
void() f_death17 =[      $fishd,       f_death18       ] {};
void() f_death18 =[      $fishd,       f_death19       ] {};
void() f_death19 =[      $fishd,       f_death20       ] {};
void() f_death20 =[      $fishd,       f_death21       ] {};
void() f_death21 =[      $fishd,       f_death21       ] {self.solid = SOLID_NOT;};

void() f_pain1  =[      $fishc, f_pain2 ] {};
void() f_pain2  =[      $fishc, f_pain3 ] {ai_pain(6);};
void() f_pain3  =[      $fishc, f_pain4 ] {ai_pain(6);};
void() f_pain4  =[      $fishc, f_pain5 ] {ai_pain(6);};
void() f_pain5  =[      $fishc, f_pain6 ] {ai_pain(6);};
void() f_pain6  =[      $fishc, f_pain7 ] {ai_pain(6);};
void() f_pain7  =[      $fishc, f_pain8 ] {ai_pain(6);};
void() f_pain8  =[      $fishc, f_pain9 ] {ai_pain(6);};
void() f_pain9  =[      $fishc, f_run1 ] {ai_pain(6);};

void(entity attacker, float damage)	fish_pain =
{

// fish allways do pain frames
	f_pain1 ();
};



/*UNTITLED-GAME/D monster_fish (1 0 0) (-16 -16 -24) (16 16 24) Ambush
*/
void() monster_fish =
{
	if (deathmatch)
	{
		remove(self);
		return;
	}
	precache_model2 ("progs/fish.mdl");

	precache_sound2 ("fish/death.wav");
	precache_sound2 ("fish/bite.wav");
	precache_sound2 ("fish/idle.wav");

	self.solid = SOLID_SLIDEBOX;
	self.movetype = MOVETYPE_STEP;

	setmodel (self, "progs/fish.mdl");

	setsize (self, '-16 -16 -24', '16 16 24');
	self.health = 25;
	
	self.th_stand = f_stand1;
	self.th_walk = f_walk1;
	self.th_run = f_run1;
	self.th_die = f_death1;
	self.th_pain = fish_pain;
	self.th_melee = f_attack1;
	
	swimmonster_start ();
};