/*
===SECOND WIND===

The second wind blaster pistol is the Artificer's original sidearm. 
Rediscovered and retiring the Genka-12 pistol, this weapon is capable 
of using standard ballistic ammunition found around and converted into 
caseless ammunition through his armor. This weapon doesn't have a mag 
generator like the Genka-12, so running out of ammo is now a possibility, 
on the plus side, these bullets travel at a higher velocity.

Though if ammunition is drained, the Second Wind features a backup blaster 
mode with a built in fast charge generator, sending out projectile energy bolts,
though it's nowhere near as effective as ballistic ammo, 
it means it'll always be at the Artificer's side.

As a secondary fire, the blaster can overcharge itself and fire a razor sharp
blade of pure energy, cleaving through targets and their projectiles they may
fire, this puts the weapon into an emergency recharge however, leaving Arti
unable to fire for a short time while it recharges.

There's a secret that has yet to be unveiled with this pistol
*/

ACTOR SecondWind : Weapon
{
	Weapon.SelectionOrder 60
	Weapon.AmmoUse 1
	weapon.ammouse2 1
	Weapon.AmmoGive2 12
	Weapon.AmmoType "Clip"
	Weapon.SlotNumber 2
	weapon.bobstyle smooth
	weapon.bobrangex 0.1
	weapon.bobrangey 0.6
	weapon.bobspeed 2
	Inventory.PickupMessage "You recovered the Second Wind!"
	Obituary "%k tapped %o to death."
	Inventory.RestrictedTo "Artificer"
	+WEAPON.AMMO_OPTIONAL
	+WEAPON.ALT_AMMO_OPTIONAL
	+undroppable
	+cheatnotweapon
	+noautofire
	+NOAUTOAIM
	Tag "Second Wind"
	states
	{
	Select:
		TNT1 A 0
		TNT1 A 0 a_playsound ("D3Pistol/draw",0)
		D3UP G 0 a_playsound ("SecondWind/Raise",0)
		TNT1 A 0 a_jumpifinventory ("SecondWindHeat",1,"LockedRaise")
	Riseup:
		D3UP AA 0 a_raise
		D3UP AAAAA 0 a_raise
		2WND A 1
		loop
	LockedRaise:
		D3UP AA 0 a_raise
		D3UP AAAAA 0 a_raise
		2WPS I 1
		loop
	
	Ready:
		TNT1 A 0
		TNT1 A 0 a_jumpifinventory ("SecondWindHeat",1,"Recharging")
		2WND A 1 a_weaponready
		loop
	Deselect:
		TNT1 A 0
		TNT1 A 0 a_jumpifhealthlower (1, "deadlower")
		TNT1 A 0 a_jumpifinventory ("SecondWindHeat",1,"LockedLower")
		TNT1 A 0 a_playsound ("D3pistol/holster", 0)
	holster:
		TNT1 A 0
		2WND A 1 a_lower
		TNT1 A 0 a_takeinventory ("secretaction", 99)
		TNT1 AAA 0 a_lower
		2WND A 1 a_lower
		loop
	LockedLower:
		TNT1 A 0
		2WPS I 1 a_lower
		TNT1 A 0 a_takeinventory ("secretaction", 99)
		TNT1 AAA 0 a_lower
		2WPS I 1 a_lower
		loop

	deadlower:
		TNT1 A 0
		TNT1 A 0
		TNT1 AAAAAAAAAAAAA 0 a_lower
		TNT1 A 1 a_lower
		wait	
	Fire:
		TNT1 A 0
		TNT1 A 0
		TNT1 A 0 a_jumpifinventory ("Clip",1,"normalshot")
		goto BackupShot
	Normalshot:
		TNT1 A 0
		TNT1 A 0 a_jumpifinventory ("SecondWindSpread",1,"NormalSpread")
		D3PS B 0 A_firebullets (0,0,1,15,"SecondWindShot", FBF_USEAMMO|FBF_NORANDOM)
		TNT1 A 0 A_Quake(1, 4, 0, 32)
		D3PS B 0 A_PlaySound ("SecondWind/Fire",CHAN_WEAPON)
		
		2WND BC 1 bright
		TNT1 A 0 a_giveinventory ("SecondWindSpread",1)
		TNT1 A 0 a_playsound ("SecondWind/SlideBack",0,0.80)
		2WND D 1 offset (0,37)
		2WND E 1 offset (0,39) 
		2WND FF 1 offset (0,34) a_weaponready (WRF_NOBOB)
		D3PS B 0 A_PlaySound ("SecondWind/SlideForward",0,0.80)
		2WND GG 1 offset (0,32) a_weaponready (WRF_NOBOB)
		2WND HH 1 a_weaponready (WRF_NOBOB)
		TNT1 A 0 a_takeinventory ("SecondWindSpread",99)
		2WND A 3 a_weaponready (WRF_NOBOB)
		2WND A 1 a_refire
		2WND A 1 
		goto ready
	NormalSpread:
		TNT1 A 0
		D3PS B 0 A_firebullets (2,2,-1,15,"SecondWindShot",FBF_USEAMMO|FBF_NORANDOM)
		TNT1 A 0 A_Quake(1, 4, 0, 32)
		D3PS B 0 A_PlaySound ("SecondWind/Fire",CHAN_WEAPON)
		2WND BC 1 bright
		TNT1 A 0 a_playsound ("SecondWind/SlideBack",0)
		TNT1 A 0 a_giveinventory ("SecondWindSpread",1)
		2WND D 1 offset (0,37)
		2WND E 1 offset (0,39) 
		2WND FF 1 offset (0,34) a_weaponready (WRF_NOBOB)
		D3PS B 0 A_PlaySound ("SecondWind/SlideForward",0)
		2WND GG 1 offset (0,32) a_weaponready (WRF_NOBOB)
		2WND HH 1 a_weaponready (WRF_NOBOB)
		TNT1 A 0 a_takeinventory ("SecondWindSpread",99)
		2WND A 4 a_weaponready (WRF_NOBOB)
		2WND A 1 
		TNT1 A 0 a_refire ("Fire")
		2WND A 1 
		goto ready
		
	BackupShot:
		TNT1 A 0
		TNT1 A 0 a_jumpifinventory ("SecondWindSpread",1,"BackupSpread")
		D3PS B 0 A_FireCustomMissile("SecondWindLaser",0,0,0,0)
		TNT1 A 0 A_Quake(1, 4, 0, 32)
		D3PS B 0 A_PlaySound ("SecondWind/BackupShot",CHAN_WEAPON)

		2WND IJ 1 bright
		TNT1 A 0 a_giveinventory ("SecondWindSpread",1)
		2WND K 1 offset (0,37) 
		2WND L 1 offset (0,39)
		2WND MM 1 offset (0,34) a_weaponready (WRF_NOBOB)
		2WND NN 1 offset (0,32) a_weaponready (WRF_NOBOB)
		TNT1 A 0 a_takeinventory ("SecondWindSpread",99)
		2WND A 3 a_weaponready (WRF_NOBOB)
		2WND A 1 a_refire
		2WND A 1 
		goto ready
	BackupSpread:
		TNT1 A 0
		D3PS B 0 A_FireCustomMissile("SecondWindLaser",frandom(-1,1),0,0,0,0,frandom(-2,2))
		TNT1 A 0 A_Quake(1, 4, 0, 32)
		D3PS B 0 A_PlaySound ("SecondWind/BackupShot",CHAN_WEAPON)

		2WND IJ 1 bright
		TNT1 A 0 a_giveinventory ("SecondWindSpread",1)
		2WND K 1 offset (0,37)
		2WND L 1 offset (0,39) 
		2WND MM 1 offset (0,34) a_weaponready (WRF_NOBOB)
		2WND NN 1 offset (0,32) a_weaponready (WRF_NOBOB)
		TNT1 A 0 a_takeinventory ("SecondWindSpread",99)
		2WND A 4 a_weaponready (WRF_NOBOB)
		2WND A 1 
		TNT1 A 0 a_refire
		2WND A 1 
		goto ready
	Altfire:
		TNT1 A 0
		2WND A 3 a_playsound ("SecondWind/BarrierWindup",CHAN_WEAPON)
		TNT1 A 0 
		TNT1 A 0 a_firecustommissile ("BladeShot",0,0)
		TNT1 A 0 a_giveinventory ("Secondwindheat", 350)
		TNT1 A 0 ACS_NamedExecuteAlways("SecondWindRecharge", 0, 0, 0, 0)
		TNT1 A 0 a_playsound ("SecondWind/BarrierShot",CHAN_WEAPON)
		TNT1 A 0 A_Quake(1, 6, 0, 32)
		2WPS AABB 1 bright a_weaponready (WRF_NOFIRE|WRF_NOBOB)
		2WPS CC 1 bright a_weaponready (WRF_NOFIRE|WRF_NOBOB)
		TNT1 A 0 offset (0,38) 
		2WPS DD 1 bright a_weaponready (WRF_NOFIRE|WRF_NOBOB)
		TNT1 A 0 offset (0,39) 
		TNT1 A 0 a_playsound ("SecondWind/Open",0)
		2WPS EE 1 bright a_weaponready (WRF_NOFIRE|WRF_NOBOB)
		2WPS GHI 2 bright a_weaponready (WRF_NOFIRE|WRF_NOBOB)
		TNT1 A 0 offset (0,38) a_weaponready (WRF_NOFIRE|WRF_NOBOB)
		2WPS I 2 offset (0,36) a_weaponready (WRF_NOFIRE|WRF_NOBOB)
		2WPS I 2 offset (0,34) a_weaponready (WRF_NOFIRE|WRF_NOBOB)
		2WPS I 2 offset (0,33) a_weaponready (WRF_NOFIRE|WRF_NOBOB)
		2WPS I 2 offset (0,32) a_weaponready (WRF_NOFIRE|WRF_NOBOB)
		2WPS I 12 a_weaponready (WRF_NOFIRE|WRF_NOBOB)
		goto Recharging
	
	Recharging:
		TNT1 A 0
		TNT1 A 0 a_playsound ("SecondWind/Recharge",0)
		2WPS JKLM 2 bright a_weaponready (WRF_NOFIRE|WRF_NOBOB)
		2WPS I 33 a_weaponready (WRF_NOFIRE|WRF_NOBOB)
		TNT1 A 0 a_jumpifinventory ("SecondWindHeat",1,"Recharging")
		Goto RechargeDone
	RechargeDone:
		TNT1 A 0
		TNT1 A 0 a_playsound ("SecondWind/RechargeDone",0)
		2WND GG 1 offset (0,32) a_weaponready (WRF_NOBOB)
		TNT1 A 0 offset (0,36)
		2WND HH 1 a_weaponready (WRF_NOBOB)
		TNT1 A 0 offset (0,34)
		2WND A 4 a_weaponready (WRF_NOBOB)
		TNT1 A 0 offset (0,32)
		2WND A 1 
		goto ready
	}
}


