
ACTOR RLTantrumCannon : RLWeapon
{
  Inventory.Pickupsound "weapons/unique"
  Obituary "%o got too near %k's quantum blasts."
  Tag "Quantum Tantrum Cannon"
  Weapon.SelectionOrder 1900
  Weapon.SlotNumber 5
  Weapon.AmmoUse1 5
  Weapon.AmmoGive1 0
  Weapon.AmmoType1 "RLTantrumCannonClip"
  Weapon.AmmoType2 "Cell"
  Inventory.Icon "QTCWICON"
  States
  {
  Ready:
	TNT1 A 0 A_JumpIfInventory("RLMisfireSpamPreventionCooldown",1,"MisfirePrevention")
    QTCW AD 1 A_WeaponReady (WRF_ALLOWZOOM | WRF_ALLOWRELOAD)
    Loop
	
  ScavengerDrop:
	TNT1 A 0 A_JumpIfInventory("RLScavengerDrop",1,"WeaponDropConfirm")
	TNT1 A 0 A_GiveInventory("RLScavengerDrop",1)
	TNT1 A 0 A_Print("Press again to drop current weapon,\nor press \crAlt Fire\c- to scrap it to retrieve a Mod Pack.")
	Goto AfterModDrop
  WeaponDropConfirm:
	TNT1 A 0 A_GiveInventory("RLMisfireSpamPreventionCooldown",1)
	TNT1 A 0 A_TakeInventory("RLScavengerDrop",1)
	TNT1 A 0 A_TakeInventory("RLWeaponDrop",1)
	TNT1 A 0 A_JumpIfInventory("RLTantrumCannonModLimit", 1, "WeaponDropModded")
	TNT1 A 0 A_SpawnItemEx("RLTantrumCannonPickup", 0, 0, 40, 10, 0, 0, 0, SXF_SETMASTER)
	Goto WeaponDropRemoval
  WeaponDropModded:
	TNT1 A 2 A_SpawnItemEx("RLTantrumCannonPickupModded", 0, 0, 40, 10, 0, 0, 0, SXF_SETMASTER)
  WeaponDropRemoval:
    TNT1 A 0 A_TakeInventory("RLTantrumCannonModLimit", 1)
    TNT1 A 0 A_TakeInventory("RLTantrumCannonPowerMod", 1)
    TNT1 A 0 A_TakeInventory("RLTantrumCannonBulkMod", 1)
    TNT1 A 0 A_TakeInventory("RLTantrumCannonAgilityMod", 1)
    TNT1 A 0 A_TakeInventory("RLTantrumCannonTechnicalMod", 1)
    TNT1 A 0 A_TakeInventory("RLTantrumCannonSniperMod", 1)
    TNT1 A 0 A_TakeInventory("RLTantrumCannonFirestormMod", 1)
    TNT1 A 0 A_TakeInventory("RLTantrumCannonNanoMod", 1)
	TNT1 A 0 A_GiveInventory("RLRarityTokenRemover", 1)
	TNT1 A 0 A_TakeInventory("RLTantrumCannonSelected", 1)
	TNT1 A 0 A_TakeInventory("RLWeaponLimit",1)
	TNT1 A 1 A_TakeInventory("RLTantrumCannon",1)
	Stop
  AfterModDrop:
    QTCW ADADADAD 1 A_WeaponReady (16)
    Goto Ready
  MisfirePrevention:
    QTCW AD 1 A_WeaponReady (WRF_NOFIRE | WRF_NOBOB)
    TNT1 A 0 A_JumpIfInventory("RLMisfireSpamPreventionCooldown", 1, "MisfirePrevention")
    Goto Ready
	
  Deselect:
	TNT1 A 0
	TNT1 A 0 A_GiveInventory("RLDeselectionFunction",1)
	TNT1 A 0 A_TakeInventory("RLTantrumCannonSelected", 1)
	TNT1 A 0 A_GiveInventory("RLRarityTokenRemover", 1)
  DeselectLoop:
    TNT1 A 0 A_JumpIfInventory("RLShellshockPerk", 1, "DeselectRenegade")
    QTCW DEFG 1
  DeselectLoopEnd:
    TNT1 A 0 A_Lower
    QTCW G 1 A_Lower
    Loop
  DeselectRenegade:
    TNT1 A 0 A_Lower
    loop
  SelectRenegade: 
    TNT1 A 0 A_Raise
    loop
  SelectSetWeapon:
	TNT1 A 0 A_GiveInventory("RLEfficientAmmoTypeWeapon", 1)
	TNT1 A 0 A_GiveInventory("RLUniqueWeaponToken", 1)
	TNT1 A 0 A_GiveInventory("RLTantrumCannonSelected", 1)
    Goto SelectLoop
  SelectLoop:
    TNT1 A 0 A_JumpIfInventory("RLShellshockPerk", 1, "SelectRenegade")
    TNT1 A 0 A_Raise
    QTCW A 1 A_Raise
    Loop
  Fire:
	
	QTCW A 0 A_JumpIfInventory("RLRestrictionMeleeOnly",1,"MeleeRestricted") // Cannot fire in levels that restrict it
	QTCW A 0 A_JumpIfInventory("RLRestrictionSilencedOnly",1,"SilencedRestricted") // Cannot fire in levels that restrict it
	QTCW A 0 A_JumpIfInventory("RLRestrictionNoBoom",1,"NoBoomRestricted") // Cannot fire in levels that restrict it
	QTCW A 0 A_JumpIfInventory("RLRestrictionLowTechOnly",1,"LowTechRestricted") // Cannot fire in levels that restrict it
	QTCW A 0 A_JumpIfInventory("RLRestrictionCunningOnly",1,"CunningRestricted") // Cannot fire in levels that restrict it
	
	TNT1 A 0 A_JumpIfInventory("RLFireangelPerk",1,2)
	TNT1 A 0 A_JumpIfInventory("RLTantrumCannonClip",10, 2)
	Goto Reload
	TNT1 A 0 A_JumpIfInventory("RLTantrumCannonClip",5, 1)
	Goto Reload
	TNT1 A 0 A_AlertMonsters
	TNT1 A 0 A_JumpIfInventory("RLTantrumCannonNanoMod",1,"FireN")
	TNT1 A 0 A_JumpIfInventory("RLTantrumCannonFirestormMod",1,"FireF")
	TNT1 A 0 A_JumpIfInventory("RLTantrumCannonSniperMod",1,"FireS")
	TNT1 A 0 A_JumpIfInventory("RLTantrumCannonPowerMod",1,"FireP")
	TNT1 A 0 A_JumpIfInventory("RLTantrumCannonAgilityMod",1,"FireA")
	TNT1 A 0 A_FireCustomMissile ("RLTantrumCannonBall", 0, 1)
	TNT1 A 0 A_JumpIfInventory("RLFireangelPerk",1,"FireFinish")
	TNT1 A 0 A_TakeInventory ("RLTantrumCannonClip", 5, TIF_NOTAKEINFINITE)
    Goto FireFinish
  FireP:
	TNT1 A 0 A_FireCustomMissile ("RLTantrumCannonBallP", 0, 1)
	TNT1 A 0 A_JumpIfInventory("RLFireangelPerk",1,"FireFinish")
	TNT1 A 0 A_TakeInventory ("RLTantrumCannonClip", 5, TIF_NOTAKEINFINITE)
    Goto FireFinish
  FireA:
	TNT1 A 0 A_FireCustomMissile ("RLTantrumCannonBallA", 0, 1)
	TNT1 A 0 A_JumpIfInventory("RLFireangelPerk",1,"FireFinish")
	TNT1 A 0 A_TakeInventory ("RLTantrumCannonClip", 5, TIF_NOTAKEINFINITE)
    Goto FireFinish
  FireS:
	TNT1 A 0 A_FireCustomMissile ("RLTantrumCannonBallS", 0, 1)
	TNT1 A 0 A_JumpIfInventory("RLFireangelPerk",1,"FireFinish")
	TNT1 A 0 A_TakeInventory ("RLTantrumCannonClip", 5, TIF_NOTAKEINFINITE)
    Goto FireFinish
  FireF:
	TNT1 A 0 A_FireCustomMissile ("RLTantrumCannonBallF", 0, 1)
	TNT1 A 0 A_JumpIfInventory("RLFireangelPerk",1,"FireFinish")
	TNT1 A 0 A_TakeInventory ("RLTantrumCannonClip", 5, TIF_NOTAKEINFINITE)
    Goto FireFinish
  FireN:
	TNT1 A 0 A_FireCustomMissile ("RLTantrumCannonBall", 0, 1)
	TNT1 A 0 A_FireCustomMissile ("RLTantrumCannonBallN", 15, 0)
	TNT1 A 0 A_FireCustomMissile ("RLTantrumCannonBallN", 30, 0)
	TNT1 A 0 A_FireCustomMissile ("RLTantrumCannonBallN", -15, 0)
	TNT1 A 0 A_FireCustomMissile ("RLTantrumCannonBallN", -30, 0)
	TNT1 A 0 A_JumpIfInventory("RLFireangelPerk",1,"FireFinish")
	TNT1 A 0 A_TakeInventory ("RLTantrumCannonClip", 5, TIF_NOTAKEINFINITE)
    Goto FireFinish
  FireFinish:
    TNT1 A 0 A_SpawnItemEx ("RLRocketLauncherRecoil", 0,0,0, 0,0,0, 0, SXF_NOCHECKPOSITION | SXF_SETMASTER) // Pitch-based recoil
    QTCW B 4 Bright A_GunFlash
    QTCW C 4 Bright
    QTCW DEF 1
    QTCW G 20
    QTCW FEDA 1
    QTCW A 2
    Goto Ready
  Reload:
	QTCW AD 1 A_WeaponReady (WRF_NOPRIMARY | WRF_ALLOWZOOM)
	TNT1 A 0 A_JumpIfInventory("RLTantrumCannonBulkMod",1,2)
	TNT1 A 0 A_JumpIfInventory("RLTantrumCannonClip", 20, "Ready")
	Goto ReloadStartingAmmoCheck
	TNT1 A 0 A_JumpIfInventory("RLTantrumCannonClip", 38, "Ready")
  ReloadStartingAmmoCheck:
	TNT1 A 0 A_JumpIfInventory("Cell", 1, 1)
	Goto Ready
  ReloadSequence:
	TNT1 A 0 // Play the reload animation.
    TNT1 A 0 A_SpawnItemEx ("RLHeavyReloadOutRecoil", 0,0,0, 0,0,0, 0, SXF_NOCHECKPOSITION | SXF_SETMASTER) // Pitch-based recoil
	TNT1 A 0 A_JumpIfInventory("RLTantrumCannonTechnicalMod",1,"Reload1")
    TNT1 A 0 A_PlaySound("weapons/tantrumcannonreload", CHAN_ITEM)
    QTCW D 2
    QTCW E 2
    QTCW F 2
    QTCW G 8
    QTCW H 4
    QTCW I 60
	Goto ReloadWorking
  Reload1:
    TNT1 A 0 A_PlaySound("weapons/tantrumcannonreload", CHAN_ITEM)
    QTCW D 2
    QTCW E 2
    QTCW F 2
    QTCW G 8
    QTCW H 4
    QTCW I 60
  ReloadWorking:
	TNT1 A 0 A_TakeInventory("Cell", 1)
	TNT1 A 0 A_GiveInventory("RLTantrumCannonClip", 1)
	TNT1 A 0 A_JumpIfInventory("RLTantrumCannonBulkMod",1,2)
	TNT1 A 0 A_JumpIfInventory("RLTantrumCannonClip",20,3)
	Goto ReloadWorkingAmmoCheck
	TNT1 A 0 A_JumpIfInventory("RLTantrumCannonClip",38,2)
  ReloadWorkingAmmoCheck:
	TNT1 A 0 A_JumpIfInventory("Cell",1,2)
	TNT1 A 0
	Goto ReloadFinish
	TNT1 A 0
	Goto ReloadWorking
  ReloadFinish:
    TNT1 A 0 A_SpawnItemEx ("RLHeavyReloadInRecoil", 0,0,0, 0,0,0, 0, SXF_NOCHECKPOSITION | SXF_SETMASTER) // Pitch-based recoil
	TNT1 A 0 A_JumpIfInventory("RLTantrumCannonTechnicalMod",1,"ReloadFinish1")
	QTCW J 6
	QTCW I 12
	QTCW H 2
    QTCW G 2
    QTCW F 2
    QTCW E 2
    QTCW D 2
    QTCW A 2
	Goto Ready
  ReloadFinish1:
	QTCW J 6
	QTCW I 6
	QTCW H 2
    QTCW G 2
    QTCW F 2
    QTCW E 2
    QTCW D 2
    QTCW A 2
	Goto Ready
	
  Flash:
    TNT1 A 4 A_Light2
    TNT1 A 4 A_Light1
    Goto LightDone
	
  Spawn:
	TNT1 A 0 NoDelay A_SpawnItemEx("RLTantrumCannonPickup",0,0,0, 0,0,0, 0,SXF_NOCHECKPOSITION, 0, tid)
    Stop
  Altfire:
	TNT1 A 0 A_JumpIfInventory("RLArmorModItemActivate",1, "ArmorModConversion")
	TNT1 A 0 A_JumpIfInventory("RLScavengerDrop",1,"ScavengerTime")
    QTCW AD 1 A_WeaponReady (WRF_NOFIRE)
	Goto Ready
  ModDiscombobulation:
	TNT1 A 0 A_Print("Applied Mod pack extracted from discarded weapon.")
	TNT1 A 0 ACS_NamedExecuteAlways("ScavengeMods", 0)
	TNT1 A 3
	TNT1 A 0 A_TakeInventory("RLScavengerDrop",1)
    TNT1 A 0 A_TakeInventory("RLTantrumCannonModLimit", 1)
    TNT1 A 0 A_TakeInventory("RLTantrumCannonPowerMod", 1)
    TNT1 A 0 A_TakeInventory("RLTantrumCannonBulkMod", 1)
    TNT1 A 0 A_TakeInventory("RLTantrumCannonAgilityMod", 1)
    TNT1 A 0 A_TakeInventory("RLTantrumCannonTechnicalMod", 1)
    TNT1 A 0 A_TakeInventory("RLTantrumCannonSniperMod", 1)
    TNT1 A 0 A_TakeInventory("RLTantrumCannonFirestormMod", 1)
    TNT1 A 0 A_TakeInventory("RLTantrumCannonNanoMod", 1)
	TNT1 A 0 A_GiveInventory("RLRarityTokenRemover", 1)
	TNT1 A 0 A_TakeInventory("RLTantrumCannonSelected", 1)
	TNT1 A 0 A_TakeInventory("RLWeaponLimit",1)
	Goto ScavengerTimeEnd
  ScavengerTime:
	TNT1 A 0 A_GiveInventory("RLScavengingExtraEffects", 1)
	TNT1 A 0 A_JumpIfInventory("RLTantrumCannonModLimit",1,"ModDiscombobulation")
	TNT1 A 0 A_Print("Mod pack extracted from discarded weapon.")
	TNT1 A 0 A_TakeInventory("RLScavengerDrop",1)
    TNT1 A 0 A_TakeInventory("RLTantrumCannonModLimit", 1)
    TNT1 A 0 A_TakeInventory("RLTantrumCannonPowerMod", 1)
    TNT1 A 0 A_TakeInventory("RLTantrumCannonBulkMod", 1)
    TNT1 A 0 A_TakeInventory("RLTantrumCannonAgilityMod", 1)
    TNT1 A 0 A_TakeInventory("RLTantrumCannonTechnicalMod", 1)
    TNT1 A 0 A_TakeInventory("RLTantrumCannonSniperMod", 1)
    TNT1 A 0 A_TakeInventory("RLTantrumCannonFirestormMod", 1)
    TNT1 A 0 A_TakeInventory("RLTantrumCannonNanoMod", 1)
	TNT1 A 0 A_GiveInventory("RLRarityTokenRemover", 1)
	TNT1 A 0 A_TakeInventory("RLTantrumCannonSelected", 1)
	TNT1 A 0 A_TakeInventory("RLWeaponLimit",1)
	TNT1 A 0 A_GiveInventory("RLEmitScavengedModUnique", 1) // Determines what mods this can generate when scavenged.
	Goto ScavengerTimeEnd
  ScavengerTimeEnd:
	TNT1 A 1 A_TakeInventory("RLTantrumCannon",1)
	Stop
  }
}

