SRL Archive - Archive

LordJashin - SRL Member Application


LordJashin

2012-06-25 02:11:09

How Long have You Played Runescape?
5 Year(s)


Are you affilated in anyway with Jagex LTD?
No

Were you Referred to SRL?



What is your general programming knowledge?
C++, vb, Delphi, HTML, CSS, some PHP


Are you a member of any other communities?
SCAR Divi Forums


Tell us about yourself…
From: LordJashin
I want to make the world a better place.

I made the FindTextEx function a while ago.

I don't have much to put in the script section, but I know how to do:

All the OCR stuff, TPA's, Color finding, just learned bitwise shifting lol nice thread. Forms extensively, and etc. I'm more interested in the Delphi atm. I could make a pretty damn good runescape script if I really wanted too.



Please show us one (or multiple) of your scripts.
program SCAR_IRC_CLIENT;

const
Server = 'irc.scar-divi.com';
Port = 6667;
Channel = 'scar';
Nick = 'SCAR_IRC_CLIENT';
BackColor = clBlack;
FontColor = clRed;

var
Button: TButton;
IRCForm: TForm;
IRCMain: TMemo;
IRCChat: TEdit;
IRCTimer: TTimer;
IRCIndex: Integer;
JoinedAChannel: Boolean;
SendOnlyToChannel: Boolean;
JoinedChannel: string;

procedure ConnectToIRC;
begin
Try
IRCIndex := TCPConnect(Server, Port, 5000);
if TCPConnected(IRCIndex) then
begin
wait(1000);
TCPSend(IRCIndex, 'NICK ' + Nick);
TCPSend(IRCIndex, 'USER ' + Nick + ' 0 * :' + Nick);
TCPSend(IRCIndex, 'JOIN #' + Channel);
end
else
begin
TCPFree(IRCIndex);
WriteLn('Failed to connect to ' + Server + ' on port ' + IntToStr(Port));
Exit;
end;
Except
if TCPConnected(IRCIndex) then
TCPFree(IRCIndex);
WriteLn('For some reason an error has occured, please try again');
finally
end;
end;

procedure ShutdownIRC(Sender: TObject; var Action: TCloseAction);
begin
if IRCTimer.Enabled then
IRCTimer.Enabled := False;
if TCPConnected(IRCIndex) then
TCPFree(IRCIndex);
Action := caFree;
end;

procedure IRCMsgSender(Sender: TObject; var Key: Word; Shift: TShiftState);
begin
if (Key = 13) then
begin
if StartsWith('/exit', LowerCase(IRCChat.Text)) then
begin
if IRCTimer.Enabled then
IRCTimer.Enabled := False;
if TCPConnected(IRCIndex) then
TCPFree(IRCIndex);
IRCForm.Close;
end;
if StartsWith('/connect ', LowerCase(IRCChat.Text)) then
begin
if TCPConnected(IRCIndex) then
TCPFree(IRCIndex);
IRCMain.Clear;
Try
IRCIndex := 0;
IRCIndex := TCPConnect(Trim(Copy(IRCChat.Text, 10, 20)), Port, 3000);
if not TCPConnected(IRCIndex) then
begin
WriteLn('Failed to connect to ' + Trim(Copy(IRCChat.Text, 10, 20)) + ' on port ' + IntToStr(Port));
Exit;
end;
Except
if TCPConnected(IRCIndex) then
TCPFree(IRCIndex);
WriteLn('For some reason an error has occured, please try again');
finally

