global Map =
{
	goldcounter = 0,

	casket_Opened = function(trigger)
	{
		SetAvailableMapGoals( TEAM.ALLIES, true, "FLAG_goldbox_altar" );
		Util.MapDebugPrint("casket_Opened");
	},

	gold_Captured = function(trigger)
	{
		Map.goldcounter += 1;
		Util.MapDebugPrint("gc:", Map.goldcounter);
		if (Map.goldcounter > 1)
		{
			SetAvailableMapGoals( TEAM.ALLIES, false, "ATTACK_.*" );
			SetAvailableMapGoals( TEAM.AXIS, false, "ATTACK_.*" );
		}
		SetAvailableMapGoals( TEAM.ALLIES, true, "ATTACK_cappoint.*" );
		SetAvailableMapGoals( TEAM.AXIS, true, "ATTACK_cappoint.*" );
		Util.MapDebugPrint("gold_Captured");
	},

	gold_Lost = function(trigger)
	{
	},

	gold_Secured = function(trigger)
	{
		Map.goldcounter -= 1;
		Util.MapDebugPrint("gc:", Map.goldcounter);
		SetAvailableMapGoals( TEAM.ALLIES, true, "ATTACK_.*" );
		SetAvailableMapGoals( TEAM.AXIS, true, "ATTACK_.*" );
		if (Map.goldcounter < 1)
		{
			SetAvailableMapGoals( TEAM.ALLIES, false, "ATTACK_cappoint.*" );
			SetAvailableMapGoals( TEAM.AXIS, false, "ATTACK_cappoint.*" );
		}
		Util.MapDebugPrint("gold_Secured");
	},

	gold_Returned = function(trigger)
	{
		Map.goldcounter -= 1;
		Util.MapDebugPrint("gc:", Map.goldcounter);
		SetAvailableMapGoals( TEAM.ALLIES, true, "ATTACK_.*" );
		SetAvailableMapGoals( TEAM.AXIS, true, "ATTACK_.*" );
		if (Map.goldcounter < 1)
		{
			SetAvailableMapGoals( TEAM.ALLIES, false, "ATTACK_cappoint.*" );
			SetAvailableMapGoals( TEAM.AXIS, false, "ATTACK_cappoint.*" );
		}
		Util.MapDebugPrint("gold_Returned");
	},

};

global OnMapLoad = function()
{
	// *** TRIGGERS ***
	OnTrigger( "The allies have opened the casket!", Map.casket_Opened );
	OnTrigger( "Allies have stolen the gold!", Map.gold_Captured );
	OnTrigger( "ml_chapel_axis_gold1_lost", Map.gold_Lost );
	OnTrigger( "ml_chapel_axis_gold2_lost", Map.gold_Lost );
	OnTrigger( "ml_chapel_axis_gold1_secured", Map.gold_Secured );
	OnTrigger( "ml_chapel_axis_gold2_secured", Map.gold_Secured );
	OnTrigger( "Flag returned goldbox_altar!", Map.gold_Returned );

	SetAvailableMapGoals( TEAM.ALLIES, false, {
		"FLAG_goldbox_altar",
		"SNIPE_.*",
		"ATTACK_cappoint.*",
	});
	SetAvailableMapGoals( TEAM.AXIS, false, "ATTACK_cappoint.*" );


	SetGoalPriority( "ATTACK_attack1", 0.55, TEAM.ALLIES );
	SetGoalPriority( "ATTACK_attack2", 0.55, TEAM.ALLIES );
	SetGoalPriority( "ATTACK_cappoint2", 0.6 );
	SetGoalPriority( "ATTACK_cappoint3", 0.6 );

	// *** ROUTES ***
	Maproutes =
	{
		FLAG_goldbox_altar =
		{
			ROUTE_allied_spawn =
			{
				ROUTE_allies_route1 = {},
				ROUTE_allies_route2 = {},
				ROUTE_allies_route3 = {},
			},
		},
		ATTACK_attack1 =
		{
			ROUTE_allied_spawn =
			{
				ROUTE_allies_route1 = {},
				ROUTE_allies_route2 = {},
				ROUTE_allies_route3 = {},
			},
			ROUTE_axis_spawn =
			{
				ROUTE_axis_route1 = {},
			},
			ROUTE_balcony2 =
			{
				ROUTE_axis_route1 = {},
			},
		},
		ATTACK_balcony2 =
		{
			ROUTE_attack1 =
			{
				ROUTE_axis_route1 = {},
			},
		},
		CAPPOINT_1 =
		{
			ROUTE_obj1 =
			{
				ROUTE_allies_route1 = {},
				ROUTE_allies_route2 = {},
			},
		},
	};
	Maproutes.ATTACK_attack2 = Maproutes.ATTACK_attack1;
	Maproutes.ATTACK_attack3 = Maproutes.ATTACK_attack1;
	Maproutes.ATTACK_attack4 = Maproutes.ATTACK_attack1;
	Util.Routes(Maproutes);

	Util.MapDebugPrint( "Omni_bot map script for " + GetMapName() + " executed." );
};