//-------------------------------------------------------------------
//		PROJECTILES

ACTOR RLTantrumCannonBall : Rocket
{
	+THRUACTORS
	+USEBOUNCESTATE
	-DEHEXPLOSION
	-ROCKETTRAIL
	+FORCEXYBILLBOARD
	Radius 5
	Height 5
	Speed 15
	Damage 0
	RenderStyle Add
	Alpha 0.95
	Damagetype "Plasma"
	BounceType "Doom"
	BounceFactor 1
	WallBounceFactor 1
	SeeSound "weapons/tantrumcannon"
	BounceSound "weapons/tantrumcannonbounce"
	DeathSound ""

	var int user_tantrumbounce;
	States
	{
		Spawn:
			QTCB A 2 Bright
			TNT1 A 1
			QTCB B 2 Bright
			TNT1 A 1
			QTCB C 2 Bright
			TNT1 A 1
			QTCB B 2 Bright
			TNT1 A 1
			QTCB A 2 Bright
			TNT1 A 1
			QTCB B 2 Bright
			TNT1 A 1
			QTCB C 2 Bright
			TNT1 A 1
			QTCB B 2 Bright
			TNT1 A 1
			Goto SpawnLoop
		SpawnLoop:
			QTCB A 0 A_JumpIf(CallACS("DRLA_Fancyprojectiles") == 1, "SpawnLoop.Fancy")
		SpawnLoop.Normal:
			QTCB A 2 Bright
			TNT1 A 1
			QTCB B 2 Bright
			TNT1 A 1
			QTCB C 2 Bright
			TNT1 A 1
			QTCB B 2 Bright
			TNT1 A 1
			TNT1 A 0 A_CustomMissile ("RLTantrumCannonBlast", 0, 0, 0, CMF_TRACKOWNER)
			Goto SpawnLoop
		SpawnLoop.Fancy:
			TNT1 A 4
			QTCB ABCB 2 Bright
			QTCB A 0 A_CustomMissile ("RLTantrumCannonBlast", 0, 0, 0, CMF_TRACKOWNER)
			QTCB A 0 A_SpawnItemEx("RLTantrumCannonTrail")
			Goto SpawnLoop
		Bounce:
			TNT1 A 0 A_JumpIf(user_tantrumbounce >= 6, "Death")
			TNT1 A 0 A_SetUserVar("user_tantrumbounce", user_tantrumbounce+1)
			Goto SpawnLoop
		Death:
			TNT1 A 0 A_ChangeFlag ("NOCLIP", 1)
			TNT1 A 0 A_Stop
			TNT1 A 0 A_JumpIf(CallACS("DRLA_QuakeNShake") == 0, 3)
			TNT1 A 0 A_Quake (1, 8, 0, 768, "")
			TNT1 A 0 A_Quake (6, 8, 0, 384, "")
			TNT1 A 0 A_PlaySound ("weapons/tantrumcannonexplode", 7, 1, 0, 0.5)
			TNT1 A 0 A_PlaySound("weapons/tantrumcannonexplode", CHAN_ITEM, 0.05, 0, 0.05)
			TNT1 A 0 A_Explode (256,128,0)
			TNT1 A 0 A_Explode (8,128)
			QTCB D 3 Bright
			QTCB D 0 Bright
			QTCB E 3 Bright
			QTCB F 3 Bright
			QTCB F 1 Bright A_FadeTo (0, 0.1, 1)
			Wait
	}
}

