/*
==VULTURE SMG==

This compact SMG doesn't seem like much at first glance,
but it features a ramping fire rate system where the longer
the trigger is held down, an extra barrel springs out, throwing
out more lead at a higher rate before finally a third barrel 
comes into play, outputting a hail of gunfire that can whittle
down even the biggest of targets, provided you have the ammo for it.

As an altifre, the weapon features a specialized laser that produces
ammunition on hit. The laser's internal generator is charged
each time one of those standard rounds find their mark. It's best
not to question how all of this works, just enjoy the extra ammo.

*/


Actor VultureSMG : Weapon
{
	Weapon.SelectionOrder 35
	Weapon.AmmoUse1 1
	Weapon.KickBack 40
	weapon.bobstyle smooth
	weapon.bobrangex 0.1
	weapon.bobrangey 0.6
	weapon.bobspeed 2
	+WEAPON.NOALERT
	+WEAPON.ALT_AMMO_OPTIONAL
	+NOAUTOAIM
	Inventory.RestrictedTo "Artificer"
	Weapon.AmmoType1 "Clip"
	Inventory.PickupSound "Misc/W_PkUp"
	Inventory.PickupMessage "You got the Vulture SMG!"
	Obituary "%o was nailed by %k."
	Tag "Vulture SMG"
	states
	{
	Spawn:
		NLMG J -1
		Loop
	Select:
		TNT1 A 0
		TNT1 A 0 a_playsound ("gnasher/draw",0)
	draw:
		TNT1 A 0
		VLTR AAAA 0 A_Raise
		VLTR A 1 A_Raise
		TNT1 A 0 a_takeinventory ("speedupcount", 99)
		Loop
	Deselect:
		TNT1 A 0
		TNT1 A 0 a_jumpifhealthlower (1, "deadlower")
		TNT1 A 0 a_playsound ("gnasher/holster",0)
	holster:
		TNT1 A 0
		VLTR A 1 A_Lower
		VLTR AA 0 A_Lower
		TNT1 A 0 a_takeinventory ("secretaction", 99)
		TNT1 A 0 a_takeinventory ("speedupcount", 99)
		Loop
	deadlower:
		TNT1 A 0
		TNT1 A 0
		TNT1 AAAAAAAAAAAAA 0 a_lower
		TNT1 A 1 a_lower
		wait  
	Ready:
		VLTR A 1 A_WeaponReady
		Loop
	Fire:
		TNT1 A 0
		TNT1 A 0 a_jumpifinventory ("Clip",1, "singlebarrelshot")
		VLTR A 1
		goto ready
	
	//Single barrel firing
	SingleBarrelShot:
		TNT1 A 0
		TNT1 A 0 a_jumpifinventory ("speedupcount", 18, "ThreeBarrelShot")
		TNT1 A 0 a_jumpifinventory ("speedupcount", 9, "TwoBarrelShot")
		TNT1 A 0 a_jumpifinventory ("speedupcount", 8, "DeployLeftBarrel")
		VLTR A 1 a_gunflash ("VultureCenterFlash")
		TNT1 A 0 A_Quake(1, 4, 0, 5,"Silence")
		NLMG B 0 a_playsound ("Vulture/Fire",CHAN_WEAPON)
		TNT1 A 0 a_alertmonsters
		VLTR A 1 A_firebullets (0,0,1,5,"VultureShot", FBF_USEAMMO)
		TNT1 A 0 offset (0,36)
		VLTR BC 1
		TNT1 A 0 a_giveinventory ("speedupcount", 1)
		TNT1 A 0 offset (0,32)
		VLTR A 1 a_refire
		TNT1 A 0 a_takeinventory ("speedupcount", 99)
		goto ready
	
	//Two Barrel firing
	DeployLeftBarrel:
		TNT1 A 0
		TNT1 A 0 a_playsound ("Vulture/Open",0)
		VLT2 AB 1
		goto TwobarrelShot
	TwoBarrelShot:
		TNT1 A 0
		TNT1 A 0 a_jumpifinventory ("speedupcount", 18, "ThreeBarrelShot")
		TNT1 A 0 a_jumpifinventory ("SpeedUpCount",17,"DeployRightBarrel")
		VLT2 D 1 a_gunflash ("Lv2VultureCenterFlash")
		TNT1 A 0 A_Quake(1, 4, 0, 5,"Silence")
		NLMG B 0 a_playsound ("Vulture/Fire",CHAN_WEAPON)
		TNT1 A 0 a_alertmonsters
		VLT2 D 1 A_firebullets (0,0,1,5,"VultureShot", FBF_USEAMMO)
		TNT1 A 0 offset (0,36)
		VLT2 EF 1
		TNT1 A 0 offset (0,32)
		TNT1 A 0 A_Quake(1, 4, 0, 5,"Silence")
		NLMG B 0 a_playsound ("Vulture/Fire",CHAN_WEAPON)
		TNT1 A 0 a_alertmonsters
		TNT1 A 0 A_firebullets (4,2,1,5,"VultureShot", FBF_USEAMMO)
		TNT1 A 0 offset (0,36)
		VLT2 HI 1 bright
		TNT1 A 0 offset (0,32)
		TNT1 A 0 a_giveinventory ("speedupcount", 1)
		VLT2 J 1 a_refire ("TwoBarrelCheck")
		VLT2 K 60 a_weaponready (WRF_NOBOB)
	TwoBarrelAway:
		TNT1 A 0
		TNT1 A 0 a_takeinventory ("speedupcount", 99)
		TNT1 A 0 a_playsound ("Vulture/Retract",0)
		VLT2 LM 2 a_weaponready (WRF_NOBOB)
		TNT1 A 0 a_playsound ("Vulture/Close",0)
		VLTR A 1 a_weaponready (WRF_NOBOB)
		goto ready
	TwoBarrelCheck:
		TNT1 A 0
		TNT1 A 0 a_jumpifinventory ("Clip",2,"TwoBarrelShot")
		TNT1 A 0 a_takeinventory ("speedupcount", 99)
		TNT1 A 0 a_playsound ("Vulture/Retract",0)
		VLT2 LM 2 
		TNT1 A 0 a_playsound ("Vulture/Close",0)
		VLTR A 1
		goto ready
	
	//Not when I shift into MAXIMUM OVERDRIVE.
	//Three Barrel firing
	DeployRightBarrel:
		TNT1 A 0
		TNT1 A 0 a_playsound ("Vulture/Open",0)
		VLT3 AB 1
		goto ThreebarrelShot
	ThreeBarrelShot:
		TNT1 A 0
		TNT1 A 0
		VLT3 D 0 a_gunflash ("Lv3VultureCenterFlash")
		TNT1 A 0 A_Quake(1, 4, 0, 5,"Silence")
		NLMG B 0 a_playsound ("Vulture/Fire",CHAN_WEAPON)
		TNT1 A 0 a_alertmonsters
		VLT3 D 1 A_firebullets (0,0,1,5,"VultureShot", FBF_USEAMMO)
		TNT1 A 0 offset (0,36)
		VLT3 EF 1
		TNT1 A 0 offset (0,32)
		NLMG B 0 a_playsound ("Vulture/Fire",CHAN_WEAPON)
		TNT1 A 0 A_Quake(1, 2, 0, 5,"Silence")
		TNT1 A 0 a_alertmonsters
		TNT1 A 0 A_firebullets (4,2,1,5,"VultureShot", FBF_USEAMMO)
		TNT1 A 0 offset (0,36)
		VLT3 HI 1 bright
		TNT1 A 0 offset (0,32)
		VLT3 J 1 
		NLMG B 0 a_playsound ("Vulture/Fire",CHAN_WEAPON)
		TNT1 A 0 A_Quake(1, 2, 0, 5,"Silence")
		TNT1 A 0 a_alertmonsters
		TNT1 A 0 A_firebullets (4,2,1,5,"VultureShot", FBF_USEAMMO)
		TNT1 A 0 offset (0,36)
		VLT3 LM 1 bright
		TNT1 A 0 offset (0,32)
		TNT1 A 0 a_giveinventory ("speedupcount", 1)
		TNT1 A 0 a_refire ("ThreeBarrelCheck")
		VLT3 N 1 
  		VLT3 O 60 a_weaponready (WRF_NOBOB)
	ThreeBarrelAway:
		TNT1 A 0
		TNT1 A 0 a_takeinventory ("speedupcount", 99)
		TNT1 A 0 a_playsound ("Vulture/Retract",0)
		VLT3 PQ 2 a_weaponready (WRF_NOBOB)
		TNT1 A 0 a_playsound ("Vulture/Close",0)
		VLTR A 1 a_weaponready (WRF_NOBOB)
		goto ready
	ThreeBarrelCheck:
		TNT1 A 0
		TNT1 A 0 a_jumpifinventory ("Clip",3,"ThreeBarrelShot")
		TNT1 A 0 a_takeinventory ("speedupcount", 99)
		TNT1 A 0 a_playsound ("Vulture/Retract",0)
		VLT3 LM 2 
		TNT1 A 0 a_playsound ("Vulture/Close",0)
		VLTR A 1
		goto ready
		
	
	Altfire:
		TNT1 A 0
		TNT1 A 0 a_jumpifinventory ("ScavCharge",100,"ScavengerLaser")
		TNT1 A 0 a_jumpifinventory ("speedupcount", 18, "ThreeBarrelAway")
		TNT1 A 0 a_jumpifinventory ("speedupcount", 9, "TwoBarrelAway")
		TNT1 A 0 a_takeinventory ("speedupcount", 99)
		VLTR A 20 a_weaponready (WRF_NOSECONDARY)
		goto ready
	ScavengerLaser:
		TNT1 A 0
		TNT1 A 0 a_playsound ("Scavenger/Start",0)
		TNT1 A 0 a_takeinventory ("speedupcount", 99)
		VTLX ABCDE 1
		TNT1 A 0 a_playsound ("Scavenger/Open",0)
		VTLX FGHIJK 1
		TNT1 A 0 a_playsound ("Scavenger/Windup",0)
		VTLX LMNO 1 bright
		TNT1 A 0 offset (0,38)
		TNT1 A 0 a_takeinventory ("ScavCharge",9999)
		TNT1 A 0 a_playsound ("Scavenger/Shot",0)
		TNT1 A 0 A_Quake(2, 4, 0, 5,"Silence")
		TNT1 A 0 a_alertmonsters
		VTLX P 1 a_firecustommissile ("ScavPulse",0,0)
		TNT1 A 0 offset (0,39)
		VTLX QRST 2 offset (0,40)
		VTLX T 1 offset (0,34)
		TNT1 A 0 offset (0,32)
		TNT1 A 0 a_playsound ("Scavenger/Close",0)
		VTLX JIFGE 2
		TNT1 A 0 a_playsound ("Scavenger/End",0)
		VTLX CBA 2
		goto ready

	
	
	
	//Muzzleflashes for center barrel
	VultureCenterFlash:
		TNT1 A 0
		TNT1 A 0 a_jump (120,"VultureCenterFlash2")
		VLT1 A 1 bright
		VLT1 BB 1 bright
		stop
	VultureCenterFlash2:
		TNT1 A 0
		VLT1 C 1 bright
		VLT1 DD 1 bright
		stop
	Lv2VultureCenterFlash:
		TNT1 A 0
		TNT1 A 0 a_jump (120,"VultureCenterFlash2")
		VLT1 A 1 bright
		VLT1 B 1 bright
		stop
	Lv2VultureCenterFlash2:
		TNT1 A 0
		VLT1 C 1 bright
		VLT1 D 1 bright
		stop
	Lv3VultureCenterFlash:
		TNT1 A 0
		TNT1 A 0 a_jump (120,"VultureCenterFlash2")
		VLT1 AB 1 bright
		stop
	Lv3VultureCenterFlash2:
		TNT1 A 0
		VLT1 CD 1 bright
		stop
	}
}



