

void () bringback =
{

	self.frags = self.frags + 1;

	if ( self.frags > 100)

	{

		if (skill < 3)
		{
			remove(self);
			return;
		}
	}

};

void () ArmyFireRocket;
void () army_fire;
void () army_fire2;
void () army_fire3;

void () army_stand1 = [ 0.000, army_stand2 ] {

   ai_stand ();

};

void () army_stand2 = [ 1.000, army_stand3 ] {

   ai_stand ();

};

void () army_stand3 = [ 2.000, army_stand4 ] {

   ai_stand ();

};

void () army_stand4 = [ 3.000, army_stand5 ] {

   ai_stand ();

};

void () army_stand5 = [ 4.000, army_stand6 ] {

   ai_stand ();

};

void () army_stand6 = [ 5.000, army_stand7 ] {

   ai_stand ();

};

void () army_stand7 = [ 6.000, army_stand8 ] {

   ai_stand ();

};

void () army_stand8 = [ 7.000, army_stand1 ] {

   ai_stand ();

};

void () army_walk1 = [ 90.000, army_walk2 ] {

   if ( (random () < 0.200) ) {

      sound (self,CHAN_VOICE,"soldier/idle.wav",TRUE,ATTN_IDLE);

   }
   ai_walk (TRUE);

};

void () army_walk2 = [ 91.000, army_walk3 ] {

   ai_walk (TRUE);

};

void () army_walk3 = [ 92.000, army_walk4 ] {

   ai_walk (TRUE);

};

void () army_walk4 = [ 93.000, army_walk5 ] {

   ai_walk (TRUE);

};

void () army_walk5 = [ 94.000, army_walk6 ] {

   ai_walk (FL_SWIM);

};

void () army_walk6 = [ 95.000, army_walk7 ] {

   ai_walk (MOVETYPE_WALK);

};

void () army_walk7 = [ 96.000, army_walk8 ] {

   ai_walk (MOVETYPE_STEP);

};

void () army_walk8 = [ 97.000, army_walk9 ] {

   ai_walk (MOVETYPE_STEP);

};

void () army_walk9 = [ 98.000, army_walk10 ] {

   ai_walk (FL_SWIM);

};

void () army_walk10 = [ 99.000, army_walk11 ] {

   ai_walk (FL_SWIM);

};

void () army_walk11 = [ 100.000, army_walk12 ] {

   ai_walk (FL_SWIM);

};

void () army_walk12 = [ 101.000, army_walk13 ] {

   ai_walk (TRUE);

};

void () army_walk13 = [ 102.000, army_walk14 ] {

   ai_walk (FALSE);

};

void () army_walk14 = [ 103.000, army_walk15 ] {

   ai_walk (TRUE);

};

void () army_walk15 = [ 104.000, army_walk16 ] {

   ai_walk (TRUE);

};

void () army_walk16 = [ 105.000, army_walk17 ] {

   ai_walk (TRUE);

};

void () army_walk17 = [ 106.000, army_walk18 ] {

   ai_walk (MOVETYPE_WALK);

};

void () army_walk18 = [ 107.000, army_walk19 ] {

   ai_walk (MOVETYPE_WALK);

};

void () army_walk19 = [ 108.000, army_walk20 ] {

   ai_walk (MOVETYPE_WALK);

};

void () army_walk20 = [ 109.000, army_walk21 ] {

   ai_walk (MOVETYPE_WALK);

};

void () army_walk21 = [ 110.000, army_walk22 ] {

   ai_walk (FL_SWIM);

};

void () army_walk22 = [ 111.000, army_walk23 ] {

   ai_walk (TRUE);

};

void () army_walk23 = [ 112.000, army_walk24 ] {

   ai_walk (TRUE);

};

void () army_walk24 = [ 113.000, army_walk1 ] {

   ai_walk (TRUE);

};

