// COMBUSTION AUTORIFLE
actor CombustionAutorifleWeak : AOWWeapon 21088 {
	+AMMO_OPTIONAL
	+ALT_AMMO_OPTIONAL
	Tag "Combustion Autorifle"
	Obituary "%o was ignited by %k's Combustion Autorifle."
	Inventory.PickupMessage "You got the Combustion Autorifle!"
	Weapon.SelectionOrder 13
	Weapon.KickBack 100
	Weapon.AmmoType "FA21Burst"
	Weapon.AmmoUse 1
	Weapon.AmmoGive 3
	Weapon.AmmoType2 "FA21CalAmmo"
	Weapon.AmmoUse2 1
	Weapon.AmmoGive2 20
	Weapon.PreferredSkin "MarineMachineGun"
	states {
	Ready:
		E21F A 8 A_WeaponReady
		E21F A 0 A_JumpIfInventory("FA21Burst",3,2) //Full ammo? Don't take clip plz thx
		E21F A 0 A_JumpIfInventory("FA21CalAmmo",1,2) //Otherwise, do we have ammo? Yes? Good, go give us a shot.
		E21F A 0
		loop
		E21F A 0 A_TakeInventory("FA21CalAmmo",1)
		E21F A 0 A_GiveInventory("FA21Burst",1)
		loop //lets go back shall we nao
	Deselect:
		E21F A 1 A_Lower
		wait
	Select:
		E21F A 1 A_Raise
		wait
	Fire:
		E21F A 0 A_JumpIfInventory ("IsInSpawnRoom", 1, "Ready")
		E21F A 0 A_JumpIfInventory ("InMenu", 1, "Ready")
		E21F A 0 A_JumpIfNoAmmo ("Reload")
		E21F A 0 A_GunFlash
		E21F A 0 A_PlaySound("toxin/fire")
		E21F A 0 bright A_FireCustomMissile ("CombustionRound", 0, 1, 10) //[Bloax] Matching the weak tibrifle.
		E21F A 1 bright offset(2,33)
		E21F A 1 bright offset(3,36)
		E21F A 1 bright offset(2,34)
		E21F A 1 bright offset(1,32)
		E21F A 2 A_JumpIfNoAmmo ("Reload")
		E21F A 2 A_ReFire
		goto Ready
	Hold:
		E21F A 0 A_JumpIfInventory ("IsInSpawnRoom", 1, "Ready")
		E21F A 0 A_JumpIfInventory ("InMenu", 1, "Ready")
		E21F A 0 A_JumpIfNoAmmo ("Reload")
		E21F A 0 A_GunFlash
		E21F A 0 A_PlaySound("toxin/fire")
		E21F A 0 bright A_FireCustomMissile ("CombustionRound", (2+random(-3,0))*0.5, 1, 10)
		Goto Fire+6 //Skipping everything pre-and-including-firing.
	AltFire:
		E21F A 1
		E21F A 0 A_JumpIfInventory ("IsInSpawnRoom", 1, "Ready")
		E21F A 0 A_JumpIfInventory ("InMenu", 1, "Ready")
		E21F A 4 A_JumpIfInventory("CombustionCooldown",1,"Ready")
		E21F A 0 A_JumpIfInventory ("FA21Burst", 1, "AltFireSound")
		goto Ready
	AltFireSound:
		E21F A 0 A_GiveInventory("CombustionCooldown",1)
		E21F A 1 A_PlaySound("toxin/fire",CHAN_AUTO)
		E21F A 0 A_GunFlash
		E21F A 0 A_PlaySound("toxin/fire",CHAN_AUTO)
		E21F A 0 A_PlaySound("toxin/fire",CHAN_AUTO)
	AltFireLoop:
		E21F A 0 A_FireCustomMissile ("CombustionRoundWeak", 0, 0, 10)
		E21F A 0 A_TakeInventory ("FA21Burst", 1)
		E21F A 0 A_JumpIfInventory ("FA21Burst", 1, 1)
		goto AltFireLoop+12
		E21F A 0 A_SetAngle(Angle+4)
		E21F A 0 A_FireCustomMissile ("CombustionRoundWeak", 0, 0, 10)
		E21F A 0 A_SetAngle(Angle-4)
		E21F A 0 A_TakeInventory ("FA21Burst", 1)
		E21F A 0 A_JumpIfInventory ("FA21Burst", 1, 1)
		goto AltFireLoop+12
		E21F A 0 A_SetAngle(Angle-4)
		E21F A 0 A_FireCustomMissile ("CombustionRoundWeak", 0, 0, 10)
		E21F A 0 A_SetAngle(Angle+4)
		E21F A 0 A_TakeInventory ("FA21Burst", 1)
		E21F A 1 bright offset(2,33)
		E21F A 1 bright offset(3,36)
		E21F A 1 bright offset(2,34)
		E21F A 1 bright offset(1,32)
		E21F A 30
		goto Reload
	Reload:
		E21F A 0 A_JumpIfInventory ("FA21CalAmmo", 3, 2)
		E21F A 5 A_CheckReload
		goto Ready
		E21F A 10
		E21F A 0 A_JumpIfInventory("FA21Burst",1,3)
		E21F A 0 A_TakeInventory ("FA21CalAmmo", 4)
		E21F A 0 A_GiveInventory ("FA21Burst", 4)
		goto Ready
		E21F A 0 A_TakeInventory("FA21CalAmmo",3)
		E21F A 0 A_GiveInventory("FA21Burst",3)
		goto Ready
	Flash:
		E21F M 2 Bright A_Light1
		E21F N 2 Bright A_Light2
		E21F M 1 Bright A_Light0
		stop
	Spawn:
		E21F X -1
		stop
	}
}