ACTOR VultureShot : BulletPuff
{
	+NOBLOCKMAP
	+NOGRAVITY
	+ALLOWPARTICLES
	+RANDOMIZE
	+thruspecies
	+MTHRUSPECIES
	+PUFFONACTORS
	+PUFFGETSOWNER
	+bright
	species "player"
	RenderStyle add
	Alpha 0.90
	scale 1.50
	VSpeed 0
	Mass 5
	decal "BulletChip"
	States
	{
	Spawn:
		TNT1 A 0
		TNT1 A 2
		// Intentional fall-through
	Xdeath:
		VLT4 A 1
		TNT1 A 0 a_giveinventory ("ScavChargeGiver",1,AAPTR_TARGET)
		TNT1 A 0 a_playsound ("blastmaster/puffhit",CHAN_VOICE,0.90,0,1.5)
		VLT4 GHIJ 1
		VLT4 J 1 a_setscale (1.60,1.60)
		Stop
	Crash:
		TNT1 A 0
		VLT4 A 2 
		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)		
		TNT1 A 0 a_playsound ("blastmaster/ricochet",CHAN_VOICE,0.5,0,1.5)
		VLT4 BCDEF 1
		VLT4 F 1 a_setscale (1,0.20)
		Stop
		
	}
}



actor ScavChargeGiver : custominventory 
{
	inventory.maxamount 1
	+INVENTORY.AUTOACTIVATE
	states
	{
	pickup:
		TNT1 A 0
		TNT1 A 0 a_jumpifinventory ("ScavCharge",100,"ChargeQuiet")
		TNT1 A 0 a_jumpifinventory ("ScavCharge",99,"ChargeFull")
		TNT1 A 1 a_giveinventory ("ScavCharge", 1)
		stop
	ChargeFull:
		TNT1 A 0 a_playsound ("Scavenger/ChargeFull",0)
		TNT1 A 1 a_giveinventory ("ScavCharge", 1)
		stop
	ChargeQuiet:
		TNT1 A 1 a_giveinventory ("ScavCharge", 1)
		stop
		
	}
}



