function ToWin()
if ((GetIGlobalVar("ukol.0", 1) * GetIGlobalVar("ukol.1", 1) * GetIGlobalVar("ukol.2", 1) * GetIGlobalVar("ukol.3", 1) * GetIGlobalVar("ukol.5", 1) * GetIGlobalVar("ukol.6", 1) * GetIGlobalVar("ukol.7", 1)) == 1) then
Win(0);
Suicide();
end;
end;

function ToLoose1()
if ( GetNUnitsInParty (0) <= 0) then
Loose(0);
DisplayTrace ("Unbelievable! The enemy has beaten you.");
Suicide();
end;
end;

function ToLoose2()
if (( GetNScriptUnitsInArea (101, "exit") > 0) or ( GetNScriptUnitsInArea (102, "exit") > 0) or ( GetNScriptUnitsInArea (103, "exit") > 0)) then
Loose(0);
DisplayTrace ("The Soviets broke through and escaped from the encirclement.");
Suicide();
end;
end;

function Start()
SetIGlobalVar("ukol.0", 0);
SetIGlobalVar("ukol.1", 0);
SetIGlobalVar("ukol.2", 0);
SetIGlobalVar("ukol.3", 0);
SetIGlobalVar("ukol.4", 0);
SetIGlobalVar("ukol.5", 0);
SetIGlobalVar("ukol.6", 0);
SetIGlobalVar("ukol.7", 0);
Suicide();
end;

function attack1()
if ( GetNUnitsInArea (0, "trigger1") > 0) then
LandReinforcement(131);
Suicide();
end;
end;

function attack2()
if ( GetNUnitsInArea (0, "trigger2") > 0) then
LandReinforcement(132);
Suicide();
end;
end;

function RevealObjective0()
if ( GetIGlobalVar("ukol.0", 0) == 0) then
        ObjectiveChanged(0, 0);
        Suicide();
	else Suicide();
	end;
end;

function Objective0()
if ( GetNUnitsInScriptGroup (151, 1) <= 0) then
SetIGlobalVar("ukol.0", 1);
ObjectiveChanged(0, 1);
RunScript( "posily2" , 10000);
Suicide();
end;
end;

function RevealObjective1()
if ( GetIGlobalVar("ukol.1", 0) == 0) then
        ObjectiveChanged(1, 0);
        Suicide();
	else Suicide();
	end;
end;

function Objective1()
if ( GetNUnitsInScriptGroup (152, 1) <= 0) then
SetIGlobalVar("ukol.1", 1);
ObjectiveChanged(1, 1);
Suicide();
end;
end;

function RevealObjective2()
if ( GetIGlobalVar("ukol.2", 0) == 0) then
        ObjectiveChanged(2, 0);
        Suicide();
	else Suicide();
	end;
end;

function Objective2()
if ( GetNUnitsInScriptGroup (153, 1) <= 0) then
SetIGlobalVar("ukol.2", 1);
ObjectiveChanged(2, 1);
Suicide();
end;
end;

function RevealObjective3()
if ( GetIGlobalVar("ukol.3", 0) == 0) then
        ObjectiveChanged(3, 0);
        Suicide();
	else Suicide();
	end;
end;

function Objective3()
if ( GetNUnitsInScriptGroup (154, 1) <= 0) then
SetIGlobalVar("ukol.3", 1);
ObjectiveChanged(3, 1);
Suicide();
end;
end;

function circle()
if ( GetIGlobalVar("ukol.3", 1) == 1) then
RunScript( "RevealObjective5" , 3000);
RunScript( "posily1" , 10000);
RunScript( "protiutok1" , 90000);
RunScript( "ToLoose2" , 2000);
Suicide();
end;
end;

function RevealObjective4()
if ( GetIGlobalVar("ukol.4", 0) == 0) then
        ObjectiveChanged(4, 0);
        Suicide();
	else Suicide();
	end;
end;

function Objective4()
if ( GetNUnitsInScriptGroup (155, 1) <= 0) then
SetIGlobalVar("ukol.4", 1);
ObjectiveChanged(4, 1);
DisableAviation (1, 0);
DisableAviation (1, 1);
DisableAviation (1, 3);
Suicide();
end;
end;

function RevealObjective5()
if ( GetIGlobalVar("ukol.5", 0) == 0) then
        ObjectiveChanged(5, 0);
        Suicide();
	else Suicide();
	end;
end;

function protiutok1()
LandReinforcement(101);
RunScript( "Objective5" , 5000);
Suicide();
end;

function Objective5()
if ( GetNUnitsInScriptGroup (101, 1) <= 2) then
SetIGlobalVar("ukol.5", 1);
ObjectiveChanged(5, 1);
RunScript( "RevealObjective6" , 3000);
RunScript( "protiutok2" , 60000);
Suicide();
end;
end;

function RevealObjective6()
if ( GetIGlobalVar("ukol.6", 0) == 0) then
        ObjectiveChanged(6, 0);
        Suicide();
	else Suicide();
	end;
end;

function protiutok2()
LandReinforcement(102);
LandReinforcement(104);
RunScript( "Objective6" , 5000);
Suicide();
end;

function Objective6()
if ( GetNUnitsInScriptGroup (102, 1) <= 2) then
SetIGlobalVar("ukol.6", 1);
ObjectiveChanged(6, 1);
RunScript( "RevealObjective7" , 3000);
RunScript( "protiutok3" , 85000);
Suicide();
end;
end;

function RevealObjective7()
if ( GetIGlobalVar("ukol.7", 0) == 0) then
        ObjectiveChanged(7, 0);
        Suicide();
	else Suicide();
	end;
end;

function protiutok3()
LandReinforcement(103);
RunScript( "Objective7" , 5000);
Suicide();
end;

function Objective7()
if ( GetNUnitsInScriptGroup (103, 1) <= 2) then
SetIGlobalVar("ukol.7", 1);
ObjectiveChanged(7, 1);
Suicide();
end;
end;

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

function posily2()
LandReinforcement(2);
Suicide();
end;

function Init()
RunScript( "Start" , 1000);
RunScript( "ToWin" , 5000);
RunScript( "ToLoose1" , 5000);
RunScript( "circle" , 5000);
RunScript( "attack1" , 25000);
RunScript( "attack2" , 10000);
RunScript( "RevealObjective0" , 3000);
RunScript( "RevealObjective1" , 6000);
RunScript( "RevealObjective2" , 9000);
RunScript( "RevealObjective3" , 12000);
RunScript( "RevealObjective4" , 15000);
RunScript( "Objective0", 5000);
RunScript( "Objective1", 5000);
RunScript( "Objective2", 5000);
RunScript( "Objective3", 5000);
RunScript( "Objective4", 5000);
end;