ACTOR FlareGun : Weapon
{
	+NOALERT
	+AMMO_OPTIONAL
	+NOAUTOFIRE
	+cheatnotweapon
	//+STRIFEDAMAGE
	Weapon.SelectionOrder 20
	Inventory.PickupSound "ZTweapons/flareclose"
	Inventory.PickupMessage "You got the ZT Prototype flare gun!"
	Weapon.AmmoType "FlareInClip"
	Weapon.AmmoGive 2
	Weapon.Kickback 100
	AttackSound "ZTweapons/flarefire"
	States
	{
	Spawn:
		FLRP A 15
		FLRP A 4 bright
		Loop
	select:
		TNT1 A 0
		FLRR AAAAAA 0 a_raise
		FLRR AAAAAAA 0 a_raise
		FLRR U 1 
		FLRG K 1 A_PlaySound("ZTweapons/flareclose")
		FLRG JIHGFEDCB 1 
		FLRG A 1 A_WeaponReady
		goto ready
	Deselect:
		TNT1 A 0
		FLRG B 1 A_PlaySound("ZTweapons/holster")
		FLRD ABCD 1
	holster:
		TNT1 A 0
		FLRG A 0 A_Lower
		FLRG AA 0 A_lower
		loop
	ready:
		FLRG A 1 A_weaponready
		Loop
	Fire:
		FLRG A 0 A_JumpIfInventory("FlareInClip", 1, "truefire")
		FLRG A 1 A_PlaySound("ZTweapons/flakdry")
		goto Ready
	TrueFire:
		FLRG A 0 A_GunFlash
		FLRG A 0 A_TakeInventory("FlareInClip",1)
		FLRG A 0 BRIGHT A_FireCustomMissile("FlareProjectile", 0, 0, 0, 0)   
		FLRF AB 1 BRIGHT
		FLRF C 1
		goto Ready
	AltFire:
		TNT1 A 0
		FLRG A 1 A_JumpIfInventory("FlareInClip", 1, "noreload")
		goto flarereload
	noreload:
		TNT1 A 0
		FLRG A 1 
		goto ready
	flarereload:
		TNT1 A 0
		FLRG A 1 A_PlaySound("ZTweapons/flareclick")
		FLRG FGHIJK 1
		FLRR A 1 A_PlaySound("ZTweapons/flareopen")
		FLRR B 1
		FLRR C 1
		FLRR DEFGHIJ 1   
		FLRR K 0 A_GiveInventory("FlareInClip",2)
		FLRR K 1 A_PlaySound("ZTweapons/flareload")
		FLRR LMNOPQRSTU 1
		FLRG K 1 A_PlaySound("ZTweapons/flareclose")
		FLRG JIHGF 1 
		goto Ready
	Flash:    
		TNT1 A 0
		TNT1 A 0 BRIGHT A_FireCustomMissile("ShotSmokeSpawner",0,0,0)
		TNT1 A 2 BRIGHT A_Light2
		TNT1 A 2 BRIGHT A_Light1
		TNT1 A 1 BRIGHT A_Light0
		Stop
	}
}

ACTOR FlareInClip : Ammo
{
   - INVBAR
   Inventory.MaxAmount 2
   Inventory.Icon FLRAA0
   States
   {
   Spawn:
      TNT1 A 4
      loop
   }
}

ACTOR FlareProjectile : Rocket
{ 
    Damage 18
    Speed 40
    - NOGRAVITY
    - ROCKETTRAIL
	+thruspecies
	species "player"
	SeeSound "ZTweapons/flarefire"
    DeathSound "ZTweapons/flareexplode"
	Obituary "%o was gratuitously flared by %k."
	HitObituary "%o took %k's flare to the face."
    States
    {
    Spawn:
		FLAR A 1 BRIGHT A_CustomMissile("FlareTrail",0,0,0)
		Loop
	Death:
		TNT1 A 0
		FLXP Z 0 BRIGHT A_CustomMissile("FlareExplode",0,0,0)
		FLXP Z 0 BRIGHT A_Explode (24, 65)
		FLXP ZZ 0 BRIGHT A_SpawnDebris("BulletSpark")
		FLXP ZZ 0 BRIGHT A_SpawnDebris("FlareCluster")
		FLXP ZZ 0 BRIGHT A_SpawnDebris("FlareCluster2")
		Stop
    }
    
}