void () army_run1 = [ 73.000, army_run2 ] {

   if ( (random () < 0.200) ) {

      sound (self,CHAN_VOICE,"soldier/idle.wav",TRUE,ATTN_IDLE);

   }
   ai_run (MOVETYPE_BOUNCEMISSILE);

};

void () army_run2 = [ 74.000, army_run3 ] {

   ai_run (15.000);

};

void () army_run3 = [ 75.000, army_run4 ] {

   ai_run (MOVETYPE_BOUNCE);

};

void () army_run4 = [ 76.000, army_run5 ] {

   ai_run (MOVETYPE_BOUNCE);

};

void () army_run5 = [ 77.000, army_run6 ] {

   ai_run (FL_CLIENT);

};

void () army_run6 = [ 78.000, army_run7 ] {

   ai_run (15.000);

};

void () army_run7 = [ 79.000, army_run8 ] {

   ai_run (MOVETYPE_BOUNCE);

};

void () army_run8 = [ 80.000, army_run1 ] {

   ai_run (FL_CLIENT);

};

void () army_atk1 = [ 81.000, army_atk2 ] {

   ai_face ();
   monster_movetogoal(15);	//added to make soldier harder to kill

};

void () army_atk2 = [ 82.000, army_atk3 ] {

   ai_face ();

};

void () army_atk3 = [ 83.000, army_atk4 ] {

   ai_face ();

};

void () army_atk4 = [ 84.000, army_atk5 ] {

   ai_face ();

};

void () army_atk5 = [ 85.000, army_atk6 ] {

   ai_face ();
   self.weapon = IT_SHOTGUN;

	if ((random() < 0.4) && (self.enemy.classname != "monster_army") )
		ArmyFireRocket();
	else
	   army_fire ();

   self.effects = (self.effects | EF_MUZZLEFLASH);

};

void () army_atk6 = [ 86.000, army_atk7 ] {

   ai_face ();

};

void () army_atk7 = [ 87.000, army_atk8 ] {

   ai_face ();
   SUB_CheckRefire (army_atk1);

};

void () army_atk8 = [ 88.000, army_atk9 ] {

   ai_face ();

};

void () army_atk9 = [ 89.000, army_atk10 ] { //army_atk10 was army_run1

   ai_face ();

};

//added by bondo. this adds a new attack to the soldier
void () army_atk10 = [ 81.000, army_atk11 ] {

   ai_face ();
   monster_movetogoal(15);	//added to make soldier harder to kill
   


};

void () army_atk11 = [ 82.000, army_atk12 ] {

   ai_face ();

};

void () army_atk12 = [ 83.000, army_atk13 ] {

	self.weapon = IT_SUPER_NAILGUN;
	//army_fire2();
	army_fire3();
   self.effects = (self.effects | EF_MUZZLEFLASH);

};

void () army_atk13 = [ 84.000, army_atk14 ] {

	//army_fire2();
	army_fire3();
   self.effects = (self.effects | EF_MUZZLEFLASH);

};

void () army_atk14 = [ 85.000, army_atk15 ] {

	//army_fire2();
	army_fire3();
   self.effects = (self.effects | EF_MUZZLEFLASH);

};

void () army_atk15 = [ 86.000, army_atk16 ] {

	//army_fire2();
	army_fire3();
   self.effects = (self.effects | EF_MUZZLEFLASH);

};

void () army_atk16 = [ 87.000, army_atk17 ] {

   ai_face ();
   SUB_CheckRefire (army_atk1);

};

void () army_atk17 = [ 88.000, army_atk18 ] {

   ai_face ();

};

void () army_atk18 = [ 89.000, army_run1 ] {

   ai_face ();

};
//end of addition

void () army_pain1 = [ 40.000, army_pain2 ] {


};

void () army_pain2 = [ 41.000, army_pain3 ] {


};

void () army_pain3 = [ 42.000, army_pain4 ] {


};

void () army_pain4 = [ 43.000, army_pain5 ] {


};

void () army_pain5 = [ 44.000, army_pain6 ] {


};

