{$I PTL05Attacks.script}
{$I PTLRebuild.script}
{$I PTLDefence.script}

{$EVENT evtMissionStart:OnMissionStart__Mission5}
{$EVENT evtTick:OnTick__Mission5}

var newDefencePositionsPlaced: boolean;

procedure OnMissionStart__Mission5;
var aiPlayer1RedZone: Rectangle;
var aiPlayer2RedZone: Rectangle;
var aiPlayer3RedZone: Rectangle;
var aiPlayer4RedZone: Rectangle;
begin
	Actions.Log('MISSION 5 BEGIN');
	Actions.LogLinesMaxCnt(10000);
	
	Actions.ShowMsg(0, '<$0>');
	Actions.HouseAllowAllyToSelectAll(1, true);
	newDefencePositionsPlaced := false;
	FillAlliancesPerPlayerIdMap();
		
	aiPlayer1RedZone.topLeftCorner.X := 9;
	aiPlayer1RedZone.topLeftCorner.Y := 130;
	aiPlayer1RedZone.bottomRightCorner.X := 40;
	aiPlayer1RedZone.bottomRightCorner.Y := 168;
	
	aiPlayer2RedZone.topLeftCorner.X := 13;
	aiPlayer2RedZone.topLeftCorner.Y := 35;
	aiPlayer2RedZone.bottomRightCorner.X := 43; 
	aiPlayer2RedZone.bottomRightCorner.Y := 47;
	
	
	aiPlayer3RedZone.topLeftCorner.X := 142;
	aiPlayer3RedZone.topLeftCorner.Y := 16;
	aiPlayer3RedZone.bottomRightCorner.X := 174; 
	aiPlayer3RedZone.bottomRightCorner.Y := 51;
	
	aiPlayer4RedZone.topLeftCorner.X := 149;
	aiPlayer4RedZone.topLeftCorner.Y := 153;
	aiPlayer4RedZone.bottomRightCorner.X := 172; 
	aiPlayer4RedZone.bottomRightCorner.Y := 173;
	
	aiPlayersRedZonesArray := AddElementToRectangleArray(aiPlayersRedZonesArray, aiPlayer1RedZone);
	aiPlayersRedZonesArray := AddElementToRectangleArray(aiPlayersRedZonesArray, aiPlayer2RedZone);
	aiPlayersRedZonesArray := AddElementToRectangleArray(aiPlayersRedZonesArray, aiPlayer3RedZone);		
	aiPlayersRedZonesArray := AddElementToRectangleArray(aiPlayersRedZonesArray, aiPlayer4RedZone);			
	
end;	

procedure OnTick__Mission5;
var defencePosition: TKMDefencePositionInfo;
begin
	if States.GameTime mod 100 = 0 then
		begin
				Actions.HouseAllowAllyToSelectAll(1, true);
		end;
end;