//======================================================================

//Scavenger Laser

actor ScavPulse
{
	Projectile
	Radius 3
	Height 3
	Speed 45
	Damage (80)
	Scale 1
	+thruspecies
	+bright
	+forcepain
	species "player"
	+Bloodlessimpact
	Projectilekickback 5000
	Decal CADecal
	
	var int user_ScavTimer;
	states
	{
	Spawn:
		TNT1 A 0
		SCV1 ABC 1 a_spawnitemex ("ScavTrail1",0,0,0,0,0,0,0,SXF_NOCHECKPOSITION)
		TNT1 A 0 a_setuservar("user_ScavTimer", user_ScavTimer+1)
		TNT1 A 0 a_jumpif (user_ScavTimer == 3, "ScavLoop2")
		loop
	ScavLoop2:
		TNT1 A 0
		TNT1 A 0 a_setscale (0.8)
		SCV2 ABC 1 a_spawnitemex ("ScavTrail2",0,0,0,0,0,0,0,SXF_NOCHECKPOSITION)
		TNT1 A 0 a_setuservar("user_ScavTimer", user_ScavTimer+1)
		TNT1 A 0 a_jumpif (user_ScavTimer == 8, "ScavLoop3")
		loop
	ScavLoop3:
		TNT1 A 0
		TNT1 A 0 a_setscale (0.6)
		SCV3 ABC 1 a_spawnitemex ("ScavTrail3",0,0,0,0,0,0,0,SXF_NOCHECKPOSITION)
		TNT1 A 0 a_setuservar("user_ScavTimer", user_ScavTimer+1)
		TNT1 A 0 a_jumpif (user_ScavTimer == 11, "ScavLoop4")
		loop
	ScavLoop4:
		TNT1 A 0
		TNT1 A 0 a_setscale (0.4)
		SCV4 ABC 1 a_spawnitemex ("ScavTrail4",0,0,0,0,0,0,0,SXF_NOCHECKPOSITION)
		TNT1 A 0 a_setuservar("user_ScavTimer", user_ScavTimer+1)
		loop

	death:
		TNT1 A 0
		TNT1 A 1
		TNT1 A 0 a_playsound ("Scavenger/Miss",0)
		TNT1 A 0 a_playsound ("Bustercarbine/Miss",0,1,0,1.20)
		TNT1 A 0 a_jumpif (user_ScavTimer == 11, "GrayMiss")
		TNT1 A 0 a_jumpif (user_ScavTimer == 8, "YellowMiss")
		TNT1 A 0 a_jumpif (user_ScavTimer == 3, "OrangeMiss")
		SCV1 DKLMNO 2
		stop
	OrangeMiss:
		SCV2 DKLMNO 2
		stop
	YellowMiss:
		SCV3 DKLMNO 2
		stop
	GrayMiss:
		SCV4 DKLMNO 2
		stop

	Xdeath:
		TNT1 A 0
		TNT1 A 1
		TNT1 A 0 a_playsound ("Scavenger/Hit",0,1,0,0.35)
		TNT1 A 0 a_playsound ("Bustercarbine/Hit",0,1,0,1.20)
		TNT1 A 0 a_jumpif (user_ScavTimer == 11, "GrayHit")
		TNT1 A 0 a_jumpif (user_ScavTimer == 8, "YellowHit")
		TNT1 A 0 a_jumpif (user_ScavTimer == 3, "OrangeHit")
		TNT1 A 0 a_custommissile ("ScavOrbSpawner1")
		SCV1 DEFGHIJ 1
		stop
	OrangeHit:
		TNT1 A 0
		TNT1 A 0 a_custommissile ("ScavOrbSpawner2")
		SCV2 DEFGHIJ 1
		stop
	YellowHit:
		TNT1 A 0
		TNT1 A 0 a_custommissile ("ScavOrbSpawner3")
		SCV3 DEFGHIJ 1
		stop
	GrayHit:
		TNT1 A 0
		TNT1 A 0 a_custommissile ("ScavOrbSpawner3")
		SCV4 DEFGHIJ 1
		stop
	}
}

