
ACTOR SolarJetpack : Weapon
{
	Weapon.SelectionOrder 400
	Weapon.AmmoType "Clip"
	Weapon.AmmoUse 1
	Weapon.AmmoGive 20
	Weapon.SlotNumber 4
	weapon.bobstyle smooth
	weapon.bobrangex 0.1
	weapon.bobrangey 0.2
	weapon.bobspeed 1
	Inventory.PickupMessage "You picked up the Solar Jetpack and pistol!"
	Obituary "%k probably didn't look up to see %o shooting them."
	Inventory.RestrictedTo "Artificer"
	+WEAPON.AMMO_OPTIONAL
	+undroppable
	+cheatnotweapon
	+noautofire	
	Tag "Solar Jetpack and pistol"
	states
	{
	Select:
		TNT1 A 0
		TNT1 A 0
		TNT1 A 0 a_setgravity (0.35)
		TNT1 A 0 a_clearrefire
		TNT1 A 0 a_giveinventory ("EquippedJetpack",1)
		TNT1 A 0 a_spawnitemex ("SolarJetPacker",0,0,0,0,0,0,0,0)
		TNT1 A 1 a_gunflash ("ThrottleUp",GFF_NOEXTCHANGE)
	Riseup:
		D3UP AA 0 a_raise
		TNT1 A 0 a_clearrefire
		D3UP AAA 0 a_raise
		SLP1 A 1
		loop
	
	Ready:
		TNT1 A 0
		SLP1 A 1 a_weaponready (WRF_NOFIRE)
		goto PistolIdle
	PistolIdle:
		SLP1 A 1 a_weaponready (WRF_NOFIRE)
		TNT1 A 0 a_jumpifinventory ("ArtiSynthFireLeft",1, "FirstShotCheck")
		loop
	Deselect:
		TNT1 A 0
		TNT1 A 0 a_setgravity (1)
		TNT1 A 0 a_takeinventory ("EquippedJetpack",999)
		TNT1 A 0 a_jumpifhealthlower (1, "deadlower")
		TNT1 A 0 a_gunflash ("ThrottleDown",GFF_NOEXTCHANGE)
		SLP1 A 7
	holster:
		TNT1 A 0
		SLP1 A 1 a_lower
		TNT1 A 0 a_takeinventory ("EquippedJetpack",999)
		TNT1 AAA 0 a_lower
		SLP1 A 1 a_lower
		loop
	deadlower:
		TNT1 A 0
		TNT1 A 0
		TNT1 A 0 a_takeinventory ("EquippedJetpack",999)
		TNT1 AAAAAAAAAAAAA 0 a_lower
		TNT1 A 1 a_lower
		wait
	Fire:
		TNT1 A 0
		CTRA A 1 
		goto PistolIdle
	
	//Actually shooting the gun
	FirstShotCheck:
		SLP1 A 1
		TNT1 A 0 a_jumpifinventory ("Clip",1,"FirstShot")
		goto WeakShot
	FirstShot:
		SLP1 A 1
		TNT1 A 0 a_playsound ("SolarJetpack/Pistol",CHAN_WEAPON)
		TNT1 A 0 a_giveinventory ("SolarPistolFired",1)
		SLP1 B 1 bright a_firebullets (2,2,-1,random(6,15),"SolarShot",FBF_USEAMMO)
		TNT1 A 0 A_Quake(1, 4, 0, 32,"ArtiSilence")
		SLP1 CD 1
		TNT1 A 0 a_jumpifinventory ("ArtiSynthFireLeft",1, "MachineGuncheck")
		SLP1 E 1
		goto PistolIdle
	
	MachineGunCheck:
		SLP1 A 1
		TNT1 A 0 a_jumpifinventory ("Clip",1,"MachineGunning")
		goto WeakShot
	
	MachineGunning:
		TNT1 A 0
		TNT1 A 0 a_playsound ("SolarJetpack/Pistol",CHAN_WEAPON)
		TNT1 A 0 a_giveinventory ("SolarPistolFired",1)
		SLP1 B 1 bright a_firebullets (2,2,-1,random(6,15),"SolarShot",FBF_USEAMMO)
		TNT1 A 0 A_Quake(1, 4, 0, 32,"ArtiSilence")
		SLP1 CD 1
		TNT1 A 0 a_jumpifinventory ("ArtiSynthFireLeft",1, "MachineGuncheck")
		SLP1 E 1
		goto PistolIdle

	WeakShot:
		TNT1 A 0
		TNT1 A 0 a_playsound ("SolarJetpack/WeakShot",0)
		SLP1 B 1 bright A_FireCustomMissile("WeakSolarBullet",random(-3,3),0,-12,0,0,random(-3,3))
		SLP1 D 2
		SLP1 E 2 
		TNT1 A 0 a_jumpifinventory ("ArtiSynthFireLeft",1, "FirstShotCheck")
		SLP1 A 3 a_jumpifinventory ("ArtiSynthFireLeft",1, "FirstShotCheck")
		goto PistolIdle
		
	//FLASH STATES FOR THE THROTTLE
	ThrottleUp:
		"####" # 0
		SLT1 A 5
		"####" # 0 a_playsound ("SolarJetpack/Equip",0)
		SLT1 BCD 2
		goto IdleCheck
	ThrottleDown:
		"####" # 0
		SLT1 D 1
		"####" # 0 a_playsound ("SolarJetpack/Unequip",0)
		SLT1 EFG 2
		SLT1 A 1
		wait
	

	//The idle states
	//5 pips
	ThrottleWait1:
		"####" # 0
		SLT2 A 1 a_jumpifinventory ("ArtiSynthFireRight",1,"FuelCheck")
		goto idlecheck
	
	//4 pips
	ThrottleWait2:
		"####" # 0
		SLT2 C 1 a_jumpifinventory ("ArtiSynthFireRight",1,"FuelCheck")
		goto idlecheck

	//3 pips
	ThrottleWait3:
		"####" # 0
		SLT2 E 1 a_jumpifinventory ("ArtiSynthFireRight",1,"FuelCheck")
		goto idlecheck
	
	//2 pips
	ThrottleWait4:
		"####" # 0
		SLT2 G 1 a_jumpifinventory ("ArtiSynthFireRight",1,"FuelCheck")
		goto idlecheck


	//1 pip
	ThrottleWait5:
		"####" # 0
		SLT2 I 1 a_jumpifinventory ("ArtiSynthFireRight",1,"FuelCheck")
		goto idlecheck

	//Empty
	ThrottleWait6:
		"####" # 0
		"####" # 0 a_jumpifinventory ("SolarFuel",1,"IdleCheck")
		SLT2 K 10 a_jumpifinventory ("SolarFuel",1,"IdleCheck")
		"####" # 0 a_jumpifinventory ("SolarFuel",1,"IdleCheck")
		goto AltThrottleWait6
	AltThrottleWait6:
		"####" # 0
		"####" # 0 a_jumpifinventory ("SolarFuel",1,"IdleCheck")
		SLT2 P 10 a_jumpifinventory ("SolarFuel",1,"IdleCheck")
		"####" # 0 a_jumpifinventory ("SolarFuel",1,"IdleCheck")
		goto ThrottleWait6


	FuelCheck:
		"####" # 0
		"####" # 0
		"####" # 0 a_jumpifinventory ("SolarFuel",81,"Jetpack1")
		"####" # 0 a_jumpifinventory ("SolarFuel",61,"Jetpack2")
		"####" # 0 a_jumpifinventory ("SolarFuel",41,"Jetpack3")
		"####" # 0 a_jumpifinventory ("SolarFuel",21,"Jetpack4")
		"####" # 1 a_jumpifinventory ("SolarFuel",1,"Jetpack5")
		goto ThrottleWait6
	
	
	
	//5 Pips
	JetPack1:
		SLT2 A 1 thrustthingz (0,3,0,1)
		"####" # 0 a_spawnitemex ("SolarFlames",-8,0,8,0,0,0,0,0)
		"####" # 0 a_giveinventory ("JetsFired",1)
		"####" # 0 a_playsound ("SolarJetpack/Jets",6)
		"####" # 0 A_Quake(1, 5, 0, 32,"ArtiSilence")
		"####" # 0 thrustthingz (0,3,0,1)
		"####" # 0 a_takeinventory ("SolarFuel",1)
		SLT2 BB 1 
		"####" # 0 a_jumpifinventory ("ArtiSynthFireRight",1,"FuelCheck")
		goto IdleCheck
	
	//4 Pips
	JetPack2:
		SLT2 C 1 thrustthingz (0,3,0,1)
		"####" # 0 a_spawnitemex ("SolarFlames",-8,0,8,0,0,0,0,0)
		"####" # 0 a_giveinventory ("JetsFired",1)
		"####" # 0 a_playsound ("SolarJetpack/Jets",6)
		"####" # 0 A_Quake(1, 5, 0, 32,"ArtiSilence")
		"####" # 0 thrustthingz (0,3,0,1)
		"####" # 0 a_takeinventory ("SolarFuel",1)
		SLT2 DD 1 
		"####" # 0 a_jumpifinventory ("ArtiSynthFireRight",1,"FuelCheck")
		goto IdleCheck

	//3 Pips
	JetPack3:
		SLT2 E 1 thrustthingz (0,3,0,1)
		"####" # 0 a_spawnitemex ("SolarFlames",-8,0,8,0,0,0,0,0)
		"####" # 0 a_giveinventory ("JetsFired",1)
		"####" # 0 a_playsound ("SolarJetpack/Jets",6)
		"####" # 0 A_Quake(1, 5, 0, 32,"ArtiSilence")
		"####" # 0 thrustthingz (0,3,0,1)
		"####" # 0 a_takeinventory ("SolarFuel",1)
		SLT2 FF 1 
		"####" # 0 a_jumpifinventory ("ArtiSynthFireRight",1,"FuelCheck")
		goto IdleCheck

	//2 Pips
	JetPack4:
		"####" # 0 
		SLT2 L 1 thrustthingz (0,3,0,1)
		"####" # 0 a_spawnitemex ("SolarFlames",-8,0,8,0,0,0,0,0)
		"####" # 0 a_giveinventory ("JetsFired",1)
		"####" # 0 a_playsound ("SolarJetpack/Jets",6)
		"####" # 0 A_Quake(1, 5, 0, 32,"ArtiSilence")
		"####" # 0 thrustthingz (0,3,0,1)
		"####" # 0 a_takeinventory ("SolarFuel",1)
		SLT2 MM 1 
		"####" # 0 a_jumpifinventory ("ArtiSynthFireRight",1,"FuelCheck")
		goto IdleCheck

	//1 Pip
	JetPack5:
		"####" # 0 
		SLT2 N 1 thrustthingz (0,3,0,1)
		"####" # 0 a_spawnitemex ("SolarFlames",-8,0,8,0,0,0,0,0)
		"####" # 0 a_giveinventory ("JetsFired",1)
		"####" # 0 a_playsound ("SolarJetpack/Jets",6)
		"####" # 0 A_Quake(1, 5, 0, 32,"ArtiSilence")
		"####" # 0 thrustthingz (0,3,0,1)
		"####" # 0 a_takeinventory ("SolarFuel",1)
		SLT2 OO 1 
		"####" # 0 a_jumpifinventory ("ArtiSynthFireRight",1,"FuelCheck")
		goto IdleCheck

		
	IdleCheck:
		"####" # 0
		"####" # 0
		"####" # 0 a_jumpifinventory ("SolarFuel",81,"ThrottleWait1")
		"####" # 0 a_jumpifinventory ("SolarFuel",61,"ThrottleWait2")
		"####" # 0 a_jumpifinventory ("SolarFuel",41,"ThrottleWait3")
		"####" # 0 a_jumpifinventory ("SolarFuel",21,"ThrottleWait4")
		"####" # 1 a_jumpifinventory ("SolarFuel",1,"ThrottleWait5")
		goto ThrottleWait6

	}
}


