//==========================================================================================
//
//	treetop_final.gm
//
//	Who			When			What
//------------------------------------------------------------------------------------------
//	**DRC**BubbaG1		06 October 2011		Initial Script
//
//==========================================================================================
//

global Map =
{
	Debug = 1, // please set to zero before distributing your script

	Allied_Roof_MG_Dyno = 0,
	Assault_Ramp_Dyno = 0,
	Command_Post_Dyno = 0,
	Crate_Barrier_Dyno = 0,
	Elevator_Power_Box_Dyno = 0,
	Front_Door_Dyno = 0,
	Missile_Base_Door_Dyno = 0,
	Ropes_Dyno = 0,
	Treetop_Bridge_Dyno = 0,

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

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

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

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

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

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

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

	Allied_Roof_MG_Planted = function( trigger )
	{
		Map.Allied_Roof_MG_Dyno += 1;
		Util.MapDebugPrint( "Allied_Roof_MG_Planted" );
	},

	Assault_Ramp_Planted = function( trigger )
	{
		Map.Assault_Ramp_Dyno += 1;
		Util.MapDebugPrint( "Assault_Ramp_Planted" );
	},

	Command_Post_Planted = function( trigger )
	{
		Map.Command_Post_Dyno += 1;
		Util.MapDebugPrint( "Command_Post_Planted" );
	},

	Crate_Barrier_Planted = function( trigger )
	{
		Map.Crate_Barrier_Dyno += 1;
		Util.MapDebugPrint( "Crate_Barrier_Planted" );
	},

	Elevator_Power_Box_Planted = function( trigger )
	{
		Map.Elevator_Power_Box_Dyno += 1;
		Util.MapDebugPrint( "Elevator_Power_Box_Planted" );
	},

	Front_Door_Planted = function( trigger )
	{
		Map.Front_Door_Dyno += 1;
		Util.MapDebugPrint( "Front_Door_Planted" );
	},

	Missile_Base_Door_Planted = function( trigger )
	{
		Map.Missile_Base_Door_Dyno += 1;
		Util.MapDebugPrint( "Missile_Base_Door_Planted" );
	},

	Ropes_Planted = function( trigger )
	{
		Map.Ropes_Dyno += 1;
		Util.MapDebugPrint( "Ropes_Planted" );
	},

	Treetop_Bridge_Planted = function( trigger )
	{
		Map.Treetop_Bridge_Dyno += 1;
		Util.MapDebugPrint( "Treetop_Bridge_Planted" );
	},

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

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

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

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

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

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

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

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

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

	Allied_Roof_MG_Destroyed = function( trigger )
	{
		Map.Allied_Roof_MG_Dyno = 0;

		Util.MapDebugPrint( "Allied_Roof_MG_Destroyed" );
	},

	Assault_Ramp_Destroyed = function( trigger )
	{
		Map.Assault_Ramp_Dyno = 0;

		Util.MapDebugPrint( "Assault_Ramp_Destroyed" );
	},

	Allied_Command_Post_Destroyed = function( trigger )
	{
		Map.Command_Post_Dyno = 0;

		Util.MapDebugPrint( "Allied_Command_Post_Destroyed" );
	},

	Axis_Command_Post_Destroyed = function( trigger )
	{
		Map.Command_Post_Dyno = 0;

		Util.MapDebugPrint( "Axis_Command_Post_Destroyed" );
	},

	Crate_Barrier_Destroyed = function( trigger )
	{
		Map.Crate_Barrier_Dyno = 0;

		Util.MapDebugPrint( "Crate_Barrier_Destroyed" );
	},

	Elevator_Power_Box_Destroyed = function( trigger )
	{
		Map.Elevator_Power_Box_Dyno = 0;

		Util.MapDebugPrint( "Elevator_Power_Box_Destroyed" );
	},

	Front_Door_Destroyed = function( trigger )
	{
		Map.Front_Door_Dyno = 0;

		Util.MapDebugPrint( "Front_Door_Destroyed" );
	},

	Missile_Base_Door_Destroyed = function( trigger )
	{

		SetAvailableMapGoals( TEAM.AXIS, false, {
			"AMMOCAB_.*",
			"HEALTHCAB_.*",
			"BUILD_Ropes",
		});

		SetAvailableMapGoals( TEAM.ALLIES, false, {
			"AMMOCAB_.*",
			"HEALTHCAB_.*",
			"PLANT_Ropes",
		});

		Map.Missile_Base_Door_Dyno = 0;

		Util.MapDebugPrint( "Missile_Base_Door_Destroyed" );
	},

	Ropes_Destroyed = function( trigger )
	{
		Map.Ropes_Dyno = 0;

		Util.MapDebugPrint( "Ropes_Destroyed" );
	},

	Treetop_Bridge_Destroyed = function( trigger )
	{
		Map.Treetop_Bridge_Dyno = 0;

		Util.MapDebugPrint( "Treetop_Bridge_Destroyed" );
	},

	the_key_Taken = function( trigger )
	{
		SetAvailableMapGoals( TEAM.ALLIES, true, {
			"CAMP_key_taken.*",
		});

		Util.MapDebugPrint( "the_key_Taken" );
	},

	transmitter_flag_Taken = function( trigger )
	{
		SetAvailableMapGoals( TEAM.ALLIES, false, {
			"CAMP_transmitter_.*",
		});

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

		Util.MapDebugPrint( "transmitter_flag_Taken" );
	},

	the_key_Returned = function( trigger )
	{
		SetAvailableMapGoals( TEAM.ALLIES, false, {
			"CAMP_key_taken.*",
		});

		Util.MapDebugPrint( "the_key_Returned" );
	},

	transmitter_flag_Returned = function( trigger )
	{
		SetAvailableMapGoals( TEAM.ALLIES, false, {
			"CAMP_trans_taken_.*",
		});

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

		Util.MapDebugPrint( "transmitter_flag_Returned" );
	},

	the_key_Secured = function( trigger )
	{
		/* Update Axis Goals */
		SetAvailableMapGoals( TEAM.AXIS, false, {
			"AMMOCAB_ammocab3",
			"BUILD_Treetop_Bridge",
			"CAPPOINT_lock",
			"FLAG_the_key",
			"PLANT_Crate_Barrier",
			"SWITCH_elevator_.*",
			"PLANT_Command_Post",
			"BUILD_Command_Post",
		});

		/* Update Allied Goals */
		SetAvailableMapGoals( TEAM.ALLIES, false, {
			"BUILD_Command_Post",
			"BUILD_Crate_Barrier",
			"CAMP_key_taken.*",
			"CAPPOINT_lock",
			"PLANT_Command_Post",
			"PLANT_Treetop_Bridge",
			"SWITCH_elevator_.*",
			"PLANT_Command_Post",
			"BUILD_Command_Post",
		});

		Util.MapDebugPrint( "the_key_Secured" );
	},

	transmitter_flag_Secured = function( trigger )
	{
		/* Update Axis Goals */
		SetAvailableMapGoals( TEAM.AXIS, false, {
			"AMMOCAB_ammocab3",
			"AMMOCAB_ammocab3",
			"CAPPOINT_transmitter",
			"FLAG_transmitter_flag",
			"HEALTHCAB_healthcab3",
			"BUILD_Elevator_Power_Box",
			"BUILD_Assault_Ramp",
			"PLANT_Allied_Roof_MG",
			"PLANT_Front_Door",
		});

		/* Update Allied Goals */
		SetAvailableMapGoals( TEAM.ALLIES, false, {
			"AMMOCAB_ammocab3",
			"CAMP_trans.*",
			"CAPPOINT_transmitter",
			"HEALTHCAB_healthcab3",
			"BUILD_Allied_Roof_MG",
			"PLANT_Assault_Ramp",
			"PLANT_Elevator_Power_Box",
		});

		Util.MapDebugPrint( "transmitter_flag_Secured" );
	},

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

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

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

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

global OnMapLoad = function()
{
	// Register callback functions
	OnTrigger( "Allies have built the MG42 Nest!", Map.Allied_Roof_MG_Built );
	OnTrigger( "The Axis has constructed the Assault Ramp", Map.Assault_Ramp_Built );
	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 axis have repaired the Power Grid", Map.Elevator_Power_Box_Built );
	OnTrigger( "The Axis have constructed the Climbable Ropes", Map.Ropes_Built );
	OnTrigger( "Bridge Constructed!!", Map.Treetop_Bridge_Built );
	OnTrigger( "Planted at the Allied Roof MG.", Map.Allied_Roof_MG_Planted );
	OnTrigger( "Planted at the Assault Ramp.", Map.Assault_Ramp_Planted );
	OnTrigger( "Planted at the Command Post.", Map.Command_Post_Planted );
	OnTrigger( "Planted at the Crate Barrier.", Map.Crate_Barrier_Planted );
	OnTrigger( "Planted at the Elevator Power Box.", Map.Elevator_Power_Box_Planted );
	OnTrigger( "Planted at the Front Door.", Map.Front_Door_Planted );
	OnTrigger( "Planted at the Missle Base Door.", Map.Missile_Base_Door_Planted );
	OnTrigger( "Planted at the Ropes.", Map.Ropes_Planted );
	OnTrigger( "Planted at the Treetop Bridge.", Map.Treetop_Bridge_Planted );
	OnTrigger( "Defused at the Allied Roof MG.", Map.Allied_Roof_MG_Defused );
	OnTrigger( "Defused at the Assault Ramp.", Map.Assault_Ramp_Defused );
	OnTrigger( "Defused at the Command Post.", Map.Command_Post_Defused );
	OnTrigger( "Defused at the Crate Barrier.", Map.Crate_Barrier_Defused );
	OnTrigger( "Defused at the Elevator Power Box.", Map.Elevator_Power_Box_Defused );
	OnTrigger( "Defused at the Front Door.", Map.Front_Door_Defused );
	OnTrigger( "Defused at the Missle Base Door.", Map.Missile_Base_Door_Defused );
	OnTrigger( "Defused at the Ropes.", Map.Ropes_Defused );
	OnTrigger( "Defused at the Treetop Bridge.", Map.Treetop_Bridge_Defused );
	OnTrigger( "Axis have destroyed the Allied Mg42 Nest!", Map.Allied_Roof_MG_Destroyed );
	OnTrigger( "The Allied have destroyed the Assault Ramp", Map.Assault_Ramp_Destroyed );
	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 Axis have destroyed the Crate Barrier", Map.Crate_Barrier_Destroyed );
	OnTrigger( "The allies have destroyed the Power Grid", Map.Elevator_Power_Box_Destroyed );
	OnTrigger( "The Axis have breached the front gate.", Map.Front_Door_Destroyed );
	OnTrigger( "The Axis have breached the door to the underground base!!!!", Map.Missile_Base_Door_Destroyed );
	OnTrigger( "The Allies have destroyed the Climbable Ropes", Map.Ropes_Destroyed );
	OnTrigger( "allies_bridge_destroyed", Map.Treetop_Bridge_Destroyed );
	OnTrigger( "The Axis have stolen the Key!!!!", Map.the_key_Taken );
	OnTrigger( "The Axis have stolen the Transmitter Parts!!!!", Map.transmitter_flag_Taken );
	OnTrigger( "The Key has been returned!!!!", Map.the_key_Returned );
	OnTrigger( "The Transmitter Parts have been returned!!!!", Map.transmitter_flag_Returned );
	OnTrigger( "The Axis have unlocked the Stairway Door!!", Map.the_key_Secured );
	OnTrigger( "The Axis have activated the transmitter!!", Map.transmitter_flag_Secured );
	OnTrigger( "The Axis are opening the Missle Launch Doors!!!!!", Map.launch_doors_Opening );
	OnTrigger( "The Doors are closing again.", Map.launch_doors_Closing );
	OnTrigger( "Countdown activated", Map.countdown_Activated );
	OnTrigger( "Countdown interrupted", Map.countdown_Interrupted );

	SetAvailableMapGoals( TEAM.AXIS, false, {
		"CAMP_.*",
		"MOUNTMG42_.*",
		"REPAIRMG42_.*",
		"SWITCH_elevator_.*",
	});
	SetAvailableMapGoals( TEAM.ALLIES, false, {
		"CAMP_.*",
		"MOUNTMG42_.*",
		"REPAIRMG42_.*",
		"SWITCH_elevator_.*",
	});
	SetAvailableMapGoals( TEAM.ALLIES, true, {
		"CAMP_transmitter_.*",
	});

	// Max users per goal
	Util.SetMaxUsers( 1, "DEFEND_.*" );
	Util.SetMaxUsers( 1, "GRENADE_.*" );
	Util.SetMaxUsers( 1, "MOUNTMG42_.*" );

	// Camp times
	SetMapGoalProperties( "MOUNTMG42_.*", {MinCampTime=15, MaxCampTime=90} );
	SetMapGoalProperties( "MOBILEMG42_.*", {MinCampTime=10, MaxCampTime=60} );


	Util.MapDebugPrint( "Omni-bot map script for " + GetMapName() + " executed." );
};

global OnBotJoin = function( bot )
{
};
