// Gatling gun
actor GatlingGun : AOWWeapon 21045 {
	Tag "Gatling Gun"
	Obituary "$OB_GATLING"
	Inventory.PickupMessage "You got the gatling gun!"
	Weapon.SelectionOrder 7
	Weapon.AmmoType "MachineGunAmmo"
	Weapon.AmmoUse 1
	Weapon.AmmoGive 25
	Weapon.AmmoType2 "MachineGunAmmo"
	Weapon.AmmoUse2 2
	Weapon.PreferredSkin "MarineChaingun"
	
	States {
	Spawn:
		GATG X -1
		stop
	Ready:
		GATG A 0 A_StopSound (CHAN_WEAPON)
		GATG A 5 A_WeaponReady
		loop
	Deselect:
		GATG A 0 A_StopSound (CHAN_WEAPON)
		GATG AAA 1 A_Lower
		loop
	Select:
		GATG A 1 A_Raise
		loop
	Fire:
		TNT1 A 0 A_JumpIfInventory ("IsInSpawnRoom", 1, "Ready")
		TNT1 A 0 A_JumpIfInventory ("InMenu", 1, "Ready")
		GATG B 0 A_PlaySound ("gatling/spinup", 5)
		GATG B 1 offset (-1, 30)
		GATG B 1 offset (-2, 28)
		GATG B 1 offset (-3, 26)
		GATG B 1 offset (-5, 24)
		GATG B 1 offset (-7, 22)
		GATG A 1 offset (-9, 20)
		GATG A 1 offset (-11, 17)
		GATG A 1 offset (-14, 14)
		GATG A 1 offset (-17, 11)
		GATG B 3
	Hold:
		TNT1 A 0 A_JumpIfInventory ("IsInSpawnRoom", 1, "Ready")
		TNT1 A 0 A_JumpIfInventory ("InMenu", 1, "Ready")
		GATG A 0 Radius_Quake(1,6,0,1,0)
		GATG A 1 offset (-19, 10) A_PlaySound ("minigun/loop", CHAN_WEAPON, 1.0, 1)
		GATG A 0 A_Light2
		GATG A 0 A_PlaySound ("minigun/fire2", 5)
		GATF A 0 A_SpawnItemEx("RifleShellCasing",4,13,32,random(-2,-4),random(2,3),random(0,1),random(45,60),128)
		GATF A 0 A_FireBullets (9.2, 3.2, 3, random (2,3), "RiflePuff", 1, 2048)
		GATF A 1 offset (-17, 10) Bright A_Light1
		GATG B 0 A_Light2
		GATF B 0 A_SpawnItemEx("RifleShellCasing",4,13,32,random(-2,-4),random(2,3),random(0,1),random(45,60),128)
		GATF B 0 A_FireBullets (9.2, 3.2, 3, random (2,3), "RiflePuff", 1, 2048)
		GATF B 1 offset (-17, 8) Bright
		GATG A 1 offset (-19, 8) A_Light1
		GATG A 0 A_JumpIfNoAmmo ("SpinDown")
		GATG A 0 A_ReFire
		goto SpinDown
	SpinDown:
		GATG B 0 A_Light0
		GATG B 0 A_PlaySound ("gatling/spin", 5)
		GATG B 0 A_StopSound (CHAN_WEAPON)
		GATG B 1 offset (-17, 11) A_ReFire
		GATG B 1 offset (-14, 14) A_ReFire
		GATG B 1 offset (-11, 17) A_ReFire
		GATG A 1 offset ( -9, 20) A_ReFire
		GATG A 1 offset ( -7, 22) A_ReFire
		GATG A 1 offset ( -5, 24) A_ReFire
		GATG A 1 offset ( -3, 26) A_ReFire
		GATG A 1 offset ( -2, 28) A_ReFire
		GATG B 1 offset ( -1, 30) A_ReFire
		GATG B 5 offset (  0, 32) A_ReFire
		GATG A 6
		GATG B 7
		goto Ready
	AltFire:
		TNT1 A 0 A_JumpIfInventory ("IsInSpawnRoom", 1, "Ready")
		TNT1 A 0 A_JumpIfInventory ("InMenu", 1, "Ready")
		GATG B 0 A_PlaySound ("gatling/spinup", 5)
		GATG B 1 offset (-1, 30)
		GATG B 1 offset (-2, 28)
		GATG B 1 offset (-3, 26)
		GATG B 1 offset (-5, 24)
		GATG B 1 offset (-7, 22)
		GATG A 1 offset (-9, 20)
		GATG A 1 offset (-11, 17)
		GATG A 1 offset (-14, 14)
		GATG A 1 offset (-17, 11)
		GATG B 3
		goto AltHold
	AltHold:
		TNT1 A 0 A_JumpIfInventory ("IsInSpawnRoom", 1, "Ready")
		TNT1 A 0 A_JumpIfInventory ("InMenu", 1, "Ready")
		GATF A 0 A_PlaySound ("gatling/alt", CHAN_WEAPON, 1, 1.0)
		GATF A 0 A_Light2
		GATF AA 0 A_SpawnItemEx("RifleShellCasing",4,13,32,random(-2,-4),random(2,3),random(0,1),random(45,60),128)
		GATF A 0 A_FireBullets (2.6, 1.6, -1, 10, "ExplosionPuffSmall", 1, 3072)
		GATF A 1 bright offset (-17, 12)
		GATF A 1 bright offset (-17, 16)
		GATG B 0 A_Light1
		GATG B 1 bright offset (-17, 15)
		GATG B 1 bright offset (-17, 13)
		GATG B 1 bright offset (-17, 11)
		GATF B 0 A_Light2
		GATF B 0 A_SpawnItemEx("RifleShellCasing",4,13,32,random(-2,-4),random(2,3),random(0,1),random(45,60),128)
		GATF B 0 A_FireBullets (2.6, 1.6, -1, 10, "ExplosionPuffSmall", 1, 3072)
		GATF B 1 bright offset (-17, 13)
		GATF B 1 bright offset (-17, 16)
		GATG A 0 A_Light1
		GATG A 1 bright offset (-17, 15)
		GATG A 1 bright offset (-17, 13)
		GATG A 1 bright offset (-17, 11)
		GATG A 0 A_JumpIfNoAmmo ("SpinDown")
		GATG A 0 A_ReFire
		goto SpinDown
	}
}

actor ExplosionPuff {
	+PUFFONACTORS
	+CLIENTSIDEONLY
	DamageType "Explosion"
	States {
	Spawn:
		TNT1 A 0
		TNT1 A 0 A_PlaySound ("gatling/boom", CHAN_BODY, 1.0)
		TNT1 A 14 A_SpawnItemEx ("ExplosionSmall", 0,0,0, 0,0,0, 0, SXF_NOCHECKPOSITION)
		stop
	}
}

actor ExplosionPuffSmall : ExplosionPuff {
	states {
	Spawn:
		TNT1 A 0
		TNT1 A 0 A_PlaySound ("gatling/boom", CHAN_BODY, 0.6)
		TNT1 A 14 A_SpawnItemEx ("ExplosionSmaller", 0,0,0, 0,0,0, 0, SXF_NOCHECKPOSITION)
		stop
	}
}