ACTOR SecondWindShot : BulletPuff
{
	+NOBLOCKMAP
	+NOGRAVITY
	+ALLOWPARTICLES
	+RANDOMIZE
	+thruspecies
	+MTHRUSPECIES
	+PUFFONACTORS
	+bright
	species "player"
	RenderStyle add
	Alpha 0.90
	scale 0.60
	VSpeed 0
	Mass 5
	decal "BulletChip"
	States
	{
	Spawn:
		TNT1 A 0
		TNT1 A 2
		// Intentional fall-through
	Xdeath:
		2WHT A 1
		TNT1 A 0 a_playsound ("blastmaster/puffhit",CHAN_VOICE,0.90,0,1.5)
		TNT1 A 0 a_jump (100,"Flip1","Flip2","Flip3")
		2WHT BCD 1
		2WHT D 1 a_setscale (0.80,0.80)
		Stop
	Flip1:
		TNT1 A 0
		TNT1 A 0 a_setscale (-0.60,-0.60)
		2WHT BCD 1
		2WHT D 1 a_setscale (-0.80,-0.80)
		Stop
	Flip2:	
		TNT1 A 0
		2WHT EFG 1
		2WHT G 1 a_setscale (0.80,0.80)
		Stop
	Flip3:	
		TNT1 A 0
		TNT1 A 0 a_setscale (-0.60,-0.60)
		2WHT EFG 1
		2WHT G 1 a_setscale (-0.80,-0.80)
		Stop
	Crash:
		TNT1 A 0
		TNT1 A 0 a_setscale (1,1)
		TNT1 AAA 0 a_spawnitemex ("CABulletSpark",4,0,0,Frandom(-200,200)/20.0,Frandom(-200,200)/20.0,Frandom(-200,200)/20.0,0,SXF_NOCHECKPOSITION)		
		2WHT A 2
		TNT1 A 0 a_playsound ("blastmaster/ricochet",CHAN_VOICE,0.5,0,1.5)
		2MIS ABC 1
		Stop
		
	}
}


