//======================================================================
//
// Weapon Casings
//
//======================================================================

ACTOR CasingBasis //(Creds to TheRailGunner)
{
	PROJECTILE
	-NOGRAVITY
	-NOBLOCKMAP
	+BOUNCEONACTORS
	+FORCEXYBILLBOARD
	Mass 10
	BounceType Doom
	BounceFactor 0.5
	WallBounceFactor 0.2
}


//=======================================================//
// 9mm Casings Spawner									 //
//=======================================================//

ACTOR 9mmCaseSpawn
{
	Speed 25
	PROJECTILE
	+NOCLIP
	+CLIENTSIDEONLY
	States
	{
	Spawn:
        TNT1 A 0
		TNT1 A 1 A_CustomMissile("9mmCasing",-5,0,random(-80,-100),2,random(45,80))//-2,0,random(80,100),2,random(40,80))
		Stop
	}
}

//=======================================================//
// 9mm Casings Spawner (left)							 //
//=======================================================//

ACTOR 9mmCasingSpawnL : 9mmCaseSpawn
{
	States
	{
	Spawn:
        TNT1 A 0
		TNT1 A 1 A_CustomMissile("9mmCasing",-2,-10,frandom(80,100),2,frandom(40,80))
		Stop
	}
}

// Uzi

ACTOR Uzi9mmCasingSpawnL : 9mmCaseSpawn
{
	States
	{
	Spawn:
        TNT1 A 0
		TNT1 A 1 A_CustomMissile("9mmCasing",-2,-10,frandom(80,100),2,frandom(40,80))
		Stop
	}
}

//=======================================================//
// 9mm Casings Spawner (right)							 //
//=======================================================//

ACTOR 9mmCasingSpawnR : 9mmCaseSpawn
{
	States
	{
	Spawn:
        TNT1 A 0
		TNT1 A 1 A_CustomMissile("9mmCasing",-2,-10,frandom(-80,-100),2,frandom(40,80))
		Stop
	}
}

// Uzi

ACTOR Uzi9mmCasingSpawnR : 9mmCaseSpawn
{
	States
	{
	Spawn:
        TNT1 A 0
		TNT1 A 1 A_CustomMissile("9mmCasing",-2,-10,frandom(-80,-100),2,frandom(40,80))
		Stop
	}
}

//=======================================================//
// 9mm Casings Spawned Casing							 //
//=======================================================//

ACTOR 9mmCasing : CasingBasis
{ 
	Radius 3
	Height 3
	Speed 9
	Scale 0.1
   	WallBounceSound "weapons/casing"
	BounceSound "weapons/casing"
	DeathSound "weapons/casing"
	States
	{
	Spawn:
		TNT1 A 0
		TNT1 A 0 A_JumpIf(CallACS("CasingToggle")==1, "Vanish")
		CAS1 ABCDEFGHIJK 1
		TNT1 A 0
		Loop
	Death:
		TNT1 A 0
		TNT1 A 0 A_jump(256,"Death1","Death2")
	Death1:
		CAS1 K 250
		Stop
	Death2:
		CAS1 D 250
		Stop
	Vanish:
		TNT1 A 0 A_StopSound(2)
		Stop
	}
}

//=======================================================//
// Assault Rifle casing spawner							 //
//=======================================================//

ACTOR RifleCaseSpawn
{
	Speed 35
	PROJECTILE
	+NOCLIP
	+CLIENTSIDEONLY
	States
	{
	Spawn:
        TNT1 A 0
		TNT1 A 1 A_CustomMissile("EmptyBrass",-5,0,random(-80,-100),2,random(45,80))//-2,0,random(80,100),2,random(40,80))
		Stop
	}
}

//=======================================================//
// Chaingun Casing Spawner							 //
//=======================================================//

ACTOR 50CaseSpawn
{
	Speed 20
	PROJECTILE
	+NOCLIP
	+CLIENTSIDEONLY
	States
	{
	Spawn:
        TNT1 A 0
		TNT1 A 1 A_CustomMissile("EmptyBrass",-2,0,random(80,100),2,random(40,80))
		Stop
	}
}