actor flareguntoken : custominventory
{
	+notimefreeze
	Inventory.PickupSound "ZTweapons/flareclose"
	Inventory.PickupMessage "You got the ZT Prototype flare gun!"
	states
	{
	spawn:
		FLRP A 8 bright
		FLRP A 5 
		Loop
	pickup:
		TNT1 A 0
		TNT1 A 0 a_jumpifinventory ("tsbrick", 1, "dropbrick")
		TNT1 A 0 a_jumpifinventory ("havocrebounder", 1, "droprebounder")
		TNT1 A 0 a_giveinventory ("flaregun", 1)
		stop
	dropbrick:
		TNT1 A 0
		TNT1 A 0 a_spawnitemex ("droppedbrick", 1)
		TNT1 A 0 a_takeinventory ("TSbrick", 1)
		TNT1 A 0 a_giveinventory ("flaregun", 1)
		stop
	droprebounder:
		TNT1 A 0
		TNT1 A 0 a_spawnitemex ("droppedrebounder", 1)
		TNT1 A 0 a_takeinventory ("havocrebounder", 1)
		TNT1 A 0 a_giveinventory ("flaregun", 1)
		stop
	}
}

actor droppedflare
{
	+notimefreeze
	renderstyle ADD
	alpha 0.50
	states
	{
	spawn:
		FLRP A 60
		goto death
	death:
		TNT1 A 0
		TNT1 A 0 a_spawnitemex ("flareguntoken")
		stop
	}
}

		

ACTOR BulletSpark
{
	Health 4
	radius 3
	height 6
	speed .1
	RenderStyle ADD
	Alpha	1
	Scale	.032
	Mass	0
	+missile
	+doombounce
	+FLOORCLIP
	+DONTSPLASH
	+NOTELEPORT
	+FORCEXYBILLBOARD
	States
	{
		BPUF A 1
		BPUF ABCDA 1  Bright A_SetTranslucent(.8,1)
		BPUF BCDABC 1  Bright A_SetTranslucent(.6,1)
		BPUF DABCDABC 1  Bright A_SetTranslucent(.4,1)
		BPUF DABCDABCDA 1 Bright A_SetTranslucent(.2,1)
		Stop
	}
}


ACTOR FlareExplode : PlasmaBall
{ 
    Alpha 0.75
    Scale 0.5
    Damage 0
    Speed 0
    + NOCLIP
    SeeSound ""
    DeathSound ""
    States
    {
    Spawn:
      FLXP ABCDEFGHIJKLMNOPQRSTUVWXYZ 1 BRIGHT
      Stop
    }
}

ACTOR FlareTrail : PlasmaBall replaces RevenantTracerSmoke
{ 
    Alpha 0.75
    Damage 0
    Speed 0
    + NOCLIP
    +FORCEXYBILLBOARD
    SeeSound ""
    DeathSound ""
    States
    {
    Spawn:
      FLAR A 0 BRIGHT
      FLAR B 2 BRIGHT A_CustomMissile("FlareSmoke",0,0,0)
      FLAR CDEFGH 2 BRIGHT
      Stop
    }
}

ACTOR FlareSmoke : BulletPuff
{ 
    Renderstyle Add
    Scale 0.2
    Alpha 0.5
    Damage 0
    Speed 0
    + NOCLIP
    +FORCEXYBILLBOARD
    States
    {
    Spawn:
      SMOK ABCDEFGHIJKLMNOPQ 1 BRIGHT
      Stop
    }
}

ACTOR FlareCluster : BulletSpark
{
	Damage 2
	speed .5
	Scale		.1
	States
	{
		BPUF A 1
		BPUF ABCDA 1  Bright A_SetTranslucent(.8,1)
		BPUF BCDABC 1  Bright A_SetTranslucent(.6,1)
		BPUF DABCDABC 1  Bright A_SetTranslucent(.4,1)
		BPUF DABCDABCDA 1 Bright A_SetTranslucent(.2,1)
		Stop
	}
}

ACTOR FlareCluster2 : BulletSpark
{
	Damage 2
	speed .5
	Scale .1
	States
	{
		BPUF A 1
		BPUF ABCDA 1  Bright A_SetTranslucent(.8,1)
		BPUF BCDABC 1  Bright A_SetTranslucent(.6,1)
		BPUF DABCDABC 1  Bright A_SetTranslucent(.4,1)
		BPUF DABCDABCDA 1 Bright A_SetTranslucent(.2,1)
		Stop
	}
}


ACTOR ShotSmokeSpawner
{
    Radius 1
    Height 1
    Speed 25
    PROJECTILE
    States
    {
    Spawn:
        TNT1 A 1
        TNT1 A 0 A_Die
        Goto Death
    Death:
        TNT1 A 0 A_CustomMissile("ShotSmoke",-2,0,0)
        Stop
    }
}

ACTOR ShotSmoke
{
	Radius		1
	Height		1
	RenderStyle ADD
	Alpha		.6
	Scale		.15
	+NOGRAVITY
	+NOBLOCKMAP
	+FLOORCLIP
	+FORCEXYBILLBOARD
	States
	{
	Spawn:
		SMOK ABCDEFGHIJKLMNOPQ 1 
		Stop
	}
}
