/*

==ICARUS LAUNCHER==
Brought into this world due to clumsier Marines blowing themselves 
up from careless rocket usage, the Icarus Launcher is a rapid
missile launcher that fires miniture rockets that not only home 
in on targets, they also rebound off walls. The homing feature
can be disabled with the launcher's altfire attack, firing a fan like
spread of rebounding missiles.

Alongside this, the rockets are programmed to not injure 
friendlies upon detonation. Making this weapon genuinely idiot proof.

*/

actor Icarustoken : custominventory
{
	+notimefreeze
	scale 1
	Inventory.PickupSound "brickbook/pickup"
	Inventory.PickupMessage "You got the Icarus Launcher!"
	states
	{
	spawn:
		ICRP A 8 bright
		ICRP A 5
		loop
	pickup:
		TNT1 A 0
		TNT1 A 0 a_jumpifinventory ("RevenantBox", 1, "dropboner")
		TNT1 A 0 a_jumpifinventory ("SKpistol", 1, "droppistol")
		TNT1 A 0 a_jumpifinventory ("Tsbrick", 1, "dropbrick")
		TNT1 A 0 a_jumpifinventory ("ParticleSmasher", 1, "dropsmasher")
		TNT1 A 0 a_giveinventory ("IcarusLauncher", 1)
		stop
	dropbrick:
		TNT1 A 0
		TNT1 A 0 a_spawnitemex ("DroppedBrick",1,0,15,random (-3,-6),0,random(2,4),0,SXF_NOCHECKPOSITION)
		TNT1 A 0 a_takeinventory ("tsbrick", 1)
		TNT1 A 0 a_giveinventory ("IcarusLauncher", 1)
		stop
	dropsmasher:
		TNT1 A 0
		TNT1 A 0 a_spawnitemex ("DroppedSmasher",1,0,15,random (-3,-6),0,random(2,4),0,SXF_NOCHECKPOSITION)
		TNT1 A 0 a_takeinventory ("Particlesmasher", 1)
		TNT1 A 0 a_giveinventory ("IcarusLauncher", 1)
		stop
	DropPistol:
		TNT1 A 0 
		TNT1 A 0 a_spawnitemex ("DroppedPistol",1,0,15,random (-3,-6),0,random(2,4),0,SXF_NOCHECKPOSITION)
		TNT1 A 0 a_takeinventory ("SKPistol", 1)
		TNT1 A 0 a_giveinventory ("IcarusLauncher", 1)
		stop
	dropboner:
		TNT1 A 0
		TNT1 A 0 a_spawnitemex ("DroppedBoner",1,0,15,random (-3,-6),0,random(2,4),0,SXF_NOCHECKPOSITION)
		TNT1 A 0 a_takeinventory ("RevenantBox", 1)
		TNT1 A 0 a_giveinventory ("IcarusLauncher", 1)
		stop
	}
}

actor DroppedIcarus
{
	+notimefreeze
	+dropped
	renderstyle ADD
	alpha 0.50
	states
	{
	spawn:
		ICRP A 60
		goto death
	death:
		TNT1 A 0
		TNT1 A 0 a_spawnitemex ("IcarusToken")
		stop
	}
}

