function ToWin()
if ((GetIGlobalVar("ukol.1", 1) * GetIGlobalVar("ukol.2", 1) * GetIGlobalVar("ukol.3", 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, "sidi_omar") <= 0) and ( GetNUnitsInArea (1, "sidi_omar") > 0)) then
Loose(0);
DisplayTrace ("The British broke through.");
Suicide();
end;
end;

function ToLoose3()
if (( GetNUnitsInArea (0, "solum") <= 0) and ( GetNUnitsInArea (1, "solum") > 0)) then
Loose(0);
DisplayTrace ("The British have won the battle.");
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);
DisableAviation (0, 1);
GiveCommand (19, 5000, 1, 9471, 3708);
LandReinforcement (105);
Suicide();
end;

function protiutok1()
LandReinforcement (101);
EnableAviation (0, 1);
DisableAviation (1, 3);
Suicide();
end;

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

function Objective0f()
if (( GetNUnitsInArea (0, "halfaya") <= 0) and ( GetNUnitsInArea (1, "halfaya") > 0)) then
ObjectiveChanged(0, 2);
RunScript( "RevealObjective1" , 3000);
LandReinforcement (102);
DeleteReinforcement (105);
RunScript( "posily1" , 10000);
RunScript( "protiutok2" , 90000);
Suicide();
end;
end;

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

function protiutok2()
LandReinforcement (103);
RunScript( "Objective1" , 5000);
Suicide();
end;

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

function Objective1()
if (( GetNUnitsInArea (0, "sidi_omar") > 0) and ( GetNUnitsInScriptGroup (103, 1) <= 1)) then
SetIGlobalVar("ukol.1", 1);
ObjectiveChanged(1, 1);
RunScript( "RevealObjective2" , 3000);
RunScript( "protiutok3" , 100000);
Suicide();
end;
end;

function protiutok3()
LandReinforcement (104);
RunScript( "Objective2" , 5000);
Suicide();
end;

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

function Objective2()
if (( GetNUnitsInArea (0, "solum") > 0) and ( GetNUnitsInScriptGroup (104, 1) <= 1)) then
SetIGlobalVar("ukol.2", 1);
ObjectiveChanged(2, 1);
DeleteReinforcement (101);
RunScript( "RevealObjective3" , 3000);
RunScript( "Objective3" , 5000);
RunScript( "RevealObjective4" , 6000);
RunScript( "Objective4" , 5000);
Suicide();
end;
end;

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

function Objective3()
if (( GetNUnitsInArea (0, "halfaya") > 0) and ( GetNUnitsInArea (1, "halfaya") <= 0)) then
SetIGlobalVar("ukol.3", 1);
ObjectiveChanged(3, 1);
Suicide();
end;
end;

function RevealObjective4()
if ( GetNUnitsInArea (0, "line") <= 0) then
        ObjectiveChanged(4, 0);
        Suicide();
	else Suicide();
	end;
end;

function Objective4()
if (( GetNUnitsInArea (0, "line") > 0) and ( GetNUnitsInArea (1, "line") <= 0)) then
SetIGlobalVar("ukol.4", 1);
ObjectiveChanged(4, 1);
RunScript( "ToWin" , 5000);
Suicide();
end;
end;

function Init()
RunScript( "Start" , 1000);
RunScript( "ToLoose1" , 5000);
RunScript( "ToLoose2" , 5000);
RunScript( "ToLoose3" , 5000);
RunScript( "RevealObjective0" , 3000);
RunScript( "Objective0f" , 5000);
RunScript( "protiutok1" , 10000);
end;