//==========================================================================================
//
//	himmelsdorf.gm
//
//	Who          	When		What
//------------------------------------------------------------------------------------------
//	^0d^7-^0lu^6X^7.	16 March 2022	Initial Script
//
//==========================================================================================
//

global Map =
{
	Debug = 0, // please set to zero before distributing your script
	ShowMovers = false,

	Allied_Command_Post_Dyno = 0,
	Axis_Command_Post_Dyno = 0,
	Depot_Side_Door_Dyno = 0,
	GOLD_DEPOSITORY_DOOR_Dyno = 0,
	Truck_Barrier_1_Dyno = 0,
	Truck_Barrier_2_Dyno = 0,
	Tunnel_Door_Dyno = 0,
	
	//ROUTE_allies_waytoObj_north = "ROUTE_allies_waytoObj_north",
	//ROUTE_allies_waytoObj_south = "ROUTE_allies_waytoObj_south",
	//ROUTE_all_fight_gate_west = "ROUTE_all_fight_gate_west",
	//ROUTE_all_fight_gate_north = "ROUTE_all_fight_gate_north",
	//ROUTE_all_fight_gate_north_2 = "ROUTE_all_fight_gate_north_2",	
	

	Allied_Command_Post_Built = function( trigger )
	{
		if ( TestMap )
			{ return; }

		Util.MapDebugPrint( "Allied_Command_Post_Built" );
	},

	Axis_Command_Post_Built = function( trigger )
	{
		if ( TestMap )
			{ return; }

		Util.MapDebugPrint( "Axis_Command_Post_Built" );
	},
	
	
	//Added extra functions bcs the map script suxx
	FactorySideDoor = function( trigger )
	{
		if ( TestMap )
			{ return; }

		SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_ax_defend_gate_.*" );
		SetAvailableMapGoals( TEAM.AXIS, true, "DEFEND_ax_defend_gold_.*" );
		SetAvailableMapGoals( TEAM.ALLIES, true, "CAPPOINT_truck_capture" );
		SetAvailableMapGoals( TEAM.ALLIES, true, "PLANT_goldDoor" );
		SetAvailableMapGoals( TEAM.ALLIES, false, "CAPPOINT_tank_capture" );
		SetAvailableMapGoals( TEAM.ALLIES, false, "ATTACK_all_attack_gate_.*" );
		SetAvailableMapGoals( TEAM.ALLIES, false, "ESCORT_tank" );
	},

	Tank_Built = function( trigger )
	{
		if ( TestMap )
			{ return; }

		Util.MapDebugPrint( "Tank_Built" );
		SetAvailableMapGoals( TEAM.ALLIES, true, "ESCORT_tank" );
		SetAvailableMapGoals( TEAM.AXIS, true, "DEFEND_ax_defend_gate_.*" );
		SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_defend_obj_.*" );
		SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_al_wait_obj_.*" );
		SetAvailableMapGoals( TEAM.ALLIES, false, "ROUTE_allies_waytoObj_.*" );
		SetAvailableMapGoals( TEAM.ALLIES, true, "ROUTE_all_fight_gate_.*" );
	},

	Truck_Built = function( trigger )
	{
		if ( TestMap )
			{ return; }

		Util.MapDebugPrint( "Truck_Built" );
	},

	Truck_Barrier_1_Built = function( trigger )
	{
		if ( TestMap )
			{ return; }

		Util.MapDebugPrint( "Truck_Barrier_1_Built" );
	},

	Truck_Barrier_2_Built = function( trigger )
	{
		if ( TestMap )
			{ return; }

		Util.MapDebugPrint( "Truck_Barrier_2_Built" );
	},

	Tunnel_Door_Built = function( trigger )
	{
		if ( TestMap )
			{ return; }

		Util.MapDebugPrint( "Tunnel_Door_Built" );
	},

	Allied_Command_Post_Planted = function( trigger )
	{
		if ( TestMap )
			{ return; }

		Map.Allied_Command_Post_Dyno += 1;
		Util.MapDebugPrint( "Allied_Command_Post_Planted" );
	},

	Axis_Command_Post_Planted = function( trigger )
	{
		if ( TestMap )
			{ return; }

		Map.Axis_Command_Post_Dyno += 1;
		Util.MapDebugPrint( "Axis_Command_Post_Planted" );
	},

	Depot_Side_Door_Planted = function( trigger )
	{
		if ( TestMap )
			{ return; }

		Map.Depot_Side_Door_Dyno += 1;
		Util.MapDebugPrint( "Depot_Side_Door_Planted" );
	},

	GOLD_DEPOSITORY_DOOR_Planted = function( trigger )
	{
		if ( TestMap )
			{ return; }

		Map.GOLD_DEPOSITORY_DOOR_Dyno += 1;
		Util.MapDebugPrint( "GOLD_DEPOSITORY_DOOR_Planted" );
		SetAvailableMapGoals( TEAM.ALLIES, true, "DEFEND_al_wait_goldDoor_.*" );
	},

	Truck_Barrier_1_Planted = function( trigger )
	{
		if ( TestMap )
			{ return; }

		Map.Truck_Barrier_1_Dyno += 1;
		Util.MapDebugPrint( "Truck_Barrier_1_Planted" );
	},

	Truck_Barrier_2_Planted = function( trigger )
	{
		if ( TestMap )
			{ return; }

		Map.Truck_Barrier_2_Dyno += 1;
		Util.MapDebugPrint( "Truck_Barrier_2_Planted" );
	},

	Tunnel_Door_Planted = function( trigger )
	{
		if ( TestMap )
			{ return; }

		Map.Tunnel_Door_Dyno += 1;
		Util.MapDebugPrint( "Tunnel_Door_Planted" );
		SetAvailableMapGoals( TEAM.ALLIES, true, "DEFEND_al_wait_obj_.*" );
	},

	Allied_Command_Post_Defused = function( trigger )
	{
		if ( TestMap )
			{ return; }

		Map.Allied_Command_Post_Dyno -= 1;
		Util.MapDebugPrint( "Allied_Command_Post_Defused" );
	},

	Axis_Command_Post_Defused = function( trigger )
	{
		if ( TestMap )
			{ return; }

		Map.Axis_Command_Post_Dyno -= 1;
		Util.MapDebugPrint( "Axis_Command_Post_Defused" );
	},

	Depot_Side_Door_Defused = function( trigger )
	{
		if ( TestMap )
			{ return; }

		Map.Depot_Side_Door_Dyno -= 1;
		Util.MapDebugPrint( "Depot_Side_Door_Defused" );
	},

	GOLD_DEPOSITORY_DOOR_Defused = function( trigger )
	{
		if ( TestMap )
			{ return; }

		Map.GOLD_DEPOSITORY_DOOR_Dyno -= 1;
		Util.MapDebugPrint( "GOLD_DEPOSITORY_DOOR_Defused" );
	},

	Truck_Barrier_1_Defused = function( trigger )
	{
		if ( TestMap )
			{ return; }

		Map.Truck_Barrier_1_Dyno -= 1;
		Util.MapDebugPrint( "Truck_Barrier_1_Defused" );
	},

	Truck_Barrier_2_Defused = function( trigger )
	{
		if ( TestMap )
			{ return; }

		Map.Truck_Barrier_2_Dyno -= 1;
		Util.MapDebugPrint( "Truck_Barrier_2_Defused" );
	},

	Tunnel_Door_Defused = function( trigger )
	{
		if ( TestMap )
			{ return; }

		Map.Tunnel_Door_Dyno -= 1;
		Util.MapDebugPrint( "Tunnel_Door_Defused" );
	},

	Allied_Command_Post_Destroyed = function( trigger )
	{
		if ( TestMap )
			{ return; }

		Map.Allied_Command_Post_Dyno = 0;

		Util.MapDebugPrint( "Allied_Command_Post_Destroyed" );
	},

	Axis_Command_Post_Destroyed = function( trigger )
	{
		if ( TestMap )
			{ return; }

		Map.Axis_Command_Post_Dyno = 0;

		Util.MapDebugPrint( "Axis_Command_Post_Destroyed" );
	},

	Depot_Side_Door_Destroyed = function( trigger )
	{
		if ( TestMap )
			{ return; }

		Map.Depot_Side_Door_Dyno = 0;

		Util.MapDebugPrint( "Depot_Side_Door_Destroyed" );
		SetAvailableMapGoals( TEAM.ALLIES, false, "PLANT_Depot_Side_Door" );
		SetAvailableMapGoals( TEAM.ALLIES, false, "PLANT_dep_sidedoor" );
		SetAvailableMapGoals( TEAM.ALLIES, true, "ROUTE_bring_gold_to_truck_.*" );
		Util.DisableGoal( "PLANT_Depot_Side_Door");
		Util.DisableGoal( "PLANT_dep_sidedoor");
	},

	GOLD_DEPOSITORY_DOOR_Destroyed = function( trigger )
	{
		if ( TestMap )
			{ return; }

		Map.GOLD_DEPOSITORY_DOOR_Dyno = 0;

		Util.MapDebugPrint( "GOLD_DEPOSITORY_DOOR_Destroyed" );
		Util.DisableGoal( "ESCORT_tank");
	},

	Truck_Barrier_1_Destroyed = function( trigger )
	{
		if ( TestMap )
			{ return; }

		Map.Truck_Barrier_1_Dyno = 0;

		Util.MapDebugPrint( "Truck_Barrier_1_Destroyed" );
	},

	Truck_Barrier_2_Destroyed = function( trigger )
	{
		if ( TestMap )
			{ return; }

		Map.Truck_Barrier_2_Dyno = 0;

		Util.MapDebugPrint( "Truck_Barrier_2_Destroyed" );
	},

	Tunnel_Door_Destroyed = function( trigger )
	{
		if ( TestMap )
			{ return; }

		Map.Tunnel_Door_Dyno = 0;

		Util.MapDebugPrint( "Tunnel_Door_Destroyed" );
		SetAvailableMapGoals( TEAM.ALLIES, false, "DEFEND_al_wait_obj_.*" );
	},

	gold_crate_Taken = function( trigger )
	{
		if ( TestMap )
			{ return; }

		Util.MapDebugPrint( "gold_crate_Taken" );
		SetAvailableMapGoals( TEAM.AXIS, true, "DEFEND_ax_defend_truck_.*" );
		
	},

	tank_fuel_Taken = function( trigger )
	{
		if ( TestMap )
			{ return; }

		Util.MapDebugPrint( "tank_fuel_Taken" );
	},

	gold_crate_Returned = function( trigger )
	{
		if ( TestMap )
			{ return; }

		Util.MapDebugPrint( "gold_crate_Returned" );
	},

	tank_fuel_Returned = function( trigger )
	{
		if ( TestMap )
			{ return; }

		Util.MapDebugPrint( "tank_fuel_Returned" );
	},

	gold_crate_Secured = function( trigger )
	{
		if ( TestMap )
			{ return; }

		Util.MapDebugPrint( "gold_crate_Secured" );
	},

	tank_fuel_Secured = function( trigger )
	{
		if ( TestMap )
			{ return; }

		Util.MapDebugPrint( "tank_fuel_Secured" );
		SetAvailableMapGoals( TEAM.ALLIES, true, "BUILD_Tank" );
		SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_defend_obj_.*" );
		SetAvailableMapGoals( TEAM.AXIS, true, "DEFEND_ax_defend_gate_.*" );
		SetAvailableMapGoals( TEAM.ALLIES, false, "DEFEND_al_wait_obj_.*" );
		SetAvailableMapGoals( TEAM.ALLIES, false, "DEFEND_defend_obj_.*" );
		SetAvailableMapGoals( TEAM.ALLIES, false, "BUILD_Allied_Command_Post" );
	},
	
	
	//Adding new triggers bcs.... the map original map script isn't that good
	escaping_gold = function(trigger)
	{
		if ( TestMap )
			{ return; }
		Util.MapDebugPrint( "Allies escaping with gold" );
		SetAvailableMapGoals( TEAM.AXIS, true, "BUILD_Truck_Barrier_1" );
		SetAvailableMapGoals( TEAM.ALLIES, true, "ESCORT_Esc_Truck" );
		SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_ax_defend_truck_.*" );
		SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_ax_defend_gold_.*" );
		SetAvailableMapGoals( TEAM.ALLIES, true, "DEFEND_defend_barrier1_.*" );
		SetAvailableMapGoals( TEAM.AXIS, true, "DEFEND_defend_barrier1_.*" );		
	},
	
	first_barrier_passed = function(trigger)
	{
		if ( TestMap )
			{ return; }
		Util.MapDebugPrint( "First barrier passed" );
		SetAvailableMapGoals( TEAM.AXIS, false, "BUILD_Truck_Barrier_1" );
		SetAvailableMapGoals( TEAM.AXIS, true, "DEFEND_ax_last_b.*" );
		SetAvailableMapGoals( TEAM.AXIS, true, "BUILD_Axis_Command_Post" );
		SetAvailableMapGoals( TEAM.ALLIES, false, "DEFEND_defend_barrier1_.*" );
		SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_defend_barrier1_.*" );			
	},

	truck_isonthe_way = function(trigger)
	{
		if ( TestMap )
			{ return; }
		Util.MapDebugPrint( "Truck is on the way" );
		SetAvailableMapGoals( TEAM.AXIS, true, "BUILD_Truck_Barrier_2" );
		SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_ax_last_.*" );
		SetAvailableMapGoals( TEAM.AXIS, true, "DEFEND_ax_last_b.*" );		
	},
	
	second_barrier_passed = function(trigger)
	{
		if ( TestMap )
			{ return; }
		Util.MapDebugPrint( "Second barrier passed" );
		SetAvailableMapGoals( TEAM.AXIS, true, "DEFEND_ax_last_.*" );
		SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_ax_last_b.*" );		
	}	
	

};

