ACTOR U_AmmoDropper : Weapon
{
	Inventory.PickupMessage ""
	Obituary ""
	tag "Ammo Dropper"
	AttackSound "None"
	+WEAPON.NOAUTOAIM
	+WEAPON.CHEATNOTWEAPON
	+WEAPON.NOAUTOFIRE
	+WEAPON.DONTBOB
	+WEAPON.NOALERT
	+WEAPON.WIMPY_WEAPON
	+WEAPON.NO_AUTO_SWITCH
	Weapon.SelectionOrder 99999
	Inventory.ForbiddenTo Purist
	States
	{
	Select:
		TNT1 A 0
		TNT1 A 0 ACS_ExecuteAlways(1043)
		TNT1 A 0 A_SetCrosshair(41)
		TNT1 A 0 A_Raise
		Wait
		
	Deselect:
		TNT1 A 1
		TNT1 A 0 A_SetCrosshair(0)
		TNT1 A 0 A_Lower
		Wait
	
	Ready:
		//TNT1 A 0 A_JumpIfInventory("Kicking",1,"Debug")
		TNT1 A 0 A_JumpIfInventory("U_AmmoDropSlot", 10, "ReadyGrenade")
		TNT1 A 0 A_JumpIfInventory("U_AmmoDropSlot", 9, "ReadyFuel")
		TNT1 A 0 A_JumpIfInventory("U_AmmoDropSlot", 8, "ReadyCore")
		TNT1 A 0 A_JumpIfInventory("U_AmmoDropSlot", 7, "ReadyCell")
		TNT1 A 0 A_JumpIfInventory("U_AmmoDropSlot", 6, "ReadyRocket")
		TNT1 A 0 A_JumpIfInventory("U_AmmoDropSlot", 5, "ReadyMinigun")
		TNT1 A 0 A_JumpIfInventory("U_AmmoDropSlot", 4, "ReadyRifle")
		TNT1 A 0 A_JumpIfInventory("U_AmmoDropSlot", 3, "ReadyShell2")
		TNT1 A 0 A_JumpIfInventory("U_AmmoDropSlot", 2, "ReadyShell")
		TNT1 A 0 A_JumpIfInventory("U_AmmoDropSlot", 1, "ReadyRevolver")
	ReadyPistol:
		ADRO A 1 BRIGHT A_WeaponReady
		Goto Ready
	ReadyRevolver:
		ADRO B 1 BRIGHT A_WeaponReady
		Goto Ready
	ReadyShell:
		ADRO C 1 BRIGHT A_WeaponReady
		Goto Ready
	ReadyShell2:
		ADRO D 1 BRIGHT A_WeaponReady
		Goto Ready
	ReadyRifle:
		ADRO E 1 BRIGHT A_WeaponReady
		Goto Ready
	ReadyMinigun:
		ADRO F 1 BRIGHT A_WeaponReady
		Goto Ready
	ReadyRocket:
		ADRO G 1 BRIGHT A_WeaponReady
		Goto Ready
	ReadyCell:
		ADRO H 1 BRIGHT A_WeaponReady
		Goto Ready
	ReadyCore:
		ADRO I 1 BRIGHT A_WeaponReady
		Goto Ready
	ReadyFuel:
		ADRO J 1 BRIGHT A_WeaponReady
		Goto Ready
	ReadyGrenade:
		ADRO K 1 BRIGHT A_WeaponReady
		Goto Ready
		
	AltFire:
		TNT1 A 0 A_JumpIfInventory("U_AmmoDropSlot", 10, 2)
		TNT1 A 0 A_GiveInventory("U_AmmoDropSlot", 1)
		Goto Ready
		TNT1 A 0 A_TakeInventory("U_AmmoDropSlot", 10)
		Goto Ready
		
	Fire:
		TNT1 A 0 A_JumpIfInventory("U_AmmoDropSlot", 10, "DropGrenade")
		TNT1 A 0 A_JumpIfInventory("U_AmmoDropSlot", 9, "DropFuel")
		TNT1 A 0 A_JumpIfInventory("U_AmmoDropSlot", 8, "DropCore")
		TNT1 A 0 A_JumpIfInventory("U_AmmoDropSlot", 7, "DropCell")
		TNT1 A 0 A_JumpIfInventory("U_AmmoDropSlot", 6, "DropRocket")
		TNT1 A 0 A_JumpIfInventory("U_AmmoDropSlot", 5, "DropMinigun")
		TNT1 A 0 A_JumpIfInventory("U_AmmoDropSlot", 4, "DropRifle")
		TNT1 A 0 A_JumpIfInventory("U_AmmoDropSlot", 3, "DropShell2")
		TNT1 A 0 A_JumpIfInventory("U_AmmoDropSlot", 2, "DropShell")
		TNT1 A 0 A_JumpIfInventory("U_AmmoDropSlot", 1, "DropRevolver")
	DropPistol:
		ADRO A 1 BRIGHT A_JumpIfInventory("Magazine9mm", 15, 2)
		TNT1 A 0 A_Print("Not enough ammo to drop", 1)
		Goto Ready
		TNT1 A 0 A_TakeInventory("Magazine9mm", 15)
		ADRO A 10 BRIGHT A_SpawnItemEx("Magazine9mm", random(51, 55), random(-4, 4), 40, 2, 0, 2, angle, SXF_ABSOLUTEANGLE)
		TNT1 A 0 A_Refire
		Goto Ready
	DropRevolver:
		ADRO B 1 BRIGHT A_JumpIfInventory("RevolverBullets", 5, 2)
		TNT1 A 0 A_Print("Not enough ammo to drop", 1)
		Goto Ready
		TNT1 A 0 A_TakeInventory("RevolverBullets", 5)
		ADRO B 10 BRIGHT A_SpawnItemEx("RevolverBullets", random(51, 55), random(-4, 4), 40, 2, 0, 2, angle, SXF_ABSOLUTEANGLE)
		TNT1 A 0 A_Refire
		Goto Ready
	DropShell:
		ADRO C 1 BRIGHT A_JumpIfInventory("AmmoShell", 4, 2)
		TNT1 A 0 A_Print("Not enough ammo to drop", 1)
		Goto Ready
		TNT1 A 0 A_TakeInventory("AmmoShell", 4)
		ADRO C 10 BRIGHT A_SpawnItemEx("AmmoShell", random(51, 55), random(-4, 4), 40, 2, 0, 2, angle, SXF_ABSOLUTEANGLE)
		TNT1 A 0 A_Refire
		Goto Ready
	DropShell2:
		ADRO D 1 BRIGHT A_JumpIfInventory("GreenShell", 4, 2)
		TNT1 A 0 A_Print("Not enough ammo to drop", 1)
		Goto Ready
		TNT1 A 0 A_TakeInventory("GreenShell", 4)
		ADRO D 10 BRIGHT A_SpawnItemEx("GreenShell", random(51, 55), random(-4, 4), 40, 2, 0, 2, angle, SXF_ABSOLUTEANGLE)
		TNT1 A 0 A_Refire
		Goto Ready
	DropRifle:
		ADRO E 1 BRIGHT A_JumpIfInventory("Clip2", 15, 2)
		TNT1 A 0 A_Print("Not enough ammo to drop", 1)
		Goto Ready
		TNT1 A 0 A_TakeInventory("Clip2", 15)
		ADRO E 10 BRIGHT A_SpawnItemEx("RifleMagazine", random(51, 55), random(-4, 4), 40, 2, 0, 2, angle, SXF_ABSOLUTEANGLE)
		TNT1 A 0 A_Refire
		Goto Ready
	DropMinigun:
		ADRO F 1 BRIGHT A_JumpIfInventory("MinigunAmmo", 20, 2)
		TNT1 A 0 A_Print("Not enough ammo to drop", 1)
		Goto Ready
		TNT1 A 0 A_TakeInventory("MinigunAmmo", 20)
		ADRO F 10 BRIGHT A_SpawnItemEx("MinigunAmmo", random(51, 55), random(-4, 4), 40, 2, 0, 2, angle, SXF_ABSOLUTEANGLE)
		TNT1 A 0 A_Refire
		Goto Ready
	DropRocket:
		ADRO G 1 BRIGHT A_JumpIfInventory("AmmoRocket", 1, 2)
		TNT1 A 0 A_Print("Not enough ammo to drop", 1)
		Goto Ready
		TNT1 A 0 A_TakeInventory("AmmoRocket", 1)
		ADRO G 10 BRIGHT A_SpawnItemEx("AmmoRocket", random(51, 55), random(-4, 4), 40, 2, 0, 2, angle, SXF_ABSOLUTEANGLE)
		TNT1 A 0 A_Refire
		Goto Ready
	DropCell:
		ADRO H 1 BRIGHT A_JumpIfInventory("AmmoCell", 20, 2)
		TNT1 A 0 A_Print("Not enough ammo to drop", 1)
		Goto Ready
		TNT1 A 0 A_TakeInventory("AmmoCell", 20)
		ADRO H 10 BRIGHT A_SpawnItemEx("AmmoCell", random(51, 55), random(-4, 4), 40, 2, 0, 2, angle, SXF_ABSOLUTEANGLE)
		TNT1 A 0 A_Refire
		Goto Ready
	DropCore:
		ADRO I 1 BRIGHT A_JumpIfInventory("RailCore", 8, 2)
		TNT1 A 0 A_Print("Not enough ammo to drop", 1)
		Goto Ready
		TNT1 A 0 A_TakeInventory("RailCore", 8)
		ADRO I 10 BRIGHT A_SpawnItemEx("RailCore", random(51, 55), random(-4, 4), 40, 2, 0, 2, angle, SXF_ABSOLUTEANGLE)
		TNT1 A 0 A_Refire
		Goto Ready
	DropFuel:
		ADRO J 1 BRIGHT A_JumpIfInventory("Gasoline", 50, 2)
		TNT1 A 0 A_Print("Not enough ammo to drop", 1)
		Goto Ready
		TNT1 A 0 A_TakeInventory("Gasoline", 50)
		ADRO J 10 BRIGHT A_SpawnItemEx("Gasoline", random(51, 55), random(-4, 4), 40, 2, 0, 2, angle, SXF_ABSOLUTEANGLE)
		TNT1 A 0 A_Refire
		Goto Ready
	DropGrenade:
		ADRO K 1 BRIGHT A_JumpIfInventory("GrenadeAmmo", 1, 2)
		TNT1 A 0 A_Print("Not enough ammo to drop", 1)
		Goto Ready
		TNT1 A 0 A_TakeInventory("GrenadeAmmo", 1)
		ADRO K 10 BRIGHT A_SpawnItemEx("GrenadeAmmo", random(51, 55), random(-4, 4), 40, 2, 0, 2, angle, SXF_ABSOLUTEANGLE)
		TNT1 A 0 A_Refire
		Goto Ready
		
	Debug:
		TNT1 A 0 A_TakeInventory("Kicking",1)
		TNT1 A 0 A_JumpIfInventory("Levelcounter", 1, 2)
		TNT1 A 0 A_Print("Level: 0?!")
		Goto Ready
		TNT1 A 0 A_JumpIfInventory("Levelcounter", 2, 2)
		TNT1 A 0 A_Print("Level: 1")
		Goto Ready
		TNT1 A 0 A_JumpIfInventory("Levelcounter", 3, 2)
		TNT1 A 0 A_Print("Level: 2")
		Goto Ready
		TNT1 A 0 A_JumpIfInventory("Levelcounter", 4, 2)
		TNT1 A 0 A_Print("Level: 3")
		Goto Ready
		TNT1 A 0 A_JumpIfInventory("Levelcounter", 5, 2)
		TNT1 A 0 A_Print("Level: 4")
		Goto Ready
		TNT1 A 0 A_JumpIfInventory("Levelcounter", 6, 2)
		TNT1 A 0 A_Print("Level: 5")
		Goto Ready
		TNT1 A 0 A_JumpIfInventory("Levelcounter", 7, 2)
		TNT1 A 0 A_Print("Level: 6")
		Goto Ready
		TNT1 A 0 A_JumpIfInventory("Levelcounter", 8, 2)
		TNT1 A 0 A_Print("Level: 7")
		Goto Ready
		TNT1 A 0 A_JumpIfInventory("Levelcounter", 9, 2)
		TNT1 A 0 A_Print("Level: 8")
		Goto Ready
		TNT1 A 0 A_JumpIfInventory("Levelcounter", 10, 2)
		TNT1 A 0 A_Print("Level: 9")
		Goto Ready
		TNT1 A 0 A_Print("Level: 10+")
		Goto Ready
	}
}

ACTOR U_AmmoDropSlot : Inventory
{
   Inventory.Amount 0
   Inventory.MaxAmount 10
}