//////////////////////
// SNOW SPAWNERS    //
// by Tormentor667  //
// improved by Ceeb //
// tweaked by Xaser //
//////////////////////

Actor SnowParticle
{
	Radius 1
	Height 1
	Damage 0
	Projectile
	RenderStyle Translucent
	Alpha 0
	Scale 0.3
	Mass 0

	+MISSILE
	+NOBLOCKMAP
	+DONTSPLASH
	+DONTBLAST

	States
	{
	Spawn:
		SNOW A 0 NoDelay A_SetScale(frandom(0.3, 0.6))
		SNOW AAAAAAA 2 A_FadeIn(0.1)
		SNOW A 3
		Wait
	Death:
		SNOW A 1 A_FadeOut(0.05)
		Loop
	}
}

Actor BlizzardParticle : SnowParticle
{
	+NOINTERACTION

	States
	{
	Spawn:
		SNOW A 0 NoDelay A_SetScale(frandom(0.3, 0.6))
		SNOW AAAAAAA 1 A_FadeIn(0.2)
		SNOW AAAAAAA 1 A_FadeOut(0.2)
		Stop
	Death:
		TNT1 A 1
		Stop
	}
}

Actor SnowSpawner 10011
{
	//$Category HPack_SpecialEffects
	//$Title Snow
	//$Sprite SNOWA0

	//$Arg0 Area
	//$Arg0Default 128

	//$Arg1 Frequency
	//$Arg1Tooltip The lower the number, the heavier the snowfall.

	//$Arg2 Area type
	//$Arg2Type 11
	//$Arg2Enum { 0 = "Square"; 1 = "Circle"; }

	//$Arg3 Intensity
	//$Arg3Type 11
	//$Arg3Enum { 0 = "Light Snowfall"; 1 = "Heavy Snowfall"; 2 = "Blizzard"; }

	//$Arg4 Wind Velocity
	//$Arg4Tooltip Applies a static 'wind' velocity to snow particles, in the facing direction of the spawner.

	Radius 1
	Height 1

	+NOBLOCKMAP
	+NOGRAVITY
	+NOSECTOR
	+NOINTERACTION
	+NOCLIP
	-SOLID
	+CLIENTSIDEONLY
	+SPAWNCEILING

	States
	{
	Spawn:
		TNT1 A 0 
		TNT1 A 0 A_CheckSight("Unsighted")
		TNT1 A 0 A_JumpIf(Args[2] >= 1, "Circle")
		TNT1 A 0 A_JumpIf(Args[3] >= 2, "SquareBlizzard")
		TNT1 A 0 A_JumpIf(Args[3] >= 1, "SquareHeavy")
	SquareLight:
		TNT1 AAAAA 1 A_SpawnItemEx(
			/*actor*/  "SnowParticle",
			/*xofs*/   frandom(-Args[0], Args[0]),
			/*yofs*/   frandom(-Args[0], Args[0]),
			/*zofs*/   0,
			/*xvel*/   frandom(-1.0, 1.0) + (Args[4]*cos(angle)),
			/*yvel*/   frandom(-1.0, 1.0) + (Args[4]*sin(angle)),
			/*zvel*/   frandom(-1.0, -3.0),
			/*angle*/  0,
			/*flags*/  SXF_CLIENTSIDE,
			/*chance*/ Args[1]
		)
		Goto Spawn
	SquareHeavy:
		TNT1 AAAAA 1 A_SpawnItemEx(
			/*actor*/  "SnowParticle",
			/*xofs*/   frandom(-Args[0], Args[0]),
			/*yofs*/   frandom(-Args[0], Args[0]),
			/*zofs*/   0, //frandom(0, max(-128, floorz-ceilingz)),
			/*xvel*/   frandom(-1.0, 1.0) + (Args[4]*cos(angle)),
			/*yvel*/   frandom(-1.0, 1.0) + (Args[4]*sin(angle)),
			/*zvel*/   frandom(-6.0, -10.0),
			/*angle*/  0,
			/*flags*/  SXF_CLIENTSIDE,
			/*chance*/ Args[1]
		)
		Goto Spawn
	SquareBlizzard:
		TNT1 AAAAAAAAAAAAAAAAAAAA 0 A_SpawnItemEx(
			/*actor*/  "BlizzardParticle",
			/*xofs*/   frandom(-Args[0], Args[0]),
			/*yofs*/   frandom(-Args[0], Args[0]),
			/*zofs*/   frandom(0, 64+floorz-ceilingz),
			/*xvel*/   frandom(-1.0, 1.0) + (Args[4]*cos(angle)),
			/*yvel*/   frandom(-1.0, 1.0) + (Args[4]*sin(angle)),
			/*zvel*/   frandom(-8.0, -12.0),
			/*angle*/  0,
			/*flags*/  SXF_CLIENTSIDE,
			/*chance*/ Args[1]
		)
		TNT1 A 1
		Goto Spawn
	Circle:
		// [XA] TODO: support Arg3 and Arg4 types here.
		// Just patchin' this for H2M4 at the moment, which
		// doesn't currently use the circle spawners.
		TNT1 AAAAA 1 A_SpawnItemEx(
			/*actor*/  "SnowParticle",
			/*xofs*/   frandom(-Args[0], Args[0]),
			/*yofs*/   0,
			/*zofs*/   0,
			/*xvel*/   frandom(-1.0, 1.0),
			/*yvel*/   frandom(-1.0, 1.0),
			/*zvel*/   frandom(-1.0, -3.0),
			/*angle*/  Random(0, 360),
			/*flags*/  SXF_CLIENTSIDE,
			/*chance*/ Args[1]
		)
		Goto Spawn
	Unsighted:
		TNT1 A 1
		Goto Spawn
	}
}
