    Actor BlackGlassesAutoPistol : GenericHumanScum
 {
  scale 1.0
  obituary "%o was neutralised by Pistol Security"
  health 66
  radius 15
  height 54
  mass 100
  speed 12
  painchance 200
  Species "IMP"
+DONTHARMSPECIES
  SeeSound "StMerc/see"
  PainSound "StMerc/pain"
  DeathSound "StMerc/Death"
  ActiveSound "StMerc/active" 
  Tag "Automatic Pistol Guard"
  MONSTER
  +DROPOFF
  +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.04,0.04))
				TNT1 A 0 A_SpawnItemEx ("HumanTrails", 0, 0, 0)
            Spawn2:	
			    DPSS A 9 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,4)
                 TNT1 A 0 A_Jump (170, "DodgeLeft", "DodgeRight", "DodgeLeftF", "DodgeLeftB", "DodgeRightF", "DodgeRightB")
	             TNT1 A 0 A_Jump (230, "MissileCheck")
			SeeLoop:
			    TNT1 A 0 A_Jump (170, "DodgeLeft", "DodgeRight", "DodgeLeftF", "DodgeLeftB", "DodgeRightF", "DodgeRightB")
			    TNT1 A 0 A_JumpIfInventory ("APistolShotCounter", 18, "Reload")
			    DPSS AAABBBCCCDDD 2 A_Chase
				Loop
	 DodgeLeft:
	    TNT1 A 0 A_FaceTarget
	    DPSS AABBCCDD 2 ThrustThing(angle*256/360+192, 1, 0, 0)
		TNT1 A 0 A_Jump (120, "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))
	    DPSS AABBCCDD 2 ThrustThing(angle*256/360+192, 1, 0, 0)
		TNT1 A 0 A_Jump (120, "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))
	    DPSS AABBCCDD 2 ThrustThing(angle*256/360+192, 1, 0, 0)
		TNT1 A 0 A_Jump (120, "MissileCheck")
		Goto SeeLoop+1
	DodgeRight:
	    TNT1 A 0 A_FaceTarget
	    DPSS AABBCCDD 2 ThrustThing(angle*256/360+64, 1, 0, 0)
		TNT1 A 0 A_Jump (100, "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)) 
	    DPSS AABBCCDD 2 ThrustThing(angle*256/360+64, 1, 0, 0)
		TNT1 A 0 A_Jump (100, "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)) 
	    DPSS AABBCCDD 2 ThrustThing(angle*256/360+64, 1, 0, 0)
		TNT1 A 0 A_Jump (100, "MissileCheck")
		Goto SeeLoop+1
		   MissileCheck:
		        TNT1 A 0 A_JumpIfTargetInLos ("Missile", 0, JLOSF_DEADNOJUMP)
				Goto SeeLoop
		    Missile:
			    DPSS E 6 A_FaceTarget
				TNT1 A 0 A_JumpIfCloser (350, "RapidFire")
				TNT1 A 0 A_JumpIfTargetInLos ("BurstFire", 0, JLOSF_CLOSENOJUMP | JLOSF_DEADNOJUMP, 800, 351)
				TNT1 A 0 A_JumpIfInventory ("APistolShotCounter", 18, "Reload")
				TNT1 A 0 A_Playsound ("PA2PISTF")
				TNT1 A 0 A_PlaySound ("BYPFRF", 6, 0.5, 0)
				DPSS F 3 BRIGHT A_CustomMissile ("APistolTracer", 45,0, random (-2,2))
				TNT1 A 0 A_GiveInventory ("APistolShotCounter", 1)
				Goto SeeLoop
		    BurstFire:
			    DPSS E 2 A_FaceTarget
				TNT1 A 0 A_JumpIfInventory ("APistolShotCounter", 18, "Reload")
				TNT1 A 0 A_Playsound ("PA2PISTF")
				TNT1 A 0 A_PlaySound ("BYPFRF", 6, 0.5, 0)
				DPSS F 1 BRIGHT A_CustomMissile ("APistolTracer", 45,0, random (-3,3))
				TNT1 A 0 A_GiveInventory ("APistolShotCounter", 1)
				DPSS E 2 A_FaceTarget
				TNT1 A 0 A_JumpIfInventory ("APistolShotCounter", 18, "Reload")
				TNT1 A 0 A_Playsound ("PA2PISTF")
				TNT1 A 0 A_PlaySound ("BYPFRF", 6, 0.5, 0)
				DPSS F 1 BRIGHT A_CustomMissile ("APistolTracer", 45,0, random (-5,5))
				TNT1 A 1 A_GiveInventory ("APistolShotCounter", 1)
				DPSS E 2 A_FaceTarget
				TNT1 A 0 A_JumpIfInventory ("APistolShotCounter", 18, "Reload")
				TNT1 A 0 A_Playsound ("PA2PISTF")
				TNT1 A 0 A_PlaySound ("BYPFRF", 6, 0.5, 0)
				DPSS F 1 BRIGHT A_CustomMissile ("APistolTracer", 45,0, random (-7,7))
				TNT1 A 0 A_GiveInventory ("APistolShotCounter", 1)
				TNT1 A 0 A_JumpIfInventory ("APistolShotCounter", 18, "Reload")
			   Goto SeeLoop	
			RapidFire:
			    DPSS E 3 A_FaceTarget
				TNT1 A 0 A_JumpIfInventory ("APistolShotCounter", 18, "Reload")
				TNT1 A 0 A_Playsound ("PA2PISTF")
				TNT1 A 0 A_PlaySound ("BYPFRF", 6, 0.5, 0)
				DPSS F 1 BRIGHT A_CustomMissile ("APistolTracer", 45,0, random (-8,8))
				TNT1 A 0 A_GiveInventory ("APistolShotCounter", 1)
				TNT1 A 0 A_JumpIfInventory ("APistolShotCounter", 18, "Reload")
				TNT1 A 0 A_MonsterRefire (40, "SeeLoop")
			     Loop
			Reload:
                DPSS D 19 A_PlaySound ("GlokRel1")
	            TNT1 A 0 A_TakeInventory ("APistolShotCounter", 18)
	            DPSS E 29 A_PlaySound ("GlokRel2")
	            DPSS D 15 A_PlaySound ("GlokRel3")
				Goto SeeLoop
			Pain:
			    DPSS G 3
			    DPSS G 3 A_Pain
			Goto SeeLoop
		Death:
			DPSS H 5
			DPSS I 5 A_Scream
			DPSS J 5
			DPSS K random(10,20) A_NoBlocking
			TNT1 A 0 A_Playsound ("FallingBodyGear", CHAN_BODY)
			DPSS L -1
			Stop
		XDeath:
		    TNT1 A 0
            TNT1 A 0 A_SpawnItemEx ("VgavnonahCore", 0, 0, 0, 0, 0, 0, 0, SXF_NOCHECKPOSITION)
		    DPSS M 5
			DPSS N 5
			DPSS O 5 A_PlaySound("gibsound")
			DPSS P 5 A_NoBlocking
			DPSS QRST 5
			DPSS U -1
			Stop
		Raise:
			TNT1 A 0 
			TNT1 A 0 A_SpawnItemEx ("NanoResEffect", 0, 0, 15, 0, 0, 0, 0, SXF_NOCHECKPOSITION)
			DPSS LKJIH 5
		   Goto See	
		   }
		   
}



Actor APistolTracer 
{
Projectile
Damage (4)
+BLOODSPLATTER
+FORCEXYBILLBOARD
+SKYEXPLODE
+DONTSPLASH 
+NOEXTREMEDEATH
radius 2
height 2
speed 20
renderstyle Add
alpha 0.9
scale .15
 States
     {
	  Spawn:
	    TNT1 A 0
		TNT1 A 0 NoDelay ACS_NamedExecuteAlways("PotentialProjectileHider", 0,0,0)
	  Spawn2:
	    TRAC A 1 Bright A_PlaySound ("Bullet/Fly", 0, 1.0, true)
		Loop
	  Crash: 	
	  Death:
	    TNT1 A 0
		TNT1 A 0 NoDelay ACS_NamedExecuteAlways("ProjectileIsDead", 0,0,0)
	    TNT1 A 0 A_Playsound ("Bullet/Impact")
		TNT1 A 0 A_Jump (100, "D2")
		FX57 CDEFGHI 1 BRIGHT
		Stop
	  D2:
	    FX58 CDEFGHI 1 BRIGHT
		Stop
      XDeath:
	    TNT1 A 0
		TNT1 A 0 NoDelay ACS_NamedExecuteAlways("ProjectileIsDead", 0,0,0)
		TNT1 A 1
		Stop	
	 }
}

Actor APistolShotCounter : Inventory
{
Inventory.maxamount 18
}		   