end;
IRCChat.Clear;
end
else if StartsWith('/serveronly', LowerCase(IRCChat.Text)) then
begin
SendOnlyToChannel := False;
IRCChat.Clear;
end
else if StartsWith('/faster', LowerCase(IRCChat.Text)) then
begin
IRCTimer.Interval := 200;
IRCChat.Clear;
end
else if StartsWith('/slower', LowerCase(IRCChat.Text)) then
begin
IRCTimer.Interval := 2000;
IRCChat.Clear;
end
else if StartsWith('/slowest', LowerCase(IRCChat.Text)) then
begin
IRCTimer.Interval := 2500;
IRCChat.Clear;
end
else if StartsWith('/channelonly', LowerCase(IRCChat.Text)) then
begin
SendOnlyToChannel := True;
IRCChat.Clear;
end
else if StartsWith('/disconnect', LowerCase(IRCChat.Text)) then
begin
if TCPConnected(IRCIndex) then
begin
TCPFree(IRCIndex);
IRCMain.Lines.Add('SCAR IRC CLIENT: Disconnected from IRC');
end
else
IRCMain.Lines.Add('SCAR IRC CLIENT: Not connected to any servers');
IRCChat.Clear;
end
else if StartsWith('/pause', LowerCase(IRCChat.Text)) then
begin
if IRCTimer.Enabled then
begin
IRCTimer.Enabled := False;
IRCMain.Lines.Add('SCAR IRC CLIENT: PAUSED RECIEVER');
end;
IRCChat.Clear;
end
else if StartsWith('/resume', LowerCase(IRCChat.Text)) then
begin
if not IRCTimer.Enabled then
begin
IRCTimer.Enabled := True;
IRCMain.Lines.Add('SCAR IRC CLIENT: RESUMED RECIEVER');
end;
IRCChat.Clear;
end
else if StartsWith('/join ', LowerCase(IRCChat.Text)) or StartsWith('join ', LowerCase(IRCChat.Text)) then
begin
if TCPConnected(IRCIndex) then
begin
TCPSend(IRCIndex, 'JOIN ' + Trim(Copy(IRCChat.Text, 6, 10)))
JoinedAChannel := True;
JoinedChannel := Trim(Copy(IRCChat.Text, 6, 10));
IRCChat.Clear;
end
else
IRCMain.Lines.Add('SCAR IRC CLIENT: You need to be connected to a server first');
end
else
begin
if SendOnlyToChannel then
begin
if not StartsWith('/privmsg', IRCChat.Text) or StartsWith('privmsg', IRCChat.Text) then
TCPSend(IRCIndex, 'PRIVMSG ' + JoinedChannel + ' :' + IRCChat.Text)
end
else
TCPSend(IRCIndex, IRCChat.Text);
IRCMain.Lines.Add(Nick + ': ' + IRCChat.Text);
IRCChat.Clear;
end;
end;
end;

procedure IRCMsgReciever(Sender: TObject);
var
E, P: Integer;
s: String;
begin
if not TCPConnected(IRCIndex) then
Exit;
TCPReceive(IRCIndex, s);
if s <> '' then
if JoinedAChannel then
begin
P := Pos('!~', s);
E := Pos(Trim(JoinedChannel), s) + Length(JoinedChannel) + 1;
if (E <> 0) and (P <> 0) then
begin
Insert(' ', s, E + 1);
Delete(s, P, E - P);
Delete(s, 1, 1);
end;
IRCMain.Lines.Add(s);
end
else
IRCMain.Lines.Add(s);
end;

procedure SetupSCAR_IRC;
begin
IRCForm := TForm.Create(nil);
with IRCForm do
begin
Position := poScreenCenter;
Caption := 'SCAR DIVI IRC CLIENT v0.1';
BorderStyle := bsSizeable;
OnClose := @ShutdownIRC;
Height := 240;
Width := 415;
end;
Button := TButton.Create(IRCForm);
with Button do
begin
Parent := IRCForm;
Top := 50;
end;
IRCChat := TEdit.Create(IRCForm);
with IRCChat do
begin
Top := 220;
Width := 415;
Height := 21;
Parent := IRCForm;
Color := BackColor;
Font.Color := FontColor;
OnKeyUp:= @IRCMsgSender;
Anchors := [akLeft, akRight, akBottom];
end;
IRCMain := TMemo.Create(IRCForm);
with IRCMain do
begin
Width := 415;
Height := 0;
Parent := IRCForm;
WordWrap := True;
ReadOnly := True;
Color := BackColor;
Font.Color := FontColor;
Text := 'SCAR DIVI IRC CLIENT v0.1';
ScrollBars := ssVertical;
Anchors := [akLeft, akTop, akRight, akBottom];
end;
IRCTimer := TTimer.Create(IRCForm);
with IRCTimer do
begin
Enabled := True;
Interval := 2000;
OnTimer := @IRCMsgReciever;
end;
IRCForm.ShowModal;
end;

procedure InitSCAR_IRC;
var
v: TVariantArray;
begin
SetLength(v, 0);
ThreadSafeCall('SetupSCAR_IRC', v);
end;

begin
ConnectToIRC;
InitSCAR_IRC;
end.

