[Init]

///////////Служебные переменные для тригеров захвата флагов/////

SET @@RectA = "Rect_FlagA"
SET @@RectB = "Rect_FlagB"
SET @@RectC = "Rect_FlagC"
SET @@RectD = "Rect_FlagD"
SET @@RectE = "Rect_FlagE"

Set @@CounterA = 0 ///Счетчики времени удержания флагов
Set @@CounterB = 0 

///////////Служебные переменные для тригеров захвата флагов/////

RunTrigger ( "_Mission_Win" )
RunTrigger ( "_Client_Activate" )

Delay ( 5000 )


RunTrigger ( "_Army_Activate" )
RunTrigger ( "_All_Units_Capture_Activate" )
RunTrigger ( "Init_flag" )
HALT
[_Mission_Win]

SET @num_client = MP_GetClientNum ( )

LABEL BEGIN

SET @flag = -2

SET @i = 0

LABEL FOR

IF ( @i < @num_client ) THEN

   SET @valid = MP_IsClientValid ( @i )

   IF ( @valid = "TRUE" ) THEN

      SET @army = MP_GetClientArmy ( @i )
      SET @check = MP_GetClientArmyType ( @i )

      SetWorkArmy ( ARMY , @army )

      IF ( @check = "COMPUTER" ) THEN

         SET @units = GetNUnits ( ARMY , @army , HUMAN )
         SET @units_tech = GetNUnits ( ARMY , @army , ALL , NOT_EMPTY , OK_WEAPON , OK_ENGINE , AND_TANK , AND_SPG , AND_ARMOREDCAR , AND_ARTILLERY , AND_HMG , AND_FLAK , AND_CAR )

         ADD ( @units , @units_tech )

      ELSE

         SET @units = GetNUnits ( ARMY , @army , HUMAN , CREW )

      ENDIF

      IF ( @units = 0 ) THEN

         GOTO END

      ENDIF

      SET @ally = MP_GetClientAlliance ( @i )

      IF ( @flag = -2 ) THEN

         SET @winner = @i

         SET @flag = @ally

         GOTO END

      ENDIF

      IF ( @flag != -1 AND @flag = @ally ) THEN

         GOTO END

      ENDIF

      DELAY ( 5000 )

      GOTO BEGIN

   ENDIF

   LABEL END

   DELAY ( 100 )

   ADD ( @i , 1 )

   GOTO FOR

ENDIF

IF ( @flag = -2 ) THEN

   HALT

ENDIF

IF ( @flag = -1 ) THEN

   MP_ClientWin ( @winner )

   HALT

ENDIF

MP_AllianceWin ( @flag )

HALT
[_Client_Activate]

SET @num_client = MP_GetClientNum ( )

SET @client = 0

LABEL _FOR

IF ( @client < @num_client ) THEN

   SET @valid = MP_IsClientValid ( @client )

   IF ( @valid = "TRUE" ) THEN

      SET @ally = MP_GetClientAlliance ( @client )

      RunTriggerInstance ( "_Client_FOW" , @client , @client , @ally )      

      RunTriggerInstance ( "_Client_Fail" , @client , @client )

   ENDIF

   DELAY ( 100 )

   ADD ( @client , 1 )

   GOTO _FOR

ENDIF

HALT
[_Client_FOW]

Param IN @client
Param IN @ally

SET @num_client = MP_GetClientNum ( )

LABEL BEGIN

SET @i = 0

LABEL FOR

IF ( @i < @num_client ) THEN

   SET @valid = MP_IsClientValid ( @i )

   IF ( @valid = "TRUE" ) THEN

      SET @army = MP_GetClientArmy ( @i )

      SetWorkArmy ( ARMY , @army )

      SET @units = GetNUnits ( ARMY , @army , HUMAN , CREW )

      IF ( @units != 0 AND @i = @client ) THEN

         DELAY ( 5000 )

         GOTO BEGIN

      ENDIF

      IF ( @units = 0 ) THEN

         GOTO END

      ENDIF


      SET @new_ally = MP_GetClientAlliance ( @i )

      IF ( @ally = -1 OR @new_ally != @ally ) THEN

         GOTO END

      ENDIF

      DELAY ( 5000 )

      GOTO BEGIN

   ENDIF

   LABEL END

   DELAY ( 100 )

   ADD ( @i , 1 )

   GOTO FOR

ENDIF

