global Map =
{
	//set this to true if you want axis to try and dynamite water pump2
	//after old city wall is destroyed.
	DestroyWaterPumpAfterWall = false,
	DispenseAmmoTime = 15,

	Ammo_Cabinet_cabinet_ammo = "AMMOCAB_cabinet_ammo",
	Health_Cabinet_cabinet_health = "HEALTHCAB_cabinet_health",
	Call_Artillery_Flag_13 = "CALLARTILLERY_Flag_13",
	Artillery_D_894 = "ARTILLERY_D_894",
	Checkpoint_oldcityflag = "CHECKPOINT_oldcityflag",
	Build_Allied_Command_Post = "BUILD_Allied_Command_Post",
	Build_Axis_Command_Post = "BUILD_Axis_Command_Post",
	Build_Axis_Command_Post_1 = "BUILD_Axis_Command_Post_1",
	Build_Garrison_MG_Nest = "BUILD_Garrison_MG_Nest",
	Build_Oasis_Water_Pump = "BUILD_Oasis_Water_Pump",
	Build_Old_City_MG_Nest = "BUILD_Old_City_MG_Nest",
	Build_Old_City_Water_Pump = "BUILD_Old_City_Water_Pump",
	Plant_Allied_Command_Post = "PLANT_Allied_Command_Post",
	Plant_Axis_Command_Post = "PLANT_Axis_Command_Post",
	Plant_Axis_Command_Post_1 = "PLANT_Axis_Command_Post_1",
	Plant_Garrison_MG_Nest = "PLANT_Garrison_MG_Nest",
	Plant_North_Anti_Tank_Gun = "PLANT_North_Anti_Tank_Gun",
	Plant_Oasis_Water_Pump = "PLANT_Oasis_Water_Pump",
	Plant_Old_City_MG_Nest = "PLANT_Old_City_MG_Nest",
	Plant_Old_City_Wall = "PLANT_Old_City_Wall",
	Plant_Old_City_Water_Pump = "PLANT_Old_City_Water_Pump",
	Plant_South_Anti_Tank_Gun = "PLANT_South_Anti_Tank_Gun",
	Mount_Garrison_MG_Nest = "MOUNTMG42_Garrison_MG_Nest",
	Mount_Old_City_MG_Nest = "MOUNTMG42_Old_City_MG_Nest",
	Repair_Garrison_MG_Nest = "REPAIRMG42_Garrison_MG_Nest",
	Repair_Old_City_MG_Nest = "REPAIRMG42_Old_City_MG_Nest",
	Mobile_MG42_p1axis_west_courtyard = "MOBILEMG42_p1axis_west_courtyard",
	Mobile_MG42_p2axis_north_garrison_entrance_1 = "MOBILEMG42_p2axis_north_garrison_entrance_1",
	Snipe_p1axis_behindflagroom = "SNIPE_p1axis_behindflagroom",
	Snipe_p1axis_supplyroom = "SNIPE_p1axis_supplyroom",
	Snipe_p1axis_valleyledge_1 = "SNIPE_p1axis_valleyledge_1",
	Snipe_p1axis_valleyledge_2 = "SNIPE_p1axis_valleyledge_2",
	Snipe_p2axis_garrison_barracks = "SNIPE_p2axis_garrison_barracks",
	Snipe_p2axis_garrison_canopy = "SNIPE_p2axis_garrison_canopy",
	Snipe_p2axis_garrison_southwest_corner = "SNIPE_p2axis_garrison_southwest_corner",
	Snipe_p2axis_old_city_oasis = "SNIPE_p2axis_old_city_oasis",
	Plant_Mine_p1axis_courtyard_middle = "PLANTMINE_p1axis_courtyard_middle",
	Plant_Mine_p1axis_west_of_flagroom = "PLANTMINE_p1axis_west_of_flagroom",

	//dyno counters
	NorthDyno = 0,
	SouthDyno = 0,
	WallDyno = 0,

	FlagStatus = 0, //no team owns it initially

	NorthGunStatus = 0, //intact
	SouthGunStatus = 0,
	WallStatus = true, //intact

	// aggressive defenders will be split into north and south 'teams'
	// this will keep them from wandering across the map
	Roles =
	{
		AXIS =
		{
			DEFENDER1 =
			{
				numbots = 2,
			},
			DEFENDER2 =
			{
				numbots = 2,
			},
		},
	},

	// path through for axis throwing a/s over the wall when attempting to reclaim
	Airstrike =
	{
		wall =
		{
			Enabled = true,
			Team = (1<<TEAM.AXIS),
			Facing = Vector3(-0.601,-0.392,0.696),
			NoPause = true,
		},
	},

	Navigation =
	{
		quickjump =
		{
			navigate = function(_this)
			{
				_this.Bot.PressButton(BTN.JUMP);
				sleep(0.25);
			},
		},
	},

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

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

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

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

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

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

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

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

	Oasis_Water_Pump_Built = function( trigger )
	{
		SetAvailableMapGoals( TEAM.AXIS, true, "MOBILEMG42_p1axis_west_courtyard" );
		SetAvailableMapGoals( TEAM.AXIS, false, "MOBILEMORTAR_waterpump" );

		Util.MapDebugPrint( "Oasis_Water_Pump_Built" );
	},

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

	Old_City_Water_Pump_Built = function( trigger )
	{
		if ( Map.WallStatus || Map.DestroyWaterPumpAfterWall )
		{
			SetAvailableMapGoals( TEAM.AXIS, true, Map.Plant_Old_City_Water_Pump );
		}

		Util.MapDebugPrint( "Old_City_Water_Pump_Built" );
	},

	Old_City_Water_Pump_Destroyed = function( trigger )
	{
		SetAvailableMapGoals( TEAM.AXIS, false, Map.Plant_Old_City_Water_Pump );

		Util.MapDebugPrint( "Old_City_Water_Pump_Destroyed" );
	},

	North_Anti_Tank_Gun_Destroyed = function( trigger )
	{
		Map.NorthGunStatus = 1;

		//don't worry about additional dynos at this point
		Map.NorthDyno = 0;

		//focus on south defense
		SetAvailableMapGoals( TEAM.AXIS, false, {
			"DEFUSE_North_Anti_Tank_Gun.*",
			"DEFEND_North_Gun.*",
			"DEFEND_north_clear.*",
			"TRIPMINE_NorthGun.*",
		});

		//hmm might consider staying conservative after one is destroyed
		if ( Map.SouthDyno < 1 )
		{
			SetAvailableMapGoals( TEAM.AXIS, true, "DEFEND_gun_flex.*" );
		}

		Util.MapDebugPrint( "North_Anti_Tank_Gun_Destroyed" );
	},

	North_Plant = function ( trigger )
	{
		Map.NorthDyno += 1;

		//shift defense to support defuse
		SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_gun_flex.*" );
		SetAvailableMapGoals( TEAM.AXIS, true,	"DEFEND_north_clear.*" );

		Util.MapDebugPrint( "North_Plant" );
	},

	North_Defuse = function ( trigger )
	{
		Map.NorthDyno -= 1;

		if ( Map.NorthDyno < 1  )
		{
			SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_north_clear.*" );

			if ( Map.SouthDyno < 1 ) {
				SetAvailableMapGoals( TEAM.AXIS, true, "DEFEND_gun_flex.*" );
			}
		}

		Util.MapDebugPrint( "North_Defuse" );
	},

	South_Anti_Tank_Gun_Destroyed = function( trigger )
	{
		Map.SouthGunStatus = 1;
		//don't worry about additional dynos at this point
		Map.SouthDyno = 0;

		//focus on north defense
		SetAvailableMapGoals( TEAM.AXIS, false, {
			"DEFUSE_South_Anti_Tank_Gun.*",
			"DEFEND_South_Gun.*",
			"DEFEND_south_clear.*",
			"TRIPMINE_SouthGun.*",
		});

		if ( Map.NorthDyno < 1 )
		{
			SetAvailableMapGoals( TEAM.AXIS, true, "DEFEND_gun_flex.*" );
		}

		Util.MapDebugPrint( "South_Anti_Tank_Gun_Destroyed" );
	},

	South_Plant = function ( trigger )
	{
		Map.SouthDyno += 1;

		//shift defense to support defuse
		SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_gun_flex.*" );
		SetAvailableMapGoals( TEAM.AXIS, true,	"DEFEND_south_clear.*" );

		Util.MapDebugPrint( "South_Plant" );
	},

	South_Defuse = function ( trigger )
	{
		Map.SouthDyno -= 1;

		if ( Map.SouthDyno < 1 )
		{
			SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_south_clear.*" );

			if ( Map.NorthDyno < 1 ) {
				SetAvailableMapGoals( TEAM.AXIS, true, "DEFEND_gun_flex.*" );
			}
		}

		Util.MapDebugPrint( "South_Defuse" );
	},

	Old_City_Wall_Destroyed = function( trigger )
	{
		// this region trigger isn't needed anymore
		DeleteTriggerRegion("snuckpast");

		// and kill the thread watching players that snuck through
		if ( Map.WatchPlayerThreadId ) {
			threadKill(Map.WatchPlayerThreadId);
		}

		Map.DispenseAmmoTime = 5;
		Map.FlagStatus = 0;
		Map.WallDyno = 0;
		Map.WallStatus = false;

		// Axis goals
		SetAvailableMapGoals( TEAM.AXIS, true, {
			"REPAIRMG42_Garrison_MG_Nest",
			"MOUNTMG42_Garrison_MG_Nest",
			"DEFEND_South_Gun_.*",
			"DEFEND_North_Gun_.*",
			"DEFEND_middle_patrol.*",
			".*_p2axis_.*",
			"MOBILEMG42_rGuns.*",
		});
		SetAvailableMapGoals( TEAM.AXIS, false, "SNIPE_p2axis_garrison_canopy" );
		SetAvailableMapGoals( TEAM.AXIS, true, {
			Map.Build_Garrison_MG_Nest,
			Map.Build_Axis_Command_Post,
			"DEFEND_gun_flex.*",
			"PLANTMINE_rGuns.*",
			"CALLARTILLERY_rTunnel.*",
			"CALLARTILLERY_rSouthEntrance.*",
			"ARTILLERY_S_rTunnel.*",
			"ARTILLERY_S_rSouthEntrance.*",
			"TRIPMINE_NorthGun.*",
			"TRIPMINE_SouthGun.*",
		});

		// all classes now
		SetGoalPriority( "DEFEND_north_clear.*", 0.92 );
		SetGoalPriority( "DEFEND_south_clear.*", 0.92 );

		// and turn em off if no dyno
		if ( Map.NorthDyno < 1 ) {
			SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_north_clear.*" );
		}

		if ( Map.SouthDyno < 1 ) {
			SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_south_clear.*" );
		}

		// disable the pathrough airstrike at the wall
		Map.Airstrike.wall.Enabled = false;

		SetAvailableMapGoals( TEAM.AXIS, false, {
			".*_p1axis_.*",
			Map.Ammo_Cabinet_cabinet_ammo,
			Map.Health_Cabinet_cabinet_health,
			Map.Plant_Oasis_Water_Pump,
			Map.Plant_Old_City_MG_Nest,
			Map.Plant_Allied_Command_Post,
			"DEFUSE_Old_City_Wall.*",
			"DEFEND_Flag_.*",
			"CALLARTILLERY_rFirstTunnel.*",
			"ARTILLERY_S_rFirstTunnel.*",
			"MOBILEMORTAR_waterpump",
			"PLANTMINE_rFlag.*",
			"TRIPMINE_Flag.*",
		});

		// this one can be enabled sooner
		SetAvailableMapGoals( TEAM.ALLIES, true, "MOBILEMORTAR_bGuns.*" );

		//optionally keep the waterpump2 dynamite action. problem is, meds will
		//leave defensive spots to go revive engineers as they inevitably get killed
		//because its so close to allied spawn
		if ( !Map.DestroyWaterPumpAfterWall )
		{
			SetAvailableMapGoals( TEAM.AXIS, false, Map.Plant_Old_City_Water_Pump );
		}

		// cs: delay it long enough for the blockable status
		// this prevents a ton of failed paths for allies
		sleep(2.1);

		// Allied goals
		SetAvailableMapGoals( TEAM.ALLIES, true, {
			"ATTACK_Guns_.*",
			"SMOKEBOMB_bGuns.*",
			Map.Plant_North_Anti_Tank_Gun,
			Map.Plant_South_Anti_Tank_Gun,
			Map.Plant_Garrison_MG_Nest,
			Map.Plant_Axis_Command_Post,
		});
		SetAvailableMapGoals( TEAM.ALLIES, false, {
			Map.Mount_Old_City_MG_Nest,
			Map.Repair_Old_City_MG_Nest,
			Map.Health_Cabinet_cabinet_health,
			Map.Ammo_Cabinet_cabinet_ammo,
			Map.Plant_Old_City_Wall,
			"ATTACK_Wall_.*",
			Map.Build_Oasis_Water_Pump,
			Map.Build_Old_City_MG_Nest,
		});
		//SetAvailableMapGoals( TEAM.ALLIES, false, Map.Build_Allied_Command_Post );
		SetAvailableMapGoals( TEAM.ALLIES, false, "AIRSTRIKE_bWall.*" );

		Util.MapDebugPrint( "Old_City_Wall_Destroyed" );
	},

	Wall_Plant = function ( trigger )
	{
		Map.WallDyno += 1;

		Util.MapDebugPrint( "Wall Plant" );
	},

	Wall_Defuse = function ( trigger )
	{
		Map.WallDyno -= 1;

		Util.MapDebugPrint( "Wall Defuse" );
	},

	oldcityflag_Axis_Captured = function( trigger )
	{
		Map.FlagStatus = 1;

		SetGoalPriority( Map.Plant_Old_City_Wall, 0.91, TEAM.ALLIES, CLASS.ENGINEER );

		// Allied goals
		SetAvailableMapGoals( TEAM.ALLIES, false, {
			"ATTACK_Wall_.*",
			Map.Ammo_Cabinet_cabinet_ammo,
			Map.Health_Cabinet_cabinet_health,
			"AIRSTRIKE_bWall.*",
		});

		// Axis goals
		SetAvailableMapGoals( TEAM.AXIS, true, {
			"DEFEND_Flag_.*",
			".*_p1axis_.*",
			"CALLARTILLERY_rFirstTunnel.*",
			"ARTILLERY_S_rFirstTunnel.*",
		});

		Util.MapDebugPrint( "oldcityflag_Axis_Captured" );
	},

	oldcityflag_Allies_Captured = function( trigger )
	{
		Map.FlagStatus = 2;

		SetGoalPriority( Map.Plant_Old_City_Wall, 0.95, TEAM.ALLIES, CLASS.ENGINEER );

		// Allied goals
		SetAvailableMapGoals( TEAM.ALLIES, true, {
			"ATTACK_Wall_.*",
			Map.Ammo_Cabinet_cabinet_ammo,
			Map.Health_Cabinet_cabinet_health,
			"AIRSTRIKE_bWall.*",
		});

		// Axis goals
		SetAvailableMapGoals( TEAM.AXIS, false, {
			"DEFEND_Flag_.*",
			".*_p1axis_.*",
			"CALLARTILLERY_rFirstTunnel.*",
			"ARTILLERY_S_rFirstTunnel.*",
		});

		Util.MapDebugPrint( "oldcityflag_Allies_Captured" );
	},

	WatchPlayerLimbo = function()
	{
		while(Map.WatchPlayer && !GetEntFlags(Map.WatchPlayer, ENTFLAG.LIMBO)) {
			sleep(0.5);
		}

		SetAvailableMapGoals( TEAM.AXIS, false, {
			"DEFEND_north_clear.*",
			"DEFEND_south_clear.*",
		});
		Util.MapDebugPrint( "Sneaky player died" );
	},

	SnuckPast =
	{
		Name = "snuckpast",
		TriggerOnClass = CLASS.ENGINEER,
		OnEnter = function(ent)
		{
			team = GetEntTeam(ent);
			if ( team != TEAM.ALLIES ) { return; }

			// spawn the engineers back (only do this once)
			if ( !Map.SpawnedBack ) {
				ETUtil.SuicideSpawn( TEAM.AXIS, 1, -1, CLASS.ENGINEER );
				Map.SpawnedBack = true;
			}

			// have the engineers defend the guns
			Util.LimitToClass( "DEFEND_north_clear.*", TEAM.AXIS, CLASS.ENGINEER );
			Util.LimitToClass( "DEFEND_south_clear.*", TEAM.AXIS, CLASS.ENGINEER );
			SetAvailableMapGoals( TEAM.AXIS, true, {
				"DEFEND_north_clear.*",
				"DEFEND_south_clear.*",
			});

			// and do it until the sneaky player dies
			Map.WatchPlayer = ent;

			if ( Map.WatchPlayerThreadId ) {
				threadKill(Map.WatchPlayerThreadId);
			}
			Map.WatchPlayerThreadId = thread(Map.WatchPlayerLimbo);

		},
	},
};