(*
-----------------------------------
Version 0.5:

Saves as PNG, uses the following includes:
GMRL, OSI

Saves Entire World Map as a 183mb .bmp file then
splits it into 500x500 png files

Supports SMART only atm.

Constants:

BRIGHTNESS, the brightness you want to increase each map piece by
MAP_CREATE, uses SMART to make the whole RS2 World Map
MAP_SLICE, just slices the World Map, doesn't need SMART
-----------------------------------

This is a program that will automatically create the entire Runescape map from
in game screenshots. The final image will be saved to the PATH_MAP
constant file path. It will also split the map into 500x500 chunks used as
SPS areas. Each area overlaps by 100 pixels. Set the MAP_CREATE and
MAP_SLICE constants depending on which (or both) activities you want to do.

NOTES:
~~~~~~

* Takes approx. 2 minutes to complete the map; 5 seconds to slice it
* 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 uses exact coord clicking
* Doesn't require you to login if you're only slicing the map

CREDITS:
~~~~~~~~

* Coh3n ~ Original author
* Nava2 & masterBB ~ Logic help + memory adjustments
* Marpis ~ Original map slicing algorithm

* LordJashin for Porting it to SCAR Divi 3.34

*)

program Runescape_Surface_Creator;
{$DEFINE RS2}
{$DEFINE SMART}
{$I GMRL/GMRL.scar}

const
MAP_CREATE = true; // true to create the map
MAP_SLICE = true; // true to slice the map into areas

BRIGHTNESS = 0; // How much brightness to apply to the map & map pieces
// Recommend 0-20


{ !~DO NOT CHANGE ANYTHING UNDER THIS LINE~! }

// The .\ ensures that if that folder is made it is in the same dir, as this file.

PATH_MAP = 'img\runescape_surface\runescape_surface.bmp'; // where to save the world map
PATH_IMG = '.\img\runescape_surface\'; // where to save the sps areas

// used so the screenshots line up properly
OVERLAP_X = 54;
OVERLAP_Y = 51;

OVERLAP_EDGE_X = 399 - OVERLAP_X; // overlap for last column
OVERLAP_EDGE_Y = 255 - OVERLAP_Y; // last row

COLUMNS = 14; // x
ROWS = 17; // y

// used to get rid of the border, X, and legend
SIZE_BORDER = 167;
SIZE_LEGEND = 50;

// values to cut off each side of the map's border (edit manualy in function)
const
LEFT = 7; // left border
RIGHT = 160; // right border + overview map
TOP = 7; // top border
BOTTOM = 43; // bottom legend

var
bmpWorld: Integer;

// Round an extended number to a certain decimal place
function RoundTo(e: Extended; DecPlace: Integer): Extended;
begin
if DecPlace >= 0 then
Result := Round(e * Pow(10,DecPlace)) / Pow(10,DecPlace)
else
Result := 0;
end;

{$IFDEF SMART}
// Credits to Wanted(OSI) - Clears Smart's Debug Canvas
procedure SmartDebugBitmap(BMP, X, Y: Integer);
var
Canvas, SCanvas: TCanvas;
BMP2, W, H: Integer;
begin
BMP2 := BitmapFromString(RSPW, RSPH, '');
SCanvas := GetBitmapCanvas(BMP2);
SCanvas.Handle := SmartGetDebugDC;
Canvas := GetBitmapCanvas(BMP);
GetBitmapSize(BMP, W, H);
SafeCopyCanvas(Canvas, SCanvas, 0, 0, W, H, X, Y, X + W, Y + H);
FreeBitmap(BMP2);
end;

// Credits to Wanted(OSI) - Clears Smart's Debug Canvas
procedure SmartClearDebugCanvas;
var
BMP: Integer;
begin
BMP := BitmapFromString(RSPW, RSPH, '');
SmartDebugBitmap(BMP, 0, 0);
FreeBitmap(BMP);
end;
{$ENDIF}

// returns true if the world map is open
function mapOpen: Boolean;
begin
Result := (getColor(749, 467) = 657930);
end;

// opens the world map
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, true, 500, 15000, 500, 15000);
if (Result) then
while (countColorTolerance(0, 10, 10, 100, 100, 10) > 500) do
wait(100);
end;

// opens the overview minimap while the map is open
function openOverview: Boolean;
begin
if (getColor(729, 453) = clBlack) then
begin
Result := true;
exit;
end;
mouse(680, 480, 5, 5, true);
wait(200 + random(300));
Result := true;
end;

// sets the map zoom to 100% (SPS won't work properly without it)
procedure set100Percent;
begin
WriteLn('Increasing Elevation Scan..');
// It is always set to 75% on default for Runescape (no need to check yet)

mouse(750, 475, 2, 2, true);
end;

// will go to any position on the world map
// number of columns and rows can be found as constants at the top of the script
procedure goPosition(column, row: Integer);
var
topLeft: TPoint;
begin
// starting point (top left)
topLeft.x := 616;
topLeft.y := 324;

