//=============================================================================
//
//  Chateau Voilegarde (Beta 3) - voilegarde_b3.gm
//
//  Who         When            What
//-----------------------------------------------------------------------------
//  Mateos      31/10/2010      Finished for OB 0.71.
//
//=============================================================================

/****************************************************
Path mapping updated and script by Mateos
Correspondant WAY file size: -
Last update: 26th June 2016
****************************************************/

/*
 * TODO:
 *  - Enable CHECKPOINT_courtyardflag if there's an access to it, and Generator isn't destroyed yet?
 *
 *  - Add class-specific goals:
 *    * Check MOBILEMG42 ones;
 *    * Call Artillery, Mortar and Snipe are done.
 */

global Map =
{
    Debug = 0,  // Please set to zero before distributing your script

    // TODO: With this system, cover spots are disabled too...
    Assault_Ramp_Dyno = 0,
    Command_Post_Dyno = 0,
    Courtyard_MG_Dyno = 0,
    Electric_Floor_Controls_Dyno = 0,
    Generator_Dyno = 0,
    Main_Entrance_Dyno = 0,
    Side_Gate_Dyno = 0,
    Truck_Barrier_Dyno = 0,

    // Global variables indicating the map progress
    isGeneratorDestroyed = false,
    isMainEntranceDestroyed = false,
    isRadarPartStolen = false,

    // TODO: Switches -> Entities + Script
    /*
    Switches =
    {
        e1_top1 =
        {
            Enabled = false,
            Priority = 0.0,
            WaypointName = "e1_top1",
            Timeout = 8000,

            Wait = function()
            {
                if ( Map.Elevator1Pos == "top" )
                {
                    sleep(1);
                    return true;
                }
                return false;
            },
        },
        e1_top2 =
        {
            Enabled = true,
            Priority = 0.0,
            WaypointName = "e1_top2",
            Timeout = 8000,

            Wait = function()
            {
                if ( Map.Elevator1Pos == "bottom" )
                {
                    sleep(1);
                    return true;
                }
                return false;
            },
        },
        e1_bot1 =
        {
            Enabled = true,
            Priority = 0.0,
            WaypointName = "e1_bot1",
            Timeout = 8000,

            Wait = function()
            {
                if ( Map.Elevator1Pos == "bottom" )
                {
                    sleep(1);
                    return true;
                }
                return false;
            },
        },
        e1_bot2 =
        {
            Enabled = false,
            Priority = 0.0,
            WaypointName = "e1_bot2",
            Timeout = 8000,

            Wait = function()
            {
                if ( Map.Elevator1Pos == "top" )
                {
                    sleep(1);
                    return true;
                }
                return false;
            },
        },
    },

    Elevator1Pos = "top",
    Elevator1 = function(trigger)
    {
        Map.Elevator1Pos = "moving";
        Util.MapDebugPrint("Elevator1 moving");

        Map.Switches.e1_top1.Enabled = false;
        Map.Switches.e1_top2.Enabled = false;
        Map.Switches.e1_bot1.Enabled = false;
        Map.Switches.e1_bot2.Enabled = false;

        sleep(7);

        vel = ToVector(trigger.Action);

        if (vel.z < 0)
        {
            Map.Elevator1Pos = "bottom";
            Map.Switches.e1_top1.Enabled = true;
            Map.Switches.e1_bot2.Enabled = true;
            Util.MapDebugPrint("Elevator1 at bottom");
        }
        else
        {
            Map.Elevator1Pos = "top";
            Map.Switches.e1_bot1.Enabled = true;
            Map.Switches.e1_top2.Enabled = true;
            Util.MapDebugPrint("Elevator1 at top");
        }
    },
    */

    Assault_Ramp_Built = function( trigger )
    {
        if ( !Map.isGeneratorDestroyed )
        {
            // blockbridge flags update
            sleep(1);

            Groups.EnableAxis( Groups.group3 );
            SetAvailableMapGoals( TEAM.AXIS, true, "PLANT_Assault_Ramp" );

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

        Util.MapDebugPrint( "Assault_Ramp_Built" );
    },

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

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

    Electric_Floor_Controls_Built = function( trigger )
    {
        SetAvailableMapGoals( TEAM.ALLIES, false, "FLAG_radarpart" );

        if ( !Map.isRadarPartStolen )
        {
            SetAvailableMapGoals( TEAM.ALLIES, true, "PLANT_Electric_Floor_Controls" );
        }

        Util.MapDebugPrint( "Electric_Floor_Controls_Built" );
    },

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

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

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

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

    Assault_Ramp_Planted = function( trigger )
    {
        Map.Assault_Ramp_Dyno += 1;
        SetAvailableMapGoals( TEAM.AXIS, false, "PLANT_Assault_Ramp" );

        Util.MapDebugPrint( "Assault_Ramp_Planted" );
    },

    Command_Post_Planted = function( trigger )
    {
        Map.Command_Post_Dyno += 1;
        SetAvailableMapGoals( TEAM.AXIS, false, "PLANT_Command_Post" );

        // CHECK! Is this a valid goal for both teams?
        SetAvailableMapGoals( TEAM.ALLIES, false, "PLANT_Command_Post" );

        Util.MapDebugPrint( "Command_Post_Planted" );
    },

    Courtyard_MG_Planted = function( trigger )
    {
        Map.Courtyard_MG_Dyno += 1;
        SetAvailableMapGoals( TEAM.ALLIES, false, "PLANT_Courtyard_MG" );

        Util.MapDebugPrint( "Courtyard_MG_Planted" );
    },

    Electric_Floor_Controls_Planted = function( trigger )
    {
        Map.Electric_Floor_Controls_Dyno += 1;
        SetAvailableMapGoals( TEAM.ALLIES, false, "PLANT_Electric_Floor_Controls" );

        Util.MapDebugPrint( "Electric_Floor_Controls_Planted" );
    },

    Generator_Planted = function( trigger )
    {
        Map.Generator_Dyno += 1;
        SetAvailableMapGoals( TEAM.ALLIES, false, "PLANT_Generator" );

        Util.MapDebugPrint( "Generator_Planted" );
    },

    Main_Entrance_Planted = function( trigger )
    {
        Map.Main_Entrance_Dyno += 1;
        SetAvailableMapGoals( TEAM.ALLIES, false, "PLANT_Main_Entrance" );

        Util.MapDebugPrint( "Main_Entrance_Planted" );
    },

    Side_Gate_Planted = function( trigger )
    {
        Map.Side_Gate_Dyno += 1;
        SetAvailableMapGoals( TEAM.ALLIES, false, "PLANT_Side_Gate" );

        Util.MapDebugPrint( "Side_Gate_Planted" );
    },

    Truck_Barrier_Planted = function( trigger )
    {
        Map.Truck_Barrier_Dyno += 1;
        SetAvailableMapGoals( TEAM.ALLIES, false, "PLANT_Truck_Barrier" );

        Util.MapDebugPrint( "Truck_Barrier_Planted" );
    },

    Assault_Ramp_Defused = function( trigger )
    {
        Map.Assault_Ramp_Dyno -= 1;
        if ( Map.Assault_Ramp_Dyno < 1 )
            { SetAvailableMapGoals( TEAM.AXIS, true, "PLANT_Assault_Ramp" ); }

        Util.MapDebugPrint( "Assault_Ramp_Defused" );
    },

    Command_Post_Defused = function( trigger )
    {
        Map.Command_Post_Dyno -= 1;
        if ( Map.Command_Post_Dyno < 1 )
            { SetAvailableMapGoals( TEAM.AXIS, true, "PLANT_Command_Post" ); }

        // TODO: Either clean that up or merge the two...
        // CHECK! Is this a valid goal for both teams?
        if ( Map.Command_Post_Dyno < 1 )
            { SetAvailableMapGoals( TEAM.ALLIES, true, "PLANT_Command_Post" ); }

        Util.MapDebugPrint( "Command_Post_Defused" );
    },

    Courtyard_MG_Defused = function( trigger )
    {
        Map.Courtyard_MG_Dyno -= 1;
        if ( Map.Courtyard_MG_Dyno < 1 )
            { SetAvailableMapGoals( TEAM.ALLIES, true, "PLANT_Courtyard_MG" ); }

        Util.MapDebugPrint( "Courtyard_MG_Defused" );
    },

    Electric_Floor_Controls_Defused = function( trigger )
    {
        Map.Electric_Floor_Controls_Dyno -= 1;
        if ( Map.Electric_Floor_Controls_Dyno < 1 )
            { SetAvailableMapGoals( TEAM.ALLIES, true, "PLANT_Electric_Floor_Controls" ); }

        Util.MapDebugPrint( "Electric_Floor_Controls_Defused" );
    },

    Generator_Defused = function( trigger )
    {
        Map.Generator_Dyno -= 1;
        if ( Map.Generator_Dyno < 1 )
            { SetAvailableMapGoals( TEAM.ALLIES, true, "PLANT_Generator" ); }

        Util.MapDebugPrint( "Generator_Defused" );
    },

    Main_Entrance_Defused = function( trigger )
    {
        Map.Main_Entrance_Dyno -= 1;
        if ( Map.Main_Entrance_Dyno < 1 )
            { SetAvailableMapGoals( TEAM.ALLIES, true, "PLANT_Main_Entrance" ); }

        Util.MapDebugPrint( "Main_Entrance_Defused" );
    },

    Side_Gate_Defused = function( trigger )
    {
        Map.Side_Gate_Dyno -= 1;
        if ( Map.Side_Gate_Dyno < 1 )
            { SetAvailableMapGoals( TEAM.ALLIES, true, "PLANT_Side_Gate" ); }

        Util.MapDebugPrint( "Side_Gate_Defused" );
    },

    Truck_Barrier_Defused = function( trigger )
    {
        Map.Truck_Barrier_Dyno -= 1;
        if ( Map.Truck_Barrier_Dyno < 1 )
            { SetAvailableMapGoals( TEAM.ALLIES, true, "PLANT_Truck_Barrier" ); }

        Util.MapDebugPrint( "Truck_Barrier_Defused" );
    },

    Assault_Ramp_Destroyed = function( trigger )
    {
        if ( !Map.isMainEntranceDestroyed )  // If Main Entrance is intact
        {
            Groups.DisableAxis(Groups.group3);
        }

        Util.MapDebugPrint( "Assault_Ramp_Destroyed" );
    },

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

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

    Electric_Floor_Controls_Destroyed = function( trigger )
    {
        if ( !Map.isRadarPartStolen )
        {
            SetAvailableMapGoals( TEAM.AXIS, true, "BUILD_Electric_Floor_Controls" );

            sleep(3);

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

        Util.MapDebugPrint( "Electric_Floor_Controls_Destroyed" );
    },

    Generator_Destroyed = function( trigger )
    {
        Map.isGeneratorDestroyed = true;

        Util.MapDebugPrint( "Generator_Destroyed" );

        sleep(13);

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

        Util.EnableGoal( "AMMOCAB_ammorack1" );
        Util.EnableGoal( "AMMOCAB_ammorack2" );
        Util.EnableGoal( "HEALTHCAB_healthrack1" );

        Groups.EnableAxis( Groups.group4 );

        SetAvailableMapGoals( TEAM.ALLIES, true, {
            "ATTACK_Bravo.*",
            "PLANT_Electric_Floor_Controls",
            "PLANT_Side_Gate",
        });

        // Move PLANT offset to the other side, and stay enabled
        // TODO: If dynamite management is removed, handle the cover spot...
        Util.SetGoalOffset( 0, 50, 0, "PLANT_Side_Gate" );

        Util.MapDebugPrint( "Generator_Hidden_Gate_Opened" );
    },

    Main_Entrance_Destroyed = function( trigger )
    {
        Map.isMainEntranceDestroyed = true;

        Groups.DisableAxis( Groups.group2 );
        Groups.EnableAxis( Groups.group3 );

        SetAvailableMapGoals( TEAM.ALLIES, true, "CHECKPOINT_courtyardflag" );
        SetAvailableMapGoals( TEAM.ALLIES, false, "ATTACK_Charlie.*" );

        if ( !Map.isGeneratorDestroyed )
        {
            SetAvailableMapGoals( TEAM.ALLIES, true, {
                "ATTACK_Dyna.*",
                "HEALTHCAB_kitchenhealthrack",
                "PLANT_Generator",
            });
        }

        Util.MapDebugPrint( "Main_Entrance_Destroyed" );
    },

    Side_Gate_Destroyed = function( trigger )
    {
        SetAvailableMapGoals( TEAM.AXIS, true, "BUILD_Side_Gate" );

        Util.MapDebugPrint( "Side_Gate_Destroyed" );
    },

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

    radarpart_Taken = function( trigger )
    {
        Map.isRadarPartStolen = true;

        Groups.DisableAxis( Groups.group4 );
        SetAvailableMapGoals( TEAM.AXIS, true, "DEFEND_Hotel.*" );

        SetAvailableMapGoals( TEAM.ALLIES, true, "DEFEND_Hotel.*" );
        SetAvailableMapGoals( TEAM.ALLIES, false, {
            "ATTACK_Bravo.*",
            "PLANT_Electric_Floor_Controls",
        });

        Util.MapDebugPrint( "radarpart_Taken" );
    },

    radarpart_Returned = function( trigger )
    {
        Map.isRadarPartStolen = false;

        Groups.EnableAxis( Groups.group4 );
        SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_Hotel.*" );

        // TODO: With offset update, PLANT_Side_Gate
        SetAvailableMapGoals( TEAM.ALLIES, true, {
            "ATTACK_Bravo.*",
            "PLANT_Electric_Floor_Controls",
        });
        SetAvailableMapGoals( TEAM.ALLIES, false, "DEFEND_Hotel.*" );

        Util.MapDebugPrint( "radarpart_Returned" );
    },

    radarpart_Secured = function( trigger )
    {
        // Map.isRadarPartStolen stays true

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

        SetAvailableMapGoals( TEAM.AXIS, true, {
            "DEFEND_Delta.*",
            "BUILD_Truck_Barrier",
            "MOBILEMG42_AxisOut1",
            "MOBILEMG42_AxisOut3",
        });

        SetAvailableMapGoals( TEAM.ALLIES, true, {
            "ESCORT_truck",
            "BUILD_Truck",
            "PLANT_Truck_Barrier",
            "SNIPE_AlliedHood2",
        });

        Util.MapDebugPrint( "radarpart_Secured" );
    },

    courtyardflag_Axis_Captured = function( trigger )
    {
        SetGoalPriority( "PLANT_Generator", 0.85 );

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

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

        Util.MapDebugPrint( "courtyardflag_Axis_Captured" );
    },

    courtyardflag_Allies_Captured = function( trigger )
    {
        SetGoalPriority( "PLANT_Generator", 1.0 );

        SetAvailableMapGoals( TEAM.AXIS, true, "CHECKPOINT_courtyardflag" );
        SetAvailableMapGoals( TEAM.AXIS, false, "MOBILEMORTAR_AxisStart" );

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

        Util.MapDebugPrint( "courtyardflag_Allies_Captured" );
    },

    truck_region_1 = function( trigger )
    {
        Util.ChangeSpawn( TEAM.ALLIES, 1 ); // Guest House

        SetAvailableMapGoals( TEAM.AXIS, true, {
            "ARTILLERY_S_AxisEnd",
            "CALLARTILLERY_AxisEnd",
            "MOUNTMG42_240",
            "DEFEND_End.*",
            "MOBILEMG42_AxisEnd",
            "MOBILEMORTAR_AxisEnd",
        });
        SetAvailableMapGoals( TEAM.AXIS, false, {
            "DEFEND_Delta.*",
            "MOBILEMG42_AxisOut1",
            "MOBILEMG42_AxisOut3",
        });

        SetAvailableMapGoals( TEAM.ALLIES, true, {
            "ARTILLERY_S_AlliedEnd",
            "ATTACK_Golf.*",
            "CALLARTILLERY_AlliedEnd",
            "MOBILEMG42_AlliedEnd",
            "MOBILEMORTAR_AlliedEnd",
        });

        Util.MapDebugPrint( "truck_region_1" );
    },

    truck_region_2 = function( trigger )
    {
        SetAvailableMapGoals( TEAM.AXIS, false, "BUILD_Truck_Barrier" );

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

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

global OnMapLoad = function()
{
    // *** TRIGGERS ***
    OnTrigger( "Allies have built the Assault Ramp!", Map.Assault_Ramp_Built );
    OnTrigger( "Axis Command Post constructed. Charge speed increased!", Map.Command_Post_Built );
    OnTrigger( "Axis have constructed the Courtyard MG!", Map.Courtyard_MG_Built );
    OnTrigger( "Axis have repaired the Electric Floor Controls!", Map.Electric_Floor_Controls_Built );
    OnTrigger( "Axis have constructed the Side Gate!", Map.Side_Gate_Built );
    OnTrigger( "The Truck has been repaired!", Map.Truck_Built );
    OnTrigger( "The Truck has been damaged!", Map.Truck_Destroyed );
    OnTrigger( "Axis have built the Truck Barrier!", Map.Truck_Barrier_Built );
    OnTrigger( "Planted at the Assault Ramp.", Map.Assault_Ramp_Planted );
    OnTrigger( "Planted at the Axis Command Post.", Map.Command_Post_Planted );
    OnTrigger( "Planted at the Courtyard MG.", Map.Courtyard_MG_Planted );
    OnTrigger( "Planted at the Electric Floor Controls.", Map.Electric_Floor_Controls_Planted );
    OnTrigger( "Planted at the Generator.", Map.Generator_Planted );
    OnTrigger( "Planted at the Main Entrance.", Map.Main_Entrance_Planted );
    OnTrigger( "Planted at the Side Gate.", Map.Side_Gate_Planted );
    OnTrigger( "Planted at the Truck Barrier.", Map.Truck_Barrier_Planted );
    OnTrigger( "Defused at the Assault Ramp.", Map.Assault_Ramp_Defused );
    OnTrigger( "Defused at the Axis Command Post.", Map.Command_Post_Defused );
    OnTrigger( "Defused at the Courtyard MG.", Map.Courtyard_MG_Defused );
    OnTrigger( "Defused at the Electric Floor Controls.", Map.Electric_Floor_Controls_Defused );
    OnTrigger( "Defused at the Generator.", Map.Generator_Defused );
    OnTrigger( "Defused at the Main Entrance.", Map.Main_Entrance_Defused );
    OnTrigger( "Defused at the Side Gate.", Map.Side_Gate_Defused );
    OnTrigger( "Defused at the Truck Barrier.", Map.Truck_Barrier_Defused );
    OnTrigger( "Axis have destroyed the Assault Ramp!", Map.Assault_Ramp_Destroyed );
    OnTrigger( "Allied team has destroyed the Axis Command Post!", Map.Command_Post_Destroyed );
    OnTrigger( "Allies have destroyed the Courtyard MG!", Map.Courtyard_MG_Destroyed );
    OnTrigger( "Allies have disabled the Electric Floor Controls!", Map.Electric_Floor_Controls_Destroyed );
    OnTrigger( "Allies have destroyed the Generator and secured the Courtyard Spawn!", Map.Generator_Destroyed );
    OnTrigger( "Allies have destroyed the Main Entrance!", Map.Main_Entrance_Destroyed );
    OnTrigger( "Allies have destroyed the Side Gate!", Map.Side_Gate_Destroyed );
    OnTrigger( "Allies have destroyed the Truck Barrier!", Map.Truck_Barrier_Destroyed );;
    OnTrigger( "Allies have taken the Radar Parts!", Map.radarpart_Taken );
    OnTrigger( "Axis have returned the Radar Parts!", Map.radarpart_Returned );
    OnTrigger( "Allies have secured the Radar Parts to the Truck!", Map.radarpart_Secured );
    OnTrigger( "Axis reclaim the Courtyard!", Map.courtyardflag_Axis_Captured );
    OnTrigger( "Allies capture the Courtyard!", Map.courtyardflag_Allies_Captured );

    // *** INITIAL AVAILABILITY OF GOALS ***
    Util.DisableGoal( ".*", true ); // All but routes

    SetAvailableMapGoals( TEAM.ALLIES, true, {
        "ATTACK_Charlie.*",
        "BUILD_Assault_Ramp",
        "MOBILEMORTAR_AlliedStart",
        "PLANT_Main_Entrance",
        "PLANT_Side_Gate",
        "SNIPE_AlliedHood",
    });

    Groups.EnableAxis( Groups.group1 );
    Groups.EnableAxis( Groups.group2 );

    // ** PRIORITY ***
    SetGoalPriority( "PLANT_Main_Entrance", 0.9 );
    SetGoalPriority( "BUILD_Electric_Floor_Controls", 0.9 );
    SetGoalPriority( "PLANT_Electric_Floor_Controls", 0.9 );
    SetGoalPriority( "PLANT_Generator", 0.85 );
    SetGoalPriority( "BUILD_Command_Post", 0.8 );
    SetGoalPriority( "PLANT_Command_Post", 0.8 );
    SetGoalPriority( "BUILD_Assault_Ramp", 0.7 );
    SetGoalPriority( "PLANT_Side_Gate", 0.7 );
    SetGoalPriority( "CHECKPOINT_courtyardflag", 0.6 );
    SetGoalPriority( "MOUNTMG42_.*", 0.5 );

    // *** MAX USERS PER GOAL ***
    Util.SetMaxUsersInProgress( 2, "BUILD_.*" );
    Util.SetMaxUsersInProgress( 2, "FLAG_.*" );
    Util.SetMaxUsersInProgress( 1, "ATTACK_.*" );
    Util.SetMaxUsersInProgress( 1, "DEFEND_.*" );
    Util.SetMaxUsersInProgress( 1, "PLANT_.*" );
    Util.SetMaxUsersInProgress( 1, "REPAIRMG42_.*" );

    // TODO: Don't forget that with switches
    //Elevator Stuff (Disabled)
    //Util.UpdateSwitchData();
    //OnTrigger( "elevator_goto", Map.Elevator1 );

    Util.AddUsePoint( "BUILD_Truck_Barrier", Vec3( 710, -2330, -50 ) );

    Util.SetGoalOffset( -100, 0, 250, "PLANT_Assault_Ramp" );
    Util.SetGoalOffset( -30, -100, 0, "PLANT_Truck_Barrier" );

    Util.OnTriggerPosition( "MOVER_truck", "region1", 200.0, Map.truck_region_1 );
    Util.OnTriggerPosition( "MOVER_truck", "region2", 200.0, Map.truck_region_2 );

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

    // TODO: What's this?
    Util.FixMoverPos( "truck", Vec3( -1881.500, -5193.000, -151.500 ), Vec3( -1736.000, -5192.000, -208.000 ) );

    Util.MapDebugPrint( "Omni-bot map script for Chateau Voilegarde (Beta 3) by Mateos" );
};

global OnBotJoin = function( bot )
{
    bot.TargetBreakableDist = 90.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 )
    {
        bot.GetWeapon( weap ).PrimaryFire.SetTargetBias( CLASS.BREAKABLE, 1.2 );
    }

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

global InitializeRoutes = function()
{
    MapRoutes =
    {
        BUILD_Assault_Ramp =
        {
            ROUTE_GuestHouse1 =
            {
                ROUTE_GuestHouseEast1 =
                {
                    ROUTE_GuestHouseEast2 = {},
                },
            },
            ROUTE_GuestHouse2 =
            {
                ROUTE_GuestHouseEast1 =
                {
                    ROUTE_GuestHouseEast2 = {},
                },
            },
            ROUTE_GuestHouse3 =
            {
                ROUTE_GuestHouseEast1 =
                {
                    ROUTE_GuestHouseEast2 = {},
                },
            },
        },

        CAPPOINT_Truck =
        {
            ROUTE_PartTaken  =
            {
                ROUTE_Escape1  =
                {
                    ROUTE_Escape2  =
                    {
                        ROUTE_BunkerWay1  = {},
                    },
                    ROUTE_BunkerBis2  =
                    {
                        ROUTE_BunkerBis1  =
                        {
                            ROUTE_BunkerWay1  = {},
                        },
                    },
                },
            },
        },

        CHECKPOINT_courtyardflag =
        {
            ROUTE_Laboratory  =
            {
                Weight = 5,
                ROUTE_FlagRecovery1  =
                {
                    ROUTE_FlagRecovery2  =
                    {
                        ROUTE_FlagRecovery3  = {},
                    },
                    ROUTE_FlagRecoveryD1  =
                    {
                        ROUTE_FlagRecoveryD2  = {},
                    },
                },
            },
        },

        PLANT_Electric_Floor_Controls =
        {
            ROUTE_Courtyard =
            {
                Weight = 1,
                ROUTE_BunkerWay1 =
                {
                    Weight = 1,
                    ROUTE_BunkerStairs1 =
                    {
                        ROUTE_BunkerStairs2 = {},
                    },
                    Weight = 4,
                    ROUTE_BunkerBis1 =
                    {
                        ROUTE_BunkerBis2 = {},
                    },
                },
                Weight = 4,
                ROUTE_HouseWay1 =
                {
                    ROUTE_HouseWay2 =
                    {
                        ROUTE_HouseWay3 = {},
                    },
                },

            },
        },

        PLANT_Side_Gate =
        {
            ROUTE_GuestHouse1 =
            {
                ROUTE_GuestHouseWest1 =
                {
                    ROUTE_GuestHouseWest2 = {},
                },
            },
            ROUTE_GuestHouse2 =
            {
                ROUTE_GuestHouseWest1 =
                {
                    ROUTE_GuestHouseWest2 = {},
                },
            },
            ROUTE_GuestHouse3 =
            {
                ROUTE_GuestHouseWest1 =
                {
                    ROUTE_GuestHouseWest2 = {},
                },
            },
        },
    };

    // Copy routes
    MapRoutes.CHECKPOINT_courtyardflag = MapRoutes.BUILD_Assault_Ramp;
    MapRoutes.ATTACK_Bravo1 = MapRoutes.PLANT_Electric_Floor_Controls;
    MapRoutes.ATTACK_Bravo2 = MapRoutes.PLANT_Electric_Floor_Controls;
    MapRoutes.ATTACK_Bravo3 = MapRoutes.PLANT_Electric_Floor_Controls;
    MapRoutes.ATTACK_Bravo4 = MapRoutes.PLANT_Electric_Floor_Controls;
    MapRoutes.ATTACK_Bravo5 = MapRoutes.PLANT_Electric_Floor_Controls;
    MapRoutes.ATTACK_Bravo6 = MapRoutes.PLANT_Electric_Floor_Controls;
    MapRoutes.ATTACK_Bravo7 = MapRoutes.PLANT_Electric_Floor_Controls;

    Util.Routes( MapRoutes );
};

global Groups =
{
    // Command Post
    group1 =
    {
        "BUILD_Command_Post",
        "PLANT_Command_Post",
    },

    // Axis Part 1: Map beginning
    group2 =
    {
        "ARTILLERY_D_AxisStart.*",
        "BUILD_Courtyard_MG",
        "DEFEND_start.*",
        "CALLARTILLERY_AxisStart.*",
        "MOBILEMG42_AxisOut1",
        "MOBILEMG42_AxisOut2",
        "MOBILEMG42_AxisOut3",
        "MOBILEMORTAR_AxisStart",
        "SNIPE_AxisHood",
        "SNIPE_CastleFrontLeft",
        "SNIPE_CastleFrontRight",
        "SNIPE_CastleLeft",
    },

    // Axis Part 2: Main Entrance destroyed
    group3 =
    {
        "DEFEND_Foxtrot.*",
        "HEALTHCAB_kitchenhealthrack",
        "MOBILEMG42_AxisIn1",
        "MOBILEMG42_AxisIn2",
        "MOUNTMG42_Courtyard_MG",
        "REPAIRMG42_Courtyard_MG",
        "SNIPE_MainDoor",
    },

    // Axis Part 3: Generator destroyed
    group4 =
    {
        "BUILD_Side_Gate",
        "BUILD_Electric_Floor_Controls",
        "DEFEND_Alpha.*",
        "MOBILEMG42_AxisBunker1",
        "MOBILEMG42_AxisBunker2",
    },

    EnableAllies = function( group )
    {
        foreach ( id and goal in group )
        {
            SetAvailableMapGoals( TEAM.ALLIES, true, goal );
        }
    },

    EnableAxis = function( group )
    {
        foreach ( id and goal in group )
        {
            SetAvailableMapGoals( TEAM.AXIS, true, goal );
        }
    },

    DisableAllies = function( group )
    {
        foreach ( id and goal in group )
        {
            SetAvailableMapGoals( TEAM.ALLIES, false, goal );
        }
    },

    DisableAxis = function(group)
    {
        foreach ( id and goal in group )
        {
            SetAvailableMapGoals( TEAM.AXIS, false, goal );
        }
    },
};
