/*

==CYCLOPS AUTO CANNON==

Having a greater need for a flexible explosive weapon that could serve 
well at both mid and long range, the Artificer designed a compact
semi-automatic cannon. Capable of firing heavy shells at a fire rate
that surpasses a standard UAC rocket launcher.

The Cyclops also features a built in scope and camera for taking 
out targets even at extreme range as an altfire. While zoomed in,
the shells fly at an even higher velocity, ensuring whatever poor
idiot that's in Arti's sights doesn't have much of a chance to
sidestep the incoming shell.


*/


actor CyclopsCannon : weapon
{
	Weapon.SelectionOrder 35
	Weapon.AmmoUse1 1
	Weapon.AmmoUse2 1
	Weapon.KickBack 180
	weapon.bobstyle smooth
	weapon.bobrangex 0.1
	weapon.bobrangey 0.6
	weapon.bobspeed 2
	+WEAPON.AMMO_OPTIONAL
	+WEAPON.ALT_AMMO_OPTIONAL
	+WEAPON.NOALERT
	+noautofire
	+NOAUTOAIM
	Inventory.RestrictedTo "Artificer"
	Weapon.AmmoType "RocketAmmo"
	Weapon.AmmoType2 "RocketAmmo"
	Inventory.PickupSound "Misc/W_PkUp"
	Obituary "%o was bombarded by %k."
	Tag "Cyclops cannon"
	States
	{
	spawn:
		CGPU A -1
		stop
	select:
		TNT1 A 0
		TNT1 A 0 a_zoomfactor (1)
		TNT1 A 0 a_setcrosshair (0)
		TNT1 A 0 a_takeinventory ("ScopeActive",1)
		TNT1 A 0 a_playsound ("Cyclops/draw",0)
	draw:
		TNT1 A 0
		TNT1 A 0 a_zoomfactor (1)
		TNT1 A 0 a_setcrosshair (0)
		TNT1 A 0 a_takeinventory ("ScopeActive",1)
		RTCN AAAA 0 a_raise
		RTCN A 1 a_raise
		loop
	deselect:
		TNT1 A 0
		TNT1 A 0 a_zoomfactor (1)
		TNT1 A 0 a_setcrosshair (0)
		TNT1 A 0 a_takeinventory ("ScopeActive",1)
		TNT1 A 0 a_jumpifhealthlower (1, "deadlower")
		TNT1 A 0 a_playsound ("Cyclops/holster",0)
	holster:
		TNT1 A 0
		TNT1 A 0 a_takeinventory ("secretaction", 99)
		RTCN A 1 a_lower
		RTCN AA 0 a_lower
		loop
	deadlower:
		TNT1 A 0
		TNT1 A 0
		TNT1 AAAAAAAAAAAAA 0 a_lower
		TNT1 A 1 a_lower
		wait
	Ready:
		RTCN A 1 a_weaponready
		wait
	Fire:
		TNT1 A 0 
		TNT1 A 0 a_jumpifinventory ("RocketAmmo",1,"RealShot")
		RTCN A 2
		goto ready
	RealShot:
		TNT1 A 0
		RTCN A 2 a_jumpifinventory ("ScopeActive",1,"AltShot")
		RTCN B 2 bright
		TNT1 A 0 A_Quake(2, 6, 0, 5)
		TNT1 A 0 a_playsound ("Cyclops/fire",1)
		TNT1 A 0 a_alertmonsters
		RTCN C 1 bright a_firecustomMissile ("CannonShell",0,1)
		RTCN D 1 bright offset (0,40)
		RTCN E 1 bright offset (0,41)
		RTCN F 1 offset (0,38) a_weaponready
		RTCN F 1 offset (0,34) a_weaponready
		RTCN F 1 offset (0,32) a_weaponready
		RTCN A 4 a_weaponready
		TNT1 A 0 a_refire
		goto ready
	Altfire:
		TNT1 A 0
		TNT1 A 0 a_jumpifinventory ("ScopeActive",1,"ZoomOut")
		TNT1 A 0 a_setcrosshair (42)
		RTCN A 1 a_setblend ("Black",0.20,10) 
		RTCN A 1 a_setblend ("Black",0.60,20) 
		RTCN A 1 a_setblend ("Black",1,30) 
		RTCN A 1
		CYZO A 4 a_zoomfactor (5)
		CYZO A 1 a_giveinventory ("ScopeActive",1)
		TNT1 A 0 a_playsound ("Cyclops/ZoomIn",0)
		CYZO BCDEF 1 bright
		TNT1 A 0 a_jumpifinventory ("RocketAmmo",1,"ZoominFinish")
		CYZO WXY 1 bright
		goto NoAmmoScope
	ZoomInFinish:
		CYZO G 1 bright a_weaponready (WRF_NOBOB)
		goto ScopeReady
	ScopeReady:
		CYZO G 1 bright a_weaponready (WRF_NOBOB)
		loop
	NoAmmoScope:
		TNT1 A 0 a_jumpifinventory ("RocketAmmo",1,"ScopeLoad")
		CYZO Y 1 bright a_weaponready (WRF_NOBOB|WRF_NOPRIMARY)
		TNT1 A 0 a_jumpifinventory ("RocketAmmo",1,"ScopeLoad")
		loop
	ZoomOut:
		TNT1 A 0
		TNT1 A 0 a_playsound ("Cyclops/ZoomOut",0)
		CYZO EDCBA 1 bright 
		CYZO A 5 a_zoomfactor (1)
		RTCN A 1 a_setblend ("Black",1,10) 
		TNT1 A 0 a_setcrosshair (0)
		RTCN A 2 
		TNT1 A 0 a_takeinventory ("ScopeActive",1)
		goto ready
		
	Altshot:
		CYZO G 2 bright
		CYZO H 2 bright 
		TNT1 A 0 A_Quake(2, 6, 0, 5)
		TNT1 A 0 a_playsound ("Cyclops/ScopeShot",1)
		TNT1 A 0 a_alertmonsters
		CYZO I 1 bright A_FireBullets (0,0,1,110,"ScopeShell",FBF_USEAMMO|FBF_NORANDOM)
		TNT1 A 0 a_playsound ("Cyclops/Cycle1",0)
		CYZO J 2 bright a_setpitch (pitch-2,SPF_INTERPOLATE)
		CYZO K 4 bright
		TNT1 A 0 a_jumpifinventory ("RocketAmmo",1,"ScopeLoad")
		CYZO Y 1 bright 
		goto NoAmmoScope
	ScopeLoad:
		TNT1 A 0
		TNT1 A 0 a_playsound ("Cyclops/Cycle2",0)
		CYZO L 2 bright
		CYZO M 1 bright
		CYZO N 2 bright
		CYZO O 1 bright
		CYZO P 2 bright
		CYZO Q 1 bright
		CYZO R 2 bright
		TNT1 A 0 a_playsound ("Cyclops/reload",0)
		CYZO S 1 bright
		CYZO T 3 bright
		CYZO U 2 bright
		CYZO V 1 bright
		TNT1 A 0 a_refire ("Altshot")
		CYZO G 2 bright a_weaponready (WRF_NOBOB)
		goto ScopeReady
		
	}
}


