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


function Objective0()
        if ( GetNUnitsInScriptGroup(1, 1) <= 0) then
		SetIGlobalVar( "temp.narev.objective.0", 1);
		ObjectiveChanged(0, 1);
		RunScript( "RevealObjective1", 3000);
                RunScript( "Reinf", 5000);
                RunScript( "Aviarus", 10000);
		Suicide();
	end;
end;


function Objective1()
	if ( GetNUnitsInScriptGroup(3, 1) <= 0) then
		SetIGlobalVar( "temp.narev.objective.1", 1);
		ObjectiveChanged(1, 1);
		RunScript( "RevealObjective2", 3000);
                RunScript( "Attack", 3000);
                RunScript( "Reinf1", 50000);     
		Suicide();
	end;
end;


function Objective2()
        if ( GetNUnitsInScriptGroup(4, 1) <= 0) then
		SetIGlobalVar( "temp.narev.objective.2", 1);
		ObjectiveChanged(2, 1);
		Suicide();
	end;
end;


function Objective3()
      if ( GetNUnitsInScriptGroup(2001) > 0) then
		SetIGlobalVar( "temp.narev.objective.3", 1);
		ObjectiveChanged(3, 1);
		Suicide();
	end;
end;


function Damage()
        if (GetNUnitsInArea(0, "bridges") > 0) then
           DamageObject(2000, 0);
           DamageObject(2001, 0);      
           DisplayTrace( "Rosjanie wysadzili mosty na rzece. Odbuduj południowo-wschodni most aby móc kontynuować ofensywę."); 
           RunScript( "RevealObjective3", 3000);
           RunScript( "Objective3", 50000);
           Suicide();
     end;
end;


function Aviarus()
         EnableAviation(1, 3);
         RunScript("EnableAviarus", 100000);
         Suicide();
end;


function EnableAviarus()      
        EnableAviation(1, 3); 
	Suicide();
end;


function DisableAviarus()
        SwitchWeatherAutomatic(0);
	SwitchWeather(0);
	DiableAviation(1, 2); 
	DiableAviation(1, 0);
	DiableAviation(1, 1);
	DiableAviation(1, 3); -- bombardirovshik
	DiableAviation(1, 4);
	Suicide();
end;


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


function Reinf1() 
         LandReinforcement(1);
		Suicide();
	
end;

function Attack()
            Cmd(3,25,7815,1258);
           Suicide();
end;


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

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

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


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


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


function Init()
        RunScript( "TobeDefeated", 100) 
        RunScript( "DisableAviarus", 0);
	RunScript( "Objective0", 2000);
        RunScript( "Objective1", 2000);
        RunScript( "Objective2", 2000);
--      RunScript( "Objective3", 2000);
        RunScript( "Damage", 3000);
	RunScript( "RevealObjective0", 2000);
        RunScript( "ToWin", 4000);
end;