SRL Archive - Research & Development Lounge

[UTILITY] SPS Path Maker


Iamadam

2011-02-14 09:50:44

Hi all

As you may know, SRL is soon to have a color based walking/positioning system. I thought that instead of using paint to painstakingly make paths, I'd develop an application to do it :)

So here it is.
Note that I made this all tonight so it may be buggy, but I want to release it before I go to bed.

To run:
1. Extract
2. Run the batch file (you can open it in notepad if you don't trust me…);

Then to make a path, all you need to do is click on a point on the map, and it will be added to the path. To remove the point, click it again.

To move the map around, just click and drag.

I will edit this so it also works with reflection paths, but not now.
Here's a pic for you all:


Download: http://www.mediafire.com/?t16hkcb74s3v3l5

SPS: http://villavu.com/forum/showthread.php?t=62286

Edit: Updated. Now shows minimap circle around cursor. To update, just copy the class files from the new rar file(below) over the old ones.

Gu3st...

2011-02-14 10:07:45

Amazing :D
Good work :)

Sabzi

2011-02-14 10:44:54

On good suggestion would be something same that is in another path-maker that I can't remember. Namely add a circle around the cursor when you choose the path representing how big the mini-map is so it's easier to make path.

EDIT: Good Job!!!

Rich

2011-02-14 11:10:14

Absolute beast.

mormonman

2011-02-14 11:43:38

Sauce?

marpis

2011-02-14 14:22:20

Nice! :) rep++
Didn't take long for someone to catch up on this! :D

Nava2

2011-02-14 18:04:51

Please post source for at least staff to read before posting things like this.

Its for the safety of those around here. :)

Opal Tasty

2011-02-14 18:27:03

I literally just finished making a path from Port Sarim to GE right before I saw this. After doing all that I can tell you that this is going to be soooo helpful. Thanks!

Iamadam

2011-02-14 19:10:48

On good suggestion would be something same that is in another path-maker that I can't remember. Namely add a circle around the cursor when you choose the path representing how big the mini-map is so it's easier to make path.

Yeah that's a good idea. Will add it.
At the moment it makes a red line if the distance is too big, and a green one if it thinks the distance between points is fine.

From: Nava2
Please post source for at least staff to read before posting things like this.

Its for the safety of those around here. :)


I haven't obfuscated it, if anyone is unsure whether or not I am trustworthy you can easily decompile it :) You'll get pretty much perfect source.

But here it is anyway.

Coh3n

2011-02-14 19:37:03

Awesome work! :)

mormonman

2011-02-14 20:21:42

public void paint(Graphics g) {
if(map != null) {
g.drawImage(map, 0, 0, getWidth(), getHeight(), xOffset, yOffset, xOffset + getWidth(), yOffset + getHeight(), Color.BLACK, null);
if(pathLog != null) {

int lastX = 0, lastY = 0;

for(Point p : pathLog.getPoints()) {

g.setColor(Color.ORANGE);
g.fillOval(p.x - xOffset - 3, p.y - yOffset - 3, 6, 6);



if(lastX != 0) {
if(distance(lastX, lastY, p.x - xOffset, p.y - yOffset) > pointDistanceThreshold) {
g.setColor(Color.RED);
} else {
g.setColor(Color.GREEN);
}

g.drawLine(lastX, lastY, p.x - xOffset, p.y - yOffset);
}
lastX = p.x - xOffset;
lastY = p.y - yOffset;
}
g.setColor(Color.LIGHT_GRAY);
g.drawOval(lastX - pointDistanceThreshold, lastY - pointDistanceThreshold, pointDistanceThreshold*2, pointDistanceThreshold*2);
}
updateInputPanel();
}
}

Really easy to add circle.

Edit: http://download.oracle.com/javase/tutorial/uiswing/components/scrollpane.html
I suggest adding that, combined with the click/drag feature.

Edit2: Also, resizing the window needs to be implemented.

Iamadam

2011-02-14 20:47:08

Already done :P
		if(drawMinimapCircle) {
//152 x 152.
g.setColor(Color.DARK_GRAY);
g.drawOval(mouseX - 76, mouseY - 76, 152, 152);
}
Got it to repaint on mouse move too.

Edit: Yeah could add a scroll pane to the map but I find it works ok with just click n' drag. The Log on the side uses a scroll pane, so I do know how awesome they are :P It's just much easier to keep track of x/y offset without a scroll pane on the map.

