// TIBERIUM AUTORIFLE
actor TiberiumAutorifleWeak : AOWWeapon 21084 {
	+AMMO_OPTIONAL
	+ALT_AMMO_OPTIONAL
	inventory.pickupmessage "You got the Tiberium Autorifle!"
	weapon.selectionorder 13
	weapon.kickback 100
	weapon.ammotype "TE21Burst"
	weapon.ammouse 1
	weapon.ammogive 4
	weapon.ammotype2 "TE21CalAmmo"
	weapon.ammouse2 1
	weapon.ammogive2 20
	obituary "%o was skewered by %k's Tiberium Autorifle."
	Weapon.PreferredSkin "MarineMachineGun"
	states
	{
	Ready:
		E21C A 8 A_WeaponReady
		E21C A 0 A_JumpIfInventory("TE21Burst",4,2) //Full ammo? Don't take clip plz thx
		E21C A 0 A_JumpIfInventory("TE21CalAmmo",1,2) //Otherwise, do we have ammo? Yes? Good, go give us a shot.
		E21C A 0
		loop
		E21C A 0 A_TakeInventory("TE21CalAmmo",1) //D:
		E21C A 0 A_GiveInventory("TE21Burst",1) //Fu.. Er, SHOT given
		loop //lets go back shall we nao
	Deselect:
		E21C A 1 A_Lower
		wait
	Select:
		E21C A 1 A_Raise
		wait
	Fire:
		E21C A 0 A_JumpIfInventory ("IsInSpawnRoom", 1, "Ready")
		E21C A 0 A_JumpIfInventory ("InMenu", 1, "Ready")
		E21C A 0 A_JumpIfNoAmmo ("Reload")
		E21C A 0 A_GunFlash
		E21C A 0 A_PlaySound("toxin/fire")
		E21C A 0 bright A_FireCustomMissile ("TiberiumDart", 0, 1, 10)
		E21C A 1 bright offset(2,33)
		E21C A 1 bright offset(3,36)
		E21C A 1 bright offset(2,34)
		E21C A 1 bright offset(1,32)
		E21C A 2 A_JumpIfNoAmmo ("Reload")
		E21C A 2 A_ReFire
		goto Ready
	Hold:
		E21C A 0 A_JumpIfInventory ("IsInSpawnRoom", 1, "Ready")
		E21C A 0 A_JumpIfInventory ("InMenu", 1, "Ready")
		E21C A 0 A_JumpIfNoAmmo ("Reload")
		E21C A 0 A_GunFlash
		E21C A 0 A_PlaySound("toxin/fire")
		E21C A 0 bright A_FireCustomMissile ("TiberiumDart", (2+random(-3,0))*0.5, 1, 10)
		goto Fire+6
	AltFire:
		E21C A 1 A_JumpIfInventory("TE21Cooldown",1,"Ready")
		E21C A 0 A_JumpIfInventory("TE21Burst",1,1)
		Goto Ready
		E21C A 0 A_PlaySound("toxin/fire",CHAN_AUTO)
		E21C A 1 A_GunFlash
		E21C A 0 A_TakeInventory("TE21Burst",1)
		E21C A 3 A_FireCustomMissile("TiberiumDartWeak",0,0,10)
		E21C A 0 A_JumpIfInventory ("TE21Burst", 1, "AltFireSound")
		goto Ready
	AltFireSound:
		E21C A 0 A_GiveInventory("TE21Cooldown",1)
		E21C A 0 A_PlaySound("toxin/fire",CHAN_AUTO)
		E21C A 1 A_PlaySound("toxin/fire",CHAN_AUTO)
		E21C A 0 A_GunFlash
	AltFireLoop:
		E21C A 0 A_FireCustomMissile ("TiberiumDartWeak", 0, 0, 10)
		E21C A 0 A_TakeInventory ("TE21Burst", 1)
		E21C A 0 A_JumpIfInventory ("TE21Burst", 1, 1)
		goto AltFireLoop+12
		E21C A 0 A_SetAngle(Angle+4)
		E21C A 0 A_FireCustomMissile ("TiberiumDartWeak", 0, 0, 10)
		E21C A 0 A_SetAngle(Angle-4)
		E21C A 0 A_TakeInventory ("TE21Burst", 1)
		E21C A 0 A_JumpIfInventory ("TE21Burst", 1, 1)
		goto AltFireLoop+12
		E21C A 0 A_SetAngle(Angle-4)
		E21C A 0 A_FireCustomMissile ("TiberiumDartWeak", 0, 0, 10)
		E21C A 0 A_SetAngle(Angle+4)
		E21C A 0 A_TakeInventory ("TE21Burst", 1)
		E21C A 1 bright offset(2,33)
		E21C A 1 bright offset(3,36)
		E21C A 1 bright offset(2,34)
		E21C A 1 bright offset(1,32)
		E21C A 30
		goto Reload
	Reload:
		E21C A 0 A_JumpIfInventory ("TE21CalAmmo", 4, 2)
		E21C A 5 A_CheckReload
		goto Ready
		E21C A 10
		E21C A 0 A_TakeInventory ("TE21CalAmmo", 4)
		E21C A 0 A_GiveInventory ("TE21Burst", 4)
		goto Ready
	Flash:
		E21C M 2 Bright A_Light1
		E21C N 2 Bright A_Light2
		E21C M 1 Bright A_Light0
		stop
	Spawn:
		E21C X -1
		stop
	}
}

