Thunderstorm = false
LightningTick = function()
	if Thunderstorm then
		if (Utils.RandomInteger(1, 100) == 10) then
			local delay = Utils.RandomInteger(1, 10)
			Lighting.Flash("LightningStrike", delay)
			Trigger.AfterDelay(delay, function()
				Media.PlaySound("thunder" .. Utils.RandomInteger(1,6) .. ".aud")
			end)
		end
		if (Utils.RandomInteger(1, 100) == 10) then
			Media.PlaySound("thunder-ambient.aud")
		end
	end
	Trigger.AfterDelay(1, LightningTick)
end
Light = 0.75
turnOn = function()
	Lighting.Ambient = Light
	if Light < 1.111 then
		Light = Light + 0.001
		Trigger.AfterDelay(4, function()
			turnOn()
		end)
	else
		Trigger.AfterDelay(3000, function()
			HourCount = HourCount + 12
			turnOff()
			LampTurnsOn()
			Trigger.AfterDelay(DateTime.Seconds(Utils.RandomInteger(0.6, 0.9)), function()
				if multi0.IsBot and multi1.IsBot and multi2.IsBot and multi3.IsBot then
				else
					Media.PlayMovieInRadar(Utils.Random({ "SunSetA", "SunSetB" }) .. ".vqa", nil)
				end
			end)
		end)
	end
end
turnOff = function()
	Lighting.Ambient = Light
	if Light < 0.7 then
		Thunderstorm = true
	end
	if Light > 0.45 then
		Light = Light - 0.001
		Trigger.AfterDelay(4, function()
			turnOff()
		end)
	else
		Trigger.AfterDelay(3000, function()
			HourCount = HourCount - 12
			DayCount = DayCount + 1
			DateDayCount = DateDayCount + 1
			turnOn()
			LampsTurnOff()
			Thunderstorm = false
			Trigger.AfterDelay(DateTime.Seconds(Utils.RandomInteger(0.6, 0.9)), function()
				if multi0.IsBot and multi1.IsBot and multi2.IsBot and multi3.IsBot then
				else
					Media.PlayMovieInRadar(Utils.Random({ "SunRiseA", "SunRiseB", "SunRiseC" }) .. ".vqa", nil)
				end
			end)
		end)
	end
end
LampsStartTurnOff = function()
	local LampsStartOff = Map.ActorsInBox(Map.TopLeft, Map.BottomRight, function(self) return self.Type == "streetlamp" or self.Type == "roadlamp" or self.Type == "roadlamp1" or self.Type == "roadlamp2" or self.Type == "roadlamp3" end)
	Utils.Do(LampsStartOff, function(startofflamps)
		startofflamps.Deploy()
	end)
end
LampsTurnOff = function()
	PartOfTheDayCount = PartOfTheDayCount - 1
	local LampsOff = Map.ActorsInBox(Map.TopLeft, Map.BottomRight, function(self) return self.Type == "streetlamp" or self.Type == "roadlamp" or self.Type == "roadlamp1" or self.Type == "roadlamp2" or self.Type == "roadlamp3" end)
	Utils.Do(LampsOff, function(offlamps)
		offlamps.Wait(Utils.RandomInteger(33, 66))
		offlamps.Deploy()
	end)
	Media.DisplayMessage("And let's became, Morning...", "[Part Of The Day]", Utils.Random({ HSLColor.Aqua, HSLColor.SkyBlue, HSLColor.Navy, HSLColor.Cyan, HSLColor.LightBlue, HSLColor.LightCyan }))
end

LampTurnsOn = function()
	PartOfTheDayCount = PartOfTheDayCount + 1
	local LampsOn = Map.ActorsInBox(Map.TopLeft, Map.BottomRight, function(self) return self.Type == "streetlamp.off" or self.Type == "roadlamp.off" or self.Type == "roadlamp1.off" or self.Type == "roadlamp2.off" or self.Type == "roadlamp3.off" end)
	Utils.Do(LampsOn, function(onlamps)
		onlamps.Wait(Utils.RandomInteger(33, 66))
		onlamps.Deploy()
	end)
	Media.DisplayMessage("And let's became, Night...", "[Part Of The Day]", Utils.Random({ HSLColor.Aqua, HSLColor.SkyBlue, HSLColor.Navy, HSLColor.Cyan, HSLColor.LightBlue, HSLColor.LightCyan }))
