Results 1 to 8 of 8

Thread: Facing Direction

  1. #1
    Join Date
    Jun 2012
    Posts
    219
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default Facing Direction

    Is there anyway to determine in which direction you character is facing when performing a task or when coming to a stop?

    Lets say there are 4 trees, I`m standing in the middle of them. I choose the one on the west to chop down but I was facing north, now My character is facing the tree to the west as that was the one I have chosen, I don`t want to find the direction by the object I have chosen, but rather by the way I`m currently facing.

    Is there any way in which to do just that?

  2. #2
    Join Date
    Jan 2012
    Posts
    2,568
    Mentioned
    35 Post(s)
    Quoted
    356 Post(s)

    Default

    rs_GetCompassAngleRadians?

  3. #3
    Join Date
    Jun 2012
    Posts
    219
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    Quote Originally Posted by riwu View Post
    rs_GetCompassAngleRadians?
    That Only works if your compass heading change, but if you are facing in a direction it does not give you a compass heading except the heading that the compass originally had to start with.

    If you are standing still and face a new direction the compass does not change direction with you.
    Last edited by VastlySuperior; 09-21-2012 at 10:04 AM.

  4. #4
    Join Date
    Jan 2012
    Posts
    2,568
    Mentioned
    35 Post(s)
    Quoted
    356 Post(s)

    Default

    Oh so you mean the direction your character is facing? You could possibly consider the differences in color pixels (hair, armor etc) when it is facing in different directions.

    But that's not going to be reliable when you wear different armors.

  5. #5
    Join Date
    Oct 2006
    Location
    Netherlands
    Posts
    3,285
    Mentioned
    105 Post(s)
    Quoted
    494 Post(s)

    Default

    The spot where you click to perform the task can be translated into a angle if you know the height of the object.
    Working on: Tithe Farmer

  6. #6
    Join Date
    Jun 2012
    Posts
    219
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    Quote Originally Posted by masterBB View Post
    The spot where you click to perform the task can be translated into a angle if you know the height of the object.
    How do you find the height masterBB?

  7. #7
    Join Date
    Jan 2008
    Location
    C:\
    Posts
    1,483
    Mentioned
    2 Post(s)
    Quoted
    2 Post(s)

    Default

    I think Bart's referring to the z value of the camera. If you have your camera at the highest angle, it shouldn't matter much though. You can use a vector like this:

    Simba Code:
    type
      TRadial = record
        Length: Integer;
        Angle: Extended;
      end;

    function RadialFromPts(P1, P2: TPoint): TRadial;
    begin
      Result.Length := Round(Hypot(P2.x - P1.x, P2.y - P1.y));
      Result.Angle := Degrees(FixRad((ArcTan2(P1.y - P2.y, P1.x - P2.x) + Radians(90)) - Pi));
    end;

    // Somewhere in your tree chopping proc:

      //...
      FindTree(x, y);
      MMouse(x, y, 3, 3);
      if WaitUptext('Chop', 500) then
      begin
        r := RadialFromPts(Point(MSCX, MSCY), Point(x, y));
        Dir := Round(r.Angle);
        ClickMouse2(mouse_left);
        //Result := True;
        //Break;
      end;
      //...

    the var Dir should then give you a good approximation of what direction your character is facing.

  8. #8
    Join Date
    Jun 2012
    Posts
    219
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    Thanks for the info, I will test it out over the weekend.

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
  •