CloudCreator = function()
	if Cloudcount == CloudMaxcount and CloudCreatorState then
		CloudCreatorState = false
		local Clouds = Map.ActorsInBox(Map.TopLeft, Map.BottomRight, function(self) return self.Owner == clouds and not (self.Type == "seagulls1" or not self.Type == "seagulls2") end)
		Utils.Do(Clouds, function(clouded)
			clouded.Teleport(CPos.New(Utils.RandomInteger(MapSlippedEdgeStartHorizontical, MapSlippedEdgeOverHorizontical), Utils.RandomInteger(MapSlippedEdgeStartVertical, MapSlippedEdgeOverVertical)))
			clouded.Stance = "HoldFire"
			clouded.GrantUpgrade("nocontrol")
			clouded.GrantUpgrade("autocontrol")
			clouded.GrantUpgrade("wandering")
			Trigger.OnIdle(clouded, function(cloud)
				if not cloud.IsDead and cloud.IsInWorld then
					cloud.Patrol({CPos.New(Utils.RandomInteger(MapSlippedEdgeStartHorizontical, MapSlippedEdgeOverHorizontical), Utils.RandomInteger(MapSlippedEdgeStartVertical, MapSlippedEdgeOverVertical)), CPos.New(Utils.RandomInteger(MapSlippedEdgeStartHorizontical, MapSlippedEdgeOverHorizontical), Utils.RandomInteger(MapSlippedEdgeStartVertical, MapSlippedEdgeOverVertical)), CPos.New(Utils.RandomInteger(MapSlippedEdgeStartHorizontical, MapSlippedEdgeOverHorizontical), Utils.RandomInteger(MapSlippedEdgeStartVertical, MapSlippedEdgeOverVertical)), CPos.New(Utils.RandomInteger(MapSlippedEdgeStartHorizontical, MapSlippedEdgeOverHorizontical), Utils.RandomInteger(MapSlippedEdgeStartVertical, MapSlippedEdgeOverVertical)), CPos.New(Utils.RandomInteger(MapSlippedEdgeStartHorizontical, MapSlippedEdgeOverHorizontical), Utils.RandomInteger(MapSlippedEdgeStartVertical, MapSlippedEdgeOverVertical)), CPos.New(Utils.RandomInteger(MapSlippedEdgeStartHorizontical, MapSlippedEdgeOverHorizontical), Utils.RandomInteger(MapSlippedEdgeStartVertical, MapSlippedEdgeOverVertical)), CPos.New(Utils.RandomInteger(MapSlippedEdgeStartHorizontical, MapSlippedEdgeOverHorizontical), Utils.RandomInteger(MapSlippedEdgeStartVertical, MapSlippedEdgeOverVertical)), CPos.New(Utils.RandomInteger(MapSlippedEdgeStartHorizontical, MapSlippedEdgeOverHorizontical), Utils.RandomInteger(MapSlippedEdgeStartVertical, MapSlippedEdgeOverVertical)), CPos.New(Utils.RandomInteger(MapSlippedEdgeStartHorizontical, MapSlippedEdgeOverHorizontical), Utils.RandomInteger(MapSlippedEdgeStartVertical, MapSlippedEdgeOverVertical)), CPos.New(Utils.RandomInteger(MapSlippedEdgeStartHorizontical, MapSlippedEdgeOverHorizontical), Utils.RandomInteger(MapSlippedEdgeStartVertical, MapSlippedEdgeOverVertical)), CPos.New(Utils.RandomInteger(MapSlippedEdgeStartHorizontical, MapSlippedEdgeOverHorizontical), Utils.RandomInteger(MapSlippedEdgeStartVertical, MapSlippedEdgeOverVertical)), CPos.New(Utils.RandomInteger(MapSlippedEdgeStartHorizontical, MapSlippedEdgeOverHorizontical), Utils.RandomInteger(MapSlippedEdgeStartVertical, MapSlippedEdgeOverVertical)), CPos.New(Utils.RandomInteger(MapSlippedEdgeStartHorizontical, MapSlippedEdgeOverHorizontical), Utils.RandomInteger(MapSlippedEdgeStartVertical, MapSlippedEdgeOverVertical))}, true, DateTime.Seconds(Utils.RandomInteger(8.8, 16.16))) 
				end
			end)
		end)
	elseif Cloudcount < CloudMaxcount and CloudCreatorState then
		CreateCloud()
	end
end
-------------------------------------------------------------------
CreateCloud = function()
	local Cloud = Actor.Create("cloud" .. Utils.RandomInteger(1, 4) .. Utils.Random({ ".25alpha", ".50alpha", ".50alpha", ".75alpha", ".90alpha" }), true, { Owner = clouds, Location = CPos.New(Utils.RandomInteger(MapSlippedEdgeStartHorizontical, MapSlippedEdgeOverHorizontical), Utils.RandomInteger(MapSlippedEdgeStartVertical, MapSlippedEdgeOverVertical)) })
	Cloudcount = Cloudcount + 1
	Trigger.OnRemovedFromWorld(Cloud, function()
		Cloudcount = Cloudcount - 1
		if Cloudcount < CloudMaxcount and CloudCreatorState then
			CloudCreator()
		end
	end)
	if Cloudcount < CloudMaxcount and CloudCreatorState then 
		CloudCreator() 
	end
end

