// --------------------------------------------------------------------------
//
//	9mm Ammo	-	Beretta, SMG, MP40
//
// --------------------------------------------------------------------------

Actor Magazine9mm : Ammo
{
	Ammo.DropAmount 15
	Inventory.Amount 15
	Inventory.MaxAmount 200
	Ammo.BackpackAmount 15
	Ammo.BackpackMaxAmount 400
	Inventory.Icon "CLIUA0"
	Inventory.PickupMessage "Picked up a magazine."
	Scale 0.7
	States
	{
	Spawn:
		CLI3 A -1
		Stop
	}
}

// --------------------------------------------------------------------------
//
//	Revolver Bullets	-	Revolver
//
// --------------------------------------------------------------------------

Actor RevolverBullets : Ammo
{
	Inventory.Amount 5
	Inventory.MaxAmount 50
	Ammo.BackpackAmount 15
	Ammo.BackpackMaxAmount 100
	Inventory.Icon "RVICB0"
	Inventory.PickupMessage "You got a some revolver bullets."
	Scale 0.2
	States
	{
	Spawn:
		RVIC C -1
		Stop
	}
}

Actor RevolverBox : RevolverBullets
{
	Inventory.Amount 15
	Inventory.PickupMessage "You got a pack of revolver bullets."
	Scale 0.6
	States
	{
	Spawn:
		RVIC B -1
		Stop
	}
}

Actor SmartRevolverBox : CustomInventory
{
	Scale 0.6
	States
	{
	Spawn:
		TNT1 A 0
		TNT1 A 0 ACS_NamedExecuteAlways("TE_SmartAmmo")
		RVIC B -1
		Stop
	NoSmart:
		TNT1 A 0 A_SpawnItemEx("RevolverBox")
		Stop
	Pickup:
		//Check if full on ammo
		TNT1 A 0 A_JumpIfInventory("TE_BackPack",1,2)
		TNT1 A 0 A_JumpIfInventory("RevolverBullets",50,"NoPickup")
		TNT1 A 0 A_JumpIfInventory("RevolverBullets",100,"NoPickup")
		//Check if enough ammo for whole pack
		TNT1 A 0 A_JumpIfInventory("TE_BackPack",1,2)
		TNT1 A 0 A_JumpIfInventory("RevolverBullets",40,"SpawnSmartAmmo")
		TNT1 A 0 A_JumpIfInventory("RevolverBullets",90,"SpawnSmartAmmo")
		TNT1 A 0 A_SpawnItemEx("RevolverBox")
		Stop
	NoPickup:
		RVIC B 1
		Fail
	SpawnSmartAmmo:
		RVIC B 1
		RVIC BBB 1 A_SpawnItemEx("RevolverBullets",0,0,0,frandom(2,3),0,frandom(2,3),random(1,360))
		RVIC B 1
		Stop
	}
}

// --------------------------------------------------------------------------
//
//	Green Shells	-	Automatic Shotgun, Assault Shotgun
//
// --------------------------------------------------------------------------

Actor GreenShell : Ammo
{
	Ammo.DropAmount 4
	Inventory.Amount 4
	Inventory.MaxAmount 50
	Ammo.BackpackAmount 12
	Ammo.BackpackMaxAmount 100
	Inventory.Icon "2SHLA0"
	Inventory.Pickupsound "SHELPK1"
	Inventory.PickupMessage "Picked up 4 green shotgun shells."
	Scale 0.9
	States
	{
	Spawn:
		2SHL A -1
		Stop
	}
}

Actor GreenShellBox : GreenShell
{
	Inventory.Amount 16
	Inventory.PickupMessage "Picked up a box of green shotgun shells."
	Inventory.Pickupsound "SHELPK2"
	Scale 0.9
	States
	{
	Spawn:
		2SHL B -1
		Stop
	}
}