ACTOR SolarShot : BulletPuff
{
	+NOBLOCKMAP
	+NOGRAVITY
	+ALLOWPARTICLES
	+RANDOMIZE
	+thruspecies
	+MTHRUSPECIES
	+puffonactors
	+bright
	+NOEXTREMEDEATH
	species "Player"
	RenderStyle Translucent
	Alpha 0.8
	VSpeed 0
	scale 2
	Mass 5
	Decal SmallArtiDecal
	States
	{
	Spawn:
        TNT1 A 0
		RSPK A 2 
	Xdeath:
		TNT1 A 0
		TNT1 A 0 a_playsound ("SolarJetpack/SolarHit",0)
		RSPK BCDE 1
		RSPK E 1 a_setscale (2.8,2.8)
		stop
	crash:
		RSPK AAFG 1
		RSPK G 1 a_setscale (2.3,2.3)
		RSPK G 1 a_setscale (2.8,2.8)
		stop
	}
}


actor SolarJetpacker
{
	Scale 1.4
	Height 0
	Radius 0
	+NOINTERACTION
	+CLIENTSIDEONLY
	-SOLID
	+NOGRAVITY
	+MISSILE
	+DONTBLAST
	States
	{
	Spawn:
		SLJP A 1 A_Warp(AAPTR_TARGET, -15, 0, 10, 0, WARPF_INTERPOLATE|WARPF_NOCHECKPOSITION)
		TNT1 A 0 a_jumpifInventory ("EquippedJetpack",1,"Spawn",AAPTR_TARGET)
		goto death
	Death:
		TNT1 A 0
		TNT1 A 1
		stop
	}
}

