Results 1 to 12 of 12

Thread: Calculating PixelShift in a circle

  1. #1
    Join Date
    Jun 2012
    Posts
    2,182
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default Calculating PixelShift in a circle

    Is there a function in SRL to calculate average pixelshift in a cirle, in this case the minimap? AveragePixelShift uses a Tbox, so I dont think that work work. Worst case scenario, I just make a box around the minimap, it just wont be as precise.
    ~Footy
    Thx Euphemism and Vinyl for the awesome siggy and avatar!

  2. #2
    Join Date
    Nov 2011
    Location
    England
    Posts
    3,072
    Mentioned
    296 Post(s)
    Quoted
    1094 Post(s)

    Default

    May i ask why you want to calc pixel shift of the minimap?

  3. #3
    Join Date
    Jun 2012
    Posts
    2,182
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Im using radialwalk to walk to a specific point, +/- 1 square, and if I click the next point while im still moving, it will be way off. Thought this would be a better way then using wait times.
    Thx Euphemism and Vinyl for the awesome siggy and avatar!

  4. #4
    Join Date
    Dec 2011
    Location
    The Netherlands
    Posts
    1,631
    Mentioned
    47 Post(s)
    Quoted
    254 Post(s)

    Default

    Can just use FFlag() and while the Flag is present, wait.

    Script source code available here: Github

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

    Default

    There is already a function IsMoving in SRL and it is actually based on the pixelshift of the minimap. If you want to make your own, take a look at how that goes about it, or alternatively just use IsMoving

  6. #6
    Join Date
    Jun 2012
    Posts
    2,182
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    @JJ, flag goes away ~ 800 ms before your character actually stops moving
    @P1ng Ill look into that, Thanks!
    Thx Euphemism and Vinyl for the awesome siggy and avatar!

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

    Default

    All IsMoving is is a box ~50x50 around the center of the MM.

    You could make a box around entire the mm and it would be just as accurate as only have the circular part- think about it. Pixelshift returns the amount of pixels that have changed. So any pixels that don't change have no impact on the result. Which is good in this case, because the pixels around the mm don't change color. So let's say there was a function to determine pixelshift within a circle, It would return the same result as the box function.

  8. #8
    Join Date
    Aug 2007
    Location
    Colorado
    Posts
    7,421
    Mentioned
    268 Post(s)
    Quoted
    1442 Post(s)

    Default

    Quote Originally Posted by Nebula View Post
    All IsMoving is is a box ~50x50 around the center of the MM.

    You could make a box around entire the mm and it would be just as accurate as only have the circular part- think about it. Pixelshift returns the amount of pixels that have changed. So any pixels that don't change have no impact on the result. Which is good in this case, because the pixels around the mm don't change color. So let's say there was a function to determine pixelshift within a circle, It would return the same result as the box function.
    That's right, but I believe there's a good reason why IsMoving doesn't read the full minimap. Should your player be walking in a dungeon or second/third story room them only a small part of the MM will change pixels, right? The majority of the MM will be black and will never change, so the pixelshift count would be much lower than normal, that's why the current IsMoving only searches a small area surrounding the center.

    If I may, I recommend using my own IsMoving function; it seems to be much faster for detecting player walking/running:
    Simba Code:
    Function IsMoving_F: Boolean;
      begin
        Result := PixelShift(IntToBox(MMCX-30, MMCY-30, MMCX+30, MMCY+30), 200) > 200;
      end;

    Current projects:
    [ AeroGuardians (GotR minigame), Motherlode Miner, Blast furnace ]

    "I won't fall in your gravity. Open your eyes,
    you're the Earth and I'm the sky..."


  9. #9
    Join Date
    Jun 2007
    Posts
    532
    Mentioned
    1 Post(s)
    Quoted
    68 Post(s)

    Default

    Quote Originally Posted by Footy View Post
    @JJ, flag goes away ~ 800 ms before your character actually stops moving
    @P1ng Ill look into that, Thanks!

    You can change that mate
    Finished B.S. Program in Radiology!!

    Projects: A big one! Total secret! hehe

  10. #10
    Join Date
    Jun 2012
    Posts
    2,182
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Thanks for all the help guys! Im using ismoving, and it appears to work perfectly. Should I ever run into any problems, ill give Flights function a go.
    Thx Euphemism and Vinyl for the awesome siggy and avatar!

  11. #11
    Join Date
    Sep 2008
    Location
    Not here.
    Posts
    5,422
    Mentioned
    13 Post(s)
    Quoted
    242 Post(s)

    Default

    I'm late, but here's your function.
    Simba Code:
    function PixelShiftCircle(CenterX, CenterY, Radius, T: Integer): Integer;
    var
      BMP, BMP2: Integer;
      CIRCLETPA: TPointArray;
      B: TBox;
    begin
      CIRCLETPA := TPAFromCircle(CenterX, CenterY, Radius);
      FillEllipse(CIRCLETPA);
      B := GetTPABounds(CIRCLETPA);
      OffsetTPA(CIRCLETPA, Point(-CenterX + Radius, -CenterY + Radius));
      BMP := BitmapFromClient(B.x1,B.y1,B.x2,B.y2);
      Wait(T);
      BMP2 := BitmapFromClient(B.x1,B.y1,B.x2,B.y2);
      Result := CalculatePixelShiftTPA(BMP, BMP2, CIRCLETPA);

      FreeBitmap(BMP);
      FreeBitmap(BMP2);
    end;

  12. #12
    Join Date
    Jun 2012
    Posts
    2,182
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Thanks! It looks really good! Everyone above just said there's no point in it, but I might find a use for this!
    Thx Euphemism and Vinyl for the awesome siggy and avatar!

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
  •