actor IcarusLauncher : weapon
{
	Weapon.SelectionOrder 20
	Weapon.AmmoUse 1
	weapon.ammouse2 1
	Weapon.AmmoType1 "CrateEnergy"
	Weapon.AmmoType2 "CrateEnergy"
	scale 1
	+WEAPON.AMMO_OPTIONAL
	+cheatnotweapon
	+WEAPON.ALT_AMMO_OPTIONAL
	+NOAUTOAIM
	+INVENTORY.UNTOSSABLE
	weapon.bobstyle smooth
	weapon.bobrangex 0.1
	weapon.bobrangey 0.6
	weapon.bobspeed 2
	Obituary "%k Lives to blast apart %o."
	Tag "Icarus Launcher"
	states
	{
	spawn:
		ICRP A 1
		loop
	select:
		TNT1 A 0
		TNT1 A 0 a_stopsound (CHAN_WEAPON)
		TNT1 A 0 a_stopsound (6)
		TNT1 A 0 a_playsound ("Icarus/draw",0)
		TNT1 A 0 a_jumpifinventory ("IAmTechMonk",1,"VisorSwap")
		Goto Draw
	VisorSwap:
		TNT1 A 0
		TNT1 A 0 a_takeinventory ("ArtiPainTimer",9999)
		TNT1 A 0 a_giveinventory ("CrateWeaponArmed",1)
		TNT1 A 0 a_giveinventory ("ArtiPainTimer",40)
	draw:	
		TNT1 A 0
		ICRE AAAA 0 A_Raise
		ICRE A 1 A_Raise
		loop
	deselect:
		TNT1 A 0
		TNT1 A 0 a_jumpifhealthlower (1, "deadlower")
		TNT1 A 0 a_playsound ("Icarus/lower",0)
		ICRE DBA 1
	holster:
		TNT1 A 0
		TNT1 A 0 a_stopsound (6)
		TNT1 A 0 a_jumpifinventory ("IAmTechMonk",1,"VisorSwapAway")
		Goto Lowering
	VisorSwapAway:
		TNT1 A 0
		TNT1 A 0 a_takeinventory ("ArtiPainTimer",9999)
		TNT1 A 0 a_giveinventory ("ArtiPainTimer",40)
	Lowering:
		ICRE A 1 a_lower
		TNT1 A 0 a_takeinventory ("secretaction", 99)
		TNT1 AA 0 a_lower
		loop
	deadlower:
		TNT1 A 0
		TNT1 A 0
		TNT1 A 0 a_stopsound (6)
		TNT1 AAAAAAAAAAAAA 0 a_lower
		TNT1 A 1 a_lower
		wait		
	Ready:
		ICRE BBCCDEEF 1 A_WeaponReady
		ICUS A 1 A_WeaponReady 
		goto realready
	realready:
		TNT1 A 0
		TNT1 A 0 a_jumpifinventory ("SecretAction",1,"FakeReload")
		ICUS A 1 A_WeaponReady
		TNT1 A 0 a_jumpifinventory ("SecretAction",1,"FakeReload")
		loop
	fire:
		ICUS A 1 a_jumpifinventory ("CrateEnergy",1,"Primary")
		ICUS A 20 a_playsound ("bustercarbine/dryfire",0)
		goto Realready
	primary:
		TNT1 A 0
		TNT1 A 0 a_playsound ("Icarus/Missile",CHAN_WEAPON)
		TNT1 A 0  A_Quake(1, 8, 0, 32)
		ICUS B 1 bright a_firecustommissile ("BabbyRocket",Frandom(1, -1),1,0,0,0,Frandom(1, -1))
		ICUS DE 1 bright
		ICUS F 1 a_weaponready
		goto realready
	altfire:
		ICUS A 1 a_jumpifinventory ("CrateEnergy",5,"SpreadShot")
		ICUS A 20 a_playsound ("bustercarbine/dryfire",0)
		goto realready
	SpreadShot:
		TNT1 A 0
		TNT1 A 0 a_playsound ("Icarus/draw",0)
		ICUS G 3
		ICUS H 3
		TNT1 A 0 a_playsound ("Icarus/SpreadShot",CHAN_WEAPON)
		TNT1 A 0 a_firecustommissile ("SpreadBabbyRocket",-10,1)
		TNT1 A 0 a_firecustommissile ("SpreadBabbyRocket",-5,1)
		TNT1 A 0 a_firecustommissile ("SpreadBabbyRocket",0,1)
		TNT1 A 0 a_firecustommissile ("SpreadBabbyRocket",5,1)
		TNT1 A 0 a_firecustommissile ("SpreadBabbyRocket",10,1)
		TNT1 A 0  A_Quake(3, 10, 0, 32)
		ICUS IJ 2 bright
		ICUS K 2 bright offset (0,40)
		ICUS L 2 bright offset (0,38)
		ICUS M 2 bright offset (0,36)
		ICUS H 3 offset (0,32)
		ICUS H 3 
		ICUS G 2
		ICUS A 2 a_weaponready
		goto realready
	FakeReload:
		ICRL ABC 2
		ICRL C 3
		TNT1 A 0 a_playsound ("Icarus/Open",0)
		ICRL DE 2
		ICRL E 1 offset (0,36)
		ICRL F 1 offset (0,34)
		ICRL G 1 offset (0,32)
	Loadan:
		ICRL HIJK 2
		TNT1 A 0 a_playsound ("Icarus/Load",0)
		ICRL L 1 offset (0,34)
		ICRL M 1 offset (0,32)
		ICRL NO 1 
		ICRL G 2 
		ICRL HIJK 2
		TNT1 A 0 a_playsound ("Icarus/Load",0)
		ICRL L 1 offset (0,34)
		ICRL M 1 offset (0,32)
		ICRL NO 1 
		ICRL HIJK 2
		TNT1 A 0 a_playsound ("Icarus/Load",0)
		ICRL L 1 offset (0,34)
		ICRL M 1 offset (0,32)
		ICRL NO 1 
		TNT1 A 0 a_jumpifinventory ("SecretAction",1,"Loadan")
		ICRL P 4
		TNT1 A 0 a_playsound ("Icarus/Close",0)
		ICRL Q 1
		ICUS A 2
		ICRL Q 2
		ICUS A 1 a_weaponready 
		goto realready
	}
}