MP_ClientChangeFogOfWar ( @client , DISABLE )

HALT
[_Client_Fail]

Param IN @client

LABEL BEGIN

SET @valid = MP_IsClientValid ( @client )

IF ( @valid = "TRUE" ) THEN

   SET @army = MP_GetClientArmy ( @client )

   SetWorkArmy ( ARMY , @army )

   SET @units = GetNUnits ( ARMY , @army , HUMAN , CREW )

   IF ( @units = 0 ) THEN

      MP_ClientFail ( @client )

      HALT

   ENDIF

   DELAY ( 5000 )

   GOTO BEGIN

ENDIF

HALT
[_Army_Attack]

PARAM IN @army

SetWorkArmy ( ARMY , @army )

SET @enemy_army = GetArmy ( ARMY , @army , ENEMY )

SET @group_name = StringMerge ( "_Attack_Group" , @army )
SET @group_name_vehicle = StringMerge ( "_Attack_Group_Vehicle" , @army )
SET @group_name_infantry = StringMerge ( "_Attack_Group_Infantry" , @army )
SET @rect = StringMerge ( "_Attack_Rect" , @army )


LABEL _BEGIN

SET @num = GetNUnits ( ARMY , @army , HUMAN , CREW )
SET @active = GetNUnits ( ARMY , @army , ALL , NOT_DEFEND )
SET @num_enemy = GetNUnits ( ARMY , @enemy_army , ALL , NOT_EMPTY , VISIBLE )

IF ( @num = 0 ) THEN

   HALT

ENDIF

if ( @num_enemy = 0 AND @active = 0 ) THEN

   CreateRectForRecon ( RECT , @rect , ARMY , @army , 256 )

   CreateGroupObject ( GROUP , @group_name , ARMY , @army , ALL , 100 , DEFEND )

   RunCommand ( GROUP , @group_name , STORM , RECT , @rect )

ENDIF

if ( @num_enemy > 0 ) THEN

   SetWorkArmy ( ARMY , @army )

   CreateRectByObject ( RECT , @rect , 100 , ARMY , @enemy_army , ALL , 100 ,  NOT_EMPTY , VISIBLE )

   CreateGroupObject ( GROUP , @group_name_vehicle , ARMY , @army , ALL , 100 , AND_SPG , AND_ARMOREDCAR , AND_TANK , AND_FLAK )

   CreateGroupObject ( GROUP , @group_name_infantry , ARMY , @army , HUMAN , 100 )

   RunCommand ( GROUP , @group_name_infantry , STORM , RECT , @rect )
 
   Delay ( 30000 )

   RunCommand ( GROUP , @group_name_vehicle , ATTACK , RECT , @rect )

ENDIF

Delay ( 30000 )

GOTO _BEGIN
[_Army_Activate]

SET @num_clients = MP_GetClientNum ( )

SET @client = 0

LABEL _BEGIN

IF ( @client >= @num_clients ) THEN

   HALT

ENDIF

SET @valid = MP_IsClientValid ( @client )

SET @check = MP_GetClientArmyType ( @client )

IF ( @valid = "TRUE" AND @check = "COMPUTER" ) THEN

   SET @army = MP_GetClientArmy ( @client )

   RunTriggerInstance ( "_Recon_Activate_Infantry" , @army , @army )      
   RunTriggerInstance ( "_Recon_Activate_Vehicle" , @army , @army )      

   Delay ( 5000 )

   RunTriggerInstance ( "_Army_Attack" , @army , @army )      

ENDIF

ADD ( @client , 1 )

DELAY ( 300 )

GOTO _BEGIN
[_Recon_Unit]

PARAM IN @army   
PARAM IN @unit
PARAM IN @name

SetWorkArmy ( ARMY , @army )

LABEL _BEGIN

SET @num = GetNUnits ( UNIT , @unit , ALL , NOT_EMPTY , OK_ENGINE )

IF ( @num = 0 ) THEN

   HALT

ENDIF

SET @rnd = Rnd ( )

IF ( @rnd > 75 ) THEN

	SET @rect = @@RectA 

ELSE

	SET @rnd = Rnd ( )

	IF ( @rnd > 50 ) THEN

		SET @rnd = Rnd ( )
	
		IF ( @rnd > 50 ) THEN

			SET @rect = @@RectB
	
		ELSE

			SET @rect = @@RectC

		ENDIF

	ELSE

		SET @rnd = Rnd ( )
	
		IF ( @rnd > 50 ) THEN

			SET @rect = @@RectD
	
		ELSE

			SET @rect = @@RectE

		ENDIF

	ENDIF
