function TobeDefeated()
local Numunits = GetNUnitsInScriptGroup(1000, 0) + GetNUnitsInScriptGroup(1001, 0) + GetNUnitsInScriptGroup(1002, 0) + GetNUnitsInScriptGroup(500, 0); 
if (Numunits <= 0 ) then
		Loose();
		Suicide();
	end;
end;

function Objective0()
local Numunits = GetNUnitsInScriptGroup(44) + GetNUnitsInScriptGroup(55); 
if (Numunits <= 4) then
		SetIGlobalVar("temp.operation_in_cambre.objective.0", 1);
                ObjectiveChanged(0, 1);
                 RunScript( "RevealObjective3", 3000);
		Suicide();
	end;
end;

function Ok()
	if ( (GetIGlobalVar("temp.operation_in_cambre.objective.1", 0) * GetIGlobalVar("temp.operation_in_cambre.objective.2", 0)) == 1) then 
                                   RunScript( "RevealObjective3", 3000);
		Suicide();
	end;
end;

function Blin()
	if (GetIGlobalVar("temp.operation_in_cambre.objective.1", 0)  == 1) or (GetIGlobalVar("temp.operation_in_cambre.objective.2", 0) == 1) then
                                  RunScript( "Reinf", 2000); 
                                      RunScript( "Attack", 10000); 
                   RunScript( "Attack3", 10000);          
                   RunScript( "RevealObjective0", 12000);
                   RunScript("TobeDefeated", 15000);
                   RunScript( "Objective0", 15000);
		Suicide();
	end;
end;		

function Kopec()
	if ( (GetIGlobalVar("temp.operation_in_cambre.objective.1", 0) * GetIGlobalVar("temp.operation_in_cambre.objective.2", 0)) > 1) then 
                   RunScript( "Reinf", 2000); 
                   RunScript( "Reinf2", 4000);
                    RunScript( "Attack", 10000); 
                   RunScript( "Attack3", 10000);          
                   RunScript( "RevealObjective0", 12000);
                   RunScript("TobeDefeated", 15000);
                   RunScript( "Objective0", 15000);
		Suicide();
	end;
end;

function Objective1()
 if (GetNUnitsInScriptGroup(1000, 0) <= 0) then
         if ( GetIGlobalVar("temp.operation_in_cambre.objective.1", 0) == 0) then  
			SetIGlobalVar("temp.operation_in_cambre.objective.1", 2);
			ObjectiveChanged(1, 2);
                 end;
		   Suicide();
	 else 
local Numunits = GetNUnitsInScriptGroup(58) + GetNUnitsInScriptGroup(59) + GetNUnitsInScriptGroup(41) + GetNUnitsInScriptGroup(40);               

if (Numunits <= 6) then
		SetIGlobalVar("temp.operation_in_cambre.objective.1", 1);
                ObjectiveChanged(1, 1);
		Suicide();
	end;
end;
end;


function Objective2()
 if (GetNUnitsInScriptGroup(1001, 0) <= 0) then
         if ( GetIGlobalVar("temp.operation_in_cambre.objective.2", 0) == 0) then  
			SetIGlobalVar("temp.operation_in_cambre.objective.2", 2);
			ObjectiveChanged(2, 2);
                                               
                 end;
		   Suicide();
	 else 
local Numunits = GetNUnitsInScriptGroup(3) + GetNUnitsInScriptGroup(1) + GetNUnitsInScriptGroup(50) + GetNUnitsInScriptGroup(51);               
if (Numunits <= 6 ) then
		SetIGlobalVar("temp.operation_in_cambre.objective.2", 1);
                ObjectiveChanged(2, 1);
		Suicide();
	end;
end;
end;


function Objective3()
	if ( GetNUnitsInScriptGroup(70, 1) <= 0) then
		SetIGlobalVar( "temp.operation_in_cambre.objective.3", 1);
		ObjectiveChanged(3, 1);
		Suicide();
	end;