actor BabbyRocket
{
	+notimefreeze
	projectile
	+THRUSPECIES
	species "Player"
	+dontblast
	+FORCEXYBILLBOARD	
	+LOOKALLAROUND
	+SEEKERMISSILE
	height 12
	radius 5
	speed 45
	damage (100)
	Projectile
	scale 0.80
	+SKYEXPLODE
	+bright
	+hexenbounce
	Bouncecount 4
	Seesound "Icarus/Bounce"
	decal DoomimpScorch
	states
	{
	spawn:
		TNT1 A 0
		TNT1 A 0 A_PlaySound("silence", CHAN_VOICE)
		HMSL A 1 a_playsound ("Icarus/Woosh",0,1,0,0.80)
		HMSL A 1  
		goto SeekingLoop
	SeekingLoop:
		HMSL A 1 a_spawnitemex ("Missilefire",Frandom(-15,-10),Frandom(-1,1),Frandom(-3,3),Frandom(-200,200)/80.0,Frandom(-200,200)/80.0,Frandom(-200,200)/80.0,0,160)
		HMSL A 1 
		TNT1 A 0 A_SeekerMissile(90,90,SMF_LOOK|SMF_PRECISE|SMF_CURSPEED,240)
		loop
	death:
		TNT1 A 0
		TNT1 A 0 a_explode (20,80,0,0,60)
		TNT1 AAAAA 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("SmolLavaLazerExplosion")
		TNT1 A 0 a_playsound ("Cyclops/rocketboom",0,0.90,0,0.90)
		TNT1 AAAAAA 0 Bright A_SpawnItemEx("LavaLazerTrail",frandom(-21,21),frandom(-21,21),frandom(-21,21),frandom(-1,1),frandom(-1,1),frandom(0,1))
		TNT1 AAAA 0 Bright A_SpawnItemEx("LavaLazerSmoke2",frandom(-8,8),frandom(-8,8),frandom(-4,4),frandom(-1,1),frandom(-1,1),frandom(0,1))
		TNT1 AAA 0 Bright A_SpawnItemEx("LavaLazerSmoke",frandom(-8,8),frandom(-8,8),frandom(-4,4),0,0,frandom(1,2))
		TNT1 A 3
		stop
	}
}

actor SpreadBabbyRocket : BabbyRocket
{
	-seekermissile
	states
	{
	spawn:
		TNT1 A 0
		TNT1 A 0 A_PlaySound("silence", CHAN_VOICE)
		HMSL A 1 a_playsound ("Icarus/Woosh",0,1,0,0.80)
		HMSL A 1  
		goto FlightLoop
	FlightLoop:
		HMSL A 1 a_spawnitemex ("Missilefire",Frandom(-15,-10),Frandom(-1,1),Frandom(-3,3),Frandom(-200,200)/80.0,Frandom(-200,200)/80.0,Frandom(-200,200)/80.0,0,160)
		HMSL A 1 
		loop
	}
}


ACTOR SmolLavaLazerExplosion : LavaLazerExplosion
{
	+NOBLOCKMAP
	+NOGRAVITY
	+ALLOWPARTICLES
	+RANDOMIZE
	RenderStyle Add
	Alpha 0.70
	Scale 0.50
	Mass 5
	+clientsideonly
}