ENDIF

RunCommand ( UNIT , @unit , STORM , RECT , @rect )

Delay ( 180000 )

GOTO _BEGIN
[_Recon_Activate_Vehicle]

PARAM IN @army

SET @recon_group = StringMerge ( "_Recon_Group_Vehicle" , @army )

SetWorkArmy ( ARMY , @army )


LABEL _BEGIN

SET @num = GetNUnits ( ARMY , @army , ALL , AND_CAR , AND_ARMOREDCAR , AND_TANK , OK_ENGINE )

IF ( @num > 0 ) THEN

   CreateGroupObject ( GROUP , @recon_group , ARMY , @army , ALL , 6 , AND_CAR , AND_ARMOREDCAR , AND_TANK , OK_ENGINE )

   SET @i = 1

   GOTO _ARMOREDCAR_BEGIN

ENDIF

HALT


LABEL _ARMOREDCAR_BEGIN

   IF ( @i > @num ) THEN

      GOTO _ARMOREDCAR

   ENDIF

   SET @unitID = GetUnitID ( GROUP , @recon_group , @i )

   SET @unit_name = GetString ( @unitID )

   RunTriggerInstance ( "_Recon_Unit" , @unit_name , @army , @unitID , @unit_name )

   ADD ( @i , 1 )

   Delay ( 500 )

GOTO _ARMOREDCAR_BEGIN


LABEL _ARMOREDCAR

   SET @num = GetNUnits ( GROUP , @recon_group , ALL , AND_CAR , AND_ARMOREDCAR , AND_TANK , OK_ENGINE )

   IF ( @num = 0 ) THEN

      GOTO _BEGIN

   ENDIF

   Delay ( 30000 )

GOTO _ARMOREDCAR
[_Recon_Activate_Infantry]

PARAM IN @army

SET @recon_group = StringMerge ( "_Recon_Group_Infantry" , @army )

SetWorkArmy ( ARMY , @army )


LABEL _BEGIN

SET @num = GetNUnits ( ARMY , @army , ALL , SOLDIER )

IF ( @num > 0 ) THEN

   CreateGroupObject ( GROUP , @recon_group , ARMY , @army , HUMAN , 32 )

   SET @i = 1

   GOTO _SOLDIER_BEGIN

ENDIF

HALT

LABEL _SOLDIER_BEGIN

   IF ( @i > @num ) THEN

      GOTO _SOLDIER

   ENDIF

   SET @unitID = GetUnitID ( GROUP , @recon_group , @i )

   SET @unit_name = GetString ( @unitID )

   RunTriggerInstance ( "_Recon_Unit" , @unit_name , @army , @unitID , @unit_name )

   ADD ( @i , 1 )

   Delay ( 500 )

GOTO _SOLDIER_BEGIN


LABEL _SOLDIER

   SET @num = GetNUnits ( GROUP , @recon_group , HUMAN )

   IF ( @num = 0 ) THEN

      GOTO _BEGIN

   ENDIF

   Delay ( 30000 )

GOTO _SOLDIER
[_All_Units_Capture_Activate]

SET @all_army = GetArmy ( ARMY , 1 , ALL )

SET @group = StringMerge ( "_Group_Capture" , "_Army" )

SetWorkArmy ( ARMY , @all_army )
 
CreateGroupObject ( GROUP , @group ,  ARMY , @all_army , ALL , 100 , OK_WEAPON , AND_TANK , AND_SPG , AND_ARMOREDCAR , AND_ARTILLERY , AND_HMG , AND_FLAK )

SET @num = GetNUnits ( GROUP , @group , ALL ) 

SET @i = 1

LABEL BEGIN

IF ( @i > @num ) THEN

   HALT

ENDIF

SET @unitID = GetUnitID ( GROUP , @group , @i )
SET @unit_name = GetString ( @unitID )

RunTriggerInstance ( "_Capture_Unit" , @unitID , @unitID , @unit_name )

ADD ( @i , 1 )

Delay ( 100 )

GOTO BEGIN
[_Capture_Unit]

PARAM IN @unit
PARAM IN @name

SET @all_army = GetArmy ( ARMY , 1 , ALL )
SET @comp_army = GetArmy ( ARMY , 1 , COMPUTER )

