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 RevealObjective0()
if ( GetIGlobalVar("ukol.0", 0) == 0) then
        ObjectiveChanged(0, 0);
        Suicide();
	else Suicide();
	end;
end;

function Objective0()
if ( GetNUnitsInScriptGroup(500) <= 0) then
SetIGlobalVar("ukol.0", 1);
ObjectiveChanged(0, 1);
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, "city") <= 0) then
SetIGlobalVar("ukol.1", 1);
ObjectiveChanged(1, 1);
RunScript( "RevealObjective3" , 3000);
RunScript( "RevealObjective4" , 6000);
RunScript( "Objective3" , 5000);
RunScript( "Objective4" , 5000);
Suicide();
end;
end;

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

function Objective2()
if ( GetNUnitsInScriptGroup(101, 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, "supply") <= 0) and ( GetNUnitsInArea (0, "supply") >= 1)) 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 ( GetNUnitsInArea (0, "exit") >= 1) then
SetIGlobalVar("ukol.4", 1);
ObjectiveChanged(4, 1);
Suicide();
end;
end;

function protiutok1()
if ( GetNScriptUnitsInArea (11, "mines") >= 1) then
GiveCommand (3, 102, 4583, 5225);
GiveCommand (3, 103, 1400, 700);
GiveQCommand (3, 103, 711, 3911);
Suicide();
end;
end;

function protiutok2()
if ( GetNUnitsInArea (0, "evade") >= 1) then
GiveCommand (3, 105, 960, 2650);
GiveCommand (3, 104, 8357, 5332);
GiveQCommand (3, 104, 711, 3911);
Suicide();
end;
end;

function posily1()
if ( GetNUnitsInScriptGroup(11, 0) <= 1) then
LandReinforcement (1);
DisplayTrace ("Engineers are essential in the desert. Keep that in mind, commander!");
Suicide();
end;
end;

function Init()
RunScript( "Start" , 1000);
RunScript( "ToWin" , 5000);
RunScript( "ToLoose1" , 5000);
RunScript( "RevealObjective0" , 3000);
RunScript( "RevealObjective1" , 6000);
RunScript( "RevealObjective2" , 9000);
RunScript( "Objective0" , 5000);
RunScript( "Objective1" , 5000);
RunScript( "Objective2" , 5000);
RunScript( "posily1" , 5000);
RunScript( "protiutok1" , 10000);
RunScript( "protiutok2" , 5000);
end;