{
// used for testing (gather a small area)
topLeft.x := 655;
topLeft.y := 375;
}
if (column = COLUMNS - 1) and (row = ROWS - 1) then
begin
mouse(752, 448, 0, 0, true); // bottom right corner
exit;
end;
if (column = COLUMNS - 1) then
begin
mouse(752, topLeft.y + (8 * row), 0, 0, true); // x-coord for right edge
exit;
end;
if (row = ROWS - 1) then
begin
mouse(topLeft.x + (11 * column), 448, 0, 0, true); // y-coord for bottom edge
exit;
end;
mouse(topLeft.x + (11 * column), topLeft.y + (8 * row), 0, 0, true);
end;

// returns the current cropped map piece as a "Bitmap Integer"
function getMapPiece: Integer;
var
w, h, bmp: Integer;
begin
getClientDimensions(w, h);
bmp := BitmapFromString(w, h, '');
copyClientToBitmap(bmp, 7, 7, w - 160, h - 43);

// Sets Each Map Piece's brightness to BRIGHTNESS constant's value

GMRL_SetBitmapBrightness(bmp, BRIGHTNESS);
Result := bmp;
end;

// gathers all the map pieces and draws them to the bmpWorld bitmap
procedure setPieces;
var
bmp, x, y, w, h: Integer;
drawn: Boolean;
begin
writeln('Creating map.. this may take a couple minutes');
getClientDimensions(w, h);

w := (w - SIZE_BORDER - OVERLAP_X);
h := (h - SIZE_LEGEND - OVERLAP_Y);

for x := 0 to (COLUMNS - 1) do
for y := 0 to (ROWS - 1) do
begin
drawn := false;
goPosition(x, y);
bmp := getMapPiece;
// bottom right corner
if (x = COLUMNS - 1) and (y = ROWS - 1) then
begin
fastDrawTransparent(x * w - OVERLAP_EDGE_X, y * h - OVERLAP_EDGE_Y, bmp, bmpWorld);
drawn := true;
end;
// right edge
if (x = COLUMNS - 1) then
begin
fastDrawTransparent(x * w - OVERLAP_EDGE_X, y * h, bmp, bmpWorld);
drawn := true;
end;
// bottom edge
if (y = ROWS - 1) then
begin
fastDrawTransparent(x * w, y * h - OVERLAP_EDGE_Y, bmp, bmpWorld);
drawn := true;
end;
if (not drawn) then
fastDrawTransparent(x * w, y * h, bmp, bmpWorld);
FreeBitmap(bmp);
end;
end;

// creates the world map
procedure createMap;
var
w, h: Integer;
begin
{$IFDEF SMART}
SmartSetTarget;
{$ENDIF}
getClientDimensions(w, h);

w := (w - SIZE_BORDER - OVERLAP_X);
h := (h - SIZE_LEGEND - OVERLAP_Y);

bmpWorld := BitmapFromString(w * COLUMNS - OVERLAP_EDGE_X,h * ROWS - OVERLAP_EDGE_Y, '');

fastDrawClear(bmpWorld, clBlack); // transparent colour

setPieces;
end;

// splits the map into SPS areas 500x500 pixels; overlap 100 pixels on each side
procedure sliceMap;
var
bmpMap, bmpTemp: Integer;
w, h, x, y, i, t, x1, y1, x2, y2: Integer;
blanks: TStringArray;
SCanvas, Canvas: TCanvas;
begin
t := getSystemTime;

// SPS areas that don't have any land on them (no point in saving them)
blanks := ['0_0', '0_4', '0_5', '0_6', '0_7', '0_8', '0_14', '0_15', '0_16',
'1_0', '1_4', '1_6', '1_14', '1_15', '1_16', '2_0', '2_1', '2_14', '2_15',
'2_16', '3_0', '3_1', '3_14', '3_15', '3_16', '4_0', '4_1', '4_14', '4_15',
'4_16', '3_14', '3_15', '3_16', '7_0', '8_0', '8_13', '9_0', '9_13', '9_14',
'9_15', '9_16', '10_0', '10_13', '10_14', '10_15', '10_16', '11_0', '11_15',
'11_16', '12_0', '12_15', '12_16', '13_0', '13_15', '13_16', '14_0', '14_1',
'14_2', '14_14', '14_15', '14_16', '15_0', '15_1', '15_2', '15_3', '15_4',
'15_13', '15_14', '15_15', '15_16', '16_0', '16_1', '16_2', '16_3', '16_4',
'16_13', '16_14', '16_15', '16_16', '17_0', '17_1', '17_2', '17_3', '17_4',
'17_7', '17_8', '17_9', '17_14', '17_15', '17_16'];

