ACTOR ImpShield : brutalpistol
{
	Weapon.AmmoUse1 0
	Weapon.AmmoGive1 0
	Weapon.AmmoUse2 0
	Weapon.AmmoGive2 0
	Weapon.AmmoType1 "BDPistolAmmo"
	Weapon.AmmoType2 "MeatAmmo"
	States
	{
	Ready:
		TNT1 A 0 A_JumpIfInventory("choosingreward", 1, "YEET")	
		TNT1 A 0 A_JumpIfInventory("weargasmask", 1, "YEET")
		TNT1 A 0 A_JumpIfInventory("removegasmask", 1, "YEET")
		TNT1 A 0 A_JumpIfInventory("battledrugtoken",1,"YEET")
		TNT1 A 0 A_JumpIfInventory("BANDAGETOKEN",1,"YEET")
		TNT1 A 0 A_Jumpifinventory("throwtoken",1, "YEET")
		pong A 0 A_Jumpifinventory("slashtoken",1, "YEET")
		TNT1 A 0 A_JumpIfInventory("flaretoken",1,"YEET")
		TNT1 A 0 A_overlay(3,"ZombieOverlay")
		TNT1 A 0 {a_overlayflags(1, pspf_flip, 1); a_overlayflags(1, pspf_mirror, 1);}
		FLPI A 2 A_WeaponReady(wrf_DISABLESWITCH)
		TNT1 A 0 {a_overlayflags(1, pspf_flip, 0); a_overlayflags(1, pspf_mirror, 0);}
		
		TNT1 A 0 A_JumpIfInventory("MeatAmmo", 100, 4)
		TNT1 A 0 A_SpawnItemEx("MeatShield", 15, 0, 15, 0)
		TNT1 A 0 A_AlertMonsters
        Loop
		TNT1 AAA 0
		Goto Destroy
	Deselect:
        TNT1 A 0 a_lower
		loop
	Select:
		TNT1 A 0 A_Giveinventory("GoSpecial",1)
		TNT1 A 0 A_Giveinventory("GotMeatShield",1)
	    TNT1 A 0 A_TakeInventory("MeatAmmo", 100)
		TNT1 A 0 A_Raise
		
	LoadBullets:
		TNT1 A 0 A_JumpIfInventory("BDPistolAmmo",15,15)
		TNT1 A 0 A_JumpIfInventory("Clip1",1,3)
		Goto Ready
        TNT1 AAAAAA 0
		TNT1 A 0 A_Giveinventory("BDPistolAmmo",1)
		TNT1 A 0 A_Giveinventory("BDDualPistolAmmo",1)
		TNT1 A 0 A_Takeinventory("Clip1",1)
		Goto LoadBullets		
		TNT1 AAAAAAAAAA 0
		TNT1 A 0 A_Takeinventory("Reloading",1)  
        Goto Ready

ZombieOverlay:
		ISHG C 2
		stop
ZombieOverlay2:
		ISHG C 2 BRIGHT
		ISHG C 2
		stop		

    Fire:
	    TNT1 A 0
        TNT1 A 0 A_JumpIfInventory("BDPistolAmmo", 1, 2)
		TNT1 A 0 A_PlaySound("DRYFIRE")
		GOTO READY
		TNT1 A 0 A_overlay(3,"ZombieOverlay2")
		TNT1 A 0 A_AlertMonsters
		TNT1 A 0 A_SpawnItemEx("MeatShield", 15, 0, 15, 0)
		TNT1 A 0 A_FireCustomMissile("YellowFlareSpawn",-5,0,0,0)
		TNT1 A 0 A_PlaySound("PISTFIRE")
        TNT1 A 0 A_FireCustomMissile("SmokeSpawner",0,0,0,5)
		TNT1 A 0 A_FireProjectile("PistolTracershield", frandom(-1.0,-1.0), 0)
		TNT1 A 0 A_TakeInventory("BDPistolAmmo", 1)
		TNT1 A 0 {a_overlayflags(1, pspf_flip, 1); a_overlayflags(1, pspf_mirror, 1);}
		FLPI BC 1 BRIGHT
		FLPI DE 1
		TNT1 A 0 {a_overlayflags(1, pspf_flip, 0); a_overlayflags(1, pspf_mirror, 0);}
		Goto Ready
		

    AltFire:
	YEET:
		GRZ3 D 1 offset(-4, 32)
		GRZ3 D 1 offset(-9, 33)
		GRZ3 D 1 offset(-16, 34)
		GRZ3 D 2 offset(-24, 35)
		GRZ3 D 3 offset(-36, 48)
		GRZ3 D 1 offset(-24, 35)
		GRZ3 B 1 offset(-16, 34)
		GRZ3 B 1 offset(-9, 33)
		GRZ3 B 1 offset(-1, 32)
        TNT1 A 0 A_PlaySound("skeleton/swing")
		TNT1 A 0 A_FireCustomMissile("ThrowedImp", 0, 0, 0)
        THEF B 4 
        THEF C 4
		TNT1 A 0 A_Giveinventory("Punching",1)
		THEF D 4
		Goto BodyAfterThrow
		
 	Spawn:
		8876 A -1
		Stop
	Destroy:
	    TNT1 A 0
		TNT1 A 0 A_SpawnItem("MeatDeath")
		TNT1 A 0 A_TakeInventory("GoSpecial",1)
		ISHF DEFGHIJJ 5
		TNT1 A 0 A_TakeInventory("GoSpecial",1)
		TNT1 A 0 A_TakeInventory("GotMeatShield", 1)
		TNT1 A 0 A_TakeInventory("HasImpShield",1)
		TNT1 A 0 A_Giveinventory("Punching",1)
		TNT1 A 0 A_TakeInventory("ImpShield",1)
		Goto Ready
		
	}
}