actor SolarFlames : SolarJetPacker
{
	+BRIGHT
	states
	{
	Spawn:
		SLJP BCB 1 A_Warp(AAPTR_TARGET, -15, 0, 8, 0, WARPF_INTERPOLATE|WARPF_NOCHECKPOSITION)
		goto death
	death:
		TNT1 A 0 
		TNT1 A 1 
		stop
	}
}

actor WeakSolarBullet
{
	+notimefreeze
	+FORCEXYBILLBOARD	
	+thruspecies	
	+dontblast
	+bright
	Projectile
	damage (8)
	species "Player"
	speed 40
	height 12
	radius 12
    Scale 1
	+BLOODSPLATTER
	+NOEXTREMEDEATH
	Decal SmallArtiDecal
	states
	{
	Spawn:
		RSPK A 1
		loop
	Death:
		TNT1 A 0
		TNT1 A 1
		TNT1 A 0 A_JumpIf(floorz == z, "FloorHit")
		TNT1 A 0 a_playsound ("SolarJetpack/WeakMiss",0)
		TNT1 A 1 a_spawnitemex ("SolarRicochet",0,0,0,0,Random(-8,8),random(-8,8),0,SXF_NOCHECKPOSITION)
		stop
	FloorHit:
		TNT1 A 0 a_playsound ("SolarJetpack/WeakMiss",0)
		TNT1 A 1 a_spawnitemex ("SolarRicochet",0,0,0,Random(-8,8),Random(-8,8),random(9,12),0,SXF_NOCHECKPOSITION)
		stop		
	Xdeath:
		TNT1 A 0
		TNT1 A 0 a_playsound ("SolarJetpack/SolarHit",0)
		RSPK BCDE 1
		RSPK E 1 a_setscale (2.8,2.8)
		stop		
	}
}


