//-------------------------------------------------------------------
//
//  This code is copyright 2001 by G5 Software.
//  Any unauthorized usage, either in part or in whole of this code
//  is strictly prohibited. Violators WILL be prosecuted to the
//  maximum extent allowed by law.
//
//-------------------------------------------------------------------

///////////////////////////////////
//
// Mission 14 -- Eliminate Descent
//
///////////////////////////////////
class CMission14_AIController extends CBaseAIController, CEliminateDescentMission_Strings
{
  array  ActivatePointCenterList = array(
    vector( 6622, 4148, 0 )     //
    );    //
  array  ActivatePointRadiusList = array(
    100.0                       //
    );
  array  ActivatePointNameList = array(
    "A"
    );

  int MissionStartTime     = 0;          // Time initialized

  int ZillahTroops   = 10000;      // Start group 1 paratroopers
  int BwairatTroops  = 180000;      // Start group 2 paratroopers
  int BenghaziTroops = 80000;      // Start group 3 paratroopers
//  int ZillahTroops   = 100000000;      // Start group 1 paratroopers
//  int BwairatTroops  = 180000000;      // Start group 2 paratroopers
//  int BenghaziTroops = 900000000;      // Start group 3 paratroopers

  boolean ZillahTroopsUp   = false;
  boolean BwairatTroopsUp  = false;
  boolean BenghaziTroopsUp = false;

