SRL Archive - OSR Help

Help with color picking and storing points?


Element17

2013-02-16 18:36:47

[ATTACH=CONFIG]19217[/ATTACH]

I have trying to click the far left one which is the enchanter one, but use ACA its all to common. How can I sort it out so that it only picks the one on the left? Also is there a way to store those cords that it found it?

This is what I currently have, and it spam moves the mouse for about three seconds then it does end up landing on the correct one, but looks crazy with the mouse moving all over the screen.

Function FindPortal(var x, y: Integer): Boolean;
Var CTS, I: Integer; TPA: TPointArray; ATPA: Array of TPointArray;
Begin If(Not(LoggedIn))Then Exit;
CTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.26, 0.96);
FindColorsSpiralTolerance(MSCX, MSCY, TPA, 5271937, MSX1, MSY1, MSX2, MSY2, 10);
ATPA := TPAToATPAEx(TPA, 20, 20);
For I := 0 To High(ATPA) Do
Begin MiddleTPAEx(A
TPA[i], x, y);
MMouse(x, y, 2, 2);
//If DeBug Then
//Smart_DebugATPA(True, ATPA);
If(IsUpTextMultiCustom(['Ench','ters'])) Then
Begin Writeln('Found Portal');
GetMousePos(x, y);
Result := True;
Break;
End;
End;
End;

Flight

2013-02-16 18:50:05

I'm going to help you with this. Give me a few minutes, I'll edit this post when I'm done.

Edit:
Try this out for size mate:


function FindPortal: Boolean;
var
CTS, I: Integer;
TPA,Portals: TPointArray;
ATPA: array of TPointArray;
begin
if (not (LoggedIn)) then
Exit;

CTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.28, 0.49);

FindColorsSpiralTolerance(MSCX, MSCY, TPA, 10991793, MSX1, MSY1, MSX2, MSY2, 6);

ColorToleranceSpeed(CTS);
SetColorSpeed2Modifiers(0.2, 0.2);

RAaSTPA(TPA, 5);
ATPA := SplitTPAEx(TPA, 25, 25);
SortATPAFromFirstPoint(ATPA, Point(MSX1,MSCY));

for i := 0 to High(ATPA) do
begin
if (GetArrayLength(ATPA[i]) >= 10) then
begin
SetArrayLength(Portals, Length(Portals)+1);
Portals[High(Portals)] := MiddleTPA(ATPA[i]);
end;
end;

if (Length(Portals) > 0) then
SortTPAFrom(Portals, Point(MSX1,MSCY))
else
Exit;

Writeln(IntToStr(Length(Portals))+' portals found.'); //Delete this is you want

for i:=0 to High(Portals) do
begin
MMouse(Portals[i].X, Portals[i].Y, 5, 5);
if WaitUpTextMulti(['Ench', 'ters'], 400) then
begin
Result := True;
Exit;
end;
end;
end;

Let me know if you'd like an explanation of how everything works within this function. Based off the picture you provided, this should be 100% accurate to the far left portal every time.

PS, Nebula's a nub.

Nebula

2013-02-16 19:14:18

Create a TPA of the middle of each teleporter so that there are 3 points, one for each teleporter.

Rotate the points in the TPA by -RS_GetCompassAngleRadians radians using RotatePoints.

Use SortTPAByX to sort your TPA in order of left to right.

Rotate the farthest left point of your TPA ( TPA[0] ) by RS_GetCompassAngleRadians radians by using RotatePoint.

Mouse(TPA[0].x, TPA[0].y, 0, 0, true) :)

~ nebula

@Flight's a noob

Element17

2013-02-16 19:33:07

From: Flight
I'm going to help you with this. Give me a few minutes, I'll edit this post when I'm done.

Edit:
Try this out for size mate:


function FindPortal: Boolean;
var
CTS, I: Integer;
TPA,Portals: TPointArray;
ATPA: array of TPointArray;
begin
if (not (LoggedIn)) then
Exit;

CTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.28, 0.49);

FindColorsSpiralTolerance(MSCX, MSCY, TPA, 10991793, MSX1, MSY1, MSX2, MSY2, 6);

ColorToleranceSpeed(CTS);
SetColorSpeed2Modifiers(0.2, 0.2);

RAaSTPA(TPA, 5);
ATPA := SplitTPAEx(TPA, 25, 25);
SortATPAFromFirstPoint(ATPA, Point(MSX1,MSCY));

for i := 0 to High(ATPA) do
begin
if (GetArrayLength(ATPA[i]) >= 10) then
begin
SetArrayLength(Portals, Length(Portals)+1);
Portals[High(Portals)] := MiddleTPA(ATPA[i]);
end;
end;

if (Length(Portals) > 0) then
SortTPAFrom(Portals, Point(MSX1,MSCY))
else
Exit;

Writeln(IntToStr(Length(Portals))+' portals found.'); //Delete this is you want

