     Actor BlackOpsRifleman : GenericHumanScum 
       {
  scale 1.0
  obituary "%o was KIA-ed by the Black Ops Rifleman"
  health 240
  radius 15
  height 54
  mass 100
  speed 11
  Species "KNIGHT"
  +DONTHARMSPECIES
  painchance 165
  SeeSound "StMerc/See"
  PainSound "StMerc/pain"
  DeathSound "StMerc/Death"
  ActiveSound "StMerc/Active"
  dropitem "Chaingun", 5	
  Tag "Black Ops Rifleman"
  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_SetScale (scaleX+frandom(-0.02, 0.02), scaleY+frandom(-0.08,0.08))	
   Spawn2:	
    USRS A 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	 
  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_JumpIfTargetInLOs ("PullBack", 0, JLOSF_DEADNOJUMP, 220)
    TNT1 A 0 A_JumpIfInventory ("AKShotCounter", 30, "Reload")
	TNT1 A 0 A_Jump (199, "DodgeLeft", "DodgeRight", "DodgeLeftF", "DodgeLeftB", "DodgeRightF", "DodgeRightB")
    USRS AABBCCDD 3 A_Chase
    loop
  CheckReload:
    TNT1 A 0 A_Jump (195, "CheckReload2")
 	Goto SeeLoop+1
  CheckReload2:
    TNT1 A 0 A_JumpIfInventory ("AKShotCounter", 30, "Reload")
	Goto SeeLoop+1
  DodgeLeft:
        TNT1 A 0 A_FaceTarget
	    USRS 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))
	    USRS 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))
	    USRS 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
	    USRS 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)) 
	    USRS 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)) 
	    USRS AABBCCDD 2 ThrustThing(angle*256/360+64, 1, 0, 0)
		TNT1 A 0 A_Jump (228, "MissileCheck")
		Goto SeeLoop+1
	Evade:
	   TNT1 A 0
	   TNT1 A 0 A_Jump (150, "EvadeGrenade")
	   TNT1 A 0 A_Jump (256, "DodgeLeft", "DodgeRight", "DodgeLeftF", "DodgeLeftB", "DodgeRightF", "DodgeRightB")
	  goto SeeLoop
	PullBack:
	   USRS AABBCCDD 2 A_Recoil (random (1,3))
	  Goto MissileCheck  
  AlphaBravo:
    TNT1 A 0 A_JumpIfInventory ("AKShotCounter", 30, "Reload")
    USRS E 2 A_FaceTarget
	TNT1 A 0 A_Chase ("", "MissileAmbush", CHF_DONTMOVE)
	USRS E 2 A_FaceTarget
	TNT1 A 0 A_Chase ("", "MissileAmbush", CHF_DONTMOVE)
	USRS E 2 A_FaceTarget
	TNT1 A 0 A_Chase ("", "MissileAmbush", CHF_DONTMOVE)
	TNT1 A 0 A_TakeInventory ("GrenadeCoolDown", 1)
	TNT1 A 0 A_Jump (1, "SeeLoop")
   Loop
  MissileAmbush:
    USRS EE 4 A_FaceTarget		
  MissileCheck:
	TNT1 A 0 A_JumpIfInventory ("GrenadeCoolDown", 1, 2)
    TNT1 A 0 A_Jump (255, "40mmCheck") 
    TNT1 A 0 A_JumpIfTargetInLos ("Missile", 0, JLOSF_DEADNOJUMP)
	Goto SeeLoop
  Missile:
    TNT1 A 0 A_TakeInventory ("GrenadeCoolDown", 1)
    TNT1 A 0 A_TakeInventory ("ShotCounter", 6)
    USRS E 10 A_FaceTarget
	TNT1 A 0 A_JumpIfTargetInLos ("CloseQuarters", 0, JLOSF_DEADNOJUMP, 500)
	TNT1 A 0 A_JumpIfTargetInLos ("LongRange", 0, JLOSF_CLOSENOJUMP | JLOSF_DEADNOJUMP, 0, 1000)
   MissileLoop:
    USRS E 2 A_FaceTarget 
    TNT1 A 0 A_PlaySound ("USZRFL")
	TNT1 A 0 A_PlaySound ("AR155FF", 6, 0.5, 0)
	USRS F 1 BRIGHT A_CustomMissile ("AKTracer",42,9,random (-2,2))
	TNT1 A 0 A_GiveInventory ("AKShotCounter", 1)
	TNT1 A 0 A_JumpIfInventory ("AKShotCounter", 30, "Reload")
	TNT1 A 0 A_FaceTarget
    USRS E 1 A_MonsterRefire (2, "AlphaBravo")
	TNT1 A 0 A_JumpIfInventory ("ShotCounter", 6, "MissileEvade")
	TNT1 A 0 A_GiveInventory ("ShotCounter", 1)
    Loop
  MissileEvade:
    TNT1 A 0 A_TakeInventory ("ShotCounter", 6)
    USRS E 2 A_FaceTarget 
    TNT1 A 0 A_PlaySound ("USZRFL")
	TNT1 A 0 A_PlaySound ("AR155FF", 6, 0.5, 0)
	USRS F 1 BRIGHT A_CustomMissile ("AKTracer",42,9,random (-2,2))
	TNT1 A 0 A_GiveInventory ("AKShotCounter", 1)
	TNT1 A 0 A_JumpIfInventory ("AKShotCounter", 30, "Reload")
	TNT1 A 0 A_JumpIfInTargetLos ("Evade", 7, JLOSF_DEADNOJUMP)
	TNT1 A 0 A_FaceTarget
    USRS E 1 A_MonsterRefire (2, "AlphaBravo")
    Loop
  LongRange:
    USRS E 14 A_FaceTarget 
    TNT1 A 0 A_PlaySound ("USZRFL")
	TNT1 A 0 A_PlaySound ("AR155FF", 6, 0.5, 0)
	USRS F 1 BRIGHT A_CustomMissile ("AKTracer",42,9)
	TNT1 A 0 A_GiveInventory ("AKShotCounter", 1)
	TNT1 A 0 A_JumpIfInventory ("AKShotCounter", 30, "Reload")
	TNT1 A 0 A_FaceTarget
	USRS E 10 A_FaceTarget
	TNT1 A 0 A_PlaySound ("USZRFL")
	TNT1 A 0 A_PlaySound ("AR155FF", 6, 0.5, 0)
	USRS F 1 BRIGHT A_CustomMissile ("AKTracer",42,9, random (-1,1))
	TNT1 A 0 A_GiveInventory ("AKShotCounter", 1)
	TNT1 A 0 A_JumpIfInventory ("AKShotCounter", 30, "Reload")
	TNT1 A 0 A_JumpIfInTargetLos ("Evade", 7, JLOSF_DEADNOJUMP)
	USRS E 10 A_FaceTarget
	TNT1 A 0 A_PlaySound ("USZRFL")
	TNT1 A 0 A_PlaySound ("AR155FF", 6, 0.5, 0)
	USRS F 1 BRIGHT A_CustomMissile ("AKTracer",42,9, random (-1,1))
	TNT1 A 0 A_GiveInventory ("AKShotCounter", 1)
	TNT1 A 0 A_JumpIfInventory ("AKShotCounter", 30, "Reload")
    USRS E 1 A_MonsterRefire (2, "AlphaBravo")
    Loop
  CloseQuarters:
    USRS E 2 A_FaceTarget
    TNT1 A 0 A_PlaySound ("USZRFL")
	TNT1 A 0 A_PlaySound ("AR155FF", 6, 0.5, 0)
	USRS F 1 BRIGHT A_CustomMissile ("AKTracer",42,9,random (-3,3))
	TNT1 A 0 A_GiveInventory ("AKShotCounter", 1)
	TNT1 A 0 A_JumpIfInventory ("AKShotCounter", 30, "Reload")
	TNT1 A 0 A_FaceTarget
	USRS E 2 A_FaceTarget 
    TNT1 A 0 A_PlaySound ("USZRFL")
	TNT1 A 0 A_PlaySound ("AR155FF", 6, 0.5, 0)
	USRS F 1 BRIGHT A_CustomMissile ("AKTracer",42,9,random (-3,3))
	TNT1 A 0 A_GiveInventory ("AKShotCounter", 1)
	TNT1 A 0 A_JumpIfInventory ("AKShotCounter", 30, "Reload")
	TNT1 A 0 A_FaceTarget
	USRS E 2 A_FaceTarget 
    TNT1 A 0 A_PlaySound ("USZRFL")
	TNT1 A 0 A_PlaySound ("AR155FF", 6, 0.5, 0)
	USRS F 1 BRIGHT A_CustomMissile ("AKTracer",42,9,random (-3,3))
	TNT1 A 0 A_GiveInventory ("AKShotCounter", 1)
	TNT1 A 0 A_JumpIfInventory ("AKShotCounter", 30, "Reload")
	TNT1 A 0 A_FaceTarget
    USRS E 1 A_MonsterRefire (2, "AlphaBravo")
   Goto SeeLoop	
  40mmCheck:
    TNT1 A 0 A_JumpIfTargetInLos ("40mm", 0, JLOSF_CLOSENOJUMP | JLOSF_DEADNOJUMP, 1200, 600)
	Goto MissileCheck+1
  40mm:
    USRS E 9 A_FaceTarget
	TNT1 A 0 A_PlaySound ("GLFIR", CHAN_WEAPON)
	USRS F 2 BRIGHT A_CustomMissile ("Grenade40mm", 42, 9, random (-3,3), CMF_OFFSETPITCH, random (10, 16))
	TNT1 A 0 A_GiveInventory ("GrenadeCoolDown", 2)
	Goto SeeLoop
   EvadeGrenade:
     TNT1 A 0 
    TNT1 A 0 A_JumpIfTargetInLos ("Granata", 0, JLOSF_CLOSENOJUMP | JLOSF_DEADNOJUMP, 700, 300)
	TNT1 A 0 A_Jump (256, "DodgeLeft", "DodgeRight", "DodgeLeftF", "DodgeLeftB", "DodgeRightF", "DodgeRightB")
   Goto MissileCheck+2
  Granata:
    USRS D 10 A_FaceTarget
	TNT1 A 0 A_PlaySound ("GRNTOSS", CHAN_WEAPON)	
	USRS E 8 A_CustomMissile ("GreenHandGrenade", 42, 0, random (-5,5), CMF_OFFSETPITCH, random (10, 15))
	TNT1 A 0 A_Jump (256, "DodgeLeft", "DodgeRight", "DodgeLeftF", "DodgeLeftB", "DodgeRightF", "DodgeRightB")
	Goto SeeLoop	
  Reload:
    USRS E 17 A_PlaySound ("RIFOUT")
	TNT1 A 0 A_TakeInventory ("AKShotCounter", 30)
	USRS D 24 A_PlaySound ("RIFIN")
	USRS E 12 A_PlaySound ("RIFREAD")
	Goto SeeLoop
  Pain:
    USRS H 3
    USRS H 3 A_Pain
    goto SeeLoop
  Death:
  	//TNT1 A 0 A_Jump(20, "Suren")
    USRS I 5 A_Scream
    USRS J 5 A_NoBlocking
    USRS K 5 
    USRS L 5 A_Playsound ("FallingBodyGear", CHAN_BODY)
    USRS M -1
    stop
  XDeath:
    TNT1 A 0
    TNT1 A 0 A_SpawnItemEx ("VgavnonahCore", 0, 0, 0, 0, 0, 0, 0, SXF_NOCHECKPOSITION)
    PGIB A 5
    PGIB B 5 A_XScream
    PGIB C 5 A_NoBlocking
    PGIB D 5
    PGIB E -1
    Stop
  Raise:
    TNT1 A 0 
	TNT1 A 0 A_SpawnItemEx ("NanoResEffect", 0, 0, 15, 0, 0, 0, 0, SXF_NOCHECKPOSITION)
	NER1 MLKJI 4
   Goto See	
  Idle:
    USRS AA 4 A_Wander
    USRS A 0 A_Look
    USRS BB 4 A_Wander
    USRS A 0 A_Look
    USRS CC 4 A_Wander
    USRS A 0 A_Look
    USRS DD 4 A_Wander
    USRS A 0 A_Look
    loop
  }
	
}


	