Code:
program CivonyMapScan;
Const
mapx1 = 600;
mapy1 = 0;
mapx2 = 799;
mapy2 = 199;
RedFlag = 160;
GrnFlag = 110082;
Var
FilePath: String;
a,b,x,y,cx,cy: Integer;
procedure CreateFilePath;
var
i: Integer;
zeros: String;
begin
i:= 0;
repeat
Inc(i);
if(Length(IntToStr(i)) = 1)then
zeros:= '00';
if(Length(IntToStr(i)) = 2)then
zeros:= '0';
if(Length(IntToStr(i)) = 3)then
zeros:= '';
until(FileExists(AppPath + 'Scripts\mapscan'+zeros+IntToStr(i)+'.ini') = False);
FilePath:= (AppPath + 'Scripts\mapscan'+zeros+IntToStr(i)+'.ini');
writeln('file saved as: '+AppPath+'Scripts\mapscan'+zeros+IntToStr(i)+'.ini');
end;
procedure EraseBoxCoords(coordsbox: Integer);
begin
if(coordsbox = 1) then ClickMouse(795,57,True);
if(coordsbox = 2) then ClickMouse(848,57,True);
wait(200);
SendKeysSilent(chr(8));
wait(50);
SendKeysSilent(chr(8));
wait(50);
SendKeysSilent(chr(8));
wait(50);
SendKeysSilent(chr(8));
wait(50);
SendKeysSilent(chr(8));
wait(100);
end;
procedure FindFlags;
var
x1,y1,Column,Row: Integer;
begin
if(findColorTolerance(x,y,GrnFlag,27,43,948,581,1) or findColorTolerance(x,y,RedFlag,27,43,948,581,1))then
begin
Column:= 0;
Row:= 0;
repeat
x1:= Round(51+(Column*126.83));
y1:= Round(41+(Row*79));
if(findColorTolerance(x,y,GrnFlag,x1,y1,x1+43,y1+18,20))then
begin
writeln('found Member at: '+IntToStr(cx-3+Column)+','+IntToStr(cy-3+Row));
WriteINI('Member Coordinates List', 'Member'+IntToStr(a),' '+IntToStr(cx-3+Column)+','+IntToStr(cy-3+Row),FilePath);
Inc(a);
end;
if(findColorTolerance(x,y,RedFlag,x1,y1,x1+43,y1+18,20))then
begin
writeln('found Hostile at: '+IntToStr(cx-3+Column)+','+IntToStr(cy-3+Row));
WriteINI('Hostile Coordinates List', 'Hostile'+IntToStr(b),' '+IntToStr(cx-3+Column)+','+IntToStr(cy-3+Row),FilePath);
Inc(b);
end;
Inc(Column);
if(Column > 6) then
begin
Column:= 0;
Inc(Row);
end;
until((Row = 7) and (Column = 1));
end;
end;
procedure Setup;
begin
cx:= mapx1;
cy:= mapy1;
EraseBoxCoords(1);
SendKeysSilent(IntToStr(cx));
wait(500);
EraseBoxCoords(2);
SendKeysSilent(IntToStr(cy));
wait(200);
ClickMouse(883,57,True);
wait(500);
repeat
wait(100);
until(Not(getcolor(160,133)=8899834));
FindFlags;
end;
procedure CalculateProgress;
var
s: Integer;
begin
s:= ((((cx+3)*(mapx2-mapx1))+(7*(cy+3-mapy1))*100));
status(IntToStr(s));
end;
procedure MapScan;
begin
repeat
if(cy > 796) or (cy > mapy2) then
begin
cy:= mapy1-4;
cx:= (cx + 7);
EraseBoxCoords(1);
SendKeysSilent(IntToStr(cx));
wait(200);
end else
begin
cy:= (cy + 6);
EraseBoxCoords(2);
SendKeysSilent(IntToStr(cy));
wait(100);
ClickMouse(883,57,True);
wait(1000);
repeat
wait(100);
until(Not(getcolor(160,133)=8899834) and Not(getcolor(788,474)=8899834));
wait(200);
FindFlags;
CalculateProgress;
end;
until((cx > 792) or (cx > mapx2));
end;
begin
CreateFilePath;
Setup;
MapScan;
writeln('|---------------|');
writeln('MAP SCAN COMPLETE');
writeln('|---------------|');
end.