SRL Archive - Help and Support

I need help with something complicated


Sir Ducksworthy

2012-05-16 04:19:35

I'm not the best at math and I'm trying to calculate the Vertical and Horizontal Distance you need to Mmouse vs the Line Angle between 2 Npc dot's
I've got this far.. lolz

Update Here's a preview of it in action I just need it at any angle n it'd be soo Leet:
[YOUTUBE]otpPhpnj5ls[/YOUTUBE]
The times before and after the clicking the script is not on, as soon as I run the function it will instantly click, so yeh it's pretty Fast I reckon lol.

So far it can Calculate Distance between 2 Npc's dot accurately and then find the Angle in Radians which is then converted into Degrees Using the Pi of the Mini Map

Function FindLocationFromNpcs():Boolean;
var
Pointz,tempTPA:tpointarray;
StoreDistance,q, i, J,yy1,yy2,xx1,xx2:integer;
RadianAngle, VerticalDistance, HorizontalDistance:extended;
msPoint:Tpoint;
ATPA: Array of TPointArray;
begin
{Instead of using an SPS Point why not try using the Static NPC DOT Coords detected in an Algorithm to detect exact location to walk and use the bank booth?
X2-X1=Vertical Distance, Y2-Y1=Horizontal Distance
if(Point[i].x>Point[i+1].x) and (Point[i].y>Point[i+1].y)then
writeln('Point-'+ inttostr(i+1) + ' is somewhere in the Radians Between West and North of Point-' + inttostr(i));

Using Calculations like this we can ^ Compare Each Point in the TPA to Each Other via Distance or/and by Direction
which means we can then work out other locations on the MM pricisely no matter the Map based on the Angles between them
even if someone is standing on them n it shows as a white point we could predict that it was actually a npc underneath the white dot by comparing distance of the white dot to our previous
Calculations.

I just need to work out how to calculate the Bank Chest line angle from the Npc's line angle.
9 Differencee Verticlly 24 Difference Horizontally
5 distane horiz 7 vertically
}

FindColorsSpiralTolerance(x, y, tempTPA, 456703, MMX1, MMY1, MMX2, MMY2, 15);
J := High(tempTPA);
if(J < 2) then
Exit;

MiddleTPA(tempTPA);
SortTPAFrom(tempTPA, Point(MMCX, MMCY));
DebugTPA(tempTPA, '');
for I := 0 to High(tempTPA) do
begin
q:=i+1;
xx1:=tempTPA[i].x;
xx2:=tempTPA[q].x;
yy1:=tempTPA[i].y;
yy2:=tempTPA[q].y;

VerticalDistance:=yy2-yy1
HorizontalDistance:=xx2-xx1

RadianAngle:=ArcTan2(VerticalDistance, HorizontalDistance);
writeln('Angle Distance Line Degrees Between Points = ' + FloattoStr(Degrees((RadianAngle - (2 * 0.5)))));

if(yy2>yy1)then
VerticalDistance:=yy2-yy1
else
VerticalDistance:=yy1-yy2;

if(xx2>xx1)then
HorizontalDistance:=xx2-xx1
else
HorizontalDistance:=xx1-xx2;

if(InRange(Distance(xx1, yy1, xx2, yy2), 24, 28))then
begin
writeln('Found 2 MM icons in range of distance specified');
Pointz:=[Point(xx1,yy1), Point(xx2,yy2)];
DebugTPA(Pointz, '');
//Distance from Point near bank = ? + Move mouse right Degrees from Angle?
Terminatescript;
// msPoint := MMtoMS(tempTPA[I]);

{ MMouse(msPoint.x, msPoint.y, 0, 0);
if(WaitUpTextMulti(UpText, 500)) then
begin
Result := True;
Exit;
end; }
end;
end;
end;

Sir Ducksworthy

2012-05-17 06:21:53

Check out the video lol

Runaway

2012-05-17 11:20:39

I've done this with coordinates, but the whole angle thing throws me off too :P

Perhaps you could just click a point a certain distance away from the center of the two NPCs found? I think that's what I used when positioning myself with NPCs…

E: Sorry to be so useless for your main intention :p

Sir Ducksworthy

2012-05-17 11:35:21

Hmm yeah it's a bit mind boggling hey
I've been pondering over it tho and I think it could be just as simple as Finding the Angle from the Middle of the Npc's Angle Line the only thing I'm not sure how to do is move my Mouse a distance using an angle.

bg5

2012-05-17 14:15:04

If you don't know how , just draw it :redface:.

…I almost resolved equation ,when noticed ,that already all needed functions are in TPA.pas…:(

Check this:

function FindRotated(O : TPoint ;dax ,day :integer) : TPoint;  // dax,day - offset from middle of NPC line ( 'O' on picture)at RS_compass = 'N'
var
x ,ca ,ra: extended;
begin
x := ArcTan2(dax,day);
ca := rs_GetCompassAngleRadians;
Result := RotatePoint( Point(o+dax,o+day),(180-x)+ca, o.x ,o.y);
end;

Sir Ducksworthy

2012-05-17 15:48:43

Omg seriously Face Palm, Rep++ man your awesome

Edit:
Atm I've still got no idea how to find the Middle

Wait that wasn't to hard actually w00t

So isn't the Target always going to be the same offset from that middle point no matter the compass direction?
Edit:
Nope the Angle needs to be rotated counter clock wise the degrees required to come in perfect lining to the target
Ahh your functions perfect then man :)