//==========================================================================================
//
//	decay_b3.gm
//
//	Who      	When		What
//------------------------------------------------------------------------------------------
//	Qiki		28 June 2016	Initial Script and waypoints
//	Native12	13.08.2016	Released for testing
//	Native12	02.04.2017	Fixed bug with variable Secret_Docs_Taken => should be SecretDocsTaken
//					added roles for CappointPlace goals
//	Native12	04.01.2019	Adapted for new function Util.CappointForFlag
//
//==========================================================================================
//

global Map =
{
	Fence = false,
	Fence_Dyno = 0,
	Ramp = false,
	Ramp_Dyno = 0,
	Allied_CP = false,
	Allied_CP_Dyno = 0,
	Axis_CP = false,
	Axis_CP_Dyno = false,
	Generator = true,
	Generator_Dyno = 0,
	Side_Gate = true,
	Side_Gate_Dyno = 0,
	Gold_1_Taken = false,
	Gold1_Secured = false,
	Gold_2_Taken = false,
	Gold2_Secured = false,
	SecretDocsTaken = false,
	SecretDocsSecured = false,
	Forward_Flag_Axis = true,
	Forward_Flag_Allied = false,

	DontDispenseAmmo = true,

	Roles =
	{
		AXIS =
		{
			AllBots = true, // each bot is considered for a role

			DEFENDER =
			{
				numbots = 5,
				//crucialClass = CLASS.ENGINEER,
			},
			DEFENDER1 =
			{
				numbots = 5,
				crucialClass = CLASS.ENGINEER,
			},
			DEFENDER2 =
			{
				numbots = 5,
				//crucialClass = CLASS.ENGINEER,
			},
			DEFENDER3 =
			{
				numbots = 5,
				crucialClass = CLASS.ENGINEER,
			},
		},

		ALLIES =
		{
			AllBots = true, // each bot is considered for a role

			ATTACKER =
			{
				numbots = 5,
				crucialClass = CLASS.ENGINEER,
			},
			ATTACKER1 =
			{
				numbots = 5,
				//crucialClass = CLASS.ENGINEER,
			},
			ATTACKER2 =
			{
				numbots = 5,
				//crucialClass = CLASS.ENGINEER,
			},
			ATTACKER3 =
			{
				numbots = 5,
				crucialClass = CLASS.ENGINEER,
			},
		},
	},

	Navigation =
	{
		//	/bot waypoint_setproperty paththrough Navigation_PT:jump
		jump =
		{
			navigate = function(_this)
			{
				_this.Bot.HoldButton(BTN.JUMP, 0.55);
				sleep(0.55);
			},
		},
	},


	Fence_Built = function()
	{
		Map.Fence = true;

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

		if ( Map.SecretDocsSecured or !Map.Side_Gate )
		{
			SetAvailableMapGoals( TEAM.ALLIES, true, "PLANT_Fence" );
		}

		Util.MapDebugPrint( "Fence_Built" );
	},

	Fence_Planted = function()
	{
		Map.Fence_Dyno += 1;

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

		Util.MapDebugPrint( "Fence_Planted" );
	},

	Fence_Defused = function()
	{
		Map.Fence_Dyno -= 1;

		Util.MapDebugPrint( "Fence_Defused" );
	},

	Fence_Destroyed = function()
	{
		Map.Fence = false;

		SetAvailableMapGoals( TEAM.ALLIES, false, "PLANT_Fence" );

		if ( Map.SecretDocsSecured or !Map.Side_Gate )
		{
			SetAvailableMapGoals( TEAM.AXIS, true, "BUILD_Fence" );
		}

		Util.MapDebugPrint( "Fence_Destroyed" );
	},

	Ramp_Built = function()
	{
		Map.Ramp = true;

		Wp.SetWaypointFlag( "Ramp_2", "closed", false );

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

		if ( !Map.SecretDocsSecured )
		{
			SetAvailableMapGoals( TEAM.ALLIES, true, "PLANT_Ramp" );
		}

		Util.MapDebugPrint( "Ramp_Built" );
	},

	Ramp_Planted = function()
	{
		Map.Ramp_Dyno += 1;

		if ( Map.SecretDocsSecured )
		{
			SetAvailableMapGoals( TEAM.AXIS, false, "DEFUSE_Ramp_.*" );
		}

		Util.MapDebugPrint( "Ramp_Planted" );
	},

	Ramp_Defused = function()
	{
		Map.Ramp_Dyno -= 1;

		Util.MapDebugPrint( "Ramp_Defused" );
	},

	Ramp_Destroyed = function()
	{
		Map.Ramp = false;

		Wp.SetWaypointFlag( "Ramp_2", "closed", true );

		SetAvailableMapGoals( TEAM.ALLIES, false, "PLANT_Ramp" );

		if ( !Map.SecretDocsSecured )
		{
			SetAvailableMapGoals( TEAM.AXIS, true, "BUILD_Ramp" );
		}

		Util.MapDebugPrint( "Ramp_Destroyed" );
	},

	CP_Planted = function()
	{
		Util.SetMaxUsers( 1, "DEFUSE_Neutral_Command_Post_.*" );

		if ( Map.Allied_CP )
		{
			Map.Allied_CP_Dyno += 1;

			Util.MapDebugPrint( "Allied_CP_Planted" );
		}
		else
		{
			Map.Axis_CP_Dyno += 1;

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

	CP_Defused = function()
	{
		if ( Map.Allied_CP )
		{
			Map.Allied_CP_Dyno -= 1;

			Util.MapDebugPrint( "Allied_CP_Defused" );
		}
		else
		{
			Map.Axis_CP_Dyno -= 1;

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

	Allied_CP_Built = function()
	{
		Map.Allied_CP = true;

		Map.SetSpawn();

		Util.MapDebugPrint( "Allied_CP_Built" );
	},

	Allied_CP_Destroyed = function()
	{
		Map.Allied_CP = false;

		Map.SetSpawn();

		Util.MapDebugPrint( "Allied_CP_Destroyed" );
	},

	Axis_CP_Built = function()
	{
		Map.Axis_CP = true;

		Util.MapDebugPrint( "Axis_CP_Built" );
	},

	Axis_CP_Destroyed = function()
	{
		Map.Axis_CP = false;

		Util.MapDebugPrint( "Axis_CP_Destroyed" );
	},

	Generator_Planted = function()
	{
		Map.Generator_Dyno += 1;

		SetAvailableMapGoals( TEAM.ALLIES, false, "SMOKEBOMB_Allies_Generator_.*" );

		Util.MapDebugPrint( "Generator_Planted" );
	},

	Generator_Defused = function()
	{
		Map.Generator_Dyno -= 1;

		if ( Map.Generator_Dyno == 0 )
		{
			SetAvailableMapGoals( TEAM.ALLIES, true, "SMOKEBOMB_Allies_Generator_.*" );
		}

		Util.MapDebugPrint( "Generator_Defused" );
	},

	Generator_Destroyed = function()
	{
		Map.Generator = false;

		ClearGoalRole( "DEFEND_Axis_Gold_.*", ROLE.DEFENDER3 );

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

		SetAvailableMapGoals( TEAM.AXIS, true, ".*_Axis_Gold_.*" );

		SetAvailableMapGoals( TEAM.ALLIES, true, ".*_Allies_Gold_.*" );

		sleep(3);

		SetAvailableMapGoals( TEAM.ALLIES, false, ".*_Allies_Generator_.*" );

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

		Util.MapDebugPrint( "Generator_Destroyed" );
	},

	Side_Gate_Planted = function()
	{
		Map.Side_Gate_Dyno += 1;

		if ( Map.SecretDocsSecured )
		{
			SetAvailableMapGoals( TEAM.AXIS, false, "DEFUSE_side_gate_.*" );
		}

		Util.MapDebugPrint( "Side_Gate_Planted" );
	},

	Side_Gate_Defused = function()
	{
		Map.Side_Gate_Dyno -= 1;

		Util.MapDebugPrint( "Side_Gate_Defused" );
	},

	Side_Gate_Destroyed = function()
	{
		Map.Side_Gate = false;

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

		SetAvailableMapGoals( TEAM.ALLIES, false, "PLANT_side_gate" );

		if ( !Map.SecretDocsSecured )
		{
			Util.EnableGoal( {
				"BUILD_Neutral_Command_Post",
				"PLANT_Neutral_Command_Post",
			});

			if ( !Map.Fence )
			{
				SetAvailableMapGoals( TEAM.AXIS, true, "BUILD_Fence" );
			}

			if ( Map.Generator )
			{
				SetAvailableMapGoals( TEAM.AXIS, true, "DEFEND_Axis_Generator_.*" );
			}

			SetAvailableMapGoals( TEAM.AXIS, true, "DEFEND_Axis_Gold_.*" );

			sleep(3);

			SetAvailableMapGoals( TEAM.ALLIES, false, "ATTACK_Allies_SideGate_.*" );

			if ( Map.Fence )
			{
				SetAvailableMapGoals( TEAM.ALLIES, true, "PLANT_Fence" );
			}

			if ( Map.Generator )
			{
				SetAvailableMapGoals( TEAM.ALLIES, true, {
					"PLANT_Generator",
					"ATTACK_Allies_Generator_.*",
				});
			}
		}

		Util.MapDebugPrint( "Side_Gate_Destroyed" );
	},

	Gold_Taken = function()
	{
		if ( !Map.Gold1_Secured )
		{
			Map.Gold_1_Taken = true;

			Util.CappointForFlag( "FLAG_axis_gold1", "CAPPOINT_Truck" );

			SetAvailableMapGoals( TEAM.ALLIES, false, "SMOKEBOMB_Allies_Gold_.*" );

			SetAvailableMapGoals( TEAM.AXIS, true, "DEFEND_Axis_CappointPlace_.*" );

			SetAvailableMapGoals( TEAM.ALLIES, true, {
				"ATTACK_Allies_CappointPlace_.*",
				"CAMP_Allies_Gold_.*",
				"CAPPOINT_Truck",
			});

			Util.MapDebugPrint( "Gold_1_Taken" );
		}
		else
		{
			Map.Gold_2_Taken = true;

			Util.CappointForFlag( "FLAG_axis_gold2", "CAPPOINT_Truck" );

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

			SetAvailableMapGoals( TEAM.ALLIES, false, "SMOKEBOMB_Allies_Gold_.*" );

			SetAvailableMapGoals( TEAM.AXIS, true, ".*_Axis_CappointPlace_.*" );

			SetAvailableMapGoals( TEAM.ALLIES, true, {
				".*_Allies_CappointPlace_.*",
				"CAPPOINT_Truck",
			});

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

	Gold_1_Dropped = function()
	{
		SetAvailableMapGoals( TEAM.ALLIES, false, "CAPPOINT_Truck" );

		Util.MapDebugPrint( "Gold_1_Dropped" );
	},

	Gold_1_Returned = function()
	{
		Map.Gold_1_Taken = false;

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

		SetAvailableMapGoals( TEAM.ALLIES, false, {
			"ATTACK_Allies_CappointPlace_.*",
			"CAMP_Allies_Gold_.*",
		});

		SetAvailableMapGoals( TEAM.ALLIES, true, "SMOKEBOMB_Allies_Gold_.*" );

		Util.MapDebugPrint( "Gold_1_Returned" );
	},

	Gold_1_Secured = function()
	{
		Map.Gold_1_Taken = false;
		Map.Gold1_Secured = true;

		Util.DisableGoal( "FLAG_axis_gold1" );

		ClearGoalRole( "DEFEND_Axis_CappointPlace_.*", { ROLE.DEFENDER2, ROLE.DEFENDER3 } );

		ClearGoalRole( "ATTACK_Allies_CappointPlace_.*", { ROLE.ATTACKER2, ROLE.ATTACKER3 } );

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

		SetAvailableMapGoals( TEAM.ALLIES, false, "CAPPOINT_Truck" );

		SetAvailableMapGoals( TEAM.ALLIES, true, "SMOKEBOMB_Allies_Gold_.*" );

		sleep(4);

		if ( !Map.Gold_2_Taken )
		{
			SetAvailableMapGoals( TEAM.ALLIES, false, {
				"CAMP_Allies_Gold_.*",
				"ATTACK_Allies_CappointPlace_.*",
			});

			SetAvailableMapGoals( TEAM.ALLIES, true, "FLAG_axis_gold2" );
		}

		Util.MapDebugPrint( "Gold_1_Secured" );
	},

	Gold_2_Dropped = function()
	{
		SetAvailableMapGoals( TEAM.ALLIES, false, "CAPPOINT_Truck" );

		Util.MapDebugPrint( "Gold_2_Dropped" );
	},

	Gold_2_Returned = function()
	{
		Map.Gold_2_Taken = false;

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

		SetAvailableMapGoals( TEAM.ALLIES, false, ".*_Allies_CappointPlace_.*" );

		SetAvailableMapGoals( TEAM.AXIS, true, ".*_Axis_Gold_.*" );

		SetAvailableMapGoals( TEAM.ALLIES, true, "SMOKEBOMB_Allies_Gold_.*" );

		Util.MapDebugPrint( "Gold_2_Returned" );
	},

	Gold_2_Secured = function()
	{
		Map.Gold_2_Taken = false;
		Map.Gold2_Secured = true;

		Util.DisableGoal( "FLAG_axis_gold2" );
		Util.DisableGoal( "CAPPOINT_Truck" );

		ETUtil.WinningChat( TEAM.ALLIES );
		ETUtil.LosingChat( TEAM.AXIS );

		Util.MapDebugPrint( "Gold_2_Secured" );
	},

	Secret_Docs_Taken = function()
	{
		Map.SecretDocsTaken = true;

		Util.CappointForFlag( "FLAG_secretdocs", "CAPPOINT_Radio" );

		SetAvailableMapGoals( TEAM.ALLIES, false, "FLAG_secretdocs" );

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

		Util.MapDebugPrint( "Secret_Docs_Taken" );
	},

	Secret_Docs_Dropped = function()
	{
		Util.SetGoalRange("FLAGRETURN_secretdocs_dropped", 800);

		SetGoalRole( "FLAGRETURN_secretdocs_dropped", { ROLE.DEFENDER, ROLE.DEFENDER2 } );
		SetGoalRole( "FLAG_secretdocs_dropped", { ROLE.ATTACKER, ROLE.ATTACKER1, ROLE.ATTACKER2 } );

		SetAvailableMapGoals( TEAM.ALLIES, false, "CAPPOINT_Radio" );

		Util.MapDebugPrint( "Secret_Docs_Dropped" );
	},

	Secret_Docs_Returned = function()
	{
		Map.SecretDocsTaken = false;

		SetAvailableMapGoals( TEAM.ALLIES, false, "CAPPOINT_Radio" );

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

		Util.MapDebugPrint( "Secret_Docs_Returned" );
	},

	Secret_Docs_Secured = function()
	{
		Map.SecretDocsTaken = false;
		Map.SecretDocsSecured = true;
		Map.Forward_Flag_Axis = false;
		Map.Forward_Flag_Allied = true;

		Util.DisableGoal( "FLAG_secretdocs" );
		Util.DisableGoal( "CAPPOINT_Radio" );

		ClearGoalRole( "BUILD_Fence", ROLE.DEFENDER3 );
		ClearGoalRole( "DEFEND_Axis_Generator_.*", ROLE.DEFENDER3 );

		Util.DisableGoal( {
			"HEALTHCAB_cabinet_health_model",
			"AMMOCAB_cabinet_ammo_model",
			"CHECKPOINT_forward_flag",
			"MOUNTMG42_Forward_Spawn",
			"REPAIRMG42_Forward_Spawn",
		});

		Util.EnableGoal( {
			"BUILD_Neutral_Command_Post",
			"PLANT_Neutral_Command_Post",
		});

		SetAvailableMapGoals( TEAM.AXIS, false, {
			"BUILD_Ramp",
			".*_Axis_ForwardFlag_GroundFloor_.*",
			"DEFEND_Axis_ForwardFlag_FirstFloor_.*",
			"DEFEND_Axis_CappointRadio_.*",
			"DEFEND_Axis_SideGate_.*",
			".*_Axis_ForwardFlag_.*",
		});

		if ( Map.Ramp_Dyno > 1 )
		{
			SetAvailableMapGoals( TEAM.AXIS, false, "DEFUSE_Ramp_.*" );
		}

		if ( Map.Side_Gate_Dyno > 1 )
		{
			SetAvailableMapGoals( TEAM.AXIS, false, "DEFUSE_side_gate_.*" );
		}

		if ( !Map.Fence )
		{
			SetAvailableMapGoals( TEAM.AXIS, true, "BUILD_Fence" );
		}

		SetAvailableMapGoals( TEAM.AXIS, true, "DEFEND_Axis_Gold_.*" );

		if ( Map.Generator )
		{
			SetAvailableMapGoals( TEAM.AXIS, true, ".*_Axis_Generator_.*" );
		}
		else
		{
			SetAvailableMapGoals( TEAM.AXIS, true, ".*_Axis_Gold_.*" );
		}

		sleep(4);

		ClearGoalRole( "ATTACK_Allies_Generator_.*", ROLE.ATTACKER3 );

		SetAvailableMapGoals( TEAM.ALLIES, false, {
			"PLANT_Ramp",
			"FLAG_secretdocs",
			"ATTACK_Allies_SideGate_.*",
			".*_Allies_ForwardFlag_.*",
		});

		if ( Map.Fence )
		{
			SetAvailableMapGoals( TEAM.ALLIES, true, "PLANT_Fence" );
		}

		if ( Map.Generator )
		{
			SetAvailableMapGoals( TEAM.ALLIES, true, {
				"PLANT_Generator",
				".*_Allies_Generator_.*",
			});
		}

		if ( Map.Side_Gate )
		{
			SetAvailableMapGoals( TEAM.ALLIES, false, "PLANT_side_gate" );
		}

		Util.MapDebugPrint( "Secret_Docs_Secured" );
	},

	Forward_Flag_Axis_Captured = function()
	{
		Map.Forward_Flag_Axis = true;
		Map.Forward_Flag_Allied = false;

		ClearGoalRole( "CHECKPOINT_forward_flag", { ROLE.DEFENDER, ROLE.DEFENDER1 } );

		SetGoalRole( "CHECKPOINT_forward_flag", { ROLE.ATTACKER, ROLE.ATTACKER1, ROLE.ATTACKER2 } );

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

		SetAvailableMapGoals( TEAM.ALLIES, false, "CAMP_Allies_ForwardFlag_.*" );

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

		Util.MapDebugPrint( "Forward_Flag_Axis_Captured" );
	},

	Forward_Flag_Allies_Captured = function()
	{
		Map.Forward_Flag_Axis = false;
		Map.Forward_Flag_Allied = true;

		ClearGoalRole( "CHECKPOINT_forward_flag", { ROLE.ATTACKER, ROLE.ATTACKER1, ROLE.ATTACKER2 } );

		SetGoalRole( "CHECKPOINT_forward_flag", { ROLE.DEFENDER, ROLE.DEFENDER1 } );

		SetAvailableMapGoals( TEAM.ALLIES, false, "CHECKPOINT_forward_flag" );

		SetAvailableMapGoals( TEAM.ALLIES, true, "CAMP_Allies_ForwardFlag_.*" );

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

		Util.MapDebugPrint( "Forward_Flag_Allies_Captured" );
	},

	SetSpawn = function()
	{
		foreach(bot in BotTable)
		{
			Map.SetSpawn1(bot);
		}
	},

	SetSpawn1 = function(bot)
	{
		if (bot.GetTeam() == TEAM.ALLIES)
		{
			if ( Map.Allied_CP )
			{
				bot.ChangeSpawnPoint(4);
			}
			else
			{
				bot.ChangeSpawnPoint(0);
			}
		}
	},
};

global OnMapLoad = function()
{
	OnTrigger( "Axis Team have built the Fence!", Map.Fence_Built );
	OnTrigger( "Axis Team have built the Ramp!", Map.Ramp_Built );
	OnTrigger( "Allied Command Post constructed. Charge speed increased!", Map.Allied_CP_Built );
	OnTrigger( "Axis Command Post constructed. Charge speed increased!", Map.Axis_CP_Built );

	OnTrigger( "Allied have destroyed the Fence!", Map.Fence_Destroyed );
	OnTrigger( "The Allies have destroyed the generator, the vault doors are opening!", Map.Generator_Destroyed );
	OnTrigger( "Allied have destroyed the Ramp!", Map.Ramp_Destroyed );
	OnTrigger( "The Allies have destroyed the side entrance!", Map.Side_Gate_Destroyed );
	OnTrigger( "Axis team has destroyed the Allied Command Post!", Map.Allied_CP_Destroyed );
	OnTrigger( "Allied team has destroyed the Axis Command Post!", Map.Axis_CP_Destroyed );

	OnTrigger( "Allies have stolen the Gold!", Map.Gold_Taken );
	OnTrigger( "Allies have stolen the secret docs!", Map.Secret_Docs_Taken );

	OnTrigger( "Flag dropped secretdocs!", Map.Secret_Docs_Dropped );
	OnTrigger( "Flag dropped axis_gold1!", Map.Gold_1_Dropped );
	OnTrigger( "Flag dropped axis_gold2!", Map.Gold_2_Dropped );

	OnTrigger( "goldrush_axis_gold1_returned", Map.Gold_1_Returned );
	OnTrigger( "goldrush_axis_gold2_returned", Map.Gold_2_Returned );
	OnTrigger( "Flag returned secretdocs!", Map.Secret_Docs_Returned );

	OnTrigger( "goldrush_axis_gold1_secured", Map.Gold_1_Secured );
	OnTrigger( "goldrush_axis_gold2_secured", Map.Gold_2_Secured );
	OnTrigger( "The Allies have transmitted the docs. The main gate is opening!!", Map.Secret_Docs_Secured );

	OnTrigger( "Axis have captured the Forward Flag!", Map.Forward_Flag_Axis_Captured );
	OnTrigger( "Allies have captured the Forward Flag!", Map.Forward_Flag_Allies_Captured );

	OnTrigger( "Planted at the side gate.", Map.Side_Gate_Planted );
	OnTrigger( "Planted at side gate.", Map.Side_Gate_Planted );	//Nitmod
	OnTrigger( "Defused at the side gate.", Map.Side_Gate_Defused );
	OnTrigger( "Defused at side gate.", Map.Side_Gate_Defused );	//Nitmod
	OnTrigger( "Planted at The Generator.", Map.Generator_Planted );
	OnTrigger( "Defused at The Generator.", Map.Generator_Defused );
	OnTrigger( "Planted at the Neutral Command Post.", Map.CP_Planted );
	OnTrigger( "Planted at Neutral Command Post.", Map.CP_Planted );	//Nitmod
	OnTrigger( "Defused at the Neutral Command Post.", Map.CP_Defused );
	OnTrigger( "Defused at Neutral Command Post.", Map.CP_Defused );	//Nitmod
	OnTrigger( "Planted at The Ramp.", Map.Ramp_Planted );
	OnTrigger( "Defused at The Ramp.", Map.Ramp_Defused );
	OnTrigger( "Planted at The Fence.", Map.Fence_Planted );
	OnTrigger( "Defused at The Fence.", Map.Fence_Defused );

	RegionTrigger.Create(AABB(-792.875,-664.875,65.125,920.875,653.875,542.465), "DisableCombatMovement", "Ruined_House");
	RegionTrigger.Create(AABB(-171.964,2287.148,264.125,-31.199,2948.924,338.133), "DisableCombatMovement", "Platform_1");
	RegionTrigger.Create(AABB(-173.857,2924.638,264.125,595.861,3099.466,339.128), "DisableCombatMovement", "Platform_2");
	RegionTrigger.Create(AABB(447.501,3060.257,264.125,595.830,3773.867,338.131), "DisableCombatMovement", "Platform_3");
	RegionTrigger.Create(AABB(856.076,-374.322,287.090,920.875,-318.041,363.316), "DisableBotPush", "Ruined_House_Wall");
	RegionTrigger.Create(AABB(-129.189,-536.875,285.125,-71.003,-467.916,359.125), "DisableBotPush", "Ruined_House_WoodenBridge");
	RegionTrigger.Create(AABB(160.449,406.877,285.344,222.488,484.274,359.344), "DisableBotPush", "Ruined_House_Floor1");
	RegionTrigger.Create(AABB(-137.341,-397.849,285.125,-70.613,-328.096,359.125), "DisableBotPush", "Ruined_House_Floor2");
	RegionTrigger.Create(AABB(-852.812,405.125,469.125,-784.433,476.875,519.125), "DisableBotPush", "Ruined_House_Window1");
	RegionTrigger.Create(AABB(3239.262,3146.556,-80.875,3336.579,3202.875,-6.875), "DisableBotPush", "Cappoint_Place_1");
	RegionTrigger.Create(AABB(1912.158,2592.968,-31.875,1968.772,2872.875,42.125), "DisableBotPush", "Cappoint_Place_2");
	RegionTrigger.Create(AABB(511.957,2931.620,0.125,567.875,2999.047,54.139), "DisableBotPush", "Ladder_to_Gold");
	RegionTrigger.Create(AABB(484.143,2894.495,265.125,595.873,2932.756,339.125), "DisableBotPush", "Ladder_to_Gold_1");

	Util.SetGoalPosition(-847.340, 2206.805, 127.125, "BUILD_Neutral_Command_Post");

	Util.DisableGoal( ".*", true );

	Util.EnableGoal( {
		"HEALTHCAB_cabinet_health_model",
		"AMMOCAB_cabinet_ammo_model",
	});
	//Util.EnableGoal( "MOUNTMG42_Forward_Spawn" );	//not important <=> suicide :o)
	//Util.EnableGoal( "REPAIRMG42_Forward_Spawn" );	//not important <=> suicide :o)

	SetAvailableMapGoals( TEAM.AXIS, true, {
		"BUILD_Ramp",
		".*_Axis_ForwardFlag_GroundFloor_.*",
		"DEFEND_Axis_ForwardFlag_FirstFloor_.*",
		"DEFEND_Axis_CappointRadio_.*",
		"DEFEND_Axis_SideGate_.*",
		".*_Axis_ForwardFlag_.*",
	});

	SetAvailableMapGoals( TEAM.ALLIES, true, {
		"FLAG_secretdocs",
		"PLANT_side_gate",
		"CHECKPOINT_forward_flag",
		"ATTACK_Allies_SideGate_.*",
		".*_Allies_ForwardFlag_.*",
	});

	SetGoalRole( "DEFEND_Axis_ForwardFlag_GroundFloor_.*", ROLE.DEFENDER );
	SetGoalRole( "DEFEND_Axis_ForwardFlag_FirstFloor_.*", ROLE.DEFENDER1 );
	SetGoalRole( "DEFEND_Axis_CappointRadio_.*", ROLE.DEFENDER2 );
	SetGoalRole( "DEFEND_Axis_SideGate_.*", ROLE.DEFENDER3 );
	SetGoalRole( "DEFEND_Axis_CappointPlace_.*", { ROLE.DEFENDER2, ROLE.DEFENDER3 } );
	SetGoalRole( "BUILD_Fence", ROLE.DEFENDER3 );
	SetGoalRole( "MOUNTMG42_Forward_Spawn", { ROLE.DEFENDER, ROLE.DEFENDER1 } );
	SetGoalRole( "REPAIRMG42_Forward_Spawn", { ROLE.DEFENDER, ROLE.DEFENDER1 } );

	SetGoalRole( "DEFEND_Axis_Generator_.*", ROLE.DEFENDER3 );
	SetGoalRole( "DEFEND_Axis_Gold_.*", ROLE.DEFENDER3 );
	SetGoalRole( "ATTACK_Allies_Generator_.*", ROLE.ATTACKER3 );

	SetGoalRole( "ATTACK_Allies_SideGate_.*", ROLE.ATTACKER3 );
	SetGoalRole( "ATTACK_Allies_CappointPlace_.*", { ROLE.ATTACKER2, ROLE.ATTACKER3 } );
	SetGoalRole( "CHECKPOINT_forward_flag", { ROLE.ATTACKER, ROLE.ATTACKER1, ROLE.ATTACKER2 } );
	SetGoalRole( "FLAG_secretdocs", { ROLE.ATTACKER, ROLE.ATTACKER1, ROLE.ATTACKER2 } );

	SetGoalPriority( "PLANT_Generator", 0.82, TEAM.ALLIES, CLASS.ENGINEER );
	SetGoalPriority( "ATTACK_Allies_CappointPlace_.*", 0.55, TEAM.ALLIES, 0 );
	SetGoalPriority( "SMOKEBOMB_Allies_.*", 0.82, TEAM.ALLIES, CLASS.COVERTOPS );
	SetGoalPriority( "PLANT_Fence", 0.8, TEAM.ALLIES, CLASS.COVERTOPS );

	SetGoalPriority( "DEFEND_Axis_Generator_.*", 0.52, TEAM.AXIS, 0 );
	SetGoalPriority( "DEFEND_Axis_CappointRadio_.*", 0.85, TEAM.AXIS, 0 );
	SetGoalPriority( "DEFEND_Axis_CappointPlace_.*", 0.55, TEAM.AXIS, 0 );
	SetGoalPriority( "AIRSTRIKE_Axis_ForwardFlag_.*", 0.81, TEAM.AXIS, CLASS.FIELDOPS );

	Util.SetMaxUsers( 1, "DEFEND_.*" );
	Util.SetMaxUsers( 1, "MOUNTMG42_.*" );
	Util.SetMaxUsers( 1, "BUILD_Ramp" );
	Util.SetMaxUsers( 1, "BUILD_Neutral_Command_Post" );
	Util.SetMaxUsers( 1, "PLANT_Neutral_Command_Post" );
	Util.SetMaxUsers( 1, "BUILD_Fence" );
	Util.SetMaxUsers( 1, "PLANT_Fence" );
	Util.SetMaxUsers( 2, "FLAG_secretdocs" );

	Util.AddUseWp( "BUILD_Ramp", "Ramp_1" );
	Util.AddUseWp( "BUILD_Fence", "Fence_1" );
	Util.AddUseWp( "PLANT_Fence", "Fence_2" );
	Util.AddUseWp( "PLANT_Fence", "Fence_3" );
	Util.AddUseWp( "PLANT_Generator", "Generator_1" );

	Wp.SetWaypointFlag( "Ramp_2", "closed", true );

	WeaponTable.SetWeaponAvailability( CLASS.SOLDIER, WEAPON.FLAMETHROWER, false );
	WeaponTable.SetWeaponAvailability( CLASS.SOLDIER, WEAPON.MORTAR, false );

	WeaponTable.SetWeaponTeamAvailability ( TEAM.ALLIES, CLASS.SOLDIER, WEAPON.MOBILE_MG42, false );

	print( "^3Omni-bot map script ^3by ^1Q^2i^3k^4i ^3and ^1n^2a^4t^8i^3v^5e12^3 for map: ^7" + GetMapName() );

	Util.BotChat( 0, "say", "^3Omni-bot map script ^3by ^1Q^2i^3k^4i ^3and ^1n^2a^4t^8i^3v^5e12 ^3for ^3map ^7decay_b3", 1 );

	sleep(5);

	SetGoalPriority( "AIRSTRIKE_Axis_ForwardFlag_.*", 0.80, TEAM.AXIS, CLASS.FIELDOPS );	//return to default value
};

global OnBotJoin = function( bot )
{
	bot.TargetBreakableDist = 80.0;
};

global InitializeRoutes = function()
{
	MapRoutes =
	{
		CAPPOINT_Radio =
		{
			ROUTE_FlagDocsPlace =
			{
				ROUTE_CappointRadio_R_1 =
				{
					ROUTE_CappointRadio_R_2 =
					{
						ROUTE_CappointRadio_R_3 =
						{
							ROUTE_CappointRadio_R_4 =
							{
								ROUTE_CappointRadio_R_5 = {},
							},
						},
					},
				},
				ROUTE_CappointRadio_D_1 =
				{
					ROUTE_CappointRadio_D_2 =
					{
						ROUTE_CappointRadio_D_3 =
						{
							ROUTE_CappointRadio_D_4 = {},
						},
					},
				},
				ROUTE_CappointRadio_L_1 =
				{
					ROUTE_CappointRadio_L_2 =
					{
						ROUTE_CappointRadio_L_3 =
						{
							ROUTE_CappointRadio_L_4 =
							{
								ROUTE_CappointRadio_L_5 = {},
							},
						},
					},
				},
			},
		},
		PLANT_Generator =
		{
			ROUTE_Upper_Spawn =
			{
				ROUTE_PlantGenerator_L_1 =
				{
					ROUTE_PlantGenerator_L_2 = {},
				},
				ROUTE_PlantGenerator_R_1 =
				{
					ROUTE_PlantGenerator_R_2 = {},
				},
				ROUTE_PlantGenerator_D_1 =
				{
					ROUTE_PlantGenerator_D_2 = {},
				},
			},
			ROUTE_CP_Spawn =
			{
				ROUTE_PlantGenerator_L_2 = {},
				ROUTE_PlantGenerator_L_1 =
				{
					ROUTE_PlantGenerator_R_1 =
					{
						ROUTE_PlantGenerator_R_2 = {},
					},
				},
				ROUTE_PlantGenerator_LR_1 = {},
			},
		},
		FLAG_axis_gold1 =
		{
			ROUTE_Upper_Spawn =
			{
				ROUTE_PlantGenerator_L_1 =
				{
					ROUTE_PlantGenerator_L_2 = {},
				},
				ROUTE_PlantGenerator_R_1 =
				{
					ROUTE_PlantGenerator_R_2 = {},
				},
				ROUTE_PlantGenerator_D_1 = {},
			},
			ROUTE_CP_Spawn =
			{
				ROUTE_PlantGenerator_L_2 = {},
				ROUTE_PlantGenerator_LR_1 =
				{
					ROUTE_FlagGold_1 = {},
				},
			},
		},
		PLANT_side_gate =
		{
			ROUTE_CampSpawn1 =
			{
				ROUTE_CappointRadio_R_1 =
				{
					ROUTE_CappointRadio_R_2 =
					{
						ROUTE_CappointRadio_R_3 =
						{
							ROUTE_CappointRadio_R_4 =
							{
								ROUTE_CappointRadio_R_5 = {},
							},
						},
					},
				},
				ROUTE_CappointRadio_D_1 =
				{
					ROUTE_CappointRadio_D_2 =
					{
						ROUTE_CappointRadio_D_3 =
						{
							ROUTE_CappointRadio_D_4 = {},
						},
					},
				},
				ROUTE_CappointRadio_L_1 =
				{
					ROUTE_CappointRadio_L_2 =
					{
						ROUTE_CappointRadio_L_3 =
						{
							ROUTE_CappointRadio_L_4 =
							{
								ROUTE_PlantSideGate_1 =
								{
									ROUTE_PlantSideGate_2 = {},
								},
							},
						},
					},
				},
			},
			ROUTE_CampSpawn2 =
			{
				ROUTE_CappointRadio_R_1 =
				{
					ROUTE_CappointRadio_R_2 =
					{
						ROUTE_CappointRadio_R_3 =
						{
							ROUTE_CappointRadio_R_4 =
							{
								ROUTE_CappointRadio_R_5 = {},
							},
						},
					},
				},
				ROUTE_CappointRadio_D_1 =
				{
					ROUTE_CappointRadio_D_2 =
					{
						ROUTE_CappointRadio_D_3 =
						{
							ROUTE_CappointRadio_D_4 = {},
						},
					},
				},
				ROUTE_CappointRadio_L_1 =
				{
					ROUTE_CappointRadio_L_2 =
					{
						ROUTE_CappointRadio_L_3 =
						{
							ROUTE_CappointRadio_L_4 =
							{
								ROUTE_PlantSideGate_1 =
								{
									ROUTE_PlantSideGate_2 = {},
								},
							},
						},
					},
				},
			},
		},
		CAPPOINT_Truck =
		{
			ROUTE_FlagGold1Place =
			{
				ROUTE_AroundAxisSpawn_1 =
				{
					ROUTE_AroundAxisSpawn_2 =
					{
						ROUTE_AroundAxisSpawn_3 = {},
					},
				},
				ROUTE_Cappoint_Stairs_1 =
				{
					ROUTE_Cappoint_Stairs_2 =
					{
						ROUTE_Cappoint_Outside_1 = {},
					},
				},
				ROUTE_Cappoint_FenceHall_1 =
				{
					ROUTE_Cappoint_FenceHall_2 =
					{
						ROUTE_Cappoint_Outside_1 = {},
					},
				},
			},
			ROUTE_FlagGold2Place =
			{
				ROUTE_AroundAxisSpawn_1 =
				{
					ROUTE_AroundAxisSpawn_2 =
					{
						ROUTE_AroundAxisSpawn_3 = {},
					},
				},
				ROUTE_Cappoint_Stairs_1 =
				{
					ROUTE_Cappoint_Stairs_2 =
					{
						ROUTE_Cappoint_Outside_1 = {},
					},
				},
				ROUTE_Cappoint_FenceHall_1 =
				{
					ROUTE_Cappoint_FenceHall_2 =
					{
						ROUTE_Cappoint_Outside_1 = {},
					},
				},
			},
			ROUTE_FlagGoldDropped =
			{
				ROUTE_AroundAxisSpawn_1 =
				{
					ROUTE_AroundAxisSpawn_2 =
					{
						ROUTE_AroundAxisSpawn_3 = {},
					},
				},
				ROUTE_Cappoint_Stairs_1 =
				{
					ROUTE_Cappoint_Stairs_2 =
					{
						ROUTE_Cappoint_Outside_1 = {},
					},
				},
				ROUTE_Cappoint_FenceHall_1 =
				{
					ROUTE_Cappoint_FenceHall_2 =
					{
						ROUTE_Cappoint_Outside_1 = {},
					},
				},
			},
		},
	};

	MapRoutes["DEFEND_Axis_Generator_.*"] =
	{
		ROUTE_GarrisonSpawn =
		{
			ROUTE_DefendGenerator_R_1 = {},
			ROUTE_DefendGenerator_L_1 = {},
		},
	};

	MapRoutes["ATTACK_Allies_SideGate_.*"] = MapRoutes.PLANT_side_gate;
	MapRoutes["ATTACK_Allies_Generator_.*"] = MapRoutes.PLANT_Generator;
	MapRoutes.FLAG_axis_gold2 = MapRoutes.FLAG_axis_gold1;

	Util.Routes(MapRoutes);
};