Actor SmartGreenShellBox : CustomInventory
{
	Scale 0.9
	States
	{
	Spawn:
		TNT1 A 0
		TNT1 A 0 ACS_NamedExecuteAlways("TE_SmartAmmo")
		2SHL B -1
		Stop
	NoSmart:
		TNT1 A 0 A_SpawnItemEx("GreenShellBox")
		Stop
	Pickup:
		//Check if full on ammo
		TNT1 A 0 A_JumpIfInventory("TE_BackPack",1,2)
		TNT1 A 0 A_JumpIfInventory("GreenShell",50,"NoPickup")
		TNT1 A 0 A_JumpIfInventory("GreenShell",100,"NoPickup")
		//Check if enough ammo for whole pack
		TNT1 A 0 A_JumpIfInventory("TE_BackPack",1,2)
		TNT1 A 0 A_JumpIfInventory("GreenShell",38,"SpawnSmartAmmo")
		TNT1 A 0 A_JumpIfInventory("GreenShell",88,"SpawnSmartAmmo")
		TNT1 A 0 A_SpawnItemEx("GreenShellBox")
		Stop
	NoPickup:
		2SHL B 1
		Fail
	SpawnSmartAmmo:
		2SHL B 1
		2SHL BBBB 1 A_SpawnItemEx("GreenShell",0,0,0,frandom(2,3),0,frandom(2,3),random(1,360))
		2SHL B 1
		Stop
	}
}

// --------------------------------------------------------------------------
//
//	Red Shells	-	Shotgun, Super Shotgun
//
// --------------------------------------------------------------------------

Actor AmmoShellBox2 : AmmoShellBox
{
	Inventory.Amount 16
}

Actor SmartShellBox : CustomInventory
{
	Scale 0.9
	States
	{
	Spawn:
		TNT1 A 0
		TNT1 A 0 ACS_NamedExecuteAlways("TE_SmartAmmo")
		SBOX A -1
		Stop
	NoSmart:
		TNT1 A 0 A_SpawnItemEx("AmmoShellBox2")
		Stop
	Pickup:
		//Check if full on ammo
		TNT1 A 0 A_JumpIfInventory("TE_BackPack",1,2)
		TNT1 A 0 A_JumpIfInventory("AmmoShell",50,"NoPickup")
		TNT1 A 0 A_JumpIfInventory("AmmoShell",100,"NoPickup")
		//Check if enough ammo for whole pack
		TNT1 A 0 A_JumpIfInventory("TE_BackPack",1,2)
		TNT1 A 0 A_JumpIfInventory("AmmoShell",38,"SpawnSmartAmmo")
		TNT1 A 0 A_JumpIfInventory("AmmoShell",88,"SpawnSmartAmmo")
		TNT1 A 0 A_SpawnItemEx("AmmoShellBox2")
		Stop
	NoPickup:
		SBOX A 1
		Fail
	SpawnSmartAmmo:
		SBOX A 1
		SBOX AAAA 1 A_SpawnItemEx("AmmoShell",0,0,0,frandom(2,3),0,frandom(2,3),random(1,360))
		SBOX A 1
		Stop
	}
}

// --------------------------------------------------------------------------
//
//	Clip2	-	Rifle, Machinegun, Sniper
//
// --------------------------------------------------------------------------

Actor RifleMagazine : Clip2
{
	Inventory.Amount 15
	Scale 0.9
	States
	{
	Spawn:
		CLIP A -1
		Stop
	}
}

Actor RifleBox : Clip2
{
	Inventory.Amount 75
	Inventory.PickupMessage "Picked up a box of rifle ammunition."
	Inventory.PickupSound "CBOXPICK"
	Scale 0.9
	States
	{
	Spawn:
		CLIP C -1
		Stop
	}
}

