Results 1 to 20 of 20

Thread: TPoint range

  1. #1
    Join Date
    Mar 2012
    Location
    Color :D
    Posts
    938
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default TPoint range

    IDK what title to put, sorry if that confuse you

    Let's say my function returns a TPoint: Point(100, 200).

    Is there any math or whatever function that can make a radius of the TPoint? For example, If I want to only fight or walk or do any skill in a range of 10 tiles away from the TPoint, I want to have a radius of 10 of the TPoint.

    Tell me if you couldn't understand. I just don't know how to explain my question lol

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

    Default

    MouseCircle?

  3. #3
    Join Date
    Mar 2012
    Location
    Color :D
    Posts
    938
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    The TPoint is the position of SPS. How does MouseCircle works on this?

    EDIT: In fact, I did look up on functions like MouseCircle, MouseOval, Smart_DrawCircle/Ellipse. But I just need more explanation and understanding towards this.

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

    Default

    Don't quite understand what you're asking...

    MouseCircle(MidX, MidY, Radius, clickType: Integer);

    Example:

    MouseCircle(100, 100, 5, 1); would click anywhere 5 pixels around the point (100, 100)

  5. #5
    Join Date
    Mar 2012
    Location
    Color :D
    Posts
    938
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    SPS_GetMyPos returns a Tpoint, which is my current position. And from that Tpoint, I want to create a radius of X around it, so that I will always be in X tiles away from the TPoint. If I am outside the range, I will walk back inside again.

    I didn't want to click on anything. Just wanted to have a radius around a TPoint.

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

    Default

    Oh

    Just use Distance(xs, ys, xe, ye: Integer);

    If Distance(xCoordOfPointYouWantToStayNear, yCoordOfPointYouWantToStayNear, SPS_GetMyPos.x, SPS_GetMyPos.y) > Radius then
    Blah;

    Edit: Forgot that you can't use SPS_GetMyPos.x/.y

    You'd have to do this:
    Simba Code:
    Var
      CurrentSPSPos: TPoint;
    begin
      CurrentSPSPos := SPS_GetMyPos;
      If Distance(xCoordOfPointYouWantToStayNear, yCoordOfPointYouWantToStayNear, CurrentSPSPos.x, CurrentSPSPos.y) > Radius then
        SPS_WalkToPos(Point(xCoordOfPointYouWantToStayNear, yCoordOfPointYouWantToStayNear));
    end;
    Last edited by Nebula; 06-24-2012 at 04:03 AM.

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

    Default

    I'm not on my computer so I can't check if this function actually exists, but you could try PointInCircle or PointInBox to do what Nebula said. (Literally exactly what his does, just figured I'd add that in )

  8. #8
    Join Date
    Mar 2012
    Location
    Color :D
    Posts
    938
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Thanks! I always see people use Distance in their script, but didn't quite understand how Distance function actually works. I'll try playing with it.


    Quote Originally Posted by Runaway View Post
    I'm not on my computer so I can't check if this function actually exists, but you could try PointInCircle or PointInBox to do what Nebula said. (Literally exactly what his does, just figured I'd add that in )
    I only found PointInBox. Box does not always make sure you're in X tile away from the TPoint, or I just don't know how to do the math. Thanks
    Last edited by CephaXz; 06-24-2012 at 04:13 AM.

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

    Default

    Well, since I have nothing better to do, I'll explain what it does. Or at least what I think it does, since Simba doesn't allow you to look at the code behind it.

    (again this is all a hypothesis..)

    It most likely takes two points, and uses the Pythagorean theorem to return the distance between the two points.

    this can be simplified to the distance formula, which you have probably seen before in a math class.


    Basically, result := the formula above, with x1 y1 x2 y2 being xs ys xe ye.

  10. #10
    Join Date
    Dec 2006
    Location
    Sydney, New South Wales, Australia
    Posts
    4,603
    Mentioned
    15 Post(s)
    Quoted
    42 Post(s)

    Default

    Quote Originally Posted by Nebula View Post
    since Simba doesn't allow you to look at the code behind it.
    What? :S

    And you are correct on your definition. In fact, that's all it does: Sqrt( Pow() ..., etc).
    You may contact me with any concerns you have.
    Are you a victim of harassment? Please notify me or any other staff member.

    | SRL Community Rules | SRL Live Help & Chat | Setting up Simba | F.A.Q's |

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

    Default

    Quote Originally Posted by Daniel View Post
    What? :S

    And you are correct on your definition. In fact, that's all it does: Sqrt( Pow() ..., etc).
    when you double click on it in the function list, it doesn't show the source like it does for most things..

  12. #12
    Join Date
    Mar 2012
    Location
    Color :D
    Posts
    938
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    I think I just started to know how to calculate it. Already forgot those maths when I left school. I'm studying something that doesn't use those complicated symbols/equations

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

    Default

    Quote Originally Posted by CephaXz View Post
    I think I just started to know how to calculate it. Already forgot those maths when I left school. I'm studying something that doesn't use those complicated symbols/equations
    You don't need to know the math behind it.. just do what I said and it should work fine.

  14. #14
    Join Date
    Mar 2012
    Location
    Color :D
    Posts
    938
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    I wouldn't continue until I totally understand something I wanted to know

    Your explanation at the 6th post kind of confused me, but I understood now. I'll just do GetMyPos at the start. Then GetMyPos again when checking position, so that it can compare the 2 points. I was wondering what CoordOfPointYouWantToStayNear will be, since there are so many points lol.

  15. #15
    Join Date
    Apr 2012
    Location
    Australia
    Posts
    1,252
    Mentioned
    1 Post(s)
    Quoted
    22 Post(s)

    Default

    Is what you are trying to fight or walk to on the mainscreen? Couldn't you just determine the co-ords of FindDTM or FindColor or whatever function you're using to find them with MSCX-10,MSCY-10,MSCX+10,MSCY+10 as your area to search in because the middle of your player will always be the middle of the mainscreen?

    Obviously need a larger area than 20x20 pixels because that wouldn't even reach the bouds outside your character, but you get the idea?

    If you want to see the box use paintsmart include and SMART_DrawBox

  16. #16
    Join Date
    Dec 2006
    Location
    Sydney, New South Wales, Australia
    Posts
    4,603
    Mentioned
    15 Post(s)
    Quoted
    42 Post(s)

    Default

    Quote Originally Posted by CephaXz View Post
    I wouldn't continue until I totally understand something I wanted to know

    Your explanation at the 6th post kind of confused me, but I understood now. I'll just do GetMyPos at the start. Then GetMyPos again when checking position, so that it can compare the 2 points. I was wondering what CoordOfPointYouWantToStayNear will be, since there are so many points lol.
    Distance get's the distance between two points (given by [x1,y1] and [x2,y2]).

    See Wikipedia for more details.
    You may contact me with any concerns you have.
    Are you a victim of harassment? Please notify me or any other staff member.

    | SRL Community Rules | SRL Live Help & Chat | Setting up Simba | F.A.Q's |

  17. #17
    Join Date
    Mar 2012
    Location
    Color :D
    Posts
    938
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by p1ng View Post
    Is what you are trying to fight or walk to on the mainscreen? Couldn't you just determine the co-ords of FindDTM or FindColor or whatever function you're using to find them with MSCX-10,MSCY-10,MSCX+10,MSCY+10 as your area to search in because the middle of your player will always be the middle of the mainscreen?

    Obviously need a larger area than 20x20 pixels because that wouldn't even reach the bouds outside your character, but you get the idea?

    If you want to see the box use paintsmart include and SMART_DrawBox
    I think you didn't understand my question
    I'm not trying to find the coords of the obj or npc, I'm getting the coords of my current position at the start of the script. If you ever used AutoFighterPro or Perfecticus Fighter of nexus client, you can set the tiles away from your position at the start of the script, which is the area you want to fight. So that when you're fighting, you don't get lost. This applies to WC bots as well. A powerchopper will always chop whatever trees it sees on the mainscreen, if no area is set, you will start from draynor and end up at lumbridge. That is where the function comes in handy.

    A box that is made out of a point, the distance/length between the outlines of the box and the center point will not always be fixed. But a circle always has a same distance/length from the center to the outline.

    Hope that make things clear about what I wanted.


    Quote Originally Posted by Daniel View Post
    Distance get's the distance between two points (given by [x1,y1] and [x2,y2]).

    See Wikipedia for more details.
    Thanks

  18. #18
    Join Date
    Jan 2007
    Posts
    8,876
    Mentioned
    123 Post(s)
    Quoted
    327 Post(s)

    Default

    Quote Originally Posted by Nebula View Post
    You don't need to know the math behind it.. just do what I said and it should work fine.
    Just use Distance(x1, y1, x2, y2) instead of doing sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1))? much easier that way.

    Also; https://github.com/MerlijnWajer/Simba ?

  19. #19
    Join Date
    Apr 2012
    Location
    Australia
    Posts
    1,252
    Mentioned
    1 Post(s)
    Quoted
    22 Post(s)

    Default

    You could try making a DTM positioning system and then if you are a certain distance away from the x,y co-ordinate make it walk back to there?

    Have a look at J J's barbarian basic dev blog for his function that he is using, it looks really cool and i plan on implementing it into my next script

  20. #20
    Join Date
    Mar 2012
    Location
    Color :D
    Posts
    938
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    I plan not to rely on dtm for anything, whether it is item or object or position finding. I find dtm use up a lot of resources in the long run. But I will try to look at it. Thanks

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
  •