Page 1 of 2 12 LastLast
Results 1 to 25 of 38

Thread: [TuT]Using Pixelshift for animation

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

    Default [TuT]Using Pixelshift for animation

    I actually quickly wrote this out for one person, briefly explaining how you can use SRL's Pixelshift to detect animation; in this case our own player's animation.
    Originally posted here: http://villavu.com/forum/showthread.php?t=72792

    Animation detection through Pixelshift
    By Flight

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

    ~Cheerz

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


  2. #2
    Join Date
    Jul 2008
    Posts
    136
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    thanks

  3. #3
    Join Date
    Feb 2011
    Location
    Wisconsin
    Posts
    398
    Mentioned
    1 Post(s)
    Quoted
    10 Post(s)

    Default

    Thanks Flight! ^^

  4. #4
    Join Date
    Nov 2011
    Location
    Jozi, South Africa
    Posts
    249
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Smile

    Quote Originally Posted by Flight View Post
    "waitPerLoop" I'm not 100% sure, but 250 seems to be just right.
    For those of us (that would be me and any others that would like to join me) that still battle to take in the finer details of the animation includes, why don't we just ask Coh3n and/or marpis to explain these for us?

    E: On the grand scale of things - I can appreciate that perhaps animation.simba is not the most complex coding out there, but I am willing to bet that there are many who would like a blow by blow breakdown on the functions.
    Last edited by NickMystre; 02-04-2012 at 07:27 AM.
    Ciao
    NM

  5. #5
    Join Date
    Oct 2008
    Location
    C:\Simba\Includes\
    Posts
    7,566
    Mentioned
    19 Post(s)
    Quoted
    180 Post(s)

    Default

    Awesome tutorial Flight! I love PixelShift!
    Away for awhile, life is keeping me busy. | Want to get my attention in a thread? @Kyle Undefined; me.
    { MSI Phoenix || SRL Stats Sigs || Paste || Scripts || Quotes || Graphics }

    When posting a bug, please post debug! Help us, help you!

    I would love to change the world, but they won't give me the source code. || To be the best, you've got to beat the rest. || Logic never changes, just the syntax.
    If you PM me with a stupid question or one listed in FAQ, or about a script that is not mine, I will NOT respond.


    SRL is a Library of routines made by the SRL community written for the Program Simba. We produce Scripts for the game Runescape.


  6. #6
    Join Date
    Dec 2008
    Posts
    160
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Just what I was looking for! ty
    My Soul Wars Scipt Proggress:[100%....]
    Probably won't release though I like it for myself

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

    Default

    Great tut man

  8. #8
    Join Date
    Jan 2012
    Location
    Minneapolis, Mn
    Posts
    185
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

  9. #9
    Join Date
    Feb 2006
    Location
    Aussie
    Posts
    937
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Awesome, very helpful!

    EDIT: Also, 650 seems to work better than 400 for the mining function
    Last edited by Jagex_Fagex; 02-23-2012 at 08:38 AM.

  10. #10
    Join Date
    Nov 2011
    Location
    UK
    Posts
    89
    Mentioned
    1 Post(s)
    Quoted
    11 Post(s)

    Default

    This is what I have been waiting for to finally make a firemaking script! Thanks!

  11. #11
    Join Date
    Jan 2012
    Posts
    2,568
    Mentioned
    35 Post(s)
    Quoted
    356 Post(s)

    Default

    just wondering..under what situation would this be more efficient than using GetXPBar?

  12. #12
    Join Date
    Oct 2006
    Location
    Netherlands
    Posts
    3,285
    Mentioned
    105 Post(s)
    Quoted
    494 Post(s)

    Default

    Quote Originally Posted by riwu View Post
    just wondering..under what situation would this be more efficient than using GetXPBar?
    When you are cutting magic trees. It may take a minute before you get a log, this one will be faster.
    Working on: Tithe Farmer

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

    Default

    Quote Originally Posted by masterBB View Post
    When you are cutting magic trees. It may take a minute before you get a log, this one will be faster.
    Yep yep, rocktails / sharks as well. Low-level'ed woodcutters chopping high level trees, low-level'ed miners mining high level ores, ect...

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


  14. #14
    Join Date
    Jan 2012
    Posts
    2,568
    Mentioned
    35 Post(s)
    Quoted
    356 Post(s)

    Default

    Quote Originally Posted by masterBB View Post
    When you are cutting magic trees. It may take a minute before you get a log, this one will be faster.
    ah thx +Rep! basically any animating activity that gains multiple xp/click.

  15. #15
    Join Date
    Mar 2012
    Location
    Canada
    Posts
    870
    Mentioned
    1 Post(s)
    Quoted
    5 Post(s)

    Default

    Pixel shift seems so scary at first but now it looks ridiculously easy. Maybe you made it look easier than it is though
    My scripts:
    Advanced Barb Agility Course(outdated), MonkeyThieverV0.11, MahoganyTableV0.4(outdated)
    Questions? I bet that for 98% of those, you'll find answer HERE

  16. #16
    Join Date
    Dec 2006
    Location
    Program TEXAS home of AUTOERS
    Posts
    7,934
    Mentioned
    26 Post(s)
    Quoted
    237 Post(s)

    Default

    Great to use, currently using on a upcoming script. And this tut explains it all! Good job

  17. #17
    Join Date
    Jan 2012
    Posts
    29
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Thank you Flight!
    Helped me out a great bit!

  18. #18
    Join Date
    Apr 2012
    Location
    Belgium
    Posts
    39
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Dam genius! Thanks a lot
    This will replace my poor is walking function which checked for SPS location every sec

  19. #19
    Join Date
    Apr 2012
    Location
    Cell beside Joe
    Posts
    102
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Great tutorial!

  20. #20
    Join Date
    Mar 2012
    Posts
    690
    Mentioned
    2 Post(s)
    Quoted
    40 Post(s)

    Default

    Helped alot!

  21. #21
    Join Date
    May 2012
    Posts
    59
    Mentioned
    0 Post(s)
    Quoted
    3 Post(s)

    Default

    Thanks very much, another method of checking if the character is cutting, mining fishing or what ever and a few other things that can come in handy.
    Thanks again

  22. #22
    Join Date
    Nov 2011
    Posts
    1,589
    Mentioned
    9 Post(s)
    Quoted
    17 Post(s)

    Default

    I'm still using this today , I keep attempting to use it, now I am going to work on it
    Thanks Flight
    Mat



    ^^

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

    Default

    Very very useful! Thanks flight!
    Thx Euphemism and Vinyl for the awesome siggy and avatar!

  24. #24
    Join Date
    Jul 2012
    Location
    System 32
    Posts
    47
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Thanks for the tutorial!

    But, would the variables (245, 130, 285, 195) need to be changed with the RS toolbar being imbedded into the RS applet?

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

    Default

    Quote Originally Posted by Etrnl Fear View Post
    Thanks for the tutorial!

    But, would the variables (245, 130, 285, 195) need to be changed with the RS toolbar being imbedded into the RS applet?
    Nah, the current SRL & Simba already have adjustments in place; these parameters remain correct.

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


Page 1 of 2 12 LastLast

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
  •