ACTOR RLTantrumCannonTrail
{
	Renderstyle Add
	+NOINTERACTION
	+FORCEXYBILLBOARD
	States
	{
		Spawn:
			TAFT AB 1
			TAFT CDE 3
			TAFT FFFGGG 2 A_FadeOut
			Stop
	}
}

ACTOR RLTantrumCannonBlast : BFGExtra
{
	+THRUGHOST
	+FORCEXYBILLBOARD
	Alpha 0.95
	DamageType "Plasma"
	States
	{
		Spawn:
			TNT1 A 0
			TNT1 A 0 A_JumpIf(CallACS("DRLA_QuakeNShake") == 0, 3)
			TNT1 A 0 A_Quake (1, 8, 0, 768, "")
			TNT1 A 0 A_Quake (6, 8, 0, 384, "")
			TNT1 A 0 A_PlaySound ("weapons/tantrumcannonexplode", 7, 1, 0, 0.5)
			TNT1 A 0 A_PlaySound("weapons/tantrumcannonexplode", CHAN_ITEM, 0.05, 0, 0.05)
			QTCB D 3 Bright A_Explode (128,256,0)
			QTCB D 0 Bright A_Explode (8,128)
			QTCB E 3 Bright
			QTCB F 3 Bright
			QTCB F 1 Bright A_FadeTo (0, 0.1, 1)
			Wait
	}
}