ACTOR ThrowedImp: ThrowedZman
{
	States
	{
	Spawn:
		TNT1 A 0
		TNT1 A 0 A_Playsound("imp/death", 1)
	Flying:
        X723 H 2
		TNT1 A 0 A_ChangeFlag("THRUGHOST", 0)
		X723 GFEDCBA 2
		Loop
		
    Death:
	Xdeath:
		TNT1 A 0
		TNT1 A 0 A_StopSound(1)
		TNT1 A 0 A_NoBlocking
		TNT1 A 0 A_CheckCeiling("HitCeil")
		TNT1 A 0 A_JumpIfHealthLower(-40, "Death.Gibs")
		TNT1 A 0 A_JumpIfHealthLower(1, "Death.Shotgun")
		X723 H 2
		NULL AA 0 A_CustomMissile ("XDeath1", 0, 0, random (0, 360), 2, random (0, 160))
	    TNT1 A 0 A_SpawnItem("MuchBlood")
		NULL A 0 A_CustomMissile ("ThrowedImpRicochet", 0, 0, 0, 2, 38)
		Stop
	
	HitCeil:
		TNT1 A 0
		TNT1 A 0 A_SpawnItem("MuchBlood")
		NULL A 0 A_CustomMissile ("ThrowedImpRicochet", 0, 0, 0, 2, -5)
		Stop
		
	Crashing:
		TNT1 A 0 A_StopSound(1)
		TNT1 A 0 A_NoBlocking
		TNT1 A 0 A_SpawnItem("MuchBlood")
		NULL AA 0 A_CustomMissile ("XDeath1", 0, 0, random (0, 360), 2, random (0, 160))
		TNT1 A 0 A_SpawnItem("DeadIMp")
		TNT1 A 3
		Stop
		
	Death.Melee:
	Death.Fatality:
	Death.ExtremePunches:
	Death.Kick:
		TNT1 A 0 A_StopSound(1)
		TNT1 A 0 A_NoBlocking
		NULL A 0 A_CustomMissile ("ThrowedImpRicochet", 0, 0, 180, 2, 32)
		Stop
	
	Death.Gibs:
	Death.Explosives:
	Death.Shotgun:
		TNT1 A 0
		TNT1 A 0 A_SpawnItem("ImpXDeath")
		Stop
	}
}



