ACTOR " Pistol " : Weapon Replaces Pistol
{
    Weapon.SelectionOrder 20
	Weapon.BobStyle Normal
    Weapon.BobSpeed 1.4
    Weapon.BobRangeX 0.85
    Weapon.BobRangeY 0.6
    Weapon.AmmoUse 1
    Weapon.AmmoGive 32
    Weapon.AmmoType "Pistol Ammo"
    Obituary "%o was gattered by %k's pistol."
    Inventory.Pickupmessage "\cnPistol!"
    Inventory.PickupSound "DukeNukem/PickWeapon"
    Scale 0.5
	+WEAPON.AMMO_OPTIONAL
	+WEAPON.ALT_AMMO_OPTIONAL
	+WEAPON.NOALERT
    States
    {
    Spawn:
		TNT1 A 0		
		TNT1 A 1 A_Jump(256,"Spawn1","Spawn2")
		Stop
	Spawn1:	
        PISP A -1
        Stop
	Spawn2:	
        PIS2 A -1
        Stop
    Ready:
	    PIST A 0 
        PIST A 0 A_JumpIfInventory("ReloadStart",1,27)
		PIST A 0 		
		PIST D 0 A_GiveInventory("FirstPistol",1)		
		PIST D 0 A_PlaySound("Pistol/Reload",6)
        PIST DDDEEEFFFGGGHHH 1 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH) 
		PIST I 0 A_TakeInventory("PistolReload",12)
        PIST I 0 A_GiveInventory("ReloadStart",1)
		PIST IIIDDD 1 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH) 
		Loop
		PIST A 1 A_WeaponReady
        PIST A 0 A_JumpIfInventory("Waiting",15,"Knuckles")
		PIST AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA 1 A_WeaponReady
		PIST A 0 A_GiveInventory("Waiting",1)
        Loop
	Knuckles:
        PIST AAAAA 1 A_Lower
        PIST A 0 A_Lower
		KNUK A 0 A_PlaySound("DukeNukem/Waiting",8)
        KNUK A 0 A_TakeInventory("Waiting",15)
        KNUK A 1 Offset(0,120) 
		KNUK A 1 Offset(0,110)
		KNUK A 1 Offset(0,100)
		KNUK A 1 Offset(0,90)
		KNUK A 1 Offset(0,80)
		KNUK A 1 Offset(0,70)
		KNUK A 1 Offset(0,60)
		KNUK A 1 Offset(0,50)
		KNUK A 1 Offset(0,40)
		KNUK AAABBB 1 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH)
		KNUK C 1 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH)
        KNUK C 0 A_PlaySound("Duke/KNuckles",5)
		KNUK C 1 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH)
		KNUK C 1 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH)
        KNUK DDDCCCBBBAAA 1 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH)  
        KNUK A 1 Offset(0,40)
		KNUK A 1 Offset(0,50)
		KNUK A 1 Offset(0,60)
		KNUK A 1 Offset(0,70)
		KNUK A 1 Offset(0,80)
		KNUK A 1 Offset(0,90)
		KNUK A 1 Offset(0,100)
		KNUK A 1 Offset(0,110)
		KNUK A 1 Offset(0,120)
        Goto Select
	Deselect:
        PIST AAAAA 1 A_Lower
        PIST A 0 A_TakeInventory("Waiting",15)
		PIST A 0 A_Lower
        Goto Deselect+4
    Select:
        PIST A 1 A_Raise
		TNT1 A 0 A_TakeInventory("CheckWeaponMightyFoot",1)
        TNT1 A 0 A_GiveInventory("CheckWeaponPistol",1)
        TNT1 A 0 A_TakeInventory("CheckWeaponDualPistol",1)
        TNT1 A 0 A_TakeInventory("CheckWeaponBlackTail",1)
        TNT1 A 0 A_TakeInventory("CheckWeaponDualBlackTail",1)
        TNT1 A 0 A_TakeInventory("CheckWeaponDesertEagle",1)
        TNT1 A 0 A_TakeInventory("CheckWeaponShotgun",1)
        TNT1 A 0 A_TakeInventory("CheckWeaponSuperShotgun",1)
        TNT1 A 0 A_TakeInventory("CheckWeaponAssaultShotgun",1)
        TNT1 A 0 A_TakeInventory("CheckWeaponExplosiveShotgun",1)
        TNT1 A 0 A_TakeInventory("CheckWeaponChaingun",1)
        TNT1 A 0 A_TakeInventory("CheckWeaponLMG2028",1)
		TNT1 A 0 A_TakeInventory("CheckWeaponMinigun",1)
		TNT1 A 0 A_TakeInventory("CheckWeaponExplosiveChaingun",1)
        TNT1 A 0 A_TakeInventory("CheckWeaponRPG",1)
        TNT1 A 0 A_TakeInventory("CheckWeaponShockCannon",1)
        TNT1 A 0 A_TakeInventory("CheckWeaponPipeBomb",1)
        TNT1 A 0 A_TakeInventory("CheckWeaponLaserTripBomb",1)
        TNT1 A 0 A_TakeInventory("CheckWeaponShrinker",1)
		TNT1 A 0 A_TakeInventory("CheckWeaponShrinker2",1)
        TNT1 A 0 A_TakeInventory("CheckWeaponExpander",1)
        TNT1 A 0 A_TakeInventory("CheckWeaponExecutor",1)
        TNT1 A 0 A_TakeInventory("CheckWeaponDevastator",1)
        TNT1 A 0 A_TakeInventory("CheckWeaponLaserChaingun",1)
        TNT1 A 0 A_TakeInventory("CheckWeaponRailgun",1)
        TNT1 A 0 A_TakeInventory("CheckWeaponFreezethrower",1)
        TNT1 A 0 A_TakeInventory("CheckWeaponIncinerator",1)
        TNT1 A 0 A_TakeInventory("CheckWeaponPulsethrower",1)
		PIST A 0 A_PlaySound("Pistol/Select",6)
        PIST A 0 A_Raise
		PIST A 1 A_Raise
        PIST A 0 A_Raise
        PIST A 1 A_Raise
        PIST A 0 A_Raise
        PIST A 1 A_Raise
        PIST A 0 A_Raise
        PIST A 1 A_Raise
        PIST A 0 A_Raise
        PIST AAAAA 1 A_Raise
        PIST AAAAAAAAAA 2 A_Raise
        Goto Ready
    Fire:
        PIST A 0 A_JumpIfNoAmmo("FireFail")
		PIST A 0 A_JumpIfInventory("PistolReload",12,"Reload")
        PIST A 0 A_TakeInventory("Waiting",15)
        PIST A 0 A_GunFlash
		PIST A 0 A_FireBullets(Random(1,2),Random(2,1),-1,Random(16,18),"BulletPistol",FBF_NORANDOM)
		PIST A 0 A_PlaySound("Pistol/Shoot",5)
		PIST A 0 A_AlertMonsters
        PIST B 1 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH)
		PIST B 0 A_TakeInventory("Pistol Ammo",1)
		PIST B 0 A_GiveInventory("PistolReload",1)
		PIST B 0 A_FireCustomMissile("9mmSpawner",0,0,0,-1)
        PIST C 1 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH)        
		PIST A 1 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH)		
        PIST AAA 1 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH) 
		Goto Ready
    Flash:
	    PI1F A 0 A_FireCustomMissile("DukeFlashPistol",0,0,0)
		PI1F A 0 A_Light2
        PI1F A 1 Bright A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH) 
		PI1F A 0 A_FireCustomMissile("DukeFlashPistol",0,0,0)
		PI1F B 0 A_Light1 
		PI1F B 1 Bright A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH) 
        PI1F B 0 A_Light0
        Goto LightDone
    Reload:  
	    PIST D 0 A_PlaySound("Pistol/Reload",6)
        PIST DDDEEEFFFGGGHHH 1 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH) 
		PIST I 0 A_TakeInventory("PistolReload",12)
        PIST IIIDDD 1 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH) 
        Goto Ready
    AltFire:
		BOOT C 0 A_JumpIfInventory("PowerStrength",1,22)
		BOOT C 0 A_GunFlash
		BOOT C 0 ACS_ExecuteAlways(500,0,FAS_ActorKick)
		BOOT CCCCCC 1 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH) 
		BOOT C 0 A_CustomPunch(Random(26,30),0,0,"MightyBootPuff")
		BOOT C 0 A_TakeInventory("Waiting",15)
        BOOT DDDDD 1 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH) 
        BOOT CCCCC 1 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH) 
        BOOT C 0 A_Refire
        Goto Ready  
		BOOT C 0 ACS_ExecuteAlways(500,0,FAS_ActorKick)
		BOOT C 0 A_GunFlash
		BOOT CCCCCC 1 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH) 
		BOOT C 0 A_CustomPunch(10*Random(26,30),0,0,"MightyBootPuff")
		BOOT C 0 A_TakeInventory("Waiting",15)
        BOOT DDDDD 1 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH) 
        BOOT CCCCC 1 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH) 
        BOOT C 0 A_Refire
        Goto Ready	
    AltFlash:  
        PIST AAAAAAAAAAAAAAAAA 1 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH) 
        Stop
	FireFail:
	    PIST A 0 A_PlaySound("Pistol/Fail",6)
		PIST A 0 A_TakeInventory("Waiting",15)
		PIST AAAAAAAAAA 1 A_WeaponReady(WRF_NOFIRE|WRF_NOSWITCH) 
        Goto Ready	
    }
}