ACTOR RLTantrumCannonBallP : RLTantrumCannonBall
{
	States
	{
		SpawnLoop:
			QTCB A 0 A_JumpIf(CallACS("DRLA_Fancyprojectiles") == 1, "SpawnLoop.Fancy")
		SpawnLoop.Normal:
			QTCB A 2 Bright
			TNT1 A 1
			QTCB B 2 Bright
			TNT1 A 1
			QTCB C 2 Bright
			TNT1 A 1
			QTCB B 2 Bright
			TNT1 A 1
			TNT1 A 0 A_CustomMissile ("RLTantrumCannonBlastP", 0, 0, 0, CMF_TRACKOWNER)
			Goto SpawnLoop
		SpawnLoop.Fancy:
			TNT1 A 4
			QTCB ABCB 2 Bright
			QTCB A 0 A_CustomMissile ("RLTantrumCannonBlastP", 0, 0, 0, CMF_TRACKOWNER)
			QTCB A 0 A_SpawnItemEx("RLTantrumCannonTrail")
			Goto SpawnLoop
		Death:
			TNT1 A 0 A_ChangeFlag ("NOCLIP", 1)
			TNT1 A 0 A_Stop
			TNT1 A 0 A_JumpIf(CallACS("DRLA_QuakeNShake") == 0, 3)
			TNT1 A 0 A_Quake (1, 8, 0, 768, "")
			TNT1 A 0 A_Quake (6, 8, 0, 384, "")
			TNT1 A 0 A_PlaySound ("weapons/tantrumcannonexplode", 7, 1, 0, 0.5)
			TNT1 A 0 A_PlaySound("weapons/tantrumcannonexplode", CHAN_ITEM, 0.05, 0, 0.05)
			TNT1 A 0 A_Explode (448,128,0)
			TNT1 A 0 A_Explode (8,128)
			QTCB D 3 Bright
			QTCB D 0 Bright
			QTCB E 3 Bright
			QTCB F 3 Bright
			QTCB F 1 Bright A_FadeTo (0, 0.1, 1)
			Wait
	}
}