LABEL BEGIN

SetWorkArmy ( ARMY , @all_army )

SET @active = GetNUnits ( UNIT , @unit , ALL , OK_WEAPON , AND_TANK , AND_SPG , AND_ARMOREDCAR , AND_ARTILLERY , AND_HMG , AND_FLAK )

IF ( @active = 0 ) THEN

	HALT

ENDIF

SET @active = GetNUnits ( UNIT , @unit , ALL , NOT_EMPTY )

IF ( @active = 0 ) THEN

	CreateRectByObject ( RECT , @name , -1 , UNIT , @unit , ALL , 20 , EMPTY )

	SetWorkArmy ( ARMY , @comp_army )

	CreateGroupByRect ( GROUP , @name , ARMY , @comp_army , HUMAN , 4 , RECT , @name , SOLDIER )

	SET @check = GetNUnits ( GROUP , @name , HUMAN )

	IF ( @check > 0 ) THEN

		RunCommand ( GROUP , @name , IN_CREW , UNIT , @unit )

	ENDIF

ENDIF

Delay ( 15000 )

GOTO BEGIN
[Flag_A]
////инициализация переменной идентификатора принадлежности флага А  и установка его в 0
Set @@A = 0
BannerCreate ( POINT , "FlagA" , "Flag_A" ,  -1 )


Label Marker1

Delay 2000

//------Проверка какой из альянсов находится в районе флага.
Set @ClientsA = 0
Set @ClientsB = 1 
set @A = GetNUnitsInArea ( Alliance , @ClientsA  , HUMAN , "Rect_FlagA" , NO_PANIC , NOT_OLD_CREW )
set @B = GetNUnitsInArea ( Alliance , @ClientsB  , HUMAN , "Rect_FlagA" , NO_PANIC , NOT_OLD_CREW )

//////////////////////////////////////////////////////////////////////////////////
////------Ветка проверок для 1Альянса (пока для первой армии. если она в ректе)///
//////////////////////////////////////////////////////////////////////////////////

///////--Модуль 1 по армии А.---
 IF  ( @A > 0 AND @B = 0 ) THEN   
     Delay 3000     
     IF  ( @A > 0 AND @B = 0 ) THEN 
   
        IF  ( @@A = 1 ) THEN
       
           GOTO Marker1

        ELSE 

           Set @@A = 1
           SendBriefingMessage ( "ArmyA_king_Hill_A" , "Projector" , 3000 )
           BannerChangeAlliance ( "Flag_A" , @ClientsA ) 
           GOTO Marker1
      
        ENDIF

      ELSE

        GOTO Marker1

     ENDIF
     
 ENDIF


///////--Модуль 1 по армии B.---
 IF  ( @B > 0 AND @A = 0 ) THEN   
     Delay 3000     
     IF  ( @B > 0 AND @A = 0 ) THEN 
   
        IF  ( @@A = -1 ) THEN
       
           GOTO Marker1

        ELSE 

           Set @@A = -1
           SendBriefingMessage ( "ArmyB_king_Hill_A" , "Projector" , 3000 )
           BannerChangeAlliance ( "Flag_A" , @ClientsB ) 
           GOTO Marker1
      
        ENDIF

      ELSE

        GOTO Marker1

     ENDIF
     
 ENDIF

///проверка на отсутсвие юнитов обоих армий у флага

 IF  ( @B = 0 AND @A = 0 ) THEN   

     IF  ( @@A = 0 ) THEN 

        GOTO Marker1      

     ELSE

        SendBriefingMessage ( "Hill_A_Lost" , "Projector" , 3000 )
        Set @@A = 0
        BannerChangeAlliance ( "Flag_A" , -1 ) 
        GOTO Marker1
     ENDIF

 ENDIF

////проверка обе армии в ректе флага А
 IF  ( @B > 0 AND @A > 0 ) THEN   

  GOTO Marker1

 ENDIF

Halt
[Init_flag]



RunTrigger ( "Flag_A" )
RunTrigger ( "Flag_B" )
RunTrigger ( "Flag_C" )
RunTrigger ( "Flag_D" )
RunTrigger ( "Flag_E" )
Delay 2000
RunTrigger ( "Control_flags" )
RunTrigger ( "Main_timer" )


