SRL Archive - OSR Help

Function Request


XcanadamanX

2010-05-05 19:18:33

Hey guys. Im just wondering if anyone has made a function that finds the closest point in every direction. (that didnt describe it very well) so i have this TPA (uploaded picture) the TPA is in Red. I want to get the box around the furnace symbol. Even if someone hasnt made the function i need, maybe a suggestion on how i could do it? I cant figure it out and ive looked through wizzy plugin/simba but cant find anything i could use…

i luffs yeww

2010-05-05 20:06:58

Couldn't you use MiddleTPA/MiddleTPAEx? If you do it by hand the first time to find it, then if MiddleTPA = whatever, then it's true? I hope you know what I mean.. :) It'd work, I think.

Or GetTPABounds.

Cazax

2010-05-05 20:36:00

Hmm I think this could work:
Function FurnaceBox(TPA : TPointArray): TBox;
Var
Bounds : TBox;
orangeTPA : TPointArray;
Begin
Bounds := GetTPABounds(TPA);
FindColorsTolerance(orangeTPA, FurnaceOrangeColor, Bounds.X1, Bounds.Y1, Bounds.X2, Bounds.Y2);
{HSL check:
For I := 0 To High(orangeTPA) Do
Begin
ColorToHSL(GetColor(orangeTPA[I].X, orangeTPA[I].Y), H, S, L);
If (H >= MinRange) and (H <= MaxRange) Then //can be H, S or L, even RGB
Begin
SetLength(NewTPA, Length(NewTPA) + 1);
newTPA[High(newTPA)] := TPA[I];
End;
End; }
Result := GetTPABounds(orangeTPA);
End;
But that'll work if you do an accurate HSL(or RGB) check that doesn't confuse with other items(dropped things, the kebab symbol maybe?) with a low range(less than 10). FindSymbol('furnace') should work fine too.

XcanadamanX

2010-05-05 22:45:21

From: i luffs yeww
Couldn't you use MiddleTPA/MiddleTPAEx? If you do it by hand the first time to find it, then if MiddleTPA = whatever, then it's true? I hope you know what I mean.. :) It'd work, I think.

Or GetTPABounds.


Thats pretty much what im doing right now. it works but if i could find the wall surrounding the furnace then i can find the middle of the furnace room really easily.

i luffs yeww

2010-05-05 23:08:01

Wouldn't GetTPABounds do that? And isn't it always the same shape/size? :p Seems like it could be pretty simple.

XcanadamanX

2010-05-06 09:49:37

No GetTPABounds doesnt work. if you look at the picture you will see that there is the other rooms beside the furnace room and my TPA is the Red lines. There are those lines from the other rooms that i do not want to have in my TPA. How is the shape/size going to help?

Sir R. M8gic1an

2010-05-06 13:42:08

I've thought about this many times; Never did it. Here's an idea:

find symbol center. Store it as TP.
Find Walls. Store as TPA.

and now just simply find four points.

Draw a vertical line from the TP, and the first point up and the first point down should be the top and bottom walls of the furnace.

Draw a horizontal line and you should find yourself the right and left walls ;)
Then you can easily find the center of the room ;)

Give it a go, and let me know if it works :p I might have some work to do in AK soon :)

e: If you're not sure how to do it, here's an inefficient way:

Function FindRoom(WallTPA: TPointArray; Symbol: TPoint): TPoint;
var
i: integer
Room : TBox;
begin

while Room.x1 = 0 do
begin
inc(i)
Symbol.x - i;
if PointInTPA(Point(Symbol.x-i, Symbol.y)) then
Room.x1 := Symbol.x - i;
end;

end;

Perhaps it would be much faster to sort through the WallTPA first. Find all the points that have the same x value as your Symbol and then just get the two closest ones to your point. An algorithm similar to bubblesort short be fast enough. Remeber that you'll need one point above and one below.

(Repeat process with y coord)


var
x, y, i: integer;
b: boolean;
begin
b := true;
x := 500000;

while b do
begin
b := false;
for i := 0 to High(WallTPA) do
if WallTPA[i].x < x then
if WallTPA[i].x > Symbol.x then // for finding the point above.
begin
x := WallTPA[i].x ;
b := true;
end;
end;

e2: Heh, I'll definitely be using something like this next time I do an Alkharider.. :)

~RM

Frement

2010-05-06 13:44:41

From: Rasta Magician
I've thought about this many times; Never did it. Here's an idea:

find symbol center. Store it as TP.
Find Walls. Store as TPA.

and now just simply find four points.

Draw a vertical line from the TP, and the first point up and the first point down should be the top and bottom walls of the furnace.

Draw a horizontal line and you should find yourself the right and left walls ;)
Then you can easily find the center of the room ;)

Give it a go, and let me know if it works :p I might have some work to do in AK soon :)

~RM


WOW! Thats the most genius idea i have seen in a while! :D I would have never thought of that.

YoHoJo

2010-05-06 13:51:43

OR :]
You can find that cluster of cactus-rock-cactus sandwich
( http://www.rsbandb.com/interactive_runescape_world_map/position/45.784149169921875/-80.75775146484375/10 )
and just click x-10, y+5 (or however many units is proper)

Sir R. M8gic1an

2010-05-06 14:01:49

From: Frement
WOW! Thats the most genius idea i have seen in a while! :D I would have never thought of that.


Take into consideration how many months it took me to come up with such a thing :p I first thought of it when I was doing my smelter… which has now been outdated for a few months, and i only just now thought of how to solve this problem. :p

~RM

Frement

2010-05-06 15:02:07

From: Rasta Magician
Take into consideration how many months it took me to come up with such a thing :p I first thought of it when I was doing my smelter… which has now been outdated for a few months, and i only just now thought of how to solve this problem. :p

~RM


Well, whatever you do, dont die young! Every great man always dies young. Its true you know :)

XcanadamanX

2010-05-06 18:10:30

From: Rasta Magician
Take into consideration how many months it took me to come up with such a thing :p I first thought of it when I was doing my smelter… which has now been outdated for a few months, and i only just now thought of how to solve this problem. :p

~RM


Thanks! Ive been trying to figure out a way for awhile. Ill try to implement tonight or tomorrow sometime! thanks again!

OR :]
You can find that cluster of cactus-rock-cactus sandwich
( http://www.rsbandb.com/interactive_r...75146484375/10 )
and just click x-10, y+5 (or however many units is proper)


Im pretty sure that the map is outdated and there is no longer that cactus-rock-cactus sandwich :P Thanks for your help