function ToWin()
if ((GetIGlobalVar("ukol.0", 1) * GetIGlobalVar("ukol.1", 1) * GetIGlobalVar("ukol.2", 1) * GetIGlobalVar("ukol.3", 1) * GetIGlobalVar("ukol.4", 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 Start()
SetIGlobalVar("ukol.0", 0);
SetIGlobalVar("ukol.1", 0);
SetIGlobalVar("ukol.2", 0);
SetIGlobalVar("ukol.3", 0);
SetIGlobalVar("ukol.4", 0);
Suicide();
end;

function avia()
if ( GetAviationState( 0) == 2) then
RunScript( "aviaoff" , 60000);
Suicide();
end;
end;

function aviaoff()
DisableAviation (0, 2);
KillScript ("avia");
Suicide();
end;

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

function Objective0()
if ((( GetNUnitsInArea (1, "bridges1") <= 0) and ( GetNUnitsInArea (1, "bridges2") <= 0) and ( GetNUnitsInArea (1, "bridges3") <= 0)) and (( GetNUnitsInArea (0, "bridges1") > 0) or ( GetNUnitsInArea (0, "bridges2") > 0) or ( GetNUnitsInArea (0, "bridges3") > 0))) then
SetIGlobalVar("ukol.0", 1);
ObjectiveChanged(0, 1);
RunScript( "RevealObjective4" , 3000);
RunScript( "protiutok1" , 60000);
Suicide();
end;
end;

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

function protiutok2()
if ( GetNUnitsInArea (0, "city") >= 5) then
GiveCommand (3, 102, 5103, 6023);
GiveQCommand (3, 102, 4711, 7639);
GiveQCommand (3, 102, 850, 8587);
Suicide();
end;
end;

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

function Objective1()
if ( GetNUnitsInArea (1, "bl") <= 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(102, 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 ( GetNUnitsInArea (1, "village") <= 0) then
SetIGlobalVar("ukol.3", 1);
ObjectiveChanged(3, 1);
Suicide();
end;
end;

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

function Objective4()
if (( GetNUnitsInScriptGroup(101, 1) <= 2) and (( GetNUnitsInArea (0, "bridges1") > 0) or ( GetNUnitsInArea (0, "bridges2") > 0))) then
SetIGlobalVar("ukol.4", 1);
ObjectiveChanged(4, 1);
KillScript ("Objective4f");
Suicide();
end;
end;

function Objective4f()
if ((( GetNUnitsInArea (0, "bridges1") <= 0) and ( GetNUnitsInArea (0, "bridges2") <= 0)) and (( GetNUnitsInArea (1, "bridges1") > 0) or ( GetNUnitsInArea (1, "bridges2") > 0))) then
ObjectiveChanged(4, 2);
Loose(0);
DisplayTrace ("The command was given to another officer because of your failure.");
Suicide();
end;
end;

function Init()
RunScript( "Start" , 1000);
RunScript( "ToWin" , 5000);
RunScript( "ToLoose1" , 5000);
RunScript( "protiutok2" , 20000);
RunScript( "avia" , 4000);
RunScript( "RevealObjective0" , 3000);
RunScript( "RevealObjective1" , 6000);
RunScript( "RevealObjective2" , 9000);
RunScript( "RevealObjective3" , 12000);
RunScript( "Objective0", 5000);
RunScript( "Objective1", 5000);
RunScript( "Objective2", 5000);
RunScript( "Objective3", 5000);
end;