void () army_pain6 = [ 45.000, army_run1 ] {

   ai_pain (TRUE);

};

void () army_painb1 = [ 46.000, army_painb2 ] {


};

void () army_painb2 = [ 47.000, army_painb3 ] {

   ai_painforward (13.000);

};

void () army_painb3 = [ 48.000, army_painb4 ] {

   ai_painforward (MOVETYPE_FLYMISSILE);

};

void () army_painb4 = [ 49.000, army_painb5 ] {


};

void () army_painb5 = [ 50.000, army_painb6 ] {


};

void () army_painb6 = [ 51.000, army_painb7 ] {


};

void () army_painb7 = [ 52.000, army_painb8 ] {


};

void () army_painb8 = [ 53.000, army_painb9 ] {


};

void () army_painb9 = [ 54.000, army_painb10 ] {


};

void () army_painb10 = [ 55.000, army_painb11 ] {


};

void () army_painb11 = [ 56.000, army_painb12 ] {


};

void () army_painb12 = [ 57.000, army_painb13 ] {

   ai_pain (FL_SWIM);

};

void () army_painb13 = [ 58.000, army_painb14 ] {


};

void () army_painb14 = [ 59.000, army_run1 ] {


};

void () army_painc1 = [ 60.000, army_painc2 ] {


};

void () army_painc2 = [ 61.000, army_painc3 ] {

   ai_pain (TRUE);

};

void () army_painc3 = [ 62.000, army_painc4 ] {


};

void () army_painc4 = [ 63.000, army_painc5 ] {


};

void () army_painc5 = [ 64.000, army_painc6 ] {

   ai_painforward (TRUE);

};

void () army_painc6 = [ 65.000, army_painc7 ] {

   ai_painforward (TRUE);

};

void () army_painc7 = [ 66.000, army_painc8 ] {


};

void () army_painc8 = [ 67.000, army_painc9 ] {

   ai_pain (TRUE);

};

void () army_painc9 = [ 68.000, army_painc10 ] {

   ai_painforward (MOVETYPE_STEP);

};

void () army_painc10 = [ 69.000, army_painc11 ] {

   ai_painforward (MOVETYPE_WALK);

};

void () army_painc11 = [ 70.000, army_painc12 ] {

   ai_painforward (MOVETYPE_TOSS);

};

void () army_painc12 = [ 71.000, army_painc13 ] {

   ai_painforward (FL_CLIENT);

};

void () army_painc13 = [ 72.000, army_run1 ] {


};

void (entity attacker, float damage) army_pain = {

   local float r;

   if ( (self.pain_finished > time) ) {

      return ;

   }
   r = random ();
   if ( (r < 0.200) ) {

      self.pain_finished = (time + 0.600);
      army_pain1 ();
      sound (self,CHAN_VOICE,"soldier/pain1.wav",TRUE,ATTN_NORM);

   } else {

      if ( (r < 0.600) ) {

         self.pain_finished = (time + 1.100);
         army_painb1 ();
         sound (self,CHAN_VOICE,"soldier/pain2.wav",TRUE,ATTN_NORM);

      } else {

         self.pain_finished = (time + 1.100);
         army_painc1 ();
         sound (self,CHAN_VOICE,"soldier/pain2.wav",TRUE,ATTN_NORM);

      }

   }

};

void () army_fire = {

   local vector dir;
   local entity en;

   ai_face ();
   sound (self,CHAN_WEAPON,"soldier/sattck1.wav",TRUE,ATTN_NORM);
   en = self.enemy;
   dir = (en.origin - (en.velocity * 0.200));
   dir = normalize ((dir - self.origin));
   FireBullets (4,dir,'0.100 0.100 0.000');
   Bullet (((self.origin + (v_forward * 16.000)) + (v_right * 6.000)),(v_right * 32.000));

};

