// Handgun
actor Handgun : AOWWeapon replaces Pistol 21041 {
    Weapon.BobSpeed 1.75
    Weapon.BobRangeX 0.2
    Weapon.BobRangeY 0.4
    Weapon.BobStyle Alpha
	//$Category Weapons
	+WIMPY_WEAPON
	+WEAPON.NOAUTOFIRE
	Weapon.AmmoUse 1
	Weapon.AmmoGive2 16
	Weapon.AmmoType "PistolMagazine"
	Weapon.AmmoType2 "NewClipAmmo"
	Weapon.SelectionOrder 19
	Weapon.PreferredSkin "MarinePistol"
	Inventory.Pickupmessage "You got the handgun!"
	Obituary "%o was capped by %k's handgun."
	Weapon.UpSound "weapons/up/pistol"
	AttackSound "weapons/pistolfire"
	Scale 0.9
	decal "BulletChip"
	+WEAPON.AMMO_OPTIONAL
	States {
    Select:
		PIST A 1 offset (-90,100)
		PIST A 1 offset (-80,89)
		PIST A 1 offset (-70,79)
		PIST A 1 offset (-60,70)
		PIST A 1 offset (-50,62)
		PIST A 1 offset (-40,55)
		PIST A 1 offset (-30,49)
		PIST A 1 offset (-20,44)
		PIST A 1 offset (-15,40)
		PIST A 1 offset (-10,37)
		PIST A 1 offset (-5,34)
		PIST A 1 offset (0,0)
		TNT1 A 0 A_TakeInventory("SelectAnimation",1)
		goto ready
	Deselect:
	    TNT1 A 0 A_TakeInventory("ActionFragGrenade",1)	
        TNT1 A 0 A_TakeInventory("ActionFlashbang",1)
        TNT1 A 0 A_TakeInventory("ActionRemoteC4",1)	
        TNT1 A 0 A_TakeInventory("ActionMeleeAttack",1)
		TNT1 A 0 A_TakeInventory("ActionReload",1)	
		PIST A 1 offset (-4,34)
		PIST A 1 offset (-8,40)
		PIST A 1 offset (-16,49)
		PIST A 1 offset (-24,62)
		PIST A 1 offset (-32,79)
		PIST A 1 offset (-40,100)
		TNT1 A 0 offset (-1, 33)
		TNT1 A 0 A_Lower
		wait
	Ready:
	    TNT1 A 0 A_JumpIfInventory("SelectAnimation",1,"Select")
	    TNT1 A 0 A_JumpIfInventory("ActionFragGrenade",1,"UseFragGrenade")
		TNT1 A 0 A_JumpIfInventory("ActionFlashbang",1,"UseFlashbang")
		TNT1 A 0 A_JumpIfInventory("ActionRemoteC4",1,"UseRemoteC4")
		TNT1 A 0 A_JumpIfInventory("ActionMeleeAttack",1,"UseMeleeAttack")
	    TNT1 A 0 A_JumpIfInventory("ActionReload",1,"Reload")
		PIST A 1 A_WeaponReady
		Loop
	Fire:
		TNT1 A 0 A_JumpIfInventory ("IsInSpawnRoom", 1, "Ready")
		TNT1 A 0 A_JumpIfInventory ("InMenu", 1, "Ready")
		TNT1 A 0 A_JumpIfNoAmmo("Empty")
		PIST B 0 A_SpawnItemEx ("ShellCasing", 0, 12, 38, random (-2, -4), random (2, 3), random (1, 3), random (45, 60))
		PIST B 0 A_FireBullets (2, 2, -1, 14, "HandgunPuff", FBF_NORANDOM|FBF_USEAMMO, 1536)
		PIST B 2 Bright
		PIST C 2
		PIST DEF 2 A_WeaponReady (WRF_NOBOB)
		Goto Ready
    Empty:
	    PIST A 0 A_PlayWeaponSound("weapons/empty1")
	    PIST A 10 A_WeaponReady(WRF_NOFIRE)
    Reload:
	    TNT1 A 0 A_TakeInventory("ActionReload",1)
	    TNT1 A 0 A_JumpIfInventory("PistolMagazine",16,2)
	    TNT1 A 0 A_JumpIfInventory("NewClipAmmo",1,2)
	    TNT1 A 0
	    Goto Ready
	    PISR A 2 A_PlaySound("weapons/pistolr1")
	    PISR BCDE 2
	    TNT1 A 0 A_FireCustomMissile("SMGEmptyMagSpawner",0,0,0,1)
		TNT1 A 0 A_WeaponReady(WRF_NOBOB | WRF_NOFIRE)
	    PISR FF 5 A_JumpIfInventory("ActionMeleeAttack",1,"UseMeleeAttack")
	    PISR G 2 A_WeaponReady(WRF_NOBOB | WRF_NOFIRE)
		PISR HI 3 A_JumpIfInventory("ActionMeleeAttack",1,"UseMeleeAttack")
		PISR J 3 A_PlayWeaponSound("weapons/pistolr2")
		PISR KLMNO 1
		PISR PQR 2
		PISR S 3
	    TNT1 A 0 A_JumpIfInventory("NewClipAmmo",1,"Reload2")
    Reload2:
	    TNT1 A 0 A_TakeInventory("NewClipAmmo",1)
	    TNT1 A 0 A_GiveInventory("PistolMagazine",1)
	    TNT1 A 0 A_JumpIfInventory("PistolMagazine",16,2)
	    TNT1 A 0 A_JumpIfInventory("NewClipAmmo",1,"Reload2")
		TNT1 A 0
	    Goto Ready
	Flash:
		PISF A 1 Bright A_Light2
		PISF A 1 Bright A_Light1
		Goto LightDone
	Spawn:
		PIST X -1
		stop
	}
}