//==============================================================

//Scavenger Laser trails

Actor ScavTrail1    
{
	Height 8
	Radius 1
	Damage 0
	Scale 0.9
	Speed 0.2
	RenderStyle Translucent
	Alpha 0.90
	+NoGravity
	+DropOff
	+NoTeleport
	+clientsideonly
	States
	{
	Spawn:
		TNT1 A 0
		TNT1 A 1
		SCV1 ABC 1 bright 
		TNT1 A 0 a_setscale (0.8)
		SCV1 ABC 1 bright 
		TNT1 A 0 a_setscale (0.6)
		SCV1 ABC 1 bright 
		TNT1 A 0 a_setscale (0.4)
		SCV1 ABC 1 bright 
		TNT1 A 0 a_setscale (0.2)
		stop
	}
}

actor ScavTrail2 : ScavTrail1
{
	Scale 0.7
	States
	{
	Spawn:
		TNT1 A 0
		TNT1 A 1
		SCV2 ABC 1 bright 
		TNT1 A 0 a_setscale (0.6)
		SCV2 ABC 1 bright 
		TNT1 A 0 a_setscale (0.4)
		SCV2 ABC 1 bright 
		TNT1 A 0 a_setscale (0.2)
		SCV2 ABC 1 bright 
		TNT1 A 0 a_setscale (0.1)
		stop
	}
}

actor ScavTrail3 : ScavTrail1
{
	Scale 0.5
	States
	{
	Spawn:
		TNT1 A 0
		TNT1 A 1
		SCV3 ABC 1 bright 
		TNT1 A 0 a_setscale (0.4)
		SCV3 ABC 1 bright 
		TNT1 A 0 a_setscale (0.2)
		SCV3 ABC 1 bright 
		TNT1 A 0 a_setscale (0.1)
		SCV3 ABC 1 bright 
		stop
	}
}

actor ScavTrail4 : ScavTrail1
{
	Scale 0.3
	States
	{
	Spawn:
		TNT1 A 0
		TNT1 A 1
		SCV4 ABC 1 bright
		TNT1 A 0 a_setscale (0.2)
		SCV4 ABC 1 bright 
		TNT1 A 0 a_setscale (0.1)
		SCV4 ABC 1 bright 
		stop
	}
}


//==============================================================

//Scavenger Laser drops

actor ScavOrbSpawner1
{
	+notimefreeze
    +FORCEXYBILLBOARD	
	+LOOKALLAROUND
	+thruactors
	+bounceonwalls
	+bright
	+noclip
	+DONTBLAST
	+NOGRAVITY
	+SKYEXPLODE
	radius 4
	height 4
	speed 5
	scale 0.25
	damage (0)
	states
	{
	Spawn:
		TNT1 A 0
		TNT1 A 0 a_spawnitemex ("ScavLootOrb1", 0, 0, 0, random (-16, 16), random (-12, 12), random (5, 7))
		TNT1 A 0 a_spawnitemex ("ScavLootOrb1", 0, 0, 0, random (-14, 14), random (-10, 12), random (5, 7))
		TNT1 A 0 a_spawnitemex ("ScavLootOrb1", 0, 0, 0, random (-12, 12), random (-8, 10), random (5, 7))
		TNT1 A 0 a_spawnitemex ("ScavLootOrb1", 0, 0, 0, random (-5, 12), random (-6, 8), random (3, 6))
		TNT1 A 1
		stop
	death:
		TNT1 A 1
		stop
	}
}


