/*

==Synthesizer==
Originally a part of a staff, the gem that powers this
small underbarrel attachement is capable of converting 
the life forceof shot targets into raw arcane energy. 
Made by Alchemists with the intent on using them on the
demons, that plan went up in smoke when the
Alchemists were attacked before they had a chance
to use it. One old man fled to Lothar to leave it
with the lord and guardian there before he was
attacked as well. The device found its way into
Samson's hands for safekeeping. It didn't take long 
for Samson to repurpose the crystal into a more 
compact system and something he's more comfortable using.

The Synthesizer is capable of firing blasts of life draining
energy that charges the weapon's capacitor. As the charge builds,
the Synthesizer's shots grow weaker and lose range. But Samson
can turn the accumulated energy into Arcane gems to serve as 
catalyst for his other weapons, or even use it to heal himself
and his friends!

==FOSFOR==
The first weapon Samson ever made, cobbled together from
spare artifacts his grandfather had collected during his 
younger days while going on adventures as a bard. The 
Fosfor is a retracting flail with a gem tip that augments
kinetic force built up from being swung around before
releasing it violently.
*/

actor Synthesizer : weapon
{
	Weapon.SelectionOrder 800
	+WEAPON.AMMO_OPTIONAL
	Weapon.AmmoType "SynthCharge"
	+NOAUTOAIM
	Tag "Synthesizer and Whipshot"
	states
	{
	spawn:
		ESHT A -1
		stop
	select:
		TNT1 A 0
		TNT1 A 0
	draw:	
		TNT1 A 0
		KPST AAAA 0 A_Raise
		TNT1 A 0 A_JumpIfInventory ("KustamBarrel",1,"PickBarrel")
		B1TG G 1 A_Raise
		loop
	deselect: 
		TNT1 A 0
		TNT1 A 0 A_JumpIfHealthLower (1, "deadlower")
		TNT1 A 0 A_JumpIfInventory ("KustamBarrel",1,"PickBarrel")
		P1UP GFEDBA 2
	holster:
		TNT1 A 0
		TNT1 A 1 A_Lower
		TNT1 AA 0 A_Lower
		loop
	PickBarrel:
		TNT1 A 0
		TNT1 A 0 A_TakeInventory ("StartingCharge",99)
		TNT1 A 0 A_TakeInventory ("UsingKustamGun",999)
		TNT1 A 0 A_TakeInventory ("PistolPrep",999)
		TNT1 A 1 A_Lower 
		TNT1 AAAAAAAAAAA 0 A_Lower
		TNT1 A 1 A_SelectWeapon ("KustamBarrel")
		loop
	deadlower:
		TNT1 A 0
		TNT1 A 0
		TNT1 AAAAAAAAAAAAA 0 A_Lower
		TNT1 A 1 A_Lower
		wait		
	Ready:
		TNT1 A 0 
		P1UP ABCDEFGH 2 A_WeaponReady (WRF_ALLOWRELOAD|WRF_NOBOB)
		P1YN A 1 A_WeaponReady (WRF_ALLOWRELOAD|WRF_NOBOB)
		goto RealReady
	RealReady:
		P1YN A 1 A_WeaponReady (WRF_ALLOWRELOAD|WRF_NOBOB)
		loop
	Fire:
		TNT1 A 0
		TNT1 A 0 A_TakeInventory ("WhipshotReady",99)
		TNT1 A 0 A_JumpIfInventory ("SynthesizerReady",1,"SynthesizerFire")
		P1YN BCD 1
		goto SynthesizerFire
	SynthesizerFire:
		P1YN E 2
		TNT1 A 0 A_FireBullets (0,0,1,0,"flickpuff",FBF_NOFLASH)
		TNT1 A 0 A_FireBullets (2,3,20,0,"flickpuff",FBF_NOFLASH)
		TNT1 A 0 A_FireBullets (3,4,35,0,"flickpuff",FBF_NOFLASH)
		TNT1 A 0 a_playsound ("doomslayer/pistol",CHAN_WEAPON)
		TNT1 A 0 A_FireCustomMissile ("SapphireShot",random(-2,2),0,0,0,0,random(-1,1))
		P1YN FF 1
		TNT1 A 0 A_GiveInventory ("SynthesizerReady",1)
		P1YN E 40 A_WeaponReady (WRF_ALLOWRELOAD|WRF_ALLOWZOOM|WRF_NOBOB)
		TNT1 A 0 A_TakeInventory ("SynthesizerReady",99)
		P1YN DCBA 1
		goto realready
	Altfire:
		TNT1 A 0
		TNT1 A 0 A_TakeInventory ("SynthesizerReady",99)
		TNT1 A 0 A_JumpIfInventory ("WhipshotReady",1,"WhipshotFire")
		P2YN ABCD 1
		goto WhipshotFire
	WhipshotFire:
		P2YN E 2
		P2YN G 1 A_FireCustomMissile ("WhipWarhead")
		P2YN HG 1
	EmptyWhip:
		P2YN F 1
		TNT1 A 0 A_JumpIfInventory ("FiredWhipshot",1,"EmptyWhip")
		goto WhipReset
	WhipReset:
		TNT1 A 0
		TNT1 A 0 A_GiveInventory ("WhipshotReady",1)
		P2YN JKL 2 
		P2YN KLK 1 A_WeaponReady (WRF_ALLOWRELOAD|WRF_ALLOWZOOM|WRF_NOBOB)
		P2YN L 3 A_WeaponReady (WRF_ALLOWRELOAD|WRF_ALLOWZOOM|WRF_NOBOB)
		P2YN JIM 1 A_WeaponReady (WRF_ALLOWRELOAD|WRF_ALLOWZOOM|WRF_NOBOB)
		TNT1 A 0 A_GiveInventory ("WhipshotReady",1)
		P2YN M 40 A_WeaponReady (WRF_ALLOWRELOAD|WRF_ALLOWZOOM|WRF_NOBOB)
		TNT1 A 0 A_TakeInventory ("WhipshotReady",99)
		P2YN IJK 2
		P2YN DCBA 1
		Goto RealReady
	}
}