actor CannonShell
{
	Projectile
	Radius 5
	Height 5
	Speed 55
	Damage 20
	+thruspecies
	scale 1.25
	+randomize
	decal scorch
	species "player"
	DeathSound "Cyclops/rocketboom"
	States
	{
	Spawn:
		TNT1 A 0		
		TNT1 A 0 a_spawnitemex ("missilering")
		TNT1 A 0 a_playsound ("Cyclops/rocketspeedup",0,1,0, 0.75)
		R5H1 A 1 bright 
		goto Flight
	Flight:
		R5H1 A 1 bright
		R5H1 A 1 bright a_spawnitem ("ShellBlur")
		TNT1 A 0 A_SpawnItemEx("LavaLazerSmoke",frandom(-4,4),frandom(-4,4),frandom(-4,4))
		Loop
	Death:
		TNT1 A 0
		TNT1 A 0
		TNT1 A 0 radius_quake (3,8,0,20,0)
		TNT1 A 0 a_explode (55,120,1,0,50)
		TNT1 AAAAAA 0 a_spawnitemex ("Missilefire",Frandom(-20,20),Frandom(-18,18),Frandom(-18,18),Frandom(-200,200)/20.0,Frandom(-200,200)/20.0,Frandom(-200,200)/20.0,0,160)
		TNT1 A 0 A_SpawnItemEx("LavaLazerExplosion")
		TNT1 AAAAAAAAAAAAAAAAA 0 Bright A_SpawnItemEx("LavaLazerTrail",frandom(-21,21),frandom(-21,21),frandom(-21,21),frandom(-1,1),frandom(-1,1),frandom(0,1))
		TNT1 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA 0 Bright A_SpawnItemEx("LavaLazerSmoke2",frandom(-8,8),frandom(-8,8),frandom(-4,4),frandom(-1,1),frandom(-1,1),frandom(0,1))
		TNT1 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA 0 Bright A_SpawnItemEx("LavaLazerSmoke",frandom(-8,8),frandom(-8,8),frandom(-4,4),0,0,frandom(1,2))
		TNT1 A 0 a_radiusthrust (200, 100, 80)
		TNT1 A 3
		stop
	}
}