Actor SmartRifleBox : CustomInventory
{
	Scale 0.9
	States
	{
	Spawn:
		TNT1 A 0
		TNT1 A 0 ACS_NamedExecuteAlways("TE_SmartAmmo")
		CLIP C -1
		Stop
	NoSmart:
		TNT1 A 0 A_SpawnItemEx("RifleBox")
		Stop
	Pickup:
		//Check if full on ammo
		TNT1 A 0 A_JumpIfInventory("TE_BackPack",1,2)
		TNT1 A 0 A_JumpIfInventory("Clip2",300,"NoPickup")
		TNT1 A 0 A_JumpIfInventory("Clip2",600,"NoPickup")
		//Check if enough ammo for whole pack
		TNT1 A 0 A_JumpIfInventory("TE_BackPack",1,2)
		TNT1 A 0 A_JumpIfInventory("Clip2",240,"SpawnSmartAmmo")
		TNT1 A 0 A_JumpIfInventory("Clip2",540,"SpawnSmartAmmo")
		TNT1 A 0 A_SpawnItemEx("RifleBox")
		Stop
	NoPickup:
		CLIP C 1
		Fail
	SpawnSmartAmmo:
		CLIP C 1
		CLIP CCCCC 1 A_SpawnItemEx("RifleMagazine",0,0,0,frandom(2,3),0,frandom(2,3),random(1,360))
		CLIP C 1
		Stop
	}
}

// --------------------------------------------------------------------------
//
//	MinigunAmmo	-	Minigun
//
// --------------------------------------------------------------------------

Actor MinigunAmmo : Ammo
{
	Inventory.Amount 20
	Inventory.MaxAmount 500
	Ammo.BackpackAmount 50
	Ammo.BackpackMaxAmount 1000
	Inventory.Icon "ABOXA0"
	Inventory.PickupMessage "Picked up a belt of minigun ammunition."
	Inventory.PickupSound "CBOXPICK"
	Scale 0.6
	States
	{
	Spawn:
		ABOX B -1
		Stop
	}
}

Actor MinigunBox : CustomInventory
{
	Inventory.PickupMessage "Picked up a box of minigun ammunition."
	Inventory.PickupSound "CBOXPICK"
	Scale 0.6
	States
	{
	Spawn:
		ABOX D -1
		Stop
	Pickup:
		TNT1 A 0 A_JumpIfInventory("IsPlayingAsPurist",1,2)
		TNT1 A 0 A_GiveInventory("MinigunAmmo",100)
		Stop
		TNT1 A 0 A_GiveInventory("Clip2",100)
		Stop
	}
}

Actor SmartMinigunBox : CustomInventory
{
	Scale 0.6
	States
	{
	Spawn:
		TNT1 A 0
		TNT1 A 0 ACS_NamedExecuteAlways("TE_SmartAmmo")
		ABOX D -1
		Stop
	NoSmart:
		TNT1 A 0 A_SpawnItemEx("MinigunBox")
		Stop
	Pickup:
		//Check if full on ammo
		TNT1 A 0 A_JumpIfInventory("TE_BackPack",1,2)
		TNT1 A 0 A_JumpIfInventory("MinigunAmmo",500,"NoPickup")
		TNT1 A 0 A_JumpIfInventory("MinigunAmmo",1000,"NoPickup")
		//Check if enough ammo for whole pack
		TNT1 A 0 A_JumpIfInventory("TE_BackPack",1,2)
		TNT1 A 0 A_JumpIfInventory("MinigunAmmo",420,"SpawnSmartAmmo")
		TNT1 A 0 A_JumpIfInventory("MinigunAmmo",920,"SpawnSmartAmmo")
		TNT1 A 0 A_SpawnItemEx("MinigunBox")
		Stop
	NoPickup:
		ABOX D 1
		Fail
	SpawnSmartAmmo:
		ABOX D 1
		ABOX DDDDD 1 A_SpawnItemEx("MinigunAmmo",0,0,0,frandom(2,3),0,frandom(2,3),random(1,360))
		ABOX D 1
		Stop
	}
}

// --------------------------------------------------------------------------
//
//	RailCore	-	Railgun, BFG10000
//
// --------------------------------------------------------------------------

Actor RailCore : Ammo
{
	Inventory.Amount 8
	Inventory.MaxAmount 50
	Ammo.BackpackAmount 8
	Ammo.BackpackMaxAmount 100
	Inventory.Icon "RGNAA0"
	Inventory.PickupMessage "Picked up a Rail Core."
	Scale 0.8
	States
	{
	Spawn:
		TNT1 A 0
		TNT1 A 0 A_Jump(256,1,2,3,4)
	Spawn1:
		RGNA ABCD 1
		Loop
	}
}

