//==========================================================================================
//
//	maccupiccu_b2.gm
//
//	Who                  	When		What
//------------------------------------------------------------------------------------------
//	maker@bigsighstudios.com	28 August 2018	Initial Script
//
//==========================================================================================
//

global Map =
{
	Debug = 0, // please set to zero before distributing your script
	DefendingTeam = TEAM.AXIS,

	Navigation =
	{
		door_slow =
		{
			navigate = function(_this)
			{
				_this.AddAimRequest(Priority.High, "facing", Vec3( 0.03, 1, -0.25 ));
				sleep(1.5);
			}
		},
	},


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

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

	Axis_East_Ladder_Defense_Built = function( trigger )
	{
		SetAvailableMapGoals( TEAM.AXIS, 1, "CAMP_r1_east_.*" );
		Util.MapDebugPrint( "Axis_East_Ladder_Defense_Built" );
	},
	Axis_East_Ladder_Defense_Destroyed = function( trigger )
	{
		SetAvailableMapGoals( TEAM.AXIS, 0, "CAMP_r1_east_.*" );
		Util.MapDebugPrint( "Axis_East_Ladder_Defense_Destroyed" );
	},

	Axis_West_Ladder_Defense_Built = function( trigger )
	{
		SetAvailableMapGoals( TEAM.AXIS, 1, "CAMP_r1_west_.*" );
		Util.MapDebugPrint( "Axis_West_Ladder_Defense_Built" );
	},
	Axis_West_Ladder_Defense_Destroyed = function( trigger )
	{
		SetAvailableMapGoals( TEAM.AXIS, 0, "CAMP_r1_west_.*" );
		Util.MapDebugPrint( "Axis_West_Ladder_Defense_Destroyed" );
	},

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

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

	Old_City_Door_Destroyed = function( trigger )
	{
		SetAvailableMapGoals( TEAM.ALLIES, 0, "BUILD_Allied_Assault_Ladder_[12]" );
		SetAvailableMapGoals( TEAM.ALLIES, 1, {
			"BUILD_Charge_Booster",
			"PLANT_Sun_Symbol_Pyramid_Door",
			"PLANT_Moon_Symbol_Pyramid_Door",
			"CAPPOINT_Truck",
		});

		SetAvailableMapGoals( 1, 1, {
			"BUILD_Axis_West_MG42_nest",
			"BUILD_Axis_East_MG42_nest",
			"MOUNTMG42_Axis_West_MG42_nest",
			"MOUNTMG42_Axis_East_MG42_nest",
		});

		SetAvailableMapGoals( 0, 1, "SNIPE_Tower_.*" );
		Util.MapDebugPrint( "Old_City_Door_Destroyed" );
	},

	Moon_Symbol_Pyramid_Door_Destroyed = function( trigger )
	{
		SetAvailableMapGoals( TEAM.ALLIES, 1, "FLAG_radarbox2" );
		Util.MapDebugPrint( "Moon_Symbol_Pyramid_Door_Destroyed" );
	},

	Sun_Symbol_Pyramid_Door_Destroyed = function( trigger )
	{
		SetAvailableMapGoals( TEAM.ALLIES, 1, "FLAG_radarbox1" );
		Util.MapDebugPrint( "Sun_Symbol_Pyramid_Door_Destroyed" );
	},

	radarbox1_Taken = function( trigger )
	{
		SetAvailableMapGoals( TEAM.ALLIES, 1, "CAPPOINT_Truck" );
		Util.MapDebugPrint( "radarbox1_Taken" );
	},
	radarbox1_Returned = function( trigger )
	{
		Util.MapDebugPrint( "radarbox1_Returned" );
	},
	radarbox1_Secured = function( trigger )
	{
		Util.MapDebugPrint( "radarbox1_Secured" );
	},

	radarbox2_Taken = function( trigger )
	{
		Util.MapDebugPrint( "radarbox2_Taken" );
	},
	radarbox2_Returned = function( trigger )
	{
		Util.MapDebugPrint( "radarbox2_Returned" );
	},
	radarbox2_Secured = function( trigger )
	{
		Util.MapDebugPrint( "radarbox2_Secured" );
	},

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

	// Neutral Command Post
	CP_Owner = 0,
	CP_Dyno = 0,

	Set_CP = function(_p) // p = TEAM.ALLIES or TEAM.AXIS or 0 (unbuilt)
	{
		switch(_p)
		{
			case 0:
			{
				Map.CP_Owner = 0;
				SetAvailableMapGoals( TEAM.ALLIES, 1, "BUILD_Charge_Booster" );
				SetAvailableMapGoals( TEAM.ALLIES, 0, "PLANT_Charge_Booster" );
				SetAvailableMapGoals( TEAM.AXIS,   1, "BUILD_Charge_Booster" );
				SetAvailableMapGoals( TEAM.AXIS,   0, "PLANT_Charge_Booster" );
			}
			case TEAM.ALLIES:
			{
				Map.CP_Owner = TEAM.ALLIES;
				SetAvailableMapGoals( TEAM.ALLIES, 0, "BUILD_Charge_Booster" );
				SetAvailableMapGoals( TEAM.ALLIES, 0, "PLANT_Charge_Booster" );
				SetAvailableMapGoals( TEAM.AXIS,   1, "PLANT_Charge_Booster" );
				SetAvailableMapGoals( TEAM.AXIS,   0, "BUILD_Charge_Booster" );
			}
			case TEAM.AXIS:
			{
				Map.CP_Owner = TEAM.AXIS;
				SetAvailableMapGoals( TEAM.ALLIES, 0, "BUILD_Charge_Booster" );
				SetAvailableMapGoals( TEAM.ALLIES, 1, "PLANT_Charge_Booster" );
				SetAvailableMapGoals( TEAM.AXIS,   0, "PLANT_Charge_Booster" );
				SetAvailableMapGoals( TEAM.AXIS,   0, "BUILD_Charge_Booster" );
			}
		}
		//Util.MapDebugPrint("CP Owner: " + Map.CP_Owner );
	},
	Allied_CP_Built = function( trigger )
	{
		Map.Set_CP(TEAM.ALLIES);
		Util.MapDebugPrint( "Allied_CP_Built" );
	},
	Allied_CP_Destroyed = function( trigger )
	{
		Map.CP_Dyno = 0;
		Map.Set_CP(0);
		Util.MapDebugPrint( "Allied_CP_Destroyed" );
	},
	Axis_CP_Built = function( trigger )
	{
		Map.Set_CP(TEAM.AXIS);
		Util.MapDebugPrint( "Axis_CP_Built" );
	},
	Axis_CP_Destroyed = function( trigger )
	{
		Map.CP_Dyno = 0;
		Map.Set_CP(0);
		Util.MapDebugPrint( "Axis_CP_Destroyed" );
	},
	CP_Planted = function( trigger )
	{
		Map.CP_Dyno += 1;
		Util.MapDebugPrint( "CP_Planted" );
	},
	CP_Defused = function( trigger )
	{
		Map.CP_Dyno -= 1;
		Util.MapDebugPrint( "CP_Defused" );
	},

};

