// Map script for vesuvius_b1 by d00d
// Compatible with Omni-bot 0.7

global Map =
{
  Movers =
  {
    "MOVER_truck",
  },

  EscortVehicle =
  {
    Truck =
    {
      EscortVehicleGoalName = "MOVER_truck",
      Offset = 
      {
        Vector3(15,-40,0),
        Vector3(-15,-40,0),
      }
    },
  },

  east_Gate_Breached = function()
  {
    //print("east_Gate_Breached");
    SetAvailableMapGoals(TEAM.AXIS, false, "DEFEND_east_gate.*");
    SetAvailableMapGoals(TEAM.ALLIES, false, "ATTACK_east_gate.*");
    SetAvailableMapGoals(TEAM.AXIS, false, "SNIPE_east_gate.*");
  },

  south_Gate_Breached = function()
  {
    //print("south_Gate_Breached");
    SetAvailableMapGoals(TEAM.AXIS, false, "DEFEND_south_gate.*");
    SetAvailableMapGoals(TEAM.AXIS, false, "SNIPE_south_gate.*");
  },

  west_Gate_Breached = function()
  {
    //print("west_Gate_Breached");
  },

  urn_Stolen = function()
  {
    //print("urn_Stolen");
    SetAvailableMapGoals(TEAM.AXIS, true, "SNIPE_cappoint.*");
    SetAvailableMapGoals(TEAM.ALLIES, true, "SNIPE_cappoint.*");
    SetAvailableMapGoals(TEAM.AXIS, false, "DEFEND_urn.*");
    SetAvailableMapGoals(TEAM.AXIS, true, "ATTACK_cappoint.*");
    SetAvailableMapGoals(TEAM.ALLIES, true, "ATTACK_cappoint.*");
    Util.ResetGoals();
  },

  urn_Returned = function()
  {
    //print("urn_Returned");
    SetAvailableMapGoals(TEAM.AXIS, false, "SNIPE_cappoint.*");
    SetAvailableMapGoals(TEAM.ALLIES, false, "SNIPE_cappoint.*");
    SetAvailableMapGoals(TEAM.AXIS, true, "DEFEND_urn.*");
    SetAvailableMapGoals(TEAM.AXIS, false, "ATTACK_cappoint.*");
    SetAvailableMapGoals(TEAM.ALLIES, false, "ATTACK_cappoint.*");
    Util.ResetGoals();    
  },

  urn_Secured = function()
  {
    //print("urn_Secured");
    SetAvailableMapGoals(TEAM.ALLIES, true, "MOVER_truck");
    SetAvailableMapGoals(TEAM.AXIS, false, "DEFEND_urn.*");
    SetAvailableMapGoals(TEAM.AXIS, false, "ATTACK_cappoint.*");
    SetAvailableMapGoals(TEAM.ALLIES, true, "ATTACK_south_gate.*");
    SetAvailableMapGoals(TEAM.AXIS, true, "DEFEND_south_gate.*");
    SetAvailableMapGoals(TEAM.AXIS, true, "SNIPE_south_gate.*");
    SetAvailableMapGoals(TEAM.ALLIES, false, "ATTACK_cappoint.*");
    SetAvailableMapGoals(TEAM.ALLIES, false, "PLANT_west_ruins_gate");
    SetAvailableMapGoals(TEAM.ALLIES, true, "BUILD_truck_ramp");
    SetAvailableMapGoals(TEAM.ALLIES, false, "BUILD_ruins_access_rope");
    SetAvailableMapGoals(TEAM.AXIS, false, "PLANT_ruins_access_rope");
    SetAvailableMapGoals(TEAM.AXIS, true, "PLANT_truck_ramp");
    SetAvailableMapGoals(TEAM.ALLIES, false, "ATTACK_east_gate.*");
    SetAvailableMapGoals(TEAM.AXIS, false, "DEFEND_east_gate.*");
    SetAvailableMapGoals(TEAM.ALLIES, true, "BUILD_Truck");
    Util.OnTriggerPosition("MOVER_truck", "corner1", 200, Map.truck_at_corner1);
    Util.ResetGoals();
  },

  truck_at_corner1 = function()
  {
    //print("truck_at_corner1");
    SetAvailableMapGoals(TEAM.AXIS, false, "MOUNTMG42_.*");
    SetAvailableMapGoals(TEAM.AXIS, false, "SNIPE_cappoint.*");
    SetAvailableMapGoals(TEAM.ALLIES, false, "SNIPE_cappoint.*");
    Util.OnTriggerPosition("MOVER_truck", "corner2", 200, Map.truck_at_corner2);
  },

  truck_at_corner2 = function()
  {
    //print("truck_at_corner2");
    SetAvailableMapGoals(TEAM.ALLIES, false, "ATTACK_south_gate.*");
    SetAvailableMapGoals(TEAM.AXIS, false, "DEFEND_south_gate.*");
    SetAvailableMapGoals(TEAM.ALLIES, true, "ATTACK_east_gate.*");
    SetAvailableMapGoals(TEAM.AXIS, true, "DEFEND_east_gate.*");
    SetAvailableMapGoals(TEAM.AXIS, true, "SNIPE_east_gate.*");
    SetAvailableMapGoals(TEAM.AXIS, false, "SNIPE_south_gate.*");
    Util.OnTriggerPosition("MOVER_truck", "corner3", 200, Map.truck_at_corner3);
  },

  truck_at_corner3 = function()
  {
    SetAvailableMapGoals(TEAM.ALLIES, true, "ATTACK_showdown.*");
    SetAvailableMapGoals(TEAM.AXIS, true, "DEFEND_showdown.*");
    SetAvailableMapGoals(TEAM.ALLIES, false, "ATTACK_east_gate.*");
    SetAvailableMapGoals(TEAM.AXIS, false, "DEFEND_east_gate.*");
    SetAvailableMapGoals(TEAM.AXIS, false, "SNIPE_east_gate.*");
    //print("truck_at_corner3");
  },

};

