Actor TerPistol : GenericHumanScum  
{

 //----------------------------COMPLEX DOOM COMPATIBILITY DROPS------------------------

DropItem "HealthFlask" 40
DropItem "ArmorCharge" 40
DropItem "AmmoPack" 20
DropItem "HandGrenadeAmmo" 50 1
DropItem "MineAmmo" 25 1


Health 31
Monster
Radius 20
Height 56
Speed 11
PainChance 170
Monster
Species "Z"
+DOHARMSPECIES
MinMissileChance 90
seesound "Arab/See"
painsound "Arab/Pain"
deathsound "Arab/Death"
activesound "Arab/Active"
Tag "Desert Moderate Opposition Pistol Disciple"
Translation "112:127=80:111", "192:207=88:111"
scale 1.0
Obituary "%o helped the lesser desert disciple to improve his faith"
//+DROPOFF
DropItem "Clip"
  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.08, 0.08), scaleY+frandom(-0.08,0.08)) 
	TNT1 A 0 A_SpawnItemEx ("HumanTrails", 0, 0, 0)
	TNT1 A 0 A_SpawnItemEx ("AlaWRITER", 0, 0, 0, 0, 0, 0, 0, SXF_NOCHECKPOSITION, 69)
  Spawn2:	
	TERP T 10 A_Look
	loop	
  STFU:
     TNT1 A 0
	 TNT1 A 0 ACS_NamedExecute ("STFUArab")
	 Goto Spawn+2
  VanJump:
	 TNT1 A 0
	 TNT1 A 0  NODELAY ACS_NamedExecuteAlways ("VanillaHeights")
	Goto Spawn+3	 
  
  KabeemCheck:
    TNT1 A 0 
    TNT1 A 0 A_JumpIfCloser (115, "Kabeem")
   Goto SeeLoop	
  Kabeem:	
    TERP G 30 A_PlaySound ("Arab/See")
	TNT1 A 0 A_SpawnItemEx ("AllaExplosion", 0, 0, 0, 0, 0, 0, 0, SXF_NOCHECKPOSITION)
	TNT1 A 0 DamageThing (999)
   Goto XDeath
	See:
	 "####" A random(1,6)
	 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_Jump (170, "DodgeLeft", "DodgeRight", "DodgeLeftF", "DodgeLeftB", "DodgeRightF", "DodgeRightB")
	 TERP AABB 3 A_Chase
	 TNT1 A 0 A_JumpIfHealthLower (12, "KabeemCheck")
	 TERP CCDD 3 A_Chase  
	Loop
   MissileCheck:
    TNT1 A 0
	TNT1 A 0 A_JumpIfInventory ("GrenadeCoolDown", 1, 2)
    TNT1 A 0 A_Jump (105, "PipeBombCheck")
	TNT1 A 0 A_JumpIfTargetInLos ("Missile")
	Goto SeeLoop	
  CheckReload:
    TNT1 A 0 A_Jump (150, "CheckReload2")
 	Goto SeeLoop+1
  CheckReload2:
    TNT1 A 0 A_JumpIfInventory ("PistolShotCounter", 9, "Reload")
	Goto SeeLoop+1
  DodgeLeft:
        TNT1 A 0 A_FaceTarget
	    TERP 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+2
	DodgeLeftF:
	    TNT1 A 0 A_FaceTarget
	    TNT1 A 0 ThrustThingZ (0, 15, 0, 0)
	    TNT1 A 0 A_Recoil (random (-8,-3))
	    TERP AABBCCDD 2 ThrustThing(angle*256/360+192, 1, 0, 0)
		TNT1 A 0 A_Jump (120, "MissileCheck")
		Goto SeeLoop+2
    DodgeLeftB:
	    TNT1 A 0 A_FaceTarget
	    TNT1 A 0 ThrustThingZ (0, 15, 0, 0)
	    TNT1 A 0 A_Recoil (random (3,8))
	    TERP AABBCCDD 2 ThrustThing(angle*256/360+192, 1, 0, 0)
		TNT1 A 0 A_Jump (120, "MissileCheck")
		Goto SeeLoop+2
	DodgeRight:
	    TNT1 A 0 A_FaceTarget
	    TERP AABBCCDD 2 ThrustThing(angle*256/360+64, 1, 0, 0)
		TNT1 A 0 A_Jump (100, "MissileCheck")
		Goto SeeLoop+2
	DodgeRightF:
	    TNT1 A 0 A_FaceTarget
	    TNT1 A 0 ThrustThingZ (0, 15, 0, 0)
	    TNT1 A 0 A_Recoil ( random (-8,-3)) 
	    TERP AABBCCDD 2 ThrustThing(angle*256/360+64, 1, 0, 0)
		TNT1 A 0 A_Jump (100, "MissileCheck")
		Goto SeeLoop+2
	DodgeRightB:
	    TNT1 A 0 A_FaceTarget
	    TNT1 A 0 ThrustThingZ (0, 15, 0, 0)
	    TNT1 A 0 A_Recoil ( random (3,8)) 
	    TERP AABBCCDD 2 ThrustThing(angle*256/360+64, 1, 0, 0)
		TNT1 A 0 A_Jump (100, "MissileCheck")
		Goto SeeLoop+2
		
 Missile:
    TNT1 A 0 A_TakeInventory ("GrenadeCooldown", 1)
    TNT1 A 0 A_JumpIfInventory ("PistolShotCounter", 9, "Reload")
	TERP E 10 A_FaceTarget
	TNT1 A 0 A_JumpIfTargetInLos ("CloseQuarters", 0, JLOSF_DEADNOJUMP, 500)
	TNT1 A 0 A_JumpIfTargetInLos ("LongRange", 0, JLOSF_DEADNOJUMP | JLOSF_CLOSENOJUMP, 0, 1000)
	TERP E 2 A_FaceTarget
    TNT1 A 0 A_PlaySound ("PA2PISTF")
	TNT1 A 0 A_PlaySound ("BYPFRF", 6, 0.5, 0)
	TNT1 A 0 A_CustomMissile ("ApistolTracer", 45, 0)
	TERP F 2 BRIGHT A_FaceTarget
	TNT1 A 0 A_GiveInventory ("PistolShotCounter", 1)
	TNT1 A 0 A_JumpIfInventory ("PistolShotCounter", 9, "Reload")
	TERP E 3 A_FaceTarget
	TNT1 A 0 A_PlaySound ("PA2PISTF")
	TNT1 A 0 A_PlaySound ("BYPFRF", 6, 0.5, 0)
	TNT1 A 0 A_CustomMissile ("ApistolTracer", 45, 0, random (-5,5))
	TERP F 2 BRIGHT A_FaceTarget
	TNT1 A 0 A_GiveInventory ("PistolShotCounter", 1)
	TNT1 A 0 A_JumpIfInventory ("PistolShotCounter", 9, "Reload")
	TERP E 3 A_FaceTarget
	TNT1 A 0 A_PlaySound ("PA2PISTF")
	TNT1 A 0 A_PlaySound ("BYPFRF", 6, 0.5, 0)
	TNT1 A 0 A_CustomMissile ("ApistolTracer", 45, 0, random (-5,5))
	TERP F 2 BRIGHT A_FaceTarget
	TNT1 A 0 A_GiveInventory ("PistolShotCounter", 1)
	TNT1 A 0 A_JumpIfInventory ("PistolShotCounter", 9, "Reload")
	TERP E 3 A_FaceTarget 
   Goto SeeLoop
 CloseQuarters:
    TERP E 2 A_FaceTarget
  CQLoop:	
	TNT1 A 0 A_PlaySound ("PA2PISTF")
	TNT1 A 0 A_PlaySound ("BYPFRF", 6, 0.5, 0)
	TNT1 A 0 A_CustomMissile ("ApistolTracer", 45, 0, random (-3,3))
	TERP F 2 BRIGHT A_FaceTarget
	TNT1 A 0 A_GiveInventory ("PistolShotCounter", 1)
	TNT1 A 0 A_JumpIfInventory ("PistolShotCounter", 9, "Reload")
	TERP E 7 A_FaceTarget
	TNT1 A 0 A_MonsterRefire (2, "SeeLoop")
   Loop
 LongRange:
    TERP E 15 A_FaceTarget
    TNT1 A 0 A_PlaySound ("PA2PISTF")
	TNT1 A 0 A_PlaySound ("BYPFRF", 6, 0.5, 0)
	TNT1 A 0 A_CustomMissile ("ApistolTracer", 45, 0)
	TERP F 2 BRIGHT A_FaceTarget
	TNT1 A 0 A_GiveInventory ("PistolShotCounter", 1)
	TNT1 A 0 A_JumpIfInventory ("PistolShotCounter", 9, "Reload")
	TERP E 3 A_FaceTarget
	TNT1 A 0 A_PlaySound ("PA2PISTF")
	TNT1 A 0 A_PlaySound ("BYPFRF", 6, 0.5, 0)
	TNT1 A 0 A_CustomMissile ("ApistolTracer", 45, 0, random (-1,1))
	TERP F 2 BRIGHT A_FaceTarget
	TNT1 A 0 A_GiveInventory ("PistolShotCounter", 1)
	TNT1 A 0 A_JumpIfInventory ("PistolShotCounter", 9, "Reload")
	TERP E 3 A_FaceTarget
	TNT1 A 0 A_PlaySound ("PA2PISTF")
	TNT1 A 0 A_PlaySound ("BYPFRF", 6, 0.5, 0)
	TNT1 A 0 A_CustomMissile ("ApistolTracer", 45, 0, random (-1,1))
	TERP F 2 BRIGHT A_FaceTarget
	TNT1 A 0 A_GiveInventory ("PistolShotCounter", 1)
	TNT1 A 0 A_JumpIfInventory ("PistolShotCounter", 9, "Reload")
   TNT1 A 0 A_MonsterRefire (2, "SeeLoop")
   Loop	
 PipeBombCheck:
	TNT1 A 0
    TNT1 A 0 A_JumpIfTargetInLos ("PipeBomb", 0, JLOSF_CLOSENOJUMP | JLOSF_DEADNOJUMP, 700, 300)
	Goto MissileCheck+2
  PipeBomb:
    TERP E 12 A_FaceTarget
	TNT1 A 0 A_PlaySound ("GRNTOSS", CHAN_WEAPON)
	TERP F 3 A_CustomMissile ("PipeBomb", 42, 0, random (-3,3), CMF_OFFSETPITCH, random (9, 14))
	TNT1 A 0 A_GiveInventory ("GrenadeCoolDown", 5)
	Goto SeeLoop  
 Reload:
    TERP D 17
	TNT1 A 0 A_PlaySound ("LPISOUT")
	TNT1 A 0 A_TakeInventory ("PistolShotCounter", 9)
	TERP E 24
	TNT1 A 0 A_PlaySound ("LPISIN")
	TERP D 22
	TNT1 A 0 A_PlaySound ("LPISREAD")
	TERP E 5
	TNT1 A 0
	Goto SeeLoop
 MissileCheck2:
    TNT1 A 0 A_JumpIfTargetInLos ("Missile")
	Goto SeeLoop
 Pain:
	TERP G 3
	TERP G 3 A_Pain
	Goto SeeLoop
 Death:
	TERP H 5 A_Scream
	TERP I 5 A_NoBlocking
	TERP J 5
	TERP K 5 A_Playsound ("FallingBodyLight", CHAN_BODY)
	TERP L -1
	Stop
  Raise:
    TNT1 A 0 
    TNT1 A 0 A_SpawnItemEx ("NanoResEffect", 0, 0, 15, 0, 0, 0, 0, SXF_NOCHECKPOSITION)
	TERP LKJIH 5
   Goto See	
  XDeath:
    TNT1 A 0
    TNT1 A 0 A_SpawnItemEx ("VgavnonahCore", 0, 0, 0, 0, 0, 0, 0, SXF_NOCHECKPOSITION)
    TERP M 5
    TERP N 5 A_XScream
    PGIB A 5 A_NoBlocking
    PGIB BCD 5
    PGIB E -1
    Stop	
    }
}	


	Actor TerPistolSpawner : RandomSpawner 
		{
		 DropItem TerPistol
		 DropItem TerPistolHakiGrey
		 DropItem TerPistolBrown
		 DropItem TerPistolBlack
		 DropItem TerPistolSandGrey
		 DropItem TerPistolGreyBrown
		 DropItem TerPistolSandBrown
		 DropItem TerPistolBlackGrey
		}
		
		
		
		
		
	Actor TerPistolHakiGrey : TerPistol 
		{
		 Translation "112:127=152:159", "192:207=80:111"
		}

	Actor TerPistolBrown : TerPistol
		{
		 Translation "112:127=64:79", "192:207=66:79"
		}
		
	Actor TerPistolBlack : TerPistol
		{
		 Translation "112:114=102:104", "115:115=3:3", "116:122=105:111", "123:126=5:8", "127:127=0:0", "192:207=4:8"
		}
		
	Actor TerPistolSandGrey : TerPistol
		{
		 Translation "112:127=48:79", "192:207=90:111"
		}	
		
	Actor TerPistolGreyBrown : TerPistol
		{
		 Translation "112:127=80:111", "192:207=144:151"
		}
		
	Actor TerPistolSandBrown : TerPistol
		{
		 Translation "112:127=128:143", "192:207=64:79"
		}
		
	Actor TerPistolBlackGrey : TerPistol
		{
		 Translation "112:127=5:8", "192:207=96:111"
		}
		
		
		
	

	