function ToWin()
if ((GetIGlobalVar("ukol.0", 1) * GetIGlobalVar("ukol.1", 1) * GetIGlobalVar("ukol.3", 1) * GetIGlobalVar("ukol.4", 1) * GetIGlobalVar("ukol.5", 1) * GetIGlobalVar("ukol.6", 1) * GetIGlobalVar("ukol.7", 1) * GetIGlobalVar("ukol.8", 1) * GetIGlobalVar("ukol.9", 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 ((( GetNUnitsInArea (0, "city_west") <= 0) or ( GetNUnitsInArea (0, "city_east") <= 0)) and (( GetNUnitsInArea (1, "city_west") > 0) or ( GetNUnitsInArea (1, "city_east") > 0))) then
ObjectiveChanged(0, 2);
Loose(0);
DisplayTrace ("You have lost Rzhev.");
Suicide();
end;
end;

function ToLoose3()
if ( GetNUnitsInArea (1, "roads") > 0) then
ObjectiveChanged(1, 2);
Loose(0);
DisplayTrace ("The Soviets have cut you off the supply lines.");
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);
SetIGlobalVar("ukol.8", 0);
SetIGlobalVar("ukol.9", 0);
DisableAviation (0, 1);
DisableAviation (0, 4);
Suicide();
end;

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

function Objective0()
SetIGlobalVar("ukol.0", 1);
ObjectiveChanged(0, 1);
Suicide();
end;

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

function Objective1()
if ( GetNUnitsInArea (1, "roads") <= 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 (( GetNUnitsInArea (0, "airfield") > 0) and ( GetNUnitsInArea (1, "airfield") <= 0)) then
	ObjectiveChanged(2, 1);
	Suicide();
	else Suicide();
	end;
end;

function Objective2f()
if (( GetNUnitsInArea (1, "airfield") > 0) and ( GetNUnitsInArea (0, "airfield") <= 0)) then
ObjectiveChanged(2, 2);
DisableAviation (0, -1);
Suicide();
end;
end;

function paradrop()
GiveCommand (22, 5000, 1, 12802, 3990);
DisableAviation (1, 2);
Suicide();
end;

function ger_avia()
EnableAviation (0, 1);
EnableAviation (0, 4);
Suicide();
end;

function protiutok0()
if ( GetNUnitsInArea (1, "para") > 0) then
LandReinforcement(151);
LandReinforcement(152);
RunScript( "arty" , 20000);
RunScript( "ger_avia" , 30000);
RunScript( "check_attacks" , 5000);
Suicide();
end;
end;

function arty()
if ( GetNUnitsInArea (0, "vil_start") <= 0) then
LandReinforcement(153);
Suicide();
end;
end;

function check_attacks()
if ( GetNUnitsInScriptGroup (152, 1) <= 2) then
RunScript( "RevealObjective3" , 3000);
RunScript( "protiutok1" , 180000);
LandReinforcement(1);
Suicide();
end;
end;

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

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

function Objective3()
if ( GetNUnitsInScriptGroup (101, 1) <= 3) then
SetIGlobalVar("ukol.3", 1);
ObjectiveChanged(3, 1);
RunScript( "RevealObjective4" , 3000);
RunScript( "protiutok2" , 180000);
Suicide();
end;
end;

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

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

function Objective4()
if ( GetNUnitsInScriptGroup (102, 1) <= 3) then
SetIGlobalVar("ukol.4", 1);
ObjectiveChanged(4, 1);
RunScript( "RevealObjective5" , 3000);
RunScript( "protiutok3" , 300000);
RunScript( "posily2" , 10000);
Suicide();
end;
end;

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

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

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

function Objective5()
if ( GetNUnitsInScriptGroup (103, 1) <= 3) then
SetIGlobalVar("ukol.5", 1);
ObjectiveChanged(5, 1);
RunScript( "RevealObjective6" , 3000);
RunScript( "protiutok4" , 300000);
Suicide();
end;
end;

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

function protiutok4()
LandReinforcement(104);
SwitchWeather (0);
GiveCommand (36, 5000, 1, 8313, 11817);
RunScript( "Objective6" , 5000);
Suicide();
end;

function Objective6()
if ( GetNUnitsInScriptGroup (104, 1) <= 3) then
SetIGlobalVar("ukol.6", 1);
ObjectiveChanged(6, 1);
RunScript( "RevealObjective7" , 3000);
RunScript( "protiutok5" , 720000);
LandReinforcement(3);
Suicide();
end;
end;

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

function protiutok5()
LandReinforcement(105);
SwitchWeather (0);
GiveCommand (36, 5000, 1, 6259, 5019);
RunScript( "Objective7" , 5000);
Suicide();
end;

function Objective7()
if ( GetNUnitsInScriptGroup (105, 1) <= 3) then
SetIGlobalVar("ukol.7", 1);
ObjectiveChanged(7, 1);
RunScript( "RevealObjective8" , 3000);
RunScript( "protiutok6" , 300000);
Suicide();
end;
end;

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

function protiutok6()
LandReinforcement(106);
SwitchWeather (0);
GiveCommand (36, 5000, 1, 8313, 11817);
RunScript( "Objective8" , 5000);
Suicide();
end;

function Objective8()
if ( GetNUnitsInScriptGroup (106, 1) <= 3) then
SetIGlobalVar("ukol.8", 1);
ObjectiveChanged(8, 1);
RunScript( "RevealObjective9" , 3000);
RunScript( "protiutok7" , 180000);
Suicide();
end;
end;

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

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

function Objective9()
if ( GetNUnitsInScriptGroup (107, 1) <= 3) then
SetIGlobalVar("ukol.9", 1);
ObjectiveChanged(9, 1);
RunScript( "Objective0" , 5000);
RunScript( "Objective2" , 8000);
RunScript( "Objective1" , 11000);
Suicide();
end;
end;

function Init()
RunScript( "Start" , 1000);
RunScript( "ToWin" , 5000);
RunScript( "ToLoose1" , 5000);
RunScript( "ToLoose2" , 5000);
RunScript( "ToLoose3" , 5000);
RunScript( "Objective2f" , 5000);
RunScript( "paradrop" , 15000);
RunScript( "protiutok0" , 2000);
RunScript( "RevealObjective0" , 3000);
RunScript( "RevealObjective1" , 6000);
RunScript( "RevealObjective2" , 9000);
end;