Halt
[Control_flags]
//---------------инициализация необходимых служебных переменных
// SET @Timerwork  - нужна для проверки работал ли таймер
// SET @Army_Timer = "Null" - присваеваю значение отличное от тех что будут использоваться в проверках для первого перехода
// SET @Sum - переменная через которую вычисляется принадлежность всех флагов, по сумме их идентификаторов


SET @Timerwork =  "False"
SET @Army_Timer = "Null"

SET @@A =  0
SET @@B =  0
SET @@C =  0
SET @@D =  0
SET @@E =  0
Set @ClientsA = 0
Set @ClientsB = 1
Label Marker1
Delay 500
//обнуление переменной , иначе происходит накопление 
SET @@Sum =  0
ADD ( @@Sum , @@A )
ADD ( @@Sum , @@B )
ADD ( @@Sum , @@C )
ADD ( @@Sum , @@D )
ADD ( @@Sum , @@E )

//////////////////////////////////////////////////////////////////////////////////
////------Ветка проверок для 1Альянса (пока для первой армии. если она в ректе)///
//////////////////////////////////////////////////////////////////////////////////

///////--Модуль 1 по армии А.---
 IF  ( @@Sum = 5 ) THEN   
   
     IF  ( @Timerwork = "True" ) THEN 
   
        IF  ( @Army_Timer = "TimerA" ) THEN
       
           GOTO MarkerA

        ELSE 

           StopTimer ( "Controll_all_flags" )
           SetTimer ( "Controll_all_flags" , 120 , REVERSE )
           Delay 500 
           StartTimer ( "Controll_all_flags" )	 
           SendBriefingMessage ( "ArmyA_capture_ALL_flags" , "Projector" , 3000 )
           SET @Army_Timer = "TimerA"	   
           Delay 500
           GOTO Marker1 

        ENDIF	

     ELSE 

        SetTimer ( "Controll_all_flags" , 120 , REVERSE )
        Delay 500 
        StartTimer ( "Controll_all_flags" )	 
        SET @Army_Timer = "TimerA"
        SET @Timerwork =  "True"
        SendBriefingMessage ( "ArmyA_capture_ALL_flags" , "Projector" , 3000 )

Label MarkerA

        Delay 1000
        SET @work = TimerIsWork ( "Controll_all_flags" )
        
           IF ( @work = "True" ) THEN

              GOTO Marker1 

           ELSE         
           
              SendBriefingMessage ( "ArmyA_WIN" , "Projector"  , 5000 )
              Delay 6000
              MP_AllianceWin ( @ClientsA )
              Halt
           ENDIF

     ENDIF

  ENDIF




/////////////////////////////////////////////////////////////////////////////////
////------Ветка проверок для 2Альянса
/////////////////////////////////////////////////////////////////////////////////

///////--Модуль 1 по армии В.---
 IF  ( @@Sum = -5 ) THEN  
   
     IF  ( @Timerwork = "True" ) THEN 
   
        IF  ( @Army_Timer = "TimerB" ) THEN
       
           GOTO MarkerB

        ELSE 

           StopTimer ( "Controll_all_flags" )
           SetTimer ( "Controll_all_flags" , 120 , REVERSE )
           Delay 500 
           StartTimer ( "Controll_all_flags" )	 
           SendBriefingMessage ( "ArmyB_capture_ALL_flags" , "Projector" , 3000 )
           SET @Army_Timer = "TimerB"	   
           Delay 500
           GOTO Marker1 

        ENDIF	

     ELSE 

        SetTimer ( "Controll_all_flags" , 120 , REVERSE )
        Delay 500 
        StartTimer ( "Controll_all_flags" )	 
        SET @Army_Timer = "TimerB"
        SET @Timerwork =  "True"
        SendBriefingMessage ( "ArmyB_capture_ALL_flags" , "Projector" , 3000 )

Label MarkerB

        Delay 1000
        SET @work = TimerIsWork ( "Controll_all_flags" )
        
           IF ( @work = "True" ) THEN

           GOTO Marker1 

           ELSE         
           SendBriefingMessage ( "ArmyB_WIN" , "Projector" , 3000 )           
           Delay 6000
           MP_AllianceWin ( @ClientsB )
           Halt 
           ENDIF


     ENDIF

 ENDIF

