//========================================================================================================
//
//	Operation Resurrection Final - resurrection.gm
//
//	Who  		When			What
//--------------------------------------------------------------------------------------------------------
//	Mateos		~2009			Updated ailmanki waypoints for OB 0.71
//	Crapshoot	~2010			Conversion of my unfinished 0.71 waypoints to the Beta 0.8
//	Mateos		21/05/2011		Conversion of the final 0.71 waypoints to 0.81
//  Blindman	09/11/2012		Added and modified goals, arty at end game, some position mods.
//
//========================================================================================================

/****************************************************
Original waypoints by ailmanki (12 July 2007)
Pathing updated and script by Mateos
Correspondant WAY file size : 87,9 Ko (90 107 octets)
Last Update : 28th October 2011
****************************************************/

global Map =
{
	Debug = 0,		// Please set to zero before distributing your script
	Talk = true,		// Set Talk to false if you don't want the bots to talk
	ShowMovers = true,
	Movers = { "MOVER_train2" },

	// Make Axis bots not fall back when some stuff need to be built/defused/destroyed
	Book_of_the_Resurrection_Status = 0,	//Not secured or stolen

	Main_Gate_Status = 0,			// Main Gate closed
	Catacomb_Door_Status = 0,		// Catacomb Door not Destroyed

	Allied_Command_Post_Dyno = 0,
	Axis_Command_Post_Dyno = 0,
	Basement_Bridge_Dyno = 0,
	Crypt_Gate_Dyno = 0,
	Dock_Dyno = 0,
	catacomb_door_Dyno = 0,
	main_gate_power_Dyno = 0,
	waterway_door_Dyno = 0,

	escort =
	{
		Name = "b1",
		TriggerOnEntity = GetGoal("MOVER_train2").GetEntity(),
		OnEnter = function(ent)
		{

			SetAvailableMapGoals( TEAM.AXIS, true, {
				"MOBILEMG42_end9",
				"ARTILLERY_S_end9",
				"CALLARTILLERY_end9",
			});

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

	Navigation =
	{
		caretaker_house_ladder =
		{
			navigate = function(_this)
			{
				_this.Bot.HoldButton(BTN.FORWARD, 3);
				sleep(3);
			},
		},
		front_gate_ladder_1 = // waypoint 1109, uid 1148
		{
			navigate = function(_this)
			{
				//look up, move backwards for 3 seconds
				// /bot mypos will show your current facing in console
				_this.AddAimRequest(Priority.High, "facing", Vector3(-0.672,0.035,0.740));
				_this.Bot.HoldButton(BTN.BACKWARD, 3);
				sleep(3);
				// spin around and press forward for 1 second
				_this.AddAimRequest(Priority.High, "facing", Vector3(0.994,-0.091,-0.053));
				_this.Bot.HoldButton(BTN.FORWARD, 1); // may consider 0.5 for this
				sleep(1);
				_this.ReleaseAimRequest();
			},
		},
	},

	Roles =
	{
		AXIS = 						// Team
		{
			AllBots = true, 			// Each bot is considered for a role
			DEFENDER = 				// The Escape Way defense
			{
				voice = "defend", 		// Signals voice chat to randomly announce
				numbots = 3,			// Maximum of 3 bots
				crucialClass = CLASS.MEDIC,	// First bot
			},
			DEFENDER1 = 				// Force the bot to camp on DEFEND_High without high priority
			{
				voice = "defend", 		// Signals voice chat to randomly announce
				numbots = 1,			// A single bot needed
				crucialClass = CLASS.ENGINEER,	// First bot
			},
		},
	},

	// *** TRIGGER CALLBACKS ***
	Allied_Command_Post_Built = function( trigger )
	{
		// If obj not stolen/secured, Axis can plant the enemy CP
		if ( Map.Book_of_the_Resurrection_Status == 0 )
		{
			SetAvailableMapGoals( TEAM.AXIS, true, "PLANT_Allied_Command_Post" );
		}

		// If some real player build Allied CP while obj stolen/secured, don't care it
		if ( Map.Book_of_the_Resurrection_Status == 1 )
		{
			SetAvailableMapGoals( TEAM.AXIS, false, "PLANT_Allied_Command_Post" );
		}

		Util.MapDebugPrint( "Allied_Command_Post_Built" );
	},




	Axis_Command_Post_Built = function( trigger )
	{
		// If obj not stolen/secured, Allies can plant the enemy CP
		if ( Map.Book_of_the_Resurrection_Status == 0 )
		{
			SetAvailableMapGoals( TEAM.ALLIES, true, "PLANT_Axis_Command_Post" );
		}

		// If some real player build Axis CP while obj stolen/secured (Nice battle sense), don't care it
		if ( Map.Book_of_the_Resurrection_Status == 1 )
		{
			SetAvailableMapGoals( TEAM.ALLIES, true, "PLANT_Axis_Command_Post" );
		}

		Util.MapDebugPrint( "Axis_Command_Post_Built" );
	},

	Basement_Bridge_Built = function( trigger )
	{
		// If obj not stolen/secured, Axis can plant it (Can be used to escape)
		if ( Map.Book_of_the_Resurrection_Status == 0 )
		{
			SetAvailableMapGoals( TEAM.AXIS, true, "PLANT_Basement_Bridge" );
		}

		// If some real player build it while obj stolen/secured, don't care it
		if ( Map.Book_of_the_Resurrection_Status == 1 )
		{
			SetAvailableMapGoals( TEAM.AXIS, false, "PLANT_Basement_Bridge" );

			// If Axis Covert Op, True: To Do
		}

		Util.MapDebugPrint( "Basement_Bridge_Built" );
	},

	Crypt_Gate_Built = function( trigger )
	{
		SetAvailableMapGoals( TEAM.ALLIES, false, "ROUTE_CryptGate1" );

		// If obj not stolen/secured, Allies can plant it (Can be used to escape)
		if ( Map.Book_of_the_Resurrection_Status == 0 )
		{
			SetAvailableMapGoals( TEAM.ALLIES, true, "PLANT_Crypt_Gate" );
		}

		// If some real player build it while obj stolen/secured, don't care it
		if ( Map.Book_of_the_Resurrection_Status == 1 )
		{
			SetAvailableMapGoals( TEAM.ALLIES, false, "PLANT_Crypt_Gate" );
		}

		// If both Catabomb and Crypt ways are closed, do not take objective
		if ( Map.Catacomb_Door_Status == 0 )
		{
			SetAvailableMapGoals( TEAM.ALLIES, false, "FLAG_Book_Of_The_Resurrection" );
		}

		// If Catacomb Door is destroyed, at least one way to escape is available
		if ( Map.Catacomb_Door_Status == 1 )
		{
			SetAvailableMapGoals( TEAM.ALLIES, true, "FLAG_Book_Of_The_Resurrection" );
		}

		Util.MapDebugPrint( "Crypt_Gate_Built" );
	},

	Dock_Built = function( trigger )
	{
		// If main_gate_power_destroyed, do not enable the side Defend spot
		if ( Map.Main_Gate_Status == 0 )
		{
			SetAvailableMapGoals( TEAM.AXIS, true, "DEFEND_start4" );
		}

		// If obj not stolen/secured, Allies can plant it
		if ( Map.Book_of_the_Resurrection_Status == 0 )
		{
			SetAvailableMapGoals( TEAM.ALLIES, true, "PLANT_waterway_door" );
		}

		Util.MapDebugPrint( "Dock_Built" );
	},

	Allied_Command_Post_Planted = function( trigger )
	{
		Map.Allied_Command_Post_Dyno += 1;
		SetAvailableMapGoals( TEAM.AXIS, false, "PLANT_Allied_Command_Post" );

		Util.MapDebugPrint( "Allied_Command_Post_Planted" );
	},

	Axis_Command_Post_Planted = function( trigger )
	{
		Map.Axis_Command_Post_Dyno += 1;
		SetAvailableMapGoals( TEAM.ALLIES, false, "PLANT_Axis_Command_Post" );

		Util.MapDebugPrint( "Axis_Command_Post_Planted" );
	},

	Basement_Bridge_Planted = function( trigger )
	{
		Map.Basement_Bridge_Dyno += 1;
		SetAvailableMapGoals( TEAM.AXIS, false, "PLANT_Basement_Bridge" );

		Util.MapDebugPrint( "Basement_Bridge_Planted" );
	},

	Crypt_Gate_Planted = function( trigger )
	{
		Map.Crypt_Gate_Dyno += 1;
		SetAvailableMapGoals( TEAM.ALLIES, false, "PLANT_Crypt_Gate" );

		Util.MapDebugPrint( "Crypt_Gate_Planted" );
	},

	Dock_Planted = function( trigger )
	{
		Map.Dock_Dyno += 1;
		SetAvailableMapGoals( TEAM.AXIS, false, "PLANT_Dock" );

		Util.MapDebugPrint( "Dock_Planted" );
	},

	catacomb_door_Planted = function( trigger )
	{
		Map.catacomb_door_Dyno += 1;
		SetAvailableMapGoals( TEAM.ALLIES, false, "PLANT_catacomb_door" );

		Util.MapDebugPrint( "catacomb_door_Planted" );
	},

	main_gate_power_Planted = function( trigger )
	{
		Map.main_gate_power_Dyno += 1;
		SetAvailableMapGoals( TEAM.ALLIES, false, "PLANT_main_gate_power" );

		Util.MapDebugPrint( "main_gate_power_Planted" );
	},

	waterway_door_Planted = function( trigger )
	{
		Map.waterway_door_Dyno += 1;
		SetAvailableMapGoals( TEAM.ALLIES, false, "PLANT_waterway_door" );

		Util.MapDebugPrint( "waterway_door_Planted" );
	},

	Allied_Command_Post_Defused = function( trigger )
	{
		Map.Allied_Command_Post_Dyno -= 1;
		if ( Map.Allied_Command_Post_Dyno < 1 )
			{ SetAvailableMapGoals( TEAM.AXIS, true, "PLANT_Allied_Command_Post" ); }

		Util.MapDebugPrint( "Allied_Command_Post_Defused" );
	},

	Axis_Command_Post_Defused = function( trigger )
	{
		Map.Axis_Command_Post_Dyno -= 1;
		if ( Map.Axis_Command_Post_Dyno < 1 )
			{ SetAvailableMapGoals( TEAM.ALLIES, true, "PLANT_Axis_Command_Post" ); }

		Util.MapDebugPrint( "Axis_Command_Post_Defused" );
	},

	Basement_Bridge_Defused = function( trigger )
	{
		Map.Basement_Bridge_Dyno -= 1;
		if ( Map.Basement_Bridge_Dyno < 1 )
			{ SetAvailableMapGoals( TEAM.AXIS, true, "PLANT_Basement_Bridge" ); }

		Util.MapDebugPrint( "Basement_Bridge_Defused" );
	},

	Crypt_Gate_Defused = function( trigger )
	{
		Map.Crypt_Gate_Dyno -= 1;
		if ( Map.Crypt_Gate_Dyno < 1 )
			{ SetAvailableMapGoals( TEAM.ALLIES, true, "PLANT_Crypt_Gate" ); }

		Util.MapDebugPrint( "Crypt_Gate_Defused" );
	},

	Dock_Defused = function( trigger )
	{
		Map.Dock_Dyno -= 1;
		if ( Map.Dock_Dyno < 1 )
			{ SetAvailableMapGoals( TEAM.AXIS, true, "PLANT_Dock" ); }

		Util.MapDebugPrint( "Dock_Defused" );
	},

	catacomb_door_Defused = function( trigger )
	{
		Map.catacomb_door_Dyno -= 1;
		if ( Map.catacomb_door_Dyno < 1 )
			{ SetAvailableMapGoals( TEAM.ALLIES, true, "PLANT_catacomb_door" ); }

		Util.MapDebugPrint( "catacomb_door_Defused" );
	},

	main_gate_power_Defused = function( trigger )
	{
		Map.main_gate_power_Dyno -= 1;
		if ( Map.main_gate_power_Dyno < 1 )
			{ SetAvailableMapGoals( TEAM.ALLIES, true, "PLANT_main_gate_power" ); }

		Util.MapDebugPrint( "main_gate_power_Defused" );
	},

	waterway_door_Defused = function( trigger )
	{
		Map.waterway_door_Dyno -= 1;
		if ( Map.waterway_door_Dyno < 1 )
			{ SetAvailableMapGoals( TEAM.ALLIES, true, "PLANT_waterway_door" ); }

		Util.MapDebugPrint( "waterway_door_Defused" );
	},

	Allied_Command_Post_Destroyed = function( trigger )
	{
		// If obj not stolen/secured, Allies can build their CP
		if ( Map.Book_of_the_Resurrection_Status == 0 )
		{
			SetAvailableMapGoals( TEAM.ALLIES, true, "BUILD_Allied_Command_Post" );
		}

		// If some real player destroy Allied CP while obj stolen/secured, don't care it
		if ( Map.Book_of_the_Resurrection_Status == 1 )
		{
			SetAvailableMapGoals( TEAM.ALLIES, false, "BUILD_Allied_Command_Post" );
		}

		Util.MapDebugPrint( "Allied_Command_Post_Destroyed" );
	},

	Axis_Command_Post_Destroyed = function( trigger )
	{
		// If obj not stolen/secured, Axis can build their CP safely
		if ( Map.Book_of_the_Resurrection_Status == 0 )
		{
			SetAvailableMapGoals( TEAM.AXIS, true, "BUILD_Axis_Command_Post" );
		}

		// If obj stolen/secured, everyone camp outside, engis included
		if ( Map.Book_of_the_Resurrection_Status == 1 )
		{
			SetAvailableMapGoals( TEAM.AXIS, false, "BUILD_Axis_Command_Post" );
		}

		Util.MapDebugPrint( "Axis_Command_Post_Destroyed" );
	},

	Basement_Bridge_Destroyed = function( trigger )
	{
		// Only useless to re-build it when obj is secured
		if ( Map.Book_of_the_Resurrection_Status == 1 )
		{
			SetAvailableMapGoals( TEAM.ALLIES, false, "BUILD_Basement_Bridge" );
		}

		Util.MapDebugPrint( "Basement_Bridge_Destroyed" );
	},

	Crypt_Gate_Destroyed = function( trigger )
	{
		if ( Map.Book_of_the_Resurrection_Status == 0 )
		{
			SetAvailableMapGoals( TEAM.AXIS, true, {
				"PLANTMINE_Obj.*",
				"BUILD_Crypt_Gate",
				"PLANTMINE_Taken.*",
			});
		}

		SetAvailableMapGoals( TEAM.ALLIES, true, {
			"ROUTE_CryptGate1",
			"FLAG_Book_Of_The_Resurrection",
		});

		Util.MapDebugPrint( "Crypt_Gate_Destroyed" );
	},

	Dock_Destroyed = function( trigger )
	{
		SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_start4" );

		Util.MapDebugPrint( "Dock_Destroyed" );
	},

	catacomb_door_Destroyed = function( trigger )
	{
		Map.Catacomb_Door_Status = 1;	// Catacomb Door Destroyed

		// If obj not stolen/secured only, disabled on Taken, re-enabled if Returned
		if ( Map.Book_of_the_Resurrection_Status == 0 )
		{
			SetAvailableMapGoals( TEAM.AXIS, true, {
				"DEFEND_Delta.*",
				"PLANTMINE_Obj.*",
				"PLANTMINE_Taken.*",
			});
			SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_Bravo.*" );
		}

		SetAvailableMapGoals( TEAM.ALLIES, true, {
			"ROUTE_Ladder1",
			"FLAG_Book_Of_The_Resurrection",
		});

		Util.MapDebugPrint( "catacomb_door_Destroyed" );
	},

	main_gate_power_Destroyed = function( trigger )
	{
		Map.Main_Gate_Status = 1;	// Main Gate opened

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

		// If obj not stolen/secured only, disabled on Taken, re-enabled if Returned
		if ( Map.Book_of_the_Resurrection_Status == 0 )
		{
			// *** AXIS GOALS ***
			SetAvailableMapGoals( TEAM.AXIS, true, {
				"DEFEND_Alpha.*",
				"MOUNTMG42_HouseMG42",
				"BUILD_Crypt_Gate",
				"MOBILEMG42_EntranceMobileMG42",
			});

			SetGoalPriority( "DEFEND_AxisFlag", 0.55 );
			SetGoalPriority( "DEFEND_Catacomb.*", 0.55 );

			SetGoalPriority( "DEFEND_DoorDestroyed", 0.55 );
			SetAvailableMapGoals( TEAM.AXIS, true, {
				"DEFEND_AxisFlag",
				"DEFEND_Catacomb.*",
				"DEFEND_DoorDestroyed",
			});

			SetAvailableMapGoals( TEAM.AXIS, false, {
				"MOUNTMG42_StartMG42",
				"DEFEND_start.*",
				"DEFEND_High",
				"DEFEND_DoorDestroyed",
			});

			// *** ALLIED GOALS ***
			SetAvailableMapGoals( TEAM.ALLIES, true, {
				"ATTACK_Charlie.*",
				"CHECKPOINT_room_flag",
				"BUILD_Allied_Command_Post",
				"PLANT_Crypt_Gate",
				"PLANT_catacomb_door",
				"PLANT_Axis_Command_Post",
			});

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

			if (Map.Talk)
			{
				foreach ( id and bot in BotTable )
				{
					if ( bot.GetTeam() == TEAM.AXIS )
					{
						r = RandRange(0,10);
						if( r < 2 )
						{
							bot.SayVoice(VOICE.REINFORCE_DEF);
						}
						else if( r > 8 )
						{
							bot.SayVoice(VOICE.DEFEND_OBJECTIVE);
						}
					}
					if ( bot.GetTeam() == TEAM.ALLIES )
					{
						r = RandRange(0,10);
						if( r < 2 )
						{
							bot.SayVoice(VOICE.LETS_GO);
						}
						else if( r > 8 )
						{
							sleep(1.2);
							bot.SayVoice(VOICE.G_CHEER);
						}
					}
				}
			}
		}

		Util.MapDebugPrint( "main_gate_power_Destroyed" );
	},

	waterway_door_Destroyed = function( trigger )
	{
		// In case some real player wants to XP while obj is secured...
		if ( Map.Book_of_the_Resurrection_Status == 0 )
		{
			SetAvailableMapGoals( TEAM.ALLIES, true, "BUILD_Basement_Bridge" );
		}

		Util.MapDebugPrint( "waterway_door_Destroyed" );
	},

	Book_of_the_Resurrection_Taken = function( trigger )
	{
		Map.Book_of_the_Resurrection_Status = 1;

		// Important camping spots, but limited to 3 bots
		SetGoalPriority( "DEFEND_Obj.*", 0.55 );
		Util.SetRoleForGoals( "DEFEND_Obj1", ROLE.DEFENDER );
		Util.SetRoleForGoals( "DEFEND_Obj2", ROLE.DEFENDER );
		Util.SetRoleForGoals( "DEFEND_Obj3", ROLE.DEFENDER );
		SetAvailableMapGoals( TEAM.AXIS, true, {
			"DEFEND_Obj.*",
			"DEFEND_Alpha.*",
		});

		SetAvailableMapGoals( TEAM.AXIS, false, {
			"DEFEND_Bravo.*",
			"DEFEND_Delta.*",
			"DEFEND_Catacomb.*",
			"MOUNTMG42_HouseMG42",
			"PLANTMINE_Obj.*",
			"PLANTMINE_Taken.*",
		});

		if (Map.Talk)
		{
			foreach ( id and bot in BotTable )
			{
				if ( bot.GetTeam() == TEAM.AXIS )
				{
					r = RandRange(0,10);
					if( r < 2 )
					{
						bot.SayVoice(VOICE.G_NEGATIVE);
					}
					else if( r > 6 )
					{
						bot.SayTeam("All to the Boat!!!");
					}
				}
				if ( bot.GetTeam() == TEAM.ALLIES )
				{
					r = RandRange(0,10);
					if( r < 2 )
					{
						bot.SayVoice(VOICE.MOVE);
					}
				}
			}
		}

		Util.MapDebugPrint( "Book_of_the_Resurrection_Taken" );
	},

	Book_of_the_Resurrection_Returned = function( trigger )
	{
		Map.Book_of_the_Resurrection_Status = 0;

		Util.EnableGoal( "CHECKPOINT_room_flag", true );

		SetAvailableMapGoals( TEAM.AXIS, true, {
			"DEFEND_Bravo.*",
			"DEFEND_Delta.*",
			"PLANTMINE_Obj.*",
			"DEFEND_Catacomb.*",
			"PLANTMINE_Taken.*",
		});

		SetAvailableMapGoals( TEAM.AXIS, false, {
			"DEFEND_Obj.*",
			"DEFEND_Alpha.*",
		});

		if (Map.Talk)
		{
			foreach ( id and bot in BotTable )
			{
				if ( bot.GetTeam() == TEAM.AXIS )
				{
					r = RandRange(0,10);
					if( r < 2 )
					{
						bot.SayVoice(VOICE.G_GOODGAME);
					}
					else if( r > 8 )
					{
						bot.SayVoice(VOICE.DEFEND_OBJECTIVE);
					}
				}
			}
		}

		Util.MapDebugPrint( "Book_of_the_Resurrection_Returned" );
	},

	Book_of_the_Resurrection_Secured = function( trigger )
	{
		Map.Book_of_the_Resurrection_Status = 1;

		// Making bots only focus on end goals
		Util.DisableGoal( ".*", true );	// All but Routes
		SetGoalPriority( "DEFUSE_.*", 0.0, TEAM.AXIS, CLASS.ENGINEER, true );
		SetGoalPriority( "DEFUSE_.*", 0.0, TEAM.ALLIES, CLASS.ENGINEER, true );

		Util.EnableGoal( "MOVER_train2", true );
		Util.EnableGoal( "ESCORT_Boat", true );

		SetAvailableMapGoals( TEAM.AXIS, true, {
			"DEFEND_End.*",
			"ARTILLERY_S_end",
			"ARTILLERY_D_end",
			"CALLARTILLERY_end",
			"CALLARTILLERY_end2",
		});

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

		// Close useless "DEFEND_start.*" spots
		SetAvailableMapGoals( TEAM.ALLIES, false, {
			"DEFEND_start1",
			"DEFEND_start2",
			"DEFEND_start4",
		});
		SetAvailableMapGoals( TEAM.ALLIES, true, {
			"ARTILLERY_S_ally.*",
			"ARTILLERY_D_ally.*",
			"CALLARTILLERY_ally.*",
		});

		if (Map.Talk)
		{
			foreach ( id and bot in BotTable )
			{
				if ( bot.GetTeam() == TEAM.AXIS )
				{
					r = RandRange(0,10);
					if( r < 2 )
					{
						bot.SayVoice(VOICE.G_NEGATIVE);
					}
					else if( r > 8 )
					{
						bot.SayTeam("All to the Boat!!!");
					}
				}
				if ( bot.GetTeam() == TEAM.ALLIES )
				{
					r = RandRange(0,10);
					if( r < 2 )
					{
						bot.SayVoice(VOICE.G_GOODGAME);
					}
					else if( r > 8 )
					{
						sleep(1.2);
						bot.SayVoice(VOICE.ESCORT_VEHICLE);
					}
				}
			}
		}

		Util.MapDebugPrint( "Book_of_the_Resurrection_Secured" );
	},

	room_flag_Axis_Captured = function( trigger )
	{
		SetAvailableMapGoals( TEAM.AXIS, true, {
			"PLANT_Dock",
			"DEFEND_Alpha.*",
			"DEFEND_AxisFlag",
			"DEFEND_DoorDestroyed",
			"MOBILEMG42_EntranceMobileMG42",
		});

		SetAvailableMapGoals( TEAM.ALLIES, true, {
			"BUILD_Dock",
			"PLANT_waterway_door",
			"CHECKPOINT_room_flag",
		});

		Util.MapDebugPrint( "room_flag_Axis_Captured" );
	},

	room_flag_Allies_Captured = function( trigger )
	{
		// If obj not stolen/secured only, disabled on Taken, re-enabled if Returned
		if ( Map.Book_of_the_Resurrection_Status == 0 )
		{
			SetAvailableMapGoals( TEAM.AXIS, true, {
				"DEFEND_Bravo.*",
				"CHECKPOINT_room_flag",
			});
			SetAvailableMapGoals( TEAM.AXIS, false, {
				"PLANT_Dock",
				"DEFEND_Alpha.*",
				"DEFEND_AxisFlag",
				"DEFEND_DoorDestroyed",
				"MOBILEMG42_EntranceMobileMG42",
			});

			SetAvailableMapGoals( TEAM.ALLIES, false, {
				"BUILD_Dock",
				"PLANT_waterway_door",
			});
		}

		Util.MapDebugPrint( "room_flag_Allies_Captured" );
	},

	AlliesWin = function( trigger )
	{
		if (Map.Talk)
		{
			foreach ( id and bot in BotTable )
			{
				if ( bot.GetTeam() == TEAM.AXIS )
				{
					r = RandRange(0,10);
					if( r < 2 )
					{
						bot.SayVoice(VOICE.G_NEGATIVE);
					}
					else if( r > 8 )
					{
						bot.Say("Verdammt!");
					}
				}
				if ( bot.GetTeam() == TEAM.ALLIES )
				{
					r = RandRange(0,10);
					if( r < 2 )
					{
						bot.SayVoice(VOICE.G_GOODGAME);
					}
					else if( r > 8 )
					{
						sleep(1.2);
						bot.SayVoice(VOICE.G_CHEER);
					}
				}
			}
		}

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

global OnMapLoad = function()
{
	// *** TRIGGERS ***
	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( "Basement Bridge has been constructed.", Map.Basement_Bridge_Built );
	OnTrigger( "Gate to Crypt has been constructed.", Map.Crypt_Gate_Built );
	OnTrigger( "Dock to waterway door has been constructed.", Map.Dock_Built );
	OnTrigger( "Planted at the Allied Command Post.", Map.Allied_Command_Post_Planted );
	OnTrigger( "Planted at the Axis Command Post.", Map.Axis_Command_Post_Planted );
	OnTrigger( "Planted at Basement Bridge.", Map.Basement_Bridge_Planted );
	OnTrigger( "Planted at Crypt Gate.", Map.Crypt_Gate_Planted );
	OnTrigger( "Planted at Dock.", Map.Dock_Planted );
	OnTrigger( "Planted at the catacomb door.", Map.catacomb_door_Planted );
	OnTrigger( "Planted at the main gate power.", Map.main_gate_power_Planted );
	OnTrigger( "Planted at the waterway door.", Map.waterway_door_Planted );
	OnTrigger( "Defused at the Allied Command Post.", Map.Allied_Command_Post_Defused );
	OnTrigger( "Defused at the Axis Command Post.", Map.Axis_Command_Post_Defused );
	OnTrigger( "Defused at Basement Bridge.", Map.Basement_Bridge_Defused );
	OnTrigger( "Defused at Crypt Gate.", Map.Crypt_Gate_Defused );
	OnTrigger( "Defused at Dock.", Map.Dock_Defused );
	OnTrigger( "Defused at the catacomb door.", Map.catacomb_door_Defused );
	OnTrigger( "Defused at the Main Gate Power.", Map.main_gate_power_Defused );
	OnTrigger( "Defused at the waterway door.", Map.waterway_door_Defused );
	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( "Basement Bridge has been destroyed.", Map.Basement_Bridge_Destroyed );
	OnTrigger( "Gate to Crypt has been destroyed.", Map.Crypt_Gate_Destroyed );
	OnTrigger( "Dock to waterway door has been destroyed.", Map.Dock_Destroyed );
	OnTrigger( "Allies Breached the catacomb tunnel entrance", Map.catacomb_door_Destroyed );
	OnTrigger( "The Main Gate has been breached!", Map.main_gate_power_Destroyed );
	OnTrigger( "Allies Breached the waterway entrance", Map.waterway_door_Destroyed );
	OnTrigger( "Allies have stolen Book of the Resurrection!", Map.Book_of_the_Resurrection_Taken );
	OnTrigger( "Axis have returned Book of the Resurrection!", Map.Book_of_the_Resurrection_Returned );
	OnTrigger( "Allied team is escaping with the Book!", Map.Book_of_the_Resurrection_Secured );
	OnTrigger( "Axis reclaims the Forward room!", Map.room_flag_Axis_Captured );
	OnTrigger( "Allies capture the Forward room!", Map.room_flag_Allies_Captured );
	OnTrigger( "Allied team escaped with the Book!", Map.AlliesWin );

	// *** NO PUSH ZONES ***
	nopush1 = OnTriggerRegion(AABB(-2021.686,-822.044,900.956,-1786.145,-448.430,1117.125),RegionTrigger.DisableBotPush);
	nopush2 = OnTriggerRegion(AABB(-1841.861,-254.305,441.926,-1519.329,-28.528,1157.042),RegionTrigger.DisableBotPush);

	b1 = OnTriggerRegion(AABB(-4716,-1337,160.5,-4601.5,-596,170.5),Map.escort);

	// *** CLEAR ALL GOALS FOR BOTH TEAMS ***
	Util.DisableGoal( ".*", true );	// All but Routes

	// *** AXIS GOALS ***
	SetAvailableMapGoals( TEAM.AXIS, true, {
		"PLANT_Dock",
		"MOUNTMG42_StartMG42",
		"DEFEND_start.*",
	});
	SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_start4" );

	SetGoalPriority( "DEFEND_High", 0.55 );	// DEFEND is 0.50 and CHECKPOINT 0.60
	Util.SetRoleForGoals( "DEFEND_High", ROLE.DEFENDER1 );
	SetAvailableMapGoals( TEAM.AXIS, true, "DEFEND_High" );

	// *** ALLIED GOALS ***
	SetAvailableMapGoals( TEAM.ALLIES, true, {
		"BUILD_Dock",
		"ATTACK_Echo.*",
		"CAPPOINT_Boat",
		"PLANT_main_gate_power",
		"FLAG_Book_Of_The_Resurrection",
	});
	SetAvailableMapGoals( TEAM.ALLIES, false, "ROUTE_Ladder1" );

	// *** GOALS PROPERTIES ***
	Util.AddInvVehicle( "MOVER_train2" );

	Util.SetMaxUsers( 1, "BUILD_.*" );
	Util.SetMaxUsers( 2, "MOVER_.*" );
	Util.SetMaxUsers( 1, "PLANT_.*" );
	Util.SetMaxUsers( 1, "DEFEND_.*" );
	Util.SetMaxUsers( 1, "REPAIR_.*" );
	Util.SetMaxUsers( 1, "MOUNTMG42_.*" );
	Util.SetMaxUsers( 1, "CHECKPOINT_.*" );
	Util.SetMaxUsers( 2, "FLAG_.*" );

	SetMapGoalProperties( "ATTACK_.*", {mincamptime=60, maxcamptime=120} );
	SetMapGoalProperties( "DEFEND_.*", {mincamptime=60, maxcamptime=120} );
	SetMapGoalProperties( "MOBILEMG42_.*", {mincamptime=60, maxcamptime=120} );

	Util.SetGoalPosition( -2126, -1557, 226, "BUILD_Dock" ) ;
	Util.SetGoalPosition( 985.875, 131.861, 71.866, "BUILD_Basement_Bridge" ) ;
	Util.SetGoalPosition( 1126.7, 392.3, 78.125, "PLANT_Basement_Bridge" ) ;

	SetGoalPriority( "PLANT_Crypt_Gate", 0.0, TEAM.ALLIES, CLASS.ENGINEER );
	SetGoalPriority( "BUILD_Basement_Bridge", 0.94, TEAM.ALLIES, CLASS.ENGINEER );
	SetGoalPriority( "PLANT_Crypt_Gate", 1.0, TEAM.ALLIES, CLASS.COVERTOPS );
	SetGoalPriority( "PLANT_Basement_Bridge", 0.0, TEAM.AXIS, CLASS.COVERTOPS );
	SetGoalPriority( "PLANT_Axis_Command_Post", 0.35 );
	SetGoalPriority( "PLANT_Allied_Command_Post", 0.35 );

	//Closed the side path, bots directly take obj...
	Wp.SetWaypointFlag( "WaterwayClosed", "closed", false );

	// *** ROUTES ***
	MapRoutes =
	{
		CAPPOINT_Boat =
		{
			ROUTE_BookTaken =
			{
				ROUTE_CryptGate1 =
				{
					ROUTE_CryptGate2 =
					{
						ROUTE_CryptGate3 =
						{
							ROUTE_Escape = {},
						}
					},
				},
				ROUTE_Ladder1 =
				{
					ROUTE_Ladder2 =
					{
						ROUTE_CryptGate2 =
						{
							ROUTE_CryptGate3 =
							{
								ROUTE_Escape = {},
							}
						},
					},
				},
			},
		},
	};

	Util.Routes(MapRoutes);

	Util.MapDebugPrint( "Omni-bot map script for Resurrection Final by Mateos" );
};

global OnBotJoin = function( bot )
{
	bot.MaxViewDistance = 2500;
	bot.TargetBreakableDist = 400.0;

	weaps = { WEAPON.THOMPSON, WEAPON.MP40, WEAPON.SHOTGUN, WEAPON.M97, WEAPON.M7, WEAPON.GARAND, WEAPON.K43, WEAPON.BAR, WEAPON.STEN, WEAPON.MP34, WEAPON.BAR, WEAPON.STG44, WEAPON.FG42};

	foreach( id and weap in weaps )
	{
		w = bot.GetWeapon(weap);
		w.PrimaryFire.SetTargetBias(CLASS.BREAKABLE, 1.2);
	}

	w = bot.GetWeapon(WEAPON.KNIFE);
	w.PrimaryFire.SetDesirabilityRange(0, 48, 0.6);
};