actor ScavOrbSpawner2 : ScavOrbSpawner1
{
	states
	{
	Spawn:
		TNT1 A 0
		TNT1 A 0 a_spawnitemex ("ScavLootOrb2", 0, 0, 0, random (-14, 14), random (-9, 14), random (3, 5))
		TNT1 A 0 a_spawnitemex ("ScavLootOrb2", 0, 0, 0, random (-12, 12), random (-8, 11), random (4, 7))
		TNT1 A 0 a_spawnitemex ("ScavLootOrb2", 0, 0, 0, random (-3, 6), random (-8, 8), random (2,3))
		TNT1 A 1
		stop
	death:
		TNT1 A 1
		stop
	}
}


actor ScavOrbSpawner3 : ScavOrbSpawner1
{
	states
	{
	Spawn:
		TNT1 A 0
		TNT1 A 0 a_spawnitemex ("ScavLootOrb3", 0, 0, 0, random (-10, 10), random (-8, 9), random (5, 7))
		TNT1 A 0 a_spawnitemex ("ScavLootOrb3", 0, 0, 0, random (-5, 12), random (-6, 8), random (3, 6))
		TNT1 A 1
		stop
	death:
		TNT1 A 1
		stop
	}
}

actor ScavOrbSpawner4 : ScavOrbSpawner1
{
	states
	{
	Spawn:
		TNT1 A 0
		TNT1 A 0 a_spawnitemex ("ScavLootOrb4", 0, 0, 0, random (-7, 10), random (-4, 10), random (5, 7))
		TNT1 A 0 a_spawnitemex ("ScavLootOrb4", 0, 0, 0, random (-7, 10), random (-4, 10), random (5, 7))
		TNT1 A 1
		stop
	death:
		TNT1 A 1
		stop
	}
}



actor ScavLootOrb1
{
	projectile
	+notimefreeze
    +FORCEXYBILLBOARD	
	+LOOKALLAROUND
	+thruactors
	+bounceonwalls
	+bounceonceilings
	+bright
	+SKYEXPLODE
	-nogravity
	radius 12
	speed 5
	scale 0.25
	damage (0)
	height 20
    gravity 0.8
	states
	{
	spawn:
		TNT1 A 0
		SCV1 A 1 a_setscale (0.30)
		SCV1 B 1 a_setscale (0.35)
		SCV1 C 1 a_setscale (0.25)
		loop
	death:
		TNT1 A 0
		TNT1 A 0 a_spawnitemex ("PinataCell", 0, 0, 0, random (-4, 4), random (-5, 5), random (2, 4),0,SXF_NOCHECKPOSITION)
		TNT1 A 0 a_spawnitemex ("PinataRocket", 0, 0, 0, random (-4, 4), random (-5, 5), random (2, 4),0,SXF_NOCHECKPOSITION)
		TNT1 A 0 a_spawnitemex ("PinataRocket", 0, 0, 0, random (-4, 4), random (-5, 5), random (2, 4),0,SXF_NOCHECKPOSITION,120)
		TNT1 A 0 a_spawnitemex ("PinataShell", 0, 0, 0, random (-4, 4), random (-5, 5), random (2, 4),0,SXF_NOCHECKPOSITION)
		TNT1 A 0 a_spawnitemex ("PinataBullet", 0, 0, 0, random (-4, 4), random (-5, 5), random (2, 4),0,SXF_NOCHECKPOSITION)
		TNT1 A 0 a_spawnitemex ("PinataBullet", 0, 0, 0, random (-4, 4), random (-5, 5), random (2, 4),0,SXF_NOCHECKPOSITION)
		TNT1 A 0 a_spawnitemex ("PinataBullet", 0, 0, 0, random (-4, 4), random (-5, 5), random (2, 4),0,SXF_NOCHECKPOSITION)
		SCV1 DKLMNO 2
		stop
	}
}


actor ScavLootOrb2 : ScavLootOrb1
{
	states
	{
	spawn:
		TNT1 A 0
		SCV2 A 1 a_setscale (0.30)
		SCV2 B 1 a_setscale (0.35)
		SCV2 C 1 a_setscale (0.25)
		loop
	death:
		TNT1 A 0
		TNT1 A 0 a_spawnitemex ("PinataRocket", 0, 0, 0, random (-4, 4), random (-5, 5), random (2, 4),0,SXF_NOCHECKPOSITION,120)
		TNT1 A 0 a_spawnitemex ("PinataShell", 0, 0, 0, random (-4, 4), random (-5, 5), random (2, 4),0,SXF_NOCHECKPOSITION,120)
		TNT1 A 0 a_spawnitemex ("PinataBullet", 0, 0, 0, random (-4, 4), random (-5, 5), random (2, 4),0,SXF_NOCHECKPOSITION)
		TNT1 A 0 a_spawnitemex ("PinataBullet", 0, 0, 0, random (-4, 4), random (-5, 5), random (2, 4),0,SXF_NOCHECKPOSITION)
		SCV2 DKLMNO 2
		stop
	}
}

