Results 1 to 7 of 7

Thread: [OGL] Walking v2

  1. #1
    Join Date
    Aug 2012
    Posts
    188
    Mentioned
    9 Post(s)
    Quoted
    71 Post(s)

    Default [OGL] Walking v2

    Over my vacation I took @Ross; walking procedure https://villavu.com/forum/showthread.php?t=113404 and looked at it some more. My problem with it was that when walking to places the randomness would compound and I would end up further off track than I wanted. However without it I would click the same spots every time. I had a go at it and came up with a new approach. So here goes:
    Simba Code:
    procedure tileWalkInterval(point : TPoint; r : Integer);
    var
      stepSize, rx, ry, toGoX, toGoY : Integer;
      next : TPoint;
    begin
      stepSize := r + 7;
      toGoX := point.X;
      toGoY := point.Y;

      repeat
        rx := random(-r, r);
        ry := random(-r, r);
        next := [sgn(toGoX) * (min(abs(toGoX), stepSize)) + rx, sgn(toGoY) * (min(abs(toGoY), stepSize)) + ry];

        walkTo(next);
        waitFlag();

        toGoX := toGoX - next.X;
        toGoY := toGoY - next.Y;

      until (abs(toGoX) <= r) and (abs(toGoY) <= r);
    end;
    This procedure is designed to walk a set of points or a long distance. It utilizes random numbers to walk different intervals and randomness for each point on the way. The way it works is it takes the point it is walking to and stores it in toGoX and toGoY. As it loops it subtracts what it has walked from toGoX and toGoY and repeats until it reaches its destination. If you plug in 0 for r it will be 100% accurate.

    And the sgn function simply returns the sign of a number:
    Simba Code:
    function sgn(x : Integer) : Integer;
    begin
      if x = 0 then
        exit(0)
      else
        if x > 0 then
          exit(1)
      else
        exit(-1);
    end;

    And here is the walkTo procedure I use:
    Simba Code:
    procedure walkTo(point : TPoint);
    begin
      mouse.click(minimap.getScreenPosition(minimap.getLocalPosition().adjustPosition(point.X, point.Y)), 1);
    end;

    Here is the waitFlag procedure @Ross; wrote that goes with this:
    Simba Code:
    procedure waitFlag;
    begin
      wait(250);
      while (not ogl.getTextures(1275).isEmpty()) do
        wait(500);
    end;

    And finally here is the tileWalk procedure that I modified. This is what you call in your program.
    Simba Code:
    procedure tileWalk(r : Integer; points : TPointArray);
    var
      i : Integer;
      next : TPoint;
    begin
      for i := 0 to high(points) do
      begin
        next := points[i];
        tileWalkInterval(next, r);
      end;
    end;

    As an example you would use this by calling the tileWalk procedure with your randomness and the array of Points (or point) to walk.
    Simba Code:
    tileWalk(2, [[-3, -10], [-11, -10], [-25, -7], [-8, -16], [12, -12]]);
    or you could do
    Simba Code:
    tileWalk(5, [[100, 94]]);

    I spent quite a bit of time brainstorming and optimizing the code for this so please let me know what you think about it and if there are any areas I can improve! Thanks again to @Ross; for the original code and @Clarity; for answering a couple questions.
    (Here is my first go at writing the new procedure photo_1436396825935.jpg)

  2. #2
    Join Date
    Apr 2015
    Location
    FireFox
    Posts
    528
    Mentioned
    10 Post(s)
    Quoted
    227 Post(s)

    Default

    Really great work man!
    Scripting with ogLib

  3. #3
    Join Date
    Aug 2014
    Location
    Australia
    Posts
    932
    Mentioned
    53 Post(s)
    Quoted
    495 Post(s)

    Default

    Great work mate, and an excellent contribution!

    EDIT: I'd recommend turning tileWalk into a boolean function that returns false if it fails for some reason.
    Last edited by Incurable; 07-17-2015 at 02:37 AM.



    New to scripting? Procedures & Functions for Beginners
    Do you use your computer at night? Just get f.lux

  4. #4
    Join Date
    Aug 2012
    Posts
    188
    Mentioned
    9 Post(s)
    Quoted
    71 Post(s)

    Default

    Quote Originally Posted by Incurable View Post
    I'd recommend turning tileWalk into a boolean function that returns false if it fails for some reason.
    I thought about it but there's not really any way I can think of that it would fail, unless the user accidentally put in [600000, 9345345] or something and it never stopped?

  5. #5
    Join Date
    Nov 2014
    Location
    Australia
    Posts
    188
    Mentioned
    2 Post(s)
    Quoted
    97 Post(s)

    Default

    Meh. This is the problem with ogl. My vps does not support it, and I get fps lag on my home machine. Great contribution though, I'm sure this will come in handy sometime.
    Why join the navy if you can be a pirate? -Steve Jobs

  6. #6
    Join Date
    Aug 2012
    Posts
    188
    Mentioned
    9 Post(s)
    Quoted
    71 Post(s)

    Default

    Quote Originally Posted by jonesy259 View Post
    Meh. This is the problem with ogl. My vps does not support it, and I get fps lag on my home machine. Great contribution though, I'm sure this will come in handy sometime.
    Yes there are problems with ogl, but hopefully it will be supported better in Windows 10 (I have no idea, praying), apparently it runs much smoother in Linux, or with better GPUs. Either way OGL is fun

  7. #7
    Join Date
    Aug 2014
    Location
    Australia
    Posts
    932
    Mentioned
    53 Post(s)
    Quoted
    495 Post(s)

    Default

    Quote Originally Posted by Swag Bag View Post
    unless the user accidentally put in [600000, 9345345] or something and it never stopped?
    Which would be user error, but a fail situation nonetheless. I mainly posted that to remind you about failsafes, it's not necessarily needed when using ogLib, but it's good scripting practice and they should still be implemented wherever possible.



    New to scripting? Procedures & Functions for Beginners
    Do you use your computer at night? Just get f.lux

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
  •