actor G2_Light_Sparkle {
	+CLIENTSIDEONLY
	renderstyle add
	alpha 1.0
	
	+FORCEXYBILLBOARD
	
	scale 0.2
	
	height 2
	radius 2
	+THRUACTORS
	
	States {
		Spawn:
			SPRK A 0 bright
			//SPRK A 0 bright A_CheckSightOrRange(2000,"Remove")
			SPRK A 0 bright A_Jump(256,"A","B")
		A:
			SPRK AA 1 bright A_FadeOut(0.05) 
			goto FadeOut
		B:
			SPRK BB 1 bright A_FadeOut(0.05) 
			goto FadeOut
		FadeOut:
		Remove:
			//"####" # 1 bright A_FadeOut(0.25) 
			TNT1 A 1
			stop
	}
}

actor G2_Light_Shard : G2_Light_Sparkle {
	scale 0.5

	renderstyle add
	
	States {
		Spawn:
			SGSA A 0
			//SGSA A 0 bright A_CheckSightOrRange(2000,"Remove")
			SGSA A 0 A_Jump(256,"A","B","C","D","E")
		A:
			SGSA A 2 A_CheckFloor("Floor")
		B:
			SGSA B 2 A_CheckFloor("Floor")
		C:
			SGSA C 2 A_CheckFloor("Floor")
		D:
			SGSA D 2 A_CheckFloor("Floor")
		E:
			SGSA E 2 A_CheckFloor("Floor")
			goto A
		Floor:
			SGSA A 0
			SGSG A 0 A_CheckSight("Remove")
			SGSA A 0 A_SetTranslucent(0.7,0)
			SGSA AAAAAAAAAAAAAAAAAAAAA 35 A_CheckSight("Remove")
		FadeOut:
			SGSA A 1 A_FadeOut(0.05)
			loop
		Remove:
			TNT1 A 1
			stop
	}
}

actor G2_BaseLight {
	+SHOOTABLE
	+NOGRAVITY
	+LOOKALLAROUND
	+NOTARGET
	+FRIENDLY

	+NODAMAGE
	+NOBLOOD

	height 2
	radius 2
	mass 99999999999
	CameraHeight 16

	+SERVERSIDEONLY

	States {
		Spawn:
		Spawn_Server:
			TNT1 A 0
		On_Finish:
		Spawn_Event:
			TNT1 A 0 Thing_ChangeTID(0, 3500 + ((random(x, x) + 10000) / 1000) + (((random(y, y) + 10000) / 1000) * 20))
			TNT1 A 0 ACS_NamedExecuteWithResult("light_spawnState")
			fail
		Flicker_Server:
		Flicker_Event:
			TNT1 A 0 Thing_ChangeTID(0, 3497)
			TNT1 A 0 ACS_NamedExecuteWithResult("light_flickerState")
			fail

		Break_Server:
		Break_Event:
			TNT1 A 0 Thing_ChangeTID(0, 3493)
			TNT1 A 0 ACS_NamedExecuteWithResult("light_breakState")
			fail

		Off_Server:
		Off_Event:
			TNT1 A 0 Thing_ChangeTID(0, 3496)
			TNT1 A 0 ACS_NamedExecuteWithResult("light_offState")
			fail

		On_Server:
		On_Event:
			TNT1 A 0 Thing_ChangeTID(0, 3500 + ((random(x, x) + 10000) / 1000) + (((random(y, y) + 10000) / 1000) * 20))
			TNT1 A 0 ACS_NamedExecuteWithResult("light_onState")
			fail

		TurnOff_Server:
		TurnOff_Event:
			TNT1 A 0 Thing_ChangeTID(0, 3494)
			TNT1 A 0 ACS_NamedExecuteWithResult("light_turnOffState")
			fail
	}
}

