///////////////////////////////////////////////////////////////////////////////////////////////////

global Map =
{
	Quiet = true,
	AddHuntGoal = true,
	debug = false,

	// Functions

	ResetTeams = function()
	{
			// Reset ALLIES

			Wp.SetWaypointFlag("alboxes","closed",true);
			Wp.SetWaypointFlag("alfloor","closed",true);
			Wp.SetWaypointFlag("algrates","closed",true);
			Wp.SetWaypointFlag("alwalls","closed",true);
			Wp.SetWaypointFlag("alduel","closed",false);

			SetAvailableMapGoals( TEAM.ALLIES, false, {
				"SWITCH_al_boxes",
				"SWITCH_al_floor",
				"SWITCH_al_grates",
				"SWITCH_al_walls",
			});
			SetAvailableMapGoals( TEAM.ALLIES, true, "SWITCH_al_duel" );

			// Reset AXIS

			Wp.SetWaypointFlag("axboxes","closed",true);
			Wp.SetWaypointFlag("axfloor","closed",true);
			Wp.SetWaypointFlag("axgrates","closed",true);
			Wp.SetWaypointFlag("axwalls","closed",true);
			Wp.SetWaypointFlag("axduel","closed",false);

			SetAvailableMapGoals( TEAM.AXIS, false, {
				"SWITCH_ax_boxes",
				"SWITCH_ax_floor",
				"SWITCH_ax_grates",
				"SWITCH_ax_walls",
			});
			SetAvailableMapGoals( TEAM.AXIS, true, "SWITCH_ax_duel" );
	},

	// Triggers

	Allies_Duel = function( trigger )
	{
			Wp.SetWaypointFlag("alboxes","closed",false);
			Wp.SetWaypointFlag("alfloor","closed",false);
			Wp.SetWaypointFlag("algrates","closed",false);
			Wp.SetWaypointFlag("alwalls","closed",false);
			Wp.SetWaypointFlag("axduel","closed",true);

			SetAvailableMapGoals( TEAM.ALLIES, true, {
				"SWITCH_al_boxes",
				"SWITCH_al_floor",
				"SWITCH_al_grates",
				"SWITCH_al_walls",
			});
			SetAvailableMapGoals( TEAM.ALLIES, false, "SWITCH_al_duel" );

			Util.MapDebugPrint("Allies Are Ready!");
	},

	Axis_Duel = function( trigger )
	{
			Wp.SetWaypointFlag("axboxes","closed",false);
			Wp.SetWaypointFlag("axfloor","closed",false);
			Wp.SetWaypointFlag("axgrates","closed",false);
			Wp.SetWaypointFlag("axwalls","closed",false);
			Wp.SetWaypointFlag("axduel","closed",true);

			SetAvailableMapGoals( TEAM.AXIS, true, {
				"SWITCH_ax_boxes",
				"SWITCH_ax_floor",
				"SWITCH_ax_grates",
				"SWITCH_ax_walls",
			});
			SetAvailableMapGoals( TEAM.AXIS, false, "SWITCH_ax_duel" );

			Util.MapDebugPrint("Axis Are Ready!");
	},

	FIGHT = function( trigger )
	{
			Util.MapDebugPrint("FIGHT!");
	},

	Allies_Win = function( trigger )
	{
			Map.ResetTeams();

			Util.MapDebugPrint("Allies Win!");
	},

	Axis_Win = function( trigger )
	{
			Map.ResetTeams();

			Util.MapDebugPrint("Axis Win!");
	},

	No_Win = function( trigger )
	{
			Map.ResetTeams();

			Util.MapDebugPrint("No Winner");
	},
};

///////////////////////////////////////////////////////////////////////////////////////////////////

global OnMapLoad = function()
{
	OnTrigger( "The Allied team is ready", Map.Allies_Duel );
	OnTrigger( "The Axis team is ready", Map.Axis_Duel );
	OnTrigger( "^3Allies win!", Map.Allies_Win );
	OnTrigger( "^3Axis win!", Map.Axis_Win );
	OnTrigger( "The arena is empty, ^3no winner", Map.No_Win );
	OnTrigger( "^1FIGHT!", Map.FIGHT );

	Util.DisableGoal( ".*", true ); // all but routes

	// set Allies goals

	Wp.SetWaypointFlag("alboxes","closed",true);
	Wp.SetWaypointFlag("alfloor","closed",true);
	Wp.SetWaypointFlag("algrates","closed",true);
	Wp.SetWaypointFlag("alwalls","closed",true);
	Wp.SetWaypointFlag("alduel","closed",false);

	SetAvailableMapGoals( TEAM.ALLIES, true, "SWITCH_al_duel" );

	// set Axis goals

	Wp.SetWaypointFlag("axboxes","closed",true);
	Wp.SetWaypointFlag("axfloor","closed",true);
	Wp.SetWaypointFlag("axgrates","closed",true);
	Wp.SetWaypointFlag("axwalls","closed",true);
	Wp.SetWaypointFlag("axduel","closed",false);

	SetAvailableMapGoals( TEAM.AXIS, true, "SWITCH_ax_duel" );

	// routes
	MapRoutes =
	{
		SWITCH_al_duel =
		{
			ROUTE_al_spawn_route =
			{
				ROUTE_al_duel_route = {},
			},
		},

		SWITCH_ax_duel =
		{
			ROUTE_ax_spawn_route =
			{
				ROUTE_ax_duel_route = {},
			},
		},
	};
	Util.Routes(MapRoutes);

	Util.MapDebugPrint( "Omni-bot map script for " + GetMapName() + " executed." );
};

///////////////////////////////////////////////////////////////////////////////////////////////////

global OnBotJoin = function( bot )
{
	if ( Map.AddHuntGoal )
	{
		bot.AddScriptGoal("Hunt");
	}
};

///////////////////////////////////////////////////////////////////////////////////////////////////