for i:=0 to High(Portals) do
begin
MMouse(Portals[i].X, Portals[i].Y, 5, 5);
if WaitUpTextMulti(['Ench', 'ters'], 400) then
begin
Result := True;
Exit;
end;
end;
end;

Let me know if you'd like an explanation of how everything works within this function. Based off the picture you provided, this should be 100% accurate to the far left portal every time.

PS, Nebula's a nub.



Would love a explanation just because I don't wanna use it and not know what it is doing, no fun in not learning but thanks a lot mate!

@Nebula thank you for your post as well!

Flight

2013-02-16 19:57:20

From: Element17
Would love a explanation just because I don't wanna use it and not know what it is doing, no fun in not learning but thanks a lot mate!


Here ya go:


function FindPortal: Boolean;
var
CTS, I: Integer;
TPA,Portals: TPointArray;
ATPA: array of TPointArray;
begin
if (not (LoggedIn)) then
Exit;

CTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.28, 0.49);

FindColorsSpiralTolerance(MSCX, MSCY, TPA, 10991793, MSX1, MSY1, MSX2, MSY2, 6); //These are colors I gathered myself

ColorToleranceSpeed(CTS);
SetColorSpeed2Modifiers(0.2, 0.2);

RAaSTPA(TPA, 5); //Remove points that are under 5 distance from each other
ATPA := SplitTPAEx(TPA, 25, 25); //When splitting TPAs there is no overlapping, but sometimes the size is off
SortATPAFromFirstPoint(ATPA, Point(MSX1,MSCY)); //Sort this 2D TPA from the center left-side of the screen

for i := 0 to High(ATPA) do
begin
if (GetArrayLength(ATPA[i]) >= 10) then //If this TPA contains atleast 10 points then...
begin
SetArrayLength(Portals, Length(Portals)+1); //...it's probably one of the portals
Portals[High(Portals)] := MiddleTPA(ATPA[i]); //So, the center of this TPA will be the center of one of the portals
end;
end;

if (Length(Portals) > 0) then //If we found some portals then sort them starting from the center left of the MS
SortTPAFrom(Portals, Point(MSX1,MSCY))
else
Exit; //If no portals found, exit;

Writeln(IntToStr(Length(Portals))+' portals found.'); //Delete this is you want

for i:=0 to High(Portals) do //For each portal do...
begin
MMouse(Portals[i].X, Portals[i].Y, 5, 5); //Move the mouse to the given portal in the array, with a 5 X/Y randomness
if WaitUpTextMulti(['Ench', 'ters'], 400) then //If we 'wait' for the uptext then...
begin
Result := True; //It's the correct portal, yay!
Exit;
end;
end;
end;

Element17

2013-02-16 20:17:48

Wow thank you so much! Credits will surely be given!

Sjoe

2013-02-16 20:53:03

@Flight

Would u care to explain RAaSTPA more detailed? Seems like it's useful, but I don't really understand it fully.
Also read it on Wizzy Plugin:


PHP Code:
{*******************************************************************************
procedure RAaSTPA(var a: TPointArray; const Dist: Integer);
Description: Leaves one point per box with the side length Dist.
*******************************************************************************}


This does what RAaSTPAEx does except it doesn't have the Width ('w') parameter. This means that it will make a circle of radius Dist around the point, in which not to have any points in.
Okay, boys and girls:

Or maybe show a debug image, so I see what it does :p

Thanks!

Nebula

2013-02-16 21:03:04

@Sjoekeloe

It converts a TPA into a TPA of the middle point of each group of points (Circle or box depending on which function you're using RAaSTPA(Ex)).

Sjoe

2013-02-16 21:04:07

From: Nebula
@Sjoekeloe

It converts a TPA into a TPA of the middle point of each group of points.


Thank you !!
So it converts a TPA to a Middle Tpoint?

Nebula

2013-02-16 21:06:58

From: Sjoekeloe
Thank you !!
So it converts a TPA to a Middle Tpoint?


Basically, it converts a TPA into an ATPA, then returns the Middle of each TPA in the ATPA as a TPA. So yeah.

Flight

2013-02-16 21:21:28

From: Nebula
@Sjoekeloe

It converts a TPA into a TPA of the middle point of each group of points (Circle or box depending on which function you're using RAaSTPA(Ex)).


No. :/ Like I said in my example:

RAaSTPA(TPA, 5); //Remove points that are under 5 distance from each other

It takes every point in the TPA and filters out the points that are less than the given distance from each other, in this case 5. It has nothing to do with the middle of any TPA, it simply filters points by distance.


Sjoe

2013-02-16 21:27:23

From: Flight
No. :/ Like I said in my example:

RAaSTPA(TPA, 5); //Remove points that are under 5 distance from each other

It takes every point in the TPA and filters out the points that are less than the given distance from each other, in this case 5. It has nothing to do with the middle of any TPA, it simply filters points by distance.



Cheers :)