function TobeDefeated()
local Numunits = GetNUnitsInScriptGroup(100, 0) + GetNUnitsInScriptGroup(1000, 0) + GetNUnitsInScriptGroup(500, 0); 
if (Numunits <= 0 ) then
		Loose();
		Suicide();
	end;
end;



function Objective0()
Numunits = GetNUnitsInScriptGroup(1) + GetNUnitsInScriptGroup(2); 
if (Numunits < 7 ) then
		SetIGlobalVar("temp.vostochnoprysskai.objective.0", 1);
                ObjectiveChanged(0, 1);
                LandReinforcement(0);
                RunScript( "RevealObjective1", 2000);
                RunScript( "RevealObjective2", 5000);
		Suicide();
	end;
end;


function Objective1()
	if ((GetNUnitsInArea(1, "zensburg") > 0) and (GetNUnitsInScriptGroup(10, 1) <= 1)) then  
		SetIGlobalVar( "temp.vostochnoprysskai.objective.1", 1);
		ObjectiveChanged(1, 1);
		Suicide();
	end;
end;


function Objective2()
	if ((GetNUnitsInArea(1, "bishofsburg") > 0) and (GetNUnitsInScriptGroup(20, 1) <= 1)) then  
		SetIGlobalVar( "temp.vostochnoprysskai.objective.2", 1);
		ObjectiveChanged(2, 1);
		Suicide();
	end;
end;

--attack alenstein------------	
function Attack1()
            Cmd(3,1,11360,11476);
            Cmd(3,2,11360,11476);

            Suicide();
end;
-------------------------------

function Attack2()
          if (GetNUnitsInArea(0, "poezd") > 0) then
          Cmd(3,99,5754,582);
          Suicide();
  end;
end;


function Reinf1()
       if ((GetNUnitsInScriptGroup(1000, 0) < 3) and (GetNUnitsInScriptGroup(100, 0) < 3)) then 
           LandReinforcement(1);
           Suicide();
      end;
end; 
     
  
function ToWin()
        if ( (GetIGlobalVar("temp.vostochnoprysskai.objective.1", 0) * GetIGlobalVar("temp.vostochnoprysskai.objective.2", 0)) == 1) then
		RunScript( "WinWin", 4000);
		Suicide();
	end;
end;


function WinWin()
	Win(0);
	Suicide();
end;


function RevealObjective0()
        if ( GetIGlobalVar("temp.vostochnoprysskai.objective.0", 0) == 0) then
	ObjectiveChanged(0, 0);
        end;
	Suicide();
end;


function RevealObjective1()
	if ( GetIGlobalVar("temp.vostochnoprysskai.objective.1", 0) == 0) then
		ObjectiveChanged(1, 0);
	end;
	Suicide();
end;


function RevealObjective2()
	if ( GetIGlobalVar("temp.vostochnoprysskai.objective.2", 0) == 0) then
		ObjectiveChanged(2, 0);
	end;
	Suicide();
end;


function Init()
	RunScript( "Objective0", 2000);
        RunScript( "Objective1", 2000);
        RunScript( "Objective2", 6000);
        RunScript( "RevealObjective0", 3000);
        RunScript( "Attack1", 40000);
        RunScript( "Attack2", 4000);
        RunScript("TobeDefeated", 5000);
        RunScript( "ToWin", 4000); 
end;