actor ScavLootOrb3 : ScavLootOrb1
{
	states
	{
	spawn:
		TNT1 A 0
		SCV3 A 1 a_setscale (0.30)
		SCV3 B 1 a_setscale (0.35)
		SCV3 C 1 a_setscale (0.25)
		loop
	death:
		TNT1 A 0
		TNT1 A 0 a_spawnitemex ("PinataShell", 0, 0, 0, random (-4, 4), random (-5, 5), random (2, 4),0,SXF_NOCHECKPOSITION,120)
		TNT1 A 0 a_spawnitemex ("PinataBullet", 0, 0, 0, random (-4, 4), random (-5, 5), random (2, 4),0,SXF_NOCHECKPOSITION)
		TNT1 A 0 a_spawnitemex ("PinataBullet", 0, 0, 0, random (-4, 4), random (-5, 5), random (2, 4),0,SXF_NOCHECKPOSITION)
		SCV3 DKLMNO 2
		stop
	}
}

actor ScavLootOrb4 : ScavLootOrb1
{
	states
	{
	spawn:
		TNT1 A 0
		SCV4 A 1 a_setscale (0.30)
		SCV4 B 1 a_setscale (0.35)
		SCV4 C 1 a_setscale (0.25)
		loop
	death:
		TNT1 A 0
		TNT1 A 0 a_spawnitemex ("PinataBullet", 0, 0, 0, random (-4, 4), random (-5, 5), random (2, 4),0,SXF_NOCHECKPOSITION,120)
		TNT1 A 0 a_spawnitemex ("PinataBullet", 0, 0, 0, random (-4, 4), random (-5, 5), random (2, 4),0,SXF_NOCHECKPOSITION)
		SCV4 DKLMNO 2
		stop
	}
}


//Pinata drops
//Code provided by DrPySpy, thank you
//So much man, you're powerful.

//const int PINATASPEED = 12;
const int PINATASPEED = 20;
const int PINATADIST = 186;


//Okay I've heavily edited this thing, I'll be using inheritance like a mofo now
ACTOR PinataBullet
{
	+ISMONSTER
	+NOBLOCKMAP
	+BRIGHT
	+DONTGIB
	+SEEINVISIBLE
	+NODAMAGE
	
	reactiontime 30
	States
	{
	Spawn:
		TNT1 A 0
		SCV5 A 10 A_RearrangePointers (AAPTR_NULL, AAPTR_NULL, AAPTR_NULL)
		goto SpawnLoop
	
	//Looking for the player, jumping up and down
	SpawnLoop:
		"####" "#" random (6,12) A_LookEx(0,0,PINATADIST,0,360)
		"####" "#" 0 A_LookEx(0,0,PINATADIST,0,360)
		"####" "#" 1 a_setscale (0.90)
		"####" "#" 0 A_LookEx(0,0,PINATADIST,0,360)
		"####" "#" 0 thrustthingz (0,10,0,0)
		"####" "#" 1 bright a_setscale (1.10)
		"####" "#" 0 A_LookEx(0,0,PINATADIST,0,360)
		"####" "#" 1 bright a_setscale (1.05)
		"####" "#" 0 A_LookEx(0,0,PINATADIST,0,360)
		"####" "#" 1 bright a_setscale (1.10)
		"####" "#" 0 A_LookEx(0,0,PINATADIST,0,360)
		"####" "#" 1 bright a_setscale (1)
		"####" "#" 0 A_LookEx(0,0,PINATADIST,0,360)
		"####" "#" 0 a_countdown
		Loop
	
	//Spotted player, but they were full on the ammo type
	NoFlight:
		"####" "#" random (6,12)
		"####" "#" 1 a_setscale (0.90)
		"####" "#" 0 thrustthingz (0,10,0,0)
		"####" "#" 1 bright a_setscale (1.10)
		"####" "#" 1 bright a_setscale (1.05)
		"####" "#" 1 bright a_setscale (1.10)
		"####" "#" 1 bright a_setscale (1)
		"####" "#" 0 a_countdown
		goto SpawnLoop	
	
	//Spotted player, check to see if they're not full on ammo first
	//if not, fly towards them
	See:
		"####" "#" 0
		"####" "#" 0 A_JumpIfInTargetInventory ("Clip",0,"NoFlight")
		"####" "#" 0 a_jump (256, "JumpAtTarget")
		goto JumpAtTarget
	JumpAtTarget:
		"####" "#" 1 a_setscale (0.90)
		"####" "#" 0 A_JumpIfCloser(24,"GiveItem")
		"####" "#" 1 a_setscale (0.80)
		"####" "#" 0 A_JumpIfCloser(24,"GiveItem")
		"####" "#" 1 a_facetarget
		"####" "#" 0 A_JumpIfCloser(24,"GiveItem")
		"####" "#" 1 a_scalevelocity (0.05)
		"####" "#" 0 A_GiveInventory ("PinataJumper",1)
		"####" "#" 0 a_facetarget
		"####" "#" 0 ThrustThing(angle*256/360, 25, 0, 0)
		"####" "#" 0 A_JumpIfCloser(24,"GiveItem")
		"####" "#" 1 a_setscale (1.20)
		"####" "#" 0 A_JumpIfCloser(24,"GiveItem")

		"####" "#" 1 a_setscale (1.00)
		"####" "#" 0 A_JumpIfCloser(24,"GiveItem")
		"####" "#" 1 a_setscale (1.00)
		"####" "#" 0 A_JumpIfCloser(24,"GiveItem")
		"####" "#" 1 a_setscale (1.00)
		"####" "#" 1 a_scalevelocity (0.80)
		"####" "#" 0 A_TakeInventory ("PinataJumper",99)
		"####" "#" 0 A_JumpIfCloser(24,"GiveItem")
		"####" "#" 0 A_clearTarget
		"####" "#" 0 a_jump (256, "SpawnLoop")
		goto SpawnLoop	
	Nevermind:
		"####" "#" 0
		"####" "#" 0 a_stop
		"####" "#" 0 A_clearTarget
		"####" "#" 0 a_jump (256, "NoFlight")
		goto NoFlight
	GiveItem:
		"####" "#" 0 
		"####" "#" 0 a_stop
		"####" "#" 0 A_JumpIfInTargetInventory ("Clip",0,"Nevermind")
		"####" "#" 0 A_GiveToTarget("ScavBulletGiver",1)
		"####" "#" 1
		Stop
	}
}