Actor ShellBlur       
{
	Height 8
	Radius 1
	Damage 0
	Scale 0.8
	Speed 0.2
	RenderStyle Translucent
	Alpha 0.7
	+NoGravity
	+DropOff
	+NoTeleport
	+clientsideonly
	States
	{
	Spawn:
		TNT1 A 0
		TNT1 A 1
	FlightLoop:
		R5H1 A 1 bright A_FadeOut(0.06)
		Loop
	}
}





ACTOR ScopeShell : BulletPuff
{
	+NOBLOCKMAP
	+NOGRAVITY
	+ALLOWPARTICLES
	+RANDOMIZE
	+thruspecies
	+MTHRUSPECIES
	+puffonactors
	+bright
	decal scorch
	species "Player"
	damagetype "CyclopsShell"
	RenderStyle Add
	scale 2
	Alpha 0.8
	VSpeed 1
	Mass 5
	States
	{
	Spawn:
        TNT1 A 0
		TNT1 A 1
		TNT1 A 0 a_explode (100,100,0,1,30)
		TNT1 AAAAAA 0 a_spawnitemex ("Missilefire",Frandom(-20,20),Frandom(-18,18),Frandom(-18,18),Frandom(-200,200)/20.0,Frandom(-200,200)/20.0,Frandom(-200,200)/20.0,0,160)
		TNT1 A 0 A_SpawnItemEx("LavaLazerExplosion")
		TNT1 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA 0 Bright A_SpawnItemEx("LavaLazerTrail",frandom(-21,21),frandom(-21,21),frandom(-21,21),frandom(-1,1),frandom(-1,1),frandom(0,1))
		TNT1 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA 0 Bright A_SpawnItemEx("LavaLazerSmoke2",frandom(-8,8),frandom(-8,8),frandom(-4,4),frandom(-1,1),frandom(-1,1),frandom(0,1))
		TNT1 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA 0 Bright A_SpawnItemEx("LavaLazerSmoke",frandom(-8,8),frandom(-8,8),frandom(-4,4),0,0,frandom(1,2))
		stop
	}
}






ACTOR Missilefire
{
	radius 3
	height 6
	speed 10
	scale 0.45
	projectile
	-nogravity
	+nointeraction
	+FLOORCLIP
	+DONTSPLASH
	+thruactors
	+NOTELEPORT
	+clientsideonly
	States
	{
	spawn:	
		MFIR ABCDE 1 bright
		MFIR FGHI 1  Bright
		Stop
	}
}


actor missilering
{
	+nointeraction
	+clientsideonly
	translation "128:223=%[0.00,0.00,0.00]:[2.00,2.00,2.00]"
	scale 0.80
	speed 55
	renderstyle add
	alpha 0.90
	states
	{
	spawn:
		TRNG GFEDCBA 2
		TNT1 A 0
		stop
	}
}