forceDirectories(PATH_IMG);

if not FileExists(PATH_MAP) then
begin
WriteLn('Failed to find runescape_surface.bmp WHOLE RS2 MAP FILE needed in order to slice into chunks');
TerminateScript;
end;

writeln('Slicing map...');

bmpMap := LoadBitmap(PATH_MAP);

GetBitmapSize(bmpMap, w, h);

for x := 0 to 17 do
for y := 0 to 16 do
begin
// skips blank areas
if (InStrArr(InttoStr(x)+'_'+InttoStr(y), blanks, false)) then
continue;

x1 := (x * 400);
y1 := (y * 400);
x2 := (x * 400 + 499);
y2 := (y * 400 + 499);

// make sure we're not exceeding the dimensions of the world map
// if we are set the coords so the areas are still 500x500
if (x2 > w) then
begin
x1 := (w - 1 - 499);
x2 := (w - 1);
end;

if (y2 > h) then
begin
y1 := (h - 1 - 499);
y2 := (h - 1);
end;

bmpTemp := BitmapFromString(500, 500, '');

Canvas := GetBitmapCanvas(bmpMap);
SCanvas := GetBitmapCanvas(bmpTemp);

// Copies bmpMap canvas onto bmpTemp canvas
SafeCopyCanvas(Canvas, SCanvas, x1, y1, x2, y2, 0, 0, 500, 500);

// Saves as PNG
GMRL_BitmapToPNG(bmpTemp, PATH_IMG + InttoStr(x)+'_'+InttoStr(y)+'.png');

FreeBitmap(bmpTemp);

inc(i);
writeln('Saved '+InttoStr(i));
end;

FreeBitmap(bmpMap);
if (getSystemTime - t) < 60000 then
writeln('Slicing map took ' + IntToStr((getSystemTime - t) div 1000) + ' seconds to complete.')
else
writeln('Slicing map took ' + FloatToStr(RoundTo(((getSystemTime - t)/1000/60), 1)) + 'mins to complete.');
end;

procedure mainloopMap;
var
t: Integer;
begin
t := getSystemTime;

if (not mapOpen) then
openMap;

set100Percent;
openOverview;

createMap;

wait(500);

// Saves WorldMap as a Bitmap
SaveBitmap(bmpWorld, PATH_MAP);

FreeBitmap(bmpWorld);

if (getSystemTime - t) < 60000 then
writeln('Creating map took ' + IntToStr((getSystemTime - t) div 1000) + ' seconds to complete.')
else
writeln('Creating map took ' + FloatToStr(RoundTo(((getSystemTime - t)/1000/60), 1)) + 'mins to complete.');
end;

begin
clearDebug;
forceDirectories(PATH_IMG);

if (MAP_CREATE) then
begin
{$IFDEF SMART}
SetupOSI;
SmartSetGraphics(true);
SmartSetDebug(true);
SmartClearDebugCanvas;
SmartSetRefresh(100);
{$ELSE}
SetupOSI;
ActivateClient;
wait(1000);
{$ENDIF}
{$IFDEF SMART}
if (not(loggedIn)) then
begin
writeln('Please login your player');
terminateScript;
end;
{$ENDIF}
mainloopMap;
end;

if (MAP_SLICE) then
sliceMap;
end.

LordJashin

2012-06-25 02:12:14

Boom

YoHoJo

2012-06-25 03:25:44

Hmm you are obviously very talented for sure, but I think we are looking for an SRL script for Simba.
I voted yes anyways ;].

J J

2012-06-25 04:00:40

Why do you want to be a SRL Member?

Jakkle

2012-06-25 06:43:04

If you make the same thing for Simba I will vote yes ;)

Kyle Undefined

2012-06-25 08:56:18

Did no one else look through the entire piece of code? Most of it was from a modified version of the tool written by Coh3n and Marpis.

Porting something to SCAR is VERY easy.