Nava2

2011-02-14 23:18:38

Perhaps use a table on the side, then have a dialogue to print it in PS format.

Just an idea. :) Looks very nice though! I like how you got it out so quickly.

It wasn't really an issue of trust, more just in case, y'know? Plus we are a very Open Source oriented community, and as such we can help each other with this! :)

If this keeps moving like this, I have no problem shipping this with SRL. Maybe this could be made into an extension though? I know its Java, but it would merely take some conversion and we could then ship it with Simba!

Once again, nice job!

Echo_

2011-02-14 23:25:54

Nice, now I can work on my script paths without even logging in. Unfortunately my school blocks SMART from connecting to the internet, but now I don't have to :D

noidea

2011-02-14 23:35:17

From: Echo_
Nice, now I can work on my script paths without even logging in. Unfortunately my school blocks SMART from connecting to the internet, but now I don't have to :D


blocks rs*
Use a proxy.

Train

2011-02-14 23:36:44

Be more specific for him.
SMART uses internet explorers proxy settings, correct?
Set a proxy in Internet Explorer's Options and then try SMART again.

Echo_

2011-02-14 23:41:18

They don't block rs, just SMART and Powerbot are blocked. Proxies don't work at my school. I do have my librarian's district password though (keylogged him), maybe I could somehow use that to connect with SMART?

pyroryan

2011-02-14 23:52:28

From: Echo_
They don't block rs, just SMART and Powerbot are blocked. Proxies don't work at my school. I do have my librarian's district password though (keylogged him), maybe I could somehow use that to connect with SMART?


So do they block java?

Becks

2011-02-15 00:01:11

This is awesome. thanks.

Boreas

2011-02-15 00:59:42

This works with reflection too right? If not, IMO SPS should be changed to include the calculations to be compatible with GetMyPos.

Coh3n

2011-02-15 01:23:32

From: Boreas
This works with reflection too right? If not, IMO SPS should be changed to include the calculations to be compatible with GetMyPos.

I think marpis plans on it. He or someone else just need to get the maths right.

Echo_

2011-02-15 07:46:49

From: pyroryan
So do they block java?


Well they don't block java if I can get on to RS. Maybe they block java applets? I have no clue. If you want to talk about it more, just pm me, because this discussion is off topic for this thread.

Iamadam

2011-02-15 08:05:17

From: Coh3n
I think marpis plans on it. He or someone else just need to get the maths right.


Thought I'd might as well do the maths:
X Pixel to X Tile: pixelX/4 + 2093.5
Y Pixel to Y Tile: 3776 - (pixelY / 4);

Home

2011-02-15 08:29:05

I don't get it.. For me it won't start :S No errors. Anything..

~Home

Gu3st...

2011-02-15 10:51:39

From: Iamadam
Thought I'd might as well do the maths:
X Pixel to X Tile: pixelX/4 + 2093.5
Y Pixel to Y Tile: 3776 - (pixelY / 4);
Awe-some. :)

function SPS_PixelToTile(pixelX, pixelY : Integer): TTile;
begin
Result.X := Round(2093.5 + (pixelX / 4));
Result.Y := Round(3776.0 - (pixelY / 4));
end;

marpis

2011-02-15 13:37:30

From: Zyt3x
Awe-some. :)

function SPS_PixelToTile(pixel: tpoint): TTile;
begin
Result.X := Round(2093.5 + (pixel.X / 4));
Result.Y := Round(3776.0 - (pixel.Y / 4));
end;


tpoint so its compatible with sps_getmypos

- mobile

mormonman

2011-02-15 13:46:06

From: marpis
tpoint so its compatible with sps_getmypos

- mobile



function SPS_PixelToPoint(pixel: tpoint): TPoint;
begin
Result.X := Round(2093.5 + (pixel.X / 4));
Result.Y := Round(3776.0 - (pixel.Y / 4));
end;

Gu3st...

2011-02-15 13:55:16

From: mormonman

function SPS_PixelToPoint(pixel: tpoint): TPoint;
begin
Result.X := Round(2093.5 + (pixel.X / 4));
Result.Y := Round(3776.0 - (pixel.Y / 4));
end;
Hehe, take a harder look at the post you quoted ;) He already edited the function :)

mormonman

2011-02-15 14:04:41

From: Zyt3x
Hehe, take a harder look at the post you quoted ;) He already edited the function :)


