function pozor1()
local Numunits = GetNUnitsInScriptGroup(1000, 0); 
if (Numunits <= 6 ) then
		RunScript( "zdaus2", 2000);
		RunScript( "good1", 20000);
		Suicide();
	end;
end;

function pozor2()
local Numunits = GetNUnitsInScriptGroup(500, 0); 
if (Numunits <= 9 ) then
		RunScript( "zdaus1", 2000);
		RunScript( "good2", 20000);
		Suicide();
	end;
end;

function Reinf1()
		RunScript( "attack1", 40000);
		RunScript( "attack2", 40000);
		RunScript( "attack3", 40000);
		RunScript( "pozor1", 6000);
		RunScript( "pozor2", 8000);
           Suicide();
end;

function attack1()
local A_Swarm = 3; 
            Cmd(3,10,1762, 2634);
            Suicide();
 
end;

function attack2()
local A_Swarm = 3; 
            Cmd(3,20,7560, 2224);
            Suicide();
 
end;

function attack3()
local A_Swarm = 3; 
            Cmd(3,30,7560, 2224);
            Suicide();
 
end;

function good1()
local A_Swarm = 3; 
            Cmd(3,10,7560, 2224);
            Suicide();
 
end;

function good2()
local A_Swarm = 3; 
            Cmd(3,20,1762, 2634);
		 Cmd(3,30,1762, 2634);
            Suicide();
 
end;

function dead()
        local Numunits = GetNUnitsInScriptGroup(1000, 0) + GetNUnitsInScriptGroup(500, 0); 
if (Numunits <= 1 ) then

		RunScript( "TobeDefeated", 4000);
           Suicide();
      end;
end;

function Objective0()
	local Numunits = GetNUnitsInScriptGroup(40, 1) + GetNUnitsInScriptGroup(50, 1) + GetNUnitsInScriptGroup(30, 1); 
if (Numunits <= 4 ) then
		SetIGlobalVar( "temp.battle_verden.objective.0", 1);
		ObjectiveChanged(0, 1);
		RunScript( "RevealObjective1", 2000);
		RunScript( "RevealObjective2", 3000);
                                    RunScript( "RevealObjective3", 4000);
                                    RunScript( "RevealObjective5", 6000);
		RunScript( "Reinf2", 8000);
		RunScript( "clean", 2000);
		RunScript( "backin", 4000);
		Suicide();
	end;
end;

function clean() 
        ChangePlayer(1000, 0);
	ChangePlayer(500, 0);
	KillScript( "dead", 2000);
	KillScript( "pozor2", 2000);
	KillScript( "pozor1", 2000);
	KillScript( "zdaus1", 2000);
	KillScript( "zdaus2", 2000);
	KillScript( "Reinf1", 2000);
	KillScript( "povtor1", 2000);
	KillScript( "povtor2", 2000);
        Suicide();
end;

function backin()
local A_Swarm = 3; 
            Cmd(3,50,7560, 2224);
		Cmd(3,40,8480, 10480);
		Cmd(3,30,8480, 10480);
		Cmd(3,20,8480, 10480);
		Cmd(3,10,8480, 10480);
            Suicide();
 
end;

function povtor1()
        if (GetNUnitsInScriptGroup(10, 1) <= 12) then
            LandReinforcement(4);
		RunScript( "attack4", 2000);
           Suicide();
      end;
end;

function attack4()
local A_Swarm = 3; 
            Cmd(3,40,1762, 2634);
            Suicide();
 
end;

function povtor2()
        if (GetNUnitsInScriptGroup(20, 1) <= 12) then
            LandReinforcement(5);
		RunScript( "attack5", 8000);
           Suicide();
      end;
end;

function attack5()
local A_Swarm = 3; 
            Cmd(3,50,7560, 2224);
            Suicide();
 
end;

function Objective1()
         if (GetNUnitsInScriptGroup(111, 1) <= 1) then
		SetIGlobalVar( "temp.battle_verden.objective.1", 1);
		ObjectiveChanged(1, 1);
		Suicide();
	end;
end;

function Objective2()
         if (GetNUnitsInScriptGroup(222, 1) <= 1) then
		SetIGlobalVar( "temp.battle_verden.objective.2", 1);
		ObjectiveChanged(2, 1);
		Suicide();
	end;
end;

function Objective3()
           if( (GetNUnitsInArea(0, "visota") > 3) and  (GetNUnitsInArea(1, "visota") < 1)) then
		SetIGlobalVar( "temp.battle_verden.objective.3", 1);
		ObjectiveChanged(3, 1);
		RunScript( "RevealObjective4", 5000);
		RunScript( "Reinf5", 4000);
		RunScript( "uraaaa", 2000);
		RunScript( "visotaout", 10000);
		Suicide();
	end;
end;

