SRL Archive - SRL Positioning System

SPS Help


Kyle Undefined

2012-03-31 04:37:56

Ok, so I'm using this script to slice an updated SPS image, a lot of the walking in MSI got messed up with the latest RS update (ex, Seers Yews/Magics). It does fine until it gets to #273, and just errors out.


program SPS_MapMaker;
{$i srl/srl.simba}

(**
* Running this script loads SPS/worldmap.png and slices the huge map
* into 500x500 pieces, which over lap each other by 100 pixels. The process
* will take several minutes. Images are saved to SPS_IMG_PATH.
*
* - marpis
*)

const
PATH_MAP = IncludePath + 'SPS\img\runescape_surface\runescape_surface.bmp';
PATH_IMG = IncludePath + 'SPS\img\runescape_surface\';

function cropBitmap(bmp, x1, y1, x2, y2: integer): integer;
var
x, y, w, h: integer;
begin
w := (x2 - x1 + 1);
h := (y2 - y1 + 1);

result := bitmapFromString(w, h, '');

for x := 0 to (w - 1) do
for y := 0 to (h - 1) do
fastSetPixel(result, x, y, fastGetPixel(bmp, x1 + x, y1 + y));
end;

procedure sliceMap;
var
mapBMP, tmpBMP: integer;
x, y, i, x1, y1, x2, y2: integer;
begin
mapBMP := loadBitmap(PATH_MAP);

for x := 0 to 17 do
for y := 0 to 15 do
begin
tmpBMP := cropBitmap(mapBMP, x * 400, y * 400, x * 400 + 499, y * 400 + 499);
saveBitmap(tmpBMP, PATH_IMG + toStr(x)+'_'+toStr(y)+'.bmp');
freeBitmap(tmpBMP);
inc(i);
writeln('## Saved '+toStr(i));
end;

freeBitmap(mapBMP);
end;

var
t: integer;
begin
t := getSystemTime();

ClearDebug;
ForceDirectories(PATH_IMG);
sliceMap;

writeln('Took '+msToTime(getSystemTime - t, TIME_SHORT)+' to complete.');
end.


## Saved 269
## Saved 270
## Saved 271
## Saved 272
Error: Exception: You are accessing an invalid point, (7271,0) at bitmap[0] at line 27
The following bitmaps were not freed: [0, 1]

Line 27 is this code in cropBitmap:
fastSetPixel(result, x, y, fastGetPixel(bmp, x1 + x, y1 + y));

I honestly don't know why it's doing it, and I've been trying to get this to work for the past few hours.

Here's the new image that is being split up, http://srl.kyleundefined.com/runescape_surface.zip

Any help or ideas would be appreciated! Thanks.

Imanoobbot

2012-03-31 05:47:46

Are the colors that drasticly changed? Or what do you think is the problem why it´s not working anymore?

*Is the SPS image uptodate?

Jordan155

2012-03-31 05:59:38

Kyle, was this because of the Seer's Village path no longer working?

Smidqe

2012-03-31 07:36:35

You're using the original slicer right? Then you should lower the amount of colums which would be x in sliceMap function
  for x := 0 to 17 do
for y := 0 to 15 do


The reason why it gets an invalid point is that it has already reached the boundary of a bitmap on the right, and it's trying to go even further. But since it's out of bounds it fails.

E: As your map is 7271 pixels wide, you could try 14 or 15 as the amount of colums…

From: Imanoobbot
Are the colors that drasticly changed? Or what do you think is the problem why it´s not working anymore?

*Is the SPS image uptodate?

I'm not sure how old the SPS map that's downloaded through the extension, but I would think that it's rather old.

Kyle Undefined

2012-03-31 14:04:03

From: Imanoobbot
Are the colors that drasticly changed? Or what do you think is the problem why it´s not working anymore?

*Is the SPS image uptodate?


They added details, took some objects out, put some in, so a new SPS map will fix everything.

And no, it's not in the SPS Git yet, so it's still the old one.

From: Jordan155
Kyle, was this because of the Seer's Village path no longer working?


Yes, a lot of the detail has changed in that area.

From: Smidqe
You're using the original slicer right? Then you should lower the amount of colums which would be x in sliceMap function
  for x := 0 to 17 do
for y := 0 to 15 do


The reason why it gets an invalid point is that it has already reached the boundary of a bitmap on the right, and it's trying to go even further. But since it's out of bounds it fails.

E: As your map is 7271 pixels wide, you could try 14 or 15 as the amount of colums…


I'm not sure how old the SPS map that's downloaded through the extension, but I would think that it's rather old.


Yeah, it's the original slicer. I'll try that, and thanks for the help! :)

