Results 1 to 8 of 8

Thread: PixelShift

  1. #1
    Join Date
    Dec 2011
    Location
    Toronto, Ontario
    Posts
    6,424
    Mentioned
    84 Post(s)
    Quoted
    863 Post(s)

    Default PixelShift

    How exactly does it work?
    I'm trying to get it to be used for Mining, I took a look inside the SRL include in animation but I couldn't glean any information :s

  2. #2
    Join Date
    Dec 2011
    Posts
    353
    Mentioned
    3 Post(s)
    Quoted
    8 Post(s)

    Default

    Quote Originally Posted by Flight View Post
    I'll give you a crash course on pixelshift, just not using those two functions. First of all, pixelshift, I believe, will count the amount of changing pixels within a certain box region over a certain amount of time. So let's say you wanted to check if your player is doing an animation, so let's use this function: (my own "Is Mining" function)
    Simba Code:
    Function Mining: Boolean;
      var
        PBox: TBox;
      begin
        PBox := IntToBox(245, 130, 285, 195);
        Result := (AveragePixelShift(PBox, 250, 500) > 400);
      end;

    In this function you can see it uses 'AveragePixelShift' with the parameters (Box, waitPerLoop, maxTime) and returns a boolean (True of False). "Box" is the box region the function will record your pixelshift (change in pixels). "waitPerLoop" I'm not 100% sure, but 250 seems to be just right. "maxTime" is the length of each loop it checks for pixelshift.

    Since we're checking for player animation it would only make sense to have the 'Box' we record pixelshift be a box around our player, right? So let's use this box: (245, 130, 285, 195), it's directly around our player. So we have our box region, we have the 'waitPerLoop' (I just leave it 250), and you see I, be default, have 500 as the 'maxTime', which means each length of recording pixelshift will be 500 milliseconds (half a second).

    The function 'AveragePixelShift' will return an integer, which will be our average amount of pixelshift within that box in 500 milliseconds. In the function I provided it will check if that number is over 400, in which case the function would return True that our player is using the Mining animation. Should that number be under 400 then it'll return false because chances are we're just standing idle, right?

    Anyways, I hope that helps. I didn't mean to make it into a tutorial. Here's a test script I use to constantly print out the player's pixelshift. You can use it to determine what's a good number to use to detect if you're doing a certain animation:
    Simba Code:
    program PrintMyPixels;
      {$DEFINE SRL5}
      {$DEFINE SMART}

      {$i SRL/srl.simba}

      Procedure DebugShiftCount;
      var
        PBox: TBox;
      begin
        PBox := IntToBox(245, 130, 285, 195);
        Writeln(IntToStr(AveragePixelShift(PBox, 250, 500)));
      end;


    begin
      Smart_Server := 86;
      Smart_Members := True;
      Smart_Signed := True;
      Smart_SuperDetail := False;
      setupSRL();

      Repeat
        DebugShiftCount;
      Until(False);
    end.

    Good luck!
    Thanks to flight

  3. #3
    Join Date
    Dec 2011
    Location
    Toronto, Ontario
    Posts
    6,424
    Mentioned
    84 Post(s)
    Quoted
    863 Post(s)

    Default

    Pro'd.
    Thanks Nex and Flight.

  4. #4
    Join Date
    Sep 2007
    Location
    Michigan
    Posts
    3,862
    Mentioned
    2 Post(s)
    Quoted
    1 Post(s)

    Default

    He should throw that into a small tut or something.
    (Scripts outdated until I update for new SRL changes)
    AK Smelter & Crafter [SRL-Stats] - Fast Fighter [TUT] [SRL-Stats]
    If you PM me with a stupid question or one listed in FAQ I will NOT respond. -Narcle
    Summer = me busy, won't be around much.

  5. #5
    Join Date
    Dec 2011
    Location
    Toronto, Ontario
    Posts
    6,424
    Mentioned
    84 Post(s)
    Quoted
    863 Post(s)

    Default

    Did GGZZ delete his post? o.O

  6. #6
    Join Date
    Feb 2011
    Location
    The Future.
    Posts
    5,600
    Mentioned
    396 Post(s)
    Quoted
    1598 Post(s)

    Default

    Quote Originally Posted by S1N View Post
    Did GGZZ delete his post? o.O
    What? I never posted on this thread :S
    I am Ggzz..
    Hackintosher

  7. #7
    Join Date
    Sep 2007
    Location
    Michigan
    Posts
    3,862
    Mentioned
    2 Post(s)
    Quoted
    1 Post(s)

    Default

    Geo posted.
    (Scripts outdated until I update for new SRL changes)
    AK Smelter & Crafter [SRL-Stats] - Fast Fighter [TUT] [SRL-Stats]
    If you PM me with a stupid question or one listed in FAQ I will NOT respond. -Narcle
    Summer = me busy, won't be around much.

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

    Default

    Quote Originally Posted by S1N View Post
    Did GGZZ delete his post? o.O
    Quote Originally Posted by ggzz View Post
    What? I never posted on this thread :S
    This made me laugh. Poor ggzz, gets blamed for everything!

    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..."


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
  •