Actor MafiaPistol : GenericHumanScum   
{

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

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

Health 26
Monster
Radius 20
Height 56
Speed 11
PainChance 200
Monster
Species "Z"
+DOHARMSPECIES
seesound "Mafia/See"
attacksound "weapons/pistol"
painsound "GTS/Pain"
deathsound "GTS/Death"
activesound "Mafia/Active"
Tag "Suspicious italian Businessman"
Translation "112:127=5:8", "192:207=5:8"
scale 1.0
Obituary "%o got best regards from the suspicious italian businessman."
//+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)
  Spawn2:	
	SUT1 T 10 A_Look
	loop
  STFU:
     TNT1 A 0
	 TNT1 A 0 ACS_NamedExecute ("STFUMafia")
	 Goto Spawn+2
  VanJump:
	 TNT1 A 0
	 TNT1 A 0  NODELAY ACS_NamedExecuteAlways ("VanillaHeights")
	Goto Spawn+3	 
	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")
	 SUT1 AABB 4 A_Chase
	 SUT1 CCDD 4 A_Chase  
	Loop
   MissileCheck:
    TNT1 A 0 A_JumpIfInTargetLos ("DodgeChoice", 50, 0, 0, 0)
	TNT1 A 0 A_JumpIfTargetInLos ("Accuracy", 50, JLOSF_CLOSENOJUMP | JLOSF_DEADNOJUMP, 0, 1150)
	Goto SeeLoop
  DodgeChoice:
    TNT1 A 0 A_Jump (190, "DodgeLeft", "DodgeRight", "DodgeLeftF", "DodgeRightF", "DodgeRightB")
	Goto MissileCheck+1	
  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
	    SUT1 AABBCCDD 2 ThrustThing(angle*256/360+192, 1, 0, 0)
		TNT1 A 0 A_Jump (120, "MissileCheck2")
		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))
	    SUT1 AABBCCDD 2 ThrustThing(angle*256/360+192, 1, 0, 0)
		TNT1 A 0 A_Jump (120, "MissileCheck2")
		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))
	    SUT1 AABBCCDD 2 ThrustThing(angle*256/360+192, 1, 0, 0)
		TNT1 A 0 A_Jump (120, "MissileCheck2")
		Goto SeeLoop+2
	DodgeRight:
	    TNT1 A 0 A_FaceTarget
	    SUT1 AABBCCDD 2 ThrustThing(angle*256/360+64, 1, 0, 0)
		TNT1 A 0 A_Jump (100, "MissileCheck2")
		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)) 
	    SUT1 AABBCCDD 2 ThrustThing(angle*256/360+64, 1, 0, 0)
		TNT1 A 0 A_Jump (100, "MissileCheck2")
		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)) 
	    SUT1 AABBCCDD 2 ThrustThing(angle*256/360+64, 1, 0, 0)
		TNT1 A 0 A_Jump (100, "MissileCheck2")
		Goto SeeLoop+2		
 Retreat:
    TNT1 A 0 A_Changeflag ("FRIGHTENED", 1)
	TNT1 A 0 A_Changeflag ("MissileMore", 1)
	TNT1 A 0 A_Changeflag ("MissileEvenMore", 1)
	Goto SeeLoop+1	
 Missile:
    TNT1 A 0 A_JumpIfInventory ("PistolShotCounter", 9, "Reload")
	SUT1 E 10 A_FaceTarget
	TNT1 A 0 A_JumpIfCloser (420, "RapidFire")
	TNT1 A 0 A_JumpIfTargetInLOS ("Accuracy", 0, JLOSF_CLOSENOJUMP | JLOSF_DEADNOJUMP, 0, 1400)
	TNT1 A 0 A_PlaySound ("BYPFR")
	TNT1 A 0 A_PlaySound ("BYPFRF", 6, 0.5, 0)
	SUT1 F 8 BRIGHT A_CustomMissile ("LightPistolTracer",45,0,random (-2,1))
	TNT1 A 0 A_GiveInventory ("PistolShotCounter", 1)
	SUT1 E 10 A_FaceTarget
	TNT1 A 0 A_JumpIfInventory ("PistolShotCounter", 9, "Reload")
	TNT1 A 0 A_PlaySound ("BYPFR")
	TNT1 A 0 A_PlaySound ("BYPFRF", 6, 0.5, 0)
	SUT1 F 8 BRIGHT A_CustomMissile ("LightPistolTracer",45,0,random (-2,1))
	TNT1 A 0 A_GiveInventory ("PistolShotCounter", 1)
	SUT1 E 10 A_FaceTarget
	TNT1 A 0 A_JumpIfInventory ("PistolShotCounter", 9, "Reload")
	TNT1 A 0 A_PlaySound ("BYPFR")
	TNT1 A 0 A_PlaySound ("BYPFRF", 6, 0.5, 0)
	SUT1 F 8 BRIGHT A_CustomMissile ("LightPistolTracer",45,0,random (-2,1))
	TNT1 A 0 A_GiveInventory ("PistolShotCounter", 1)
	goto SeeLoop
 RapidFire:
    TNT1 A 0 A_JumpIfInventory ("PistolShotCounter", 9, "Reload")
	TNT1 A 0 A_PlaySound ("BYPFR")
	TNT1 A 0 A_PlaySound ("BYPFRF", 6, 0.5, 0)
    SUT1 F 5 Bright A_CustomMissile ("LightPistolTracer",45,0,random (-1,1))
	TNT1 A 0 A_GiveInventory ("PistolShotCounter", 1)
	SUT1 E 6 A_FaceTarget
	TNT1 A 0 A_JumpIfInventory ("PistolShotCounter", 9, "Reload")
	TNT1 A 0 A_PlaySound ("BYPFR")
	TNT1 A 0 A_PlaySound ("BYPFRF", 6, 0.5, 0)
	SUT1 F 5 Bright A_CustomMissile ("LightPistolTracer",45,0,random (-2,2))
	TNT1 A 0 A_GiveInventory ("PistolShotCounter", 1)
	SUT1 E 6 A_FaceTarget
	TNT1 A 0 A_JumpIfInventory ("PistolShotCounter", 9, "Reload")
	TNT1 A 0 A_PlaySound ("BYPFR")
	TNT1 A 0 A_PlaySound ("BYPFRF", 6, 0.5, 0)
	SUT1 F 5 Bright A_CustomMissile ("LightPistolTracer",45,0,random (-3,3))
	TNT1 A 0 A_GiveInventory ("PistolShotCounter", 1)
	SUT1 E 6 A_FaceTarget
	TNT1 A 0 A_JumpIfInventory ("PistolShotCounter", 9, "Reload")
	TNT1 A 0 A_PlaySound ("BYPFR")
	TNT1 A 0 A_PlaySound ("BYPFRF", 6, 0.5, 0)
	SUT1 F 5 Bright A_CustomMissile ("LightPistolTracer",45,0,random (-4,4))
	TNT1 A 0 A_GiveInventory ("PistolShotCounter", 1)
	Goto SeeLoop
 Accuracy:
    TNT1 A 0 A_JumpIfInventory ("PistolShotCounter", 9, "Reload")
    SUT1 E 15
	TNT1 A 0 A_PlaySound ("BYPFR")
	TNT1 A 0 A_PlaySound ("BYPFRF", 6, 0.5, 0)
	SUT1 F 8 Bright A_CustomMissile ("LightPistolTracer",45)
	TNT1 A 0 A_GiveInventory ("PistolShotCounter", 1)
	Goto SeeLoop
 Reload:
    TNT1 A 0 A_JumpIfInTargetLos ("Retreating", 0, JLOSF_CLOSENOJUMP, 0, 1200)
	TNT1 A 0 A_PlaySound ("LPISOUT")
    SUT1 E 15
	TNT1 A 0 A_TakeInventory ("PistolShotCounter", 9)
	TNT1 A 0 A_PlaySound ("LPISIN")
	SUT1 D 20
	SUT1 E 14
	TNT1 A 0 A_PlaySound ("LPISREAD")
	TNT1 A 0 A_JumpIfCloser (350, "RapidFireCheck")
	Goto SeeLoop
 RapidFireCheck:
    TNT1 A 0 A_JumpIfTargetInLos ("RapidFire")
	Goto SeeLoop
 Retreating:
    TNT1 A 0 A_ChangeFlag ("FRIGHTENED", true) 
    SUT1 AABBCCDD 2 A_Chase
	TNT1 A 0 A_CheckSight ("ReloadReady")
	Loop
 ReloadReady:
    TNT1 A 0 A_ChangeFlag ("FRIGHTENED", false)
	Goto Reload
 Techka:
    SUT1 H 1 DamageThing (1)
	Goto SeeLoop+2
 MissileCheck2:
    TNT1 A 0 A_JumpIfTargetInLos ("Missile")
	Goto SeeLoop
 Pain:
	SUT1 H 3
	SUT1 H 3 A_Pain
	Goto SeeLoop
 Death:
	SUT1 N 3
	SUT1 O 5 A_Scream
	SUT1 P 5 A_NoBlocking
	SUT1 Q 5 A_Playsound ("FallingBodyLight", CHAN_BODY)
	SUT1 R -1
	Stop
  XDeath:
    TNT1 A 0
    TNT1 A 0 A_SpawnItemEx ("VgavnonahCore", 0, 0, 0, 0, 0, 0, 0, SXF_NOCHECKPOSITION)
    SUT1 U 5
    SUT1 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)
	SUT1 RQPON 5
	Goto See
    }
}	