void () army_fire2 = {

   local vector dir;
   local entity en;

   ai_face ();
   sound (self,CHAN_WEAPON,"gun/fire.wav",TRUE,ATTN_NORM);
   en = self.enemy;
   dir = (en.origin - (en.velocity * 0.200));
   dir = normalize ((dir - self.origin));
   FireBullets (4,dir,'0.100 0.100 0.000');
   Bullet (((self.origin + (v_forward * 16.000)) + (v_right * 6.000)),(v_right * 32.000));

};


void () army_fire3 = {

   local vector dir;
   local entity en;

   ai_face ();

   sound (self,CHAN_WEAPON,"weapons/spike2.wav",TRUE,ATTN_NORM);
   //self.attack_finished = (time + 0.200);
   en = self.enemy;
   dir = (en.origin - (en.velocity * 0.200));
   dir = normalize ((dir - self.origin));
   launch_spike ((self.origin + '0.000 0.000 16.000'),dir);
   newmis.touch = spike_touch;
   setmodel (newmis,"progs/s_spike.mdl");
   setsize (newmis,VEC_ORIGIN,VEC_ORIGIN);
   //self.punchangle_x = CONTENT_SOLID;

};


void () ArmyMissileTouch = {

   local float damg;

   if ( (other == self.owner) ) {

      return ;

   }
   if ( (pointcontents (self.origin) == CONTENT_SKY) ) {

      remove (self);
      return ;

   }
   damg = (20.000 + (random () * 10.000));
   if ( other.health ) {

      if ( (other.classname == "monster_shambler") ) {

         damg = (damg * 0.500);

      }
      T_Damage (other,self,self.owner,damg);

   }
   T_RadiusDamage (self,self.owner,30.000,world);
   self.origin = (self.origin - (FL_CLIENT * normalize (self.velocity)));
   WriteByte (MSG_BROADCAST,SVC_TEMPENTITY);
   WriteByte (MSG_BROADCAST,TE_EXPLOSION);
   WriteCoord (MSG_BROADCAST,self.origin_x);
   WriteCoord (MSG_BROADCAST,self.origin_y);
   WriteCoord (MSG_BROADCAST,self.origin_z);
   BecomeExplosion ();

};

void () ArmyFireRocket = {

   local entity missile,en;
	local vector dir;
	
   ai_face ();
   //missile.velocity = aim (self,1000.000);
   en = self.enemy;
   dir = (en.origin - (en.velocity * 0.200));
   dir = normalize ((dir - self.origin));
   sound (self,CHAN_WEAPON,"weapons/sgun1.wav",TRUE,ATTN_NORM);
   self.punchangle_x = CONTENT_SOLID;
   missile = spawn ();
   missile.owner = self;
   missile.movetype = MOVETYPE_FLYMISSILE;
   missile.solid = SOLID_BBOX;
   missile.classname = "armymissile";
   makevectors (self.v_angle);
   missile.velocity = dir;
   missile.velocity = (missile.velocity * 1000.000);
   missile.angles = vectoangles (missile.velocity);
   missile.touch = ArmyMissileTouch;
   missile.nextthink = (time + MOVETYPE_FLY);
   missile.think = SUB_Remove;
   //setmodel (missile,"progs/missile.mdl");
   setmodel (missile,"progs/missile2.mdl");
   setsize (missile,VEC_ORIGIN,VEC_ORIGIN);
   setorigin (missile,((self.origin + (v_forward * FL_CLIENT)) + '0.000 0.000 16.000'));

};

void (vector org, vector dir) launch_spike;

void () army_die1 = [ 8.000, army_die2 ] {


};

void () army_die2 = [ 9.000, army_die3 ] {


};

void () army_die3 = [ 10.000, army_die4 ] {

	//for respawn
//	if (skill > 2)
		self.solid = SOLID_NOT;
	   
	if (random() < 0.5)
	{
   	self.ammo_shells = 20; //was 5
		self.weapon = IT_SUPER_SHOTGUN;
	}
	else if (random() < 0.7)
	{
   	self.ammo_rockets = 5;
		self.weapon = IT_ROCKET_LAUNCHER;
	}
	else
	{
   	self.ammo_nails = 50;
		self.weapon = IT_SUPER_NAILGUN;
	}
   DropBackpack ();

};