  void Init( int _Time )
  {
    MissionStartTime = _Time;
  }
  void Update( int _Time )
  {
    if ( (_Time>= (MissionStartTime + ZillahTroops)) && ( !ZillahTroopsUp ) )
     {
       ZillahTroopsUp = true;
       Core_SendEventTo( "Helicopter",
          "OnDisplayMessage",
          str_ZilahDropped,
          color(0.5, 05, 0.0));
       Core_ScheduleTask(SOID_MissionController,
                         OT_SendEventTo,
                         0.1,
                         "GenerateParatroopers",
                         "14_PZillahFlak",                // Name of group w/o number
                         2,                              // Groups amount
                         4,                              // Paratroopers in group
                         vector(5400.0, 10730.0, 450.0), // point of landing
                         150.0,                          // Radius
                         30.0,                           // Hight
                         "14_ZillahFlak",                // Name of unit after landing
                         "CGermanMobileFlak",            // Class of unit after landing
                         2,                              // Min troopers amount for unit creating
                         2.0                             // Distribution time for paratroopers creation
                       );
       Core_ScheduleTask(SOID_MissionController,
                         OT_SendEventTo,
                         0.3,
                         "GenerateParatroopers",
                         "14_PZillahAA",                  // Name of group w/o number
                         5,                              // Groups amount
                         4,                              // Paratroopers in group
                         vector(5400.0, 10730.0, 400.0), // point of landing
                         150.0,                          // Radius
                         30.0,                           // Hight
                         "14_ZillahAA",                  // Name of unit after landing
                         "CGermanAntiair",               // Class of unit after landing
                         2,                              // Min troopers amount for unit creating
                         2.0                             // Distribution time for paratroopers creation
                       );
       Core_ScheduleTask(SOID_MissionController,
                         OT_SendEventTo,
                         0.5,
                         "GenerateParatroopers",
                         "14_PZillahJeep",                // Name of group w/o number
                         4,                              // Groups amount
                         4,                              // Paratroopers in group
                         vector(5400.0, 10730.0, 400.0), // point of landing
                         150.0,                          // Radius
                         30.0,                           // Hight
                         "14_ZillahJeep",                // Name of unit after landing
                         "CGermanAJeep",                 // Class of unit after landing
                         2,                              // Min troopers amount for unit creating
                         2.0                             // Distribution time for paratroopers creation
                       );
//       Core_SendEventTo(
//                 "Helicopter",
//                 "ShowEventPoint",
//                 vector(5400.0, 10730.0, 400.0), //     - id of object to show
//                 100.0,                          //     - distance from camera to object
//                 false
//               );
         Core_ScheduleTask(
                 "Helicopter",
                 OT_SendEventTo,
                 2.5,
                 "ShowEventPoint",
                 vector(5400.0, 10730.0, 400.0),
                 100.0,
                 false
               );
     }
//    if ( (_Time>= (MissionStartTime + BwairatTroops)) && ( !BwairatTroopsUp ) )
//     {
//       BwairatTroopsUp = true;
//       Core_SendEventTo( "Helicopter",
//          "OnDisplayMessage",
//          str_BwairatDropped,
//          color(1.0, 0.0, 0.0));
//
//     }
    if ( (_Time>= (MissionStartTime + BenghaziTroops)) && ( !BenghaziTroopsUp ) )
     {
       BenghaziTroopsUp = true;
       Core_SendEventTo( "Helicopter",
          "OnDisplayMessage",
          str_BenghaziDropped,
          color(0.5, 0.5, 0.0));
       Core_ScheduleTask(SOID_MissionController,
                         OT_SendEventTo,
                         0.1,
                         "GenerateParatroopers",
                         "14_PBenghaziFlak",              // Name of group w/o number
                         2,                              // Groups amount
                         4,                              // Paratroopers in group
                         vector(5400.0, 10730.0, 450.0), // point of landing
                         150.0,                          // Radius
                         30.0,                           // Hight
                         "14_BenghaziFlak",              // Name of unit after landing
                         "CGermanMobileFlak",            // Class of unit after landing
                         2,                              // Min troopers amount for unit creating
                         2.0                             // Distribution time for paratroopers creation
                       );
       Core_ScheduleTask(SOID_MissionController,
                         OT_SendEventTo,
                         0.3,
                         "GenerateParatroopers",
                         "14_PBenghaziAA",                // Name of group w/o number
                         5,                              // Groups amount
                         4,                              // Paratroopers in group
                         vector(5400.0, 10730.0, 400.0), // point of landing
                         150.0,                          // Radius
                         30.0,                           // Hight
                         "14_BenghaziAA",                // Name of unit after landing
                         "CGermanAntiair",               // Class of unit after landing
                         2,                              // Min troopers amount for unit creating
                         2.0                             // Distribution time for paratroopers creation
                       );
       Core_ScheduleTask(SOID_MissionController,
                         OT_SendEventTo,
                         0.5,
                         "GenerateParatroopers",
                         "14_PBenghaziJeep",              // Name of group w/o number
                         4,                              // Groups amount
                         4,                              // Paratroopers in group
                         vector(5400.0, 10730.0, 400.0), // point of landing
                         150.0,                          // Radius
                         30.0,                           // Hight
                         "14_BenghaziJeep",              // Name of unit after landing
                         "CGermanAJeep",                 // Class of unit after landing
                         2,                              // Min troopers amount for unit creating
                         2.0                             // Distribution time for paratroopers creation
                       );
         Core_ScheduleTask(
                 "Helicopter",
                 OT_SendEventTo,
                 2.5,
                 "ShowEventPoint",
                 vector(5400.0, 10730.0, 400.0),
                 100.0,
                 false
               );
     }
    if ( (_Time>= (MissionStartTime + BwairatTroops)) && ( !BwairatTroopsUp ) )
     {
       BwairatTroopsUp = true;
       Core_SendEventTo( "Helicopter",
          "OnDisplayMessage",
          str_BwairatDropped,
          color(0.5, 0.5, 0.0));
       Core_ScheduleTask(SOID_MissionController,
                         OT_SendEventTo,
                         0.1,
                         "GenerateParatroopers",
                         "14_PBwairatFlak",               // Name of group w/o number
                         2,                              // Groups amount
                         2,                              // Paratroopers in group
                         vector(5400.0, 10730.0, 450.0), // point of landing
                         150.0,                          // Radius
                         30.0,                           // Hight
                         "14_BwairatFlak",               // Name of unit after landing
                         "CGermanMobileFlak",            // Class of unit after landing
                         2,                              // Min troopers amount for unit creating
                         2.0                             // Distribution time for paratroopers creation
                       );
       Core_ScheduleTask(SOID_MissionController,
                         OT_SendEventTo,
                         0.3,
                         "GenerateParatroopers",
                         "14_PBwairatAA",                 // Name of group w/o number
                         4,                              // Groups amount
                         4,                              // Paratroopers in group
                         vector(5400.0, 10730.0, 400.0), // point of landing
                         150.0,                          // Radius
                         30.0,                           // Hight
                         "14_BwairatAA",                 // Name of unit after landing
                         "CGermanAntiair",               // Class of unit after landing
                         2,                              // Min troopers amount for unit creating
                         2.0                             // Distribution time for paratroopers creation
                       );
       Core_ScheduleTask(SOID_MissionController,
                         OT_SendEventTo,
                         0.5,
                         "GenerateParatroopers",
                         "14_PBwairatJeep",               // Name of group w/o number
                         2,                              // Groups amount
                         4,                              // Paratroopers in group
                         vector(5400.0, 10730.0, 400.0), // point of landing
                         150.0,                          // Radius
                         30.0,                           // Hight
                         "14_BwairatJeep",               // Name of unit after landing
                         "CGermanAJeep",                 // Class of unit after landing
                         2,                              // Min troopers amount for unit creating
                         2.0                             // Distribution time for paratroopers creation
                       );
         Core_ScheduleTask(
                 "Helicopter",
                 OT_SendEventTo,
                 2.5,
                 "ShowEventPoint",
                 vector(5400.0, 10730.0, 400.0),
                 100.0,
                 false
               );
     }
  }

