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

{$EVENT evtMissionStart:OnMissionStart__Mission8}
{$EVENT evtTick:OnTick__Mission8}

var newDefencePositionsPlaced: boolean;

procedure OnMissionStart__Mission8;
var aiPlayer1RedZone: Rectangle;
var aiPlayer2RedZone: Rectangle;
var aiPlayer3RedZone: Rectangle;
var aiPlayer4RedZone: Rectangle;
var aiPlayer5RedZone: Rectangle;
var aiPlayer6RedZone: Rectangle;
var aiPlayer7RedZone: Rectangle;
begin
	Actions.Log('MISSION 8 BEGIN');
	Actions.LogLinesMaxCnt(10000);
	
	Actions.ShowMsg(0, '<$0>');
	Actions.HouseAllowAllyToSelectAll(1, true);
	Actions.HouseAllowAllyToSelectAll(2, true);
	newDefencePositionsPlaced := false;
	FillAlliancesPerPlayerIdMap();
		
	aiPlayer1RedZone.topLeftCorner.X := 42;
	aiPlayer1RedZone.topLeftCorner.Y := 120;
	aiPlayer1RedZone.bottomRightCorner.X := 57;
	aiPlayer1RedZone.bottomRightCorner.Y := 142;
	
	aiPlayer2RedZone.topLeftCorner.X := 122;
	aiPlayer2RedZone.topLeftCorner.Y := 124;
	aiPlayer2RedZone.bottomRightCorner.X := 144; 
	aiPlayer2RedZone.bottomRightCorner.Y := 131;
	
	
	aiPlayer3RedZone.topLeftCorner.X := 7;
	aiPlayer3RedZone.topLeftCorner.Y := 28;
	aiPlayer3RedZone.bottomRightCorner.X := 25; 
	aiPlayer3RedZone.bottomRightCorner.Y := 49;
	
	aiPlayer4RedZone.topLeftCorner.X := 168;
	aiPlayer4RedZone.topLeftCorner.Y := 38;
	aiPlayer4RedZone.bottomRightCorner.X := 188; 
	aiPlayer4RedZone.bottomRightCorner.Y := 51;
	
	aiPlayer5RedZone.topLeftCorner.X := 41;
	aiPlayer5RedZone.topLeftCorner.Y := 79;
	aiPlayer5RedZone.bottomRightCorner.X := 58; 
	aiPlayer5RedZone.bottomRightCorner.Y := 95;
	
	aiPlayer6RedZone.topLeftCorner.X := 134;
	aiPlayer6RedZone.topLeftCorner.Y := 72;
	aiPlayer6RedZone.bottomRightCorner.X := 151; 
	aiPlayer6RedZone.bottomRightCorner.Y := 82;
	
	aiPlayer7RedZone.topLeftCorner.X := 83;
	aiPlayer7RedZone.topLeftCorner.Y := 44;
	aiPlayer7RedZone.bottomRightCorner.X := 120; 
	aiPlayer7RedZone.bottomRightCorner.Y := 64;
	
	aiPlayersRedZonesArray := AddElementToRectangleArray(aiPlayersRedZonesArray, aiPlayer1RedZone);
	aiPlayersRedZonesArray := AddElementToRectangleArray(aiPlayersRedZonesArray, aiPlayer2RedZone);
	aiPlayersRedZonesArray := AddElementToRectangleArray(aiPlayersRedZonesArray, aiPlayer3RedZone);		
	aiPlayersRedZonesArray := AddElementToRectangleArray(aiPlayersRedZonesArray, aiPlayer4RedZone);		
	aiPlayersRedZonesArray := AddElementToRectangleArray(aiPlayersRedZonesArray, aiPlayer5RedZone);		
	aiPlayersRedZonesArray := AddElementToRectangleArray(aiPlayersRedZonesArray, aiPlayer6RedZone);		
	aiPlayersRedZonesArray := AddElementToRectangleArray(aiPlayersRedZonesArray, aiPlayer7RedZone);		
	
end;	

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