ACTOR ThrowedImpRicochet: ThrowedImp
{
    +BOUNCEONWALLS
	+THRUGHOST
	+BOUNCEONACTORS
	Radius 12
	Height 14
	WallBounceFactor 0.6
	Speed 10
	States
	{
	Spawn:
        X723 H 2
		TNT1 A 0 A_ChangeFlag("THRUGHOST", 0)
		X723 GFEDCBA 2
		Loop
    Death:
	Xdeath:
		TNT1 A 0
		TNT1 A 0 A_StopSound(1)
		TNT1 A 0 A_NoBlocking
		TNT1 A 0 A_JumpIfHealthLower(-40, "Death.Gibs")
		TNT1 A 0 A_JumpIfHealthLower(1, "Death.Shotgun")
	Goto Crashing
	}
}

ACTOR ThrowedImp2: ThrowedImp
{
    +NOGRAVITY
	Damage 20
}


ACTOR ThrowedImpDead: ThrowedImp
{
	States
	{
	Spawn:
		TNT1 A 0
        X723 H 2
		TNT1 A 0 A_ChangeFlag("THRUGHOST", 0)
		X723 GFEDCBA 2 A_CustomMissile("Brutal_FlyingBlood", 0, 0, random(0,360), 2, random(0,360))
		Loop
		
	}
}




ACTOR ExtremePunchedImp: ThrowedImp
{
	Radius 10
	Height 14
	Speed 30
	+THRUGHOST
	States
	{
	Spawn:
        ID11 AA 2 A_CustomMissile ("Brutal_FlyingBloodTrail", 0, 0, random (0, 360), 2, random (0, 90))
		TNT1 A 0 A_ChangeFlag("THRUGHOST", 0)
		Loop
    Death:
		TNT1 A 0
		TNT1 A 0 A_CheckFloor("Floor")
		TNT1 A 0 A_CheckCeiling("Floor")
		TNT1 A 0 A_SetAngle(angle-180)
		TNT1 A 0 A_Stop
		TNT1 A 0 A_ChangeFlag("LOWGRAVITY", 1)
		TNT1 AA 0 A_CustomMissile ("BloodMistBig", 40, 0, random (0, 360), 2, random (30, 90))
		TNT1 AAA 0 A_CustomMissile ("BloodMist", 40, 0, random (0, 360), 2, random (30, 90))
		
	    TNT1 AAA 0 bright A_CustomMissile ("SuperGoreSpawner", 35, 0, random (170, 190), 2, random (0, 40))
        TNT1 AA 0 A_CustomMissile ("XDeath2", 32, 0, random (170, 190), 2, random (0, 40))
		TNT1 A 0 A_CustomMissile ("XDeath3", 32, 0, random (170, 190), 2, random (0, 40))
		TNT1 AAA 0 A_CustomMissile ("Guts", 32, 0, random (150, 210), 2, random (0, 40))
		TNT1 AA 0 A_CustomMissile ("XDeathImpArm", 32, 0, random (170, 190), 2, random (0, 40))
		TNT1 A 0 A_CustomMissile ("ImpHeadExplode", 60, 0, random (170, 190), 2, random (0, 40))
        TNT1 A 0 A_XScream
		TNT1 A 0 A_NoBlocking
        IZD1 EEEEEFF 6
		TNT1 A 0 A_ChangeFlag("LOWGRAVITY", 1)
		IZD1 G 6
		TNT1 A 0 A_SpawnItem ("GrowingBloodPool")
		TNT1 A 0 A_SpawnItem("DeadImpIZD1H")
		TNT1 A -1
        Stop
		
	Floor:	
		TNT1 AA 0 A_CustomMissile ("XDeath1", 35, 0, random (0, 360), 2, random (0, 160))
		TNT1 A 0 A_Recoil(-30)
		TR06 ABCDE 3 A_CustomMissile ("Brutal_LiquidBlood3", 15, 0, random (0, 360), 2, random (0, 40))
		TR06 FGHIJK 3 A_JumpIf((MomY == 0), "DSFStop")
		Goto DSFStop+1
		
		
	DSFStop:
		TNT1 A 0 A_SpawnItem("Ploft3")
		TNT1 A 0 A_SpawnItem ("GrowingBloodPool")
		TNT1 A 0 A_CustomMissile ("SuperWallRedBlood", 2, 0, random (170, 190), 2, random (0, 0))
		TNT1 A 0 A_SpawnItem("DeadImpTR06K")
		TNT1 A -1
		Stop
	}
}