global OnMapLoad = function()
{
	// Register callback functions

	//Buildables

	OnTrigger( "^2The Allied Assault Ladder has been constructed.", Map.Allied_Assault_Ladder_Built );
	OnTrigger( "^2The Allies Assault Ladder has been destroyed.", Map.Allied_Assault_Ladder_Destroyed );

	OnTrigger( "^2The Allied Assault Ladder has been constructed.", Map.Allied_Assault_Ladder_1_Built );
	OnTrigger( "^2The Allies Assault Ladder has been destroyed.", Map.Allied_Assault_Ladder_1_Destroyed );

	OnTrigger( "^3The Axis East Ladder defense has been constructed.", Map.Axis_East_Ladder_Defense_Built );
	OnTrigger( "^3The Axis East Ladder defense has been destroyed.", Map.Axis_East_Ladder_Defense_Destroyed );

	OnTrigger( "^3The Axis West Ladder defense has been constructed.", Map.Axis_West_Ladder_Defense_Built );
	OnTrigger( "^3The Axis West Ladder defense has been destroyed.", Map.Axis_West_Ladder_Defense_Destroyed );

	OnTrigger( "^3The Axis East MG42 Nest has been constructed.", Map.Axis_East_MG42_Nest_Built );
	OnTrigger( "^3The Axis East MG42 Nest has been destroyed.", Map.Axis_East_MG42_Nest_Destroyed );

	OnTrigger( "^3The Axis West MG42 Nest has been constructed.", Map.Axis_West_MG42_nest_Built );
	OnTrigger( "^3The Axis West MG42 Nest has been destroyed.", Map.Axis_West_MG42_nest_Destroyed );

	OnTrigger( "^1Allies have breached the Old City Door", Map.Old_City_Door_Destroyed );

	OnTrigger( "^1The East Pyramid Door is Destroyed !", Map.Moon_Symbol_Pyramid_Door_Destroyed );

	OnTrigger( "^1The West Pyramid Door is Destroyed !", Map.Sun_Symbol_Pyramid_Door_Destroyed );

	OnTrigger( "Axis have stolen the Moon Symbol!", Map.radarbox1_Taken );
	OnTrigger( "Axis have returned the Moon Symbol!", Map.radarbox1_Returned );
	OnTrigger( "^1Allies have secured the Moon Symbol!", Map.radarbox1_Secured );

	OnTrigger( "Axis have stolen the Sun Symbol!", Map.radarbox2_Taken );
	OnTrigger( "Axis have returned the Sun Symbol!", Map.radarbox2_Returned );
	OnTrigger( "^1Allies have secured the Sun Symbol!", Map.radarbox2_Secured );

	OnTrigger( "^1Axis reclaim the Old City!", Map.oldcityflag_Axis_Captured );
	OnTrigger( "^1Allies capture the Old City!", Map.oldcityflag_Allies_Captured );

	//OnMapLoad CP Triggers
	OnTrigger( "^8Allies Charge Booster constructed. Charge speed increased !",  Map.Allied_CP_Built );
	OnTrigger( "^8Axis have destroyed the Charge Booster !",                     Map.Allied_CP_Destroyed );
	OnTrigger( "^8Axis Charge Booster constructed. Charge speed increased !",    Map.Axis_CP_Built );
	OnTrigger( "^8Allies have destroyed the Charge Booster !",                   Map.Axis_CP_Destroyed );


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

	Util.LimitToClass("PLANT_Axis_East_Ladder_Defense", 2, 5 );
	Util.LimitToClass("PLANT_Axis_West_Ladder_Defense", 2, 5 );

	Util.LimitToClass("BUILD_Axis_West_MG42_nest", 1, 3 );
	Util.LimitToClass("BUILD_Axis_East_MG42_nest", 1, 3 );

	Util.LimitToClass("PLANT_Axis_West_MG42_nest", 2, 5 );
	Util.LimitToClass("PLANT_Axis_East_MG42_nest", 2, 5 );

	Util.LimitToClass("PLANT_Charge_Booster", 0, 5 );

	//Allies
	SetAvailableMapGoals( TEAM.ALLIES, 1, {
		"CAMP_b1_.*",
		"PLANT_Old_City_Door",
		"BUILD_Allied_Assault_Ladder",
		"BUILD_Allied_Assault_Ladder_1",
		"MOUNTMG42_128",
	});

	//Axis
	SetAvailableMapGoals( TEAM.AXIS, 1, {
		"BUILD_Axis_West_Ladder_Defense",
		"BUILD_Axis_East_Ladder_Defense",
	});

	// Max users per goal
	Util.SetMaxUsers( 1, "CAMP_.*" );

	// Camp times
	SetMapGoalProperties( "CAMP_.*", {MinCampTime=60, MaxCampTime=300} );
	SetGoalPriority( "SNIPE_Tower_.*", 0.95 );

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

global OnBotJoin = function( bot )
{
	// Uncomment for shootable breakables
	bot.TargetBreakableDist = 90.0;
	// Only set MaxViewDistance on maps with limited sight (e.g. fog)
	//~bot.MaxViewDistance = 2400;
};

global InitializeRoutes = function()
{
	MapRoutes =
	{
		CHECKPOINT_oldcityflag =
		{
		},
		PLANT_Old_City_Door =
		{
		},
		BUILD_Charge_Booster =
		{
		},
		PLANT_Charge_Booster =
		{
		},
		PLANT_Moon_Symbol_Pyramid_Door =
		{
		},
		PLANT_Sun_Symbol_Pyramid_Door =
		{
		},
		FLAG_radarbox1 =
		{
		},
		FLAG_radarbox2 =
		{
		},
		BUILD_Axis_East_MG42_Nest =
		{
		},
		PLANT_Axis_East_MG42_Nest =
		{
		},
		BUILD_Axis_West_MG42_nest =
		{
		},
		PLANT_Axis_West_MG42_nest =
		{
		},
		BUILD_Axis_East_Ladder_Defense =
		{
		},
		PLANT_Axis_East_Ladder_Defense =
		{
		},
		BUILD_Axis_West_Ladder_Defense =
		{
		},
		PLANT_Axis_West_Ladder_Defense =
		{
		},
		BUILD_Allied_Assault_Ladder =
		{
		},
		PLANT_Allied_Assault_Ladder =
		{
		},
		BUILD_Allied_Assault_Ladder_1 =
		{
		},
		PLANT_Allied_Assault_Ladder_1 =
		{
		},
	};
	Util.Routes(MapRoutes);
};