actor CombustionAutorifle : CombustionAutorifleWeak {
	obituary "%o was set ablaze by %k's Combustion Autorifle."
	weapon.ammotype "FA21Burst6"
	weapon.ammouse 1
	Dropitem "CombustionAutorifleWeak"
	weapon.ammogive 3
	states {
	Ready:
		E21F A 0 A_TakeInventory("CombustionAutorifleWeak") //[Bloax] Well, why would you want this?
		goto Ready2
	Ready2:
		E21F A 4 A_WeaponReady
		E21F A 0 A_JumpIfInventory("FA21Burst6",0,2)
		E21F A 0 A_JumpIfInventory("FA21CalAmmo",1,2)
		E21F A 0
		loop
		E21F A 0 A_TakeInventory("FA21CalAmmo",1)
		E21F A 0 A_GiveInventory("FA21Burst6",1)
		loop
	Reload:
		E21F A 0 A_JumpIfInventory ("FA21CalAmmo", 6, 2)
		E21F A 5 A_CheckReload
		goto Ready
		E21F A 11
		E21F A 0 A_TakeInventory ("FA21CalAmmo", 6)
		E21F A 0 A_GiveInventory ("FA21Burst6", 6)
		goto Ready
	Fire:
		E21F A 0 A_JumpIfInventory ("IsInSpawnRoom", 1, "Ready")
		E21F A 0 A_JumpIfInventory ("InMenu", 1, "Ready")
		E21F A 0 A_JumpIfNoAmmo ("Reload")
		E21F A 0 A_GunFlash
		E21F A 0 A_PlaySound("toxin/fire")
		E21F A 0 bright A_FireCustomMissile ("CombustionRound", 0, 1, 10)
		E21F A 1 bright offset(2,33)
		E21F A 1 bright offset(3,36)
		E21F A 1 bright offset(2,34)
		E21F A 1 bright offset(1,32)
		E21F A 2 A_JumpIfNoAmmo ("Reload")
		E21F A 2 A_ReFire
		goto Ready
	Hold:
		E21F A 0 A_JumpIfInventory ("IsInSpawnRoom", 1, "Ready")
		E21F A 0 A_JumpIfInventory ("InMenu", 1, "Ready")
		E21F A 0 A_JumpIfNoAmmo ("Reload")
		E21F A 0 A_GunFlash
		E21F A 0 A_PlaySound("toxin/fire")
		E21F A 0 bright A_FireCustomMissile ("CombustionRound", (2+random(-3,0))*0.5, 1, 10)
		Goto Fire+6 //Skipping everything pre-and-including-firing.
	AltFire:
		E21F A 1
		E21F A 0 A_JumpIfInventory ("IsInSpawnRoom", 1, "Ready")
		E21F A 0 A_JumpIfInventory ("InMenu", 1, "Ready")
		E21F A 4 A_JumpIfInventory("CombustionCooldown",1,"Ready")
		E21F A 0 A_JumpIfInventory ("FA21Burst6", 1, "AltFireSound")
		goto Ready
	AltFireSound:
		E21F A 0 A_GiveInventory("CombustionCooldown",1)
		E21F A 1 A_PlaySound("toxin/fire",CHAN_AUTO)
		E21F A 0 A_GunFlash
		E21F A 0 A_PlaySound("toxin/fire",CHAN_AUTO)
		E21F A 0 A_PlaySound("toxin/fire",CHAN_AUTO)
	AltFireLoop:
		E21F A 0 A_SetAngle(Angle+0.5)
		E21F A 0 A_FireCustomMissile ("CombustionRoundWeak", 0, 0, 10)
		E21F A 0 A_SetAngle(Angle-0.5)
		E21F A 0 A_TakeInventory ("FA21Burst6", 1)
		E21F A 0 A_JumpIfInventory ("FA21Burst6", 1, 1)
		goto AltFireLoop+34
		E21F A 0 A_SetAngle(Angle-0.5)
		E21F A 0 A_FireCustomMissile ("CombustionRoundWeak", 0, 0, 10)
		E21F A 0 A_SetAngle(Angle+0.5)
		E21F A 0 A_TakeInventory ("FA21Burst6", 1)
		E21F A 0 A_JumpIfInventory ("FA21Burst6", 1, 1)
		goto AltFireLoop+34
		E21F A 0 A_SetAngle(Angle+3)
		E21F A 0 A_FireCustomMissile ("CombustionRoundWeak", 0, 0, 10)
		E21F A 0 A_SetAngle(Angle-3)
		E21F A 0 A_TakeInventory ("FA21Burst6", 1)
		E21F A 0 A_JumpIfInventory ("FA21Burst6", 1, 1)
		goto AltFireLoop+34
		E21F A 0 A_SetAngle(Angle+5)
		E21F A 0 A_FireCustomMissile ("CombustionRoundWeak", 0, 0, 10)
		E21F A 0 A_SetAngle(Angle-5)
		E21F A 0 A_TakeInventory ("FA21Burst6", 1)
		E21F A 0 A_JumpIfInventory ("FA21Burst6", 1, 1)
		goto AltFireLoop+34
		E21F A 0 A_SetAngle(Angle-3)
		E21F A 0 A_FireCustomMissile ("CombustionRoundWeak", 0, 0, 10)
		E21F A 0 A_SetAngle(Angle+3)
		E21F A 0 A_TakeInventory ("FA21Burst6", 1)
		E21F A 0 A_JumpIfInventory ("FA21Burst6", 1, 1)
		goto AltFireLoop+34
		E21F A 0 A_SetAngle(Angle-5)
		E21F A 0 A_FireCustomMissile ("CombustionRoundWeak", 0, 0, 10)
		E21F A 0 A_SetAngle(Angle+5)
		E21F A 0 A_TakeInventory ("FA21Burst6", 1)
		E21F A 0 A_JumpIfInventory ("FA21Burst6", 1, 1)
		E21F A 1 bright offset(2,33)
		E21F A 1 bright offset(3,36)
		E21F A 1 bright offset(2,34)
		E21F A 1 bright offset(1,32)
		E21F A 30
		goto Reload
	Spawn:
		TNT1 A 0
		TNT1 A 0 A_SpawnItemEx ("TiberiumAutorifleWeak")
		stop
	}
}

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

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

