class LeadBallAmmoCounter : GenericToken { Default { Inventory.MaxAmount 99; } }

// I should rewrite this so it's less awful, some beautiful day...
class LeadBall : Actor
{
	Default
	{
		Radius 10;
		Height 18;
		Speed 30;
		Damage 10;
		MaxStepHeight 32;
		Gravity 0.5;
		ProjectileKickback 150;
		BounceFactor 1.0;
		WallBounceFactor 0.9;
		Alpha 0.5;
		Scale 0.25;
		BounceSound "LeadBall/Bounce";
		Renderstyle "Translucent";
		+STEPMISSILE +FORCERADIUSDMG
		+NOEXPLODEFLOOR +NOINTERACTION
		+BOUNCEONWALLS +BOUNCEONCEILINGS
		+NOCLIP +MTHRUSPECIES +CANBOUNCEWATER
		+EXTREMEDEATH +MISSILE
	}
	
	int User_Frame;
	int User_Lifespan;
	int User_Size;
	int User_Amount;
	
	States
	{
	Spawn:
		TNT1 A 0 NoDelay {
			A_PlaySound("LeadBall/Roll",4,0.8 + (0.01 * User_Size), 1);
			User_Frame = 1;
			User_Lifespan = 1;
			User_Size = 1;
			if(CountInv("HexenCounter",AAPTR_TARGET)) { A_TakeInventory("BlueMana",3,TIF_NOTAKEINFINITE,AAPTR_TARGET); }
			else 									  { A_TakeInventory("PulverizerAmmo",5,TIF_NOTAKEINFINITE,AAPTR_TARGET); }
		}
		LDBF ABCDEFGHIJKLMNO 1 Bright A_Warp(AAPTR_TARGET,80.0+(User_Size*2.0),12.0,15.0,0,WARPF_INTERPOLATE|WARPF_NOCHECKPOSITION);
	SetFrame:
		TNT1 A 0 A_JumpIf(User_Frame == 7, "FrameG");
		TNT1 A 0 A_JumpIf(User_Frame == 6, "FrameF");
		TNT1 A 0 A_JumpIf(User_Frame == 5, "FrameE");
		TNT1 A 0 A_JumpIf(User_Frame == 4, "FrameD");
		TNT1 A 0 A_JumpIf(User_Frame == 3, "FrameC");
		TNT1 A 0 A_JumpIf(User_Frame == 2, "FrameB");
		TNT1 A 0 A_JumpIf(User_Frame == 1, "FrameA");
	FrameA:
		LDBL A 0;
		Goto Crapcheck;
	FrameB:
		LDBL B 0;
		Goto Crapcheck;
	FrameC:
		LDBL C 0;
		Goto Crapcheck;
	FrameD:
		LDBL D 0;
		Goto Crapcheck;
	FrameE:
		LDBL E 0;
		Goto Crapcheck;
	FrameF:
		LDBL F 0;
		Goto Crapcheck;
	FrameG:
		LDBL G 0 { User_Frame = 0; }
		Goto Crapcheck;
	Crapcheck:
		"####" "#" 0 A_JumpIf(CountInv("LeadBallReleased"),"Main");
		"####" "#" 0 A_JumpIf(CountInv("LeadBallHeld",AAPTR_TARGET),1);
		Goto UnleashTheShitstorm;
		"####" "#" 0 A_JumpIf(User_Frame == 6, "TakeMeSomeDough");
		Goto Main;
	TakeMeSomeDough:
		"####" "#" 0 A_JumpIf(CountInv("HexenCounter",AAPTR_TARGET),"TakeMeSomeManaDough");
		"####" "#" 0 A_JumpIf(User_Size >= 21,"PumpingLeadOnSlowerPace");	//Full size reached.
		"####" "#" 0 A_JumpIf(CountInv("PulverizerAmmo",AAPTR_TARGET) >= 8,"Expand");
		Goto UnleashTheShitstorm;
	TakeMeSomeManaDough:
		"####" "#" 0 A_JumpIf(User_Size >= 21,"PumpingLeadOnSlowerPace");
		"####" "#" 0 A_JumpIf(CountInv("BlueMana",AAPTR_TARGET) >= 4,"Expand");
		Goto UnleashTheShitstorm;
	Expand:
		"####" "#" 0 A_GiveInventory("LeadBallSize",4,AAPTR_TARGET);
		"####" "#" 0 A_JumpIf(CountInv("HexenCounter",AAPTR_TARGET),"AmmoCheck");
		"####" "#" 0 A_TakeInventory("PulverizerAmmo",8,TIF_NOTAKEINFINITE,AAPTR_TARGET);
		Goto ExorciiiizeTheDemons;
	PumpingLeadOnSlowerPace:
		"####" "#" 0 A_JumpIf(CountInv("HexenCounter",AAPTR_TARGET),"AmmoCheck2");
		"####" "#" 0 A_JumpIf(CountInv("PulverizerAmmo",AAPTR_TARGET),1);
		Goto UnleashTheShitstorm;
		"####" "#" 0 A_GiveInventory("LeadBallAmmoCounter",1);
		"####" "#" 0 A_JumpIf(CountInv("LeadBallAmmoCounter") >= 5,2);
		"####" "#" 0 A_Jump(256,"Main");
		"####" "#" 0 {
			A_TakeInventory("PulverizerAmmo",1,TIF_NOTAKEINFINITE,AAPTR_TARGET);
			A_TakeInventory("LeadBallAmmoCounter",0);
		}
		Goto Main;
	AmmoCheck:
		"####" "#" 0 A_JumpIf(CountInv("BlueMana",AAPTR_TARGET) >= 4,1);
		Goto UnleashTheShitstorm;
		"####" "#" 0 A_GiveInventory("LeadBallAmmoCounter",1);
		"####" "#" 0 A_JumpIf(CountInv("LeadBallAmmoCounter") >= 3,2);
		"####" "#" 0 A_Jump(256,"ExorciiiizeTheDemons");
		"####" "#" 0 {
			A_TakeInventory("BlueMana",4,TIF_NOTAKEINFINITE,AAPTR_TARGET);
			A_TakeInventory("LeadBallAmmoCounter",0);
		}
	AmmoCheck2:
		"####" "#" 0 A_JumpIf(CountInv("BlueMana",AAPTR_TARGET),1);
		Goto UnleashTheShitstorm;
		"####" "#" 0 A_GiveInventory("LeadBallAmmoCounter",1);
		"####" "#" 0 A_JumpIf(CountInv("LeadBallAmmoCounter") >= 10,2);
		"####" "#" 0 A_Jump(256,"ExorciiiizeTheDemons");
		"####" "#" 0 {
			A_TakeInventory("BlueMana",1,TIF_NOTAKEINFINITE,AAPTR_TARGET);
			A_TakeInventory("LeadBallAmmoCounter",0);
		}
	ExorciiiizeTheDemons:
		"####" "#" 0 {
			A_SetScale(Scale.X + 0.12);
			User_Size = User_Size + 4;
		}
	Main:
		"####" "#" 0 A_JumpIf(User_Lifespan <= 0, "Death");
		"####" "#" 0 { User_Frame++; }
		
		//Spam bullets maybe?
		"####" "#" 0 A_JumpIf(User_Size >= 20, 5);
		"####" "#" 0 A_JumpIf(User_Size >= 15, 5);
		"####" "#" 0 A_JumpIf(User_Size >= 10, 5);
		"####" "#" 0 A_JumpIf(User_Size >= 5, 5);
		"####" "#" 0 A_Jump(256,5);
		"####" "#####" 0 A_SpawnItemEx("LeadBallBullet", (FRandom(2.0, -2.0) * User_Size) * 0.5, (FRandom(2.0, -2.0) * User_Size) * 0.5, (FRandom(2.0, -2.0) * User_Size) * 0.5,
										FRandom(100.0,80.0), FRandom(100.0,80.0), FRandom(-100.0,100.0),
										FRandom(0.0,360.0), SXF_TRANSFERPOINTERS, 200);
		"####" "#" 0 A_JumpIf(User_Size >= 20, 5);
		"####" "#" 0 A_JumpIf(User_Size >= 10, 5);
		"####" "#" 0 A_JumpIf(User_Size >= 5, 5);
		"####" "#" 0 A_Jump(256,5);
		"####" "####" 0 A_SpawnItemEx("BigBuellerCasing", (FRandom(16.0, -16.0) * User_Size) * 0.5, (FRandom(16.0, -16.0) * User_Size) * 0.5, (FRandom(16.0, -16.0) * User_Size) * 0.5,
														   (FRandom(3.0, -3.0) * User_Size) * 0.5, (FRandom(-3.0, 3.0) * User_Size) * 0.5, (FRandom(2.0, 3.0) * User_Size) * 0.5,
														    FRandom(0.0,360.0), SXF_TRANSFERPOINTERS, 224);
		"####" "#" 1 Bright {
			//If it got released, cease holding in place and significantly increase damage.
			If(CountInv("LeadBallReleased")) {
				User_Lifespan--;
				A_Explode(((10 + User_Size)*random(1,3)), 64 + (User_Size * 2), 0);
			} else {
				A_Warp(AAPTR_TARGET,80.0+(User_Size*2.0),12.0,15.0,0,WARPF_INTERPOLATE|WARPF_NOCHECKPOSITION);
				A_Explode(((5 + (User_Size * 0.25))), 64 + (User_Size * 2), 0);
			}
		}
		Goto SetFrame;
	UnleashTheShitstorm:
		"####" "#" 0 {
			A_FadeIn(0.5);
			A_Warp(AAPTR_TARGET,0,0.0,height*0.5,0,WARPF_NOCHECKPOSITION);
			A_GiveInventory("LeadBallReleased",1);
			bNOINTERACTION = 0;
			bNOCLIP = 0;
			if(Target) { A_SetPitch(Target.Pitch); }
			User_Lifespan = 105 + (User_Size * 5);
			A_ChangeVelocity(cos(angle) * cos(pitch) * (30 + User_Size), sin(angle) * cos(pitch) * (30 + User_Size), -sin(pitch) * (30 + User_Size), CVF_REPLACE);
			If(User_Size >= 10) { bRIPPER = 1; } //If the ball is big enough, let's make it roll through the enemies.
		}
		Goto Main;
	Death:	//Might as well salvage the midas statue stuff for this one.
		TNT1 A 0 {
			A_PlaySound("Matriarch/Exp",4,1.0);
			User_Amount = 6 + User_Size;
			A_Explode(60 + (User_Size * 2), 96 + (User_Size * 5), 0);
		}
	PhaseOne:
		TNT1 A 0 {
			for(int Sosig = 0; Sosig < 5; Sosig++) {
				A_SpawnItemEx("LeadBallBullet", (FRandom(2.0, -2.0) * User_Size) * 0.5,(FRandom(2.0, -2.0) * User_Size) * 0.5, (FRandom(2.0, -2.0) * User_Size) * 0.5,
										FRandom(100.0,80.0), FRandom(100.0,80), FRandom(-100.0,100.0),
										FRandom(0.0,360.0), SXF_TRANSFERPOINTERS, 20);
			}
			for(int Sosig = 0; Sosig < 3; Sosig++) {
				A_SpawnItemEx("BigBuellerCasing", (FRandom(16.0, -16.0) * User_Size) * 0.5, (FRandom(16.0, -16.0) * User_Size) * 0.5, (FRandom(16.0, -16.0) * User_Size) * 0.5,
										(FRandom(6.0, -6.0) * User_Size) * 0.5, (FRandom(-6.0, 6.0) * User_Size) * 0.5, (FRandom(4.0, 6.0) * User_Size) * 0.5,
										FRandom(0.0,360.0), SXF_TRANSFERPOINTERS, 40);
				A_SpawnItemEx("Midas_Smoke", (FRandom(16.0, -16.0) * User_Size) * 0.5, (FRandom(16.0, -16.0) * User_Size) * 0.5, (FRandom(16.0, -16.0) * User_Size) * 0.5,
										(FRandom(1.0, -1.0) * User_Size) * 0.5, (FRandom(-1.0, 1.0) * User_Size) * 0.5, (FRandom(-1.0, 1.0) * User_Size) * 0.5,
										FRandom(0.0,360.0), SXF_CLIENTSIDE, 20);
			}
			for(int Sosig = 0; Sosig < 2; Sosig++) {
				A_SpawnItemEx("Midas_Particle", (FRandom(12.0, -12.0) * User_Size) * 0.5, (FRandom(12.0, -12.0) * User_Size) * 0.5, (FRandom(12.0, -12.0) * User_Size) * 0.5,
										(FRandom(-1.0, -1.0) * User_Size) * 0.5, (FRandom(-1.0, 1.0) * User_Size) * 0.5, (FRandom(-0.5, 1.0) * User_Size) * 0.5,
										FRandom(0.0,360.0), SXF_CLIENTSIDE, 20);
			}
			User_Amount--;
			Return A_JumpIf(User_Amount <= 0, "Rest");
		}
		Loop;
	Rest:
		TNT1 A 0 {
			A_SpawnItemEx("Midas_Blast",0,0,0,0,0,0,0,SXF_CLIENTSIDE|SXF_SETMASTER);
			//A_SpawnItemEx("Midas_Emitter",0,0,2.5 * User_Range,0,0,0,0,SXF_CLIENTSIDE|SXF_SETMASTER);
			A_SpawnItemEx("Midas_Flare",0,0,0,0,0,0,0,SXF_CLIENTSIDE|SXF_SETMASTER);
			A_SpawnItemEx("Midas_Shockwave",0,0,0,0,0,0,0,SXF_CLIENTSIDE|SXF_SETMASTER);
			A_SpawnItemEx("Midas_GLDEF",0,0,0,0,0,0,0,SXF_CLIENTSIDE|SXF_SETMASTER);
		}
		Stop;
	}
}