actor WhipWarhead : fastprojectile
{
	Projectile
	speed 70
	damage (10)
	obituary "%o was smashed by %k's staff."
	+BLOODSPLATTER
	+thruspecies
	+dontblast
	+bright
	+noblood
	+NOEXTREMEDEATH
	+DONTREFLECT
	species "friendly"
	height 10
	radius 10
	decal KustamStaff
	mass 1000000
	states
	{
	Spawn:
		WPCH B 5
		TNT1 A 1 A_TakeFromTarget ("FiredWhipshot",99)
		stop
	Death:
		TNT1 A 0
		TNT1 A 1 A_TakeFromTarget ("FiredWhipshot",99)
		TNT1 A 0 A_PlaySound("Kustam/KickMiss", 5)
		TNT1 A 0 A_PlaySound("Kustam/KickMiss", 6)
		TNT1 A 0 radius_quake (2,8,0,15,0)
		TNT1 A 5 
		stop
	Xdeath:
		TNT1 A 0
		TNT1 A 0 A_stop
		TNT1 A 0 A_TakeFromTarget ("FiredWhipshot",99)
		TNT1 A 0 A_PlaySound("Kustam/Staffhit", 5)
		TNT1 A 0 A_PlaySound("Kustam/Staffhit", 6)
		TNT1 A 0 A_PlaySound("Kustam/Staffhit", 7)
		TNT1 A 0 radius_quake (2,3,0,10,0)
		TNT1 A 0 A_stop
		KSPK BCDEFG 1
		stop
	}
}





actor FiredWhipshot : Powerup
{
  Powerup.Duration 25
}


actor SynthesizerReady : Powerup
{
  Powerup.Duration 38
}

actor WhipshotReady : Powerup
{
  Powerup.Duration 38
}
