//-------------------------------------------------------------------
//
//  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 15 -- Survival
//
///////////////////////////////////
class CMission15_AIController extends CBaseAIController, CNavPointUser, CSurvivalMission_Strings
{
  array  ActivatePointCenterList = array(
    vector( 6622, 4148, 0 )     //
    );    //
  array  ActivatePointRadiusList = array(
    100.0                       //
    );
  array  ActivatePointNameList = array(
    "A"
    );

  int MissionStartTime     = 0;          // Time initialized

  final int m_GTobruqStartTime   = 5000;
  final int m_GAqaliaStartTime   = 20000;
  final int m_GBenghaziStartTime = 30000;
  final int m_BwairatStartTime   = 105000;

  boolean GTobruqStarted   = false;
  boolean GAqaliaStarted   = false;
  boolean GBenghaziStarted = false;
  boolean BwairatStarted   = false;

  void Init( int _Time )
  {
    MissionStartTime = _Time;
  }
  void Update( int _Time )
  {
    if ( (_Time>= (MissionStartTime + m_GTobruqStartTime)) && ( !GTobruqStarted ) )
     {
       GTobruqStarted = true;
       Core_SendEventTo( "Helicopter",
          "OnDisplayMessage",
          str_TobruqPatrol,
          color(1.0, 0.0, 0.0));
       Core_BroadcastEvent("GTobruqStarted");
     }
    if ( (_Time>= (MissionStartTime + m_GAqaliaStartTime)) && ( !GAqaliaStarted ) )
     {
       GAqaliaStarted = true;
       Core_SendEventTo( "Helicopter",
          "OnDisplayMessage",
          str_AqaliaPatrol,
          color(1.0, 0.0, 0.0));
       Core_BroadcastEvent("GAqaliaStarted");
     }
    if ( (_Time>= (MissionStartTime + m_GBenghaziStartTime)) && ( !GBenghaziStarted ) )
     {
       GBenghaziStarted = true;
       Core_SendEventTo( "Helicopter",
          "OnDisplayMessage",
          str_BenghaziPatrol,
          color(1.0, 0.0, 0.0));
       Core_BroadcastEvent("GBenghaziStarted");
     }
    if ( (_Time>= (MissionStartTime + m_BwairatStartTime)) && ( !BwairatStarted ) )
     {
       BwairatStarted = true;
       Core_BroadcastEvent("BwairatStarted");
     }

  }

  boolean m_ConvoyGetNavPoint   = false;
  boolean m_BwairatGetNavPoint  = false;

  void OnObjectEnterArea( int _AreaIndex, string _NavPointName, string _ObjectID)
  {
    if ( Core_IsStringStartsWith( _NavPointName, "NavPoint_02") && Core_IsStringStartsWith( _ObjectID, "15_G") && !m_ConvoyGetNavPoint )
    {
      m_ConvoyGetNavPoint = true;
       Core_SendEventTo( "Helicopter",
          "OnDisplayMessage",
          str_GermanConvoyRichThePoint,
          color(1.0, 0.0, 0.0));
      Core_BroadcastEvent("ConvoyGetNavPoint_02");
    }
    if ( Core_IsStringStartsWith( _NavPointName, "NavPoint_03") && Core_IsStringStartsWith( _ObjectID, "15_Bwairat") && !m_BwairatGetNavPoint )
    {
      m_BwairatGetNavPoint = true;
      Core_BroadcastEvent("BwairatStopped");
    }

  }
}
//================================================================================
class C15_GTobruq extends CNavPointUser, CBaseAITask_Patrol
{
  array GetPatrolTrip()
    {
      return array (GetNavPoint("NavPoint_01"),
                    GetNavPoint("NavPoint_02"),
                    GetNavPoint("NavPoint_03"));
    }
  float GetTripSpeed()
    {
      return 25;
    }
  void Init()
    {
       DeactivatePatrol();
    }
  void GTobruqStarted()
    {
      ActivatePatrol();
    }
  void OnEnemyOnRadar()
    {
    }
  void Wave1MemberStopped( string _idConvoy )
    {
      if ( _idConvoy == "Tobruq")
       {
         DeactivatePatrol();
       }
    }

}
//----------------------------------------------------------------------------
class C15_GAqalia extends C15_GTobruq
{
  float GetTripSpeed()
    {
      return 28;
    }
  void GTobruqStarted()
    {
    }
  void GAqaliaStarted()
    {
      ActivatePatrol();
    }
  void Wave1MemberStopped( string _idConvoy )
    {
      if ( _idConvoy == "Aqalia")
       {
         DeactivatePatrol();
       }
    }
}
//---------------------------------------------------------------------------
class C15_GBenghazi extends C15_GTobruq
{
  float GetTripSpeed()
    {
      return 25;
    }
  void GTobruqStarted()
    {
    }
  void GBenghaziStarted()
    {
      ActivatePatrol();
    }
  void Wave1MemberStopped( string _idConvoy )
    {
      if ( _idConvoy == "Benghazi")
       {
         DeactivatePatrol();
       }
    }
}
//---------------------------------------------------------------------------------
class C15_GBenghaziTank extends C15_GBenghazi
{
  float GetTripSpeed()
    {
      return 25;
    }
  void GTobruqStarted()
    {
    }
  void GBenghaziStarted()
    {
      ActivatePatrol();
    }
  void OnEnemyOnRadar()
    {
    }
  void Wave1MemberStopped( string _idConvoy )
    {
      if ( _idConvoy == "Benghazi")
       {
         DeactivatePatrol();
       }
    }
}
//----------------------------------------------------------------------------------
class C15_Bwairat extends C15_GTobruq
{
  array GetPatrolTrip()
    {
      return array (GetNavPoint("NavPoint_02"),
                    GetNavPoint("NavPoint_03"));
    }
  float GetTripSpeed()
    {
      return 25;
    }
  void GTobruqStarted()
    {
    }
  void BwairatStarted()
    {
      ActivatePatrol();
    }
  void BwairatStopped( )
    {
      DeactivatePatrol();
    }
  void Wave1MemberStopped( string _idConvoy )
    {
    }
}