Actor RailPack : RailCore
{
	Inventory.Amount 24
	Inventory.PickupMessage "Picked up a pack of three Rail Cores."
	Scale 0.8
	States
	{
	Spawn:
		TNT1 A 0
		TNT1 A 0 A_Jump(256,1,2,3,4)
	Spawn1:
		RGNA EFGH 1
		Loop
	}
}

Actor SmartRailPack : CustomInventory
{
	Scale 0.8
	States
	{
	Spawn:
		TNT1 A 0
		TNT1 A 0 ACS_NamedExecuteAlways("TE_SmartAmmo")
		TNT1 A 0 A_Jump(256,1,2,3,4)
	Spawn1:
		RGNA EFGH 1
		Loop
	NoSmart:
		TNT1 A 0 A_SpawnItemEx("RailPack")
		Stop
	Pickup:
		//Check if full on ammo
		TNT1 A 0 A_JumpIfInventory("TE_BackPack",1,2)
		TNT1 A 0 A_JumpIfInventory("RailCore",50,"NoPickup")
		TNT1 A 0 A_JumpIfInventory("RailCore",100,"NoPickup")
		//Check if enough ammo for whole pack
		TNT1 A 0 A_JumpIfInventory("TE_BackPack",1,2)
		TNT1 A 0 A_JumpIfInventory("RailCore",34,"SpawnSmartAmmo")
		TNT1 A 0 A_JumpIfInventory("RailCore",84,"SpawnSmartAmmo")
		TNT1 A 0 A_SpawnItemEx("RailPack")
		Stop
	NoPickup:
		RGNA E 1
		Fail
	SpawnSmartAmmo:
		RGNA E 1
		RGNA EEE 1 A_SpawnItemEx("RailCore",0,0,0,frandom(2,3),0,frandom(2,3),random(1,360))
		RGNA E 1
		Stop
	}
}

// --------------------------------------------------------------------------
//
//	Cell	-	Plasma rifle, BFG9000
//
// --------------------------------------------------------------------------

Actor SmartCellPack : CustomInventory
{
	Scale 0.9
	States
	{
	Spawn:
		TNT1 A 0
		TNT1 A 0 ACS_NamedExecuteAlways("TE_SmartAmmo")
		CELP A -1
		Stop
	NoSmart:
		TNT1 A 0 A_SpawnItemEx("AmmoCellPack")
		Stop
	Pickup:
		//Check if full on ammo
		TNT1 A 0 A_JumpIfInventory("TE_BackPack",1,2)
		TNT1 A 0 A_JumpIfInventory("AmmoCell",300,"NoPickup")
		TNT1 A 0 A_JumpIfInventory("AmmoCell",600,"NoPickup")
		//Check if enough ammo for whole pack
		TNT1 A 0 A_JumpIfInventory("TE_BackPack",1,2)
		TNT1 A 0 A_JumpIfInventory("AmmoCell",220,"SpawnSmartAmmo")
		TNT1 A 0 A_JumpIfInventory("AmmoCell",520,"SpawnSmartAmmo")
		TNT1 A 0 A_SpawnItemEx("AmmoCellPack")
		Stop
	NoPickup:
		CELP A 1
		Fail
	SpawnSmartAmmo:
		CELP A 1
		CELP AAAAA 1 A_SpawnItemEx("AmmoCell",0,0,0,frandom(2,3),0,frandom(2,3),random(1,360))
		CELP A 1
		Stop
	}
}

// --------------------------------------------------------------------------
//
//	C4	-	C-4
//
// --------------------------------------------------------------------------

Actor C4Ammo : Ammo
{
	Inventory.Amount 1
	Inventory.MaxAmount 5
	Ammo.BackpackAmount 1
	Ammo.BackpackMaxAmount 10
	Inventory.Icon C4EWA0
	Inventory.PickupMessage "You got a C-4 Explosive!"
	Scale 0.25
	States
	{
	Spawn:
		C4EI E -1
		Stop
	}
}

