// --------------------------------------------------------------------------
//
// UAC-Precision Railgun
//
// --------------------------------------------------------------------------

ACTOR D64Railgun: D64Weapon
{
	Weapon.AmmoUse 10
	Weapon.AmmoGive 50
	Weapon.AmmoType "Cell2"
	Inventory.PickUpSound "Weapons/PickUp"
	Inventory.PickupMessage "You got the UAC-Precision Railgun!"
	Tag "UAC-Precision Railgun"
	Scale 0.95
	+WEAPON.AMMO_OPTIONAL
	+WEAPON.NOAUTOFIRE
	
	States
	{
	Select:
		TNT1 A 0 A_PlaySound("Weapons/Railgun/Up",5)
		RGNS A 1 Offset(67, 100)
		RGNS A 1 Offset(54, 81)
		RGNS A 1 Offset(32, 69)
		RGNS A 1 Offset(22, 58)
		RGNS A 1 Offset(10, 47)
		RGNS A 1 Offset(7, 39)
		RGNS A 1 Offset(2, 34)
		RGNS A 1 A_Raise
		Wait
	Ready:
		TNT1 A 0 A_PlaySound("Weapons/Railgun/Idle", 7, 1, 1)
		TNT1 A 0 A_JumpIfInventory("RailZoomed",1,"ReadyZoomed")
		TNT1 A 0 A_JumpIfInventory("IsKicking", 1, "DoKick")
		RGNI A 2 BRIGHT A_WeaponReady
		TNT1 A 0 A_JumpifInventory("IsKicking", 1, "DoKick")
		TNT1 A 0 A_JumpIfInventory("RailZoomed",1,"ReadyZoomed")
		RGNI B 2 BRIGHT A_WeaponReady
		TNT1 A 0 A_JumpifInventory("IsKicking", 1, "DoKick")
		TNT1 A 0 A_JumpIfInventory("RailZoomed",1,"ReadyZoomed")
		RGNI C 2 BRIGHT A_WeaponReady
		TNT1 A 0 A_JumpifInventory("IsKicking", 1, "DoKick")
		TNT1 A 0 A_JumpIfInventory("RailZoomed",1,"ReadyZoomed")
		RGNI D 2 BRIGHT A_WeaponReady 
		TNT1 A 0 A_JumpIfInventory("RailZoomed",1,"ReadyZoomed")
		TNT1 A 0 A_JumpifInventory("IsKicking", 1, "DoKick")
		TNT1 A 0 A_JumpifInventory("IsGrenading",1,"ThrowGrenade")
		Loop
	ReadyZoomed:
		RGNZ E 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_StopSound(7)
		TNT1 A 0 A_TakeInventory("PowerLightAmp",1)
		TNT1 A 0 A_TakeInventory("RailZoomed",1)
		TNT1 A 0 A_ZoomFactor(1)
		RGNS A 1 Offset(2, 34)
		RGNS A 1 Offset(7, 39)
		RGNS A 1 Offset(10, 47)
		RGNS A 1 Offset(22, 58)
		RGNS A 1 Offset(32, 69)
		RGNS A 1 Offset(54, 81)
		RGNS A 1 Offset(67, 100)
		RGNS A 1 A_Lower
		Wait 
	
		
	Fire:
		TNT1 A 0 A_JumpIfInventory("Cell2",10,1)
		Goto DryFire
		TNT1 A 0 A_JumpIfInventory("RailZoomed",1,"FireZoomed")
		TNT1 A 0 A_StopSound(7)
		RGNF A 2 
		TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSecondary|WRF_NoSwitch)
		RGNF BCDEF 2
		TNT1 A 0 A_Playsound("Weapons/Railgun/Fire",6)
		TNT1 A 0 A_SetPitch(pitch -0.2)
        TNT1 A 0 BRIGHT A_RailAttack(250,0,10,"00 85 FF",None,0,0,"Bullet_Puff")
		TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSecondary|WRF_NoSwitch)
		RGNF G 1 A_SetPitch(-6.0 + pitch)
		TNT1 A 0 A_AlertMonsters
		TNT1 A 0 A_Gunflash
		TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSecondary|WRF_NoSwitch)
		RGNF HIJKL 2 A_SetPitch(1.2 + pitch)
		TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSecondary|WRF_NoSwitch)
		RGNF LLLLL 3 A_FireCustomMissile("GunSmokeSpawner2",0,0,0,2)
		TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSecondary|WRF_NoSwitch)
		RGNF AA 3
		TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSecondary|WRF_NoSwitch)
		Goto Ready
	FireZoomed:
		TNT1 A 0 A_JumpIfInventory("Cell2",10,1)
		Goto DryFire
		TNT1 A 0 A_StopSound(7)
		TNT1 A 0 A_Playsound("Weapons/Railgun/Fire",6)
		TNT1 A 0 A_SetPitch(pitch -0.2)
		TNT1 A 0 BRIGHT A_RailAttack(250,0,1,"00 85 FF",None,0,0,"Bullet_Puff")
		TNT1 A 0 A_AlertMonsters
		TNT1 A 0 A_Gunflash
		TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSecondary|WRF_NoSwitch)
		RGNZ D 5 BRIGHT
		TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSecondary|WRF_NoSwitch)
		RGNZ DDDDD 2 BRIGHT A_WeaponReady(WRF_NoFire|WRF_NoSwitch)
		TNT1 A 0 A_WeaponReady(WRF_NoFire|WRF_NoSecondary|WRF_NoSwitch)
		RGNZ EE 15 BRIGHT
		Goto Ready
	 AltFire:
		TNT1 A 0 A_JumpIfInventory("RailZoomed",1,"UnZoom")
		TNT1 A 0 A_GiveInventory("RailZoomed",1)
		TNT1 A 0 A_Giveinventory("RailgunNightvisionOn",1)
		TNT1 A 0 A_Giveinventory("PowerLightAmp",1)
		TNT1 A 0 A_PlaySound("Weapons/Railgun/Zoom")
		RGNZ A 1 A_ZoomFactor(1.1)
		RGNZ B 1 A_ZoomFactor(1.2)
		RGNZ C 1 A_ZoomFactor(1.3)
		RGNZ D 1 A_ZoomFactor(1.4)
		RGNZ E 1 A_ZoomFactor(1.5)
		Goto Ready
	UnZoom:
		TNT1 A 0 A_PlaySound("Weapons/Railgun/UnZoom")
		RGNZ E 1 A_ZoomFactor(1.4)
		RGNZ D 1 A_ZoomFactor(1.3)
		RGNZ C 1 A_ZoomFactor(1.2)
		RGNZ B 1 A_ZoomFactor(1.1)
		RGNZ A 1 A_ZoomFactor(1.0)
		TNT1 A 0 A_Takeinventory("RailgunNightvisionOn",1)
		TNT1 A 0 A_TaKeinventory("PowerLightAmp",1)
		TNT1 A 0 A_TakeInventory("RailZoomed",1)
		Goto Ready
		
		DryFire:
		TNT1 A 0 A_Print("No ammunition. Go find more.",1)
		Goto Ready
		
	Flash:
		TNT1 A 5 Bright A_Light1
		Goto LightDone
		TNT1 A 5 Bright A_Light2
		Goto LightDone

//Kick
	DoKick:
		TNT1 A 0 A_JumpIf (momZ > 0, "AirBorne")
		TNT1 A 0 A_JumpIf (momZ < 0, "AirBorne")
		TNT1 A 0 A_JumpIfInventory("BerserkStrength",1,"BerserkKick")
		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:
		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:
		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_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 Offset(-1,32)
		KIKK ABCDE 1 A_Recoil(-2)
		KIKK F 3 A_CustomPunch (25 * random(5, 10),0,0,"KickPuff")
		Goto EndFire
		EndFire:
		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_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

	Spawn:
		RGNW ABCACBACABAC 3
		Loop
		
	}
}

ACTOR RailgunNightvisionOn : Inventory { Inventory.MaxAmount 1 }

ACTOR RailZoomed: Inventory
{
Inventory.MaxAmount 1
}