SRL Archive - OSR Help

Symbol Clicking question


Parade

2012-06-25 12:19:57

So was curious if it is possible to click in a certain distance away from a symbol. Say… You have a mining symbol on the minimap, and you want to click just a little bit south of it, would this be possible?

Main

2012-06-25 12:33:24

Yep
EDIT Adding coding

program new;
{$i SRL\SRL.simba}

Function Compas: Integer;
Begin
Result := Round( RS_GetCompassAngleDegrees);
End;

Function PolToPt( A, H: Integer; C: Tpoint): TPoint;
//Convert a angle'A'to a point'Result'from the center'C'.
//'H'is the distance from the point'C'.
Var
P: TPoint;
Rh: Integer;
Begin
A := 360 - A;
P.X := Round( - 100 * Sin( Radians( Compas + A )));
P.Y := Round( - 100 * Cos( Radians( Compas + A )));
Rh := Round( Hypot( P.X, P.Y));
P.X := C.X + H * P.X / Rh
P.Y := C.Y + H * P.Y / Rh;
Result:= P;
End;

Var
T: TPoint;
begin
SetupSRL;
If FindSymbol( T.X, T.Y, 'arrow') Then
Begin
T := PolToPt( 180, 75, T);
Mouse( T.X, T.Y, 0, 0, True);
End;
end.

The line

T:=PolToPt( 180, 75, T);

Means T ( the point) will now be 180 degrees ( which is south) and 75 pixel away from the point T (which is the symbol).

CephaXz

2012-06-25 12:34:15

You could + or - the x and y coordinate where you wanna click.

NKN

2012-06-25 12:52:56

if(FindSymbol(x,y,'mining')) then
mouse(x,(y + 50),3,3,1);

That should click below it.

Main

2012-06-25 13:04:20

but depends on the compass angle, +50 might be up or down depends on whether he is facing north or south.

Parade

2012-06-27 05:10:04

Well, I have gotten this function to work. It's just not exactly what I desired. I'm in living rock caverns, down by a gold deposit. Where I am having my script walk to, I need my character to be at an exact location to avoid being attacked. I just figured clicking south of the mining symbol would put me in the right position. And it would except for one small issue… The find symbol function decides to find the mining symbol north of me instead.


I did a search and saw that maybe the "FindSymbolIn" would call the closest mining symbol. Would this work? And how would I address the extra perimeters to define the symbol I want?

riwu

2012-06-27 05:49:42

yeah FindSymbolIn would work, specify the parameter to search from middle of mm perhaps? FindSymbolIn(x,y,'mine',MMX1,59,MMX2,MMY2) would make it only search the bottom half of the Mini-map.

J J

2012-06-27 09:51:34

You could make a TPA with the results of FindSymbol. Then check which Point has the highest Y which means it is the one to the south.

The problem with symbol clicking is that the symbols move slightly every time so yeah.. I would use something with the X coord of the symbol and then searching in a box around it for the black color then using the Y coord of the black color to make sure you are indeed far south.

Something like this
procedure Test;
var
i: Integer;
X, Y: Array of Integer;

begin
repeat
FindSymbol(X[i], Y[i], 'Mining');
Inc(i);
until not(FindSymbol(X[i], Y[i], 'Mining'));
i := High(Y)
MMouse(X[i], Y[i], RandomRange(-2, 2), RandomRange(-2, 2));
end;

Parade

2012-06-28 13:03:43

Thank you, guys.

Main

2012-06-28 13:09:55

my method should take you straight south regardless of your compass angle if you found the dungeon symbol:)