Results 1 to 9 of 9

Thread: [Func]TurnToMMPoint

  1. #1
    Join Date
    Aug 2007
    Location
    Colorado
    Posts
    7,421
    Mentioned
    268 Post(s)
    Quoted
    1442 Post(s)

    Default [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.

    Current projects:
    [ AeroGuardians (GotR minigame), Motherlode Miner, Blast furnace ]

    "I won't fall in your gravity. Open your eyes,
    you're the Earth and I'm the sky..."


  2. #2
    Join Date
    Jun 2012
    Posts
    2,182
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    This looks incredibly useful. Nice work flight!
    Thx Euphemism and Vinyl for the awesome siggy and avatar!

  3. #3
    Join Date
    Aug 2007
    Location
    Colorado
    Posts
    7,421
    Mentioned
    268 Post(s)
    Quoted
    1442 Post(s)

    Default

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

    Current projects:
    [ AeroGuardians (GotR minigame), Motherlode Miner, Blast furnace ]

    "I won't fall in your gravity. Open your eyes,
    you're the Earth and I'm the sky..."


  4. #4
    Join Date
    May 2007
    Location
    England/Liverpool
    Posts
    1,004
    Mentioned
    9 Post(s)
    Quoted
    106 Post(s)

    Default

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

  5. #5
    Join Date
    Dec 2011
    Location
    New York, USA
    Posts
    1,242
    Mentioned
    12 Post(s)
    Quoted
    193 Post(s)

    Default

    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. #6
    Join Date
    Oct 2007
    Location
    #srl
    Posts
    6,102
    Mentioned
    39 Post(s)
    Quoted
    62 Post(s)

    Default

    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. #7
    Join Date
    Aug 2007
    Location
    England
    Posts
    1,038
    Mentioned
    0 Post(s)
    Quoted
    6 Post(s)

    Default

    Very nice Flight, a much needed addition. Thanks.
    Today is the first day of the rest of your life

  8. #8
    Join Date
    Aug 2007
    Location
    Colorado
    Posts
    7,421
    Mentioned
    268 Post(s)
    Quoted
    1442 Post(s)

    Default

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

    Current projects:
    [ AeroGuardians (GotR minigame), Motherlode Miner, Blast furnace ]

    "I won't fall in your gravity. Open your eyes,
    you're the Earth and I'm the sky..."


  9. #9
    Join Date
    Aug 2007
    Location
    Colorado
    Posts
    7,421
    Mentioned
    268 Post(s)
    Quoted
    1442 Post(s)

    Default

    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.

    Current projects:
    [ AeroGuardians (GotR minigame), Motherlode Miner, Blast furnace ]

    "I won't fall in your gravity. Open your eyes,
    you're the Earth and I'm the sky..."


Thread Information

Users Browsing this Thread

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
  •