function visotaout()
        if( (GetNUnitsInArea(1, "visota") > 3) and (GetNUnitsInArea(0, "visota") < 3)) then
		DisplayTrace ("Niemcy zajęli wzgórze 304.0!", 2000);
		Loose();
		Suicide();
	end;
end;

function Objective4()
         if (GetNUnitsInScriptGroup(444, 1) <= 0) then
		SetIGlobalVar( "temp.battle_verden.objective.4", 1);
		ObjectiveChanged(4, 1);
		KillScript( "visotaout", 2000);
		RunScript( "beg", 2000);
		Suicide();
	end;
end;

function beg()
local A_Swarm = 3; 
            Cmd(3,90,11116, 11612);
            Suicide();
 
end;

function Objective5()
         if (GetNUnitsInArea(0, "end") > 3) then
		SetIGlobalVar( "temp.battle_verden.objective.5", 1);
		ObjectiveChanged(5, 1);
		Suicide();
	end;
end;

function uraaaa()
            LandReinforcement(9);
		RunScript( "attack9", 30000);
           Suicide();
end;

function attack9()
local A_Swarm = 3; 
            Cmd(3,190,5777, 9324);
		Cmd(3,444,5777, 9324);
            Suicide();
 
end;

function zdaus1() 
        ChangePlayer(500, 2);
	DisplayTrace ("Twoje oddziały poddały się!!!", 2000); 
        Suicide();
end;

function zdaus2() 
        ChangePlayer(1000, 2);
	DisplayTrace ("Twoje oddziały poddały się!", 2000); 
        Suicide();
end;

function TobeDefeated()
		Loose();
		Suicide();
end;

function ToWin()
        if ( (GetIGlobalVar("temp.battle_verden.objective.0", 0) * GetIGlobalVar("temp.battle_verden.objective.1", 0) * GetIGlobalVar("temp.battle_verden.objective.2", 0) * GetIGlobalVar("temp.battle_verden.objective.3", 0) * GetIGlobalVar("temp.battle_verden.objective.4", 0) * GetIGlobalVar("temp.battle_verden.objective.5", 0)) == 1) then
		RunScript( "WinWin", 4000);
		Suicide();
	end;
end;

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


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


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


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


function RevealObjective3()
	if ( GetIGlobalVar("temp.battle_verden.objective.3", 0) == 0) then
		ObjectiveChanged(3, 0);
	end;
	Suicide();
end;

function RevealObjective4()
	if ( GetIGlobalVar("temp.battle_verden.objective.4", 0) == 0) then
		ObjectiveChanged(4, 0);
	end;
	Suicide();
end;

function RevealObjective5()
	if ( GetIGlobalVar("temp.battle_verden.objective.5", 0) == 0) then
		ObjectiveChanged(5, 0);
	end;
	Suicide();
end;

function last()
          if ( (GetIGlobalVar("temp.battle_verden.objective.0", 0) * GetIGlobalVar("temp.battle_verden.objective.1", 0) * GetIGlobalVar("temp.battle_verden.objective.2", 0)) == 1) then
		RunScript( "RevealObjective3", 2000);
		Suicide();
	end;
end;

function Reinf2()
            LandReinforcement(10);
		LandReinforcement(20);
           Suicide();
end;

function Reinf3()
        if (GetNUnitsInArea(0, "zasada1") > 0) then
            LandReinforcement(6);
		LandReinforcement(25);
		RunScript( "Fit1", 2000); 
           Suicide();
      end;
end;

function Fit1()
	AddIronMan(252);
	Suicide();
end;

function Reinf4()
        if (GetNUnitsInArea(0, "zasada2") > 0) then
            LandReinforcement(7);
		LandReinforcement(26);
		RunScript( "Fit2", 2000); 
           Suicide();
      end;
end;

function Fit2()
	AddIronMan(256);
	Suicide();
end;

function Reinf5()
        if (GetNUnitsInArea(0, "mission2") > 0) then
            LandReinforcement(8);
           Suicide();
      end;
end;

function Reinf6()
            LandReinforcement(30);
           Suicide();
end;

function Reinf12()
        if (GetNUnitsInArea(0, "casle") > 0) then
            LandReinforcement(12);
           Suicide();
      end;
end;

function Init()
	RunScript( "Objective0", 2000);
        RunScript( "Objective1", 2000);
        RunScript( "Objective2", 2000);
        RunScript( "Objective3", 2000);
	RunScript( "Objective4", 2000);
        RunScript( "Objective5", 2000);
	RunScript( "RevealObjective0", 4000);
	RunScript("ToWin", 4000);
	RunScript( "Reinf1", 2000);
	RunScript( "Reinf3", 2000);
	RunScript( "Reinf4", 2000);
	RunScript( "Reinf5", 2000);
	RunScript( "Reinf12", 2000);
	RunScript( "dead", 2000);
	RunScript( "povtor1", 4000);
	RunScript( "povtor2", 4000);
	RunScript( "last", 4000);
end;