actor G2_FluorescentLamp : G2_BaseLight 32070 {
	States {
		On_Finish:
		Spawn_Client:
			PCLL A 0 bright A_StopSound(CHAN_6)
			PCLL A 0 bright A_PlaySound("Lights/Idle", CHAN_7, 1.0, true)
			PCLL A -1 bright
			loop
		SpawnDistant_Client:
			PCLL A 0 bright A_StopSound(CHAN_6)
			PCLL A 0 bright A_StopSound(CHAN_7)
			PCLL A -1 bright
			loop

		Flicker_Client:
			PCLL A 0 bright A_StopSound(CHAN_7)
			PCLL A 0 bright A_PlaySound("Lights/Flickering", CHAN_6)
			PCLL BABAAAABAABAACBAAABABCABAAAABAAAAABCAABACBAABABCABABABAAABCBCBCA 1
			PCLL AABCBACBAAABCAAABCACBCAABCBAABACBABAABAABCAAABCAAABCAAACBBCBABCA 1
			PCLL ABABABCABABCAABACCBABAABABABABCBCBCBABCBBCBCBBCBCBCBBABCBABCBACC 1
			PCLL ABCABCBACBABCBABCBCBBABABABAAABAAABACBCABCBACBABAAABCCBABABCABCB 1
			loop

		Break_Client:
			PCLL W 0 A_StopSound(CHAN_7)
			PCLL W 0 A_PlaySound("Lights/Break", CHAN_6)
			PCLL WWWWWWWWWWWWWWWWWWWW 0 A_SpawnItemEx("G2_Light_Shard", random(-30, 30), random(-2, 2), random(-3, -1), random(-4, 4), random(-4, 4), random(-20, -10), 0, SXF_CLIENTSIDE)
			PCLL WW 0 A_SpawnItemEx("G2_Light_Sparkle", random(-30, 30), random(-2, 2), random(-3, -1), random(-8, 8), random(-8, 8), random(-16, -1), 0, SXF_CLIENTSIDE)
			PCLL WWWWW 1 A_SpawnItemEx("G2_Light_Sparkle", random(-30, 30), random(-2, 2), random(-3, -1), random(-8, 8), random(-8, 8), random(-16, -1), 0, SXF_CLIENTSIDE)
			PCLL W -1
			loop

		Off_Client:
			PCLL A 0 A_PlaySound("Lights/Off", CHAN_6)
			PCLL A 0 A_StopSound(CHAN_7)
			PCLL ABC 1
			PCLL D -1
			loop

		On_Client:
			PCLL CBA 1
			goto On_Finish

		TurnOff_Client:
			PCLL A 0 A_StopSound(CHAN_6)
			PCLL A 0 A_StopSound(CHAN_7)
			PCLL ABC 1
			PCLL D -1
			loop
	}
}

actor G2_Lamp : G2_FluorescentLamp 32071 {
	States {
		On_Finish:
		Spawn_Client:
			PCLL A 0 bright A_StopSound(CHAN_6)
			PCLL A -1 bright
			loop

		Break_Client:
			PCLL W 0 A_StopSound(CHAN_7)
			PCLL W 0 A_PlaySound("Lights/Lamp/Break", CHAN_6)
			PCLL WWWWWWWWWWWWWWWWWWWW 0 A_SpawnItemEx("G2_Light_Shard", random(-16, 16), random(-16, 16), random(-3, -1), random(-4, 4), random(-4, 4), random(-20, -10), 0, SXF_CLIENTSIDE)
			PCLL WW 0 A_SpawnItemEx("G2_Light_Sparkle", random(-16, 16), random(-16, 16), random(-3, -1), random(-8, 8), random(-8, 8), random(-16 ,-1), 0, SXF_CLIENTSIDE)
			PCLL WWWWW 1 A_SpawnItemEx("G2_Light_Sparkle", random(-16, 16), random(-16, 16), random(-3, -1), random(-8, 8), random(-8, 8), random(-16, -1), 0, SXF_CLIENTSIDE)
			PCLL W -1
			loop

		On_Client:
			PCLL CBA 1
			goto On_Finish
	}
}

actor G2_FluorescentLampBlue : G2_FluorescentLamp 32072 {
}

actor G2_FluorescentLampRed : G2_FluorescentLamp 32073 {
}