I seriously just read through the entire thread like 3 times and I still don't see what your talking about.

Gu3st...

2011-02-15 14:20:07

How would the SPS_TileToPixel math be?

Train

2011-02-15 22:04:37

From: Zyt3x
How would the SPS_TileToPixel math be?


Solve it for the variable of the pixel.
function SPS_PixelToPoint(pixel: TPoint): TPoint;
begin
Result.X := Round(2093.5 + (pixel.X / 4));
Result.Y := Round(3776.0 - (pixel.Y / 4));
end;

function SPS_PointToPixel(point: TPoint): TPoint;
begin
Result.X := Round((point.x - 2093.5) * 4);
Result.Y := Round((3776.0 - point.y) * 4);
end;

Coh3n

2011-02-16 01:56:09

I suggest having the multipliers constants in case they need to be changed.

Gu3st...

2011-02-16 04:09:05

From: Train
Solve it for the variable of the pixel.
function SPS_PixelToPoint(pixel: TPoint): TPoint;
begin
Result.X := Round(2093.5 + (pixel.X / 4));
Result.Y := Round(3776.0 - (pixel.Y / 4));
end;

function SPS_PointToPixel(point: TPoint): TPoint;
begin
Result.X := Round((point.x - 2093.5) * 4);
Result.Y := Round((3776.0 - point.y) * 4);
end;
Yeah, I figured it out already

Coh3n

2011-02-16 15:12:34

From: Home
I don't get it.. For me it won't start :S No errors. Anything..

~Home

Same here. The cmd window opens then closes, but nothing else happens..

IPwnz

2011-02-16 19:33:01

From: Coh3n
Same here. The cmd window opens then closes, but nothing else happens..


Same here.

Echo_

2011-02-16 19:46:58

I reuploaded it to include the worldmap.bmp, batch file to run the program, and a set of instructions :)

updating…

bigjosh0315

2011-02-16 22:12:22

From: Echo_
I reuploaded it to include the worldmap.bmp, batch file to run the program, and a set of instructions :)

http://www.mediafire.com/?8bt8kofe1u02i6h


His fix works. =). This is great. Thanks Iamadam.

Edit: It's giving me the wrong SPS areas. Idk if the points are right or not. I'll find out.

Edit: Points are off too.

Iamadam

2011-02-17 07:31:54

Should work fine. I've used it to generate a path which has walked basically everywhere in the free world. So I don't know what's going wrong for you.
Edit: I think Echo_ may have uploaded it with the wrong wordmap.bmp.
Also, it may not work with the batch file he posted as on a lot of machines you need to increase the heap space. Best bet is to download the big rar file (on 3rd party hosting software) in the first post, and add worldmap.bmp from that to the pathmaker folder. Or copy worldmap.bmp from your SPS folder.

if the cmd appears then disappears, replace the text in the batch file with this:
@echo off
java -Xms32m -Xmx128m PathMaker
pause
And post whatever comes up if it still doesn't work.

bigjosh0315

2011-02-17 08:49:09

I replaced the text in the batch and got this error:


bigjosh0315

2011-02-17 08:55:05

From: Iamadam
Should work fine. I've used it to generate a path which has walked basically everywhere in the free world. So I don't know what's going wrong for you.
Edit: I think Echo_ may have uploaded it with the wrong wordmap.bmp.
Also, it may not work with the batch file he posted as on a lot of machines you need to increase the heap space. Best bet is to download the big rar file (on 3rd party hosting software) in the first post, and add worldmap.bmp from that to the pathmaker folder. Or copy worldmap.bmp from your SPS folder.

if the cmd appears then disappears, replace the text in the batch file with this:
@echo off
java -Xms32m -Xmx128m PathMaker
pause
And post whatever comes up if it still doesn't work.


I replaced the text in the batch and got an error.


but I put this in the batch and it worked:

@echo off
title PathMaker
start javaw PathMaker
exit

That was the text in batch that Echo_ uploaded. When I put it in the batch you uploaded the pathmaker opened and and the SPS areas and points are perfect. =). I guess he did put a different map or something.

Nava2

2011-02-17 08:55:27

From: bigjosh0315
I replaced the text in the batch and got this error:



Its the exact issue posted above, have you tried his solution?

If it didn't work, you could try:
@echo off
java -Xms32m -Xmx256m PathMaker
pause

That will allocate 256mb of heap rather than just 128. I really hope it doesn't even need 128mb. o.O

