class Dragonshout : Actor
{
	Default
	{
		Radius 8;
		Height 6;
		Speed 60;
		Damage 0;
		Scale 0.2;
		SeeSound "Dragonshout/Fly";
		Renderstyle "Add";
		Projectile;
		+ROLLSPRITE
		+ROLLCENTER
		+RIPPER
		+BLOODLESSIMPACT
		+FORCERADIUSDMG
		-MISSILE	//This flag combo lets it A. not die when hitting map geometry,
		+MBFBOUNCER //B. go through impassable linedefs.
		+MTHRUSPECIES
	}
	
	float user_t;
	int user_i;
	float user_tm;
	
	states
	{
	Spawn:
		TNT1 A 0 NoDelay {
			user_t = 0.0;
			user_tm = 96;
			A_SetRoll(frandom(0.0,360.0));
			A_QuakeEx(9,9,9,40,0,2048,"none",QF_SCALEDOWN);
		}
	Looplet:
		SHCK K 1 Bright {
			user_t = user_t + 1.0;
			A_Explode(192 + (user_t * 5.0), 180 - (user_t * 2), 0, 1);
			A_RadiusThrust(3000 - (user_t * 50), 128 + (user_t * 5.0), RTF_THRUSTZ);
			A_Blast(BF_AFFECTBOSSES, 164, 128 + (user_t * 4.0), 25.0, "DragonshoutBlastDummy", "none");
			for (user_i = 0; user_i < 10; user_i++)
			{
				A_SpawnItemEx("DragonshoutParticle",
					frandom(5.0,-5.0)   + (frandom(5.0,-5.0)   * (user_t * 0.25)),		//X pos.
					frandom(40.0,-40.0) + (frandom(40.0,-40.0) * (user_t * 0.25)),		//Y pos.
					frandom(30.0,-30.0) + (frandom(30.0,-30.0) * (user_t * 0.25)),		//Z pos.
					frandom(40.0,60.0), frandom(4.0,4.0), frandom(4.0,-4.0),			//X/Y/Z vel.
					frandom(-15.0,15.0),SXF_CLIENTSIDE,48 + (user_t * 3.0) + user_tm);	//angle/flags/chance.
			}
			A_ScaleVelocity(0.98);
			A_SetRoll(Roll - 25.0, SPF_INTERPOLATE);
			A_SetScale(Scale.X + 0.1);
			A_FadeOut(0.025);
			A_SpawnItemEx("DragonshoutTrail",0,0,0,0,0,0,0,
			SXF_TRANSFERALPHA|SXF_TRANSFERROLL|SXF_TRANSFERSCALE|SXF_TRANSFERSPRITEFRAME);
		}
		Loop;
		}
}

class DragonshoutTrail : Actor
{
	Default
	{
		Renderstyle "Add";
		+NOINTERACTION
	}
	
	States
	{
	Spawn:
		"####" "#" 1 NoDelay A_FadeOut(0.075);
		Loop;
	}
}

class DragonshoutParticle : DragonshoutTrail
{
	Default
	{
		Alpha 0.99;
		Scale 0.025;
	}
	
	States
	{
	Spawn:
		SPRT A 0 NoDelay {
			A_SetScale(Scale.X + frandom(0.0,0.05));
		}
	Looplet:
		SPRT A 1 Bright {
			A_SetScale(Scale.X - frandom(0.001,0.0002));
			A_FadeOut(frandom(0.05,0.02));
			A_ChangeVelocity(frandom(1.0,-1.0),frandom(1.0,-1.0),frandom(1.0,-1.0),CVF_RELATIVE);
			return A_JumpIf(Scale.X <= 0, "Null");
		}
		Loop;
	}
}

/*
Detached the shouting noise from the player.

PROS:
-It doesn't get cut off from shooting or anything else.
-They can overlap without cutting off or not playing at all.

CONS:
-It can be more affected by system or net lag.
*/

class Dragonshouter : Actor
{
	Default
	{
		Radius 0;
		Height 0;
		Projectile;
		+NOINTERACTION;
		+NOCLIP; //To make damn freaking sure this thing always spawns and sticks to you.
	}
	
	int user_t;
	
	States
	{
	Spawn:
		TNT1 A 0 NoDelay {
		A_PlaySound("Dragonshout/Use",5);
		A_PlaySound("Dragonshout/Use",6,0.4);
		user_t = 315;
	}
	Looplet:
		TNT1 A 1 {
			A_Warp(AAPTR_TARGET,0,0,0,0,WARPF_NOCHECKPOSITION|WARPF_INTERPOLATE);
			user_t--;
			Return A_JumpIf(user_t <= 0, "Null");
		}
		Loop;
	}
}

//As apparently you can't specify none in A_Blast. Lol.
class DragonshoutBlastDummy : Actor
{
	Default
	{
		+NOINTERACTION
	}
	
	States
	{
	Spawn:
		TNT1 A 0;
		Stop;
	}
}