original post
edit: More in-depth explanation of the issue here: https://villavu.com/forum/showthread...23#post1376023
original post
edit: More in-depth explanation of the issue here: https://villavu.com/forum/showthread...23#post1376023
Last edited by acow; 06-11-2016 at 09:16 PM.
Simba Code:
for i := 1 to high(atpa) do if (distance(middleTPA(atpa[0]), middleTPA(atpa[i])) < 10) then writeln('found!') else writeln('not found!');
edit: probably not what you're asking. you're saying ATPA, but the pic makes it seem like you mean TPA?
also, from which points do you want to measure distance?
Last edited by Citrus; 06-11-2016 at 03:16 PM.
Kinda sounds to me like you wanna use clustering in the first place, not TPAToATPA, but I am not sure what your real goal is.
If you can't find another way to solve what you want you should know that it would turn out horribly slow to do what you want as soon as the flattened length of the ATPA get a tad large.
Last edited by slacky; 06-11-2016 at 04:01 PM.
!No priv. messages please
You could try putting ATPA's 2/3/etc in an array and then using some nested for loops to check distances between their TPA's and TPA's from ATPA1. So something like:
Simba Code:
for i:=0 to High(ATPA1) do for j:=0 to High(AATPAs) do for k:=0 to High(AATPAs[j]) do if (Distance(MiddleTPA(ATPA1[i]), MiddleTPA(AATPAs[j][k])) < 10) then writeln('found!') else writeln('not found!');
I think that should do what you wanted, maybe?
Perhaps something with the ATPA bounds -> T2DBoxArray
Expand that BoxesArray (array1), and check for overlap of each box?
https://villavu.com/forum/showthread.php?t=110546
I think this is what you are looking for.
My Scripts:
Alch-O-Matic --- Enchant-O-Matic --- AIO Portable-O-Matic --- Wilderness Agility --- Ivy Chop-O-Matic --- Bone-O-Matic
I was being less clear with explaining what I'm trying to do as I thought I was, my apologies.
In the picture there's 3 ATPAs
ATPA1 is red (3 TPAs)
ATPA2 is blue (2 TPAs)
ATPA3 is green (1 TPA)
I'd like to go through each of the TPAs in ATPA1 and for each one check if any of the TPAs in ATPA2 or ATPA3 are within a certain distance that first point. If it is, then do something!
In this specific case I wish to throw those TPAs out of ATPA1, when atleast 1 TPA of ATPA2/ATPA3 was found within X pixels.
In the image, the second TPA of ATPA1 would be the only TPA remaining (the "not found!" one).
Just incase you're wondering: This specific usage is for combat on Rs3, ATPA1 is the monster(s) and ATPA2 & ATPA3 are to let me know if the monster is already in combat with me / somebody else (if they're found within X distance from ATPA1 then ATPA1 was in combat), though this is also something that would be useful for relative filtering in general so I'm pretty interested in getting it done properly. Taking the input from @slacky; it'd most likely be best to reduce all of the TPAs in each ATPA to single points (at their middle), before filtering.
@fady; That is exactly where I got the idea, having used that guide to make this procedure that was in the combiner script, however it's only for finding the TPAs of an ATPA within X distance of a single point. Definitely a great start, though I'm not sure of where exactly I should be heading after that for this.
edit: changed "a single point" to "single points" for clarity (love you clarity! )
Last edited by acow; 06-12-2016 at 02:05 AM.
Simba Code:for i := 0 to high(ATPA) do
if inRange(length(ATPA[i]), 50, maxInt) then
begin
box := ATPA[i].getBounds();
box.expand(30);
for j := 0 to high(ATPA2) do
if box.overlap(ATPA2[j].getBounds) then
begin
ATPA.deleteIndex(i);
continue(2);
end;
for j := 0 to high(ATPA3) do
if box.overlap(ATPA3[j].getBounds) then
begin
ATPA.deleteIndex(i);
continue(2);
end;
end;
I'm not sure if continue(2) works like I intend, but I'm sure you can figure out some alternative if needed.
Maybe this helps:
Simba Code:function shouldDelete(box: TBox; ATPA: T2DPointArray): boolean
var
boxes: TBoxArray;
i: integer;
begin
boxes := ATPA.getEachBounds();
for i := 0 to high(boxes) do
if box.overlap(boxes[i]) then
exit(true);
end;
function acow(): TBoxArray;
var
i: integer;
box: TBox;
TPA: TPointArray;
ATPA, ATPA2, ATPA3: T2DPointArray;
color: T2DColorData;
begin
if color.gatherIn(TPA, mainScreen.getBounds()) then
mainScreen.filterPointsPlayer(TPA);
if (length(TPA) > 50) then
ATPA := TPA.cluster(20);
SortATPASize(ATPA, true);
for i := 0 to high(ATPA) do
if inRange(length(ATPA[i]), 50, maxInt) then
result.append(ATPA[i].getBounds());
for i := 0 to high(result) do
begin
box := result[i];
box.expand(30);
if shouldDelete(box, ATPA2) then
result.deleteIndex(i)
else if shouldDelete(box, ATPA3) then
result.deleteIndex(i);
end;
end;
Also you should probably gatherIn both the colors red/yellow in 1 atpa!
@acow, What method did you end up using?
Learned from what you guys posted, then researched up stuff & tested it out until that good ol' magical bot stuff started to happen.
Code wise it's a hacked together mess with lots of room for improvement. Functionality wise it's close, getting there in regards to effectively filtering them out & thus far I'm pretty happy with the cpu efficiency (simba averaging ~0.7% on my i7-3770 ).
Here's exactly where I've gotten to with it, if you'd like the rest of the script & an account to try it out on, just lmk and I'll pm it.
code
Something like that?
yellow dots is TPA found, you can make atpa from it if you want:
Tested on your beautiful MsPaint artwork
As ATPAs:
Last edited by bg5; 06-17-2016 at 09:07 PM. Reason: SPOILER fail
Tuts: Run script from another script || [Lape] Exceeding limits of VariantInvoke()
Plugins: Fast multi-layer objects finding || Multithreading in tabs || Optimised motion detection || ETL - paint on any window||Magic Keyboard (Simba's DirectX input + input in background to any normal window)
Snippets: [RS] Ultimate Loot Grabber || ShowPalette() || APPA JS Interface
There are currently 1 users browsing this thread. (0 members and 1 guests)