Coh3n

2012-03-31 14:20:07

You're using the wrong file. Where do you get that? It's incredibly old. Use the one that's in the current repository (SPS/tools/). It'll create the entire map and slice the pieces for you. You specify the save path.

Once you do that, make sure you test A LOT and reload the client several times (the minimap colors seem to want to change quite often). Then you can send them to me, and I'll compress (or you can, using OptiPNG) them and commit.

The tool I made for making the map should ALWAYS be used. It makes sure the map is always the same size (that won't actually matter in SPS2.0, but still). It also does it really fast, and the instructions are at the top of the script if you're unsure.

Kyle Undefined

2012-03-31 14:24:59

That's the one I'm using, in /SPS/tools/ :p I'll make sure I have the most up to date one, that's what was confusing me. It's two files right now, one that creates the map and one that slices it.

Yeah, testing will take awhile, don't want to release broken stuff ;)

EDIT: According to Simba, I had the latest version, and I even did an Override Update. I looked on Git, and I have a completely different version. Downloading that now.

Coh3n

2012-03-31 14:44:53

The latest version should just have 1 file (runescape_surface_creator.simba):

(*

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

*)

program runescape_surface_creator;
{$DEFINE SMART}
{$i srl/srl.scar}
{$i srl/srl/misc/paintsmart.scar}

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

const
PATH_MAP = appPath + 'runescape_surface\runescape_surface.bmp'; // where to save the world map
PATH_IMG = appPath + '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;

var
bmpWorld: TMufasaBitmap;

// 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, 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();
var
x, y: integer;
begin
if (findText(x, y, '100', statChars, 700, 460, 760, 495)) then
exit;

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;

// values to cut off each side of the map's border
const
LEFT = 7; // left border
RIGHT = 160; // right border + overview map
TOP = 7; // top border
BOTTOM = 43; // bottom legend
// returns the current cropped map piece as a TMufasaBitmap
function getMufaPiece(): TMufasaBitmap;
var
bmp, w, h: integer;
begin
getClientDimensions(w, h);
bmp := createBitmap(w, h);
copyClientToBitmap(bmp, LEFT, TOP, w - RIGHT, h - BOTTOM);

result := getMufasaBitmap(bmp);

//result.saveToFile(appPath + 'dwarven2.png');
end;

// gathers all the map pieces and draws them to the bmpWorld bitmap
procedure setPieces();
var
bmp: TMufasaBitmap;
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 := getMufaPiece();

// bottom right corner
if (x = COLUMNS - 1) and (y = ROWS - 1) then
begin
bmp.fastDrawTransparent(x * w - OVERLAP_EDGE_X, y * h - OVERLAP_EDGE_Y, bmpWorld);
drawn := true;
end;

// right edge
if (x = COLUMNS - 1) then
begin
bmp.fastDrawTransparent(x * w - OVERLAP_EDGE_X, y * h, bmpWorld);
drawn := true;
end;

// bottom edge
if (y = ROWS - 1) then
begin
bmp.fastDrawTransparent(x * w, y * h - OVERLAP_EDGE_Y, bmpWorld);
drawn := true;
end;

if (not drawn) then
bmp.fastDrawTransparent(x * w, y * h, bmpWorld);

bmp.free();
end;
end;

// creates the world map
procedure createMap();
var
w, h: integer;
begin
bmpWorld := TMufasaBitmap.create();
getClientDimensions(w, h);

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

bmpWorld.setSize(w * COLUMNS - OVERLAP_EDGE_X, h * ROWS - OVERLAP_EDGE_Y);
bmpWorld.fastDrawClear(clBlack); // transparent colour

setPieces()
end;

// splits the map into SPS areas 500x500 pixels; overlap 100 pixels on each side
// finished in about 10 seconds
procedure sliceMap;
var
bmpMap, bmpTemp: TMufasaBitmap;
x, y, i, t, x1, y1, x2, y2: integer;
blanks: TStringArray;
begin
writeln('Slicing map...');
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);

bmpMap := TMufasaBitmap.Create();
bmpMap.loadFromFile(PATH_MAP);