void () army_die4 = [ 11.000, army_die5 ] {


};

void () army_die5 = [ 12.000, army_die6 ] {


};

void () army_die6 = [ 13.000, army_die7 ] {


};

void () army_die7 = [ 14.000, army_die8 ] {


};

void () army_die8 = [ 15.000, army_die9 ] {


};

void () army_die9 = [ 16.000, army_die10 ] {


};

void () army_die10 = [ 17.000, army_die10 ] {

//if (random() < 0.5)
//	self.oldorigin = self.origin;

//	if (skill > 2)
		bringback(); //respawn

};

void () army_cdie1 = [ 18.000, army_cdie2 ] {


};

void () army_cdie2 = [ 19.000, army_cdie3 ] {

   ai_back (MOVETYPE_FLY);

};

void () army_cdie3 = [ 20.000, army_cdie4 ] {

//	if (skill > 2)
		self.solid = SOLID_NOT;

	if (random() < 0.3)
	{
   	self.ammo_shells = 10; //was 5
		self.weapon = IT_SUPER_SHOTGUN;
	}
	else if (random() < 0.5)
	{
   	self.ammo_rockets = 5;
		self.weapon = IT_ROCKET_LAUNCHER;
	}
	else if (random() < 0.7)
	{
   	self.ammo_nails = 50;
		self.weapon = IT_SUPER_NAILGUN;
	}
   DropBackpack ();
   ai_back (MOVETYPE_STEP);

};

void () army_cdie4 = [ 21.000, army_cdie5 ] {

   ai_back (13.000);

};

void () army_cdie5 = [ 22.000, army_cdie6 ] {

   ai_back (MOVETYPE_WALK);

};

void () army_cdie6 = [ 23.000, army_cdie7 ] {

   ai_back (MOVETYPE_STEP);

};

void () army_cdie7 = [ 24.000, army_cdie8 ] {


};

void () army_cdie8 = [ 25.000, army_cdie9 ] {


};

void () army_cdie9 = [ 26.000, army_cdie10 ] {


};

void () army_cdie10 = [ 27.000, army_cdie11 ] {


};

void () army_cdie11 = [ 28.000, army_cdie11 ] {

//if (random() < 0.5)
//	self.oldorigin = self.origin;

//	if (skill > 2)
		bringback(); //respawn


};

void () army_die = {

   if ( (self.health < -35.000) ) {

      sound (self,CHAN_VOICE,"player/udeath.wav",TRUE,ATTN_NORM);
      /*
      ThrowHead ("progs/h_guard.mdl",self.health);
      ThrowGib ("progs/mangib1.mdl",self.health);
      ThrowGib ("progs/mangib2.mdl",self.health);
      ThrowGib ("progs/mangib3.mdl",self.health);
      */
      monster_gib("progs/h_guard.mdl");
      return ;

   }
   sound (self,CHAN_VOICE,"soldier/death1.wav",TRUE,ATTN_NORM);
   if ( (random () < 0.500) ) {

      army_die1 ();

   } else {

      army_cdie1 ();

   }
//	if (skill < 3)
//	   monster_corpse_setup('-16 -16 -24', '16 16 -10', "progs/h_guard.mdl");

};

void () monster_army = {

   self.solid = SOLID_SLIDEBOX;
   self.movetype = MOVETYPE_STEP;
   setmodel (self,"progs/soldier.mdl");
   setsize (self,VEC_HULL_MIN,'16.000 16.000 40.000');
   self.health = 50.0;
   self.th_stand = army_stand1;
   self.th_walk = army_walk1;
   self.th_run = army_run1;
   self.th_missile = army_atk1;
   self.th_pain = army_pain;
   self.th_die = army_die;

	//savecritter(); //respawn
	
   walkmonster_start ();

};
