// COMBUSTION AUTORIFLE
actor CombustionAutorifleWeak : AOWWeapon 21088 {
    Weapon.BobSpeed 1.75
    Weapon.BobRangeX 0.2
    Weapon.BobRangeY 0.4
    Weapon.BobStyle Alpha
	+AMMO_OPTIONAL
	+ALT_AMMO_OPTIONAL
	Obituary "$OB_COMBAUTORIFLE"
	Inventory.PickupMessage "You got the Combustion Autorifle!"
	Weapon.SelectionOrder 13
	Weapon.KickBack 100
	Weapon.AmmoType "FA21Burst"
	Weapon.AmmoUse 1
	Weapon.AmmoGive 4
	Weapon.AmmoType2 "FA21CalAmmo"
	Weapon.AmmoUse2 1
	Weapon.AmmoGive2 20
	Weapon.UpSound "weapons/up/combrifle"
	Weapon.PreferredSkin "MarineMachineGun"
    Tag "Combustion Autorifle Weak"
	states {
    Select:
		E21F A 1 offset (-90,100)
		E21F A 1 offset (-80,89)
		E21F A 1 offset (-70,79)
		E21F A 1 offset (-60,70)
		E21F A 1 offset (-50,62)
		E21F A 1 offset (-40,55)
		E21F A 1 offset (-30,49)
		E21F A 1 offset (-20,44)
		E21F A 1 offset (-15,40)
		E21F A 1 offset (-10,37)
		E21F A 1 offset (-5,34)
		E21F A 1 offset (0,0)
		TNT1 A 0 A_TakeInventory("SelectAnimation",1)
		goto ready
	Deselect:
	    TNT1 A 0 A_TakeInventory("ActionFragGrenade",1)	
        TNT1 A 0 A_TakeInventory("ActionFlashbang",1)
        TNT1 A 0 A_TakeInventory("ActionRemoteC4",1)	
        TNT1 A 0 A_TakeInventory("ActionMeleeAttack",1)
		TNT1 A 0 A_TakeInventory("ActionReload",1)	
		E21F A 1 offset (-4,34)
		E21F A 1 offset (-8,40)
		E21F A 1 offset (-16,49)
		E21F A 1 offset (-24,62)
		E21F A 1 offset (-32,79)
		E21F A 1 offset (-40,100)
		TNT1 A 0 offset (-1, 33)
		TNT1 A 0 A_Lower
		wait
	Ready:
	    TNT1 A 0 A_JumpIfInventory("SelectAnimation",1,"Select")
		TNT1 A 0 A_JumpIfInventory("ActionFragGrenade",1,"UseFragGrenade")
		TNT1 A 0 A_JumpIfInventory("ActionFlashbang",1,"UseFlashbang")
		TNT1 A 0 A_JumpIfInventory("ActionRemoteC4",1,"UseRemoteC4")
		TNT1 A 0 A_JumpIfInventory("ActionMeleeAttack",1,"UseMeleeAttack")
		TNT1 A 0 A_TakeInventory("ActionReload",1)
		E21F A 4 A_WeaponReady
		TNT1 A 0 A_JumpIfInventory("ActionFragGrenade",1,"UseFragGrenade")
		TNT1 A 0 A_JumpIfInventory("ActionFlashbang",1,"UseFlashbang")
		TNT1 A 0 A_JumpIfInventory("ActionRemoteC4",1,"UseRemoteC4")
		TNT1 A 0 A_JumpIfInventory("ActionMeleeAttack",1,"UseMeleeAttack")
		TNT1 A 0 A_TakeInventory("ActionReload",1)
		E21F A 4 A_WeaponReady
		E21F A 0 A_JumpIfInventory("FA21Burst",4,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
	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_SetAngle(Angle+1.25)
		E21F A 0 A_FireCustomMissile ("CombustionRoundWeak", 0, 0, 10)
		E21F A 0 A_SetAngle(Angle-1.25)
		E21F A 0 A_TakeInventory ("FA21Burst", 1)
		E21F A 0 A_JumpIfInventory ("FA21Burst", 1, 1)
		goto AltFireLoop+19
		E21F A 0 A_SetAngle(Angle+3.75)
		E21F A 0 A_FireCustomMissile ("CombustionRoundWeak", 0, 0, 10)
		E21F A 0 A_SetAngle(Angle-3.75)
		E21F A 0 A_TakeInventory ("FA21Burst", 1)
		E21F A 0 A_JumpIfInventory ("FA21Burst", 1, 1)
		goto AltFireLoop+19
		E21F A 0 A_SetAngle(Angle-1.25)
		E21F A 0 A_FireCustomMissile ("CombustionRoundWeak", 0, 0, 10)
		E21F A 0 A_SetAngle(Angle+1.25)
		E21F A 0 A_TakeInventory ("FA21Burst", 1)
		E21F A 0 A_JumpIfInventory ("FA21Burst", 1, 1)
		goto AltFireLoop+19
		E21F A 0 A_SetAngle(Angle-3.75)
		E21F A 0 A_FireCustomMissile ("CombustionRoundWeak", 0, 0, 10)
		E21F A 0 A_SetAngle(Angle+3.75)
		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)
		TNT1 A 0 A_WeaponReady(WRF_NOBOB | WRF_NOFIRE)
		E21F AA 5 A_JumpIfInventory("ActionMeleeAttack",1,"UseMeleeAttack")
		TNT1 A 0 A_WeaponReady(WRF_NOBOB | WRF_NOFIRE)
		E21F AA 5 A_JumpIfInventory("ActionMeleeAttack",1,"UseMeleeAttack")
		TNT1 A 0 A_WeaponReady(WRF_NOBOB | WRF_NOFIRE)
		E21F AA 5 A_JumpIfInventory("ActionMeleeAttack",1,"UseMeleeAttack")
		goto Reload
	Reload:
		E21F A 0 A_JumpIfInventory ("FA21CalAmmo", 4, 2)
		E21F A 5 A_CheckReload
		goto Ready
		E21F A 10 A_WeaponReady(WRF_NOBOB | WRF_NOFIRE)
		E21F A 0 A_TakeInventory ("FA21CalAmmo", 4)
		E21F A 0 A_GiveInventory ("FA21Burst", 4)
		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 "$OB_COMBAUTORIFLE"
	weapon.ammotype "FA21Burst6"
	weapon.ammouse 1
	Dropitem "CombustionAutorifleWeak"
	weapon.ammogive 3
	Tag "Combustion Autorifle"
	states {
    Select:
		E21F A 1 offset (-90,100)
		E21F A 1 offset (-80,89)
		E21F A 1 offset (-70,79)
		E21F A 1 offset (-60,70)
		E21F A 1 offset (-50,62)
		E21F A 1 offset (-40,55)
		E21F A 1 offset (-30,49)
		E21F A 1 offset (-20,44)
		E21F A 1 offset (-15,40)
		E21F A 1 offset (-10,37)
		E21F A 1 offset (-5,34)
		E21F A 1 offset (0,0)
		TNT1 A 0 A_TakeInventory("SelectAnimation",1)
		goto ready
	Ready:
		E21F A 0 A_TakeInventory("CombustionAutorifleWeak") //[Bloax] Well, why would you want this?
	Ready2:
	    TNT1 A 0 A_JumpIfInventory("SelectAnimation",1,"Select")
	    TNT1 A 0 A_JumpIfInventory("ActionFragGrenade",1,"UseFragGrenade")
		TNT1 A 0 A_JumpIfInventory("ActionFlashbang",1,"UseFlashbang")
		TNT1 A 0 A_JumpIfInventory("ActionRemoteC4",1,"UseRemoteC4")
		TNT1 A 0 A_JumpIfInventory("ActionMeleeAttack",1,"UseMeleeAttack")
		E21F A 4 A_WeaponReady
		E21F A 0 A_JumpIfInventory("FA21Burst6",6,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 A_WeaponReady(WRF_NOBOB | WRF_NOFIRE)
		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+1.25)
		E21F A 0 A_FireCustomMissile ("CombustionRoundWeak", 0, 0, 10)
		E21F A 0 A_SetAngle(Angle-1.25)
		E21F A 0 A_TakeInventory ("FA21Burst6", 1)
		E21F A 0 A_JumpIfInventory ("FA21Burst6", 1, 1)
		goto AltFireLoop+29
		E21F A 0 A_SetAngle(Angle-1.25)
		E21F A 0 A_FireCustomMissile ("CombustionRoundWeak", 0, 0, 10)
		E21F A 0 A_SetAngle(Angle+1.25)
		E21F A 0 A_TakeInventory ("FA21Burst6", 1)
		E21F A 0 A_JumpIfInventory ("FA21Burst6", 1, 1)
		goto AltFireLoop+29
		E21F A 0 A_SetAngle(Angle+3.75)
		E21F A 0 A_FireCustomMissile ("CombustionRoundWeak", 0, 0, 10)
		E21F A 0 A_SetAngle(Angle-3.75)
		E21F A 0 A_TakeInventory ("FA21Burst6", 1)
		E21F A 0 A_JumpIfInventory ("FA21Burst6", 1, 1)
		goto AltFireLoop+29
		E21F A 0 A_SetAngle(Angle+6.25)
		E21F A 0 A_FireCustomMissile ("CombustionRoundWeak", 0, 0, 10)
		E21F A 0 A_SetAngle(Angle-6.25)
		E21F A 0 A_TakeInventory ("FA21Burst6", 1)
		E21F A 0 A_JumpIfInventory ("FA21Burst6", 1, 1)
		goto AltFireLoop+29
		E21F A 0 A_SetAngle(Angle-3.75)
		E21F A 0 A_FireCustomMissile ("CombustionRoundWeak", 0, 0, 10)
		E21F A 0 A_SetAngle(Angle+3.75)
		E21F A 0 A_TakeInventory ("FA21Burst6", 1)
		E21F A 0 A_JumpIfInventory ("FA21Burst6", 1, 1)
		goto AltFireLoop+29
		E21F A 0 A_SetAngle(Angle-6.25)
		E21F A 0 A_FireCustomMissile ("CombustionRoundWeak", 0, 0, 10)
		E21F A 0 A_SetAngle(Angle+6.25)
		E21F A 0 A_TakeInventory ("FA21Burst6", 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)
		TNT1 A 0 A_WeaponReady(WRF_NOBOB | WRF_NOFIRE)
		E21F AA 5 A_JumpIfInventory("ActionMeleeAttack",1,"UseMeleeAttack")
		TNT1 A 0 A_WeaponReady(WRF_NOBOB | WRF_NOFIRE)
		E21F AA 5 A_JumpIfInventory("ActionMeleeAttack",1,"UseMeleeAttack")
		TNT1 A 0 A_WeaponReady(WRF_NOBOB | WRF_NOFIRE)
		E21F AA 5 A_JumpIfInventory("ActionMeleeAttack",1,"UseMeleeAttack")
		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 {
	Obituary "$OB_COMBAUTORIFLE"
	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 
{
	Obituary "$OB_COMBAUTORIFLEEXPLOSION"
	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 }