for x := 0 to 17 do
for y := 0 to 16 do
begin
// skips blank areas
if (inStrArr(toStr(x)+'_'+toStr(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 > bmpMap.width) then
begin
x1 := (bmpMap.width - 1 - 499);
x2 := (bmpMap.width - 1);
end;

if (y2 > bmpMap.height) then
begin
y1 := (bmpMap.height - 1 - 499);
y2 := (bmpMap.height - 1);
end;

bmpTemp := bmpMap.copy(x1, y1, x2, y2);
bmpTemp.saveToFile(PATH_IMG + toStr(x)+'_'+toStr(y)+'.bmp');
bmpTemp.free();

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

bmpMap.free();
writeln('Slicing map took '+msToTime(getSystemTime - t, TIME_SHORT)+' to complete.');
end;

procedure mainloopMap();
var
t: integer;
begin
t := getSystemTime();

if (not mapOpen()) then
openMap();

set100Percent();
openOverview();

createMap();
bmpWorld.saveToFile(PATH_MAP);
bmpWorld.free();

writeln('Creating map took '+msToTime(getSystemTime - t, TIME_SHORT)+' to complete.');
end;

procedure mainloopSlice();
begin
sliceMap();
end;

begin
clearDebug();
forceDirectories(PATH_IMG);

if (MAP_CREATE) then
begin
{$IFDEF SMART}
SMART_Server := 1;
SMART_Members := False;
SMART_Signed := True;
SMART_SuperDetail := False;
SMART_SetupDebug();
clearRSCanvas(SMART_Canvas.canvas);
{$ENDIF}

activateClient();
setupSRL();

{$IFDEF SMART}
if (not(loggedIn)) then
begin
writeln('Please login your player');
terminateScript();
end;
{$ENDIF}

mainloopMap();
end;

if (MAP_SLICE) then
mainloopSlice();
end.
It will create or slice the map, or both.

Kyle Undefined

2012-03-31 16:22:41

From: Kyle Undefined
Ok, yeah, I see that tool now. That was weird. It created and sliced the map perfectly this time, going to convert them to PNGs and start testing!

Thanks!


Ok, so I got the new images, used OptiPNG to convert and optimize them all, and started doing some testing. I was trying to walk from Seers bank to the Magics, and it would fail halfway through. I tried remaking the path as well.

I'm thinking that the Tolerance might need to be adjusted. I'll keep looking into this. If you want the images, they're here http://www.filedropper.com/runescapesurface

To anyone, feel free to play around with this and test walking with these images.

Jordan155

2012-03-31 18:13:59

Hey, I tried remaking the path with what little knowledge I have but failed miserably, seems to walk in a different direction now.'

If anyone has Seers bank path to magics working please let us know :D

Coh3n

2012-03-31 18:35:59

Kyle, make sure when you made the maps, that you were in Safe Mode. The minimap is very different in Safe Mode than in Software Mode. Kind of annoying to be honest. Also, try testing with my SPS 2.0 branch. As soon as I figure out the Access Violation error it'll be released. It's much more accurate and works in the desert. Been using MSI's Cooker for a few days without problems.

SPS 2.0 branch: https://github.com/Coh3n/SPS/tree/sps_2.0

I'll look more into your images when I get home tomorrow.

Kyle Undefined

2012-04-01 03:55:28

From: Coh3n
Kyle, make sure when you made the maps, that you were in Safe Mode. The minimap is very different in Safe Mode than in Software Mode. Kind of annoying to be honest. Also, try testing with my SPS 2.0 branch. As soon as I figure out the Access Violation error it'll be released. It's much more accurate and works in the desert. Been using MSI's Cooker for a few days without problems.

SPS 2.0 branch: https://github.com/Coh3n/SPS/tree/sps_2.0

I'll look more into your images when I get home tomorrow.


Yeah, I double checked and I am on Safe Mode, so I really don't know what's up.

I just got back home, left after I posted that really, so I'll dig into this now. EDIT: I think I'll wait, since SPS 2.0 is basically right around the corner :p

And sweet, I'll play with that as well, that will be nice. If SPS 2.0 works now with walking, then I won't waste my time in looking into why SPS 1.0 isn't working :p

Thanks! :)

Jordan155

2012-04-01 17:08:26

Wait what is the deal with SPS 2.0?

Coh3n

2012-04-01 22:42:17

From: Jordan155
Wait what is the deal with SPS 2.0?
Marpis became inactive so I've taken on the development. I haven't released anything more than what's in Marpis's thread. I've tested it a few times, but have been busy the last few days.

E: Kyle, are you sure the minimap changed? I'm looking at the images in the current SPS and the map in game, and one's slightly darker, but other than that they're exactly the same.

Jordan155

2012-04-01 23:38:00

From: Coh3n
Marpis became inactive so I've taken on the development. I haven't released anything more than what's in Marpis's thread. I've tested it a few times, but have been busy the last few days.

E: Kyle, are you sure the minimap changed? I'm looking at the images in the current SPS and the map in game, and one's slightly darker, but other than that they're exactly the same.


As for the images you are referring to, something is wrong with the Seer's Village images on the walkpath from the Bank to the Magic Tree spot which is what I pointed out to him. Apparently the images have changed a bit in that area.

Coh3n

2012-04-01 23:44:11

From: Jordan155
As for the images you are referring to, something is wrong with the Seer's Village images on the walkpath from the Bank to the Magic Tree spot which is what I pointed out to him. Apparently the images have changed a bit in that area.
I know that's what I'm saying. I compared the map in game and the SPS images, and they're the same. Are you sure you're in Safe Mode?

Brandon

2012-04-01 23:56:25

Coh3n Sorry to say.. They really are NOT the same.. This happens with LRC and Zanaris as well as the Place where u hunt those jadinko's..

Someone tell me the area or screenshot it and I'll make you a custom map and we can see if I'm right.. If I am then Jagex has changed the ball game.. Also note that the black on the minimaps aren't actually black anymore.. well in some areas.. They are actually quite a lot off from black.. And sometimes almost completely different colours from the world map are on the minimap.

Ahh nvm I'll just go to seers and make the whole village I guess..

Coh3n

2012-04-02 00:03:13

From: ggzz
Coh3n Sorry to say.. They really are NOT the same.. This happens with LRC and Zanaris as well as the Place where u hunt those jadinko's..
You HAVE to be in safe mode, otherwise the minimap is very different from the in game world map.

I didn't actually go to Seers, I looked at the in game world map compared to the images in SPS.

E: My world map:


SPS image:


As I said, ones darker, but I don't think it's enough to mess up SPS. I don't have a members account so I can't see for sure, but everywhere in F2P that I use it, it works just fine.

Jordan155

2012-04-02 00:44:37

From: Coh3n
You HAVE to be in safe mode, otherwise the minimap is very different from the in game world map.

I didn't actually go to Seers, I looked at the in game world map compared to the images in SPS.

E: My world map:


SPS image:


As I said, ones darker, but I don't think it's enough to mess up SPS. I don't have a members account so I can't see for sure, but everywhere in F2P that I use it, it works just fine.


If you are interested you can use one of my member accounts with wc enough for magics to test this out if you want

Coh3n

2012-04-02 00:51:58

Thanks, but I don't have time right now. I'll PM you if I need it. :)