actor HandgunPuff : HHBulletPuff {
	DamageType "Bullet"
}

/////////////////What.

actor ArmyCreator : AOWWeapon
{
  attacksound "pistol/fire"
  Weapon.SelectionOrder 99
  Weapon.AmmoUse 1
  Weapon.AmmoGive 0
  Weapon.AmmoType "NewClipAmmo"
  Weapon.AmmoUse2 1
  Weapon.AmmoType2 "NewClipAmmo"
  Obituary "%o was capped by %k's handgun."
  +WEAPON.WIMPY_WEAPON
  Inventory.Pickupmessage "Got the handgun!"
  States
  {
  Ready:
    PISG A 1 A_WeaponReady
    Loop
  Deselect:
    PISG A 1 A_Lower
    Loop
  Select:
    PISG A 1 A_Raise
    Loop
  Fire:
    PISG A 3
    PISG B 0 A_SpawnItemEx("ShellCasing",8,8,32,random(1,3),random(0,1),random(1,3),random(45,60),128)
    PISG B 0 A_SpawnItemEx("DoomPlayer",36,0,0,0,0,0,0,0,0)
    PISG B 0 A_SpawnItemEx("DoomPlayer",36,36,0,0,0,0,0,0,0)
    PISG B 0 A_SpawnItemEx("DoomPlayer",36,72,0,0,0,0,0,0,0)
    PISG B 0 A_SpawnItemEx("DoomPlayer",36,108,0,0,0,0,0,0,0)
    PISG B 0 A_SpawnItemEx("DoomPlayer",36,-36,0,0,0,0,0,0,0)
    PISG B 0 A_SpawnItemEx("DoomPlayer",36,-72,0,0,0,0,0,0,0)
    PISG B 0 A_SpawnItemEx("DoomPlayer",36,-108,0,0,0,0,0,0,0)
    PISG B 0 A_SpawnItemEx("DoomPlayer",72,0,0,0,0,0,0,0,0)
    PISG B 0 A_SpawnItemEx("DoomPlayer",72,36,0,0,0,0,0,0,0)
    PISG B 0 A_SpawnItemEx("DoomPlayer",72,72,0,0,0,0,0,0,0)
    PISG B 0 A_SpawnItemEx("DoomPlayer",72,108,0,0,0,0,0,0,0)
    PISG B 0 A_SpawnItemEx("DoomPlayer",72,-36,0,0,0,0,0,0,0)
    PISG B 0 A_SpawnItemEx("DoomPlayer",72,-72,0,0,0,0,0,0,0)
    PISG B 0 A_SpawnItemEx("DoomPlayer",72,-108,0,0,0,0,0,0,0)
    PISG B 0 A_SpawnItemEx("DoomPlayer",108,0,0,0,0,0,0,0,0)
    PISG B 0 A_SpawnItemEx("DoomPlayer",108,36,0,0,0,0,0,0,0)
    PISG B 0 A_SpawnItemEx("DoomPlayer",108,72,0,0,0,0,0,0,0)
    PISG B 0 A_SpawnItemEx("DoomPlayer",108,108,0,0,0,0,0,0,0)
    PISG B 0 A_SpawnItemEx("DoomPlayer",108,-36,0,0,0,0,0,0,0)
    PISG B 0 A_SpawnItemEx("DoomPlayer",108,-72,0,0,0,0,0,0,0)
    PISG B 0 A_SpawnItemEx("DoomPlayer",108,-108,0,0,0,0,0,0,0)
    PISG B 0 A_SpawnItemEx("DoomPlayer",36*4,0,0,0,0,0,0,0,0)
    PISG B 0 A_SpawnItemEx("DoomPlayer",36*4,36,0,0,0,0,0,0,0)
    PISG B 0 A_SpawnItemEx("DoomPlayer",36*4,72,0,0,0,0,0,0,0)
    PISG B 0 A_SpawnItemEx("DoomPlayer",36*4,108,0,0,0,0,0,0,0)
    PISG B 0 A_SpawnItemEx("DoomPlayer",36*4,-36,0,0,0,0,0,0,0)
    PISG B 0 A_SpawnItemEx("DoomPlayer",36*4,-72,0,0,0,0,0,0,0)
    PISG B 0 A_SpawnItemEx("DoomPlayer",36*4,-108,0,0,0,0,0,0,0)
    PISG B 0 A_SpawnItemEx("DoomPlayer",36*5,0,0,0,0,0,0,0,0)
    PISG B 0 A_SpawnItemEx("DoomPlayer",36*5,36,0,0,0,0,0,0,0)
    PISG B 0 A_SpawnItemEx("DoomPlayer",36*5,72,0,0,0,0,0,0,0)
    PISG B 0 A_SpawnItemEx("DoomPlayer",36*5,108,0,0,0,0,0,0,0)
    PISG B 0 A_SpawnItemEx("DoomPlayer",36*5,-36,0,0,0,0,0,0,0)
    PISG B 0 A_SpawnItemEx("DoomPlayer",36*5,-72,0,0,0,0,0,0,0)
    PISG B 0 A_SpawnItemEx("DoomPlayer",36*5,-108,0,0,0,0,0,0,0)
    PISG B 0 A_SpawnItemEx("DoomPlayer",36*6,0,0,0,0,0,0,0,0)
    PISG B 0 A_SpawnItemEx("DoomPlayer",36*6,36,0,0,0,0,0,0,0)
    PISG B 0 A_SpawnItemEx("DoomPlayer",36*6,72,0,0,0,0,0,0,0)
    PISG B 0 A_SpawnItemEx("DoomPlayer",36*6,108,0,0,0,0,0,0,0)
    PISG B 0 A_SpawnItemEx("DoomPlayer",36*6,-36,0,0,0,0,0,0,0)
    PISG B 0 A_SpawnItemEx("DoomPlayer",36*6,-72,0,0,0,0,0,0,0)
    PISG B 0 A_SpawnItemEx("DoomPlayer",36*6,-108,0,0,0,0,0,0,0)
    PISG B 0 A_SpawnItemEx("DoomPlayer",36*7,0,0,0,0,0,0,0,0)
    PISG B 0 A_SpawnItemEx("DoomPlayer",36*7,36,0,0,0,0,0,0,0)
    PISG B 0 A_SpawnItemEx("DoomPlayer",36*7,72,0,0,0,0,0,0,0)
    PISG B 0 A_SpawnItemEx("DoomPlayer",36*7,108,0,0,0,0,0,0,0)
    PISG B 0 A_SpawnItemEx("DoomPlayer",36*7,-36,0,0,0,0,0,0,0)
    PISG B 0 A_SpawnItemEx("DoomPlayer",36*7,-72,0,0,0,0,0,0,0)
    PISG B 0 A_SpawnItemEx("DoomPlayer",36*7,-108,0,0,0,0,0,0,0)
    PISG B 6 A_GunFlash
    PISG C 5
    PISG B 4 A_ReFire
    Goto Ready
  Flash:
    PISF A 2 Bright A_Light2
    PISF A 2 Bright A_Light1
    Goto LightDone
  AltFlash:
    PISF A 1 Bright A_Light2
    PISF A 1 Bright A_Light1
    Goto LightDone
  Spawn:
    TNT1 A 0 
    TNT1 A 0 A_SpawnItem("Handgun")
    stop
  }
}

ACTOR PistolMagazine : Ammo
{
Inventory.Amount 0
Inventory.MaxAmount 16
Ammo.BackpackAmount 0
Ammo.BackpackMaxAmount 16
+IGNORESKILL
}