     Actor MountainRifleMerc : GenericHumanScum 
       {
  scale 1.0
  obituary "%o was mistaken with the infidel by the Mountain Merc"
  health 175
  radius 15
  height 54
  mass 100
  speed 14
  Species "Reva"
  +DONTHARMSPECIES
  painchance 130
  SeeSound "MountainMerc/See"
  PainSound "MountainMerc/pain"
  DeathSound "MountainMerc/Death"
  ActiveSound "MountainMerc/Active"
  dropitem "Chaingun", 6
  Translation "112:127=117:127", "192:207=117:127"
  Tag "Mountain rifleman merc"
  MONSTER
  +FLOORCLIP
  States
       {
  Spawn:
	TNT1 A 0
	TNT1 A 0 A_JumpIf(ACS_NamedExecuteWithResult("STFUCheck") == 1, "STFU")
	TNT1 A 0 A_JumpIf(ACS_NamedExecuteWithResult ("VanJumpCheck") == 1, "VanJump")
	TNT1 A 0 A_Jump (50, "MAFON")
	TNT1 A 0 A_SpawnItemEx ("HumanTrails", 0, 0, 0)
	TNT1 A 0 A_SetScale (scaleX+frandom(-0.02, 0.02), scaleY+frandom(-0.08,0.08))	
   Spawn2:	
    ER3A T 10 A_Look
    loop
  STFU:
     TNT1 A 0
	 TNT1 A 0 ACS_NamedExecute ("STFUStMerc")
	 Goto Spawn+2
   VanJump:
	 TNT1 A 0
	 TNT1 A 0  NODELAY ACS_NamedExecuteAlways ("VanillaHeights")
	Goto Spawn+3	 
    MAFON:
	TNT1 A 0
	TNT1 A 0 A_SpawnItemEx ("DAGMSPAWNER", 0, 0, 0)
   Goto Spawn2		
  See:
    "####" A random(1,5)
    TNT1 A 0 A_Jump (70, "DodgeLeft", "DodgeRight", "DodgeLeftF", "DodgeLeftB", "DodgeRightF", "DodgeRightB")
	TNT1 A 0 A_Jump (180, "MissileCheck")
  SeeLoop:
    TNT1 A 0 A_CheckSight ("CheckReload")
    TNT1 A 0 A_JumpIfInventory ("RifleShotCounter", 60, "Reload")
	TNT1 A 0 A_Jump (199, "DodgeLeft", "DodgeRight", "DodgeLeftF", "DodgeLeftB", "DodgeRightF", "DodgeRightB")
	TNT1 A 0 A_TakeInventory ("GrenadeCoolDown", 1)
    ER3A AABBCCDD 3 A_Chase
    loop
  CheckReload:
    TNT1 A 0 A_Jump (150, "CheckReload2")
 	Goto SeeLoop+1
  CheckReload2:
    TNT1 A 0 A_JumpIfInventory ("RifleShotCounter", 60, "Reload")
	Goto SeeLoop+1
  DodgeLeft:
        TNT1 A 0 A_FaceTarget
	    ER3A AABBCCDD 2 ThrustThing(angle*256/360+192, 1, 0, 0)
		TNT1 A 0 A_Jump (228, "MissileCheck")
		TNT1 A 0 A_Jump (50, "DodgeRight")
		Goto SeeLoop+1
	DodgeLeftF:
	    TNT1 A 0 A_FaceTarget
	    TNT1 A 0 ThrustThingZ (0, 15, 0, 0)
	    TNT1 A 0 A_Recoil (random (-8,-3))
	    ER3A AABBCCDD 2 ThrustThing(angle*256/360+192, 1, 0, 0)
		TNT1 A 0 A_Jump (228, "MissileCheck")
		Goto SeeLoop+1
    DodgeLeftB:
	    TNT1 A 0 A_FaceTarget
	    TNT1 A 0 ThrustThingZ (0, 15, 0, 0)
	    TNT1 A 0 A_Recoil (random (3,8))
	    ER3A AABBCCDD 2 ThrustThing(angle*256/360+192, 1, 0, 0)
		TNT1 A 0 A_Jump (228, "MissileCheck")
		Goto SeeLoop+1
	DodgeRight:
	    TNT1 A 0 A_FaceTarget
	    ER3A AABBCCDD 2 ThrustThing(angle*256/360+64, 1, 0, 0)
		TNT1 A 0 A_Jump (228, "MissileCheck")
		Goto SeeLoop+1
	DodgeRightF:
	    TNT1 A 0 A_FaceTarget
	    TNT1 A 0 ThrustThingZ (0, 15, 0, 0)
	    TNT1 A 0 A_Recoil ( random (-8,-3)) 
	    ER3A AABBCCDD 2 ThrustThing(angle*256/360+64, 1, 0, 0)
		TNT1 A 0 A_Jump (228, "MissileCheck")
		Goto SeeLoop+1
	DodgeRightB:
	    TNT1 A 0 A_FaceTarget
	    TNT1 A 0 ThrustThingZ (0, 15, 0, 0)
	    TNT1 A 0 A_Recoil ( random (3,8)) 
	    ER3A AABBCCDD 2 ThrustThing(angle*256/360+64, 1, 0, 0)
		TNT1 A 0 A_Jump (228, "MissileCheck")
		Goto SeeLoop+1
	ChangingPosition:
		ER3A AABBCCDDAABBCCDDAABBCCDDAABBCCDDAABBCCDD 2 A_Wander 
  MissileCheck:
	TNT1 A 0 A_JumpIfInventory ("GrenadeCoolDown", 1, 2)
    TNT1 A 0 A_Jump (200, "GranataCheck") 
    TNT1 A 0 A_JumpIfTargetInLos ("Missile", 0, JLOSF_DEADNOJUMP)
	Goto SeeLoop
  Missile:
    ER3A E 9 A_FaceTarget
	TNT1 A 0 A_TakeInventory ("GrenadeCoolDown", 1)
	TNT1 A 0 A_JumpIfTargetInLos ("3Shot", 0, JLOSF_CLOSENOJUMP | JLOSF_DEADNOJUMP, 1000, 500) 
	TNT1 A 0 A_JumpIfTargetInLos ("Accuracy", 0, JLOSF_CLOSENOJUMP | JLOSF_DEADNOJUMP, 0, 1000)
  MissileLoop:
    ER3A E 9 A_FaceTarget
    TNT1 A 0 A_PlaySound ("USZRFL")
	TNT1 A 0 A_PlaySound ("HR155FF", 6, 0.5, 0)
	ER3A F 1 BRIGHT A_CustomMissile ("HRTracer",42,9,random (-14,-12))
	TNT1 A 0 A_GiveInventory ("RifleShotCounter", 1)
	TNT1 A 0 A_JumpIfInventory ("RifleShotCounter", 60, "Reload")
	//TNT1 A 0 A_JumpIfInTargetLos ("DodgeCheck")
	ER3A E 2 A_FaceTarget
	TNT1 A 0 A_PlaySound ("USZRFL")
	TNT1 A 0 A_PlaySound ("HR155FF", 6, 0.5, 0)
	ER3A F 1 BRIGHT A_CustomMissile ("HRTracer",42,9,random (-10,-8))
	TNT1 A 0 A_GiveInventory ("RifleShotCounter", 1)
	TNT1 A 0 A_JumpIfInventory ("RifleShotCounter", 60, "Reload")
	ER3A E 2 A_FaceTarget
	TNT1 A 0 A_PlaySound ("USZRFL")
	TNT1 A 0 A_PlaySound ("HR155FF", 6, 0.5, 0)
	ER3A F 1 BRIGHT A_CustomMissile ("HRTracer",42,9,random (-6,-4))
	TNT1 A 0 A_GiveInventory ("RifleShotCounter", 1)
	TNT1 A 0 A_JumpIfInventory ("RifleShotCounter", 60, "Reload")
	ER3A E 2 A_FaceTarget
	TNT1 A 0 A_PlaySound ("USZRFL")
	TNT1 A 0 A_PlaySound ("HR155FF", 6, 0.5, 0)
	ER3A F 1 BRIGHT A_CustomMissile ("HRTracer",42,9,random (0,4))
	TNT1 A 0 A_GiveInventory ("RifleShotCounter", 1)
	TNT1 A 0 A_JumpIfInventory ("RifleShotCounter", 60, "Reload")
	ER3A E 2 A_FaceTarget
	TNT1 A 0 A_PlaySound ("USZRFL")
	TNT1 A 0 A_PlaySound ("HR155FF", 6, 0.5, 0)
	ER3A F 1 BRIGHT A_CustomMissile ("HRTracer",42,9,random (6,8))
	TNT1 A 0 A_GiveInventory ("RifleShotCounter", 1)
	TNT1 A 0 A_JumpIfInventory ("RifleShotCounter", 60, "Reload")
	ER3A E 2 A_FaceTarget
	TNT1 A 0 A_PlaySound ("USZRFL")
	TNT1 A 0 A_PlaySound ("HR155FF", 6, 0.5, 0)
	ER3A F 1 BRIGHT A_CustomMissile ("HRTracer",42,9,random (10,12))
	TNT1 A 0 A_GiveInventory ("RifleShotCounter", 1)
	TNT1 A 0 A_JumpIfInventory ("RifleShotCounter", 60, "Reload")
	TNT1 A 0 A_JumpifInTargetLos ("ChangingPosition", 10, JLOSF_DEADNOJUMP | JLOSF_CLOSENOJUMP, 650, 500)
	Goto Seeloop
  3Shot:
    TNT1 A 0 A_PlaySound ("USZRFL")
	TNT1 A 0 A_PlaySound ("HR155FF", 6, 0.5, 0)
	ER3A F 1 BRIGHT A_CustomMissile ("HRTracer",42,9)
	TNT1 A 0 A_GiveInventory ("RifleShotCounter", 1)
	TNT1 A 0 A_JumpIfInventory ("RifleShotCounter", 60, "Reload")
	ER3A E 1 A_FaceTarget 
	TNT1 A 0 A_PlaySound ("USZRFL")
	TNT1 A 0 A_PlaySound ("HR155FF", 6, 0.5, 0)
	ER3A F 1 BRIGHT A_CustomMissile ("HRTracer",42,9,random (-1,1))
	TNT1 A 0 A_GiveInventory ("RifleShotCounter", 1)
	TNT1 A 0 A_JumpIfInventory ("RifleShotCounter", 60, "Reload")
	ER3A E 1 A_FaceTarget
	TNT1 A 0 A_PlaySound ("USZRFL")
	TNT1 A 0 A_PlaySound ("HR155FF", 6, 0.5, 0)
	ER3A F 1 BRIGHT A_CustomMissile ("HRTracer",42,9,random (-2,2))
	TNT1 A 0 A_GiveInventory ("RifleShotCounter", 1)
	TNT1 A 0 A_JumpIfInventory ("RifleShotCounter", 60, "Reload")
	ER3a E 1 A_FaceTarget
	Goto SeeLoop
  Accuracy:
    ER3A E 7 A_FaceTarget
	TNT1 A 0 A_PlaySound ("USZRFL")
	TNT1 A 0 A_PlaySound ("HR155FF", 6, 0.5, 0)
	ER3A F 1 BRIGHT A_CustomMissile ("HRTracer",42,9)
	TNT1 A 0 A_GiveInventory ("RifleShotCounter", 1)
	TNT1 A 0 A_JumpIfInventory ("RifleShotCounter", 60, "Reload")
	ER3A E 3 A_FaceTarget 
	TNT1 A 0 A_PlaySound ("USZRFL")
	TNT1 A 0 A_PlaySound ("HR155FF", 6, 0.5, 0)
	ER3A F 1 BRIGHT A_CustomMissile ("HRTracer",42,9)
	TNT1 A 0 A_GiveInventory ("RifleShotCounter", 1)
	TNT1 A 0 A_JumpIfInventory ("RifleShotCounter", 60, "Reload")
	ER3A E 3 A_FaceTarget
	TNT1 A 0 A_PlaySound ("USZRFL")
	TNT1 A 0 A_PlaySound ("HR155FF", 6, 0.5, 0)
	ER3A F 1 BRIGHT A_CustomMissile ("HRTracer",42,9)
	TNT1 A 0 A_GiveInventory ("RifleShotCounter", 1)
	TNT1 A 0 A_JumpIfInventory ("RifleShotCounter", 60, "Reload")
	ER3A E 3 A_FaceTarget 
	TNT1 A 0 A_PlaySound ("USZRFL")
	TNT1 A 0 A_PlaySound ("HR155FF", 6, 0.5, 0)
	ER3A F 1 BRIGHT A_CustomMissile ("HRTracer",42,9,random (-1,1))
	TNT1 A 0 A_GiveInventory ("RifleShotCounter", 1)
	TNT1 A 0 A_JumpIfInventory ("RifleShotCounter", 60, "Reload")
	ER3A E 2 A_FaceTarget
	TNT1 A 0 A_PlaySound ("USZRFL")
	TNT1 A 0 A_PlaySound ("HR155FF", 6, 0.5, 0)
	ER3A F 1 BRIGHT A_CustomMissile ("HRTracer",42,9,random (-2,2))
	TNT1 A 0 A_GiveInventory ("RifleShotCounter", 1)
	TNT1 A 0 A_JumpIfInventory ("RifleShotCounter", 60, "Reload")
    ER3A E 3 A_FaceTarget
   Goto SeeLoop
  GranataCheck:
    TNT1 A 0 A_JumpIfTargetInLos ("Granata", 0, JLOSF_CLOSENOJUMP | JLOSF_DEADNOJUMP, 700, 300)
	Goto MissileCheck+1
  Granata:
	TNT1 A 0
	TNT1 A 0
	TNT1 A 0 A_Jump (100, 2)
	TNT1 A 0 A_Playsound ("MountainMerc/Grenade", CHAN_VOICE)
    ER3A E 9 A_FaceTarget
	TNT1 A 0 A_PlaySound ("GRNTOSS", CHAN_WEAPON)
	TNT1 A 0 A_CustomMissile ("PipeBomb", 42, 0, random (-5,6), CMF_OFFSETPITCH, random (10, 16))
	TNT1 A 0 A_GiveInventory ("GrenadeCoolDown", 2)
	ER3A DE 4 
	Goto SeeLoop
  Reload:
    ER3A E 17 A_PlaySound ("HRIFOUT")
	TNT1 A 0 A_TakeInventory ("RifleShotCounter", 60)
	ER3A D 42 A_PlaySound ("HRIFIN")
	ER3A E 16
	Goto SeeLoop
  Pain:
    ER3A H 3
    ER3A H 3 A_Pain
	TNT1 A 0 A_Jump (49, "ChangingPosition")
	TNT1 A 0
    goto SeeLoop
  Death:
  	//TNT1 A 0 A_Jump(20, "Suren")
    ER3A I 5 A_Scream
    ER3A J 5
    ER3A K 5 A_NoBlocking
    ER3A KL 5 A_Playsound ("FallingBodyGear", CHAN_BODY)
    ER3A M -1
    stop
  XDeath:
    TNT1 A 0
    TNT1 A 0 A_SpawnItemEx ("VgavnonahCore", 0, 0, 0, 0, 0, 0, 0, SXF_NOCHECKPOSITION)
    ER3A U 5
    ER3A V 5 A_XScream
    PGIB A 5 A_NoBlocking
    PGIB BCD 5
    PGIB E -1
    Stop
  Raise:
    TNT1 A 0 
	TNT1 A 0 A_SpawnItemEx ("NanoResEffect", 0, 0, 15, 0, 0, 0, 0, SXF_NOCHECKPOSITION)
	ER3A MLKJI 5
   Goto See	
  Idle:
    ER3A AA 4 A_Wander
    ER3A A 0 A_Look
    ER3A BB 4 A_Wander
    ER3A A 0 A_Look
    ER3A CC 4 A_Wander
    ER3A A 0 A_Look
    ER3A DD 4 A_Wander
    ER3A A 0 A_Look
    loop
	}
	   
	   
  }
  
  
  
	Actor MountainRifleMercSpawner : RandomSpawner
		{
		 DropItem MountainRifleMerc
		 DropItem MountainRifleMercHaki
		 DropItem MountainRifleMercBlack
		 DropItem MountainRifleMercBlackCap
		 DropItem MountainRifleMercGreyCap
		 DropItem MountainRifleMercBrownYellowCap
		 DropItem MountainRifleMercWhiteBlackCap
		 DropItem MountainRifleMercBrownBlackCap
		}
	   
	   
	   
	   

	Actor MountainRifleMercHaki : MountainRifleMerc 
		{
		 Translation "112:127=5:12", "192:207=117:127" 
		}

	Actor MountainRifleMercBlack : MountainRifleMerc 
		{
		 Translation "112:127=3:8", "192:207=117:127"
		}
		
	Actor MountainRifleMercBlackCap : MountainRifleMerc 
		{
		 Translation "112:127=117:127", "192:207=5:8"
		}
		
	Actor MountainRifleMercGreyCap : MountainRifleMerc 
		{
		 Translation "112:127=117:127", "192:207=80:111"
		}
		
	Actor MountainRifleMercBrownYellowCap : MountainRifleMerc 
		{
		 Translation "112:127=64:79", "192:207=160:165"
		}
		
	Actor MountainRifleMercWhiteBlackCap : MountainRifleMerc 
		{
		 Translation "112:127=80:95", "192:207=5:8"
		}
	
	Actor MountainRifleMercBrownBlackCap : MountainRifleMerc 
		{
		 Translation "112:127=64:79", "192:207=5:8"
		}
		
		
		
	Actor RifleShotCounter : Inventory
		{
		 Inventory.MaxAmount 90
		}	