View Full Version : Can someone explain me these animating methods
NexPB
01-19-2012, 09:10 PM
I don' rly know hwo to use them and what they will do.
(*
AnimatingMulti
~~~~~~~~~~~~~~
.. code-block:: pascal
function AnimatingMulti(B: TBoxArray; Time, MinCount: Integer): TBooleanArray;
Finds constant animation in boxes B during time T. If PixelShift in box is
smaller than MinCount, it's considered not animating.
.. note::
Author: marpis
Last Modified: Nov. 29, 2009
Example:
.. code-block:: pascal
boolArray := AnimatingMulti(boxArray, 5000, 2000);
for i := 0 to High(boolArray) do
isAnimating := boolArray[i];
*)
function AnimatingMulti(B: TBoxArray; Time, MinCount: Integer): TBooleanArray;
var
Shifts: TIntegerArray;
TT, I, H: Integer;
begin
TT := GetSystemTime + Time;
H := High(B);
SetLength(Result, H + 1);
for I := 0 to H do
Result[I] := True;
while (GetSystemTime < TT) do
begin
Shifts := PixelShiftMulti(B, 50);
for I := 0 to H do
if (Shifts[I] <= MinCount) then
Result[I] := False;
end;
end;
(*
Animating
~~~~~~~~~
.. code-block:: pascal
function Animating(B: TBox; Time, MinCount: Integer): Boolean;
Finds constant animation in boxes B during time T. If PixelShift in box is
smaller than MinCount, it's considered not animating.
.. note::
Author: marpis
Last Modified: Nov. 29, 2009
Example:
.. code-block:: pascal
playerAnimating := Animating(box, 5000, 2000);
*)
function Animating(B: TBox; Time, MinCount: Integer): Boolean;
var
TBA: TBooleanArray;
begin
TBA := AnimatingMulti([B], Time, MinCount);
Result := TBA[0];
end;
Flight
01-20-2012, 01:45 AM
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)
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. :p 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:
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!
'Toxin
01-20-2012, 03:18 AM
Hmmm... I honestly had no idea how useful pixelShift was until today. Flight, I'm planning on doing an agility script later on, would using pixelShift checks be fairly ideal for differentiating between animations?
Flight
01-20-2012, 03:33 AM
Hmmm... I honestly had no idea how useful pixelShift was until today. Flight, I'm planning on doing an agility script later on, would using pixelShift checks be fairly ideal for differentiating between animations?
Absolutely. Between pixelshift and location detections, Agility scripts are in the bag, so to speak. ;)
I also use this to detect whether my character is woodcutting with averagePixelShift. AFAIK it can be used to do many things, particularly when you're doing something that you stay at the same spot.
NexPB
01-20-2012, 03:18 PM
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)
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. :p 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:
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 for this awesome post I completly understand it now, repped =D
I also needed it for mining ;p
Inception
01-20-2012, 04:26 PM
That was a great explanation Flight! I've always wondered the best way to figure out pixel shifts. Rep++
Blakerey
02-13-2012, 06:34 AM
Just found this, and yet it was in the beginner tutorial section ^_^ haha.
Powered by vBulletin® Version 4.2.1 Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.