(*
-----------------------------------
Version 0.5:

Saves as PNG, uses the following includes:
GMRL, OSI

Saves Entire World Map as a 183mb .bmp file then
splits it into 500x500 png files

Supports SMART only atm.

Constants:

BRIGHTNESS, the brightness you want to increase each map piece by
MAP_CREATE, uses SMART to make the whole RS2 World Map
MAP_SLICE, just slices the World Map, doesn't need SMART
-----------------------------------

This is a program that will automatically create the entire Runescape map from
in game screenshots. The final image will be saved to the PATH_MAP
constant file path. It will also split the map into 500x500 chunks used as
SPS areas. Each area overlaps by 100 pixels. Set the MAP_CREATE and
MAP_SLICE constants depending on which (or both) activities you want to do.

NOTES:
~~~~~~

* Takes approx. 2 minutes to complete the map; 5 seconds to slice it
* 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 uses exact coord clicking
* Doesn't require you to login if you're only slicing the map

CREDITS:
~~~~~~~~

* Coh3n ~ Original author
* Nava2 & masterBB ~ Logic help + memory adjustments
* Marpis ~ Original map slicing algorithm

* LordJashin for Porting it to SCAR Divi 3.34

*)

program Runescape_Surface_Creator;
{$DEFINE RS2}
{$DEFINE SMART}
{$I GMRL/GMRL.scar}

const
MAP_CREATE = true; // true to create the map
MAP_SLICE = true; // true to slice the map into areas

BRIGHTNESS = 0; // How much brightness to apply to the map & map pieces
// Recommend 0-20


{ !~DO NOT CHANGE ANYTHING UNDER THIS LINE~! }

// The .\ ensures that if that folder is made it is in the same dir, as this file.

PATH_MAP = 'img\runescape_surface\runescape_surface.bmp'; // where to save the world map
PATH_IMG = '.\img\runescape_surface\'; // where to save the sps areas

// used so the screenshots line up properly
OVERLAP_X = 54;
OVERLAP_Y = 51;

OVERLAP_EDGE_X = 399 - OVERLAP_X; // overlap for last column
OVERLAP_EDGE_Y = 255 - OVERLAP_Y; // last row

COLUMNS = 14; // x
ROWS = 17; // y

// used to get rid of the border, X, and legend
SIZE_BORDER = 167;
SIZE_LEGEND = 50;

// values to cut off each side of the map's border (edit manualy in function)
const
LEFT = 7; // left border
RIGHT = 160; // right border + overview map
TOP = 7; // top border
BOTTOM = 43; // bottom legend

var
bmpWorld: Integer;

// Round an extended number to a certain decimal place
function RoundTo(e: Extended; DecPlace: Integer): Extended;
begin
if DecPlace >= 0 then
Result := Round(e * Pow(10,DecPlace)) / Pow(10,DecPlace)
else
Result := 0;
end;

{$IFDEF SMART}
// Credits to Wanted(OSI) - Clears Smart's Debug Canvas
procedure SmartDebugBitmap(BMP, X, Y: Integer);
var
Canvas, SCanvas: TCanvas;
BMP2, W, H: Integer;
begin
BMP2 := BitmapFromString(RSPW, RSPH, '');
SCanvas := GetBitmapCanvas(BMP2);
SCanvas.Handle := SmartGetDebugDC;
Canvas := GetBitmapCanvas(BMP);
GetBitmapSize(BMP, W, H);
SafeCopyCanvas(Canvas, SCanvas, 0, 0, W, H, X, Y, X + W, Y + H);
FreeBitmap(BMP2);
end;

// Credits to Wanted(OSI) - Clears Smart's Debug Canvas
procedure SmartClearDebugCanvas;
var
BMP: Integer;
begin
BMP := BitmapFromString(RSPW, RSPH, '');
SmartDebugBitmap(BMP, 0, 0);
FreeBitmap(BMP);
end;
{$ENDIF}

// returns true if the world map is open
function mapOpen: Boolean;
begin
Result := (getColor(749, 467) = 657930);
end;

// opens the world map
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, true, 500, 15000, 500, 15000);
if (Result) then
while (countColorTolerance(0, 10, 10, 100, 100, 10) > 500) do
wait(100);
end;

// opens the overview minimap while the map is open
function openOverview: Boolean;
begin
if (getColor(729, 453) = clBlack) then
begin
Result := true;
exit;
end;
mouse(680, 480, 5, 5, true);
wait(200 + random(300));
Result := true;
end;

// sets the map zoom to 100% (SPS won't work properly without it)
procedure set100Percent;
begin
WriteLn('Increasing Elevation Scan..');
// It is always set to 75% on default for Runescape (no need to check yet)

mouse(750, 475, 2, 2, true);
end;

// will go to any position on the world map
// number of columns and rows can be found as constants at the top of the script
procedure goPosition(column, row: Integer);
var
topLeft: TPoint;
begin
// starting point (top left)
topLeft.x := 616;
topLeft.y := 324;

