Results 1 to 15 of 15

Thread: How to walk at an angle? Regardless of color

  1. #1
    Join Date
    Jul 2007
    Location
    Massachusetts
    Posts
    896
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default How to walk at an angle? Regardless of color

    I am currently working on a secret(ish) project/function that I will hopefully release within the next week. Part of it requires walking in an angle.

    DO NOT WRITE ANYTHING FOR ME! I need my practice.

    I dk if there is a srl function that already does this or if I have to write my own.

    So far I have a it find the tpa of pts in the MM and then I use FilterPointsPie. I think from there Ill be able to pick a random one of these points and offset it a bit. If u guys have any other ideas please post them.

    I also would like some clarification on what Filterpointspie does. Does it make the other points blank, leaving the array the same size, or does it decrease the size of the array so that it only contains the points filtered (This would make it much easier). Also, do SD and ED need to be different? I want it to only search the inputted angle, so put SD and ED as the same angle.

  2. #2
    Join Date
    Nov 2007
    Posts
    437
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    So you want to input an angle and a radius and have it click there pretty much?

  3. #3
    Join Date
    Aug 2007
    Posts
    429
    Mentioned
    0 Post(s)
    Quoted
    2 Post(s)

    Default

    I made a function like this.
    Basically just how Dusk explained it, by inputing a compass angle you want to move at and a radius and it clicks there without moving the minimap.

    Is that what you're thinking of?

  4. #4
    Join Date
    Nov 2007
    Posts
    437
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    You can just use the angle and the radius along with sine and cosine and you can determine the x and y coordinates for that point. It is rather simple. 5-10 lines tops.

    Edit: I know you said you didn't want anyone writing it for you but I did it anyways! This is a function that converts an angle and a radius to a TPoint. It doesn't click or walk or anything so it isn't really the full function but you can use it if you want. If you do not want it, don't read it lol.

    SCAR Code:
    function AngleToPoint(Degrees, Radius : Integer) : TPoint;
    begin
      Result.x := Round((cos(Radians(Degrees))) * Radius);
      Result.y := Round((sin(Radians(Degrees))) * Radius);
    end;

  5. #5
    Join Date
    Jul 2007
    Location
    Massachusetts
    Posts
    896
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Can you please explain why that works. I like to understand

  6. #6
    Join Date
    Nov 2007
    Posts
    437
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Okay it would be a lot easier with a circle picture. One sec I will make a paint picture and explain it.



    Okay here we have a circle on our coordinate plane right. So I made it go 5 in every direction and the circle has a radius of 4 (It may not be exactly on 4, but, hey, it is Paint remember lol).



    Okay so this circle is like our minimap. To the right is 0 degrees, up is 90, left is 180, down is 270, and back to the right side again is 360. Okay so here it is crappily labeled in paint. Remember that a circle has 360 degrees total.



    Okay so we pick the point that we want to walk. We figure out its angle and its distance from the center. Let's say we pick the point labeled with a red dot on the circle. It's angle is 30 degrees. It's distance from the center, or radius, is 3.



    So we can draw a triangle by going from the center of the circle out to our point. That is the hypotenuse. Then we can draw a line from our point straight down, perpendicular with the x-axis, that is one leg of the triangle. Then we draw a line straight out from the center, along the x-axis, to connect to make our 2nd leg. Voila, triangle. Okay so now if we can solve for the two sides of the triangle we don't know, we would have the x and y values of that point.



    This is where we get into some basic trigonometry. Some basic equations in trig are these:
    sin (angle) = opposite side / hypotenuse
    cos (angle) = adjacent side / hypotenuse
    tan (angle) = opposite side / adjacent side
    sin, cos, and tan (sine, cosine, tangent) are trigonometry thingies that are on most calculators. So we know the angle and we know the hypotenuse which means that in the first two equations we only have a single variable which means we can solve for it. In this case, the adjacent side is the bottom leg and also our x value. The opposite side is the vertical leg and our y value. So pretty much we do the cos (angle) or sin (angle) and then multiply by the hypotenuse (aka the radius), and we have our x and y values. In the function I have, I also have Radian(angle) because the sin and cos functions built into SCAR take radians not degrees. I also have Round because we want whole number x and y values so we can use them as coordinates. Then I return it as a TPoint.

    If I didn't explain something well enough or forgot something let me know .

  7. #7
    Join Date
    Jul 2007
    Location
    Massachusetts
    Posts
    896
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Thanks for the tut. Rep++. I should have figured this out, I know trig and all, i guess i was too lazy lol. One flaw, you need to use the angle from the y axis (positive side). The point you used would be 60 degrees .

    You should post that as a tut

    Oh yeah, if and when u make it a tut, u might want to explain that radians are a unit of measurement equal to 180/pi degrees and is the measure of the angle formed by two radii when the the length of the arc between them is equal to the measure of a radii.

    (I used wikipedia )

  8. #8
    Join Date
    Nov 2007
    Posts
    437
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    yea i hoped you would know about radians cuz I didn't wanna explain it lol. And you should not use the angle from the y axis. trigonometry treats the right side of a circle as 0 degrees, not the top, so that is how I used it. At least I am pretty sure I am right lol. If not, please explain.

    Also, that as a tut would not really be that useful in SCAR. I mean I guess maybe to help with trigonometry homework but not for much else. You never usually need to convert an angle and a radius to a point lol.

  9. #9
    Join Date
    Jul 2007
    Location
    Massachusetts
    Posts
    896
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    I know how trig works, but in radial walk etc. North := 0

    The post is good for teaching trig because it gives an example of how it can be used to solve a right triangle.

  10. #10
    Join Date
    Nov 2007
    Posts
    437
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Oh well if you really wanted north to be zero you could just add a Angle = Angle - 90 or something. Yea.

  11. #11
    Join Date
    Jul 2007
    Location
    Massachusetts
    Posts
    896
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    u would need to switch x and y around to make it in reference to the positive y-axis. right?

    Also, does the scar sin and cos function already fix the problem of which section its in. Im not being very clear, but you know how in calculators, sin(185) is equal to sin(5). I dont want to have scar calculate the same point for these two angles because on is 5 degrees after east and one is 5 degrees after north. Does scar do this automaticly or do I have to fix this problem myself?

  12. #12
    Join Date
    Jul 2007
    Location
    Ottawa, Canada
    Posts
    930
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    yes, it is all skrewed up

    srl has it all backwards and stuff. so basically




    --- 0
    270---90
    ---180

    basically it is inverted on y = x or is that mirrored... hmmmm
    ~ Metagen

  13. #13
    Join Date
    Nov 2007
    Posts
    437
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    it should be fine. switch x and y and it should do it on y axis. sin and cos should be fine.

  14. #14
    Join Date
    Jul 2007
    Location
    Ottawa, Canada
    Posts
    930
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    DONT SWITCH X AND Y!!! dusk is a heretic -.-
    ~ Metagen

  15. #15
    Join Date
    Jul 2007
    Location
    Massachusetts
    Posts
    896
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    yes switch x and y, that way it uses the line counter clockwise to it as a reference.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 5
    Last Post: 07-31-2007, 07:23 PM
  2. procedure AWalk2(Angle, Radius, Color: Integer);
    By Starblaster100 in forum OSR Outdated Tutorials
    Replies: 15
    Last Post: 12-14-2006, 06:31 PM

Posting Permissions

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