ACTOR RLTantrumCannonBlastP : RLTantrumCannonBlast
{
	States
	{
		Spawn:
			TNT1 A 0
			TNT1 A 0 A_JumpIf(CallACS("DRLA_QuakeNShake") == 0, 3)
			TNT1 A 0 A_Quake (1, 8, 0, 768, "")
			TNT1 A 0 A_Quake (6, 8, 0, 384, "")
			TNT1 A 0 A_PlaySound ("weapons/tantrumcannonexplode", 7, 1, 0, 0.5)
			TNT1 A 0 A_PlaySound("weapons/tantrumcannonexplode", CHAN_ITEM, 0.05, 0, 0.05)
			TNT1 A 0 A_Explode (224,128,0)
			TNT1 A 0 A_Explode (8,128)
			QTCB D 3 Bright
			QTCB D 0 Bright
			QTCB E 3 Bright
			QTCB F 3 Bright
			QTCB F 1 Bright A_FadeTo (0, 0.1, 1)
			Wait
	}
}

ACTOR RLTantrumCannonBallA : RLTantrumCannonBall
{
	Speed 45
}

ACTOR RLTantrumCannonBallF : RLTantrumCannonBall
{
	States
	{
		Spawn:
			QTCB A 2 Bright
			TNT1 A 1
			QTCB B 2 Bright
			TNT1 A 1
			QTCB C 2 Bright
			TNT1 A 1
			QTCB B 2 Bright
			TNT1 A 1
			Goto SpawnLoop
		SpawnLoop:
			QTCB A 0 A_JumpIf(CallACS("DRLA_Fancyprojectiles") == 1, "SpawnLoop.Fancy")
		SpawnLoop.Normal:
			QTCB A 2 Bright
			TNT1 A 1
			QTCB B 2 Bright
			TNT1 A 1
			QTCB C 2 Bright
			TNT1 A 1
			QTCB B 2 Bright
			TNT1 A 1
			TNT1 A 0 A_CustomMissile ("RLTantrumCannonBlast", 0, 0, 0, CMF_TRACKOWNER)
			TNT1 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA 0 A_CustomMissile ("RLTantrumCannonStarburst", 0, 0, random(0,359), CMF_AIMDIRECTION | CMF_TRACKOWNER, random(-90,90))
			Goto SpawnLoop
		SpawnLoop.Fancy:
			TNT1 A 4
			QTCB ABCB 2 Bright
			QTCB A 0 A_CustomMissile ("RLTantrumCannonBlast", 0, 0, 0, CMF_TRACKOWNER)
			QTCB AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA 0 A_CustomMissile ("RLTantrumCannonStarburst", 0, 0, random(0,359), CMF_AIMDIRECTION | CMF_TRACKOWNER, random(-90,90))
			QTCB A 0 A_SpawnItemEx("RLTantrumCannonTrail")
			Goto SpawnLoop
		Bounce:
			TNT1 A 0 A_JumpIf(user_tantrumbounce >= 6, "Death")
			TNT1 A 0 A_SetUserVar("user_tantrumbounce", user_tantrumbounce+1)
			Goto SpawnLoop
	}
}