class LeadBallBullet : FastProjectile
{
	Default
	{
		Radius 11;
		Height 7;
		MissileHeight 8;
		Speed 200;
		DamageFunction (5*random(1,3));
		Projectile;
		Renderstyle "Add";
		Obituary "%o was hit by %k's stray bullet, coming from a lead ball.";
		Scale 0.5;
		Decal "BulletChip";
		+NOGRAVITY
		+FORCERADIUSDMG
		+MTHRUSPECIES
	}
	
	States
	{
	Spawn:
		TRAC A 1 Bright NoDelay {
			A_ChangeVelocity(0, 0, -0.25, CVF_RELATIVE);
			A_FaceMovementDirection();
		}
		Loop;
	Death:
		TNT1 A 1 {
			A_Explode(5*random(1,3),24,0);
			A_PlaySound("LeadBullet/Hit",4,0.2);
			A_SpawnItemEx("HBulletPuff",0,0,0,0,0,0,0,SXF_CLIENTSIDE);
		}
		Stop;
	XDeath:
		TNT1 A 0;
		Stop;
	}
}

class PhalanxBullet : LeadBallBullet
{
	Default
	{
		Damage 0;
		Radius 12;
		Height 18;
		species "Rrerr";
		Decal "";
		-NOBLOCKMAP
		+SOLID
		+THRUSPECIES
		-BLOODSPLATTER
	}
	