actor TiberiumAutorifle : TiberiumAutorifleWeak {
	obituary "%o was skewered and mutated by %k's Tiberium Autorifle."
	weapon.ammotype "TE21Burst6"
	weapon.ammouse 1
	Dropitem "TiberiumAutorifleWeak"
	weapon.ammogive 3
	states {
	Ready:
		E21C A 0
		goto Ready2
	Ready2:
		E21C A 4 A_WeaponReady
		E21C A 0 A_JumpIfInventory("TE21Burst6",0,2)
		E21C A 0 A_JumpIfInventory("TE21CalAmmo",1,2)
		E21C A 0
		loop
		E21C A 0 A_TakeInventory("TE21CalAmmo",1)
		E21C A 0 A_GiveInventory("TE21Burst6",1)
		loop
	Reload:
		E21C A 0 A_JumpIfInventory ("TE21CalAmmo", 6, 2)
		E21C A 5 A_CheckReload
		goto Ready
		E21C A 11
		E21C A 0 A_TakeInventory ("TE21CalAmmo", 6)
		E21C A 0 A_GiveInventory ("TE21Burst6", 6)
		goto Ready
	Fire:
		E21C A 0 A_JumpIfInventory ("IsInSpawnRoom", 1, "Ready")
		E21C A 0 A_JumpIfInventory ("InMenu", 1, "Ready")
		E21C A 0 A_JumpIfNoAmmo ("Reload")
		E21C A 0 A_GunFlash
		E21C A 0 A_PlaySound("toxin/fire")
		E21C A 0 bright A_FireCustomMissile ("TiberiumDart", 0, 1, 10)
		E21C A 1 bright offset(2,33)
		E21C A 1 bright offset(3,36)
		E21C A 1 bright offset(2,34)
		E21C A 1 bright offset(1,32)
		E21C A 2 A_JumpIfNoAmmo ("Reload")
		E21C A 2 A_ReFire
		goto Ready
	Hold:
		E21C A 0 A_JumpIfInventory ("IsInSpawnRoom", 1, "Ready")
		E21C A 0 A_JumpIfInventory ("InMenu", 1, "Ready")
		E21C A 0 A_JumpIfNoAmmo ("Reload")
		E21C A 0 A_GunFlash
		E21C A 0 A_PlaySound("toxin/fire")
		E21C A 0 bright A_FireCustomMissile ("TiberiumDart", (2+random(-3,0))*0.4, 1, 10)
		goto Fire+6
	AltFire:
		E21C A 1 A_JumpIfInventory("TE21Cooldown",1,"Ready")
		E21C A 0 A_JumpIfInventory("TE21Burst6",1,1)
		Goto Ready
		E21C A 1 A_PlaySound("toxin/fire",CHAN_AUTO)
		E21C A 0 A_GunFlash
		E21C A 0 A_TakeInventory("TE21Burst6",2)
		E21C A 0 A_FireCustomMissile("TiberiumDartWeak",0,0,16)
		E21C A 3 A_FireCustomMissile("TiberiumDartWeak",0,0,8)
		E21C A 0 A_JumpIfInventory ("TE21Burst6", 1, "AltFireSound")
		goto Ready
	AltFireSound:
		E21C A 0 A_GiveInventory("TE21Cooldown",1)
		E21C A 0 A_PlaySound("toxin/fire",CHAN_AUTO)
		E21C A 1 A_PlaySound("toxin/fire",CHAN_AUTO)
		E21C A 0 A_GunFlash
	AltFireLoop:
		E21C A 0 A_SetAngle(Angle+2.5)
		E21C A 0 A_FireCustomMissile ("TiberiumDartWeak", 0, 0, 10)
		E21C A 0 A_SetAngle(Angle-2.5)
		E21C A 0 A_TakeInventory ("TE21Burst6", 1)
		E21C A 0 A_JumpIfInventory ("TE21Burst6", 1, 1)
		goto AltFireLoop+22
		E21C A 0 A_SetAngle(Angle+5)
		E21C A 0 A_FireCustomMissile ("TiberiumDartWeak", 0, 0, 10)
		E21C A 0 A_SetAngle(Angle-5)
		E21C A 0 A_TakeInventory ("TE21Burst6", 1)
		E21C A 0 A_JumpIfInventory ("TE21Burst6", 1, 1)
		goto AltFireLoop+22
		E21C A 0 A_SetAngle(Angle-2.5)
		E21C A 0 A_FireCustomMissile ("TiberiumDartWeak", 0, 0, 10)
		E21C A 0 A_SetAngle(Angle+2.5)
		E21C A 0 A_TakeInventory ("TE21Burst6", 1)
		E21C A 0 A_JumpIfInventory ("TE21Burst6", 1, 1)
		goto AltFireLoop+22
		E21C A 0 A_SetAngle(Angle-5)
		E21C A 0 A_FireCustomMissile ("TiberiumDartWeak", 0, 0, 10)
		E21C A 0 A_SetAngle(Angle+5)
		E21C A 0 A_TakeInventory ("TE21Burst6", 1)
		E21C A 0 A_JumpIfInventory ("TE21Burst6", 1, 1)
		E21C A 1 bright offset(2,33)
		E21C A 1 bright offset(3,36)
		E21C A 1 bright offset(2,34)
		E21C A 1 bright offset(1,32)
		E21C A 30
		goto Reload
	Spawn:
		TNT1 A 0
		TNT1 A 0 A_SpawnItemEx ("TiberiumAutorifleWeak")
		stop
	}
}

