// crapshoot: just needs tested i guess

global Map =
{
	Ammo_Cabinet_south_ammocabinet = "AMMOCAB_south_ammocabinet",
	Health_Cabinet_south_healthcabinet = "HEALTHCAB_south_healthcabinet",
	Checkpoint_oldcityflag = "CHECKPOINT_oldcityflag",
	Flag_radarbox1 = "FLAG_radarbox1",
	Flag_radarbox2 = "FLAG_radarbox2",
	Build_Command_Post = "BUILD_Command_Post",
	Plant_Command_Post = "PLANT_Command_Post",
	Plant_Main_Door = "PLANT_Main_Door",
	Plant_Side_Door = "PLANT_Side_Door",
        Cappoint_50 = "CAPPOINT_50",

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

	obj2_Taken = function( trigger )
	{

		SetAvailableMapGoals( TEAM.AXIS, false, {
			"DEFEND_GOLD_2",
			"DEFEND_GOLD_3",
			"ATTACK_GOLD_.*",
		});
//~		SetAvailableMapGoals( TEAM.AXIS, true, "DEFEND_DEF_1" );
		SetAvailableMapGoals( TEAM.AXIS, true, {
			"DEFEND_DEF_.*",
			"DEFEND_objtaken",
		});
		SetAvailableMapGoals( TEAM.ALLIES, false, "ATTACK_ag.*" );

		Util.MapDebugPrint( "obj2_taken" );
	},

	obj2_Returned = function( trigger )
	{

		SetAvailableMapGoals( TEAM.AXIS, true, {
			"DEFEND_GOLD_.*",
			"ATTACK_GOLD_.*",
		});


		SetAvailableMapGoals( TEAM.AXIS, false, {
			"DEFEND_DEF_.*",
			"DEFEND_objtaken",
		});
		SetAvailableMapGoals( TEAM.ALLIES, true, "ATTACK_ag.*" );

		Util.MapDebugPrint( "obj2_returned" );
	},

	obj2_secured = function( trigger )
	{


//~		SetAvailableMapGoals( TEAM.AXIS, true, "DEFEND_DEF_1" );
		SetAvailableMapGoals( TEAM.AXIS, true, "DEFEND_DEF_.*" );
		SetAvailableMapGoals( TEAM.ALLIES, false, "ATTACK_ag.*" );

		Util.MapDebugPrint( "Allies-obj2_secured" );
	},

	obj1_Taken = function( trigger )
	{

		SetAvailableMapGoals( TEAM.AXIS, false, {
			"DEFEND_GOLD_.*",
			"ATTACK_GOLD_.*",
		});
		SetAvailableMapGoals( TEAM.AXIS, true, "DEFEND_DEF_.*" );

//~		SetAvailableMapGoals( TEAM.AXIS, true, "DEFEND_objtaken" );
		SetAvailableMapGoals( TEAM.ALLIES, false, "ATTACK_ag.*" );

		Util.MapDebugPrint( "obj1_taken" );
	},

	obj1_Returned = function( trigger )
	{

		SetAvailableMapGoals( TEAM.AXIS, true, {
			"DEFEND_GOLD_2",
			"ATTACK_GOLD_3",
		});

		SetAvailableMapGoals( TEAM.AXIS, false, {
			"ATTACK_GOLD_1",
			"DEFEND_DEF_.*",
			"DEFEND_objtaken",
		});
		SetAvailableMapGoals( TEAM.ALLIES, true, "ATTACK_ag.*" );

		Util.MapDebugPrint( "obj1_returned" );
	},

	obj1_secured = function( trigger )
	{


		SetAvailableMapGoals( TEAM.AXIS, true, {
			"DEFEND_DEF_1",
			"DEFEND_DEF_2",
		});
		SetAvailableMapGoals( TEAM.ALLIES, false, "ATTACK_ag.*" );

		Util.MapDebugPrint( "Allies-obj1_secured" );
	},

	allied_compost_built_Built = function( trigger )
	{

		Util.MapDebugPrint( "allied_compost_built_Built" );
	},

	oldcitywall_Destroyed = function( trigger )
	{
		SetAvailableMapGoals( TEAM.AXIS, true, {
			"DEFEND_GOLD_2",
			"ATTACK_GOLD_.*",
		});

		SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_DEF_.*" );

		SetAvailableMapGoals( TEAM.ALLIES, true, {
			"FLAG_radarbox1",
			"FLAG_radarbox2",
			"ATTACK_ag.*",
		});

		Util.MapDebugPrint( "oldcitywall_Destroyed" );
	},

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

	dynamitetest_Destroyed = function( trigger )
	{

		SetAvailableMapGoals( TEAM.ALLIES, true, {
			"FLAG_radarbox1",
			"FLAG_radarbox2",
		});
		SetAvailableMapGoals( TEAM.AXIS, true, "ATTACK_GOLD_.*" );
		SetAvailableMapGoals( TEAM.AXIS, false, {
			"DEFEND_DEF_.*",
			"DEFEND_def_.*",
		});
		SetAvailableMapGoals( TEAM.AXIS, true, "DEFEND_GOLD_2" );

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

		foreach ( id and bot in BotTable )
		{
			if ( bot.GetTeam() == TEAM.AXIS )
			{
				if ( RandInt(0,1) < 1)
				{
					bot.ChangeSpawnPoint( 2 ); // downstairs
				}
				else
				{
					bot.ChangeSpawnPoint( 1 ); //flag
				}
			}


		}

		Util.MapDebugPrint( "dynamitetest_Destroyed" );
	},

 	Allies_Capture_Flag = function( trigger )
 	{

 		SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_objtaken" );

 		Util.MapDebugPrint( "Allies_Capture_Flag" );
 	},

 	Axis_Capture_Flag = function( trigger )
 	{


 		SetAvailableMapGoals( TEAM.AXIS, true, "DEFEND_objtaken" );
		foreach ( id and bot in BotTable )
		{
			if ( bot.GetTeam() == TEAM.AXIS )
			{
				if ( RandInt(0,1) < 1)
				{
					bot.ChangeSpawnPoint( 3 ); // downstairs
				}
				else
				{
					bot.ChangeSpawnPoint( 3 ); //flag
				}
			}
		}

		Util.MapDebugPrint( "Axis_Capture_Flag" );
 	},
};