//////////////////////////////////////////////////////////////////////
////------Ветка проверок для ситуации , когда не все флаги захваченны одной армией./////
////////////////////////////////////////////////////////////////////


  IF ( @@Sum != -5 AND @@Sum != 5 ) THEN

     IF  ( @Timerwork = "True" ) THEN 
         
         StopTimer ( "Controll_all_flags" )
         SendBriefingMessage ( "One_or_more_flags_lost" , "Projector" , 3000 )     
         SET @Timerwork =  "False"
         GOTO Marker1

     ELSE

        GOTO Marker1

     ENDIF

  ENDIF


Halt
[Main_timer]
Set @ClientsA = 0
Set @ClientsB = 1 
SetTimer ( "GUI" , 2400 , REVERSE )
//проверка на бескоченость времени таймера заданную из интерфейса
SET @bCanBeActivated = CanTimerBeActivated ( "GUI" )

If ( @bCanBeActivated = "False" ) THEN

Halt

ELSE

ENDIF


StartTimer ( "GUI" )

Label Marker1 

Delay 5000
SET @work = TimerIsWork ( "GUI" )
        
 IF ( @work = "True" ) THEN

    GOTO Marker1 

 ELSE         
             
      IF ( @@Sum = 0 ) THEN
        
        set @A = GetNUnits ( Alliance , @ClientsA  , ALL  , NOT_EMPTY , OK_WEAPON , OK_ENGINE , NO_PANIC )
        set @B = GetNUnits ( Alliance , @ClientsB  , ALL  , NOT_EMPTY , OK_WEAPON , OK_ENGINE , NO_PANIC )
        
          IF ( @A > @B ) THEN

            MP_AllianceWin ( @ClientsA )
            Halt

            ELSE 

            MP_AllianceWin ( @ClientsB )
            Halt  

          ENDIF
      ELSE
        
        IF ( @@Sum > 0 ) THEN

            MP_AllianceWin ( @ClientsA )
            Halt
        
        ELSE 

            MP_AllianceWin ( @ClientsB )
            Halt
           
        ENDIF
 
     ENDIF
              
 ENDIF
[Flag_B]
////инициализация переменной идентификатора принадлежности флага B  и установка его в 0
Set @@B = 0
BannerCreate ( POINT , "FlagB" , "Flag_B" ,  -1 )


Label Marker1

Delay 2000

//------Проверка какой из альянсов находится в районе флага.
Set @ClientsA = 0
Set @ClientsB = 1 
set @A = GetNUnitsInArea ( Alliance , @ClientsA  , HUMAN , "Rect_FlagB" , NO_PANIC , NOT_OLD_CREW )
set @B = GetNUnitsInArea ( Alliance , @ClientsB  , HUMAN , "Rect_FlagB" , NO_PANIC , NOT_OLD_CREW )

//////////////////////////////////////////////////////////////////////////////////
////------Ветка проверок для 1Альянса (пока для первой армии. если она в ректе)///
//////////////////////////////////////////////////////////////////////////////////

///////--Модуль 1 по армии А.---
 IF  ( @A > 0 AND @B = 0 ) THEN   
     Delay 3000     
     IF  ( @A > 0 AND @B = 0 ) THEN 
   
        IF  ( @@B = 1 ) THEN

           GOTO Marker1

        ELSE 

           Set @@B = 1
           SendBriefingMessage ( "ArmyA_king_Hill_B" , "Projector" , 3000 )
           BannerChangeAlliance ( "Flag_B" , @ClientsA ) 
           GOTO Marker1
      
        ENDIF

      ELSE

        GOTO Marker1

     ENDIF
     
 ENDIF


///////--Модуль 1 по армии B.---
 IF  ( @B > 0 AND @A = 0 ) THEN   
     Delay 3000     
     IF  ( @B > 0 AND @A = 0 ) THEN 
   
        IF  ( @@B = -1 ) THEN

           GOTO Marker1

        ELSE 

           Set @@B = -1

           SendBriefingMessage ( "ArmyB_king_Hill_B" , "Projector" , 3000 )
           BannerChangeAlliance ( "Flag_B" , @ClientsB ) 
           GOTO Marker1
      
        ENDIF

      ELSE

        GOTO Marker1

     ENDIF
     
 ENDIF

///проверка на отсутсвие юнитов обоих армий у флага

 IF  ( @B = 0 AND @A = 0 ) THEN   

     IF  ( @@B = 0 ) THEN 

        GOTO Marker1      

     ELSE

        SendBriefingMessage ( "Hill_B_Lost" , "Projector" , 3000 )
        Set @@B = 0
        BannerChangeAlliance ( "Flag_B" , -1 ) 
        GOTO Marker1
     ENDIF

 ENDIF