ACTOR PistolReload : Ammo
{
	+IGNORESKILL
	Inventory.Amount 1
	Inventory.MaxAmount 12
}

ACTOR ReloadStart : Inventory
{
    Inventory.Amount 0
    Inventory.MaxAmount 1
}

ACTOR "  Pistol  " : CustomInventory Replaces Chainsaw 31000
{
	//$Category DN3D Weapons
	Inventory.Pickupmessage "\cnPistol!"
    Inventory.PickupSound "DukeNukem/PickWeapon"
	Inventory.MaxAmount 200
    Inventory.Amount 12
	Scale 0.5
    States
    {
    Spawn:
		TNT1 A 0		
		TNT1 A 1 A_Jump(256,"Spawn1","Spawn2")
		Stop
	Spawn1:	
        PISP A -1
        Stop
	Spawn2:	
        PIS2 A -1
        Stop
	Pickup: 		
		PISP A 0 A_JumpIfInventory("FirstPistol",1,4)
        PISP A 1 A_GiveInventory(" Pistol ",1)
		PISP A 0 A_GiveInventory("FirstPistol",1)		
        Stop
		PISP A 0
        PISP A 1 A_GiveInventory("Dual Pistol")
        Stop
	}
}

ACTOR FirstPistol : Inventory
{
    Inventory.Amount 0
    Inventory.MaxAmount 1
}

ACTOR DukeFlashPistol
{
    Speed 1
    Radius 1
    Height 1
    Damage 0
    Projectile
    +NOCLIP
	+NOTIMEFREEZE
    States
    {
    Spawn:
        TNT1 A 0 
		TNT1 A 1
        Stop
    }
}