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