// --------------------------------------------------------------------------
//
// UAC-Rotary "Rock" Cannon Mark II
//
// --------------------------------------------------------------------------

ACTOR GyroSpin: Inventory { Inventory.MaxAmount 1 }

ACTOR D64Chaingun: D64Weapon
{
	Weapon.AmmoUse 1
	Weapon.AmmoGive 25
	Weapon.AmmoType "AmmoClip"
	AttackSound "Weapons/Chaingun/Fire"
	Inventory.PickupMessage "You got the UAC-Rotary 'Rock' Cannon Mark II!"
	Inventory.PickUpSound "Weapons/PickUp"
	Obituary "%o was cut in half by %k UAC-Rotary 'Rock' Cannon Mark II."
	Tag "UAC-Rotary 'Rock' Cannon Mark II"
	Scale 0.95
	+WEAPON.AMMO_OPTIONAL
	+WEAPON.NOAUTOFIRE
	
	States
	{
	Select:
		TNT1 A 0 A_PlaySound("Weapons/Chaingun/Up",5)
		GATG A 1 Offset(67, 100)
		GATG B 1 Offset(54, 81)
		GATG A 1 Offset(32, 69)
		GATG B 1 Offset(22, 58)
		GATG A 1 Offset(10, 47)
		GATG B 1 Offset(7, 39)
		GATG A 1 Offset(2, 34)
		GATG B 1 A_Raise
		Wait
	Ready:
		TNT1 A 0 A_JumpIfInventory("IsKicking", 1, "DoKick")
		GATG A 1 A_WeaponReady
		TNT1 A 0 A_JumpIfInventory("IsGrenading",1,"ThrowGrenade")
		TNT1 A 0 A_JumpIfInventory("IsKicking", 1, "DoKick")
		Loop
	LessonFive:
		TNT1 A 0 A_Playsound("Weapons/Chaingun/Spin",6,1,1)
		TNT1 A 0 A_AlertMonsters
		GATG ABCD 1 A_WeaponReady
		TNT1 A 0 A_JumpifInventory("IsGrenading",1,"ThrowGrenade")
		TNT1 A 0 A_JumpifInventory("IsKicking", 1, "DoKick")
		Loop
	Deselect:
	    TNT1 A 0 A_PlaySound("weapons/weaponholster",3)
		TNT1 A 0 A_TakeInventory("GyroSpin",10)
		TNT1 A 0 A_StopSound(6)
		GATG A 1 Offset(2, 34)
		GATG B 1 Offset(7, 39)
		GATG A 1 Offset(10, 47)
		GATG B 1 Offset(22, 58)
		GATG A 1 Offset(32, 69)
		GATG B 1 Offset(54, 81)
		GATG A 1 Offset(67, 100)
		GATG B 1 A_Lower
		Wait

	Fire:
		TNT1 A 0 A_JumpIfInventory("AmmoClip",1,1)
		Goto DryFire
		TNT1 A 0 A_JumpIfInventory("GyroSpin",1,"Hold")
		TNT1 A 0 A_Playsound("Weapons/Chaingun/Start",6)
		GATG BCD 3 A_WeaponReady(WRF_NoFire|WRF_NoSecondary|WRF_NoSwitch)
		GATG ABCD 2 A_WeaponReady(WRF_NoFire|WRF_NoSecondary|WRF_NoSwitch)
		TNT1 A 0 A_Refire
		GATG ABCD 3 A_WeaponReady(WRF_NoFire|WRF_NoSecondary|WRF_NoSwitch)
		Goto Ready
	Hold:
		TNT1 A 0 A_JumpIfInventory("AmmoClip",1,1)
		Goto DryFire
		TNT1 A 0 A_JumpIfNoAmmo("WindDown")
		TNT1 A 0 A_AlertMonsters
		TNT1 A 0 Radius_Quake (1, 2, 0, 1, 0)
		TNT1 A 0 A_SetPitch(pitch-0.5)
		TNT1 A 0 A_Playsound("Weapons/Chaingun/Spin",6)
		TNT1 A 0 A_GunFlash
		TNT1 A 0 A_Jump(164,"HoldAlt", "HoldAlt2")
	HoldCont:
		TNT1 A 0 A_JumpIfInventory("AmmoClip",1,1)
		Goto DryFire
		TNT1 A 0 A_SetPitch(pitch +0.3)
		TNT1 A 0 A_FireCustomMissile("50CaseSpawn",345+random(-8,8),0,-4,-5,0)
		GATF A 1 BRIGHT A_FireBullets(2.9, 2.9, 1, 10,"Bullet_Puff")
		TNT1 A 0 A_ZoomFactor(0.99)
		GATG C 1 Offset(0,36)
		TNT1 A 0 A_SetPitch(pitch+0.1)
		TNT1 A 0 A_ZoomFactor(0.995)
		GATG D 1 Offset(0,34)
		TNT1 A 0 A_SetPitch(pitch-0.3)
		TNT1 D 0 A_ZoomFactor(1.00)
		TNT1 A 0 Offset(0,32) A_ReFire
		Goto WindDown
	HoldAlt:
		TNT1 A 0 A_JumpIfInventory("AmmoClip",1,1)
		Goto DryFire
		TNT1 A 0 A_SetPitch(pitch +0.3)
		TNT1 A 0 A_FireCustomMissile("50CaseSpawn",345+random(-8,8),0,-4,-5,0)
		GATF B 1 BRIGHT A_FireBullets(2.9, 2.9, 1, 10,"Bullet_Puff")
		TNT1 A 0 A_ZoomFactor(0.99)
		GATG C 1 Offset(3,36) 
		TNT1 A 0 A_SetPitch(pitch+0.1)
		TNT1 A 0 A_ZoomFactor(0.995)
		GATG D 1 Offset(1,34)
		TNT1 A 0 A_SetPitch(pitch+-0.5)
		TNT1 D 0 A_ZoomFactor(1.00)
		TNT1 A 0 Offset(0,32) A_ReFire
		Goto WindDown
	HoldAlt2:
		TNT1 A 0 A_JumpIfInventory("AmmoClip",1,1)
		Goto DryFire
		TNT1 A 0 A_SetPitch(pitch +0.3)
		TNT1 A 0 A_FireCustomMissile("50CaseSpawn",345+random(-8,8),0,-4,-5,0)
		GATF C 1 BRIGHT A_FireBullets(2.9, 2.9, 1, 10,"Bullet_Puff")
		TNT1 A 0 A_ZoomFactor(0.99)
		GATG C 1 Offset(-3,36)
		TNT1 A 0 A_SetPitch(pitch-0.1)
		TNT1 A 0 A_ZoomFactor(0.995)
		GATG D 1 Offset(-1,34)
		TNT1 A 0 A_SetPitch(pitch+0.5)
		TNT1 D 0 A_ZoomFactor(1.00)
		TNT1 A 0 Offset(0,32) A_ReFire
		Goto WindDown
	WindDown:
		TNT1 A 0 A_JumpIfInventory("GyroSpin",1,"LessonFive")
		TNT1 A 0 A_PlaySound("Weapons/Chaingun/Stop",6)
		GATG ABCDAB 2 A_WeaponReady 
		GATG CDABCD 2 A_WeaponReady
		GATG ABCDCB 3 A_WeaponReady 
		TNT1 A 0 A_ClearRefire
		Goto Ready
	AltFire:
		TNT1 A 0 A_JumpIfInventory("GyroSpin",1,"SpinDown")
		TNT1 A 0 A_GiveInventory("GyroSpin",1)
		TNT1 A 0 A_Playsound("Weapons/Chaingun/Start",6)
		GATG BCD 3 A_WeaponReady(WRF_NoFire|WRF_NoSecondary|WRF_NoSwitch)
		GATG ABCD 2 A_WeaponReady(WRF_NoFire|WRF_NoSecondary|WRF_NoSwitch)
		Goto LessonFive
	SpinDown:
		TNT1 A 0 A_PlaySound("Weapons/Chaingun/Stop",6)
		GATG ABCDAB 2 A_WeaponReady(WRF_NoFire|WRF_NoSecondary|WRF_NoSwitch)
		GATG CDABCD 2 A_WeaponReady(WRF_NoFire|WRF_NoSecondary|WRF_NoSwitch)
		GATG ABCDCB 3 A_WeaponReady(WRF_NoFire|WRF_NoSecondary|WRF_NoSwitch)
		TNT1 A 0 A_TakeInventory("GyroSpin",1)
		Goto Ready
		
	DryFire:
	    TNT1 A 0 A_Print("No ammunition. Go find more.",1)
		TNT1 A 0 A_StopSound(6)
	    Goto Ready

//Kick
	DoKick:
		TNT1 A 0 A_StopSound(6)
		TNT1 A 0 A_JumpIf (momZ > 0, "AirBorne")
		TNT1 A 0 A_JumpIf (momZ < 0, "AirBorne")
		TNT1 A 0 A_JumpIfInventory("BerserkStrength",1,"BerserkKick")
		TNT1 A 0 A_TakeInventory("GyroSpin",10)
		KICK A 1 Offset(0,32)
		TNT1 A 0 A_SetPitch(Pitch-1)
		KICK B 1 A_ZoomFactor(0.99)
		TNT1 A 0 A_SetPitch(Pitch-1)
		KICK C 1 A_ZoomFactor(0.98)
		TNT1 A 0 A_SetPitch(Pitch-1)
		KICK D 1 A_ZoomFactor(0.97)
		TNT1 A 0 A_SetPitch(Pitch-1)
		KICK E 1 A_ZoomFactor(0.96)
		TNT1 A 0 A_SetPitch(Pitch-1)
		KICK F 1 A_ZoomFactor(0.95)
		TNT1 A 0 A_CustomPunch(2 * random(1, 10),0,0,"KickPuff") 
		Goto FireEnd
		BerserkKick:
		TNT1 A 0 A_StopSound(6)
		TNT1 A 0 A_TakeInventory("GyroSpin",10)
		KICK A 1 Offset(0,32)
		TNT1 A 0 A_SetPitch(Pitch-1)
		KICK B 1 A_ZoomFactor(0.99)
		TNT1 A 0 A_SetPitch(Pitch-1)
		KICK C 1 A_ZoomFactor(0.98)
		TNT1 A 0 A_SetPitch(Pitch-1)
		KICK D 1 A_ZoomFactor(0.97)
		TNT1 A 0 A_SetPitch(Pitch-1)
		KICK E 1 A_ZoomFactor(0.96)
		TNT1 A 0 A_SetPitch(Pitch-1)
		KICK F 1 A_ZoomFactor(0.95)
		TNT1 A 0 A_CustomPunch(20 * random(5, 10),0,0,"KickPuff")
		Goto FireEnd
		FireEnd:
		TNT1 A 0 A_StopSound(6)
		KICK GHIH 1
		TNT1 A 0 A_SetPitch(Pitch+1)
		KICK G 1 A_ZoomFactor(0.96)
		TNT1 A 0 A_SetPitch(Pitch+1)
		KICK F 1 A_ZoomFactor(0.97)
		TNT1 A 0 A_SetPitch(Pitch+1)
		KICK E 1 A_ZoomFactor(0.98)
		TNT1 A 0 A_SetPitch(Pitch+1)
		KICK D 1 A_ZoomFactor(0.99)
		TNT1 A 0 A_SetPitch(Pitch+1)
		KICK C 1 A_ZoomFactor(1.00)
		TNT1 A 3
		KICK BA 1
		Goto Ready
		AirBorne:
		TNT1 A 0 A_StopSound(6)
		TNT1 A 0 A_JumpIfInventory("BerserkStrength",1,"AirBerserk")
		TNT1 A 0 Offset(-1,32)
		KIKK ABCDE 1 A_Recoil(-2)
		KIKK F 3 A_CustomPunch (15,0,0,"KickPuff") 
		Goto EndFire
		AirBerserk:
		TNT1 A 0 A_StopSound(6)
		TNT1 A 0 Offset(-1,32)
		KIKK ABCDE 1 A_Recoil(-2)
		KIKK F 3 A_CustomPunch (25 * random(5, 10),0,0,"KickPuff")
		Goto EndFire
		EndFire:
		TNT1 A 0 A_StopSound(6)
		KIKK GHIJK 2 
		Goto Ready
		
//Throw Grenade
	ThrowGrenade:
		TNT1 A 0 A_JumpIf(waterlevel>2,"DryFire")
		TNT1 A 0 A_JumpIfInventory("GrenadeAmmo",1,1)
		Goto Dryfire
		TNT1 A 0 A_JumpIfInventory("GyroSpin",1,"ThrowGrenadeSpin")
		TNT1 A 0 A_StopSound(1)
		TNT1 A 0 Offset(-20,32)
		TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSecondary|WRF_NoSwitch)
		MAND B 1 Offset(0,24)
		TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSecondary|WRF_NoSwitch)
		MAND C 1 Offset(0,23)
		TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSecondary|WRF_NoSwitch)
		MAND D 1 Offset(0,26) A_PlaySound("weapons/SHG/throw")
		TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSecondary|WRF_NoSwitch)
		MAND D 1 Offset(0,28)
		TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSecondary|WRF_NoSwitch)
		TNT1 A 0 A_SpawnItemEx("RealGrenade",0,1,24,cos(pitch)*40,0,sin(-pitch)*40,3,SXF_TRANSFERPITCH|SXF_NOCHECKPOSITION)
		TNT1 A 0 A_TakeInventory("GrenadeAmmo",1)
		MAND E 1 Offset(-3,30)
		TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSecondary|WRF_NoSwitch)
		MAND E 1 Offset(-6,31)
		TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSecondary|WRF_NoSwitch)
		MAND F 1 Offset(-9,32)
		TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSecondary|WRF_NoSwitch)
		MAND F 1 Offset(-12,33)
		TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSecondary|WRF_NoSwitch)
		TNT1 A 0 A_TakeInventory("GetOnWithIt", 100)
		TNT1 A 0 A_JumpIfNoAmmo("DryFire")
		TNT1 A 7 Offset (75, 152)
		TNT1 A 1 Offset (6, 42)
		Goto Ready
		ThrowGrenadeSpin:
		TNT1 A 0 A_JumpIf(waterlevel>2,"DryFire")
		TNT1 A 0 A_JumpIfInventory("GrenadeAmmo",1,1)
		Goto Dryfire
		TNT1 A 0 A_StopSound(1)
		TNT1 A 0 Offset(-20,32)
		TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSecondary|WRF_NoSwitch)
		MAND B 1 Offset(0,24)
		TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSecondary|WRF_NoSwitch)
		MAND C 1 Offset(0,23)
		TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSecondary|WRF_NoSwitch)
		MAND D 1 Offset(0,26) A_PlaySound("weapons/SHG/throw")
		TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSecondary|WRF_NoSwitch)
		MAND D 1 Offset(0,28)
		TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSecondary|WRF_NoSwitch)
		TNT1 A 0 A_SpawnItemEx("RealGrenade",0,1,24,cos(pitch)*40,0,sin(-pitch)*40,3,SXF_TRANSFERPITCH|SXF_NOCHECKPOSITION)
		TNT1 A 0 A_TakeInventory("GrenadeAmmo",1)
		MAND E 1 Offset(-3,30)
		TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSecondary|WRF_NoSwitch)
		MAND E 1 Offset(-6,31)
		TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSecondary|WRF_NoSwitch)
		MAND F 1 Offset(-9,32)
		TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSecondary|WRF_NoSwitch)
		MAND F 1 Offset(-12,33)
		TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSecondary|WRF_NoSwitch)
		TNT1 A 0 A_TakeInventory("GetOnWithIt", 100)
		TNT1 A 0 A_JumpIfNoAmmo("DryFire")
		TNT1 A 7 Offset (75, 152)
		TNT1 A 1 Offset (6, 42)
		Goto LessonFive
		
	Flash:
		TNT1 A 5 Bright A_Light1
		Goto LightDone
		TNT1 A 5 Bright A_Light2
		Goto LightDone
		
	Spawn:
		GATP A -1
		Stop
	}
}