Results 1 to 4 of 4

Thread: waitForPixelShift issue (ongoing clicks)

  1. #1
    Join Date
    Jan 2016
    Posts
    77
    Mentioned
    0 Post(s)
    Quoted
    44 Post(s)

    Default waitForPixelShift issue (ongoing clicks)

    Hello,

    Im trying to create a woodcutting script and am having an issue where the mouse continually clicks on the trees. I think it may be an issue with waitForPixelShift function but Im not entirely sure.

    Here is the waitForPixelShift function Im using:

    Code:
    function waitForPixelShift(amount, timeOut: Integer; box: TBox): Boolean;
    var
      x1, y1, BMP, BMP2, tempShift: Integer;
      t: Timer;
    begin
      result := false;
      t.start();
      BMP := bitmapFromClient(box.x1, box.y1, box.x2, box.y2);
      repeat
        if (t.timeElapsed() >= timeOut) then
          break;
        sleep(250);
        BMP2 := bitmapFromClient(box.x1, box.y1, box.x2, box.y2);
        tempShift := calculatePixelShift(BMP, BMP2, IntToBox(0,0,(box.x2 - box.x1),(box.y2-box.y1)));
        if (calculatePixelShift(BMP, BMP2, IntToBox(0,0,(box.x2 - box.x1),(box.y2-box.y1))) >= amount) then
          result := true;
        freeBitmap(BMP2);
      until (Result);
      if (Result) then
        writeln(toStr(tempShift) + ' pixels (amount: ' + toStr(amount) + ') changed after: ' + toString(t.timeElapsed()) + '  result: true')
      else
        writeln('less than ' + toString(amount) + ' pixels changed after: ' + toStr(timeOut) + ' (timeout)    result: false');
      freeBitmap(BMP);
    end;
    And here is where I use it:

    Code:
    function getState(): Integer;
    begin
      if (getTimeRunning >= breakAfterTime) and (USEBREAKS) then
        exit(8);
      if (not isLoggedIn()) then
        exit(0);
      if ((getCurrentTab <> TAB_INV) and (not isBankOpen())) then
        exit(1);
      if (getInvCount() = 28) then
        exit(5);
      if ((not waitForPixelShift(10, 2500, intToBox(MIX1, MIY1, MIX2, MIY2)))) then
        exit(3);
      inc(bowsMade);
      exit(4);
    end;
    
    procedure executeState(State: Integer);
    begin
      case (State) of
        0: setupPlayer();
        1: gameTab(TAB_INV);
        3: cuttrees();
        4: antiban();
        5: droptrees();
        8: breakHandlerCustom();
      end;
      stats_Commit();
      progress();
      sleep(random(150, 200));
    end;
    I've tried using different wait times and number of pixels but it keeps returning a false value, and proceeds to click on the tree. Any suggestions?

  2. #2
    Join Date
    Jun 2013
    Location
    Scranton
    Posts
    496
    Mentioned
    5 Post(s)
    Quoted
    220 Post(s)

    Default

    Your inventory isn't shifting by at least 10 pixels within 2.5 seconds, so it will try to cut a tree again

  3. #3
    Join Date
    Jan 2016
    Posts
    77
    Mentioned
    0 Post(s)
    Quoted
    44 Post(s)

    Default

    Quote Originally Posted by jstemper View Post
    Your inventory isn't shifting by at least 10 pixels within 2.5 seconds, so it will try to cut a tree again
    Thank you, makes a lot more sense. I ended up using a box for the player to see if he is animating which works better. My question however is if a log appears in the inventory (as Im cutting) shouldnt that count as a pixel shift?

  4. #4
    Join Date
    Apr 2016
    Location
    New Zealand
    Posts
    76
    Mentioned
    0 Post(s)
    Quoted
    32 Post(s)

    Default

    Personally I would use the XP tracker (which Borland makes good use of), and everytime you get XP, recheck the tree/fishing spot/MM vein.

    Also can do a time out check, but the animation check probably would activate first anyways.

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
  •