ACTOR RLTantrumCannonStarburst
{
	Radius	5
	Height	5
	Speed	15
	Damage	(25)
	Damagetype "Plasma"
	SeeSound "weapons/tantrumcannonbounce"
	DeathSound ""
	RenderStyle Add
	Alpha 0.95
	PROJECTILE
	+THRUACTORS
	States
	{
		Spawn:
			QTCB CBAB 2 Bright
			Loop
		Death:
			QTCB F 2 A_SetScale(0.1)
			QTCB F 0 A_Explode(8,64,0)
			QTCB ED 2
			Stop
	}
}

ACTOR RLTantrumCannonBallS : RLTantrumCannonBall
{
	+USEBOUNCESTATE
	+SEEKERMISSILE
	+SCREENSEEKER
	BounceCount 12
	States
	{
		Bounce:
			TNT1 A 0 A_CustomMissile ("RLTantrumCannonBlastS", 0, 0, 0, CMF_TRACKOWNER)
			TNT1 A 0 A_JumpIf(user_tantrumbounce >= 6, "Death")
			TNT1 A 0 A_SetUserVar("user_tantrumbounce", user_tantrumbounce+1)
			TNT1 AAAA 0 A_SeekerMissile (90, 90, SMF_LOOK | SMF_PRECISE, 256) 
			TNT1 A 0 A_CustomMissile ("RLTantrumCannonHomingBurst", 0, 0, random(0,359), CMF_AIMDIRECTION | CMF_TRACKOWNER, random(-90,90))
			Goto SpawnLoop
	}
}

ACTOR RLTantrumCannonBlastS : RLTantrumCannonBlast
{
	Scale 2
	States
	{
		Spawn:
			TNT1 A 0
			TNT1 A 0 A_JumpIf(CallACS("DRLA_QuakeNShake") == 0, 3)
			TNT1 A 0 A_Quake (1, 8, 0, 1024, "")
			TNT1 A 0 A_Quake (8, 8, 0, 512, "")
			TNT1 A 0 A_PlaySound ("weapons/tantrumcannonexplode", 7, 1, 0, 0.5)
			TNT1 A 0 A_PlaySound("weapons/tantrumcannonexplode", CHAN_ITEM, 0.05, 0, 0.05)
			QTCB D 3 Bright A_Explode (600,256,0)
			QTCB D 0 Bright A_Explode (8,128)
			QTCB E 3 Bright
			QTCB F 3 Bright
			QTCB F 1 Bright A_FadeTo (0, 0.1, 1)
			Wait
	}
}

ACTOR RLTantrumCannonHomingBurst
{
	Decal "ArachnotronScorch"
	Translation "112:127=176:191", "224:231=168:175"
	Radius	13
	Height	8
	Speed	25
	Damage	(25)
	DamageType "Plasma"
	Scale	0.8
	BounceType "Doom"
	BounceCount 2
	RenderStyle Add
	Alpha 0.85
	SeeSound ""
	Projectile
	+RANDOMIZE
	+THRUGHOST
	+SEEKERMISSILE
	+SCREENSEEKER
	-USEBOUNCESTATE
	States
	{
		Spawn:
			TNT1 A 0
			TNT1 AAAA 0 A_SeekerMissile (90, 90, SMF_LOOK | SMF_PRECISE, 256)
		SpawnLoop:
			TNT1 A 0 A_JumpIf(CallACS("DRLA_Fancyprojectiles") == 1, "Spawn.Fancy")
		Spawn.Normal:
			APLS AB 5 Bright
			Loop
		Spawn.Fancy:
			APLS ABAB 2 Bright A_SpawnItemEx("RLTantrumCannonHomingBurstTrail")
			Loop
		Bounce:
			TNT1 AAAA 0 A_SeekerMissile (90, 90, SMF_LOOK | SMF_PRECISE, 256) 
			Goto SpawnLoop
		Death:
			APBX A 0 A_Explode(256, 256, 0)
			APBX A 0 A_Explode(8, 128)
			APBX ABCDE 5 Bright
			Stop
	}
}

ACTOR RLTantrumCannonHomingBurstTrail
{
	Translation "224:231=168:175"
	Renderstyle Add
	Scale 0.2
	+NOINTERACTION
	States
	{
		Spawn:
			APBX A 2 A_FadeOut
			APBX A 0 A_SetScale(scalex + 0.1)
			APBX B 2 A_FadeOut
			APBX B 0 A_SetScale(scalex + 0.1)
			APBX C 2 A_FadeOut
			APBX C 0 A_SetScale(scalex + 0.1)
			APBX D 2 A_FadeOut
			APBX D 0 A_SetScale(scalex + 0.1)
			APBX E 2 A_FadeOut
			APBX E 0 A_SetScale(scalex + 0.1)
			Stop
	}
}

