1. ## [Func]TurnToMMPoint

Heya. So I had to make up something like this in one of my projects I've been working on lately. Just feed the function a point on the MM and it'll turn your camera to that point as well as return the degree of the point. It works really nicely for SPS as well.

Simba Code:
Procedure TurnToMMPoint(P: TPoint);  var    BaseRad: Extended;    FinalAn,RMod,CAng: Integer;  begin    CAng := (Round(rs_GetCompassAngleDegrees)-90);    if (CAng < 0) then      CAng := (360+CAng);    BaseRad := (ArcTan2((P.Y - MMCY),(P.X - MMCX)) + Radians(CAng));    FinalAn := Round(Degrees(fixRad(BaseRad-Pi)));    MakeCompass(FinalAn);  end;

You can see it uses similar math to SRL's 'rs_GetCompassAngleRadians'. Maybe some of you will find the use out of this for things like rotating to the nearest NPC/Object on the MM to get a better camera view for a higher chance of finding the MS object, ect...

For use with SPS just do something like this:
Simba Code:
TurnToMMPoint(SPS_PosToMM(Point(X, Y)));

Edit:
I'd also like to bring up to an SRL dev a updated 'rs_GetCompassAngleRadians'. This modified version is mathematically correct therefore more accurate: Already added to the include.
Simba Code:
Function rs_GetCompassAngleRadians: Extended;var  TPA: TPointArray;  T: TPoint;  B: TBox;begin  B := IntToBox(524, 5, 562, 43);  with B do    FindColorsSpiralTolerance(T.x, T.y, TPA, 65536, x1, y1, x2, y2, 0);  if Length(TPA) < 1 then   Exit;  T := MiddleTPA(TPA);  Result := ArcTan2(-(T.Y - 24), T.X - 543) + Radians(90);  Result := fixRad(Result - Pi);end;
Last edited by Flight; 09-04-2012 at 03:58 AM.

2. Suspended
Join Date
Jun 2012
Posts
2,183
Mentioned
0 Post(s)
Quoted
0 Post(s)
This looks incredibly useful. Nice work flight!

3. Ops. Apparently I didn't need to define the MMCX/Y as a point. Changed it.

4. Great work flight will most certainly improve quallity of many users functions

5. Ooh this looks like it would have great human-like use in a fighter script. Have the camera angle down a bit and rotate the compass toward the closest yellow dot. Then obviously click the monster. Good work Flight :3

6. Love it Flight, will definitely be used in MSI once I get back to it. I needed something to do just this, just never got a chance to put it together.

7. Very nice Flight, a much needed addition. Thanks.

8. Updated the OP to include a more accurate 'rs_GetCompassAngleRadians'. I hope a Dev reads this and makes the change.

9. Um, apologies for the double post but I thought I should bring up that the previous procedure didn't function correctly when the camera angle was between North and West.

I fixed this by also incorporating the MM compass angle in with the math formula to get a precise angle to for us to turn to. I tested this at N,NE,E,SE,S,SW,W,NW angles, all work perfectly.

So enjoy. Probably today I'll be playing around with this to see if I can correctly walk via SPS at any camera angle.

There are currently 1 users browsing this thread. (0 members and 1 guests)

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•