end;

	
function Attack1()
local A_Swarm = 3;
            Cmd(3,40,1690,4786);
            Cmd(3,41,1690,4786);

            Cmd(3,50,5182,7834);
            Cmd(3,51,5182,7834);

            Suicide();
end;


function Attack2()
local A_Swarm = 3;
          Cmd(3,58,2216,11432);
          Cmd(3,59,2216,11432);

          Cmd(3,1,4166,11438);
          Cmd(3,3,4166,11438);

            Suicide();
end; 


function Reinf() 
         LandReinforcement(0);
		Suicide();
	
end;

function Reinf2() 
         LandReinforcement(3);
		Suicide();
	
end;

-----------Attack---------------
function Attack()
            LandReinforcement(1);
            RunScript( "Cmd1", 2000);   
           Suicide();
end;

function Cmd1()
local A_Swarm = 3; 
            Cmd(3,44,2218,11380);         
end;
  
-------------A1-----------------

function Attack3()
            LandReinforcement(2);
            RunScript( "Cmd2", 2000);   
           Suicide();
end;


function Cmd2()
local A_Swarm = 3; 
             Cmd(3,55,2800,11380);        
end;
-------------------------------------------------

function Avianem()
         EnableAviation(1, 3);
         RunScript("EnableAvianem", 3000);
         Suicide();
end;


function EnableAvianem()      
local A_Swarm = 3;
	EnableAviation(1, 3);
        Cmd(A_Swarm, 10000, 0, 1718, 4589);
	Suicide();
end;


function DisableAvianem()
	DiableAviation(1, 2); 
	DiableAviation(1, 0);
	DiableAviation(1, 1);
	DiableAviation(1, 3); -- bombardirovshik
	DiableAviation(1, 4);
	Suicide();
end;


function Avia()
         EnableAviation(0, 1);
         Suicide();
end;


function DisableAvia()
	SwitchWeatherAutomatic(0);
	SwitchWeather(0);
	DiableAviation(0, 0); 
	DiableAviation(0, 1);
	DiableAviation(0, 2);
	DiableAviation(0, 3); 
	DiableAviation(0, 4);
	Suicide();
end;


function ToWin()
        if ( (GetIGlobalVar("temp.operation_in_cambre.objective.0", 0) * GetIGlobalVar("temp.operation_in_cambre.objective.3", 0)) == 1) then
		RunScript( "WinWin", 4000);
		Suicide();
	end;
end;

function WinWin()
	Win(0);
	Suicide();
end;


function RevealObjective0()
        if ( GetIGlobalVar("temp.operation_in_cambre.objective.0", 0) == 0) then
	ObjectiveChanged(0, 0);
        end;
	Suicide();
end;


function RevealObjective1()
	if ( GetIGlobalVar("temp.operation_in_cambre.objective.1", 0) == 0) then
		ObjectiveChanged(1, 0);
	end;
	Suicide();
end;


function RevealObjective2()
	if ( GetIGlobalVar("temp.operation_in_cambre.objective.2", 0) == 0) then
		ObjectiveChanged(2, 0);
	end;
	Suicide();
end;


function RevealObjective3()
	if ( GetIGlobalVar("temp.operation_in_cambre.objective.3", 0) == 0) then
		ObjectiveChanged(3, 0);
	end;
	Suicide();
end;


function Init()
        RunScript( "DisableAvianem", 0);
         RunScript( "Kopec", 2000);
       RunScript( "Ok", 4000); 
        RunScript( "Blin", 5000); 
--	RunScript( "Objective0", 2000);
        RunScript( "Objective1", 2000);
        RunScript( "Objective2", 6000);
        RunScript( "Objective3", 6000);
--        RunScript( "RevealObjective0", 3000);
        RunScript( "RevealObjective1", 3000);
        RunScript( "RevealObjective2", 3000);  
        RunScript( "Attack1", 10000);
--        RunScript( "Attack", 2000); 
--        RunScript( "Attack3", 2000);
        RunScript( "Attack2", 10000);
         RunScript( "Avianem", 15000);
         RunScript( "ToWin", 4000); 
--        RunScript("TobeDefeated", 5000);
end;

