//-------------------------------------------------------------------
//
//  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 13 -- Support Aerial Attack
//
///////////////////////////////////

class CMission13_AIController extends CBaseAIController, CSupportAerialAttackMission_Strings, CMissionMessageColors
{
  array  ActivatePointCenterList = array(
    vector( 6622, 4148, 0 )     // Soviet Katusha Point of Fire
    );    //
  array  ActivatePointRadiusList = array(
    100.0                       //
    );
  array  ActivatePointNameList = array(
    "A"
    );
  int m_StartTime         = 0;
  int m_ShowTimeToScreen  = 0;
  int m_StartMissionTime  = 10000;
  int m_EndTobruqTime     = 200000;
  int m_EndAlAqaliaTime   = 410000;

  boolean m_TobruqOnTimer = true;
  boolean m_StartTobruq = false;
  boolean m_AlAqaliaOnTimer = true;

  void Objective1_Complete()
   {
     m_TobruqOnTimer = false;
   }
  void Objective2_Complete()
   {
     m_AlAqaliaOnTimer = false;
     Core_SendEventTo( "Helicopter",
              "OnDisplayMessage",
              str_BeforeAlAqaliaComplete,
              m_GoodNewsColor);
   }
  void Init( int _Time )
  {
      m_StartTime  = _Time;
  }
  void Update( int _Time )
  {
    if ( ((_Time - m_StartTime) >= m_StartMissionTime) && (!m_StartTobruq) )
       {
          m_StartTobruq = true;
          m_StartTime = _Time;
       }
    if ( m_TobruqOnTimer && m_StartTobruq )
       {
         m_ShowTimeToScreen = m_EndTobruqTime-(_Time - m_StartTime);
       }
    if ( !m_TobruqOnTimer && m_AlAqaliaOnTimer)
       {
         m_ShowTimeToScreen = m_EndAlAqaliaTime-(_Time - m_StartTime);
       }
    if ( m_TobruqOnTimer && m_StartTobruq )
     {
        Core_SendEventTo( "Helicopter",
          "OnDisplayMessage",
          str_BeforeTobruqBombing + (m_ShowTimeToScreen/1000) + str_Sec,
          m_ReminderColor);
      if ( _Time >= (m_StartTime + m_EndTobruqTime) )
      {
        m_TobruqOnTimer = false;
        Core_BroadcastEvent("OnTobruqTumeUp");
      }
     }
    if ( m_AlAqaliaOnTimer && !m_TobruqOnTimer)
     {
       //Core_LogMessage("Al-Aqaliaa boolean variables: m_AlAqaliaOnTimer = "+m_AlAqaliaOnTimer+" m_TobruqOnTimer = "+m_TobruqOnTimer);
       //Core_LogMessage("And _Time = "+_Time+" StartTime( "+m_StartTime+" ) + m_EndTobruqTime( "+m_EndTobruqTime+" ) = "+(m_StartTime + m_EndTobruqTime));
       if ( _Time >= (m_StartTime + m_EndTobruqTime + 2) )
        {
           Core_SendEventTo( "Helicopter",
              "OnDisplayMessage",
              str_BeforeAlAqaliaBombing + m_ShowTimeToScreen/1000 + str_Sec,
              m_ReminderColor);
        }
       if ( _Time >= (m_StartTime + m_EndAlAqaliaTime) )
        {
         m_AlAqaliaOnTimer = false;
         Core_BroadcastEvent("OnAlAqaliaTumeUp");
        }
     }
  }
//  void OnObjectEnterArea( int _AreaIndex, string _NavPointName, string _ObjectID)
//  {
//    if ( _AreaIndex == 0
//      && Core_IsStringStartsWith( _ObjectID, "12_SovietTank"))
//    {
//      Core_BroadcastEvent("OnSovietOffensiveStop");
//    }
//  }
}
//====================================================================================================
class C13_Refueller extends CBaseAITask_Patrol
{
  int m_StartTime;
  boolean m_ActivateOnTimer = true;

  void Init()
  {
    DeactivatePatrol();
    m_StartTime = GetGameTime();
  }

  void OnUpdate()
  {
    if ( m_ActivateOnTimer )
    {
      if ( GetGameTime() >= m_StartTime + 1)
      {
        m_ActivateOnTimer = false;
        ActivatePatrol();
      }
    }
  }

  array GetPatrolTrip()
  {
    return array(
      vector( 8980, 6875, 0),
      vector( 5350, 3605, 0));
  }

  float GetTripSpeed()
  {
    return 28;
  }

  void OnEnemyTargeted() {} // do not attack
}
//----------------------------------------------------------------------
class C13_Tobruq_Patrol extends C13_Refueller
{
  array GetPatrolTrip()
  {
    return array(
      vector( 9511, 6879, 0),
      vector( 9512, 6412, 0),
      vector( 8972, 6405, 0),
      vector( 8979, 6884, 0));
  }
  float GetTripSpeed()
  {
    return 22;
  }
}
//------------------------------------------------------------------------
class C13_Al_Mobile extends C13_Refueller
{
  array GetPatrolTrip()
  {
    return array(
      vector( 5597, 3390, 0),
      vector( 5136, 3386, 0),
      vector( 5128, 3595, 0),
      vector( 5599, 3595, 0));
  }
  float GetTripSpeed()
  {
    return 23;
  }
}