////проверка обе армии в ректе флага А
 IF  ( @B > 0 AND @A > 0 ) THEN   

  GOTO Marker1

 ENDIF

Halt
[Flag_C]
////инициализация переменной идентификатора принадлежности флага C  и установка его в 0
Set @@C = 0
BannerCreate ( POINT , "FlagC" , "Flag_C" ,  -1 )


Label Marker1

Delay 2000

//------Проверка какой из альянсов находится в районе флага.
Set @ClientsA = 0
Set @ClientsB = 1 
set @A = GetNUnitsInArea ( Alliance , @ClientsA  , HUMAN , "Rect_FlagC" , NOT_OLD_CREW , NO_PANIC )
set @B = GetNUnitsInArea ( Alliance , @ClientsB  , HUMAN , "Rect_FlagC" , NOT_OLD_CREW , NO_PANIC )

//////////////////////////////////////////////////////////////////////////////////
////------Ветка проверок для 1Альянса (пока для первой армии. если она в ректе)///
//////////////////////////////////////////////////////////////////////////////////

///////--Модуль 1 по армии А.---
 IF  ( @A > 0 AND @B = 0 ) THEN   
     Delay 3000     
     IF  ( @A > 0 AND @B = 0 ) THEN 
   
        IF  ( @@C = 1 ) THEN
       
           GOTO Marker1

        ELSE 

           Set @@C = 1
           SendBriefingMessage ( "ArmyA_king_Hill_C" , "Projector" , 3000 )
           BannerChangeAlliance ( "Flag_C" , @ClientsA ) 
           GOTO Marker1
      
        ENDIF

     ELSE

        GOTO Marker1

     ENDIF
     
 ENDIF


///////--Модуль 1 по армии B.---
 IF  ( @B > 0 AND @A = 0 ) THEN   
     Delay 3000     
     IF  ( @B > 0 AND @A = 0 ) THEN 
   
        IF  ( @@C = -1 ) THEN
       
           GOTO Marker1

        ELSE 

           Set @@C = -1
           SendBriefingMessage ( "ArmyB_king_Hill_C" , "Projector" , 3000 )
           BannerChangeAlliance ( "Flag_C" , @ClientsB ) 
           GOTO Marker1
      
        ENDIF

      ELSE

        GOTO Marker1

     ENDIF
     
 ENDIF

///проверка на отсутсвие юнитов обоих армий у флага

 IF  ( @B = 0 AND @A = 0 ) THEN   

     IF  ( @@C = 0 ) THEN 

        GOTO Marker1      

     ELSE

        SendBriefingMessage ( "Hill_C_Lost" , "Projector" , 3000 )
        Set @@C = 0
        BannerChangeAlliance ( "Flag_C" , -1 ) 
        GOTO Marker1
     ENDIF

 ENDIF

////проверка обе армии в ректе флага А
 IF  ( @B > 0 AND @A > 0 ) THEN   

  GOTO Marker1

 ENDIF

Halt
[Flag_D]
////инициализация переменной идентификатора принадлежности флага А  и установка его в 0
Set @@D = 0
BannerCreate ( POINT , "FlagD" , "Flag_D" ,  -1 )


Label Marker1

Delay 2000

//------Проверка какой из альянсов находится в районе флага.
Set @ClientsA = 0
Set @ClientsB = 1 
set @A = GetNUnitsInArea ( Alliance , @ClientsA  , HUMAN , "Rect_FlagD" , NOT_OLD_CREW , NO_PANIC )
set @B = GetNUnitsInArea ( Alliance , @ClientsB  , HUMAN , "Rect_FlagD" , NOT_OLD_CREW , NO_PANIC )

//////////////////////////////////////////////////////////////////////////////////
////------Ветка проверок для 1Альянса (пока для первой армии. если она в ректе)///
//////////////////////////////////////////////////////////////////////////////////

///////--Модуль 1 по армии А.---
 IF  ( @A > 0 AND @B = 0 ) THEN   
     Delay 3000     
     IF  ( @A > 0 AND @B = 0 ) THEN 
   
        IF  ( @@D = 1 ) THEN
       
           GOTO Marker1

        ELSE 

           Set @@D = 1
           SendBriefingMessage ( "ArmyA_king_Hill_D" , "Projector" , 3000 )
           BannerChangeAlliance ( "Flag_D" , @ClientsA ) 
           GOTO Marker1
      
        ENDIF

      ELSE

        GOTO Marker1

     ENDIF
     
 ENDIF