actor SecondWindLaser : fastprojectile
{
	+notimefreeze
	projectile
    +FORCEXYBILLBOARD	
    +BLOODSPLATTER
	+bright
	species "player"
	missiletype "SecondWindTracer"
    missileheight 10
	+thruspecies
	height 4
	radius 4
	speed 220
	Damage (3*random(2,5))
	scale 0.50
	Decal bulletchip
	alpha 0.55
	states
	{
	spawn:
		2WBS AB 1
		loop
	Xdeath:
		TNT1 A 0 
		TNT1 A 0 a_playsound ("blastmaster/puffhit",CHAN_VOICE,0.90,0,1.5)
		TNT1 A 1 a_spawnitemex ("SecondWindLaserHit",0,0,0,0,0,0,0,SXF_NOCHECKPOSITION)
		Stop
	Death:
		TNT1 A 0
		TNT1 A 0 a_playsound ("blastmaster/ricochet",CHAN_VOICE,0.5,0,1.5)
		TNT1 A 1 a_spawnitemex ("SecondWindLaserMiss",0,0,0,0,0,0,0,SXF_NOCHECKPOSITION)
		Stop
	}
}

actor SecondWindLaserHit
{
	RenderStyle add
	Alpha 0.90
	Scale 0.50
	+NOBLOCKMAP
	+NOGRAVITY
	+NOCLIP
	+DONTSPLASH
	+NOTELEPORT
	+clientsideonly
	+bright
	States
	{
	Spawn:
		TNT1 A 0
		TNT1 A 0
		2WHT H 1
		TNT1 A 0 a_jump (100,"Flip1","Flip2","Flip3")
		2WHT IJK 1
		2WHT K 1 a_setscale (0.60,0.60)
		Stop
	Flip1:
		TNT1 A 0
		TNT1 A 0 a_setscale (-0.50,-0.50)
		2WHT IJK 1
		2WHT K 1 a_setscale (-0.60,-0.60)
		Stop
	Flip2:	
		TNT1 A 0
		2WHT LMN 1
		2WHT N 1 a_setscale (0.60,0.60)
		TNT1 A 0 a_setscale (0.70,0.70)
		Stop
	Flip3:	
		TNT1 A 0
		TNT1 A 0 a_setscale (-0.50,-0.50)
		2WHT LMN 1
		2WHT N 1 a_setscale (-0.60,-0.60)
		Stop
	}
}

