//==========================================================================================
//
//	decay_b4.gm
//
//	Who      	When		What
//------------------------------------------------------------------------------------------
//	Qiki		28 June 2016	Initial Script and waypoints
//	Native12	13.08.2016	Released for testing
//	Native12	04.04.2017	Adapted for Decay_b4 (from Decay_b3)
//	Native12	06.04.2017	Adapted for Decay_b5
//
//	Bugs and suggestions: PM on http://omni-bot.invisionzone.com/index.php?/index
//==========================================================================================
//

global Map =
{
	Debug = 0,
	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( trigger )
	{
		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( trigger )
	{
		Map.Fence_Dyno += 1;
		
		SetAvailableMapGoals( TEAM.AXIS, false, "DEFUSE_Fence_.*" );
		
		Util.MapDebugPrint( "Fence_Planted" );
	},

	Fence_Defused = function( trigger )
	{
		Map.Fence_Dyno -= 1;
		
		Util.MapDebugPrint( "Fence_Defused" );
	},

	Fence_Destroyed = function( trigger )
	{
		Map.Fence = false;
		
		SetAvailableMapGoals( TEAM.AXIS, false, "DEFUSE_Fence_.*" );
		
		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( trigger )
	{
		Map.Ramp = true;
		
		Wp.SetWaypointFlag( "Ramp_2", "closed", false );
		
		SetAvailableMapGoals( TEAM.AXIS, false, "BUILD_Ramp" );
		
		if ( !Map.SecretDocsSecured and Map.Generator and Map.Side_Gate )
		{
			SetAvailableMapGoals( TEAM.ALLIES, true, "PLANT_Ramp" );
		}
		
		Util.MapDebugPrint( "Ramp_Built" );
	},

	Ramp_Planted = function( trigger )
	{
		Map.Ramp_Dyno += 1; 
		
		SetGoalPriority( "DEFUSE_Ramp_.*", 0.6, TEAM.AXIS, CLASS.ENGINEER );
		Util.SetMaxUsers( 1, "DEFUSE_Ramp_.*" );
		
		if ( Map.SecretDocsSecured or !Map.Generator )
		{
			SetAvailableMapGoals( TEAM.AXIS, false, "DEFUSE_Ramp_.*" );
		}
		
		Util.MapDebugPrint( "Ramp_Planted" );
	},

	Ramp_Defused = function( trigger )
	{
		Map.Ramp_Dyno -= 1;
		
		Util.MapDebugPrint( "Ramp_Defused" );
	},

	Ramp_Destroyed = function( trigger )
	{
		Map.Ramp = false;
		
		Wp.SetWaypointFlag( "Ramp_2", "closed", true );
		
		SetAvailableMapGoals( TEAM.AXIS, false, "DEFUSE_Ramp_.*" );
		
		SetAvailableMapGoals( TEAM.ALLIES, false, "PLANT_Ramp" );
		
		if ( !Map.SecretDocsSecured and Map.Generator )
		{
			SetAvailableMapGoals( TEAM.AXIS, true, "BUILD_Ramp" );
		}
		
		Util.MapDebugPrint( "Ramp_Destroyed" );
	},

	CP_Planted = function( trigger )
	{
		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( trigger )
	{
		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( trigger )
	{
		Map.Allied_CP = true;
		
		Map.SetSpawn();
		
		Util.MapDebugPrint( "Allied_CP_Built" );
	},

	Allied_CP_Destroyed = function( trigger )
	{
		Map.Allied_CP = false;
		
		Map.SetSpawn();
		
		Util.MapDebugPrint( "Allied_CP_Destroyed" );
	},

	Axis_CP_Built = function( trigger )
	{
		Map.Axis_CP = true;
		
		Util.MapDebugPrint( "Axis_CP_Built" );
	},

	Axis_CP_Destroyed = function( trigger )
	{
		Map.Axis_CP = false;
		
		Util.MapDebugPrint( "Axis_CP_Destroyed" );
	},

	Generator_Planted = function( trigger )
	{
		Map.Generator_Dyno += 1;
		
		SetAvailableMapGoals( TEAM.ALLIES, false, "SMOKEBOMB_Allies_Generator_.*" );
		
		Util.MapDebugPrint( "Generator_Planted" );
	},

	Generator_Defused = function( trigger )
	{
		Map.Generator_Dyno -= 1;
		
		if ( Map.Generator_Dyno == 0 )
		{
			SetAvailableMapGoals( TEAM.ALLIES, true, "SMOKEBOMB_Allies_Generator_.*" );
		}
		
		Util.MapDebugPrint( "Generator_Defused" );
	},

	Generator_Destroyed = function( trigger )
	{
		Map.Generator = false;
		
		Map.SetSpawn();
		
		ClearGoalRole( "DEFEND_Axis_Gold_.*", ROLE.DEFENDER3 );
		
		//SetAvailableMapGoals( TEAM.AXIS, false, ".*_Axis_Generator_.*" );
		//SetAvailableMapGoals( TEAM.AXIS, false, "DEFUSE_Generator_.*" );
		
		if ( Map.SecretDocsTaken )
		{
			bot = Map.GetBotWithFlag( "FLAG_secretdocs" );
			
			if (bot)
			{
				bot.ExecCommand( "kill" );
				
				Util.MapDebugPrint( "Bot with Secret Docs killed himself" );
			}
		}
		
		//Util.DisableGoal( ".*", true );
		
		SetAvailableMapGoals( TEAM.AXIS, false, ".*" );
		
		SetAvailableMapGoals( TEAM.AXIS, true, "ROUTE_.*" );
		
		SetAvailableMapGoals( TEAM.AXIS, true, ".*_Axis_Gold_.*" );
		SetAvailableMapGoals( TEAM.AXIS, true, "BUILD_Neutral_Command_Post" );
		SetAvailableMapGoals( TEAM.AXIS, true, "PLANT_Neutral_Command_Post" );
		SetAvailableMapGoals( TEAM.AXIS, true, "HEALTHCAB_.*" );
		SetAvailableMapGoals( TEAM.AXIS, true, "AMMOCAB_.*" );
		
		sleep(3);
		
		//SetAvailableMapGoals( TEAM.ALLIES, false, ".*_Allies_Generator_.*" );
		SetAvailableMapGoals( TEAM.ALLIES, false, ".*" );
		
		SetAvailableMapGoals( TEAM.ALLIES, true, "ROUTE_.*" );
		
		SetAvailableMapGoals( TEAM.ALLIES, true, "BUILD_Neutral_Command_Post" );
		SetAvailableMapGoals( TEAM.ALLIES, true, "PLANT_Neutral_Command_Post" );
		SetAvailableMapGoals( TEAM.ALLIES, true, "HEALTHCAB_.*" );
		SetAvailableMapGoals( TEAM.ALLIES, true, "AMMOCAB_.*" );
		
		/*foreach ( bot in BotTable )
		{
			if ( bot.HasRole(ROLE.AMBUSHER) )
			{
				bot.ExecCommand( "kill" );
				
				Util.MapDebugPrint( "Bot with Secret Docs killed himself" );
			}
		}*/
		
		SetAvailableMapGoals( TEAM.ALLIES, true, ".*_Allies_Gold_.*" );
		SetAvailableMapGoals( TEAM.ALLIES, true, "FLAG_axis_gold1" );
		
		Util.MapDebugPrint( "Generator_Destroyed" );
	},

	Side_Gate_Planted = function( trigger )
	{
		Map.Side_Gate_Dyno += 1;
		
		if ( Map.SecretDocsSecured or !Map.Generator )
		{
			SetAvailableMapGoals( TEAM.AXIS, false, "DEFUSE_side_gate_.*" );
		}
		
		Util.MapDebugPrint( "Side_Gate_Planted" );
	},

	Side_Gate_Defused = function( trigger )
	{
		Map.Side_Gate_Dyno -= 1;
		
		Util.MapDebugPrint( "Side_Gate_Defused" );
	},

	Side_Gate_Destroyed = function( trigger )
	{
		Map.Side_Gate = false;
		
		SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_Axis_SideGate_.*" );
		SetAvailableMapGoals( TEAM.AXIS, false, "DEFUSE_side_gate_.*" );
		
		SetAvailableMapGoals( TEAM.ALLIES, false, "PLANT_side_gate" );
		
		if ( !Map.SecretDocsSecured )
		{
			SetAvailableMapGoals( 0, true, "BUILD_Neutral_Command_Post" );
			SetAvailableMapGoals( 0, true, "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" );
				SetAvailableMapGoals( TEAM.ALLIES, true, "ATTACK_Allies_Generator_.*" );
			}
		}
		
		Util.MapDebugPrint( "Side_Gate_Destroyed" );
	},
	
	//====================================================================================================================
	//Flag and Cappoint settings - to avoid placing Flag goals on wrong Cappoint places (if two cappoint goals are active)
	GetBotWithFlag = function(goal)
	{
		ent = GetGoal(goal).GetEntity();
		owner = GetEntOwner(ent);
		if ( EntityIsValid(owner) && GetEntFlags(owner, ENTFLAG.CARRYINGGOAL) )
		{
			n = 1;
		}
		else
		{
			Util.MapDebugPrint( "GetEntOwner failed for " + goal, 2 );
			n = 0;
			for ( i = 0; i < 64; i += 1 )
			{
				if ( EntityIsValid(i) && GetEntFlags(i, ENTFLAG.CARRYINGGOAL) ){
					owner = i;
					n += 1;
				}
			}
		}
		if (n==1)
		{
			Util.MapDebugPrint( goal + " taken by " + GetEntName(owner), 1 );
			return Util.IsBot(owner);
		}

		// Enable both cappoints
		foreach ( bot in BotTable )
		{
			if ( bot.IsCarryingFlag() ) 
			{
				Util.MapDebugPrint( "Enabled both cappoints for bot " + bot.Name, 1 );
				bot.SetRoles( ROLE.AMBUSHER, ROLE.ROAMER );
			}
		}
		return null;
	},
	
	Gold_Taken = function( trigger )
	{
		if ( !Map.Gold1_Secured )
		{
			Map.Gold_1_Taken = true;
			
			if ( Map.SecretDocsTaken )
			{
				bot = Map.GetBotWithFlag( "FLAG_axis_gold1" );
				SetGoalRole( "CAPPOINT_Truck", ROLE.ROAMER );
				
				if (bot)
				{
					bot.ClearRoles( ROLE.AMBUSHER );
					bot.SetRoles( ROLE.ROAMER );
				}
			}
			
			SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_Axis_Gold_.*" );
			
			SetAvailableMapGoals( TEAM.ALLIES, false, "SMOKEBOMB_Allies_Gold_.*" );
			
			SetAvailableMapGoals( TEAM.AXIS, true, "DEFEND_Axis_CappointPlace_.*" );
			
			SetAvailableMapGoals( TEAM.ALLIES, true, "ATTACK_Allies_CappointPlace_.*" );
			SetAvailableMapGoals( TEAM.ALLIES, true, "CAMP_Allies_Gold_.*" );
			SetAvailableMapGoals( TEAM.ALLIES, true, "CAPPOINT_Truck" );
			
			yield();
			
			SetAvailableMapGoals( TEAM.AXIS, true, "DEFEND_Axis_Gold_.*" );
			
			Util.MapDebugPrint( "Gold_1_Taken" );
		}
		else
		{
			Map.Gold_2_Taken = true;
			
			if ( Map.SecretDocsTaken )
			{
				bot = Map.GetBotWithFlag( "FLAG_axis_gold2" );
				SetGoalRole( "CAPPOINT_Truck", ROLE.ROAMER );
				
				if (bot)
				{
					bot.ClearRoles( ROLE.AMBUSHER );
					bot.SetRoles( ROLE.ROAMER );
				}
			}
			
			SetAvailableMapGoals( TEAM.AXIS, false, ".*_Axis_Gold_.*" );
			SetAvailableMapGoals( TEAM.AXIS, false, "MOBILEMG42_Axis_Gold2_01" );
			
			SetAvailableMapGoals( TEAM.ALLIES, false, "SMOKEBOMB_Allies_Gold_.*" );
			
			SetAvailableMapGoals( TEAM.AXIS, true, ".*_Axis_CappointPlace_.*" );
			
			SetAvailableMapGoals( TEAM.ALLIES, true, ".*_Allies_CappointPlace_.*" );
			SetAvailableMapGoals( TEAM.ALLIES, true, "CAPPOINT_Truck" );
			
			Util.MapDebugPrint( "Gold_2_Taken" );
		}
	},
	
	Gold_1_Dropped = function( trigger )
	{
		foreach ( bot in BotTable )
		{
			if ( bot.HasRole(ROLE.ROAMER) )
			{
				bot.ClearRoles( ROLE.ROAMER );
				
				Util.MapDebugPrint( "Gold_1_Dropped => clear role Roamer" );
			}
		}
		
		SetAvailableMapGoals( TEAM.ALLIES, false, "CAPPOINT_Truck" );
		
		Util.MapDebugPrint( "Gold_1_Dropped" );
	},
	
	Gold_1_Returned = function( trigger )
	{
		Map.Gold_1_Taken = false;
		
		SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_Axis_CappointPlace_.*" );
		
		SetAvailableMapGoals( TEAM.ALLIES, false, "ATTACK_Allies_CappointPlace_.*" );
		SetAvailableMapGoals( TEAM.ALLIES, false, "CAMP_Allies_Gold_.*" );
		
		SetAvailableMapGoals( TEAM.ALLIES, true, "SMOKEBOMB_Allies_Gold_.*" );
		
		Util.MapDebugPrint( "Gold_1_Returned" );
	},

	Gold_1_Secured = function( trigger )
	{
		Map.Gold_1_Taken = false;
		Map.Gold1_Secured = true;
		
		Util.DisableGoal( "FLAG_axis_gold1" );
		
		foreach ( bot in BotTable )
		{
			if ( bot.HasRole(ROLE.ROAMER) )
			{
				bot.ClearRoles( ROLE.ROAMER );
				
				Util.MapDebugPrint( "Gold_1_Secured => clear role Roamer" );
			}
		}
		
		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.AXIS, true, "MOBILEMG42_Axis_Gold2_01" );
		
		SetAvailableMapGoals( TEAM.ALLIES, false, "CAPPOINT_Truck" );
		
		SetAvailableMapGoals( TEAM.ALLIES, true, "SMOKEBOMB_Allies_Gold_.*" );
		
		sleep(4);
		
		SetAvailableMapGoals( TEAM.ALLIES, false, "CAMP_Allies_Gold_.*" );
		SetAvailableMapGoals( TEAM.ALLIES, false, "ATTACK_Allies_CappointPlace_.*" );
		
		SetAvailableMapGoals( TEAM.ALLIES, true, "FLAG_axis_gold2" );
		
		Util.MapDebugPrint( "Gold_1_Secured" );
	},

	Gold_2_Dropped = function( trigger )
	{
		foreach ( bot in BotTable )
		{
			if ( bot.HasRole(ROLE.ROAMER) )
			{
				bot.ClearRoles( ROLE.ROAMER );
				
				Util.MapDebugPrint( "Gold_2_Dropped => clear role Roamer" );
			}
		}
		
		SetAvailableMapGoals( TEAM.ALLIES, false, "CAPPOINT_Truck" );
		
		Util.MapDebugPrint( "Gold_2_Dropped" );
	},
	
	Gold_2_Returned = function( trigger )
	{
		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.AXIS, true, "MOBILEMG42_Axis_Gold2_01" );
		
		SetAvailableMapGoals( TEAM.ALLIES, true, "SMOKEBOMB_Allies_Gold_.*" );
		
		Util.MapDebugPrint( "Gold_2_Returned" );
	},

	Gold_2_Secured = function( trigger )
	{
		Map.Gold_2_Taken = false;
		Map.Gold2_Secured = true;
		
		foreach ( bot in BotTable )
		{
			if ( bot.HasRole(ROLE.ROAMER) )
			{
				bot.ClearRoles( ROLE.ROAMER );
				
				Util.MapDebugPrint( "Gold_2_Secured => clear role Roamer" );
			}
		}
		
		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( trigger )
	{
		Map.SecretDocsTaken = true;
		
		if ( Map.Gold_1_Taken or Map.Gold_2_Taken )
		{
			bot = Map.GetBotWithFlag( "FLAG_secretdocs" );
			SetGoalRole( "CAPPOINT_Radio", ROLE.AMBUSHER );
			
			if (bot)
			{
				bot.ClearRoles( ROLE.ROAMER );
				bot.SetRoles( ROLE.AMBUSHER );
			}
		}
		
		SetAvailableMapGoals( TEAM.ALLIES, false, "FLAG_secretdocs" );
		
		SetAvailableMapGoals( TEAM.ALLIES, true, "CAPPOINT_Radio" );
		
		Util.MapDebugPrint( "Secret_Docs_Taken" );
	},
	
	Secret_Docs_Dropped = function( trigger )
	{
		Util.SetGoalRange("FLAGRETURN_secretdocs_dropped", 800);
		
		foreach ( bot in BotTable )
		{
			if ( bot.HasRole(ROLE.AMBUSHER) )
			{
				bot.ClearRoles( ROLE.AMBUSHER );
				
				Util.MapDebugPrint( "Secret_Docs_Dropped => clear role Ambusher" );
			}
		}
		
		if ( !Map.Generator )
		{
			SetAvailableMapGoals( 0, false, ".*_secretdocs_dropped" );
		}
		else
		{
			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( trigger )
	{
		Map.SecretDocsTaken = false;
		
		SetAvailableMapGoals( TEAM.ALLIES, false, "CAPPOINT_Radio" );
		
		if ( Map.Generator )
		{
			SetAvailableMapGoals( TEAM.ALLIES, true, "FLAG_secretdocs" );
		}
		
		Util.MapDebugPrint( "Secret_Docs_Returned" );
	},

	Secret_Docs_Secured = function( trigger )
	{
		Map.SecretDocsTaken = false;
		Map.SecretDocsSecured = true;
		Map.Forward_Flag_Axis = false;
		Map.Forward_Flag_Allied = true;
		
		Map.SetSpawn();
		
		Util.DisableGoal( "FLAG_secretdocs" );
		Util.DisableGoal( "CAPPOINT_Radio" );
		
		foreach ( id and bot in BotTable )
		{
			if ( bot.GetTeam() == TEAM.ALLIES )
			{
				if ( Map.Generator )
				{
					bot.ChangeSpawnPoint(1);
				}
				else
				{
					bot.ChangeSpawnPoint(0);
				}
			}
		}
		
		//End of Flag and Cappoint settings
		//====================================================================================================================
		
		foreach ( bot in BotTable )
		{
			if ( bot.HasRole(ROLE.AMBUSHER) )
			{
				bot.ClearRoles( ROLE.AMBUSHER );
				
				Util.MapDebugPrint( "Secret_Docs_Secured => clear role Ambusher" );
			}
		}
		
		ClearGoalRole( "BUILD_Fence", ROLE.DEFENDER3 );
		ClearGoalRole( "DEFEND_Axis_Generator_.*", ROLE.DEFENDER3 );
		
		SetAvailableMapGoals( 0, false, "HEALTHCAB_cabinet_health_model" );
		SetAvailableMapGoals( 0, false, "AMMOCAB_cabinet_ammo_model" );
		SetAvailableMapGoals( 0, false, "CHECKPOINT_forward_flag" );
		SetAvailableMapGoals( 0, false, "MOUNTMG42_Forward_Spawn" );
		SetAvailableMapGoals( 0, false, "REPAIRMG42_Forward_Spawn" );
		
		SetAvailableMapGoals( 0, true, "BUILD_Neutral_Command_Post" );
		SetAvailableMapGoals( 0, true, "PLANT_Neutral_Command_Post" );
		
		SetAvailableMapGoals( TEAM.AXIS, false, "BUILD_Ramp" );
		SetAvailableMapGoals( TEAM.AXIS, false, ".*_Axis_ForwardFlag_GroundFloor_.*" );
		SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_Axis_ForwardFlag_FirstFloor_.*" );
		SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_Axis_CappointRadio_.*" );
		SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_Axis_SideGate_.*" );
		SetAvailableMapGoals( TEAM.AXIS, false, ".*_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" );
		SetAvailableMapGoals( TEAM.ALLIES, false, "FLAG_secretdocs" );
		SetAvailableMapGoals( TEAM.ALLIES, false, "ATTACK_Allies_SideGate_.*" );
		SetAvailableMapGoals( TEAM.ALLIES, false, ".*_Allies_ForwardFlag_.*" );
		
		if ( Map.Fence )
		{
			SetAvailableMapGoals( TEAM.ALLIES, true, "PLANT_Fence" );
		}
		
		if ( Map.Generator )
		{
			SetAvailableMapGoals( TEAM.ALLIES, true, "PLANT_Generator" );
			SetAvailableMapGoals( TEAM.ALLIES, true, ".*_Allies_Generator_.*" );
		}
		
		if ( Map.Side_Gate )
		{
			SetAvailableMapGoals( TEAM.ALLIES, false, "PLANT_side_gate" );
		}
		
		Util.MapDebugPrint( "Secret_Docs_Secured" );
	},
	
	Forward_Flag_Axis_Captured = function( trigger )
	{
		Map.Forward_Flag_Axis = true;
		Map.Forward_Flag_Allied = false;
		
		Map.SetSpawn();
		
		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( trigger )
	{
		Map.Forward_Flag_Axis = false;
		Map.Forward_Flag_Allied = true;
		
		Map.SetSpawn();
		
		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.Generator )
			{
				bot.ChangeSpawnPoint(5);
				
				Util.MapDebugPrint( "Allied spawn in Allied room" );
			}
			else
			{
				if ( Map.Allied_CP )
				{
					bot.ChangeSpawnPoint(3);
					
					Util.MapDebugPrint( "Allied spawn near Side Entrance" );
				}
				else
				{
					if ( Map.SecretDocsSecured or Map.Forward_Flag_Allied )
					{
						bot.ChangeSpawnPoint(1);
						
						Util.MapDebugPrint( "Allied spawn at Main gate" );
					}
					else
					{
						bot.ChangeSpawnPoint(4);
						
						Util.MapDebugPrint( "Allied spawn at Allied camp" );
					}
				}
			}
		}
		else
		{
			if ( !Map.Generator )
			{
				bot.ChangeSpawnPoint(2);
				
				Util.MapDebugPrint( "Axis spawn in Garrison" );
			}
		}
	},
};
/*
Commands["botsgoals"] = function(_params)	//only for testing roles (thx. Palota) => called at the end of OnMapLoad 
{
	foreach (team in TEAM)
	{
		foreach (class in Util.PlayerClassTable)
		{
			foreach ( bot in BotTable )
			{
				if(bot.GetClass()==class && bot.GetTeam()==team)
				{
					s="";
					foreach ( id and role in ROLE )
					{
						if(bot.HasRole(role))
						{
							s= s + " " + id;
						}
					}
					goal=bot.GetMapGoalName();
					if(!goal)
					{
						goal=bot.GetHighLevelGoalName();
					}
					if(!goal)
					{
						goal = "";
					}
					print(Util.TeamName(team) + " " + Util.ClassName(class) + s + ": " + goal);
				}
			}
		}
	}
};*/

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 Access Codes!", 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 Access codes. 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(1725.471,-95.186,1.125,1896.498,335.944,79.132), "DisableCombatMovement", "Wall");
	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(2221.125,2889.125,-111.875,2626.665,3194.875,330.290), "DisableCombatMovement", "Stairs");
	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 );
	
	foreach ( id and bot in BotTable )
	{
		if ( bot.GetTeam() == TEAM.ALLIES )
		{
			bot.ChangeSpawnPoint(4);
		}
	}
	
	SetAvailableMapGoals( 0, true, "HEALTHCAB_cabinet_health_model" );
	SetAvailableMapGoals( 0, true, "AMMOCAB_cabinet_ammo_model" );
	//SetAvailableMapGoals( 0, true, "MOUNTMG42_Forward_Spawn" );	//not important <=> suicide :o)
	//SetAvailableMapGoals( 0, true, "REPAIRMG42_Forward_Spawn" );	//not important <=> suicide :o)
	
	SetAvailableMapGoals( TEAM.AXIS, true, "BUILD_Ramp" );
	SetAvailableMapGoals( TEAM.AXIS, true, ".*_Axis_ForwardFlag_GroundFloor_.*" );
	SetAvailableMapGoals( TEAM.AXIS, true, "DEFEND_Axis_ForwardFlag_FirstFloor_.*" );
	SetAvailableMapGoals( TEAM.AXIS, true, "DEFEND_Axis_CappointRadio_.*" );
	SetAvailableMapGoals( TEAM.AXIS, true, "DEFEND_Axis_SideGate_.*" );
	SetAvailableMapGoals( TEAM.AXIS, true, ".*_Axis_ForwardFlag_.*" );
	
	SetAvailableMapGoals( TEAM.ALLIES, true, "FLAG_secretdocs" );
	SetAvailableMapGoals( TEAM.ALLIES, true, "PLANT_side_gate" );
	SetAvailableMapGoals( TEAM.ALLIES, true, "CHECKPOINT_forward_flag" );
	SetAvailableMapGoals( TEAM.ALLIES, true, "ATTACK_Allies_SideGate_.*" );
	SetAvailableMapGoals( TEAM.ALLIES, true, ".*_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( "CAPPOINT_Radio", ROLE.AMBUSHER );
	//SetGoalRole( "CAPPOINT_Truck", ROLE.ROAMER );
	
	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_Ramp", 0.5, TEAM.ALLIES, CLASS.ENGINEER );
	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( "PLANT_Neutral_Command_Post", 0.83, 0, 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( "DEFEND_Axis_CappointPlace_02", 0.56, TEAM.AXIS, 0 );
	SetGoalPriority( "DEFEND_Axis_CappointPlace_03", 0.56, TEAM.AXIS, 0 );
	SetGoalPriority( "DEFEND_Axis_CappointPlace_04", 0.56, TEAM.AXIS, 0 );
	SetGoalPriority( "DEFEND_Axis_CappointPlace_05", 0.56, TEAM.AXIS, 0 );
	SetGoalPriority( "DEFEND_Axis_CappointPlace_06", 0.56, TEAM.AXIS, 0 );
	SetGoalPriority( "DEFEND_Axis_CappointPlace_09", 0.56, TEAM.AXIS, 0 );
	SetGoalPriority( "AIRSTRIKE_Axis_ForwardFlag_.*", 0.81, TEAM.AXIS, CLASS.FIELDOPS );

	Util.SetMaxUsers( 1, "DEFEND_.*" );
	Util.SetMaxUsers( 1, "MOUNTMG42_.*" );
	Util.SetMaxUsers( 1, "REPAIRMG42_.*" );
	Util.SetMaxUsers( 1, "AIRSTRIKE_.*" );
	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" );
	Util.AddUseWp( "PLANT_Neutral_Command_Post", "Plant_CP_WP" );
	Util.AddUseWp( "CHECKPOINT_forward_flag", "Flag_1" );
	Util.AddUseWp( "CHECKPOINT_forward_flag", "Flag_2" );
	Util.AddUseWp( "CHECKPOINT_forward_flag", "Flag_3" );
	Util.AddUseWp( "CHECKPOINT_forward_flag", "Flag_4" );
	Util.AddUseWp( "AMMOCAB_cabinet_ammo_model", "Ammo" );
	Util.AddUseWp( "HEALTHCAB_cabinet_health_model", "Health" );
	
	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_b5", 1 );
	
	sleep(5);
	
	SetGoalPriority( "AIRSTRIKE_Axis_ForwardFlag_.*", 0.80, TEAM.AXIS, CLASS.FIELDOPS );	//return to default value
	
	/*while (1)	//for testing roles
	{
		foreach ( id and bot in BotTable )
		{
			print( "^3=========================Test Roles & Goals=========================" );
			Commands["botsgoals"](_params);
			print( "^3============================End of Test=============================" );
			sleep(5);
		}
		yield();
		yield();
	}*/
};

global OnBotJoin = function( bot )
{
	bot.TargetBreakableDist = 80.0;
	
	if (bot.GetTeam() == TEAM.ALLIES)
	{
		if ( !Map.Generator )
		{
			bot.ChangeSpawnPoint(5);
			
			Util.MapDebugPrint( "Allied spawn in Allied room" );
		}
		else
		{
			if ( Map.Allied_CP )
			{
				bot.ChangeSpawnPoint(3);
				
				Util.MapDebugPrint( "Allied spawn near Side Entrance" );
			}
			else
			{
				if ( Map.SecretDocsSecured or Map.Forward_Flag_Allied )
				{
					bot.ChangeSpawnPoint(1);
					
					Util.MapDebugPrint( "Allied spawn at Main gate" );
				}
				else
				{
					bot.ChangeSpawnPoint(4);
					
					Util.MapDebugPrint( "Allied spawn at Allied camp" );
				}
			}
		}
	}
	else
	{
		if ( !Map.Generator )
		{
			bot.ChangeSpawnPoint(2);
			
			Util.MapDebugPrint( "Axis spawn in Garrison" );
		}
	}
};

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 = {},
							},
						},
					},
				},
			},
		},
		BUILD_Ramp =
		{
		},
		PLANT_Ramp =
		{
		},
		CHECKPOINT_forward_flag =
		{
		},
		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_Locked_door = {},
					},
				},
				ROUTE_PlantGenerator_R_1 =
				{
					ROUTE_AroundAxisSpawn_3 =
					{
						ROUTE_AroundAxisSpawn_2 =
						{
							ROUTE_AroundAxisSpawn_1 = {},
						},
					},
				},
				ROUTE_PlantGenerator_D_1 =
				{
					ROUTE_Locked_door = {},
					ROUTE_FlagGold_2 =
					{
						ROUTE_AroundAxisSpawn_1 = {},
					},
				},
			},
			ROUTE_CP_Spawn =
			{
				ROUTE_PlantGenerator_L_2 =
				{
					ROUTE_Locked_door = {},
				},
				ROUTE_PlantGenerator_LR_1 =
				{
					ROUTE_FlagGold_1 =
					{
						ROUTE_Locked_door = {},
						ROUTE_FlagGold_2 =
						{
							ROUTE_AroundAxisSpawn_1 = {},
						},
					},
					ROUTE_AroundAxisSpawn_3 =
					{
						ROUTE_AroundAxisSpawn_2 =
						{
							ROUTE_AroundAxisSpawn_1 = {},
						},
					},
				},
			},
			ROUTE_Allied_Room_Spawn =
			{
				//ROUTE_Allied_Room_Spawn2 =
				//{
					ROUTE_PlantGenerator_R_1 =
					{
						ROUTE_AroundAxisSpawn_3 =
						{
							ROUTE_AroundAxisSpawn_2 =
							{
								ROUTE_AroundAxisSpawn_1 = {},
							},
						},
					},
					ROUTE_Locked_door = {},
					ROUTE_FlagGold_2 =
					{
						ROUTE_AroundAxisSpawn_1 = {},
					},
				//},
			},
			ROUTE_Allied_Room_Spawn2 =
			{
				ROUTE_PlantGenerator_R_1 =
				{
					ROUTE_AroundAxisSpawn_3 =
					{
						ROUTE_AroundAxisSpawn_2 =
						{
							ROUTE_AroundAxisSpawn_1 = {},
						},
					},
				},
				ROUTE_Locked_door = {},
				ROUTE_FlagGold_2 =
				{
					ROUTE_AroundAxisSpawn_1 = {},
				},
			},
		},
		BUILD_Neutral_Command_Post =
		{
		},
		PLANT_Neutral_Command_Post =
		{
		},
		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 = {},
								},
							},
						},
					},
				},
			},
		},
		BUILD_Fence =
		{
		},
		PLANT_Fence =
		{
		},
		CAPPOINT_Truck =
		{
			ROUTE_FlagGold1Place =
			{
				ROUTE_AroundAxisSpawn_1 =
				{
					ROUTE_AroundAxisSpawn_2 =
					{
						ROUTE_AroundAxisSpawn_3 = {},
					},
				},
				ROUTE_Under_Axis_Spawn_1 =
				{
					ROUTE_Under_Axis_Spawn_2 = { Weight=2, },
				},
				ROUTE_Locked_door =
				{	
					ROUTE_Cappoint_Stairs_1 =
					{
						ROUTE_Cappoint_Stairs_2 =
						{
							ROUTE_Cappoint_Outside_1 = {},
						},
					},
				},
				ROUTE_Locked_door =
				{
					ROUTE_Cappoint_FenceHall_1 =
					{
						ROUTE_Cappoint_FenceHall_2 =
						{
							ROUTE_Cappoint_Outside_1 = {},
						},
					},
				},
			},
			ROUTE_FlagGold2Place =
			{
				ROUTE_AroundAxisSpawn_1 =
				{
					ROUTE_AroundAxisSpawn_2 =
					{
						ROUTE_AroundAxisSpawn_3 = {},
					},
				},
				ROUTE_Under_Axis_Spawn_1 =
				{
					ROUTE_Under_Axis_Spawn_2 = { Weight=2, },
				},
				ROUTE_Locked_door =
				{	
					ROUTE_Cappoint_Stairs_1 =
					{
						ROUTE_Cappoint_Stairs_2 =
						{
							ROUTE_Cappoint_Outside_1 = {},
						},
					},
				},
				ROUTE_Locked_door =
				{
					ROUTE_Cappoint_FenceHall_1 =
					{
						ROUTE_Cappoint_FenceHall_2 =
						{
							ROUTE_Cappoint_Outside_1 = {},
						},
					},
				},
			},
			ROUTE_FlagGoldDropped =
			{
				ROUTE_AroundAxisSpawn_1 =
				{
					ROUTE_AroundAxisSpawn_2 =
					{
						ROUTE_AroundAxisSpawn_3 = {},
					},
				},
				ROUTE_Under_Axis_Spawn_1 =
				{
					ROUTE_Under_Axis_Spawn_2 = { Weight=2, },
				},
				ROUTE_Locked_door =
				{	
					ROUTE_Cappoint_Stairs_1 =
					{
						ROUTE_Cappoint_Stairs_2 =
						{
							ROUTE_Cappoint_Outside_1 = {},
						},
					},
				},
				ROUTE_Locked_door =
				{
					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[".*_Axis_Gold_.*"] =
	{
		ROUTE_GarrisonSpawn =
		{
			ROUTE_AroundAxisSpawn_1 = {},
			ROUTE_FlagGold_2 =
			{
				ROUTE_Locked_door = {},
			},
		},
	};
	
	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);
};