actor CombustionRound : FastProjectile {
	PROJECTILE
	-RANDOMIZE
	radius 10
	height 6
	speed 70
	damage (8)
	damagetype "Rifle"
	renderstyle Normal
	alpha 1
	scale 0.32
	deathsound "toxin/explode"
	states {
	Spawn:
		E21Y A -1 bright
		stop
	Death:
		TNT1 A 0
		TNT1 A 0 A_SpawnItemEx("CombustionBoom",-1)
		TNT1 A 5 A_SpawnItemEx ("ExplosionSmall")
		TNT1 A 0 A_SpawnItemEx("FlameDecay", random(-16,16), random(-16,16), 4, 0, 0, 0, 0, 0, 140)
		stop
	}
}

actor CombustionRoundWeak : CombustionRound { speed 62 damage (3)
	states {
	Death:
		TNT1 A 0
		TNT1 A 0 A_SpawnItemEx("CombustionBoomWeak",-1)
		goto Super::Death+2
	}
}

actor CombustionBoom {
	Radius 1
	Height 1
	DamageType "Fire"
	states {
	Spawn:
		TNT1 A 0
		TNT1 A 1 A_Explode(13,96,1)
		stop
	}
}

actor CombustionBoomWeak : CombustionBoom { 
	states {
	Spawn:
		TNT1 A 0
		TNT1 A 1 A_Explode(9,96,1)
		stop
	}
}

actor CombustionCooldown : Cooldown { Powerup.Duration 90 }