actor TE21Burst : Ammo {
	+IGNORESKILL
	inventory.amount 4
	inventory.maxamount 4
	ammo.backpackamount 4
	ammo.backpackmaxamount 4
}

actor TE21Burst6 : Ammo {
	+IGNORESKILL
	inventory.amount 6
	inventory.maxamount 6
	ammo.backpackamount 6
	ammo.backpackmaxamount 6
}

actor TiberiumDart : FastProjectile {
	PROJECTILE
	-RANDOMIZE
	radius 13
	height 6
	speed 80
	damage (6)
	damagetype "Rifle"
	renderstyle add
	alpha 0.85
	scale 0.15
	deathsound "toxin/explode"
	decal "ChemScorch"
	states {
	Spawn:
		E21X A -1 bright
		stop
	Death:
		TNT1 A 0
		TNT1 A 0 A_SpawnItemEx ("TiberiumDartExplosion", -1)
		TNT1 A 5 A_SpawnItemEx ("ChemicalExplosionSmall")
		TNT1 A 0 A_SpawnItemEx("AnthraxDecay", random(-16,16), random(-16,16), 4, 0, 0, 0, 0, 0, 160)
		stop
	}
}

actor TiberiumDartWeak : TiberiumDart { speed 72 damage (4) }

actor TiberiumDartExplosion {
	PROJECTILE
	+NOCLIP
	DamageType "Chemical"
	states {
	Spawn:
		TNT1 A 0
		TNT1 A 5 A_Explode(6, 64)
		stop
	}
}

actor TE21Cooldown : Cooldown { Powerup.Duration 75 }