//=======================================================//
// Assault Rifle spawned casing							 //
//=======================================================//

ACTOR EmptyBrass : CasingBasis
{
	Height 5
	Radius 5
	Speed 6
	Scale 0.1
	WallBounceSound "weapons/rcasing"
	BounceSound "weapons/rcasing"
	DeathSound "weapons/rcasing"
	States
	{
	Spawn:
		TNT1 A 0
		TNT1 A 0 A_JumpIf(CallACS("CasingToggle")==1, "Vanish")
		CAS3 ABCDEFGH 3
		TNT1 A 0
		Loop
	Death:
		TNT1 A 0 
		TNT1 A 0 A_jump(256,"Death1","Death2")
	Death1:
		CAS3 A 250
		Stop
	Death2:
		CAS3 E 250
		Stop
	Vanish:
		TNT1 A 0 A_StopSound(2)
		Stop
   }
}

//=======================================================//
// Assault Rifle spawned casing	(different direction)	 //
//=======================================================//

ACTOR EmptyBrass2 : CasingBasis
{
	Height 5
	Radius 5
	Speed 6
	Scale 0.1
	WallBounceSound "weapons/rcasing"
	BounceSound "weapons/rcasing"
	DeathSound "weapons/rcasing"
	States
   {
   Spawn:
		CAS3 ABCDEFGH 3
		Loop
	Death:
		TNT1 A 0 
		TNT1 A 0 A_jump(256,"Death1","Death2")
	Death1:
		CAS3 A 1000
		TNT1 A 0 A_CheckSight(1)
		Wait
		TNT1 A 1
		Stop
	Death2:
		CAS3 E 1000
		TNT1 A 0 A_CheckSight(1)
		Wait
		TNT1 A 1
		Stop
   }
}

//=======================================================//
// Shotgun Casing spawner								 //
//=======================================================//

ACTOR ShotCaseSpawn: RifleCaseSpawn
{
	States
	{
	Spawn:
        TNT1 A 0
		TNT1 A 1 A_CustomMissile("ShotgunCasing",-2,0,random(80,100),2,random(40,80))
		Stop
	}
}

//======================================================//
// Triple barreled Casing spawner variant    	   		//
//======================================================//

ACTOR SSGCasingSpawner: ShotCaseSpawn {}

//=======================================================//
// Shotgun spawned Casing								 //
//=======================================================//

ACTOR ShotgunCasing: CasingBasis
{
	Height 8
	Radius 4
	Speed 9
	Scale 0.23
	WallBounceSound "weapons/shell"
	BounceSound "weapons/shell"
	DeathSound "weapons/shell"
	States
   {
	Spawn:
		TNT1 A 0
		TNT1 A 0 A_JumpIf(CallACS("CasingToggle")==1, "Vanish")
		CAS2 ABCDEFGHIJKLMN 2
		TNT1 A 0
		Loop
	Death:
      TNT1 A 0 A_Jump(256,"Rest1","Rest2","Rest3","Rest4","Rest5","Rest6","Rest7","Rest8")
      Goto Rest1
    Rest1:
      CAS2 B 250
      TNT1 A 0 A_CheckSight("Vanish")
		Loop
    Rest2:
      CAS2 H 250
      TNT1 A 0 A_CheckSight("Vanish")
		Loop
    Rest3:
      CAS2 L 250
      TNT1 A 0 A_CheckSight("Vanish")
		Loop
    Rest4:
      CAS2 N 250
      TNT1 A 0 A_CheckSight("Vanish")
		Loop
    Rest5:
      CAS2 B 250
      TNT1 A 0 A_CheckSight("Vanish")
		Loop
    Rest6:
      CAS2 H 250
      TNT1 A 0 A_CheckSight("Vanish")
		Loop
    Rest7:
      CAS2 P 250
      TNT1 A 0 A_CheckSight("Vanish")
		Loop
    Rest8:
      TNT1 A 0 A_CheckSight("Vanish")
      CAS2 N 250
		Loop
     Vanish:
		TNT1 A 0 A_StopSound(2)
		Stop

   }
}