function Reinf1()
		LandReinforcement(1); 
		LandReinforcement(2); 
		LandReinforcement(3); 
		RunScript( "attack7", 30000);
		RunScript( "attack2", 50000);
		RunScript( "attack3", 50000);
           Suicide();
end;

function attack7()
local A_Swarm = 3; 
            Cmd(3,10,10369, 861);
            Suicide();
 
end;

function attack2()
local A_Swarm = 3; 
            Cmd(3,20,10369, 861);
            Suicide();
 
end;

function attack3()
local A_Swarm = 3; 
            Cmd(3,30,10369, 861);
            Suicide();
 
end;

function dead()
        local Numunits = GetNUnitsInScriptGroup(1000, 0) + GetNUnitsInScriptGroup(500, 0); 
if (Numunits <= 1 ) then
		RunScript( "TobeDefeated", 4000);
           Suicide();
      end;
end;

function proigrish()
       if (GetNUnitsInArea(1, "city") > 3) then
		DisplayTrace ("Niemcy zajęli miasto!", 2000);
		RunScript( "zdaus1", 4000);
		RunScript( "TobeDefeated", 6000);
           Suicide();
      end;
end;

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

function attack4()
local A_Swarm = 3; 
            Cmd(3,40,10369, 861);
            Suicide();
 
end;

function Objective0()
	local Numunits = GetNUnitsInScriptGroup(10, 1) + GetNUnitsInScriptGroup(20, 1) + GetNUnitsInScriptGroup(30, 1); 
if (Numunits <= 4 ) then
		SetIGlobalVar( "temp.ipr.objective.0", 1);
		ObjectiveChanged(0, 1);
                                RunScript( "Ob", 2000);
		RunScript( "RevealObjective1", 2000);
		Suicide();
	end;
end;

function Ob()
		RunScript( "Reinf21", 8000);
		KillScript( "mashina", 2000);
		Suicide();
	end;


function uraaaa()
	if (GetNUnitsInArea(0, "attack1") > 3) then
            LandReinforcement(5);
		RunScript( "attack10", 30000);
           Suicide();
	end;
end;

function attack10()
local A_Swarm = 3; 
            Cmd(3,50,7107, 509);
            Suicide();
 
end;

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

function Objective2()
            if (GetNUnitsInScriptGroup(222, 1) <= 1) then
		SetIGlobalVar( "temp.ipr.objective.2", 1);
		ObjectiveChanged(2, 1);
		RunScript("clean", 2000);
		RunScript( "RevealObjective3", 2000);
		RunScript( "Reinf23", 2000);
		RunScript( "Reinf24", 4000);
		Suicide();
	end;
end;

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

function zdaus1() 
        ChangePlayer(1000, 2);
	DisplayTrace ("Twoje oddziały poddały się i trafiły do niewoli!", 2000); 
        Suicide();
end;

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

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


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


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


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


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

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

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

function Reinf20()
	if (GetNUnitsInArea(0, "attack3") > 3) then
            LandReinforcement(6);
           Suicide();
	end;
end;

function death1()
	if (GetNUnitsInArea(0, "loose1") > 2) then
	DisplayTrace ("Niemcy czekali tutaj na ciebie. Twoje oddziały zostały otoczone i wzięte do niewoli!!!", 2000);
           Loose(); 
           Suicide();
	end;
end;

function death2()
	if (GetNUnitsInArea(0, "loose2") > 2) then
	DisplayTrace ("Niemcy czekali tutaj na ciebie. Twoje oddziały zostały otoczone i wzięte do niewoli!!!", 2000);
           Loose(); 
           Suicide();
	end;
end;

function clean() 
	KillScript( "death1", 2000);
	KillScript( "death2", 2000);
        Suicide();
end;

function Reinf21()
            LandReinforcement(10);
           Suicide();
end;

function mashina()
        if (GetNUnitsInScriptGroup(5000, 0) <= 0) then
	DisplayTrace ("Ciężarówka inżynieryjna została zniszczona!", 2000);
		Loose();
           Suicide();
      end;
end;

function Reinf22()
	if (GetNUnitsInArea(0, "attack4") > 3) then
            LandReinforcement(7);
		RunScript( "attack11", 3000);
           Suicide();
	end;
end;

function attack11()
local A_Swarm = 3; 
            Cmd(3,70,2069, 10497);
            Suicide();
 
end;

function Reinf23()
            LandReinforcement(8);
           Suicide();
end;


function Reinf24()
            LandReinforcement(20);
           Suicide();
end;

function Reinf25()
	if (GetNUnitsInArea(0, "attack5") > 3) then
            LandReinforcement(9);
           Suicide();
	end;
end;

function Init()
	RunScript( "Objective0", 2000);
        RunScript( "Objective1", 2000);
        RunScript( "Objective2", 2000);
        RunScript( "Objective3", 2000);
	RunScript( "RevealObjective0", 2000);
	RunScript( "Reinf1", 2000);
	RunScript( "Reinf20", 2000);
	RunScript( "proigrish", 2000);
	RunScript("ToWin", 4000);
	RunScript("uraaaa", 2000);
	RunScript("death1", 2000);
	RunScript("death2", 2000);
	RunScript("mashina", 2000);
	RunScript( "Reinf22", 2000);
	RunScript( "Reinf25", 2000);
end;
