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

{$EVENT evtMissionStart:OnMissionStart__Mission6}
{$EVENT evtTick:OnTick__Mission6}

var newDefencePositionsPlaced: boolean;

procedure OnMissionStart__Mission6;
var aiPlayer1RedZone: Rectangle;
var aiPlayer2RedZone: Rectangle;
var aiPlayer3RedZone: Rectangle;
var aiPlayer4RedZone: Rectangle;
begin
	Actions.Log('MISSION 6 BEGIN');
	Actions.LogLinesMaxCnt(10000);
	
	Actions.ShowMsg(0, '<$0>');
	Actions.HouseAllowAllyToSelectAll(1, true);
	newDefencePositionsPlaced := false;
	FillAlliancesPerPlayerIdMap();
		
	aiPlayer1RedZone.topLeftCorner.X := 80;
	aiPlayer1RedZone.topLeftCorner.Y := 53;
	aiPlayer1RedZone.bottomRightCorner.X := 98;
	aiPlayer1RedZone.bottomRightCorner.Y := 62;
	
	aiPlayer2RedZone.topLeftCorner.X := 165;
	aiPlayer2RedZone.topLeftCorner.Y := 50;
	aiPlayer2RedZone.bottomRightCorner.X := 180; 
	aiPlayer2RedZone.bottomRightCorner.Y := 68;
	
	
	aiPlayer3RedZone.topLeftCorner.X := 139;
	aiPlayer3RedZone.topLeftCorner.Y := 89;
	aiPlayer3RedZone.bottomRightCorner.X := 167; 
	aiPlayer3RedZone.bottomRightCorner.Y := 100;
	
	aiPlayer4RedZone.topLeftCorner.X := 145;
	aiPlayer4RedZone.topLeftCorner.Y := 160;
	aiPlayer4RedZone.bottomRightCorner.X := 183; 
	aiPlayer4RedZone.bottomRightCorner.Y := 175;
	
	aiPlayersRedZonesArray := AddElementToRectangleArray(aiPlayersRedZonesArray, aiPlayer1RedZone);
	aiPlayersRedZonesArray := AddElementToRectangleArray(aiPlayersRedZonesArray, aiPlayer2RedZone);
	aiPlayersRedZonesArray := AddElementToRectangleArray(aiPlayersRedZonesArray, aiPlayer3RedZone);		
	aiPlayersRedZonesArray := AddElementToRectangleArray(aiPlayersRedZonesArray, aiPlayer4RedZone);			
	
end;	

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