ACTOR Minigun : Weapon replaces Chaingun
{
	Weapon.SelectionOrder 400
	Weapon.SlotNumber 4
	Weapon.AmmoType "Nato"
	Weapon.AmmoGive 80
	Weapon.AmmoUse 1
	Weapon.AmmoType2 "NatoBelt"
	Weapon.AmmoUse2 1
	Inventory.PickupMessage "You got the Vulcan Rotary Cannon!"
	Inventory.PickupSound "weapons/fist/swing"
	Obituary "%o was torn to pieces by %k's minigun."
	+WEAPON.NOALERT
	+WEAPON.AMMO_CHECKBOTH
	Tag "Rotary Cannon"
	Weapon.BobStyle "Smooth"
	Weapon.BobSpeed 2.0
	Weapon.BobRangeX 0.30
	Weapon.BobRangeY 0.40
	Scale 1.1
	States
	{
	Ready:
		TNT1 A 0 A_PlaySound ("weapon/minigun")
		VLCN A 1 Offset(66,100)
		VLCN A 1 Offset(65,95)
		VLCN A 1 Offset(64,90)
		VLCN A 1 Offset(55,85)
		VLCN A 1 Offset(50,80)
		VLCN A 1 Offset(45,75)
		VLCN A 1 Offset(40,70)
		VLCN A 1 Offset(35,65)
		VLCN A 1 Offset(30,60)
		VLCN A 1 Offset(25,55)
		VLCN A 1 Offset(20,50)
		VLCN A 1 Offset(15,45)
		VLCN A 1 Offset(10,40)
		VLCN A 1 Offset(5,35)
		VLCN A 1 Offset(0,32)
	ReadyII:
		TNT1 A 0 A_JumpIfInventory("NatoBelt",0,2)
		TNT1 A 0 A_JumpIfInventory("Nato",1,2)
		VLCN A 1 A_WeaponReady
		Loop
		VLCN A 1 A_WeaponReady(WRF_ALLOWRELOAD)
		Loop
	Deselect:
		TNT1 A 0 A_ClearReFire
		VLCN A 1 Offset(10,40)
		VLCN A 1 Offset(15,55)
		VLCN A 1 Offset(20,75)
		VLCN A 1 Offset(25,100)
		VLCN A 1 Offset(30,130)
		VLCN A 0 A_Lower
		Wait
	Select:
		VLCN A 0 A_Raise
		Loop
	Fire:
		TNT1 A 0 A_JumpIfInventory("NatoBelt",1,1)
		Goto ReloadCheck
		TNT1 A 0 A_TakeInventory("FiringPlasma",1)
		TNT1 A 0 A_PlaySound ("weapons/chaingun/start")
		VLCN B 2
		VLCN CD 1
		VLCN ABCD 1
		TNT1 A 0 A_Refire
		VLCN ABCD 1
		VLCN ABC 2 A_WeaponReady
		VLCN DABCDAB 3 A_WeaponReady
		VLCN CD 4 A_WeaponReady
		Goto ReadyII
	Hold:
		TNT1 A 0 A_JumpIfInventory("NatoBelt",1,1)
		Goto ReloadCheck
		TNT1 A 0 A_JumpIfInventory("FiringTracer",1,"Hold2")
		TNT1 A 0 A_AlertMonsters
		TNT1 A 0 A_SetPitch(pitch - 0.1)
		TNT1 A 0 A_PlaySound("weapons/chaingun/spin",7)
		TNT1 A 0 A_TakeInventory("NatoBelt",1,TIF_NOTAKEINFINITE)
		VLCS A 1 A_FireBullets(3, 2, -1, 5, "AltPuff3", 0)
		VLCS B 1 A_Firecustommissile("ChaingunCasingSpawner",0,0,-12,-18)
		TNT1 A 0 A_ZoomFactor(0.996)
		TNT1 A 0 A_SetPitch(pitch + 0.1)
		VLCS C 1 A_FireBullets(3, 2, -1, 2, "AltPuff3", 0)
		TNT1 A 0 A_Firecustommissile("ChaingunCasingSpawner",0,0,-12,-18)
		TNT1 A 0 A_ZoomFactor(0.999)
		TNT1 A 0 A_SetPitch(pitch - 0.2)
		TNT1 A 0 A_GunFlash
		TNT1 A 0 A_TakeInventory("NatoBelt",1,TIF_NOTAKEINFINITE)
		VLCS D 1 A_SetPitch(pitch + 0.2)
		TNT1 A 0 A_TakeInventory("NatoBelt",1,TIF_NOTAKEINFINITE)
		VLCS A 1 Bright A_FireBullets(3, 2, -1, 2, "AltPuff3", 0)
		TNT1 A 0 A_Firecustommissile("ChaingunCasingSpawner",0,0,-12,-18)
		TNT1 A 0 A_ZoomFactor(0.996)
		VLCS B 1 A_FireBullets(2, 2, -1, 10, "AltPuff3", 0)
		TNT1 A 0 A_Firecustommissile("ChaingunCasingSpawner",0,0,-12,-18)
		TNT1 A 0 A_TakeInventory("NatoBelt",1,TIF_NOTAKEINFINITE)
		VLCS C 1 A_FireBullets(3, 2, -1, 2, "AltPuff3", 0)
		TNT1 A 0 A_ZoomFactor(0.998)
		TNT1 AA 0 A_FireCustomMissile("GunSmokeSpawner",0,0,0,0)
		VLCS D 1 A_Firecustommissile("ChaingunCasingSpawner",0,0,-12,-18)
		TNT1 A 0 A_GiveInventory("FiringTracer",1)
		TNT1 A 0 A_ReFire
		TNT1 A 0 A_PlaySound("weapons/chaingun/stop",6)
		TNT1 A 0 A_ZoomFactor(1.0)
		VLCS ABCD 1
		TNT1 AAAA 0 A_FireCustomMissile("GunSmokeSpawner",0,0,0,-4)
		VLCS ABCD 2
		VLCN ABC 2 A_WeaponReady
		TNT1 AA 0 A_FireCustomMissile("GunSmokeSpawner",0,0,0,1)
		VLCN DABCDA 3 A_WeaponReady
		VLCS BCD 2 A_WeaponReady
		Goto ReadyII
	  Hold2:
		TNT1 A 0 A_JumpIfInventory("NatoBelt",1,1)
		Goto ReloadCheck
		TNT1 A 0 A_AlertMonsters
		TNT1 A 0 A_SetPitch(pitch - 0.1)
		TNT1 A 0 A_PlaySound("weapons/chaingun/spin",7)
		TNT1 A 0 A_TakeInventory("NatoBelt",1,TIF_NOTAKEINFINITE)
		VLCS A 1 A_FireBullets(3, 2, -1, 1, "AltPuff3", 0)
		VLCS B 1 A_Firecustommissile("ChaingunCasingSpawner",0,0,-12,-18)
		TNT1 A 0 A_ZoomFactor(0.996)
		TNT1 A 0 A_SetPitch(pitch + 0.1)
		VLCS C 1 A_FireBullets(3, 2, -1, 0, "AltPuff3", 0)
		TNT1 A 0 A_Firecustommissile("ChaingunCasingSpawner",0,0,-12,-18)
		TNT1 A 0 A_ZoomFactor(0.999)
		TNT1 A 0 A_SetPitch(pitch - 0.2)
		TNT1 A 0 A_GunFlash
		TNT1 A 0 A_TakeInventory("NatoBelt",1,TIF_NOTAKEINFINITE)
		VLCS D 1 A_FireCustomMissile("ChaingunTracer",FRandom(-1.0,1.0),0,0,-1,0,FRandom(-1.0,1.0))
		TNT1 A 0 A_SetPitch(pitch + 0.2)
		TNT1 A 0 A_TakeInventory("NatoBelt",1,TIF_NOTAKEINFINITE)
		VLCS A 1 A_FireBullets(3, 2, -1, 1, "AltPuff3", 0)
		TNT1 A 0 A_Firecustommissile("ChaingunCasingSpawner",0,0,-12,-18)
		TNT1 A 0 A_ZoomFactor(0.996)
		VLCS B 1 Bright A_FireBullets(2, 2, -1, 0, "AltPuff3", 0)
		TNT1 A 0 A_Firecustommissile("ChaingunCasingSpawner",0,0,-12,-18)
		TNT1 A 0 A_TakeInventory("NatoBelt",1,TIF_NOTAKEINFINITE)
		VLCS C 1 A_FireBullets(3, 2, -1, 8, "AltPuff3", 0)
		TNT1 A 0 A_ZoomFactor(0.998)
		TNT1 AA 0 A_FireCustomMissile("GunSmokeSpawner",0,0,0,0)
		VLCS D 1 A_Firecustommissile("ChaingunCasingSpawner",0,0,-12,-18)
		TNT1 A 0 A_TakeInventory("FiringTracer",1)
		TNT1 A 0 A_ReFire
		TNT1 A 0 A_PlaySound("weapons/chaingun/stop",6)
		TNT1 A 0 A_ZoomFactor(1.0)
		VLCS ABCD 1
		TNT1 AAAA 0 A_FireCustomMissile("GunSmokeSpawner",0,0,0,-4)
		VLCS ABCD 2
		VLCN ABC 2 A_WeaponReady
		TNT1 AA 0 A_FireCustomMissile("GunSmokeSpawner",0,0,0,1)
		VLCN DABCDA 3 A_WeaponReady
		VLCS BCD 2 A_WeaponReady
		Goto ReadyII
	AltFire:
		TNT1 A 0 A_JumpIfInventory("NatoBelt",1,1)
		Goto ReloadCheck
		TNT1 A 0 A_GiveInventory("FiringPlasma",1)
		TNT1 A 0 A_PlaySound("weapon/minigun",CHAN_AUTO)
		TNT1 A 0 A_PlaySound("weapons/chaingun/start")
		VLCN B 2
		VLCN CD 1
		VLCN ABCDABCDABCDABCD 1
		TNT1 A 0 A_Refire
		TNT1 A 0 A_TakeInventory("FiringPlasma",1)
		TNT1 A 0 A_PlaySound("weapons/chaingun/stop",6)
		VLCN ABCD 1
		VLCN ABCDABC 2 A_WeaponReady
		VLCN DABCDA 3 A_WeaponReady
		TNT1 A 0 A_PlaySound("weapons/chaingun/load",5)
		VLCN DCBADCB 3 A_WeaponReady(WRF_ALLOWRELOAD)
		VLCN A 1 A_WeaponReady
		Goto ReadyII
	AltHold:
		TNT1 A 0 A_JumpIfInventory("NatoBelt",1,1)
		Goto ReloadCheck
		TNT1 A 0 A_AlertMonsters
		TNT1 A 0 A_SetPitch(pitch - 0.1)
		TNT1 A 0 A_PlaySound("weapons/chaingun/spin",7)
		TNT1 A 0 A_PlayWeaponSound("weapons/rotarypulse/fire")
		TNT1 AAA 0 A_TakeInventory("NatoBelt",1,TIF_NOTAKEINFINITE)
		TNT1 AA 0 A_Firecustommissile("ChaingunCasingSpawner",0,0,-12,-18)
		VLCS A 1 A_FireCustomMissile("RotaryPlasma",FRandom(-2.0,2.0),0,-1,0,0,FRandom(-2.0,2.0))
		VLCS B 1 A_ZoomFactor(0.996)
		TNT1 AA 0 A_Firecustommissile("ChaingunCasingSpawner",0,0,-12,-18)
		TNT1 A 0 A_SetPitch(pitch + 0.1)
		VLCS C 1 A_FireCustomMissile("RotaryPlasma",FRandom(-2.0,2.0),0,-2,0,0,FRandom(-1.0,1.0))
		TNT1 A 0 A_ZoomFactor(0.999)
		TNT1 A 0 A_SetPitch(pitch - 0.2)
		TNT1 A 0 A_GunFlash
		TNT1 A 0 A_PlayWeaponSound("weapons/rotarypulse/fire")
		TNT1 A 0 A_TakeInventory("NatoBelt",1,TIF_NOTAKEINFINITE)
		TNT1 AA 0 A_Firecustommissile("ChaingunCasingSpawner",0,0,-12,-18)
		VLCS D 1 A_FireCustomMissile("RotaryPlasma",FRandom(-2.0,2.0),0,-0,0,0,FRandom(-2.0,2.0))
		TNT1 A 0 A_ZoomFactor(0.996)
		TNT1 A 0 A_SetPitch(pitch + 0.2)
		TNT1 A 0 A_TakeInventory("NatoBelt",1,TIF_NOTAKEINFINITE)
		TNT1 AA 0 A_Firecustommissile("ChaingunCasingSpawner",0,0,-12,-18)
		VLCS A 1 Bright A_FireCustomMissile("RotaryPlasma",FRandom(-2.0,2.0),0,-1,0,0,FRandom(-1.0,1.0))
		VLCS B 1 A_ZoomFactor(0.998)
		TNT1 A 0 A_PlayWeaponSound("weapons/rotarypulse/fire")
		TNT1 A 0 A_TakeInventory("NatoBelt",1,TIF_NOTAKEINFINITE)
		TNT1 A 0 A_Firecustommissile("ChaingunCasingSpawner",0,0,-12,-18)
		VLCS C 1 Bright A_FireCustomMissile("RotaryPlasma",FRandom(-2.0,2.0),0,-1,0,0,frandom(-2.0,2.0))
		TNT1 A 0 A_FireCustomMissile("GunSmokeSpawner",0,0,0,0)
		VLCS D 1 
		TNT1 A 0 A_ReFire
		TNT1 A 0 A_TakeInventory("FiringPlasma",1)
		TNT1 A 0 A_PlaySound("weapons/chaingun/stop",6)
		TNT1 A 0 A_ZoomFactor(1.0)
		VLCS ABCD 1
		TNT1 AAAAAA 0 A_FireCustomMissile("GunSmokeSpawner",0,0,0,-4)
		VLCS ABCD 2
		VLCN ABC 2
		TNT1 AAA 0 A_FireCustomMissile("GunSmokeSpawner",0,0,0,1)
		VLCN DABCD 3 A_WeaponReady
		TNT1 A 0 A_PlaySound("weapons/chaingun/load",5)
		VLCN DCBADCB 3 A_WeaponReady
		Goto ReadyII
	Flash:
		CHAF A 1 Bright A_Light2 
		TNT1 A 2 A_Light0
		CHAF B 1 Bright A_Light2
		TNT1 A 1 A_Light1
		TNT1 A 2 A_Light0
		TNT1 A 1 A_Light2
		TNT1 A 2 A_Light0
		Goto LightDone
	AltFlash:
		CHPF A 1 Bright A_Light2 
		TNT1 A 2 A_Light0
		CHPF B 1 Bright A_Light2
		TNT1 A 1 A_Light1
		TNT1 A 2 A_Light0
		TNT1 A 1 A_Light2
		TNT1 A 2 A_Light0
		Goto LightDone
	ReloadCheck:
		TNT1 A 0 A_JumpIf(ACS_NamedExecuteWithResult("VulcanReload")==0, "NoReload")
		Goto NoAmmo
	NoAmmo:
		TNT1 A 0 A_ClearReFire
		TNT1 A 0 A_JumpIfInventory("FiringPlasma",1,"WindDownPlasma")
		Goto WindDown
	WindDown:
		TNT1 A 0 A_PlaySound("weapons/chaingun/stop",6)
		CHAG BCDABCD 1
		CHAG CBAD 2
		CHAG CB 3
		Goto Reload2
	WindDownPlasma:
		TNT1 A 0 A_TakeInventory("FiringPlasma",1)
		TNT1 A 0 A_PlaySound("weapons/chaingun/stop",6)
		CHAG DCB 1
		CHAG ADCBA 2
		TNT1 A 0 A_PlaySound("weapons/chaingun/load",5)
		CHAG BCDABCD 3
		Goto Reload2
	Reload:
		RCLD ABCDEEE 1
		TNT1 A 0 A_PlaySound("weapons/chaingun/feed",5)
		RCLD F 2
		NGLD GHIJKL 2
		Goto ReloadLoop
	Reload2:
		NGLD ABCDEEE 1
		TNT1 A 0 A_PlaySound("weapons/chaingun/feed",5)
		NGLD FGHIJKL 2
	ReloadLoop:
		TNT1 A 0 A_GiveInventory("NatoBelt")
		TNT1 A 0 A_TakeInventory("Nato",1,TIF_NOTAKEINFINITE)
		TNT1 A 0 A_JumpIfInventory("NatoBelt",0,"ReloadEnd")
		TNT1 A 0 A_JumpIfInventory("Nato",1,"ReloadLoop")
		Goto ReloadEnd
	ReloadEnd:
		TNT1 A 0
		Goto ReadyII
		
	NoReload:
		TNT1 A 0 A_GiveInventory("NatoBelt")
		TNT1 A 0 A_TakeInventory("Nato",1,TIF_NOTAKEINFINITE)
		TNT1 A 0 A_JumpIfInventory("NatoBelt",0,"ReloadEnd")
		TNT1 A 0 A_JumpIfInventory("Nato",1,"ReloadLoop")
		Goto ReloadEnd
		
	ReloadEnd:
		TNT1 A 0
		Goto ReadyII

	Spawn:
		MNIG A -1
	Stop
	}
}

