Simba Code:
(**
This is a program that will automatically create the entire Runescape from
in game screenshots. The final image will be saved as a .bmp and saved to
the PATH_MAP constant file path.
NOTES:
~~~~~~
* I suggest using SMART or running it overnight as it takes a VERY long time
* If you're using SMART, start with the map CLOSED
* If you're not using SMART, you can start with it open OR closed
* ALWAYS start logged in; it won't login for you
* Reccommend running on a bad account as it's quite tedious
*)
program new;
//{$DEFINE SMART}
{$i srl/srl.scar}
const
PATH_MAP = appPath + 'sps_temp.bmp';
NEXT_COLUMN = 8;
NEXT_ROW = 4;
OVERLAP_X = 15;
OVERLAP_Y = 80;
COLUMNS = 2;
ROWS = 2;
var
bmpGrid: array[0..(COLUMNS - 1)] of array[0..(ROWS - 1)] of TMufasaBitmap;
bmpWorld: TMufasaBitmap;
function mapOpen(): boolean;
begin
result := (getColor(749, 467) = 657930);
end;
function openMap(): boolean;
var
x, y: integer;
begin
if (findColorTolerance(x, y, 14802090, 510, 120, 565, 165, 5)) then
mouse(x, y, 5, 5, true);
result := waitFunc(@mapOpen, 500, 15000);
if (result) then
while (countColorTolerance(0, 10, 10, 100, 100, 10) > 500) do
wait(100);
end;
procedure set100Percent();
var
x, y: integer;
begin
if (findText(x, y, '100', statChars, 700, 460, 760, 495)) then
exit;
mouse(750, 475, 2, 2, true);
end;
procedure nextColumn();
var
i: integer;
begin
for i := 1 to NEXT_COLUMN do
begin
typeByte(VK_RIGHT);
wait(1000+random(500));
end;
end;
procedure nextRow();
var
i: integer;
begin
for i := 1 to NEXT_ROW do
begin
typeByte(VK_DOWN);
wait(1000+random(500));
end;
end;
procedure reset();
var
i: integer;
begin
i := 0;
mouse(680, 480, 5, 5, true); // opens the overview map
wait(200 + random(300));
mouse(660, 380, 0, 0, true); // random spot on the map (used for testing)
{ commented out for testing
mouse(612, 312, 1, 1, true);
for i := 1 to 5 do
begin
typeByte(VK_LEFT);
wait(200 + random(300));
typeByte(VK_UP);
wait(200 + random(300));
end;
}
mouse(680, 480, 5, 5, true); // removes the overview map
mmouse(600, 400, 30, 30); // to get rid of the "overview" uptext
end;
procedure goPosition(row, column: integer);
var
i: integer;
begin
reset();
for i := 1 to column do
begin
nextColumn();
writeln('At column '+toStr(i));
end;
for i := 1 to row do
begin
nextRow();
writeln('At row '+toStr(i));
end;
end;
// returns the cropped screenshot of the map
function getPiece(): integer;
var
w, h: integer;
begin
getClientDimensions(w, h);
result := createBitmap(w, h);
copyClientToBitmap(result, 7, 7, w - 26, h - 43);
end;
function getMufaPiece(): TMufasaBitmap;
var
bmp: integer;
begin
bmp := getPiece();
result := getMufasaBitmap(bmp);
end;
procedure setPieces();
var
x, y, h, hh: integer;
begin
h := high(bmpGrid);
for x := 0 to h do
begin
goPosition(0, x);
hh := high(bmpGrid[x]);
for y := 0 to hh do
begin
bmpGrid[x][y] := getMufaPiece();
if (y <> hh) then
nextRow();
end;
end;
end;
procedure createMap();
var
x, y, w, h: integer;
begin
setPieces();
bmpWorld := TMufasaBitmap.create();
for x := 0 to high(bmpGrid) do
w := (w + bmpGrid[x][0].width);
for y := 0 to high(bmpGrid[0]) do
h := (h + bmpGrid[0][y].height - OVERLAP_Y);
bmpWorld.setSize(w, h);
bmpWorld.fastDrawClear(clBlack); // transparent colour
w := 0;
h := 0;
for x := 0 to high(bmpGrid) do
begin
h := 0;
w := bmpGrid[x][0].width * x;
for y := 0 to high(bmpGrid[x]) do
begin
bmpGrid[x][y].fastDrawTransparent(w, h, bmpWorld);
h := (h + bmpGrid[x][y].height - OVERLAP_Y);
end;
end;
end;
procedure free();
var
i, j: integer;
begin
for i := 0 to high(bmpGrid) do
for j := 0 to high(bmpGrid[i]) do
bmpGrid[i][j].free();
end;
var
t: integer;
begin
{$IFDEF SMART}
SMART_Server := 152;
SMART_Members := False;
SMART_Signed := True;
SMART_SuperDetail := False;
{$ENDIF}
clearDebug();
activateClient();
setupSRL();
t := getSystemTime();
if (not mapOpen()) then
openMap();
set100Percent();
createMap();
bmpWorld.saveToFile(PATH_MAP);
free();
writeln('Took '+msToTime(getSystemTime - t, TIME_SHORT)+' to complete.');
end.