View Full Version : RemoveDistTPointArrayWrap
I'm lost at the function:
function RemoveDistTPointArray(x, y, dist: Integer;const ThePoints: TPointArray; RemoveHigher: Boolean): TPointArray;
Finds the possible gaps in the TPointArray TPA and removes the gaps. Considers as a gap if the gap length is >= MinPixels
If they are 'gaps', it means the TPA don't contain these points, so i'm not sure what it means?
http://i.imgur.com/9HCCz.png
Basically, I'm using GetMMDotsOnMS to get the red dots, then i'm finding a way to delete the points outside the gate (there isn't any in the picture but there will be if someone is killing mobs outside the gate).
What i can think of right now is to get the TPA of the white color, then splitting them and getting the TPA with highest length (which should be the gate), follow by GetTPABounds and then just click on a red dot that is within the box.
However, the gate is, as you can see, not a perfect rectangle so if there is red dots right outside the gate it won't filter them out.
One possible way is to fill up all the 'gaps' within the gate then only consider those red dots that match the filled TPA.
I'm not too sure how these 'gaps' function (eg. the 1 above and FindGapsTPAWrap) work and can't find any detailed documentation of them. Hoping someone can explain them/suggest what i can do.
Also where can i find the source code of the WizzyPlugin? I might be able to read some Delphi. Can't find it at https://github.com/MerlijnWajer/Simba, unless it's hidden deeply in subfiles.
Taken from 'A low down on WizzyPlugin and TPA's (http://villavu.com/forum/showthread.php?t=49067)'
RemoveDistTPointArray
{************************************************* ******************************
function RemoveDistTPointArray(x, y, dist: Integer; ThePoints: TPointArray; RemoveHigher: Boolean): TPointArray;
Description: Removes the points that are inside or outside the distance Dist
from the point (x, y) from the TPointArray ThePoints.
************************************************** *****************************}
RemoveDistTPointArray, will make a circle of radius 'Dist' with it's center points being situated at cordinates 'x' and 'y'. The 'RemoveHigher' parameter of data type Boolean will remove points inside or outside of the circle.
RemoveHigher is True - Points removed outside the circle of radius 'Dist', points are kept within circle of radius 'Dist'
RemoveHigher is False - Points are kept outside the circle of radius 'Dist', points are removed within circle of radius 'Dist'.
Remember that this is a function so a data type of TPointArray must be assigned to it. It can be used as such:
program New;
{.Include SRL/SRL.Scar}
{.include srl/srl/misc/debug.scar}
Var x, y : Integer;
tpa : array of tpoint;
Begin
SetupSRL;
FindColorsTolerance(TPA, 7048347, msx1, msy1, msx2, msy2, 10);
MiddleTPAEx(TPA, x, y);
TPA := RemoveDistTPointArray(x, y, 20, TPA, true); // here
DebugTPA(tpa, '');
End.
What that script will do is find occurances of the color '7048347' in the mainscreen of runescape and find the middle of all those points. It then makes a circle of radius 20 (Dist) around the cordinates x and y of the TPointArray 'TPA'. The last parameter is true, so it will remove the points within the circle, and leave the ones outside of the circle untouched.
More will be explained in due time, in the next section.
WizzyPlugin source:
https://github.com/MerlijnWajer/Simba/blob/master/Units/MMLCore/tpa.pas#L964
function RemoveDistTPointArray(x, y, dist: Integer;const ThePoints: TPointArray; RemoveHigher: Boolean): TPointArray;
var
I, L, LL: integer;
begin;
L := 0;
LL := Length(ThePoints) -1;
SetLength(Result, LL + 1);
if RemoveHigher then
begin;
for I := 0 to LL do
if not (Round(sqrt(sqr(ThePoints[i].x - x)+sqr(ThePoints[i].y - y))) > Dist) then
begin;
Result[L] := ThePoints[i];
L := L + 1;
end;
end else
begin;
for I := 0 to LL do
if not (Round(sqrt(sqr(ThePoints[i].x - x)+sqr(ThePoints[i].y - y))) < Dist) then
begin;
Result[L] := ThePoints[i];
L := L + 1;
end;
end;
SetLength(Result,L);
end;
Option #1
I would define the outside of the area first. Make a TPA with the points of the wall in there. Then you can SplitTPAEx to split the TPA. For each TPA in the ATPA you can calculate the middlepoint and calculate which one is the nearest to the player (MMCX, MMCY = 627, 135).
Then once you know which TPA is the one of the fence around you, you can use that as boundaries. You can loop through every coord in the TPA and check if it finds the red color of the swamp toads. Or you can use GetMMDotsOnMS.
But that is basicly what you already posted.. but seems like a good way!
I made something similar here: http://villavu.com/forum/showthread.php?t=88223
--
Option #2
Once you have an ATPA you can use RAaSTPAEx to remove some points. Then you can draw a line from each point to another to get the rough outside of the area. Then you can search in that area.
That would look something like this:
http://img543.imageshack.us/img543/2101/edgev5.png
Taken from 'A low down on WizzyPlugin and TPA's (http://villavu.com/forum/showthread.php?t=49067)'
Ah i was looking there, strange that i didn't find it just now. Seems like RemoveDistTPointArray isn't what i'm looking for.
I couldn't understand what FindGapsTPA is though. There is no parameter for maximum pixel of gap, so it will group all TPA that isn't close (>MinPixels) together?
program new;
procedure test;
var
TPA: Tpointarray;
begin
TPA:=[Point(1,1),Point(5,5),Point(2,2),Point(223,231),Po int(20,20)];
writeln(FindGapsTPA(TPA,2));
writeln(SplitTPA(TPA,2));
end;
begin
test;
end.
[[(1, 1), (2, 2), (5, 5)], [(20, 20)], [(223, 231)]]
[[(1, 1), (2, 2)], [(20, 20)], [(223, 231)], [(5, 5)]]
Ran this and the output confused me further. Obviously FindGapsTPA didn't group (223,231) and (20,20) together with the rest (even though their gap is >2).
Also just discovered that SplitTPA actually rearranged the TPA? (5, 5) is placed to the last when it was at [2] of the TPA. Does that mean we should sort the TPA (from centre) after splitting rather than before?
Option #1
I would define the outside of the area first. Make a TPA with the points of the wall in there. Then you can SplitTPAEx to split the TPA. For each TPA in the ATPA you can calculate the middlepoint and calculate which one is the nearest to the player (MMCX, MMCY = 627, 135).
Then once you know which TPA is the one of the fence around you, you can use that as boundaries. You can loop through every coord in the TPA and check if it finds the red color of the swamp toads. Or you can use GetMMDotsOnMS.
But that is basicly what you already posted.. but seems like a good way!
I made something similar here: http://villavu.com/forum/showthread.php?t=88223
--
Option #2
Once you have an ATPA you can use RAaSTPAEx to remove some points. Then you can draw a line from each point to another to get the rough outside of the area. Then you can search in that area.
How do you 'draw a line from each point to another'? Also all the 'area' and 'boundary' you referred to are still rectangles right? As the gate isn't a perfect rectangle, it will cover extra/less area than the actual boundary of the gate which wouldn't be accurate.
Thanks for the source code link though!
Does anyone know a better solution to search within the exact boundary of the gate? I've thought of another idea, get 2 points from the TPA that have the same y-coordinate, then search across it, and repeat until all points are covered. Something like this:
http://i.imgur.com/59abY.png
The lines would of course be fully saturated and cover every pixel, but you get the idea :D
Well you could use ObjDTM and make a custom function that searches for the minimap dots in the area.
How do you 'draw a line from each point to another'? Also all the 'area' and 'boundary' you referred to are still rectangles right? As the gate isn't a perfect rectangle, it will cover extra/less area than the actual boundary of the gate which wouldn't be accurate.
Thanks for the source code link though!
Does anyone know a better solution to search within the exact boundary of the gate? I've thought of another idea, get 2 points from the TPA that have the same y-coordinate, then search across it, and repeat until all points are covered. Something like this:
http://i.imgur.com/59abY.png
The lines would of course be fully saturated and cover every pixel, but you get the idea :D
I just made this and it does compile and print out a result that seems correct:
procedure Test;
var
TPA, TPA2, TPA3: TPointArray;
ATPA, ATPA2: T2DPointArray;
i, j, k, l: Integer;
begin
TPA := [Point(0, 0), Point(1, 1), Point(5, 5), Point(6, 6), Point(7, 7),
Point(9, 9), Point(15, 15), Point(13, 6), Point(16, 1), Point(19, 11)];
// Splitting the TPA into a ATPA and sorting it from big to small
ATPA := SplitTPAEx(TPA, 10, 10);
SortATPASize(ATPA, True);
if Length(ATPA) > 0 then
begin
// Converting it to RAasTPA
RAaSTPAEx(ATPA[0], 5, 5);
TPA2 := CopyTPA(ATPA[0]);
// For each point in the Raastpa we made we make a tpa between the next points in the array
SetLength(ATPA2, high(TPA2));
for i:=0 to (high(TPA2)-1) do
ATPA2[i] := TPABetweenPoints(TPA2[i], TPA2[i+1], 1, 1);
// We add each point in the ATPA we made to a new TPA
for j:=0 to high(ATPA2) do
for k:=0 to high(ATPA2[j]) do
begin
SetLength(TPA3, Length(TPA3)+1);
TPA3[Length(TPA3)-1] := ATPA2[j][k];
end;
// Printing it out
for l:=0 to high(TPA3) do
writeln(TPA3[l]);
end;
end;
Haven't tested it on RS because I don't have a p2p account atm (otherwise I would've went to the swamp toads :P)
Anyways result:
(0, 0)
(1, 0)
(1, 0)
(2, 2)
(2, 3)
(3, 3)
(4, 3)
(4, 5)
(6, 6)
(6, 6)
(6, 6)
(8, 5)
(8, 5)
(10, 5)
(11, 6)
(12, 6)
(13, 6)
(13, 6)
(12, 7)
(12, 7)
(13, 9)
(13, 10)
(14, 11)
(13, 11)
(15, 12)
(15, 13)
(15, 15)
Then you can use that as boundary's I guess.
Powered by vBulletin® Version 4.2.1 Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.