global OnMapLoad = function()
{
	Util.SetGoalPosition( 4576.686, 6586.125, -468.781, "PLANT_Old_City_Water_Pump" );

	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 Garrison MG Nest has been constructed!", Map.Garrison_MG_Nest_Built );
	OnTrigger( "Allies have built the Oasis Water Pump!", Map.Oasis_Water_Pump_Built );
	OnTrigger( "The Old City MG Nest has been constructed!", Map.Old_City_MG_Nest_Built );
	OnTrigger( "Allies have built the Old City Water Pump!", Map.Old_City_Water_Pump_Built );
	OnTrigger( "Axis team has destroyed the Allied Command Post!", Map.Allied_Command_Post_Destroyed );
	OnTrigger( "Allied team has destroyed the Axis Command Post!", Map.Axis_Command_Post_Destroyed );
	OnTrigger( "The Garrison MG Nest has been damaged!", Map.Garrison_MG_Nest_Destroyed );
	OnTrigger( "Allies have destroyed the North Anti-Tank Gun!", Map.North_Anti_Tank_Gun_Destroyed );
	OnTrigger( "Axis have damaged the Oasis Water Pump!", Map.Oasis_Water_Pump_Destroyed );
	OnTrigger( "The Old City MG Nest has been damaged!", Map.Old_City_MG_Nest_Destroyed );
	OnTrigger( "Allies have breached the Old City wall", Map.Old_City_Wall_Destroyed );
	OnTrigger( "Axis have damaged the Old City Water Pump!", Map.Old_City_Water_Pump_Destroyed );
	OnTrigger( "Allied team has destroyed the South Anti-Tank Gun!", Map.South_Anti_Tank_Gun_Destroyed );
	OnTrigger( "Axis reclaim the Old City!", Map.oldcityflag_Axis_Captured );
	OnTrigger( "Allies capture the Old City!", Map.oldcityflag_Allies_Captured );
	OnTrigger( "Planted at the North Anti-Tank Gun.", Map.North_Plant );
	OnTrigger( "Planted at the South Anti-Tank Gun.", Map.South_Plant );
	OnTrigger( "Defused at the North Anti-Tank Gun.", Map.North_Defuse );
	OnTrigger( "Defused at the South Anti-Tank Gun.", Map.South_Defuse );
	OnTrigger( "Planted at the Old City Wall.", Map.Wall_Plant );
	OnTrigger( "Defused at the Old City Wall.", Map.Wall_Defuse );

	// detect engineers getting through when wall is still intact
	wTunnel2 = OnTriggerRegion(AABB(5731.727,4805.139,-869.945,5983.292,4945.652,-771.262),Map.SnuckPast);
	wall = OnTriggerRegion(AABB(5536.597,6820.100,-565.253,5700.429,7872.364,-367.812),Map.SnuckPast);

	SetMapGoalProperties( "ATTACK_.*", {MinCampTime=15, MaxCampTime=30});
	SetMapGoalProperties( "DEFEND_.*", {MinCampTime=10, MaxCampTime=15});
	SetMapGoalProperties( "MOUNTMG42_.*", {MinCampTime=45, MaxCampTime=90});
	SetMapGoalProperties( "MOBILEMG42_.*", {MinCampTime=30, MaxCampTime=60});
	SetMapGoalProperties( "SNIPE_.*", {MinCampTime=120, MaxCampTime=120});
	SetMapGoalProperties( "DEFEND_north_clear.*", {MinCampTime=30, MaxCampTime=35});
	SetMapGoalProperties( "DEFEND_south_clear.*", {MinCampTime=30, MaxCampTime=35});
	SetMapGoalProperties( "DEFEND_middle_patrol.*", {MinCampTime=1, MaxCampTime=2});

	SetGoalPriority( "MOUNTMG42_.*", 0.0, 0, CLASS.MEDIC );
	SetGoalPriority( "MOUNTMG42_.*", 0.0, 0, CLASS.ENGINEER );

	// don't backtrack to defuse these unless camping
	SetGoalPriority( "DEFUSE_Oasis_Water_Pump.*", 0.7, TEAM.ALLIES, CLASS.ENGINEER, true );
	SetGoalPriority( "DEFUSE_Allied_Command_Post.*", 0.7, TEAM.ALLIES, CLASS.ENGINEER, true );

	// Max users per goal
	Util.SetMaxUsersInProgress( 15, Map.Checkpoint_oldcityflag );
	Util.SetMaxUsers( 1, "DEFEND_.*" );
	Util.SetMaxUsers( 1, "MOUNTMG42_.*" );
	Util.SetMaxUsers( 1, "REPAIR_.*" );
	Util.SetMaxUsersInProgress( 5, "DEFEND_north_clear.*" );
	Util.SetMaxUsersInUse( 1, "DEFEND_north_clear.*" );
	Util.SetMaxUsersInProgress( 5, "DEFEND_south_clear.*" );
	Util.SetMaxUsersInUse( 1, "DEFEND_south_clear.*" );

	// Allied goals
	SetGoalPriority( Map.Build_Oasis_Water_Pump, 0.94, TEAM.ALLIES, CLASS.ENGINEER );
	SetGoalPriority( Map.Build_Allied_Command_Post, 0.93, TEAM.ALLIES, CLASS.ENGINEER );
	SetGoalPriority( Map.Checkpoint_oldcityflag, 0.92, TEAM.ALLIES, CLASS.ENGINEER );
	SetGoalPriority( Map.Plant_Old_City_Wall, 0.91, TEAM.ALLIES, CLASS.ENGINEER );
	SetGoalPriority( Map.Build_Old_City_Water_Pump, 0.90, TEAM.ALLIES, CLASS.ENGINEER );
	SetGoalPriority( Map.Build_Old_City_MG_Nest, 0.89, TEAM.ALLIES, CLASS.ENGINEER );
	SetGoalPriority( Map.Plant_North_Anti_Tank_Gun, 0.81, TEAM.ALLIES, CLASS.ENGINEER );
	SetGoalPriority( Map.Plant_South_Anti_Tank_Gun, 0.81, TEAM.ALLIES, CLASS.ENGINEER );
	SetGoalPriority( Map.Plant_Garrison_MG_Nest, 0.0, TEAM.ALLIES, CLASS.ENGINEER );
	SetGoalPriority( Map.Plant_Axis_Command_Post, 0.0, TEAM.ALLIES, CLASS.ENGINEER );
	SetGoalPriority( Map.Plant_Garrison_MG_Nest, 0.81, TEAM.ALLIES, CLASS.COVERTOPS );

	// Axis goals
	SetGoalPriority( "PLANTMINE_rFlag.*", 0.91, TEAM.AXIS, CLASS.ENGINEER );
	SetGoalPriority( Map.Plant_Old_City_Water_Pump, 0.83, TEAM.AXIS, CLASS.ENGINEER );
	SetGoalPriority( Map.Plant_Oasis_Water_Pump, 0.83, TEAM.AXIS, CLASS.ENGINEER );
	SetGoalPriority( Map.Plant_Old_City_MG_Nest, 0.0, TEAM.AXIS, CLASS.ENGINEER );
	SetGoalPriority( Map.Plant_Allied_Command_Post, 0.0, TEAM.AXIS, CLASS.ENGINEER );
	SetGoalPriority( Map.Plant_Old_City_MG_Nest, 0.82, TEAM.AXIS, CLASS.COVERTOPS );
	SetGoalPriority( Map.Plant_Allied_Command_Post, 0.81, TEAM.AXIS, CLASS.COVERTOPS );
	SetGoalPriority( "DEFEND_north_clear.*", 0.92 );
	SetGoalPriority( "DEFEND_south_clear.*", 0.92 );
	SetGoalPriority( "DEFEND_middle_patrol.*", 0.49 );
	SetGoalPriority( "DEFEND_middle_patrol5", 0.55 ); // peak out the back for campers

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

	SetAvailableMapGoals( TEAM.ALLIES, true, {
		"REPAIRMG42_Old_City_MG_Nest",
		"BUILD_Oasis_Water_Pump",
		"PLANT_Old_City_Wall",
		"PLANT_Garrison_MG_Nest",
		"MOUNTMG42_Old_City_MG_Nest",
		"CHECKPOINT_oldcityflag",
		Map.Build_Old_City_Water_Pump,
		Map.Build_Allied_Command_Post,
		Map.Build_Old_City_MG_Nest,
	});

	SetAvailableMapGoals( TEAM.AXIS, true, {
		"PLANTMINE_rFlag.*",
		"AMMOCAB_cabinet_ammo",
		"HEALTHCAB_cabinet_health",
		"PLANT_Allied_Command_Post",
	});
	//SetAvailableMapGoals( TEAM.AXIS, true, "PLANT_Oasis_Water_Pump" );
	SetAvailableMapGoals( TEAM.AXIS, true, {
		"PLANT_Old_City_MG_Nest",
		"PLANT_Old_City_Water_Pump",
		"SNIPE_p1axis_valleyledge_2",
		"SNIPE_p1axis_behindflagroom",
		"SNIPE_p1axis_supplyroom",
		"SNIPE_p1axis_valleyledge_1",
		"CHECKPOINT_oldcityflag",
		"DEFEND_Flag_.*",
		"TRIPMINE_Flag.*",
		"MOBILEMORTAR_waterpump",
		"CALLARTILLERY_rFirstTunnel.*",
		"ARTILLERY_S_rFirstTunnel.*",
	});

	// randomize plant goal position
	Util.AddUsePoint( Map.Plant_North_Anti_Tank_Gun, { Vec3(9662, 4696, -103), Vec3(9649, 4773, -200) });
	Util.AddUsePoint( Map.Plant_South_Anti_Tank_Gun, { Vec3(9658, 3935, -103), Vec3(9644, 3869, -200) });

	// Routing
	MapRoutes =
	{
		// Alternate Routes
		CHECKPOINT_oldcityflag =
		{
			ROUTE_allyspawn =
			{
				ROUTE_frontdoor_l = {},
				ROUTE_frontdoor_r = {},
				ROUTE_leftdoor =
				{
					Weight = 2,
					ROUTE_toproute_a =
					{
						ROUTE_toproute_b = {},
						ROUTE_toproute_c = {},
					},
					ROUTE_ruins_l =
					{
						ROUTE_ruins_stairs =
						{
							ROUTE_flag_l = {},
							ROUTE_flag_t = {},
						},
					},
				},
				ROUTE_tunnel1 =
				{
					Weight = 2,
					ROUTE_tunnel2 = {},
				},
			},
			ROUTE_cp =
			{
				ROUTE_ruins_l =
				{
					ROUTE_ruins_stairs =
					{
						ROUTE_flag_l = {},
						ROUTE_flag_t = {},
					},
				},
			},
			ROUTE_leftdoor =
			{
				Weight = 2,
				ROUTE_toproute_a =
				{
					ROUTE_toproute_b = {},
					ROUTE_toproute_c = {},
				},
				ROUTE_ruins_l =
				{
					ROUTE_ruins_stairs =
					{
						ROUTE_flag_l = {},
						ROUTE_flag_t = {},
					},
				},
			},
			ROUTE_AxisSpawn1 =
			{
				ROUTE_overwall =
				{
					ROUTE_walltop = {},
					ROUTE_wallfar = {},
				},
				ROUTE_walldoor = {},
			},
			ROUTE_AxisSpawn2 =
			{
				ROUTE_overwall =
				{
					ROUTE_walltop = {},
					ROUTE_wallfar = {},
				},
				ROUTE_walldoor = {},
			},
		},
		DEFEND_Flag_3 =
		{
			ROUTE_AxisSpawn1 =
			{
				ROUTE_overwall =
				{
					ROUTE_walltop = {},
					ROUTE_wallfar = {},
				},
				ROUTE_walldoor = {},
			},
			ROUTE_AxisSpawn2 =
			{
				ROUTE_overwall =
				{
					ROUTE_walltop = {},
					ROUTE_wallfar = {},
				},
				ROUTE_walldoor = {},
			},
		},
		PLANT_North_Anti_Tank_Gun =
		{
			ROUTE_FlagSpawn =
			{
				ROUTE_oc_tunnel =
				{
					Weight = 3,
					ROUTE_southentrance = {},
					ROUTE_se_corner = { ROUTE_eastentrance = {}, },
				},
				ROUTE_upper_connection =
				{
					ROUTE_northentrance1 =
					{
						ROUTE_cp_split =
						{
							ROUTE_cp_route = {},
							ROUTE_halls = {},
						},
					},
					ROUTE_northentrance2 = {},
					ROUTE_ne_corner = { ROUTE_eastentrance = {}, },
					ROUTE_westside =
					{
						ROUTE_sw_corner =
						{
							ROUTE_southentrance = {},
							ROUTE_se_corner = { ROUTE_eastentrance = {}, },
						},
					},
				},
				ROUTE_lower_connection =
				{
					ROUTE_northentrance1 =
					{
						ROUTE_cp_split =
						{
							ROUTE_cp_route = {},
							ROUTE_halls = {},
						},
					},
					ROUTE_northentrance2 = {},
					ROUTE_ne_corner = { ROUTE_eastentrance = {}, },
					ROUTE_westside =
					{
						ROUTE_sw_corner =
						{
							ROUTE_southentrance = {},
							ROUTE_se_corner = { ROUTE_eastentrance = {}, },
						},
					},
				},
			},
		},
		PLANT_South_Anti_Tank_Gun =
		{
			ROUTE_FlagSpawn =
			{
				ROUTE_oc_tunnel =
				{
					Weight = 3,
					ROUTE_southentrance = {},
					ROUTE_se_corner = { ROUTE_eastentrance = {}, },
				},
				ROUTE_upper_connection =
				{
					ROUTE_northentrance1 =
					{
						ROUTE_cp_split =
						{
							ROUTE_halls =
							{
								ROUTE_uppersouth = {},
							},
						},
						ROUTE_lowermg1 = { ROUTE_lowermg2 = {}, },
					},
					ROUTE_northentrance2 = {},
					ROUTE_ne_corner = { ROUTE_eastentrance = {}, },
					ROUTE_westside =
					{
						ROUTE_sw_corner =
						{
							ROUTE_southentrance = {},
							ROUTE_se_corner = { ROUTE_eastentrance = {}, },
						},
					},
				},
				ROUTE_lower_connection =
				{
					ROUTE_northentrance1 =
					{
						ROUTE_cp_split =
						{
							ROUTE_halls =
							{
								ROUTE_uppersouth = {},
							},
						},
						ROUTE_lowermg1 = { ROUTE_lowermg2 = {}, },
					},
					ROUTE_northentrance2 = {},
					ROUTE_ne_corner = { ROUTE_eastentrance = {}, },
					ROUTE_westside =
					{
						ROUTE_sw_corner =
						{
							ROUTE_southentrance = {},
							ROUTE_se_corner = { ROUTE_eastentrance = {}, },
						},
					},
				},
			},
		},
		PLANT_Oasis_Water_Pump =
		{
			ROUTE_FlagSpawn =
				{ ROUTE_tunnel2 = { ROUTE_tunnel1 = {}, }, },
		},
		DEFEND_gun_flex_4 =
		{
			ROUTE_AxisSpawn1 =
			{
				ROUTE_gunpatrol2 = { ROUTE_northentrance2 = {}, },
			},
			ROUTE_AxisSpawn2 =
			{
				ROUTE_gunpatrol2 = { ROUTE_northentrance2 = {}, },
			},
		},
		//most of the time they should check gun area before taking tunnel to the pump
		PLANT_Old_City_Water_Pump =
		{
			ROUTE_AxisSpawn1 =
			{
				ROUTE_oc_tunnel = {},
				ROUTE_gunpatrol = { ROUTE_oc_tunnel = {}, },
				ROUTE_gunpatrol2 =
				{
					ROUTE_gunpatrol = { ROUTE_oc_tunnel = {}, },
				},
			},
			ROUTE_AxisSpawn2 =
			{
				ROUTE_oc_tunnel = {},
				ROUTE_gunpatrol = { ROUTE_oc_tunnel = {}, },
				ROUTE_gunpatrol2 =
				{
					ROUTE_gunpatrol = { ROUTE_oc_tunnel = {}, },
				},
			},
		},
		MOBILEMG42_rGuns1 =
		{
			// send them this way so they don't have their back to enemy when heading to them
			ROUTE_AxisSpawn1 =
			{
				ROUTE_nTruck = {},
			},
			ROUTE_AxisSpawn2 =
			{
				ROUTE_nTruck = {},
			},
		},
		SMOKEBOMB_bGuns_south =
		{
			ROUTE_FlagSpawn =
			{
				ROUTE_oc_tunnel =
				{
					ROUTE_southentrance = {},
				},
			},
		},
		SMOKEBOMB_bGuns_north =
		{
			ROUTE_FlagSpawn =
			{
				ROUTE_upper_connection = {},
				ROUTE_lower_connection = {},
			},
		},
	};

	//copy some routes
	MapRoutes.DEFEND_Flag_4 = MapRoutes.DEFEND_Flag_3;
	MapRoutes.DEFEND_Flag_5 = MapRoutes.DEFEND_Flag_3;
	MapRoutes.DEFEND_Flag_6 = MapRoutes.DEFEND_Flag_3;
	MapRoutes.DEFEND_Flag_7 = MapRoutes.DEFEND_Flag_3;
	MapRoutes.DEFEND_Flag_8 = MapRoutes.DEFEND_Flag_3;
	MapRoutes.DEFEND_Flag_9 = MapRoutes.DEFEND_Flag_3;
	MapRoutes.DEFEND_Flag_10 = MapRoutes.DEFEND_Flag_3;
	MapRoutes.DEFEND_Flag_11 = MapRoutes.DEFEND_Flag_3;
	MapRoutes.DEFEND_Flag_12 = MapRoutes.DEFEND_Flag_3;
	MapRoutes.DEFEND_Flag_13 = MapRoutes.DEFEND_Flag_3;
	MapRoutes.DEFEND_Flag_14 = MapRoutes.DEFEND_Flag_3;
	MapRoutes.DEFEND_Flag_15 = MapRoutes.DEFEND_Flag_3;
	MapRoutes.PLANT_Garrison_MG_Nest = MapRoutes.PLANT_North_Anti_Tank_Gun;
	MapRoutes.PLANT_Axis_Command_Post = MapRoutes.PLANT_North_Anti_Tank_Gun;
	MapRoutes.ATTACK_Guns_1 = MapRoutes.PLANT_North_Anti_Tank_Gun;
	MapRoutes.ATTACK_Guns_2 = MapRoutes.PLANT_North_Anti_Tank_Gun;
	MapRoutes.ATTACK_Guns_3 = MapRoutes.PLANT_North_Anti_Tank_Gun;
	MapRoutes.ATTACK_Guns_4 = MapRoutes.PLANT_North_Anti_Tank_Gun;
	MapRoutes.ATTACK_Guns_5 = MapRoutes.PLANT_North_Anti_Tank_Gun;
	MapRoutes.ATTACK_Guns_6 = MapRoutes.PLANT_North_Anti_Tank_Gun;
	MapRoutes.ATTACK_Guns_7 = MapRoutes.PLANT_North_Anti_Tank_Gun;
	MapRoutes.ATTACK_Guns_8 = MapRoutes.PLANT_North_Anti_Tank_Gun;
	MapRoutes.ATTACK_Guns_9 = MapRoutes.PLANT_North_Anti_Tank_Gun;
	MapRoutes.ATTACK_Guns_10 = MapRoutes.PLANT_North_Anti_Tank_Gun;
	MapRoutes.DEFEND_gun_flex_5 = MapRoutes.DEFEND_gun_flex_4;
	MapRoutes.DEFEND_gun_flex_6 = MapRoutes.DEFEND_gun_flex_4;
	MapRoutes.MOBILEMG42_rGuns2 = MapRoutes.MOBILEMG42_rGuns1;

	Util.Routes(MapRoutes);
	Util.MapDebugPrint( "OnMapLoad" );
};
