
Actors1 = { "t01", "t02", "t03", "t05", "t06", "t07", "t08", "t10", "t11", "t12", "t13", "t14", "t15", "t16", "t17" }
Actors2 = { "t01", "t02", "t05", "t06", "t07", "t08", "t16", "t01", "t02", "t05", "t06", "t07", "t01", "t02", "t05", "t06", "t07", "t08", "t16", "t01", "t02", "t05", "t06", "t07", "t08", "t16", "t01", "t02", "t05", "t06", "t07", "t08", "t16", "t01", "t02", "t05", "t06", "t07", "t08", "t16", "t01", "t02", "t05", "t06", "t07", "t08", "t16", "t01", "t02", "t05", "t06", "t07", "t08", "t16", "t01", "t02", "t05", "t06", "t07", "t08", "t16", "t01", "t02", "t05", "t06", "t07", "t08", "t16", "t01", "t02", "t05", "t06", "t07", "t01", "t02", "t05", "t06", "t07", "t08", "t16", "t01", "t02", "t05","t01", "t02", "t05", "t06", "t07", "brl3", "brl3", "barl", "barl", "barl", "mine", "gmine" }
Actors3 = { "t03", "t10", "t11", "t12", "t13", "t14", "t15", "t17", "t03", "t10", "t11", "t12", "t13", "t14", "t15", "t17", "t03", "t10", "t11", "t12", "t13", "t14", "t15", "t17", "t03", "t10", "t11", "t12", "t13", "t14", "t15", "t17", "t03", "t10", "t11", "t12", "t13", "t14", "t15", "t17", "t03", "t10", "t11", "t12", "t13", "t14", "t15", "t17", "t03", "t10", "t11", "t12", "t13", "t14", "t15", "t17", "t03", "t10", "t11", "t12", "t13", "t14", "t15", "t17", "t03", "t10", "t11", "t12", "t13", "t14", "t15", "t17", "t03", "t10", "t11", "t12", "t13", "t14", "t15", "t17", "t03", "t10", "t11", "t12", "t13", "t14", "t13", "t14", "brl3", "brl3", "barl", "barl", "barl", "mine", "gmine" }

ActorAmount1 = { 1, 2, 3, 4, 5, 6 }
countH1 = 0
countV1 = 0
RandmActorMaker1 = function()
	RandomActor1 = Utils.Random(Actors1)
	if countV1 < 85 then
		RandomActorAmount1 = Utils.Random(ActorAmount1)
		if RandomActorAmount1 == 1 then
			newactor = Actor.Create(RandomActor1, true, { Location = Actor452.Location + CVec.New(countH1, countV1), Owner = Neutral })
			newactor = Actor.Create(RandomActor1, true, { Location = Actor453.Location + CVec.New(countH1, countV1), Owner = Neutral })
		end
		countH1 = countH1 + 1
		if countH1 > 7 then
			countV1 = countV1 + 1
			countH1 = 1
		end
			RandmActorMaker1()
	end
end

ActorAmount2 = { 1, 2, 3, 4, 5 }
countH2 = 0
countV2 = 0
RandmActorMaker2 = function()
	RandomActor2 = Utils.Random(Actors2)
	RandomActor3 = Utils.Random(Actors3)
	if countV2 < 7 then
		RandomActorAmount2 = Utils.Random(ActorAmount2)
		if RandomActorAmount2 == 1 then
			newactor = Actor.Create(RandomActor2, true, { Location = Actor448.Location + CVec.New(countH2, countV2), Owner = Neutral })
			newactor = Actor.Create(RandomActor3, true, { Location = Actor449.Location + CVec.New(countH2, countV2), Owner = Neutral })
		end
		countH2 = countH2 + 1
		if countH2 == 37 then
			countH2 = countH2 + 13
		end
		if countH2 > 85 then
			countV2 = countV2 + 1
			countH2 = 1
		end
			RandmActorMaker2()
	end
end


 
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()
			turnOff()
		end)
	end
end

turnOff = function()
    Lighting.Ambient = Light
    if Light < 0.8 then
        Thunderstorm = true
    end
    if Light > 0.66 then
        Light = Light - 0.001
        Trigger.AfterDelay(4, function()
            turnOff()
        end)
    else
        Trigger.AfterDelay(3000, function()
            turnOn()
            Thunderstorm = false
        end)
    end
end

checked = false

PlayerCheck = function()
    return Player.GetPlayers(function(player)
        return true
    end);
end

CheckPlayers = function()
    Utils.Do(PlayerCheck(), function(Playeractor)
        if checked == false then
            checked = true
            if Playeractor.HasPrerequisites({ "weather" }) then
                Light = 0.88
                turnOn()
                Trigger.AfterDelay(DateTime.Seconds(3), function()
                    Media.DisplaySystemMessage("Weather effects are turned on")
                end)
            end
            if Playeractor.HasPrerequisites({ "global-reusable-mechanics" }) then
                Trigger.AfterDelay(DateTime.Seconds(9), function()
                    Media.DisplaySystemMessage(
                        "Reusable Mechanics are activated, allowing you to use the same mechanics multiple times for capturing Husks.")
                end)
            end
            if Playeractor.HasPrerequisites({ "gps.temp" }) then
                Trigger.AfterDelay(DateTime.Seconds(14), function()
                    Media.DisplaySystemMessage(
                        "Temporarayy GPS mode, The GPS satellite will only be available temporarily (BI-Rules).")
                end)
            end
            if not Playeractor.HasPrerequisites({ "techlevel.naval" }) then
                Trigger.AfterDelay(DateTime.Seconds(19), function()
                    Media.DisplaySystemMessage(
                        "Naval Units are turned off, as the host has decided to disable them for this match.")
                end)
            end
--            if Playeractor.HasPrerequisites({ "ww3.description" }) then
--                Trigger.AfterDelay(DateTime.Seconds(24), function()
--                    ModInfoBroadcaster()
--                end)
--            end
        end
    end)
end

WorldLoaded = function()
    Neutral = Player.GetPlayer("Neutral")
	Multi0 = Player.GetPlayer("Multi0")
	RandmActorMaker1()
    RandmActorMaker2()
	CheckPlayers()
    WW3world()
end

Thunderstorm = false

Tick = function()
	if Thunderstorm then
		if (Utils.RandomInteger(1, 200) == 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, 200) == 10) then
			Media.PlaySound("thunder-ambient.aud")
		end
	end
end