Jordan155

2012-04-02 00:57:49

From: Coh3n
Thanks, but I don't have time right now. I'll PM you if I need it. :)


Yeah sorry didn't mean to make it sound like I was making you do it right now haha. PM me whenever you'd like.

Brandon

2012-04-02 01:40:45

Well here's my butchered SPS map lol.. Co-ordinates are exact.. but the map u give me above doesn't work for me :S

EDIT The map u posted above works as long as I edit the name to something like 0_0Coh3n.. That worked for me.



Coh3n

2012-04-02 02:47:07

SPS requires specific naming for the maps to work correctly. The images I posted weren't meant to be tested specifically. They were to show the difference between the SPS image and the in game world map.

I can tell from the one you posted that there isn't enough of a difference for it to mess up. There are bugs in SPS that have been fixed for SPS 2.0. It's been known for a while that certain areas aren't as accurate as others. This seems to be one of them.

I've PM'd Jordan so I can test SPS 2.0 with this account. If you want, you can test it as well, but from the images provided I can say that the minimap hasn't changed; this particular area just doesn't want to work that well.

Kyle Undefined

2012-04-02 09:38:32

I honestly think it's just the detail they added to the MiniMap. They removed rocks/trees, moved trees around, etc.

Like I said earlier, no point in trying to get this to work on SPS 1.0 if it works with SPS 2.0. I'll test this with SPS 2.0 later when I get home.

ggzz, in my post above I linked to the new images, that match the detail that's in the game now, if you want to check them out.

Coh3n

2012-04-02 14:24:18

Ah yes, I didn't notice the trees and stuff. I just looked at the buildings. Kyle, I'll test out your images.

E: Kyle, your images are too dark; that may be why it didn't work well for you. I've found that the in game map is darker/lighter different times you log in.

E2: Kyle, try these images: http://dl.dropbox.com/u/33256273/runescape_surface.zip

Kyle Undefined

2012-04-02 15:36:37

Huh, that's weird. Is the light/dark areas only on the main map, or on the MiniMap as well? I'll do some testing when I get home with both sets of images, just to see.

Thank Coh3n! :)

Coh3n

2012-04-02 16:39:40

From: Kyle Undefined
Huh, that's weird. Is the light/dark areas only on the main map, or on the MiniMap as well? I'll do some testing when I get home with both sets of images, just to see.

Thank Coh3n! :)
Just the main map, I think. The minimap doesn't change that much, but I have noticed that when RS loads a new section, it'll sometimes darken/lighten slightly.