ACTOR RLTantrumCannonBallN : RLTantrumCannonBall
{
	Scale 0.5
	SeeSound ""
	States
	{
		SpawnLoop:
			QTCB A 2 Bright
			TNT1 A 1
			QTCB B 2 Bright
			TNT1 A 1
			QTCB C 2 Bright
			TNT1 A 1
			QTCB B 2 Bright
			TNT1 A 1
			TNT1 A 0 A_CustomMissile ("RLTantrumCannonBlastN", 0, 0, 0, CMF_TRACKOWNER)
			Goto SpawnLoop
		Death:
			TNT1 A 0 A_ChangeFlag ("NOCLIP", 1)
			TNT1 A 0 A_Stop
			TNT1 A 0 A_JumpIf(CallACS("DRLA_QuakeNShake") == 0, 3)
			TNT1 A 0 A_Quake (1, 8, 0, 768, "")
			TNT1 A 0 A_Quake (6, 8, 0, 384, "")
			TNT1 A 0 A_PlaySound ("weapons/tantrumcannonexplode", 7, 1, 0, 0.5)
			TNT1 A 0 A_PlaySound("weapons/tantrumcannonexplode", CHAN_ITEM, 0.05, 0, 0.05)
			QTCB D 2 Bright A_Explode (128,128,0)
			QTCB E 2 Bright
			QTCB F 2 Bright
			QTCB F 1 Bright A_FadeTo (0, 0.1, 1)
			Wait
	}
}

ACTOR RLTantrumCannonBlastN : RLTantrumCannonBlast
{
	Scale 0.5
	States
	{
		Spawn:
			TNT1 A 0
			TNT1 A 0 A_JumpIf(CallACS("DRLA_QuakeNShake") == 0, 3)
			TNT1 A 0 A_Quake (1, 8, 0, 768, "")
			TNT1 A 0 A_Quake (6, 8, 0, 384, "")
			TNT1 A 0 A_PlaySound ("weapons/tantrumcannonexplode", 7, 1, 0, 0.5)
			TNT1 A 0 A_PlaySound("weapons/tantrumcannonexplode", CHAN_ITEM, 0.05, 0, 0.05)
			QTCB D 2 Bright A_Explode (64,64,0)
			QTCB E 2 Bright
			QTCB F 2 Bright
			QTCB F 1 Bright A_FadeTo (0, 0.1, 1)
			Wait
	}
}

//-------------------------------------------------------------------
//		MECHANICS

Actor RLTantrumCannonSelected : RLPermanentInventory {}
Actor RLTantrumCannonModLimit : RLUniqueModAmount {}
Actor RLTantrumCannonPowerMod : RLUniqueModAmount {}
Actor RLTantrumCannonBulkMod : RLUniqueModAmount {}
Actor RLTantrumCannonAgilityMod : RLUniqueModAmount {}
Actor RLTantrumCannonTechnicalMod : RLUniqueModAmount {}
Actor RLTantrumCannonNanoMod : RLUniqueModAmount {}
Actor RLTantrumCannonFirestormMod : RLUniqueModAmount {}
Actor RLTantrumCannonSniperMod : RLUniqueModAmount {}

ACTOR RLTantrumCannonClip : Ammo
{
   +INVENTORY.IGNORESKILL
   Inventory.MaxAmount 38
   Inventory.Icon ""
}

//-------------------------------------------------------------------
//		PICKUPS

ACTOR RLTantrumCannonPickup : RLUniqueWeaponPickup
{
	//$Sprite QTCWX0
	Tag "Quantum Tantrum Cannon [Pickup]"
	States
	{
	SpawnFrame:
		QTCW X 4
		"####" "#" 0 A_Jump(256, "SpawnLoop")
		Goto SpawnLoop
	SpawnLoop:
		"####" "#" 0 A_JumpIf(Abs(VelZ) <= 0.01 && user_floorhit == 0, "FloorHit")
		"####" "#" 1
		Loop
	FloorHit:
		"####" "#" 0 A_PlaySound("weapons/gundropbig")
		"####" "#" 0 A_ScaleVelocity (0.25)
		"####" "#" 0 A_ChangeFlag("SPECIAL", true)
		"####" "#" 0 A_ChangeFlag("THRUACTORS", false)
		"####" "#" 0 A_SetUserVar("user_floorhit", 1)
		"####" "#" 0 A_Jump(256, "SpawnLoop")
		Stop
	Pickup:
		"####" "#" 0
		"####" "#" 0 A_JumpIfInventory("RLTantrumCannon",1,"NotPickup") // If the player already has this weapon, they are not given the weapon
		"####" "#" 0 A_JumpIfInventory("RLWeaponLimit",0,"NotPickupLimit") // The absolute max limit check for weapons
		"####" "#" 0 A_Jump(256, "GiveWeapon")
		Goto GiveWeapon
	GiveWeapon:
		"####" "#" 0 A_GiveInventory("RLTantrumCannon",1)
		"####" "#" 0 A_GiveInventory("RLWeaponLimit",1)
		"####" "#" 0 A_GiveInventory("RLUniqueItemFound",1, AAPTR_PLAYER1)
		"####" "#" 0 A_Print("\ccPicked up the \cdQuantum Tantrum Cannon.")
		Goto PickupSound
	NotPickupLimit:
		"####" "#" 0 A_Jump(256, "NotPickup")
		Goto NotPickup
	NotPickup:
		"####" "#" 0 A_JumpIfInventory("DRLA_WeaponAntiLogFloodCheck",1,"NotPickup_NoPrint")
		"####" "#" 0 A_GiveInventory("DRLA_WeaponAntiLogFloodCheck")
		"####" "#" 0 A_Print("\cd= Quantum Tantrum Cannon =", 2, "CONFONT")
		Goto NotPickup_NoPrint
	NotPickup_NoPrint:
		"####" "#" 0
		Fail
	PickupSound:
		"####" "#" 0 A_PlaySound("weapons/TantrumCannonpickup")
		Stop
//==============================================================================
	MarathonStuff:
		"####" "#" 0 A_SpawnItemEx("RLMarathonShells",0,0,0, 0,0,0, 0,SXF_NOCHECKPOSITION)
		Stop
	SuperweaponStuff:
		"####" "#" 0 A_Jump(256, "NoSpecialStartsStuff")
		Goto NoSpecialStartsStuff
	}
}