actor SecondWindLaserMiss
{
	RenderStyle add
	Alpha 0.90
	Scale 1
	+NOBLOCKMAP
	+NOGRAVITY
	+NOCLIP
	+DONTSPLASH
	+NOTELEPORT
	+clientsideonly
	+bright
	States
	{
	Spawn:
		TNT1 A 0
		TNT1 A 0
		2MIS DEF 1
		Stop
	}
}




actor SecondWindTracer
{
	RenderStyle add
	Alpha 0.99
	Scale 0.4
	+NOBLOCKMAP
	+NOGRAVITY
	+NOCLIP
	+DONTSPLASH
	+NOTELEPORT
	+clientsideonly
	+bright
	States
	{
	spawn:
		TNT1 A 0 
		TNT1 A 0 a_checkrange (40,"Flight")
		TNT1 A 2 
		goto death
	Flight:
		TNT1 A 0
		2WBS B 1 
		2WBS B 1 a_setscale (0.2,0.2) 
		stop
	death:
		TNT1 A 1
		stop
	}
}




actor BladeShot : fastprojectile
{
	+notimefreeze
	projectile
    +FORCEXYBILLBOARD	
    +BLOODSPLATTER
	+bright
	+ripper
	+DONTREFLECT

	species "player"
	damagetype "CABladeBeam"
	missiletype "BladeShotTracer"
    missileheight 10
	+thruspecies
	height 4
	radius 4
	speed 150
	Damage 0
	yscale 0.30
	xscale 3
	alpha 0.55
	reactiontime 1
	states
	{
	spawn:
		TNT1 A 0
		2WBS A 1
		TNT1 A 0 a_countdown
		loop
	Xdeath:
		TNT1 A 0 
		TNT1 A 1 a_spawnitemex ("SecondWindLaserHit",0,0,0,0,0,0,0,SXF_NOCHECKPOSITION)
		Stop
	Death:
		TNT1 A 0
		TNT1 A 0 a_setscale (1.25)
		IBMS ABC 2 bright
		TNT1 A 0 a_setscale (2.50, 0.50)
		IBMS D 2 bright
		TNT1 A 0 a_setscale (4, 0.25)
		IBMS E 2 bright
		Stop
	}
}