//Holy shit this is dumb but it works, good old gross hacks
ACTOR PinataJumper : CustomInventory
{
	+AUTOACTIVATE
	States
	{
	Spawn:
		TNT1 A 0
		TNT1 A 1
		Stop
	Use:
		TNT1 A 0
		TNT1 A 0 a_jumpif(Z >= FloorZ+30,"NoJump")
		TNT1 A 0 a_jumpif(Z >= FloorZ+45,"TooHigh")
		TNT1 A 0 thrustthingz (0,25,0,0)
		TNT1 A 1 
		Stop
	TooHigh:
		TNT1 A 0 thrustthingz (0,45,1,0)
		TNT1 A 1 
		Stop
	NoJump:
		TNT1 A 1
		stop
	}
}


//This part however is gross hax suggested by Yholl
//But it works.
actor ScavBulletGiver : custominventory 
{
	+notimefreeze
	+dropped
	+noclip
	+DONTGIB
    +INVENTORY.AUTOACTIVATE
	inventory.maxamount 0
	states
	{
	spawn:
		TNT1 A 1
		loop
	Pickup:
		TNT1 A 0
		TNT1 A 0 A_Recoil (-0.0001)
		TNT1 A 0 a_spawnitemex ("ScavBullet",0,0,0,0,0,0,0,SXF_NOCHECKPOSITION)
		stop
	}
}

actor ScavBullet : custominventory 
{
	+notimefreeze
	+dropped
	+noclip
	+DONTGIB
    +INVENTORY.AUTOACTIVATE
	inventory.maxamount 0
	inventory.pickupmessage "Mini Bullet Pack!"
	inventory.pickupsound "misc/MiniAmmo"
	states
	{
	spawn:
		SCV5 A random (6,12)
		SCV5 A 1 a_setscale (0.90)
		TNT1 A 0 thrustthingz (0,10,0,0)
		SCV5 A 1 bright a_setscale (1.10)
		SCV5 A 1 bright a_setscale (1.05)
		SCV5 A 1 bright a_setscale (1.10)
		SCV5 A 1 bright a_setscale (1)
		TNT1 A 0 a_spawnitemex ("PinataBullet",0,0,1,0,0,0,0,SXF_NOCHECKPOSITION)
		stop
	pickup:
		TNT1 A 0
		TNT1 A 1 a_giveinventory ("clip",4)
		stop
	}
}

//==================================================================
//=======================SHELLS=====================================
//==================================================================

ACTOR PinataShell : PinataBullet
{
	States
	{
	Spawn:
		TNT1 A 0
		SCV5 B 10 A_RearrangePointers (AAPTR_NULL, AAPTR_NULL, AAPTR_NULL)
		goto SpawnLoop	
	See:
		"####" "#" 0
		"####" "#" 0 A_JumpIfInTargetInventory ("Shell",0,"NoFlight")
		"####" "#" 0 a_jump (256, "JumpAtTarget")
		goto JumpAtTarget
	GiveItem:
		"####" "#" 0 
		"####" "#" 0 A_JumpIfInTargetInventory ("Shell",0,"Nevermind")
		"####" "#" 0 A_GiveToTarget("ScavShellGiver",1)
		"####" "#" 1
		Stop
	}
}

actor ScavShellGiver : ScavBulletGiver
{
	states
	{
	spawn:
		TNT1 A 1
		loop
	Pickup:
		TNT1 A 0
		TNT1 A 0 A_Recoil (-0.0001)
		TNT1 A 0 a_spawnitemex ("ScavShell",0,0,0,0,0,0,0,SXF_NOCHECKPOSITION)
		stop
	}
}