ACTOR RLTantrumCannonWorldSpawnPickup : RLTantrumCannonPickup 17112
{
	States
	{
	NoSpecialStartsStuff:
		TNT1 A 0 A_SpawnItemEx("RLRarityBeamUniqueWorld", 0,0,0, 0,0,0, 0, SXF_SETMASTER)
		TNT1 A 0 A_JumpIf(CallACS("DRPGCheckTiem"), "DRPGInit")
		"####" "#" 0 A_Jump(256, "SpawnFrame")
		Goto SpawnFrame
		
	SpawnFrame:
		QTCW X 4
		"####" "#" 0 A_GiveInventory("RLUniqueItemSpawnMessageSender",1)
		"####" "#" 0 A_PlaySound("weapons/uniquespawned", 7, 0.25, 0, 0)
		"####" "#" 0 A_Jump(256, "SpawnLoop")
		Goto SpawnLoop
		
	GiveWeapon:
		"####" "#" 0 A_GiveInventory("RLTantrumCannon",1)
		"####" "#" 0 A_GiveInventory("RLWeaponLimit",1)
		"####" "#" 0 A_GiveInventory("RLUniqueItemFound",1, AAPTR_PLAYER1)
		"####" "#" 0 A_Print("\ccPicked up the \cdQuantum Tantrum Cannon.")
		"####" "#" 0 A_GiveInventory("RLDangerLevelUniqueGiver",1, AAPTR_PLAYER1)
		Goto PickupSound
	}
}

ACTOR RLTantrumCannonPickupModded : RLTantrumCannonPickup
{
	+INVENTORY.TRANSFER
	States
	{
	Spawn:
		TNT1 A 0 NoDelay ACS_NamedExecuteAlways("GetWeaponMods", 0)
		TNT1 A 0 A_JumpIf(CallACS("DRLA_specialstarts") == 0, "NoSpecialStartsStuff")
		"####" "#" 0 A_Jump(256, "SpecialStartsStuff")
		Goto SpecialStartsStuff
		
	SpawnFrame:
		QTCW X 4
		"####" "#" 0 A_Jump(256, "SpawnLoop")
		Goto SpawnLoop
	SpawnLoop:
		"####" "#" 0 A_JumpIf(VelZ <= 0.01 && user_floorhit == 0, "FloorHit")
		"####" "#" 0 ACS_NamedExecuteAlways("RLWeaponModDisplay", 0)
		"####" "#" 1
		Loop
	GiveWeapon:
		"####" "#" 0 A_GiveInventory("RLTantrumCannon",1)
		"####" "#" 0 A_GiveInventory("RLWeaponLimit",1)
		"####" "#" 0 A_Print("\ccPicked up a \cbmodded \cdQuantum Tantrum Cannon.")
		Goto PickupSound
	NotPickupLimit:
		"####" "#" 0 A_JumpIfInventory("DRLA_WeaponAntiLogFloodCheck",1,"NotPickup_NoPrint")
		"####" "#" 0 A_GiveInventory("DRLA_WeaponAntiLogFloodCheck")
		"####" "#" 0 A_Print("\cd= Quantum Tantrum Cannon =", 2, "CONFONT")
		Goto NotPickup_NoPrint
	NotPickup:
		"####" "#" 0 A_JumpIfInventory("RLTantrumCannonModLimit", 1, "NotPickup_Modded")
		"####" "#" 0 A_JumpIfInventory("DRLA_WeaponAntiLogFloodCheck",1,"NotPickup_NoPrint")
		"####" "#" 0 A_GiveInventory("DRLA_WeaponAntiLogFloodCheck")
		"####" "#" 0 A_Print("\cd= Quantum Tantrum Cannon =\n\n\ccYou replace your unmodded\n\ccweapon with the one you picked up.", 5, "CONFONT")
		"####" "#" 0 A_GiveInventory("Cell",20)
		Goto PickupSound
	NotPickup_Modded:
		"####" "#" 0 A_Print("\cd= Quantum Tantrum Cannon =\n\n\caYou are already carrying a modded\n\caweapon of this type", 5, "CONFONT")
		Fail
	}
}
