function ToWin()
if ((GetIGlobalVar("ukol.0", 1) * GetIGlobalVar("ukol.1", 1) * GetIGlobalVar("ukol.2", 1) * GetIGlobalVar("ukol.3", 1) * GetIGlobalVar("ukol.4", 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 (103, "pocket") > 0) or ( GetNScriptUnitsInArea (104, "pocket") > 0)) then
Loose(0);
DisplayTrace ("The Russians broke through and restored the contact with the pocket.");
Suicide();
end;
end;

function ToLoose3()
if ( GetNScriptUnitsInArea (101, "exit") > 0) then
Loose(0);
DisplayTrace ("The Russians withdrawed and established continuous defensive frontline.");
Suicide();
end;
end;

function ToLoose4()
if (( GetNUnitsInArea (1, "city") > 0) and ( GetNUnitsInArea (0, "city") <= 0)) then
Loose(0);
DisplayTrace ("You have lost Smolensk.");
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 protiutok1()
LandReinforcement(101);
RunScript( "Objective1" , 5000);
Suicide();
end;

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

function Objective0()
if (( GetNUnitsInScriptGroup(153, 1) <= 0) and ( GetNUnitsInArea (0, "circle") >= 1)) then
SetIGlobalVar("ukol.0", 1);
ObjectiveChanged(0, 1);
DisplayTrace ("Wait until the enemy units appear...");
Suicide();
end;
end;

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

function Objective1()
if ( GetNUnitsInScriptGroup(101, 1) <= 2) then
SetIGlobalVar("ukol.1", 1);
ObjectiveChanged(1, 1);
RunScript( "RevealObjective2" , 3000);
RunScript( "Objective2" , 5000);
RunScript( "nadrazi" , 5000);
Suicide();
end;
end;

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

function nadrazi()
if ( GetNUnitsInArea (1, "station") <= 0) then
RunScript( "posily1" , 120000);
Suicide();
end;
end;

function Objective2()
if (( GetNUnitsInArea (1, "station") <= 0) and ( GetNUnitsInArea (1, "factory") <= 0) and ( GetNUnitsInArea (1, "city") <= 0)) then
SetIGlobalVar("ukol.2", 1);
ObjectiveChanged(2, 1);
RunScript( "RevealObjective3" , 3000);
RunScript( "protiutok2" , 20000);
Suicide();
end;
end;

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

function protiutok2()
LandReinforcement(102);
RunScript( "Objective3" , 5000);
RunScript( "Objective3f" , 5000);
Suicide();
end;

function Objective3()
if ( GetNUnitsInScriptGroup (102, 1) <= 2) then
SetIGlobalVar("ukol.3", 1);
ObjectiveChanged(3, 1);
KillScript ("Objective3f");
RunScript( "RevealObjective4" , 3000);
RunScript( "protiutok3" , 180000);
RunScript( "protiutok4" , 300000);
RunScript( "ToLoose2" , 5000);
Suicide();
end;
end;

function Objective3f()
if (( GetNScriptUnitsInArea (102, "city") > 0) and ( GetNUnitsInArea (0, "city") <= 3)) then
ObjectiveChanged(3, 2);
Loose(0);
DisplayTrace ("Thanks to the successful counter-attack, the pocket will never surrender.");
Suicide();
end;
end;

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

function protiutok3()
LandReinforcement(103);
Suicide();
end;

function protiutok4()
LandReinforcement(104);
LandReinforcement(151);
RunScript( "avia1" , 2000);
RunScript( "Objective4" , 5000);
Suicide();
end;

function avia1()
SwitchWeather (0);
GiveCommand (36, 5000, 1, 7338, 7694);
Suicide();
end;

function Objective4()
if (( GetNUnitsInScriptGroup (103, 1) <= 2) and ( GetNUnitsInScriptGroup (104, 1) <= 2)) then
SetIGlobalVar("ukol.4", 1);
ObjectiveChanged(4, 1);
ChangePlayer (152, 2);
RunScript( "RevealObjective5" , 3000);
RunScript( "RevealObjective6" , 6000);
RunScript( "RevealObjective7" , 9000);
RunScript( "Objective5" , 5000);
RunScript( "Objective6" , 5000);
RunScript( "protiutok5" , 300000);
RunScript( "protiutok6" , 420000);
RunScript( "protiutok7" , 660000);
RunScript( "posily2" , 25000);
RunScript( "ToLoose4" , 5000);
Suicide();
end;
end;

function protiutok5()
LandReinforcement(105);
Suicide();
end;

function protiutok6()
LandReinforcement(106);
Suicide();
end;

function protiutok7()
LandReinforcement(107);
RunScript( "Objective7" , 5000);
Suicide();
end;

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

function Objective5()
if ( GetNUnitsInArea (1, "nvil") <= 0) then
SetIGlobalVar("ukol.5", 1);
ObjectiveChanged(5, 1);
Suicide();
end;
end;

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

function Objective6()
if ( GetNUnitsInArea (1, "svil") <= 0) then
SetIGlobalVar("ukol.6", 1);
ObjectiveChanged(6, 1);
Suicide();
end;
end;

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

function Objective7()
if ( GetNUnitsInScriptGroup (107, 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( "RevealObjective0" , 3000);
RunScript( "Objective0", 5000);
RunScript( "RevealObjective1" , 475000);
RunScript( "protiutok1", 480000);
RunScript( "ToLoose3" , 5000);
end;