end
SolarFlareEvent = function()
	Media.DisplayMessage("[Solar Flare Ahead]\n -All electrical device is malfunctioned!!!", "[WeatherEvent]", Utils.Random({ HSLColor.Orange, HSLColor.Red, HSLColor.DarkRed }))
	Trigger.AfterDelay(DateTime.Seconds(1.1), function()
		Media.PlaySound("SoundFiles/WeatherSound/ionstorm.aud")
		local SolarFlareCount = Utils.RandomInteger(24, 32)
		local SolarFlareLowPowerCount = DateTime.Seconds(Utils.RandomInteger(28, 56))
		Lighting.Flash("solarstorm", SolarFlareCount)
		Trigger.AfterDelay(DateTime.Seconds(4), function()
			Lighting.Flash("solarstorm", SolarFlareCount)
			Trigger.AfterDelay(DateTime.Seconds(4), function()
				Lighting.Flash("solarstorm", SolarFlareCount)
				Trigger.AfterDelay(DateTime.Seconds(4), function()
					Lighting.Flash("solarstorm", SolarFlareCount)
				end)
			end)
		end)
		multi0.TriggerPowerOutage(SolarFlareLowPowerCount)
		multi1.TriggerPowerOutage(SolarFlareLowPowerCount)
		multi2.TriggerPowerOutage(SolarFlareLowPowerCount)
		multi3.TriggerPowerOutage(SolarFlareLowPowerCount)
		local SolarFlarePowerPlant0 = Map.ActorsInBox(Map.TopLeft, Map.BottomRight, function(sfpp0) return (sfpp0.Type == "powr" or sfpp0.Type == "apwr" or sfpp0.Type == "windplant" or sfpp0.Type == "trafo") and sfpp0.Owner == multi0 end)
		local SolarFlarePowerPlant1 = Map.ActorsInBox(Map.TopLeft, Map.BottomRight, function(sfpp1) return (sfpp1.Type == "powr" or sfpp1.Type == "apwr" or sfpp1.Type == "windplant" or sfpp1.Type == "trafo") and sfpp1.Owner == multi1 end)
		local SolarFlarePowerPlant2 = Map.ActorsInBox(Map.TopLeft, Map.BottomRight, function(sfpp2) return (sfpp2.Type == "powr" or sfpp2.Type == "apwr" or sfpp2.Type == "windplant" or sfpp2.Type == "trafo") and sfpp2.Owner == multi2 end)
		local SolarFlarePowerPlant3 = Map.ActorsInBox(Map.TopLeft, Map.BottomRight, function(sfpp3) return (sfpp3.Type == "powr" or sfpp3.Type == "apwr" or sfpp3.Type == "windplant" or sfpp3.Type == "trafo") and sfpp3.Owner == multi3 end)
		Utils.Do(SolarFlarePowerPlant0, function(sfpp0)
		      Media.FloatingText(Utils.Random({ "Power Denied", "Plant: OFF-Line", "No power creating", "[OFF]", }), sfpp0.CenterPosition + WVec.New(0, -1, 15), Utils.RandomInteger(99, 111), Utils.Random({ HSLColor.Aqua, HSLColor.Orange, HSLColor.Navy, HSLColor.Cyan, HSLColor.Red, HSLColor.LightCyan }))
		end)
		Utils.Do(SolarFlarePowerPlant1, function(sfpp1)
		      Media.FloatingText(Utils.Random({ "Power Denied", "Plant: OFF-Line", "No power creating", "[OFF]", }), sfpp1.CenterPosition + WVec.New(0, -1, 15), Utils.RandomInteger(99, 111), Utils.Random({ HSLColor.Aqua, HSLColor.Orange, HSLColor.Navy, HSLColor.Cyan, HSLColor.Red, HSLColor.LightCyan }))
		end)
		Utils.Do(SolarFlarePowerPlant2, function(sfpp2)
		      Media.FloatingText(Utils.Random({ "Power Denied", "Plant: OFF-Line", "No power creating", "[OFF]", }), sfpp2.CenterPosition + WVec.New(0, -1, 15), Utils.RandomInteger(99, 111), Utils.Random({ HSLColor.Aqua, HSLColor.Orange, HSLColor.Navy, HSLColor.Cyan, HSLColor.Red, HSLColor.LightCyan }))
		end)
		Utils.Do(SolarFlarePowerPlant3, function(sfpp3)
		      Media.FloatingText(Utils.Random({ "Power Denied", "Plant: OFF-Line", "No power creating", "[OFF]", }), sfpp3.CenterPosition + WVec.New(0, -1, 15), Utils.RandomInteger(99, 111), Utils.Random({ HSLColor.Aqua, HSLColor.Orange, HSLColor.Navy, HSLColor.Cyan, HSLColor.Red, HSLColor.LightCyan }))
		end)
		Trigger.AfterDelay(DateTime.Seconds(Utils.RandomInteger(666.6, 888.8)), function() SolarFlareEvent() end)
	end)
end