	States
	{
	Death:
		TNT1 A 0; //A_Explode(5*random(1,3),24,0);
		Stop;
	}
}

class BigBuellerCasing : BuellerCasing
{
	Default
	{
		Scale 0.3;
	}
	
	States
	{
	Death:
		CAS1 A 0 A_SpawnItemEx("BigBuellerCasingLiedown",0,0,0,0,0,0,0,SXF_CLIENTSIDE);
		stop;
	}
}

class BigBuellerCasingLiedown : BuellerCasingLiedown
{
    Default
	{
		Scale 0.3;
	}
	
	States
	{
	Spawn:
		TNT1 A 0 NoDelay A_Jump(256,"Spawn1","Spawn2");
		stop;
	Spawn1:
		CAS1 I 1;
		Goto Ded;
	Spawn2:
		CAS1 J 1;
		Goto Ded;
	Ded:
		//since it can get quite cpu-heavy, I opted for the on-sight despawn here.
		"####" "#" random(210,350) { if(!GetCvar("GC_ToasterMode")) { Return ResolveState("Fadying"); } Return ResolveState(Null); }
		Goto Fadying;
	Fadying:
		"####" "#" 1 A_FadeOut(0.1);
		Wait;
	}
}

class LLeadBall : LeadBall
{
	States
	{
	Spawn:
		TNT1 A 0 NoDelay {
			A_PlaySound("LeadBall/Roll",4,0.8 + (0.01 * User_Size), 1);
			User_Frame = 1;
			User_Lifespan = 1;
			User_Size = 1;
			if(CountInv("HexenCounter",AAPTR_TARGET)) { A_TakeInventory("BlueMana",3,TIF_NOTAKEINFINITE,AAPTR_TARGET); }
			else 									  { A_TakeInventory("PulverizerAmmo",5,TIF_NOTAKEINFINITE,AAPTR_TARGET); }
		}
		LDBF ABCDEFGHIJKLMNO 1 Bright A_Warp(AAPTR_TARGET,80.0+(User_Size*2.0),-12.0,15.0,0,WARPF_INTERPOLATE|WARPF_NOCHECKPOSITION);
	SetFrame:
		TNT1 A 0 A_JumpIf(User_Frame == 7, "FrameG");
		TNT1 A 0 A_JumpIf(User_Frame == 6, "FrameF");
		TNT1 A 0 A_JumpIf(User_Frame == 5, "FrameE");
		TNT1 A 0 A_JumpIf(User_Frame == 4, "FrameD");
		TNT1 A 0 A_JumpIf(User_Frame == 3, "FrameC");
		TNT1 A 0 A_JumpIf(User_Frame == 2, "FrameB");
		TNT1 A 0 A_JumpIf(User_Frame == 1, "FrameA");
	FrameA:
		LDBL A 0;
		Goto Crapcheck;
	FrameB:
		LDBL B 0;
		Goto Crapcheck;
	FrameC:
		LDBL C 0;
		Goto Crapcheck;
	FrameD:
		LDBL D 0;
		Goto Crapcheck;
	FrameE:
		LDBL E 0;
		Goto Crapcheck;
	FrameF:
		LDBL F 0;
		Goto Crapcheck;
	FrameG:
		LDBL G 0 { User_Frame = 0; }
		Goto Crapcheck;
	Crapcheck:
		"####" "#" 0 A_JumpIf(CountInv("LeadBallReleased"),"Main");
		"####" "#" 0 A_JumpIf(CountInv("LLeadBallHeld",AAPTR_TARGET),1);
		Goto UnleashTheShitstorm;
		"####" "#" 0 A_JumpIf(User_Frame == 6, "TakeMeSomeDough");
		Goto Main;
	TakeMeSomeDough:
		"####" "#" 0 A_JumpIf(CountInv("HexenCounter",AAPTR_TARGET),"TakeMeSomeManaDough");
		"####" "#" 0 A_JumpIf(User_Size >= 21,"PumpingLeadOnSlowerPace");
		"####" "#" 0 A_JumpIf(CountInv("PulverizerAmmo",AAPTR_TARGET) >= 8,"Expand");
		Goto UnleashTheShitstorm;
	TakeMeSomeManaDough:
		"####" "#" 0 A_JumpIf(User_Size >= 21,"PumpingLeadOnSlowerPace");
		"####" "#" 0 A_JumpIf(CountInv("BlueMana",AAPTR_TARGET) >= 4,"Expand");
		Goto UnleashTheShitstorm;
	Expand:
		"####" "#" 0 A_GiveInventory("LLeadBallSize",4,AAPTR_TARGET);	//To count how much ball had expanded in the gun, and cease pouring the lead in when it reached full size.
		"####" "#" 0 A_JumpIf(CountInv("HexenCounter",AAPTR_TARGET),"AmmoCheck");
		"####" "#" 0 A_TakeInventory("PulverizerAmmo",8,TIF_NOTAKEINFINITE,AAPTR_TARGET);
		Goto ExorciiiizeTheDemons;
	PumpingLeadOnSlowerPace:
		"####" "#" 0 A_JumpIf(CountInv("HexenCounter",AAPTR_TARGET),"AmmoCheck2");
		"####" "#" 0 A_JumpIf(CountInv("PulverizerAmmo",AAPTR_TARGET),1);
		Goto UnleashTheShitstorm;
		"####" "#" 0 A_GiveInventory("LeadBallAmmoCounter",1);
		"####" "#" 0 A_JumpIfInventory("LeadBallAmmoCounter",5,2);
		"####" "#" 0 A_Jump(256,"Main");
		"####" "#" 0 A_TakeInventory("PulverizerAmmo",1,TIF_NOTAKEINFINITE,AAPTR_TARGET);
		"####" "#" 0 A_TakeInventory("LeadBallAmmoCounter",0);
		Goto Main;
	AmmoCheck:
		"####" "#" 0 A_JumpIf(CountInv("BlueMana",AAPTR_TARGET),1);
		Goto UnleashTheShitstorm;
		"####" "#" 0 A_GiveInventory("LeadBallAmmoCounter",1);
		"####" "#" 0 A_JumpIf(CountInv("LeadBallAmmoCounter") >= 3,2);
		"####" "#" 0 A_Jump(256,"ExorciiiizeTheDemons");
		"####" "#" 0 A_TakeInventory("BlueMana",4,TIF_NOTAKEINFINITE,AAPTR_TARGET);
		"####" "#" 0 A_TakeInventory("LeadBallAmmoCounter",0);
	AmmoCheck2:
		"####" "#" 0 A_JumpIf(CountInv("BlueMana",AAPTR_TARGET),1);
		Goto UnleashTheShitstorm;
		"####" "#" 0 A_GiveInventory("LeadBallAmmoCounter",1);
		"####" "#" 0 A_JumpIf(CountInv("LeadBallAmmoCounter") >= 10,2);
		"####" "#" 0 A_Jump(256,"ExorciiiizeTheDemons");
		"####" "#" 0 A_TakeInventory("BlueMana",1,TIF_NOTAKEINFINITE,AAPTR_TARGET);
		"####" "#" 0 A_TakeInventory("LeadBallAmmoCounter",0);
	ExorciiiizeTheDemons:
		"####" "#" 0 {
			A_SetScale(Scale.X + 0.12);
			User_Size = User_Size + 4;
		}
	Main:
		"####" "#" 0 A_JumpIf(User_Lifespan <= 0, "Death");
		"####" "#" 0 { User_Frame++; }
		//Spam bullets? Maybe.
		"####" "#" 0 A_JumpIf(User_Size >= 20, 5);
		"####" "#" 0 A_JumpIf(User_Size >= 15, 5);
		"####" "#" 0 A_JumpIf(User_Size >= 10, 5);
		"####" "#" 0 A_JumpIf(User_Size >= 5, 5);
		"####" "#" 0 A_Jump(256,5);
		"####" "#####" 0 A_SpawnItemEx("LeadBallBullet", (FRandom(2.0, -2.0) * User_Size) * 0.5, (FRandom(2.0, -2.0) * User_Size) * 0.5, (FRandom(2.0, -2.0) * User_Size) * 0.5,
										FRandom(100.0,80.0), FRandom(100.0,80.0), FRandom(-100.0,100.0),
										FRandom(0.0,360.0), SXF_TRANSFERPOINTERS, 200);
		"####" "#" 0 A_JumpIf(User_Size >= 20, 5);
		"####" "#" 0 A_JumpIf(User_Size >= 10, 5);
		"####" "#" 0 A_JumpIf(User_Size >= 5, 5);
		"####" "#" 0 A_Jump(256,5);
		"####" "####" 0 A_SpawnItemEx("BigBuellerCasing", (FRandom(16.0, -16.0) * User_Size) * 0.5, (FRandom(16.0, -16.0) * User_Size) * 0.5, (FRandom(16.0, -16.0) * User_Size) * 0.5,
														   (FRandom(3.0, -3.0) * User_Size) * 0.5, (FRandom(-3.0, 3.0) * User_Size) * 0.5, (FRandom(2.0, 3.0) * User_Size) * 0.5,
														    FRandom(0.0,360.0), SXF_TRANSFERPOINTERS, 224);
		"####" "#" 1 Bright {
			//If it got released, cease holding in place and significantly increase damage.
			If(CountInv("LeadBallReleased")) {
				User_Lifespan--;
				A_Explode(((10 + User_Size)*random(1,3)), 64 + (User_Size * 2), 0);
			} else {
				A_Warp(AAPTR_TARGET,80.0+(User_Size*2.0),-12.0,15.0,0,WARPF_INTERPOLATE|WARPF_NOCHECKPOSITION);
				A_Explode(((5 + (User_Size * 0.25))), 64 + (User_Size * 2), 0);
			}
		}
		Goto SetFrame;
	UnleashTheShitstorm:
		"####" "#" 0 {
			A_FadeIn(0.5);
			A_GiveInventory("LeadBallReleased",1);
			A_Warp(AAPTR_TARGET,0.0,0.0,height*0.5,0,WARPF_INTERPOLATE|WARPF_NOCHECKPOSITION);
			bNOINTERACTION = 0;
			bNOCLIP = 0;
			if(Target) { A_SetPitch(Target.Pitch); }
			User_Lifespan = 3 * 35 + (User_Size * 5);
			A_ChangeVelocity(cos(angle) * cos(pitch) * (30 + User_Size), sin(angle) * cos(pitch) * (30 + User_Size), -sin(pitch) * (30 + User_Size), CVF_REPLACE);
			If(User_Size >= 10) { bRIPPER = 1; } //If the ball is big enough, let's make it roll through the enemies.
		}
		Goto Main;
	Death:	//Might as well salvage the midas statue stuff for this one.
		TNT1 A 0 {
			A_PlaySound("Matriarch/Exp",4,1.0);
			User_Amount = 6 + User_Size;
			A_Explode(50 + (User_Size * 2), 96 + (User_Size * 5), 0);
		}
	PhaseOne:
		TNT1 A 0 {
			for(int Sosig = 0; Sosig < 5; Sosig++) {
				A_SpawnItemEx("LeadBallBullet", (FRandom(2.0, -2.0) * User_Size) * 0.5,(FRandom(2.0, -2.0) * User_Size) * 0.5, (FRandom(2.0, -2.0) * User_Size) * 0.5,
										FRandom(100.0,80.0), FRandom(100.0,80), FRandom(-100.0,100.0),
										FRandom(0.0,360.0), SXF_TRANSFERPOINTERS, 20);
			}
			for(int Sosig = 0; Sosig < 3; Sosig++) {
				A_SpawnItemEx("BigBuellerCasing", (FRandom(16.0, -16.0) * User_Size) * 0.5, (FRandom(16.0, -16.0) * User_Size) * 0.5, (FRandom(16.0, -16.0) * User_Size) * 0.5,
										(FRandom(6.0, -6.0) * User_Size) * 0.5, (FRandom(-6.0, 6.0) * User_Size) * 0.5, (FRandom(4.0, 6.0) * User_Size) * 0.5,
										FRandom(0.0,360.0), SXF_TRANSFERPOINTERS, 40);
				A_SpawnItemEx("Midas_Smoke", (FRandom(16.0, -16.0) * User_Size) * 0.5, (FRandom(16.0, -16.0) * User_Size) * 0.5, (FRandom(16.0, -16.0) * User_Size) * 0.5,
										(FRandom(1.0, -1.0) * User_Size) * 0.5, (FRandom(-1.0, 1.0) * User_Size) * 0.5, (FRandom(-1.0, 1.0) * User_Size) * 0.5,
										FRandom(0.0,360.0), SXF_CLIENTSIDE, 20);
			}
			for(int Sosig = 0; Sosig < 2; Sosig++) {
				A_SpawnItemEx("Midas_Particle", (FRandom(12.0, -12.0) * User_Size) * 0.5, (FRandom(12.0, -12.0) * User_Size) * 0.5, (FRandom(12.0, -12.0) * User_Size) * 0.5,
										(FRandom(-1.0, -1.0) * User_Size) * 0.5, (FRandom(-1.0, 1.0) * User_Size) * 0.5, (FRandom(-0.5, 1.0) * User_Size) * 0.5,
										FRandom(0.0,360.0), SXF_CLIENTSIDE, 20);
			}
			User_Amount--;
			Return A_JumpIf(User_Amount <= 0, "Rest");
		}
		Loop;
	Rest:
		TNT1 A 0 {
			A_SpawnItemEx("Midas_Blast",0,0,0,0,0,0,0,SXF_CLIENTSIDE|SXF_SETMASTER);
			//A_SpawnItemEx("Midas_Emitter",0,0,2.5 * User_Range,0,0,0,0,SXF_CLIENTSIDE|SXF_SETMASTER);
			A_SpawnItemEx("Midas_Flare",0,0,0,0,0,0,0,SXF_CLIENTSIDE|SXF_SETMASTER);
			A_SpawnItemEx("Midas_Shockwave",0,0,0,0,0,0,0,SXF_CLIENTSIDE|SXF_SETMASTER);
			A_SpawnItemEx("Midas_GLDEF",0,0,0,0,0,0,0,SXF_CLIENTSIDE|SXF_SETMASTER);
		}
		Stop;
	}
}