Echo_

2011-02-17 09:43:00

I will repost the link when I get home, I need to switch out the map with the working one. Otherwise, just use my batch file and the map file from the SPS thread.

bigjosh0315

2011-02-17 11:19:07

From: Nava2
Its the exact issue posted above, have you tried his solution?

If it didn't work, you could try:
@echo off
java -Xms32m -Xmx256m PathMaker
pause

That will allocate 256mb of heap rather than just 128. I really hope it doesn't even need 128mb. o.O


Yes, I tried it but his solution is what gave me the error. At first the cmd prompt would just open then close. But, I replaced the text in the original .batch with the text from Echo_'s .batch and it worked perfectly. It's in my reply you quoted if you want to try it. You could just move Echo_'s .batch the original folder and replace it, but if you don't want to download both just to move it over here it is.

@echo off
title PathMaker
start javaw PathMaker
exit

Echo_

2011-02-18 07:24:54

Alright, here's the package with the correct bitmap :p Sorry for taking a long time.

http://www.mediafire.com/?qu1ycdv4t3uw9rb

Yago

2011-02-18 18:42:27

What program does this file open with?

Iamadam

2011-02-18 21:50:40

It's a java application.
So run the batch script. If you want to run it on linux/mac I'm not sure how to execute it. But it _is_ cross platform because it's java.

As for why my batch won't work for some people: No idea. Anyone have insight?

Nava2

2011-02-19 02:56:33

From: Iamadam
It's a java application.
So run the batch script. If you want to run it on linux/mac I'm not sure how to execute it. But it _is_ cross platform because it's java.

As for why my batch won't work for some people: No idea. Anyone have insight?


If you wanted it to work on linux.mac just write a bash script to do the same thing as the bash script. Although, most users of Linux probably know how to use a terminal enough to figure there way around running a java program ;).

Echo_

2011-02-19 08:30:46

Windows batch:
@echo off
title PathMaker
java PathMaker
pause

Linux batch:
java PathMaker

Apache Ant run.xml with batch:
<project name="PathMaker" default="run" basedir=".">
<target name="run" description="Runs Iamadam's RS Path Maker.">
<java classname="PathMaker" fork="true">
</java>
</target>
</project>

ant run

There, now you can run it on any OS :)

Yago

2011-02-19 12:59:03

its not an executable or anything though. Ill try to figure it out.

bigjosh0315

2011-02-19 14:48:48

From: yago
its not an executable or anything though. Ill try to figure it out.


The batch opens it. Just click it. =). You should see a command prompt then the path maker will come up. If the path maker doesn't open after the command prompt then right click on the batch file, click edit and replace the code with the code Echo_ posted.

Yago

2011-02-20 18:37:07

From: Echo_
Windows batch:
@echo off
title PathMaker
java PathMaker
pause

I tried this and i got the following error

"java is not recognized as an internal or external command, operable program, or batch file."

Echo_

2011-02-20 18:56:09

From: yago
From: Echo_
Windows batch:
@echo off
title PathMaker
java PathMaker
pause

I tried this and i got the following error

"java is not recognized as an internal or external command, operable program, or batch file."


That means you haven't set your environmental variables for java. You need to set them in order to run java applications out of the command prompt.
http://www.java.com/en/download/help/path.xml

Coh3n

2011-08-27 11:38:07

I'd like to add this to the SPS repository, how easy is it to make it able to load any map rather than just the runescape surface? Also, is the source included in the download?

Yago

2011-08-27 13:41:01

From: Echo_
From: yago


That means you haven't set your environmental variables for java. You need to set them in order to run java applications out of the command prompt.
http://www.java.com/en/download/help/path.xml


Lol yeah i was a noob at this stuff lol. I didnt even know batch files existed. This is pretty old…

Echo_

2011-08-28 08:38:13

From: Coh3n
I'd like to add this to the SPS repository, how easy is it to make it able to load any map rather than just the runescape surface? Also, is the source included in the download?


The source is here. As for loading other maps, I don't think there is a way currently to enter custom tile offsets.

Coh3n

2011-08-28 19:28:56

From: Echo_
The source is here. As for loading other maps, I don't think there is a way currently to enter custom tile offsets.
Thanks, and you don't need any kind of offsets for SPS. It's just the pixel coord from the map.

RuneDragon

2012-06-02 18:40:40

Where do we get worldmap.bmp ?