{
// used for testing (gather a small area)
topLeft.x := 655;
topLeft.y := 375;
}
if (column = COLUMNS - 1) and (row = ROWS - 1) then
begin
mouse(752, 448, 0, 0, true); // bottom right corner
exit;
end;
if (column = COLUMNS - 1) then
begin
mouse(752, topLeft.y + (8 * row), 0, 0, true); // x-coord for right edge
exit;
end;
if (row = ROWS - 1) then
begin
mouse(topLeft.x + (11 * column), 448, 0, 0, true); // y-coord for bottom edge
exit;
end;
mouse(topLeft.x + (11 * column), topLeft.y + (8 * row), 0, 0, true);
end;

// returns the current cropped map piece as a "Bitmap Integer"
function getMapPiece: Integer;
var
w, h, bmp: Integer;
begin
getClientDimensions(w, h);
bmp := BitmapFromString(w, h, '');
copyClientToBitmap(bmp, 7, 7, w - 160, h - 43);

// Sets Each Map Piece's brightness to BRIGHTNESS constant's value

GMRL_SetBitmapBrightness(bmp, BRIGHTNESS);
Result := bmp;
end;

// gathers all the map pieces and draws them to the bmpWorld bitmap
procedure setPieces;
var
bmp, x, y, w, h: Integer;
drawn: Boolean;
begin
writeln('Creating map.. this may take a couple minutes');
getClientDimensions(w, h);

w := (w - SIZE_BORDER - OVERLAP_X);
h := (h - SIZE_LEGEND - OVERLAP_Y);

for x := 0 to (COLUMNS - 1) do
for y := 0 to (ROWS - 1) do
begin
drawn := false;
goPosition(x, y);
bmp := getMapPiece;
// bottom right corner
if (x = COLUMNS - 1) and (y = ROWS - 1) then
begin
fastDrawTransparent(x * w - OVERLAP_EDGE_X, y * h - OVERLAP_EDGE_Y, bmp, bmpWorld);
drawn := true;
end;
// right edge
if (x = COLUMNS - 1) then
begin
fastDrawTransparent(x * w - OVERLAP_EDGE_X, y * h, bmp, bmpWorld);
drawn := true;
end;
// bottom edge
if (y = ROWS - 1) then
begin
fastDrawTransparent(x * w, y * h - OVERLAP_EDGE_Y, bmp, bmpWorld);
drawn := true;
end;
if (not drawn) then
fastDrawTransparent(x * w, y * h, bmp, bmpWorld);
FreeBitmap(bmp);
end;
end;

// creates the world map
procedure createMap;
var
w, h: Integer;
begin
{$IFDEF SMART}
SmartSetTarget;
{$ENDIF}
getClientDimensions(w, h);

w := (w - SIZE_BORDER - OVERLAP_X);
h := (h - SIZE_LEGEND - OVERLAP_Y);

bmpWorld := BitmapFromString(w * COLUMNS - OVERLAP_EDGE_X,h * ROWS - OVERLAP_EDGE_Y, '');

fastDrawClear(bmpWorld, clBlack); // transparent colour

setPieces;
end;

// splits the map into SPS areas 500x500 pixels; overlap 100 pixels on each side
procedure sliceMap;
var
bmpMap, bmpTemp: Integer;
w, h, x, y, i, t, x1, y1, x2, y2: Integer;
blanks: TStringArray;
SCanvas, Canvas: TCanvas;
begin
t := getSystemTime;

// SPS areas that don't have any land on them (no point in saving them)
blanks := ['0_0', '0_4', '0_5', '0_6', '0_7', '0_8', '0_14', '0_15', '0_16',
'1_0', '1_4', '1_6', '1_14', '1_15', '1_16', '2_0', '2_1', '2_14', '2_15',
'2_16', '3_0', '3_1', '3_14', '3_15', '3_16', '4_0', '4_1', '4_14', '4_15',
'4_16', '3_14', '3_15', '3_16', '7_0', '8_0', '8_13', '9_0', '9_13', '9_14',
'9_15', '9_16', '10_0', '10_13', '10_14', '10_15', '10_16', '11_0', '11_15',
'11_16', '12_0', '12_15', '12_16', '13_0', '13_15', '13_16', '14_0', '14_1',
'14_2', '14_14', '14_15', '14_16', '15_0', '15_1', '15_2', '15_3', '15_4',
'15_13', '15_14', '15_15', '15_16', '16_0', '16_1', '16_2', '16_3', '16_4',
'16_13', '16_14', '16_15', '16_16', '17_0', '17_1', '17_2', '17_3', '17_4',
'17_7', '17_8', '17_9', '17_14', '17_15', '17_16'];