  boolean m_ZillahCaptured   = false;
  boolean m_BenghaziCaptured = false;
  boolean m_BwairatCaptured  = false;

  void OnObjectEnterArea( int _AreaIndex, string _NavPointName, string _ObjectID)
  {
    if (    Core_IsStringStartsWith( _NavPointName, "NavPoint_04")
         && Core_IsStringStartsWith( _ObjectID, "14_Zillah") && !m_ZillahCaptured )
    {
      Core_SendEventTo( "Helicopter",
          "OnDisplayMessage",
          str_ZillahCaptured,
          color(1.0, 0.0, 0.0));
      Core_BroadcastEvent("ZillahDescentArrival");
      m_ZillahCaptured = true;
    }
    if (    Core_IsStringStartsWith( _NavPointName, "NavPoint_02")
         && Core_IsStringStartsWith( _ObjectID, "14_Benghazi") && !m_BenghaziCaptured )
    {
      Core_SendEventTo( "Helicopter",
          "OnDisplayMessage",
          str_BenghaziCaptured,
          color(1.0, 0.0, 0.0));
      Core_BroadcastEvent("BenghaziDescentArrival");
      m_BenghaziCaptured = true;
    }
    if (    Core_IsStringStartsWith( _NavPointName, "NavPoint_03")
         && Core_IsStringStartsWith( _ObjectID, "14_Bwairat") && !m_BwairatCaptured )
    {
      Core_SendEventTo( "Helicopter",
          "OnDisplayMessage",
          str_BwairatCaptured,
          color(1.0, 0.0, 0.0));
      Core_BroadcastEvent("BwairatDescentArrival");
      m_BwairatCaptured = true;
    }
  }
}
class C14_ZillahDescent extends CBaseAITask_BaseTask, CNavPointUser
{
  vector   DestinationPoint        = vector( 6644, 4124, 0 );//GetNavPoint("NavPoint_04"); // where to go
  vector   FormationVector         = vector( 25, 0, 0);
  vector   PointOfFire             = vector( 2100, 3485, 130 );
  float    CruiserSpeed            = 29; // autocade with guard should keep this speed
  float    RunSpeed                = 29; // autocade wo guards should keep this speed
  float    OvertakeSpeed           = 32; // maximum allowed speed for overtake
  boolean  OnTanksStops             = false;

  boolean Moving = false;

  void ClearState()
  {
    Moving    = false;
  }

  void Init()
   {
    SetFireStyle_Nearest();
    DestinationPoint = GetNavPoint("NavPoint_04");
    SetOrder_MoveTo( DestinationPoint, CruiserSpeed);
   }
}
//-------------------------------------------------------------------------------------------
class C14_BenghaziDescent extends CBaseAITask_BaseTask, CNavPointUser
{
  vector   DestinationPoint        = vector( 6644, 4124, 0 );//GetNavPoint("NavPoint_04"); // where to go
  vector   FormationVector         = vector( 25, 0, 0);
  vector   PointOfFire             = vector( 2100, 3485, 130 );
  float    CruiserSpeed            = 30; // autocade with guard should keep this speed
  float    RunSpeed                = 29; // autocade wo guards should keep this speed
  float    OvertakeSpeed           = 32; // maximum allowed speed for overtake
  boolean  OnTanksStops            = false;

  boolean Moving = false;

  void ClearState()
  {
    Moving    = false;
  }

  void Init()
   {
    SetFireStyle_Nearest();
    DestinationPoint = GetNavPoint("NavPoint_02");
    SetOrder_MoveTo( DestinationPoint, CruiserSpeed);
   }
}
//--------------------------------------------------------------------------------------------------
class C14_BwairatDescent extends CBaseAITask_BaseTask, CNavPointUser
{
  vector   DestinationPoint        = vector( 6644, 4124, 0 );//GetNavPoint("NavPoint_04"); // where to go
  vector   FormationVector         = vector( 25, 0, 0);
  vector   PointOfFire             = vector( 2100, 3485, 130 );
  float    CruiserSpeed            = 20; // autocade with guard should keep this speed
  float    RunSpeed                = 29; // autocade wo guards should keep this speed
  float    OvertakeSpeed           = 32; // maximum allowed speed for overtake
  boolean  OnTanksStops            = false;

  boolean Moving = false;

  void ClearState()
  {
    Moving    = false;
  }

  void Init()
   {
    SetFireStyle_Nearest();
    DestinationPoint = GetNavPoint("NavPoint_03");
    SetOrder_MoveTo( DestinationPoint, CruiserSpeed);
   }
}