Actor SolarRicochet
{
	projectile
	+dontblast
	+notimefreeze
	+THRUACTORS
	+clientsideonly
    +FORCEXYBILLBOARD	
	+LOOKALLAROUND
	+Bright
	+NOCLIP
	+thruspecies
	+hexenbounce
	species "Player"
	radius 2
	speed 3
    Scale 1
	reactiontime 10
	states
	{
	Spawn:
		TNT1 A 0
		TNT1 A 0 a_jump (100, "Resize1","Resize2","Resize3")
	Resize1:
		TNT1 A 0
		TNT1 A 0 a_setscale (0.7,0.7)
		goto Flight
	Resize2:
		TNT1 A 0
		TNT1 A 0 a_setscale (0.5,0.5)
		goto Flight
	Resize3:
		TNT1 A 0
		TNT1 A 0 a_setscale (0.3,0.3)
		goto Flight
	Flight:
		RSPK ACBCA 1
		TNT1 A 0 a_countdown
		loop
	death:
		TNT1 A 0
		TNT1 A 1
		stop
	}
}



//Tokens



Actor JetsFired : Powerup
{
  Powerup.Duration -6
}

Actor SolarPistolFired : Powerup
{
  Powerup.Duration 10
}


actor SolarFuel : inventory
{inventory.maxamount 100}

actor ArtiSynthFireLeft : inventory
{inventory.maxamount 1}

actor ArtiSynthFireRight : inventory
{inventory.maxamount 1}

actor EquippedJetpack : inventory
{inventory.maxamount 1}