///////--Модуль 1 по армии B.---
 IF  ( @B > 0 AND @A = 0 ) THEN   
     Delay 3000     
     IF  ( @B > 0 AND @A = 0 ) THEN 
   
        IF  ( @@D = -1 ) THEN
       
           GOTO Marker1

        ELSE 

           Set @@D = -1
           SendBriefingMessage ( "ArmyB_king_Hill_D" , "Projector" , 3000 )
           BannerChangeAlliance ( "Flag_D" , @ClientsB ) 
           GOTO Marker1
      
        ENDIF

      ELSE

        GOTO Marker1

     ENDIF
     
 ENDIF

///проверка на отсутсвие юнитов обоих армий у флага

 IF  ( @B = 0 AND @A = 0 ) THEN   

     IF  ( @@D = 0 ) THEN 

        GOTO Marker1      

     ELSE

        SendBriefingMessage ( "Hill_D_Lost" , "Projector" , 3000 )
        Set @@D = 0
        BannerChangeAlliance ( "Flag_D" , -1 ) 
        GOTO Marker1
     ENDIF

 ENDIF

////проверка обе армии в ректе флага А
 IF  ( @B > 0 AND @A > 0 ) THEN   

  GOTO Marker1

 ENDIF

Halt
[Flag_E]
////инициализация переменной идентификатора принадлежности флага А  и установка его в 0
Set @@E = 0
BannerCreate ( POINT , "FlagE" , "Flag_E" ,  -1 )


Label Marker1

Delay 2000

//------Проверка какой из альянсов находится в районе флага.
Set @ClientsA = 0
Set @ClientsB = 1 
set @A = GetNUnitsInArea ( Alliance , @ClientsA  , HUMAN , "Rect_FlagE" , NOT_OLD_CREW , NO_PANIC )
set @B = GetNUnitsInArea ( Alliance , @ClientsB  , HUMAN , "Rect_FlagE" , NOT_OLD_CREW , NO_PANIC )

//////////////////////////////////////////////////////////////////////////////////
////------Ветка проверок для 1Альянса (пока для первой армии. если она в ректе)///
//////////////////////////////////////////////////////////////////////////////////

///////--Модуль 1 по армии А.---
 IF  ( @A > 0 AND @B = 0 ) THEN   
     Delay 3000     
     IF  ( @A > 0 AND @B = 0 ) THEN 
   
        IF  ( @@E = 1 ) THEN
       
           GOTO Marker1

        ELSE 

           Set @@E = 1
           SendBriefingMessage ( "ArmyA_king_Hill_E" , "Projector" , 3000 )
           BannerChangeAlliance ( "Flag_E" , @ClientsA ) 
           GOTO Marker1
      
        ENDIF

      ELSE

        GOTO Marker1

     ENDIF
     
 ENDIF


///////--Модуль 1 по армии B.---
 IF  ( @B > 0 AND @A = 0 ) THEN   
     Delay 3000     
     IF  ( @B > 0 AND @A = 0 ) THEN 
   
        IF  ( @@E = -1 ) THEN
       
           GOTO Marker1

        ELSE 

           Set @@E = -1
           SendBriefingMessage ( "ArmyB_king_Hill_E" , "Projector" , 3000 )
           BannerChangeAlliance ( "Flag_E" , @ClientsB ) 
           GOTO Marker1
      
        ENDIF

      ELSE

        GOTO Marker1

     ENDIF
     
 ENDIF

///проверка на отсутсвие юнитов обоих армий у флага

 IF  ( @B = 0 AND @A = 0 ) THEN   

     IF  ( @@E = 0 ) THEN 

        GOTO Marker1      

     ELSE

        SendBriefingMessage ( "Hill_E_Lost" , "Projector" , 3000 )
        Set @@E = 0
        BannerChangeAlliance ( "Flag_E" , -1 ) 
        GOTO Marker1
     ENDIF

 ENDIF

////проверка обе армии в ректе флага А
 IF  ( @B > 0 AND @A > 0 ) THEN   

  GOTO Marker1

 ENDIF

Halt
