function Objective0()
  if ( GetIGlobalVar("temp.narva.objective.0", 0) == 0) then     
	ObjectiveChanged(0, 0);
	Suicide();
	end;	
end;
--------------------------------------------------------------------------------
function Objective1()
  if ( GetIGlobalVar("temp.narva.objective.1", 0) == 0) then     
	ObjectiveChanged(1, 0);
	Suicide();
	end;	
end;
--------------------------------------------------------------------------------
function Objective2()
  if ( GetIGlobalVar("temp.narva.objective.2", 0) == 0) then     
	ObjectiveChanged(2, 0);
	Suicide();
  	end;	
end;
---------------------------------------------------------------------------------
function Objective3()
  if ( GetIGlobalVar("temp.narva.objective.3", 0) == 0) then     
	ObjectiveChanged(3, 0);
	Suicide();
  	end;	
end;

---------------------------------------------------------------------------------
function Objective4()
  if ( GetIGlobalVar("temp.narva.objective.4", 0) == 0) then     
	ObjectiveChanged(4, 0);
	Suicide();
  	end;	
end;
---------------------------------------------------------------------------------
function z_0()

Group1 = GetNUnitsInScriptGroup(1);

	
	if (Group1  < 2) then
	--DisplayTrace ("z0");
	SetIGlobalVar("temp.narva.objective.0", 1);
	ObjectiveChanged(0, 1);
	RunScript("Objective1", 2000);
	Suicide();
	end;
end;
---------------------------------------------------------------------------------
function z_1()
	if (GetNUnitsInArea(1, "z_1") < 1) then
	--DisplayTrace ("z1");
	SetIGlobalVar("temp.narva.objective.1", 1);
	ObjectiveChanged(1, 1);
	RunScript("Objective2", 2000);
	Suicide();
	end;
end;
--------------------------------------------------------------------------------
function z_3()
	if (GetNUnitsInArea(1, "z_2") < 1) then
	--DisplayTrace ("z2");
	SetIGlobalVar("temp.narva.objective.2", 1);
	ObjectiveChanged(2, 1);
	LandReinforcement(10);
	RunScript("Objective3", 2000);	
	RunScript("at1", 60000);
	Suicide();
	end;
end;
--------------------------------------------------------------------------------
function z_4()
	if (GetNUnitsInScriptGroup(2) < 1) then
	--DisplayTrace ("z3");
	SetIGlobalVar("temp.narva.objective.3", 1);
	LandReinforcement(20);
	ObjectiveChanged(3, 1);
	RunScript("Objective4", 2000);
	Suicide();
	end;
end;

--------------------------------------------------------------------------------
function z_5()
	if (GetNUnitsInArea(1, "z_4") < 1) then
	DisplayTrace ("z4");
	SetIGlobalVar("temp.narva.objective.4", 1);
	ObjectiveChanged(4, 1);
	Suicide();
	end;
end;

--------------------------------------------------------------------------------
function at1()

	GiveCommand(3,2,x100,y100);
x100, y100 = GetScriptAreaParams ("z_3");

     if (GetNUnitsInArea(1, "z_3") > 0) then
	if (GetNUnitsInArea(0, "z_3") < 1) then
	RunScript("gamover_Loose1", 5000);	
	Suicide();
	end;
     end;
end;

--------------------------------------------------------------------------------
function df_0()

		--DisplayTrace ("placebo");

		GiveCommand(3,33,x200,y200);




			if ( GetNUnitsInArea(0, "d1") > 0) then
                                              x200, y200 = GetScriptAreaParams ("d1");

			end;


			if ( GetNUnitsInArea(0, "d9") > 0) then
                                              x200, y200 = GetScriptAreaParams ("d9");

			end;

			if ( GetNUnitsInArea(0, "d2") > 0) then
                                              x200, y200 = GetScriptAreaParams ("d2");

			end;

			if ( GetNUnitsInArea(0, "d3") > 0) then
                                              x200, y200 = GetScriptAreaParams ("d3");

			end;

			if ( GetNUnitsInArea(0, "d4") > 0) then
                                              x200, y200 = GetScriptAreaParams ("d4");

			end;

			if ( GetNUnitsInArea(0, "d5") > 0) then
                                              x200, y200 = GetScriptAreaParams ("d5");

			end;

			if ( GetNUnitsInArea(0, "d6") > 0) then
                                              x200, y200 = GetScriptAreaParams ("d6");

			end;


			if ( GetNUnitsInArea(0, "d7") > 0) then
                                              x200, y200 = GetScriptAreaParams ("d7");

			end;

			if ( GetNUnitsInArea(0, "d8") > 0) then
                                              x200, y200 = GetScriptAreaParams ("d8");

			end;

			if ( GetNUnitsInArea(0, "d10") > 0) then
                                              x200, y200 = GetScriptAreaParams ("d10");

			end;
			if ( GetNUnitsInArea(0, "d0") > 0) then
                                              x200, y200 = GetScriptAreaParams ("d0");

			end;

			if ( GetNUnitsInArea(0, "d11") > 0) then
                                              x200, y200 = GetScriptAreaParams ("d11");

			end;

			if ( GetNUnitsInArea(0, "d12") > 0) then
                                              x200, y200 = GetScriptAreaParams ("d12");

			end;

			if ( GetNUnitsInArea(0, "d14") > 0) then
                                              x200, y200 = GetScriptAreaParams ("d14");

			end;

			if ( GetNUnitsInArea(0, "d13") > 0) then
                                              x200, y200 = GetScriptAreaParams ("d13");

			end;
			if ( GetNUnitsInArea(0, "d15") > 0) then
                                              x200, y200 = GetScriptAreaParams ("d15");

			end;
			
			if ( GetNUnitsInArea(0, "d16") > 0) then
                                              x200, y200 = GetScriptAreaParams ("d16");

			end;

			if ( GetNUnitsInArea(0, "d17") > 0) then
                                              x200, y200 = GetScriptAreaParams ("d17");

			end;

			if ( GetNUnitsInArea(0, "d18") > 0) then
                                              x200, y200 = GetScriptAreaParams ("d18");

			end;

			if ( GetNUnitsInArea(0, "d19") > 0) then
                                              x200, y200 = GetScriptAreaParams ("d19");

			end;

			if ( GetNUnitsInArea(0, "d20") > 0) then
                                              x200, y200 = GetScriptAreaParams ("d20");

			end;

end;
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
function ToWin()
	if ((GetIGlobalVar("temp.narva.objective.0", 0) 
	* GetIGlobalVar("temp.narva.objective.1", 0) 
	* GetIGlobalVar("temp.narva.objective.2", 0)
	* GetIGlobalVar("temp.narva.objective.3", 0)  
	* GetIGlobalVar("temp.narva.objective.4", 0)) == 1) then
		Win(0);
		Suicide();
	end;
end;
---------------------------------------------------------------------------------
function gamover_Loose1()
	if ( GetNUnitsInParty (0) < 1) then
	RunScript("gamover_Loose0", 5000);
	Suicide();
	end;
end;
---------------------------------------------------------------------------------
function gamover_Loose0()
        Loose();
        Suicide();
end;
---------------------------------------------------------------------------------
function Init()
	RunScript("Objective0", 2000);
	RunScript("z_0", 2000);
	RunScript("z_1", 2000);
	RunScript("z_2", 2000);
	RunScript("z_3", 2000);
	RunScript("z_5", 2000);
	RunScript("z_4", 2000);
	RunScript("df_0", 2000);
	RunScript("ToWin", 2000);
	RunScript("gamover_Loose1", 2000);
end;