actor BladeShotTracer
{
	RenderStyle add
	Alpha 0.99
	yscale 0.30
	xscale 3
	+thruspecies
	species "Player"
	+NOBLOCKMAP
	+NOGRAVITY
	+NOCLIP
	+DONTSPLASH
	+NOTELEPORT
	+DONTREFLECT
	+bright
	States
	{
	spawn:
		TNT1 A 0 
		TNT1 A 0 a_spawnitemex ("BladeDefense",0,0,0,0,0,0,0,0,SXF_NOCHECKPOSITION)
		2WBS B 2 a_spawnitemex ("BladeCutter",0,0,0,0,0,0,0,0,SXF_NOCHECKPOSITION)
		TNT1 A 0 a_spawnitemex ("BladeDefense",0,0,0,0,0,0,0,0,SXF_NOCHECKPOSITION)
		2WBS B 2 a_setscale (2,0.20) 
		TNT1 A 0 a_spawnitemex ("BladeCutter",0,0,0,0,0,0,0,0,SXF_NOCHECKPOSITION)
		TNT1 A 0 a_spawnitemex ("BladeDefense",0,0,0,0,0,0,0,0,SXF_NOCHECKPOSITION)
		2WBS B 2 a_setscale (1,0.10) 
		TNT1 A 0 a_spawnitemex ("BladeCutter",0,0,0,0,0,0,0,0,SXF_NOCHECKPOSITION)
		TNT1 A 0 a_spawnitemex ("BladeDefense",0,0,0,0,0,0,0,0,SXF_NOCHECKPOSITION)
		2WBS B 2 a_setscale (0.5,0.05) 
		TNT1 A 0 a_spawnitemex ("BladeCutter",0,0,0,0,0,0,0,0,SXF_NOCHECKPOSITION)
		TNT1 A 0 a_spawnitemex ("BladeDefense",0,0,0,0,0,0,0,0,SXF_NOCHECKPOSITION)
		stop
	death:
		TNT1 A 1
		stop
	}
}




actor BladeCutter
{
	projectile
    Radius 25
    Height 35
    Speed 0
	damage (25)
	+DONTREFLECT
	+DONTBLAST
	+thruspecies
	damagetype "CABladeBeam"
	Projectilekickback 5
	species "Player"
	states
	{
	spawn:
		TNT1 A 1
		stop
	death:
		TNT1 A 1
		stop
	Xdeath:
		TNT1 A 0
		TNT1 A 0
		TNT1 A 0 a_setscale (1.25)
		TNT1 A 0 a_playsound ("Bustercarbine/Hit",0,0.60,0,1.20)
		IBMS ABC 2 bright
		TNT1 A 0 a_setscale (2.50, 0.50)
		IBMS D 2 bright
		TNT1 A 0 a_setscale (4, 0.25)
		IBMS E 2 bright
		stop
	}
}


	
actor BladeDefense
{
	projectile
	+noblood
	+shootable
	+notimefreeze
	+ripper
	+bloodlessimpact
	+thruspecies
	+notargetswitch
	+NORADIUSDMG
	+PAINLESS
	+DONTRIP
	+HEXENBOUNCE
	+DONTREFLECT
	-bloodsplatter
	-noblockmap
	-ACTIVATEIMPACT
	painchance 255
	species "Player"
	radius 12
	height 20
	speed 1
	mass 1
	damage (0)
	states
	{
	spawn:
		TNT1 A 0
		TNT1 A 1
		goto blockend
	blockend:
		TNT1 A 0
		TNT1 A 1 
		stop
	death:
		TNT1 A 0
		TNT1 A 1
		stop
	pain:
		TNT1 A 0 Radius_Quake (1,8,0,20,0)
		TNT1 A 1
		stop
	Pain.Linked:
		TNT1 A 1
		stop

	}
}




ACTOR WWStyleBulletSpark
{
	Health 4
	radius 3
	height 6
	speed .1
	RenderStyle ADD
	Alpha 1
	Scale 0.5
	Mass 0
	+missile
	+doombounce
	+FLOORCLIP
	+DONTSPLASH
	+NOTELEPORT
	+bright
	+clientsideonly
	States
	{
	Spawn:	
		PUFF A 1
		PUFF AAAA 1  Bright A_SetTranslucent(.8,1)
		Stop
	}
}

actor CAbullettracer
{
	RenderStyle add
	Alpha 0.95
	Scale 0.7
	+NOBLOCKMAP
	+NOGRAVITY
	+NOCLIP
	+DONTSPLASH
	+NOTELEPORT
	+clientsideonly
	States
	{
	spawn:
		TNT1 A 0 
		TNT1 A 0 
		TNT1 A 2 a_checkrange (30,"Flight")
		goto death
	Flight:
		PUFF A 2 
		stop
	death:
		TNT1 A 1
		stop
	}
}





actor PistolClipper : inventory
{inventory.maxamount 1}

actor SecondWindSpread : inventory
{inventory.maxamount 1}

actor SecondWindHeat : inventory
{inventory.maxamount 350}