actor ScavShell : custominventory 
{
	+notimefreeze
	+dropped
	+INVENTORY.AUTOACTIVATE
	inventory.maxamount 0
	inventory.pickupmessage "Mini Shell Pack!"
	inventory.pickupsound "misc/MiniAmmo"
	states
	{
	spawn:
		SCV5 B random (6,12)
		SCV5 B 1 a_setscale (0.90)
		TNT1 A 0 thrustthingz (0,10,0,0)
		SCV5 B 1 bright a_setscale (1.10)
		SCV5 B 1 bright a_setscale (1.05)
		SCV5 B 1 bright a_setscale (1.10)
		SCV5 B 1 bright a_setscale (1)
		TNT1 A 0 a_spawnitemex ("PinataShell",0,0,1,0,0,0,0,SXF_NOCHECKPOSITION)
		stop
	pickup:
		TNT1 A 0
		TNT1 A 1 a_giveinventory ("Shell",2)
		stop
	}
}


//==================================================================
//=======================ROCKETS====================================
//==================================================================


ACTOR PinataRocket : PinataBullet
{
	States
	{
	Spawn:
		TNT1 A 0
		SCV5 C 10 A_RearrangePointers (AAPTR_NULL, AAPTR_NULL, AAPTR_NULL)
		goto SpawnLoop	
	See:
		"####" "#" 0
		"####" "#" 0 A_JumpIfInTargetInventory ("RocketAmmo",0,"NoFlight")
		"####" "#" 0 a_jump (256, "JumpAtTarget")
		goto JumpAtTarget
	GiveItem:
		"####" "#" 0 
		"####" "#" 0 a_jumpifinventory ("RocketAmmo",0,"Nevermind")
		"####" "#" 0 A_GiveToTarget("ScavRocketGiver",1)
		"####" "#" 1
		Stop
	}
}


actor ScavRocketGiver : ScavBulletGiver
{
	states
	{
	spawn:
		TNT1 A 1
		loop
	Pickup:
		TNT1 A 0
		TNT1 A 0 A_Recoil (-0.0001)
		TNT1 A 0 a_spawnitemex ("ScavRocket",0,0,0,0,0,0,0,SXF_NOCHECKPOSITION)
		stop
	}
}



actor ScavRocket : custominventory 
{
	+notimefreeze
	+dropped
    +INVENTORY.AUTOACTIVATE
	inventory.maxamount 0
	inventory.pickupmessage "Mini Rocket (it's still just one)!"
	inventory.pickupsound "misc/MiniAmmo"
	states
	{
	spawn:
		SCV5 C random (6,12)
		SCV5 C 1 a_setscale (0.90)
		TNT1 A 0 thrustthingz (0,10,0,0)
		SCV5 C 1 bright a_setscale (1.10)
		SCV5 C 1 bright a_setscale (1.05)
		SCV5 C 1 bright a_setscale (1.10)
		SCV5 C 1 bright a_setscale (1)
		TNT1 A 0 a_spawnitemex ("PinataRocket",0,0,1,0,0,0,0,SXF_NOCHECKPOSITION)
		stop
	pickup:
		TNT1 A 0
		TNT1 A 1 a_giveinventory ("RocketAmmo",1)
		stop
	}
}




//==================================================================
//==========================CELLS===================================
//==================================================================


ACTOR PinataCell : PinataBullet
{
	States
	{
	Spawn:
		TNT1 A 0
		SCV5 D 10 A_RearrangePointers (AAPTR_NULL, AAPTR_NULL, AAPTR_NULL)
		goto SpawnLoop	
	See:
		"####" "#" 0
		"####" "#" 0 A_JumpIfInTargetInventory ("Cell",0,"NoFlight")
		"####" "#" 0 a_jump (256, "JumpAtTarget")
		goto JumpAtTarget
	GiveItem:
		"####" "#" 0 
		"####" "#" 0 A_JumpIfInventory ("Cell",0,"Nevermind")
		"####" "#" 0 A_GiveToTarget("ScavCellGiver",1)
		"####" "#" 1
		Stop
	}
}


actor ScavCellGiver : ScavBulletGiver
{
	states
	{
	spawn:
		TNT1 A 1
		loop
	Pickup:
		TNT1 A 0
		TNT1 A 0 A_Recoil (-0.0001)
		TNT1 A 0 a_spawnitemex ("ScavCell",0,0,0,0,0,0,0,SXF_NOCHECKPOSITION)
		stop
	}
}


actor ScavCell : custominventory 
{
	+notimefreeze
	+dropped
    +INVENTORY.AUTOACTIVATE
	inventory.maxamount 0
	inventory.pickupmessage "Mini Cell Pack!"
	inventory.pickupsound "misc/MiniAmmo"
	states
	{
	spawn:
		SCV5 D random (6,12)
		SCV5 D 1 a_setscale (0.90)
		TNT1 A 0 thrustthingz (0,10,0,0)
		SCV5 D 1 bright a_setscale (1.10)
		SCV5 D 1 bright a_setscale (1.05)
		SCV5 D 1 bright a_setscale (1.10)
		SCV5 D 1 bright a_setscale (1)
		TNT1 A 0 a_spawnitemex ("PinataCell",0,0,1,0,0,0,0,SXF_NOCHECKPOSITION)
		stop
		pickup:
		TNT1 A 0
		TNT1 A 1 a_giveinventory ("Cell",5)
		stop
	}
}




actor ScavCharge : inventory
{inventory.maxamount 100}


actor speedupcount : inventory
{inventory.maxamount 20}


