SRL Archive - OSR Help

Pin Point an object on the screen


samerdl

2013-06-16 10:50:39

Kinda of dozed off and tired, not sure how to make this work.

What i want to accomplish: Find bones, pick them up.
What hinders the project: the fact the room pretty much has objects with 100% similar colors.

What i need to do: Tell the script in a for do loop, to loop through my TPA or ATPA and only begin moving mouse when its on the TPA/ATPA that matches the requested size.

Whats the problem? it doesn't work, and am not doing it right.

This isn't a corrected function, as it doesn't do what i want it to do, but this is what i have right now:



function SeenBones: boolean;
var
TPA:tpointarray;
I,H,Col,TmpCts:integer;
ATPA: T2DPointArray;
begin



//setlength(Tpa,2);
tmpCTS := GetColorToleranceSpeed;

ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(BoneHue, BoneSat);

result := FindColorsTolerance(TPA, BonesColor, 185, 50, 400, 250,BoneTol);


ColorToleranceSpeed(tmpCTS);
SetColorSpeed2Modifiers(0.2, 0.2);





// SetArrayLength(ATPA,1);
// ATPA := TPAtoATPAEx(TPA,20,20);
//TPAtoATPAWrap(TPA,10,ATPA);

TPAtoATPAExWrap(TPA,15,15,ATPA);
SortATPAFromSize(ATPA,10,true);


DebugATPA(atpa,'');
wait(1000);

H := High(ATPA);
For I := 0 To H Do
Begin
if ((length(ATPA[i]) < 160) and (length(ATPA[i]) > 40)) then
begin
writeln('yes');

result := true;


End;
end;
end;


The size is off for this and doesn't work really. The bones is minimum 40 maximum 160 from every angle on the screen.

I couldn't manage to make it work, so how do i get around making it only move mouse if its the object i really want? and not the skeletons in the background, which have much larger lengths as tpa's.

Already tried sorting from closest and all, currently it only searches for bones if there are red dots on the minimap and my inventory is not full.. But it seldom spazzes all over the screen too..

SO how do i set a length in size for a tpa and not just an array number?.
Sorry for posting this, i know if i try harder i'll probably figure it out, but to be honest am too tired.. Pretty sure at least one person already encountered this problem and solved it.

Peanuts

2013-06-16 11:32:00

Okay.. I'm not great at this.. but i can maybe point you in the right direction.. I've only just started learning this stuff too.

From: samerdl

ATPA := TPAtoATPAEx(TPA,20,20);


If you change those you will change the box size?..

and put
// smart_debugATPA(true,ATPA);     

nearby so you can watch what it picks up on screen..

I think bones may be somewhere like… 5,5, but try 10,10 and see what shows up on screen………
If it is still finding other objects thn you need to set the pixels to search for in the box.. ahh.. im really tired too…
If no one else helps ill edit your script n try make it work .. .. I'm not very good at explaining things

samerdl

2013-06-16 11:47:48

From: Peanuts
Okay.. I'm not great at this.. but i can maybe point you in the right direction.. I've only just started learning this stuff too.



If you change those you will change the box size?..

and put
// smart_debugATPA(true,ATPA);     

nearby so you can watch what it picks up on screen..

I think bones may be somewhere like… 5,5, but try 10,10 and see what shows up on screen………
If it is still finding other objects thn you need to set the pixels to search for in the box.. ahh.. im really tired too…
If no one else helps ill edit your script n try make it work .. .. I'm not very good at explaining things


Well thats not apart of the script, thats me trying random stupid stuff, but hey thank for the reply, my problem isn't finding a box, my problem is making sure its the correct one by making sure its above the minimum size and below the maximum size, kinda hard to explain.

Buts its cool thanks.

Peanuts

2013-06-16 11:53:53

Do you debug and see what it finds?
That's the easiest way to figure out how to fix it..

Take a screenshot of the debug n ill tell you how to narrow your search

Flight

2013-06-16 11:59:39

A screenshot would be great.

Nebula

2013-06-16 12:01:16

You need to put a break in the loop so that the function stops after mouse'ing at the correct integer.

Simba Code:
function SeenBones: boolean;
var
TPA:tpointarray;
I,H,Col,TmpCts:integer;
ATPA: T2DPointArray;
begin
tmpCTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(BoneHue, BoneSat);
FindColorsTolerance(TPA, BonesColor, 185, 50, 400, 250,BoneTol);
ColorToleranceSpeed(tmpCTS);
SetColorSpeed2Modifiers(0.2, 0.2);

TPAtoATPAExWrap(TPA,15,15,ATPA);
SortATPAFromSize(ATPA,10,true);

DebugATPA(atpa,'');
wait(1000);

H := High(ATPA);
For I := 0 To H Do
Begin
if ((length(ATPA[i]) < 160) and (length(ATPA[i]) > 40)) then
begin
writeln('yes');
MMouse(MiddleTPA(ATPA[i]).x, MiddleTPA(ATPA[i]).y, 0, 0);
result := true;
break;
end;
end;
end;

samerdl

2013-06-16 13:05:35

Thanks Nebula, guess that's what i missed, will try something more elaborate later on thanks for the reply folks.
Its for the Ankous/skeletons room in stronghold fourth floor, now to sort out random events.. Just about the only spot you can train at and make money that isn't 100% crowded by bots (yet, some dude about to post a full script for it on tribot :()

Btw don't try to script when your starving/hungry ;)
I'll keep trying different things to get the result i desire and will edit this topic later.

Sorry for the typo's my S button doesn't work properly, and i wrote it when while hungry.