ACTOR NatoBelt : Ammo
{
	+IGNORESKILL
	Inventory.MaxAmount 120
}

ACTOR Tracer : FastProjectile
{
	Alpha 0.75
	RenderStyle Add
	Radius 2
	Height 2
	Speed 75
	PROJECTILE
	+BLOODSPLATTER
	Scale 0.2
	MissileType TracerTrail
	MissileHeight 8
	Decal BulletChip
	States
	{
	Spawn:
		PUFF A 1 BRIGHT
		PUFF A 1 BRIGHT
		Loop

	Death:
	Crash:
		TNT1 A 0 A_PlaySound("ricochet",CHAN_AUTO)
		TNT1 AAA 0 A_CustomMissile("RicochetSparks",0,0,random(0,360),2,random(10,60))
		Stop
	}
}

ACTOR TracerTrail
{ 
	Alpha 0.75
	RenderStyle Add
	Speed 0
	+NOBLOCKMAP
	+NOGRAVITY
	+NOTELEPORT
	+CANNOTPUSH
	+NODAMAGETHRUST
	Scale 0.4
	States
	{
	Spawn:
		PUFF A 1 BRIGHT A_FadeOut(0.3)
		Loop
	}
}

ACTOR BlueTracer : Tracer
{
	Alpha 0.80
	RenderStyle Add
	Scale 0.3
	Decal "PlasmaScorchLower"
	MissileType BlueTracerTrail
	+PUFFONACTORS
	States
	{
	Spawn:
		PLZE E 1 BRIGHT
		PLZE E 1 BRIGHT 
		Loop
		
	Death:
		TNT1 A 0 A_Explode (40,100,(0))
		TNT1 A 0 A_CustomMissile ("PlasmaSmoke", 1, 0, random (0, 360), 2, random (0, 160))
		PLZE ABCDE 4 Bright
    Stop
	
	XDeath:
		TNT1 A 3
		Stop
	}
}

ACTOR BlueTracerTrail
{ 
	Alpha 0.50
	RenderStyle Add
	Speed 0
	Scale 0.3
	States
	{
	Spawn:
		PLZE E 1 BRIGHT A_FadeOut(0.3)
		Loop
	}
}

ACTOR ChaingunTracer : Tracer
{
	Damage (random(1,2))
	Speed 260
}

ACTOR RotaryPlasma : BlueTracer
{
	Damage (random(6,10))
	Speed 160
	Decal PlasmaScorchFast
}

Actor FiringPlasma : Inventory
{
	Inventory.Maxamount 1
}

Actor FiringTracer : Inventory
{
	Inventory.Maxamount 1
}