global OnMapLoad = function()
{
  // *** TRIGGERS ***
  OnTrigger( "Allied team has breached the east gate", Map.east_Gate_Breached );
  OnTrigger( "Allied team has breached the south valley gate", Map.south_Gate_Breached );
  OnTrigger( "Allied team has breached the west ruins gate", Map.west_Gate_Breached );
  OnTrigger( "Allies have stolen The Urn!", Map.urn_Stolen );
  OnTrigger( "Flag returned The Urn!", Map.urn_Returned );
  OnTrigger( "Allied team is escaping with the urn!", Map.urn_Secured );

  // Move some goals for reachability
  Util.SetGoalOffset( 30,30,-10, "BUILD_truck_ramp" );
  rope_target = GetGoal( "PLANT_ruins_access_rope" );
  if(rope_target)
  {
    new_pos = Util.GetWpNamePosition( "rope_dyno" ) + Vector3(0,0,400);
    rope_target.SetPosition( new_pos );
    rope_target.DynamicPosition = false;
  }

  Util.SetMaxUsersInProgress( 1, "DEFEND_.*" );
  Util.SetMaxUsersInProgress( 1, "MOUNTMG42_.*" );
  Util.SetMaxUsersInProgress( 1, "SNIPE_.*" );
  Util.SetMaxUsersInProgress( 1, "BUILD_.*" );
  Util.SetMaxUsersInProgress( 1, "PLANT_.*" );
  SetGoalPriority("PLANT_.*", 0.9);

  SetAvailableMapGoals(TEAM.ALLIES, false, "MOUNTMG42_.*");
  SetAvailableMapGoals(TEAM.ALLIES, false, "BUILD_truck_ramp");
  SetAvailableMapGoals(TEAM.ALLIES, false, "BUILD_Truck");
  SetAvailableMapGoals(TEAM.ALLIES, false, "ATTACK_.*");
  SetAvailableMapGoals(TEAM.ALLIES, false, "DEFEND_.*");
  SetAvailableMapGoals(TEAM.ALLIES, false, "SNIPE_.*");
  SetAvailableMapGoals(TEAM.ALLIES, false, "MOVER_truck");
  SetAvailableMapGoals(TEAM.ALLIES, true, "ATTACK_east_gate.*");

  SetAvailableMapGoals(TEAM.AXIS, false, "CHECKPOINT_.*");
  SetAvailableMapGoals(TEAM.AXIS, false, "ATTACK_.*");
  SetAvailableMapGoals(TEAM.AXIS, true, "DEFEND_.*");
  SetAvailableMapGoals(TEAM.AXIS, false, "DEFEND_showdown.*");
  print("Omni-bot map script loaded.");
};

global OnBotJoin = function( bot )
{
  // Tweak these settings appropriately:
  // bot.MaxViewDistance = 2400.0;
  // bot.TargetBreakableDist = 200.0;
};