Actor SmartC4AmmoPack : CustomInventory
{
	Scale 0.3
	States
	{
	Spawn:
		TNT1 A 0
		TNT1 A 0 ACS_NamedExecuteAlways("TE_SmartAmmo")
		C4EW B -1
		Stop
	NoSmart:
		TNT1 A 0 A_SpawnItemEx("C4Weapon")
		Stop
	Pickup:
		//Check if having weapon
		TNT1 A 0 A_JumpIfInventory("C4Weapon",1,1)
		Goto NoSmart
		//Check if full on ammo
		TNT1 A 0 A_JumpIfInventory("TE_BackPack",1,2)
		TNT1 A 0 A_JumpIfInventory("C4Ammo",5,"NoPickup")
		TNT1 A 0 A_JumpIfInventory("C4Ammo",10,"NoPickup")
		//Check if enough ammo for whole pack
		TNT1 A 0 A_JumpIfInventory("TE_BackPack",1,2)
		TNT1 A 0 A_JumpIfInventory("C4Ammo",3,"SpawnSmartAmmo")
		TNT1 A 0 A_JumpIfInventory("C4Ammo",8,"SpawnSmartAmmo")
		TNT1 A 0 A_SpawnItemEx("C4Weapon")
		Stop
	NoPickup:
		C4EW B 1
		Fail
	SpawnSmartAmmo:
		C4EW B 1
		C4EW BBB 1 A_SpawnItemEx("C4Ammo",0,0,0,frandom(2,3),0,frandom(2,3),random(1,360))
		C4EW B 1
		Stop
	}
}

// --------------------------------------------------------------------------
//
//	Gasoline	-	Mancubus Flame Cannon
//
// --------------------------------------------------------------------------

Actor Gasoline : Ammo
{
	Inventory.Amount 50
	Inventory.MaxAmount 500
	Ammo.BackpackAmount 50
	Ammo.BackpackMaxAmount 1000
	Inventory.Icon "GSLNA0"
	Inventory.PickupMessage "You got Gasoline."
	States
	{
	Spawn:
		GSLN A -1
	}
}

// --------------------------------------------------------------------------
//
//	Upgrades	-	Beretta
//
// --------------------------------------------------------------------------

Actor PistolFlashlight : Ammo
{
	Inventory.Amount 1
	Inventory.MaxAmount 1
	Ammo.BackpackAmount 0
	Ammo.BackpackMaxAmount 1
	Inventory.Icon "FLASH5"
	Inventory.PickupMessage "You got a flashlight attachment for the Pistol."
	Scale 0.08
	States
	{
	Spawn:
		TNT1 A 0
		TNT1 A 0 A_SetAngle(angle - 315)
	Idle1:
		FLAS H 5
		TNT1 A 0 A_CheckRange(1000,2)
		TNT1 A 0 A_Jump(256,2)
		FLAS H 500
		Loop
	Idle2:
		TNT1 A 0 A_Jump(1,2)
		FLAS H 1 A_CustomMissile("FlashLightBeam",5,0,0,2,0)
		Loop
	Idle3:
		FLAS H 1
		Goto Idle2
	}
}

Actor PistolSilencer : CustomInventory
{
	Scale 0.6
	Inventory.PickupMessage "You got a silencer attachment for the Pistol."
	States
	{
	Spawn:
		BERT B -1
		Stop
	Pickup:
		TNT1 A 0
		TNT1 A 0 A_GiveInventory("TE_Pistols",1)
		TNT1 A 0 A_GiveInventory("PistolSilencerAmmo",1)
		TNT1 A 0 A_GiveInventory("Magazine9mm",15)
		Stop
	}
}

Actor PistolSilencerAmmo : Ammo
{
	Inventory.Amount 1
	Inventory.MaxAmount 1
	Ammo.BackpackAmount 0
	Ammo.BackpackMaxAmount 1
	Inventory.Icon "FLASH5"
	Inventory.PickupMessage "You got a silencer attachment for the Pistol."
	Scale 0.6
	States
	{
	Spawn:
		BERT B -1
		Stop
	}
}