global OnMapLoad = function()
{
	if ( TestMapOn )
		{ Util.AutoTestMap(); }
	

	// Register callback functions
	OnTrigger( "Allied Command Post constructed. Charge speed increased!", Map.Allied_Command_Post_Built );
	OnTrigger( "Axis Command Post constructed. Charge speed increased!", Map.Axis_Command_Post_Built );
	OnTrigger( "The Tank has been repaired!", Map.Tank_Built );
	OnTrigger( "The Factory Side door has opened", Map.FactorySideDoor);
	OnTrigger( "MISSING_STRING", Map.Truck_Built );
	OnTrigger( "MISSING_STRING", Map.Truck_Barrier_1_Built );
	OnTrigger( "MISSING_STRING", Map.Truck_Barrier_2_Built );
	OnTrigger( "MISSING_STRING", Map.Tunnel_Door_Built );
	OnTrigger( "Planted at the Allied Command Post.", Map.Allied_Command_Post_Planted );
	OnTrigger( "Planted at the Axis Command Post.", Map.Axis_Command_Post_Planted );
	OnTrigger( "Planted at the MISSING_STRING.", Map.Depot_Side_Door_Planted );
	OnTrigger( "Planted at the DEPOSITORY DOOR.", Map.GOLD_DEPOSITORY_DOOR_Planted );
	OnTrigger( "Planted at the MISSING_STRING.", Map.Truck_Barrier_1_Planted );
	OnTrigger( "Planted at the MISSING_STRING.", Map.Truck_Barrier_2_Planted );
	OnTrigger( "Planted at the Tunnel Door.", Map.Tunnel_Door_Planted );
	OnTrigger( "Defused at the Allied Command Post.", Map.Allied_Command_Post_Defused );
	OnTrigger( "Defused at the Axis Command Post.", Map.Axis_Command_Post_Defused );
	OnTrigger( "Defused at the MISSING_STRING.", Map.Depot_Side_Door_Defused );
	OnTrigger( "Defused at the MISSING_STRING.", Map.GOLD_DEPOSITORY_DOOR_Defused );
	OnTrigger( "Defused at the MISSING_STRING.", Map.Truck_Barrier_1_Defused );
	OnTrigger( "Defused at the MISSING_STRING.", Map.Truck_Barrier_2_Defused );
	OnTrigger( "Defused at the MISSING_STRING.", Map.Tunnel_Door_Defused );
	OnTrigger( "MISSING_STRING", Map.Allied_Command_Post_Destroyed );
	OnTrigger( "MISSING_STRING", Map.Axis_Command_Post_Destroyed );
	OnTrigger( "^1Depot Side Entrance destroyed!", Map.Depot_Side_Door_Destroyed );
	OnTrigger( "the depot doors have been destroyed.", Map.GOLD_DEPOSITORY_DOOR_Destroyed );
	OnTrigger( "MISSING_STRING", Map.Truck_Barrier_1_Destroyed );
	OnTrigger( "MISSING_STRING", Map.Truck_Barrier_2_Destroyed );
	OnTrigger( "Allied team have blown the Tunnel door", Map.Tunnel_Door_Destroyed );
	OnTrigger( "Allies have stolen the Gold Crate!", Map.gold_crate_Taken );
	OnTrigger( "Allied team have stolen Tank Fuel!", Map.tank_fuel_Taken );
	OnTrigger( "MISSING_STRING", Map.gold_crate_Returned );
	OnTrigger( "Axis have returned Tank Fuel!", Map.tank_fuel_Returned );
	OnTrigger( "MISSING_STRING", Map.gold_crate_Secured );
	OnTrigger( "Allies have secured Tank Fuel!", Map.tank_fuel_Secured );
	OnTrigger( "Allied team is escaping with the Gold Crates!" , Map.escaping_gold);
	OnTrigger( "^1The spawns have moved" , Map.first_barrier_passed);
	OnTrigger( "^3The Truck is on the way!!!" , Map.truck_isonthe_way);
	OnTrigger( "^3The Truck has passed the second barrier!" , Map.second_barrier_passed);

	Util.DisableGoal( "MOUNTMG42_.*");
	Util.DisableGoal( "MOBILEMG42_.*" );
	Util.DisableGoal( "MOBILEMORTAR_.*");
	//Util.DisableGoal( "BUILD_Tank");
	//Util.DisableGoal("BUILD_Tank");
	Util.DisableGoal("PLANT_Axis_Command_Post");
	Util.DisableGoal("BUILD_Allied_Command_Post");
	Util.DisableGoal("BUILD_Tunnel_Door"); // Useless Goal bcs it doesn't work
	
	// Lets disable those fucking mobiles
	SetAvailableMapGoals( TEAM.ALLIES, false, "MOUNTMG42_.*" );
	SetAvailableMapGoals( TEAM.AXIS, false, "MOUNTMG42_.*" );
	SetAvailableMapGoals( TEAM.ALLIES, false, "MOBILEMG42_.*" );
	SetAvailableMapGoals( TEAM.AXIS, false, "MOBILEMG42_.*" );
	SetAvailableMapGoals( TEAM.ALLIES, false, "MOBILEMORTAR_.*" );
	SetAvailableMapGoals( TEAM.AXIS, false, "MOBILEMORTAR_.*" );
	SetAvailableMapGoals( TEAM.ALLIES, false, "MOBILEMORTAR_.*" );
	
	/////////////////////////////////////////
	
	
	
	//Axis Defend Goals
	SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_ax_defend_gate_.*" );
	SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_ax_defend_truck_.*" );
	SetAvailableMapGoals( TEAM.AXIS, true, "DEFEND_defend_obj_.*" );
	SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_ax_defend_gold_.*" );
	SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_ax_last_.*" );
	
	
	
	//Allies Object Goals
	SetAvailableMapGoals( TEAM.ALLIES, false, "BUILD_Tank" );
	SetAvailableMapGoals( TEAM.ALLIES, false, "PLANT_Axis_Command_Post" );
	SetAvailableMapGoals( TEAM.ALLIES, false, "BUILD_Allied_Command_Post" );	
	SetAvailableMapGoals( TEAM.ALLIES, true, "PLANT_Tunnel_Door" );
	SetAvailableMapGoals( TEAM.ALLIES, true, "PLANT_Allied_ObjDoor" );
	SetAvailableMapGoals( TEAM.ALLIES, false, "ESCORT_tank" );
	SetAvailableMapGoals( TEAM.ALLIES, false, "ESCORT_Esc_Truck" );
	SetAvailableMapGoals( TEAM.ALLIES, false, "CAPPOINT_truck_capture" );
	SetAvailableMapGoals( TEAM.ALLIES, false, "PLANT_goldDoor" );
	SetAvailableMapGoals( TEAM.ALLIES, false, "PLANT_Depot_Side_Door" );
	
	//Axis Object Goals
	SetAvailableMapGoals( TEAM.AXIS, false, "BUILD_Truck_Barrier_1" );
	SetAvailableMapGoals( TEAM.AXIS, false, "BUILD_Truck_Barrier_2" );
	SetAvailableMapGoals( TEAM.AXIS, false, "BUILD_Axis_Command_Post" );
	
	
	
	//Allies Wait and Attack Goals
	SetAvailableMapGoals( TEAM.ALLIES, false, "DEFEND_al_wait_obj_.*" );
	SetAvailableMapGoals( TEAM.ALLIES, false, "DEFEND_al_wait_goldDoor_.*" );
	
	//Allies Routes
	SetAvailableMapGoals( TEAM.ALLIES, true, "ROUTE_allies_waytoObj_.*" );
	SetAvailableMapGoals( TEAM.ALLIES, false, "ROUTE_all_fight_gate_.*" );
	SetAvailableMapGoals( TEAM.ALLIES, false, "ROUTE_bring_gold_to_truck_.*" );
	
	SetAvailableMapGoals( TEAM.ALLIES, false, "DEFEND_defend_barrier1_.*" );
	SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_defend_barrier1_.*" );
	SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_ax_last_.*" );
	SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_ax_last_b.*" );
	
	
	
	SetGoalPriority( "PLANT_Tunnel_Door", 1.0);
	SetGoalPriority( "PLANT_Allied_ObjDoor", 1.0);

	// Max users per goal
	Util.SetMaxUsers( 1, "ATTACK_.*" );
	Util.SetMaxUsers( 1, "DEFEND_.*" );
	Util.SetMaxUsers( 1, "GRENADE_.*" );
	Util.SetMaxUsers( 1, "SNIPE_.*" );
	Util.SetMaxUsers( 0, "MOUNTMG42_.*" );
	Util.SetMaxUsers( 0, "MOBILEMG42_.*" );
	Util.SetMaxUsers( 0, "MOBILEMORTAR_.*" );
	Util.SetMaxUsers( 1, "AIRSTRIKE_.*" );
	Util.SetMaxUsers( 1, "CALLARTILLERY_.*" );

	// Camp times
	//SetMapGoalProperties( "MOUNTMG42_.*", {MinCampTime=15, MaxCampTime=90} );
	//SetMapGoalProperties( "MOBILEMG42_.*", {MinCampTime=10, MaxCampTime=60} );
	
	MapRoutes =
	{
		FLAG_tank_fuel = 
		{
			ROUTE_allies_waytoObj_north  = 
			{
			},
			ROUTE_allies_waytoobj_south  = 
			{
			},
		},
		CAPPOINT_truck_capture = 
		{
			ROUTE_bring_gold_to_truck_1  = 
			{
			},
			ROUTE_bring_gold_to_truck_2  = 
			{
			},
		},
	};

	Util.Routes(MapRoutes);


	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;
};
