
-------------------------------------------------------------------------------------------------Bridges_def
function B1_Guard()
	if (GetNUnitsInArea(0, "b1") > 0) then
		GiveCommand(3,44,715,10080);
		RunScript( "B1_Guard2", 2000);
		Suicide();
	end;
end;

function B1_Guard2()
	if (GetNUnitsInArea(0, "b1") < 1) then
		GiveCommand(0,44,836,8608);
		QCmd(8,44,715,10080);
		RunScript( "KillBridge1", 14000);
		RunScript( "B1_Guard", 10000);
		Suicide();
	end;
end;
----------------------------
function B2_Guard()
	if (GetNUnitsInArea(0, "b2") > 0) then
		GiveCommand(3,45,2165,10070);
		RunScript( "B22_Guard2", 2000);
		Suicide();
	end;
end;

function B22_Guard2()
	if (GetNUnitsInArea(0, "b2") < 1) then
		GiveCommand(0,45,2193,8638);
		QCmd(8,45,2165,10070);
		RunScript( "KillBridge2", 14000);
		RunScript( "B2_Guard", 10000);
		Suicide();
	end;
end;

---------------------------------------------------

function KillBridge1()
	if ((GetNUnitsInArea(0, "b1") < 1) or (GetIGlobalVar("temp.objective.0", 0) ~= 2)) then
		DamageObject( 56,0);
		Suicide();
	end;
end;

function KillBridge2()
	if ((GetNUnitsInArea(0, "b2") < 1) or (GetIGlobalVar("temp.objective.0", 0) ~= 2)) then
		DamageObject( 55,0);
		Suicide();
	end;
end;
----------------------------------------------------
function Bridge1()
	DamageObject( 55,0);
	Suicide();
end;

function Bridge2()
	DamageObject( 56,0);
	Suicide();
end;

--------------------------------------------------------------------------Looses
function ToDefead()
            if ( GetNUnitsInParty(0) < 1) then
                    Loose(0);
                    Suicide();
           end;
end;
-------------------------------------------------------------------------Objectives_Wineer
function RevealObjective0()
	ObjectiveChanged(0, 0);
	Suicide();
end;

function RevealObjective1()
	ObjectiveChanged(1, 0);
	Suicide();
end;

function Objective0()
	if ((GetNUnitsInArea(0, "cannes") > 0) and (GetNUnitsInArea(1, "cannes") <= 0)) then
		ObjectiveChanged(0, 1);
		SetIGlobalVar("temp.objective.0", 2);
		Suicide();
	end;
end;

function Objective1()
	if ((GetNUnitsInArea(0, "road") > 0) and (GetNUnitsInArea(1, "road") <= 0)) then
		ObjectiveChanged(1, 1);
		SetIGlobalVar("temp.objective.1", 2);
		Suicide();
	end;
end;

function ToWin()
	if ((GetIGlobalVar("temp.objective.0", 0) and GetIGlobalVar("temp.objective.1", 0)) == 2) then
		RunScript( "RevealObjective2", 4000);
		Suicide();
	end;
end;
---------------------------------------------------------------------------Weather
function Weatswitch()
	SwitchWeatherAutomatic(0);
	Suicide();
end;

function Wetbad()
	SwitchWeather(1);
        RunScript("Wetgood", RandomInt (70000) + 100000 );
	Suicide();
end;

function Wetgood()
	SwitchWeather(0);
            RunScript("Wetbad", RandomInt (70000) + 100000 );
	Suicide();
end;
----------------------------------------------------------------------------------German_reinf_1
function Renf_GTank1()
	if (GetNUnitsInScriptGroup(200, 1) < 1) then
		RunScript("GTank1", RandomInt (20000) + 60000 );
		Suicide();
	end;
end;

function GTank1()
	LandReinforcement(2);
	Suicide();
end;
-----------------------------------------------------------------------------------German_Attack1
function German_Attack1()
	if ((GetNUnitsInArea(1, "cannes") <= 6) or (GetNUnitsInArea(0, "road") > 0)) then
		LandReinforcement(3);
		RunScript("G_Attack1", RandomInt (4000) + 40000 );
		Suicide();
	end;
end;

function G_Attack1()
	GiveCommand(3,301,11429,11386);
	QCmd(3,301,8717,2938);
	QCmd(3,301,2207,967);
	Suicide();
end;

function Renf_Brit_Tank()
	if (GetNUnitsInScriptGroup(110, 0) <= 4) then
		LandReinforcement(1);
		DisplayTrace ("Берегите свои войска, командир. Это наше последнее подкрепление!!!");
		Suicide();
	end;
end;
------------------------------------------------------------------------------------Last_blow
function RevealObjective2()
	ObjectiveChanged(2, 0);
	RunScript( "Last_blow", 8000);
	Suicide();
end;

function Last_blow()
            RunScript( "Rand_reinf", 2000);
            Suicide();
end;

function Rand_reinf()
local x = RandomInt(2);
	if x == 0 then
	RunScript("Reinf4", 2000);
	end;
	if x == 1 then
	RunScript("Reinf5", 2000);
	end;
	Suicide();
end;

function Reinf4()
        LandReinforcement(4);
	RunScript( "G_1", 2000);
	Suicide();
end;

function Reinf5()
        LandReinforcement(5);
	RunScript( "G_2", 2000);
	Suicide();
end;

function G_1()
	GiveCommand(3,501,5695,1398);
	QCmd(3,501,4868,5688);
	QCmd(3,501,2741,8433);
	QCmd(3,501,682,8594);
	QCmd(3,501,717,9853);
	QCmd(3,501,3210,9646);
	RunScript( "Winns1", 8000);
	Suicide();
end;

function G_2()
	GiveCommand(3,502,6925,8369);
	QCmd(3,502,691,9991);
	QCmd(3,502,774,8402);
	QCmd(3,502,2216,8484);
	RunScript( "Winns2", 8000);
	Suicide();
end;

function Winns1()
	if (GetNUnitsInScriptGroup(501, 1) <= 0) then
		ObjectiveChanged(2, 1);
		RunScript( "WinGB", 4000);
	end;
end;

function Winns2()
		if (GetNUnitsInScriptGroup(502, 1) <= 0) then
		ObjectiveChanged(2, 1);
		RunScript( "WinGB", 4000);
	end;
end;

function WinGB()
        Win(0);
end;
------------------------------------------MAIN

function Init()
	RunScript( "Renf_Brit_Tank", 6000);
	RunScript( "German_Attack1", 2000);
	RunScript( "Renf_GTank1", 2000);
	RunScript( "B1_Guard", 2000);
	RunScript( "B2_Guard", 2000);
	RunScript( "Bridge1", 500);
	RunScript( "Bridge2", 500);
	RunScript( "Objective0", 4000);
	RunScript( "Objective1", 4000);
	RunScript( "ToWin", 2000);
	RunScript( "ToDefead", 2000);
	RunScript( "Weatswitch", 2000);
	RunScript( "Wetbad", 2000);
	RunScript( "RevealObjective0",6000);
	RunScript( "RevealObjective1",30000);
end;