/*

==DEFIANCE MACHINEGUN==
A high performance compact machine gun, the Defiance earned
its name with its forward ejection system for spent casings.
Further adding to this, as the weapon builds heat, the heat
is focused into the casings themselves, casting out hot metal
into targets and onto the ground, creating no-pass zones with
extended fire.
*/

actor BMmachinegun : weapon
{
	weapon.slotnumber 4
	Weapon.AmmoUse 1
	weapon.bobstyle alpha
	weapon.bobrangex 0.2
	weapon.bobrangey 0.2
	weapon.bobspeed 2
	Weapon.AmmoType "Clip"
	Inventory.RestrictedTo "Blastmaster"
	Inventory.PickupMessage "You got the Defiance Machinegun!"
	+NOAUTOAIM
	Tag "Defiance Machinegun"
	states
	{
	Select:
		TNT1 A 0
        TNT1 AAAAAAAAAAAAAAAAAAAA 0 A_Raise
        TNT1 A 1 A_Raise
		goto ready
	Ready:
		BMST A 2
		TNT1 A 0 a_playsound ("BMMG/raise",0)
		BMGI ABCDEF 1
		BMGI GHIJKLMNOPQRSTUVW 1 a_weaponready (WRF_NOBOB)
		goto realready
	Deselect:
		TNT1 A 0
		TNT1 A 0 a_jumpifhealthlower (1, "deadlower")
		TNT1 A 0 a_takeinventory ("secretaction", 99)
		TNT1 A 0
		TNT1 A 0 a_playsound ("BMMG/lower",0)
		BMGI WUTQPOMIHDCBA 1
		BMST A 5
	holster:
        TNT1 AAAAAAAAAAAAAAAAAAAA 0 A_lower
        TNT1 A 1 A_lower
		loop
	deadlower:
		TNT1 A 0
		TNT1 A 0
		TNT1 AAAAAAAAAAAAA 0 a_lower
		TNT1 A 1 a_lower
		wait	
	Realready:
		TNT1 A 0
		TNT1 A 0 a_jumpifinventory ("BMoverheat",1,"lockdown")
		BMGI W 1 a_weaponready
		TNT1 A 0 a_jumpifinventory ("BMoverheat",1,"lockdown")
		loop
	lockdown:
		TNT1 A 0
		BMGI W 3 a_weaponready (WRF_NOPRIMARY)
		TNT1 A 0 a_firecustommissile ("smashersmokespawner",0,0,0,0,0,0)
		BMGI W 3 a_weaponready (WRF_NOPRIMARY)
		TNT1 A 0 a_jumpifinventory ("BMoverheat",1,"lockdown")
		goto realready
		
	Fire:
		TNT1 A 0
		TNT1 A 0 a_jumpifinventory ("BMoverheat",1,"lockdown")
		TNT1 A 0 a_jumpifinventory ("BMheat",156,"MoltenCasings")
		TNT1 A 0 a_jumpifinventory ("BMheat",91,"HotCasings")
		TNT1 A 0 a_gunflash
		TNT1 A 0 A_Quake(1, 2, 0, 32)
		TNT1 A 0 A_giveinventory ("BlastMasterFired",1)
		TNT1 A 0 a_playsound ("Defiance/Lv1Shot",CHAN_WEAPON)
		TNT1 A 0 a_giveinventory ("BMheat",random (2,3))
		BMMG A 1 bright A_FireBullets (3.5, 3.0, 1, 5, "BlueBMPuff") 
		BMMG B 2 
		BMMG C 1
		TNT1 A 0 A_FireCustomMissile("DefianceCasing",random(-5,5),0,0,3,0,random(-2,2))
		TNT1 A 0 a_refire
		goto realready
	HotCasings:
		TNT1 A 0 a_gunflash
		TNT1 A 0 A_Quake(1, 2, 0, 32)
		TNT1 A 0 a_playsound ("Blastmaster/Lightheat",0)
		TNT1 A 0 a_playsound ("Defiance/Lv2Shot",CHAN_WEAPON)
		TNT1 A 0 A_giveinventory ("BlastMasterFired",1)
		TNT1 A 0 a_giveinventory ("BMheat",random (0,2))
		BMM2 A 1 bright A_FireBullets (3.5, 3.0, 1, 5, "YellowBMPuff") 
		BMMG B 2
		BMMG C 1
		TNT1 A 0 A_FireCustomMissile("HotDefianceCasing",random(-5,5),0,0,3,0,random(-2,2))
		TNT1 A 0 a_refire
		goto realready
	MoltenCasings:
		TNT1 A 0 a_gunflash
		TNT1 A 0 A_Quake(1, 2, 0, 32)
		TNT1 A 0 a_playsound ("Blastmaster/HighHeat",0,0.50)
		TNT1 A 0 a_playsound ("Defiance/Lv3Shot",CHAN_WEAPON)
		TNT1 A 0 A_giveinventory ("BlastMasterFired",1)
		TNT1 A 0 a_playsound ("BMMG/fire",CHAN_WEAPON)
		TNT1 A 0 a_giveinventory ("BMheat",random(0,1))
		BMM3 A 1 bright A_FireBullets (3.5, 3.0, 1, 5, "RedBMPuff") 
		BMMG B 2 
		TNT1 A 0 A_FireCustomMissile("SlagDefianceCasing",random(-5,5),0,0,3,0,random(-2,2))
		BMMG C 1
		TNT1 A 0 a_refire
		goto realready


	//VENT ATTACKS------------------------------------------------------------------
	Altfire:
		TNT1 A 0
		BMGI W 2 A_weaponready (WRF_NOFIRE)
		TNT1 A 0 A_jumpifinventory ("BMoverheat",1,"OverHeatFire")
		TNT1 A 0 A_jumpifinventory ("BMheat",156,"RedGrenade")
		TNT1 A 0 A_jumpifinventory ("BMheat",91,"YellowMachineGun")
		TNT1 A 0 A_jumpifinventory ("BMheat",1,"BlueFire")
		goto realready

	//Blue Fire (Tier one)----------------------------------------------------------
	BlueFire:
		TNT1 A 0 A_playsound ("BlastMaster/BlueFireStart",0)
		TNT1 A 0 A_playsound ("BlastMaster/BlueFireLoop",6,1,1)
	BlueFireLoop:
		TNT1 A 0 A_gunflash
		TNT1 A 0 A_takeinventory ("BMheat",2)
		TNT1 A 0 A_giveinventory ("BlastMasterFired",1)
		TNT1 A 0 A_giveinventory ("BlastMasterVented",1)
		TNT1 A 0 A_recoil (0.10)
		TNT1 A 0 Bright A_FireCustomMissile ("BlueVentFire",Frandom(-5, 5), 0, random(-1,1), random(-2,-1), 0, Frandom(-2, 2))
		BMGI W 0 A_jumpifinventory ("SuperVenter",1,"SuperBlueFire")
		BMV5 AB 1 bright
		TNT1 A 0 A_jumpifinventory ("BMHeat",1,"BlueFireLoop")
		TNT1 A 0 A_playsound ("BlastMaster/BlueFireEnd",6)
		goto VentFinish
	SuperBlueFire:
		TNT1 A 0
		TNT1 A 0 A_FireCustomMissile ("BlueVentEmber1",Frandom(-5, 5), 0, random(-4,4), random(1,4), 0, Frandom(-5, 5))
		TNT1 A 0 A_FireCustomMissile ("BlueVentEmber2",Frandom(-5, 5), 0, random(-4,4), random(1,4), 0, Frandom(-5, 5))
		TNT1 A 0 Bright A_FireCustomMissile ("BlueVentFire",Frandom(-9, 9), 0, random(-3,3), random(-2,-1), 0, Frandom(-4, 4))
		TNT1 A 0 A_playsound ("BlastMaster/PowerFire",0)
		BMV5 AB 1 bright
		TNT1 A 0 A_jumpifinventory ("BMHeat",1,"BlueFireLoop")
		TNT1 A 0 A_playsound ("BlastMaster/BlueFireEnd",6)
		goto VentFinish

	//Yellow Machine Gun (Tier two)--------------------------------------------------
	YellowMachineGun:
		TNT1 A 0 A_gunflash
		TNT1 A 0 A_takeinventory ("BMheat",4)
		TNT1 A 0 A_giveinventory ("BlastMasterFired",1)
		TNT1 A 0 A_giveinventory ("BlastMasterVented",1)
		TNT1 A 0 A_playsound ("BlastMaster/YellowShot",6)
		TNT1 A 0 A_Quake(1, 2, 0, 32)
		BMGI W 0 A_jumpifinventory ("SuperVenter",1,"YellowHitScan")
		ESHG B 0 Bright A_FireCustomMissile("YellowVentBullet",Frandom(-2, 2), 0, 0, random(-1,1), 0, Frandom(-2, 2))
		BMV5 CD 1 bright
		BMGI W 1
		TNT1 A 0 A_jumpifinventory ("BMHeat",1,"YellowMachineGun")
		goto VentFinish
	YellowHitScan:
		ESHG B 0 Bright A_FireBullets (3.5, 2.0, -1, 9, "YellowCAPuff",FBF_NORANDOM) 
		BMV5 C 1 bright
		TNT1 A 0 A_playsound ("BlastMaster/PowerGun",6)
		BMV5 D 1 bright
		BMGI W 1
		TNT1 A 0 A_jumpifinventory ("BMHeat",1,"YellowMachineGun")
		goto VentFinish

	//Red Grenade (Tier three)--------------------------------------------------------
	RedGrenade:
		TNT1 A 0 A_gunflash
		TNT1 A 0 A_playsound ("BlastMaster/RedGrenade",6)		
		TNT1 A 0 A_takeinventory ("BMheat",999)
		TNT1 A 0 A_giveinventory ("BlastMasterVented",1)
		TNT1 A 0 A_giveinventory ("BlastMasterFired",1)
		TNT1 A 0 A_Quake(2, 6, 0, 32)
		BMGI W 0 A_jumpifinventory ("SuperVenter",1,"SuperGrenade")
		ESHG B 0 Bright A_FireCustomMissile("RedGrenade")
		BMV5 EFGHHIIJJKKLL 1 bright
		BMGI W 3
		goto VentFinish
	SuperGrenade:
		ESHG B 0 Bright A_FireCustomMissile("SuperRedGrenade")
		BMV5 EFGHH 1
		TNT1 A 0 a_playsound ("BlastMaster/PowerGrenade",0)		
		BMV5 IIJJKKLL 1 bright
		BMGI W 3
		goto VentFinish

		
	
	VentFinish:
		BMGI W 3
		BMP5 ABCC 2
		TNT1 A 0 A_takeinventory ("BlastMasterFired",99)
		TNT1 A 0 A_takeinventory ("BlastMasterVented",99)
		TNT1 A 0 A_playsound ("BlastMaster/PumpDown",0)
		BMP5 DEFFG 2 A_FireCustomMissile ("BlastMasterSmoker",0,0,6,6)
		TNT1 A 0 A_playsound ("BlastMaster/PumpUp",0)
		BMP5 CBA 2
		BMGI W 1
		goto realready

	//Super Flamer (Overheat)--------------------------------------------------------
	OverHeatFire:
		TNT1 A 0 A_takeinventory ("BlastMasterFired",99)
		TNT1 A 0 A_takeinventory ("BlastMasterVented",99)
		TNT1 A 0 A_playsound ("BlastMaster/BlueFireStart",0)
		TNT1 A 0 A_playsound ("BlastMaster/RedFireStart",0)
		TNT1 A 0 A_playsound ("BlastMaster/RedFireLoop",6,1,1)
	OverHeatFireLoop:
		TNT1 A 0 A_gunflash
		TNT1 A 0 Bright A_FireCustomMissile ("RedVentFire",Frandom(-5, 5), 0, random(-1,1), random(-2,-1), 0, Frandom(-2, 2))
		TNT1 A 0 A_takeinventory ("BMOverHeat",1)
		TNT1 A 0 A_recoil (0.15)
		BMGI W 0 A_jumpifinventory ("SuperVenter",1,"SuperRedFire")
		BMV5 MN 1 bright
		TNT1 A 0 A_refire ("OverHeatCheck")
		TNT1 A 0 A_playsound ("BlastMaster/RedFireEnd",6)	
		BMGI W 0 A_jumpifinventory ("SuperVenter",1,"RedFinisherCheck")
		BMGI W 6 
		BMGI W 6 A_weaponready (WRF_NOPRIMARY)
		goto LockDown	
	OverHeatCheck:
		TNT1 A 0 A_jumpifinventory ("BMOverHeat",1,"OverHeatFireLoop")
		TNT1 A 0 A_playsound ("BlastMaster/RedFireEnd",6)	
		goto VentFinish

	SuperRedFire:
		TNT1 A 0
		TNT1 A 0 A_FireCustomMissile ("RedVentEmber1",Frandom(-5, 5), 0, random(-4,4), random(1,4), 0, Frandom(-5, 5))
		TNT1 A 0 A_FireCustomMissile ("RedVentEmber2",Frandom(-5, 5), 0, random(-4,4), random(1,4), 0, Frandom(-5, 5))
		TNT1 A 0 Bright A_FireCustomMissile ("RedVentFire",Frandom(-9, 9), 0, random(-3,3), random(-2,-1), 0, Frandom(-4, 4))
		TNT1 A 0 A_playsound ("BlastMaster/PowerFire",0)
		BMV5 MN 1 bright
		TNT1 A 0 A_refire ("OverHeatCheck")
		TNT1 A 0 A_playsound ("BlastMaster/RedFireEnd",6)
		goto RedFinisherCheck
	RedFinisherCheck:
		TNT1 A 0 A_jumpifinventory ("BMOverHeat",60,"SuperFinisher")
		goto LockDown
	SuperFinisher:
		TNT1 A 0 A_gunflash
		TNT1 A 0 A_playsound ("BlastMaster/RedGrenade",6)		
		TNT1 A 0 A_takeinventory ("BMOverHeat",60)
		BMGI W 0 A_jumpifinventory ("SuperVenter",1,"SuperGrenade")
		ESHG B 0 Bright A_FireCustomMissile("RedGrenade")
		BMV5 EFGHHIIJJKKLL 1 bright
		BMGI W 6
		goto LockDown

	Flash:
		TNT1 A 2 Bright A_Light(3)
		TNT1 A 2 Bright A_Light2
		TNT1 A 2 Bright A_Light1
		Goto LightDone
		
	}
}