//NICE VISUAL EFFECTS COURTESY OF SGT SHIVERS

ACTOR LavaLazerTrail
{
	projectile
	+NOBLOCKMAP
	+NOGRAVITY
	+ALLOWPARTICLES
	+RANDOMIZE
	+HEXENBOUNCE
	bouncecount 2
	RenderStyle Add
	Alpha 0.5
	Scale 0.35
	+clientsideonly
	Mass 5
	States
	{
	Spawn:
		TNT1 A 0
		TNT1 A 0 a_setscale (frandom (0.10,0.35),frandom(0.10,0.35))
		LVLZ A 2 Bright A_FadeOut(0.1)
		LVLZ A 2 Bright A_FadeOut(0.1)
		LVLZ A 2 Bright A_FadeOut(0.1)
	fade:
		LVLZ A 2 Bright A_FadeOut(0.1)
		loop
	}
}

ACTOR LavaLazerEmber1
{
	+NOBLOCKMAP
	+NOGRAVITY
	+ALLOWPARTICLES
	+RANDOMIZE
	RenderStyle Add
	Alpha 0.5
	Scale 0.1
	+clientsideonly
	Mass 5
	States
	{
	Spawn:
		LVLZ A 2 Bright A_FadeOut(0.04)
		LVLZ A 2 Bright A_FadeOut(0.1)
		LVLZ A 2 Bright A_FadeOut(0.1)
	fade:
		LVLZ D 2 Bright A_FadeOut(0.1)
		loop
	}
}

ACTOR LavaLazerEmber2
{
	Projectile
	+NOBLOCKMAP
	+ALLOWPARTICLES
	+RANDOMIZE
	+HEXENBOUNCE
	Gravity 0.4
	RenderStyle Add
	Alpha 0.5
	radius 6
	Scale 0.05
	Mass 5
	+clientsideonly
	States
	{
	Spawn:
		LVLZ A random(8,12) Bright
		TNT1 A 0 a_changeflag ("NOGRAVITY",0)
		LVLZ AAAAAAAAAAAAAAAAA 2 Bright A_FadeOut(0.04)
		Stop
	}
}


ACTOR LavaLazerExplosion
{
	+NOBLOCKMAP
	+NOGRAVITY
	+ALLOWPARTICLES
	+RANDOMIZE
	RenderStyle Add
	Alpha 0.6
	Scale 0.60
	Mass 5
	+clientsideonly
	States
	{
	Spawn:
		LVEX A 1 Bright 
		LVEX B 1 Bright 
	Fade:
		LVEX D 1 Bright
		LVEX E 1 Bright A_FadeOut(0.2)
		LVEX F 1 Bright A_FadeOut(0.2)
		LVEX G 1 Bright A_FadeOut(0.2)
		LVEX H 1 Bright A_FadeOut(0.2)
		LVEX I 1 Bright A_FadeOut(0.2)
		LVEX J 1 Bright A_FadeOut(0.2)
		LVEX K 1 Bright A_FadeOut(0.2)
		LVEX L 1 Bright A_FadeOut(0.2)
		LVEX M 1 Bright A_FadeOut(0.2)
	Fade2:
		LVEX M 1 Bright A_FadeOut(0.2)
		loop
	}
}



actor LavaLazerSmoke
{
    Radius 1
    Height 1
	Scale 0.10
	Alpha 0.1
    Projectile
    +NOCLIP
	+clientsideonly
    States
    {
	Spawn:
		TNT1 A 3
		SMOK ABCDEFGHIJKLMNOPQ 3 A_FadeIn(0.02)
		Stop
    }
}

actor LavaLazerSmoke2
{
    Radius 1
    Height 1
	Scale 0.20
	Alpha 0.6
    Projectile
	+clientsideonly
    +NOCLIP
    States
    {
	Spawn:
		TNT1 A 2
		SMOK ABCDEFGHIJKLMNOPQ 2 A_FadeOut(0.1)
		Stop
    }
}


actor ScopeActive : inventory
{inventory.maxamount 1}