global OnMapLoad = function()
{
	OnTrigger( "Allies have secured the Second Gold Crate!", Map.obj2_secured );
	OnTrigger( "Allies have secured the First Gold Crate!", Map.obj1_secured );
	OnTrigger( "Allies have stolen Second Gold Crate!", Map.obj2_Taken );
	OnTrigger( "Axis have returned Second Gold Crate!", Map.obj2_Returned );
	OnTrigger( "Allies have stolen First Gold Crate!", Map.obj1_Taken );
	OnTrigger( "Axis have returned First Gold Crate!", Map.obj1_Returned );
	OnTrigger( "MISSING_STRING", Map.axis_compost_built_Built );
	OnTrigger( "Allied Command Post constructed. Charge speed increased!", Map.allied_compost_built_Built );
	OnTrigger( "Allies have breached the Main Gate", Map.oldcitywall_Destroyed );
	OnTrigger( "MISSING_STRING", Map.allied_compost_built_Destroyed );
	OnTrigger( "Allies have blown open the Side Door!", Map.dynamitetest_Destroyed );
 	OnTrigger( "Allies capture the Palace!", Map.Allies_Capture_Flag );
 	OnTrigger( "Axis reclaim the Palace!", Map.Axis_Capture_Flag );


	Util.SetGoalOffset( -20, -80, 0, "PLANT_Main_Door" );
	Util.SetGoalOffset( -20, 0, 0, "PLANT_Side_Door" );
	Util.SetGoalOffset( 0, 0, -50, "CHECKPOINT_oldcityflag" );

	//SetAvailableMapGoals( TEAM.ALLIES, false, "DEFEND_GOLD_2" ); //cs: this doesn't exist
	SetAvailableMapGoals( TEAM.ALLIES, false, {
		"ATTACK_GOLD.*",
		"ATTACK_FLAG_1",
	});
	SetAvailableMapGoals( TEAM.AXIS, false, {
		"ATTACK_FLAG_1",
		"ATTACK_ag.*",
	});
	SetAvailableMapGoals( TEAM.ALLIES, false, "ATTACK_ag.*" );
	SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_objtaken" );

	//SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_GOLD_2" ); //cs: this doesn't exist
	SetAvailableMapGoals( TEAM.AXIS, false, "ATTACK_GOLD_.*" );


	SetAvailableMapGoals( TEAM.ALLIES, false, {
		"DEFEND_objtaken",
		"DEFEND_DEF_.*",
	});

	SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_objtaken" );
	SetAvailableMapGoals( TEAM.ALLIES, false, {
		"FLAG_radarbox1",
		"FLAG_radarbox2",
	});

	SetAvailableMapGoals( TEAM.AXIS, false, "ROUTE_.*" );
	SetAvailableMapGoals( TEAM.ALLIES, false, {
		"ROUTE_fs3",
		"ARTILLERY_.*",
		"CALLARTILLERY.*",
	});
	SetAvailableMapGoals( TEAM.AXIS, false, {
		"ARTILLERY_.*",
		"CALLARTILLERY.*",
	});

	Util.SetMaxUsers( 1, "DEFEND_.*" );


        MapRoutes =
        {
                PLANT_Main_Door =
                {
                        ROUTE_ally1  =
                        {
                                ROUTE_ally2  =
                                {
                                        Weight = 3,
                                        ROUTE_ally3  =
                                        {
                                                ROUTE_ally4  =
                                                {
                                                        ROUTE_fs4  =
                                                        {
                                                                ROUTE_ally5  =
                                                                {
                                                                },
                                                        },
                                                },
                                        },
                                },
                                ROUTE_ally6  =
                                {
                                        ROUTE_ally7  =
                                        {
                                                ROUTE_ally8  =
                                                {
                                                        ROUTE_fs3  =
                                                        {
                                                        },
                                                },
                                        },
                                },
                        },
                },
                FLAG_radarbox1 =
                {
                        ROUTE_fs2  =
                        {
                                ROUTE_fs3  =
                                {
                                        Weight = 3,
                                        ROUTE_fs4  = { },
                                        ROUTE_fs5  = { },
                                        ROUTE_gold3  = { },
                                        ROUTE_fs6  = { },
                                        ROUTE_fs7  = { },
                                        ROUTE_fs8  = { },
                                        ROUTE_fs9  = { },
                                        ROUTE_fs10  = { },
                                        ROUTE_fs11  = { },
                                        ROUTE_fs23  = {},
                                },
                                ROUTE_fs13  =
                                {
                                        ROUTE_gold2  =
                                        {
                                                ROUTE_fs18  = {},
                                                ROUTE_fs20  = {},
                                                ROUTE_fs21  = {},
                                                ROUTE_fs22  = {},
                                                ROUTE_fs23  = {},
                                        },
                                        ROUTE_gold1  =
                                        {
                                                ROUTE_fs14  = {},
                                                ROUTE_fs15  = {},
                                                ROUTE_fs16  = {},
                                                ROUTE_fs17  = {},
                                        },
                                },
                        },
                },
                CAPPOINT_50 =
                {
                        ROUTE_objective  =
                        {
                                ROUTE_fs23  =
                                {
                                        ROUTE_fs22  =
                                        {
                                                ROUTE_fs21  =
                                                {
                                                        ROUTE_fs20  =
                                                        {
                                                                ROUTE_gold2  =
                                                                {
                                                                        ROUTE_fs13  =
                                                                        {
                                                                        },
                                                                },
                                                                ROUTE_fs14  =
                                                                {
                                                                        ROUTE_gold1  =
                                                                        {
                                                                                ROUTE_fs13  =
                                                                                {
                                                                                },
                                                                        },
                                                                },
                                                        },
                                                },
                                        },
                                },
                                ROUTE_fs17 =
                                {
                                        ROUTE_fs16  =
                                        {
                                                ROUTE_fs15  =
                                                {
                                                        ROUTE_gold1  =
                                                        {
                                                                ROUTE_fs13  = {},
                                                        },
                                                },
                                        },
                                },
                        },
                },
        };

	MapRoutes.FLAG_radarbox2 = MapRoutes.FLAG_radarbox1;
	MapRoutes.ATTACK_ag1 = MapRoutes.FLAG_radarbox1;
	MapRoutes.ATTACK_ag2 = MapRoutes.FLAG_radarbox1;
	MapRoutes.CHECKPOINT_oldcityflag = MapRoutes.PLANT_Main_Door;
	Util.Routes(MapRoutes);

	Util.MapDebugPrint( "OnMapLoad" );
};

global OnBotJoin = function( bot )
{
	 bot.TargetBreakableDist = 400.0;
	 bot.MaxViewDistance = 3000.0;
};