actor G2_CeilingLight : G2_FluorescentLamp 32050 {
	States {
		On_Finish:
		Spawn_Client:
			PCLL A 0 bright A_StopSound(CHAN_6)
			PCLL A 0 bright A_PlaySound("Lights/Legacy/Idle", CHAN_7, 1.0, true)
			PCLL A -1 bright
			loop

		Break_Client:
			PCLL W 0 A_StopSound(CHAN_7)
			PCLL W 0 A_PlaySound("Lights/Break", CHAN_6)
			PCLL WWWWWWWWWWWWWWWWWWWW 0 A_SpawnItemEx("G2_Light_Shard", random(-16, 16), random(-16, 16), random(-3, -1), random(-4, 4), random(-4, 4), random(-20, -10), 0, SXF_CLIENTSIDE)
			PCLL WW 0 A_SpawnItemEx("G2_Light_Sparkle", random(-16, 16), random(-16, 16), random(-3, -1), random(-8, 8), random(-8, 8), random(-16 ,-1), 0, SXF_CLIENTSIDE)
			PCLL WWWWW 1 A_SpawnItemEx("G2_Light_Sparkle", random(-16, 16), random(-16, 16), random(-3, -1), random(-8, 8), random(-8, 8), random(-16, -1), 0, SXF_CLIENTSIDE)
			PCLL W -1
			loop

		On_Client:
			PCLL CBA 1
			goto On_Finish
	}
}

actor G2_Light : G2_CeilingLight 32051 {
	renderstyle none
	health 99992
}

actor G2_FloorLight : G2_CeilingLight 32052 {
	states
	{
		On_Finish:
		Spawn_Client:
			PFLL A 0 bright A_StopSound(CHAN_6)
			PFLL A 0 bright A_PlaySound("Lights/Legacy/Idle", CHAN_7, 1.0, true)
			PFLL A -1 bright
			loop
		SpawnDistant_Client:
			PFLL A 0 bright A_StopSound(CHAN_6)
			PFLL A 0 bright A_StopSound(CHAN_7)
			PFLL A -1 bright
			loop

		Flicker_Client:
			PFLL A 0 A_StopSound(CHAN_7)
			PFLL A 0 bright A_PlaySound("Lights/Flickering", CHAN_6)
			PFLL BABAAAABAABAACBAAABABCABAAAABAAAAABCAABACBAABABCABABABAAABCBCBCA 1
			PFLL AABCBACBAAABCAAABCACBCAABCBAABACBABAABAABCAAABCAAABCAAACBBCBABCA 1
			PFLL ABABABCABABCAABACCBABAABABABABCBCBCBABCBBCBCBBCBCBCBBABCBABCBACC 1
			PFLL ABCABCBACBABCBABCBCBBABABABAAABAAABACBCABCBACBABAAABCCBABABCABCB 1
			loop

		Break_Client:
			PFLL W 0 A_StopSound(CHAN_7)
			PFLL W 0 A_PlaySound("Lights/Break")
			PFLL WWWWWWWWWWWWWWWWWWWW 0 A_SpawnItemEx("G2_Light_Shard", random(-16, 16), random(-16, 16), random(-3, -1), random(-4, 4), random(-4, 4), random(-20, -10), 0, SXF_CLIENTSIDE)
			PFLL WW 0 A_SpawnItemEx("G2_Light_Sparkle", random(-16, 16), random(-16, 16), random(-3, -1), random(-8, 8), random(-8, 8), random(-16 ,-1), 0, SXF_CLIENTSIDE)
			PFLL WWWWW 1 A_SpawnItemEx("G2_Light_Sparkle", random(-16, 16), random(-16, 16), random(-3, -1), random(-8, 8), random(-8, 8), random(-16, -1), 0, SXF_CLIENTSIDE)
			PFLL W -1
			loop

		Off_Client:
			PFLL A 0 A_StopSound(CHAN_7)
			PFLL A 0 A_PlaySound("Lights/Off", CHAN_6)
			PFLL ABC 1
			PFLL D -1
			loop

		On_Client:
			PFLL CBA 1
			goto On_Finish

		TurnOn_Client:
			PFLL A 0 A_StopSound(CHAN_6)
			PFLL A 0 A_StopSound(CHAN_7)
			PFLL ABC 1
			PFLL D -1
			loop
	}
}

actor G2_CeilingLight2 : G2_CeilingLight 32053 { health 99991 }
actor G2_FloorLight2 : G2_FloorLight 32054 { health 99991 }

actor G2_CeilingLight3 : G2_CeilingLight 32060 { health 99993 }
actor G2_Light3 : G2_CeilingLight 32061 { health 99994 }
actor G2_FloorLight3 : G2_FloorLight 32062 { health 99993 }

actor G2_Lamp2 : G2_lamp 32063 { }
actor G2_Lamp2CenterLight : G2_Lamp2 32064 { }

actor G2_BaseSolidLight : G2_BaseLight {
	+SOLID
}