forceDirectories(PATH_IMG);

if not FileExists(PATH_MAP) then
begin
WriteLn('Failed to find runescape_surface.bmp WHOLE RS2 MAP FILE needed in order to slice into chunks');
TerminateScript;
end;

writeln('Slicing map...');

bmpMap := LoadBitmap(PATH_MAP);

GetBitmapSize(bmpMap, w, h);

for x := 0 to 17 do
for y := 0 to 16 do
begin
// skips blank areas
if (InStrArr(InttoStr(x)+'_'+InttoStr(y), blanks, false)) then
continue;

x1 := (x * 400);
y1 := (y * 400);
x2 := (x * 400 + 499);
y2 := (y * 400 + 499);

// make sure we're not exceeding the dimensions of the world map
// if we are set the coords so the areas are still 500x500
if (x2 > w) then
begin
x1 := (w - 1 - 499);
x2 := (w - 1);
end;

if (y2 > h) then
begin
y1 := (h - 1 - 499);
y2 := (h - 1);
end;

bmpTemp := BitmapFromString(500, 500, '');

Canvas := GetBitmapCanvas(bmpMap);
SCanvas := GetBitmapCanvas(bmpTemp);

// Copies bmpMap canvas onto bmpTemp canvas
SafeCopyCanvas(Canvas, SCanvas, x1, y1, x2, y2, 0, 0, 500, 500);

// Saves as PNG
GMRL_BitmapToPNG(bmpTemp, PATH_IMG + InttoStr(x)+'_'+InttoStr(y)+'.png');

FreeBitmap(bmpTemp);

inc(i);
writeln('Saved '+InttoStr(i));
end;

FreeBitmap(bmpMap);
if (getSystemTime - t) < 60000 then
writeln('Slicing map took ' + IntToStr((getSystemTime - t) div 1000) + ' seconds to complete.')
else
writeln('Slicing map took ' + FloatToStr(RoundTo(((getSystemTime - t)/1000/60), 1)) + 'mins to complete.');
end;

procedure mainloopMap;
var
t: Integer;
begin
t := getSystemTime;

if (not mapOpen) then
openMap;

set100Percent;
openOverview;

createMap;

wait(500);

// Saves WorldMap as a Bitmap
SaveBitmap(bmpWorld, PATH_MAP);

FreeBitmap(bmpWorld);

if (getSystemTime - t) < 60000 then
writeln('Creating map took ' + IntToStr((getSystemTime - t) div 1000) + ' seconds to complete.')
else
writeln('Creating map took ' + FloatToStr(RoundTo(((getSystemTime - t)/1000/60), 1)) + 'mins to complete.');
end;

begin
clearDebug;
forceDirectories(PATH_IMG);

if (MAP_CREATE) then
begin
{$IFDEF SMART}
SetupOSI;
SmartSetGraphics(true);
SmartSetDebug(true);
SmartClearDebugCanvas;
SmartSetRefresh(100);
{$ELSE}
SetupOSI;
ActivateClient;
wait(1000);
{$ENDIF}
{$IFDEF SMART}
if (not(loggedIn)) then
begin
writeln('Please login your player');
terminateScript;
end;
{$ENDIF}
mainloopMap;
end;

if (MAP_SLICE) then
sliceMap;
end.

NKN

2012-06-25 11:46:45

Voted no…. code has to be for Simba and show you can use the SRL Include.

LordJashin

2012-06-25 12:33:55

From: Jakkle
If you make the same thing for Simba I will vote yes ;)


An IRC client? lol. I'd rather make one with delphi, and make it a plugin.

Hm, has to be using Simba. I could make somethin. What should I make though that isn't already done. Has to be F2P as well, unless some1 could help me out somehow.

1. Anti-Dragon-Shield banker? They used to be worth so much more lol 167 now pitiful.
2. Dungeoneering would be probably the hardest.
3. Bone burier?
4. Grand Exchange seller, (sell at x % more or less than G.E. price or w/e)

Maybe a quest completer for the F2P quests. I have no idea, as long as its something that no1 else has working with Simba/SCAR I'll do it.

It would have a form, SPS support, multi player, a paint, and might support Replenish ring, bank pin, and etc. I think I would be too lazy to make a nice logo/icon for the name of it.

Something challenging…SRL members only maybe…

Abu

2012-06-25 16:06:22

I'm sure you have the ability, no doubt.

Doesn't matter which script you make or whether it's useful or not, heck you don't even have to release it, as long as you can show you can script at an advanced level then you should get in.