SRL Archive - Jr. Member General Help and Discussion

mainscreen.isPlayerAnimating() not working.


CRASH_OVERRIDE

2014-06-28 22:56:25

Hey guys,

i don't think the function "
mainscreen.isPlayerAnimating()
" is working. Whenever i use it, i get the error: "
Exception in Script: Unknown declaration "isPlayerAnimating"
"

Am i using this function wrong?
Do i need to add something to the includes?

I thought i could use it like this:
while (not mainscreen.isPlayerAnimating()) do
AntiBan();


I need to find a way to check if the player isn't moving and to do the antiban when the player is not moving. Any ideas? i hoped the above would work because it seemed simple and easy, i am thinking about maybe looking into pixel shift as an alternative but i don't really find the tutorials on it too descriptive. Can someone give some examples please?

KeepBotting

2014-06-28 23:22:28

Just searched, and mainScreen.isPlayerAnimating() seems to have been left out of the includes.

It uses/used pixelshift anyway, so it shouldn't be too hard to re-create, I believe someone (can't remember who) has a tutorial on it somewhere, and although it was written for SRL-5, the concept is 99% the same. It'd probably be in the outdated tutorials section.

Add my Skype (or PM me here) if you need additional help :D

CRASH_OVERRIDE

2014-07-01 06:28:06

Yeah i read the pixel shift tutorial, it just seems like a lot of code when i could simply use "isPlayerAnimating" :(

Based on Flights Tut: https://villavu.com/forum/showthread.php?t=74090

AveragePixelShift doesn't even work?

KeepBotting

2014-07-01 08:58:58

From: CRASH_OVERRIDE
Yeah i read the pixel shift tutorial, it just seems like a lot of code when i could simply use "isPlayerAnimating" :(

Based on Flights Tut: https://villavu.com/forum/showthread.php?t=74090

AveragePixelShift doesn't even work?
His code is for SRL-5, shouldn't be too hard to port to SRL-6.

I believe averagePixelShift is now getPixelShiftAverage()

CRASH_OVERRIDE

2014-07-04 04:59:02

Ahhh! Too easy, cheers "KeepBotting".

Coh3n

2014-07-04 08:14:38

I am not sure why that function was removed from the include. @Olly; do you know more about this?

If it was there when SRL-6 was released, it should have never been removed.

Olly

2014-07-04 10:05:51

From: Coh3n
I am not sure why that function was removed from the include. @Olly; do you know more about this?

If it was there when SRL-6 was released, it should have never been removed.


I dont think it was ever in the include? I don't remember it.

Coh3n

2014-07-05 10:17:25

From: Olly
I dont think it was ever in the include? I don't remember it.

I wonder if I had planned to put it in, but never did. It's in a documentation example. @CRASH_OVERRIDE; is there where you heard of the function?

Either way, it may not be a bad addition to the include. :)

CRASH_OVERRIDE

2014-07-06 03:10:55

@Coh3n, yes i got it from the SRL-6 Documentation, i thought everything in the documentation works? Could you add it? Would certainly help in a few scripts i have seen to reduce space and save time as well :)

Coh3n

2014-07-06 20:36:21

From: CRASH_OVERRIDE
@Coh3n, yes i got it from the SRL-6 Documentation, i thought everything in the documentation works? Could you add it? Would certainly help in a few scripts i have seen to reduce space and save time as well :)
If you think you have a version that works well, post it. :)

CRASH_OVERRIDE

2014-07-07 02:14:15

Did a bit of research Coh3n mate,

Found "CitadelLoom-Current.simba" http://broscripts.googlecode.com/svn/trunk/Crafting/CitadelLoom-Current.simba

// @ Function isPlayerAnimating by vwxz,edited by Brotein
// * Takes 10 samples and compares them to our threshold for idle animation
// # Returns true if 60% of sample is greater than the threshold
function isPlayerAnimating: Boolean
var
PixelShiftResult, IX, CX: Integer;
begin
printStatus('IsPlayerAnimating: Starting...', 1);
CX := 0;
for IX := 1 to AnimMaxIter do
begin
PixelShiftResult := GetPixelShiftAverage(PixelShiftBox, AnimMinTime, AnimMaxTime);
if (PixelShiftResult > AnimThreshold) then
begin
CX := CX + 1;
end;
printStatus('PixelShift: ' + IntToStr(PixelShiftResult), 2);
end;
Result := CX >= 6;
printStatus(IntToStr(CX) + ' periods out of 10 showed pixel shift over threshold', 2);
printStatus('IsPlayerAnimating: ' + BoolToStr(Result), 3);
end;

According to SRL-6.0 Documentation, you can test this with:
    if (mainscreen.isPlayerAnimating()) then
writeln('Player is doing something');

It also has on description who invented it, so you can add them to the Docs.


-CRASH.

Coh3n

2014-07-07 11:22:27

That's for OSR, but I can use it to make one for RS3.

Coh3n

2014-07-07 19:36:34

@CRASH_OVERRIDE; I've added this function to SRL. You should be able to use it when your SRL updates. It's a one-liner (which is probably why we didn't include it in the first place, but I understand that the pixel shift functions aren't well known and some might fine them difficult/unclear to use.

(*
TRSMainscreen.isPlayerAnimating
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

.. code-block:: pascal

function TRSMainscreen.isPlayerAnimating(maxShift: integer = 100): boolean;

Returns true if the pixel shift around the player is less than 'maxShift'. The
box around the player is defined in "mainscreen.playerBox". Pixel shifts can
vary depending on what the player is wearing/holding. This function's default is
based off of a player wearing nothing, and having the mainscreen at about half
zoom.

.. note::

- by Coh3n
- Last Updated: 7 July 2014 by Coh3n

Example:

.. code-block:: pascal

while (mainscreen.isPlayerAnimating()) do
begin
antiban();
wait(50 + random(50));
end;
*)
function TRSMainscreen.isPlayerAnimating(maxShift: integer = 300): boolean;
begin
result := (getPixelShiftAverage(self.playerBox, 50, 250) >= maxShift);
end;

CRASH_OVERRIDE

2014-07-08 02:42:28

Cheers man!