SRL Archive - OSR Help

Animation Help


Roflme

2012-10-29 16:42:15

Function isAnimating: Boolean;
var
B: TBox;
begin
B := PointToBox(Point(MSCX-20, MSCY-20),Point(MSCX+20,MSCY+20));
Result := Animating(B, 5, 300);

if Result then
Writeln('It is animating');
end;

I'm trying to find a way to detect when the player is teleporting or not. I was going to try to use the above code. My goal is for it to try to detect the center of the screen (where the player is). Some animations will be going on while teleporting so I was going to try see if I could find a way to detect that. I was hoping the above would detect nothing when nothing was happening, and then when the player is teleporting it'd pick that animation up.

Well, it works for the most part…

The only problem is that when I have this on repeat, it will sometimes detect animation while it's just standing still. (I was testing it to repeat until(false). I'd click to walk and enable SMART and "It is animating" would spam until it stopped walking. It would spam the same while I was teleporting. But when I stood still sometimes it'd just randomly message that while doing nothing (nothing at all moved in the specified box. I made sure only my character was in the box).




So I have some questions:

  1. Would the above be an efficient way for detecting animation? I understand if anyone/thing moves near the center of the screen it will detect it as animation. But is there any better way for detecting any animation (specifically teleporting animation?)
  2. Is there any way to make the above function more accurate? I really want it only to detect animation when moving/*insert script action here*/teleporting.
  3. Why does the message only appear every so often while standing still?
  4. When it's counting the amount of pixels shifted (while the function is left on an indefinite repeat), will the count reset when it's restarted the function? I don't know, I'm just trying to find out why it will detect animation when it's just standing there (I made sure nothing could move in it's way). Would upping the minimum count/time length fix that? I don't want to make it too high of a minimum count because it may not be able to pick up the teleport animation :(

Err and I'll edit this when I come up with another question I guess. Someone tell me what you did to detect that the player is teleporting. :(

Rezozo

2012-10-29 16:45:46

If its loadstones, Why do you need to detect? Just add a wait. Plus, you could add a search for the loadstone on the minimap after 10 sec?

Roflme

2012-10-29 16:49:26

From: Rezozo
If its loadstones, Why do you need to detect? Just add a wait. Plus, you could add a search for the loadstone on the minimap after 10 sec?


Loadstone and the dungeoneering ring teleport.

I was originally just using a long wait and then check the minimap to see if it teleported. But my problem was that if it misclicked and didn't teleport, it would have to wait those ~10 seconds before trying to teleport again.

I was hoping that by detecting if animation was occurring or not I could prevent the script from having to wait that long and could just try to teleport again immediately after failing.

I've just been having problems with the teleports so I was trying to add an extra failsafe :p

Rezozo

2012-10-29 17:15:16

I see… IDK about this, but I could help find a workaround? PM me the details of the script, what its supposed to do etc

Footy

2012-10-29 17:31:51

You could try this:

Function IstherePixelShift(Timestotry, WaitBetweenTries:integer):boolean;
var
Shift:integer;
begin
for i := 0 to TimesToTry do
begin
Shift := AveragePixelShift(YourBox, 250, 500);
if Shift > 500 then
begin
Result := True;
Break;
end;
wait(randomrange(WaitBetweenTries - 100, WaitBetweenTries + 100));
end;
end;

Roflme

2012-10-29 17:39:21

From: Rezozo
I see… IDK about this, but I could help find a workaround? PM me the details of the script, what its supposed to do etc


It isn't so much of a script at the moment, but just some function that I'd hope to use for future scripts.


But I got the idea while trying to make a script to mine clay at rimmington and bank at dung bank. I was working on a harpoon buying script before and was using wait timers for that but it just seemed inefficient so I was trying to make something else.

I wanted to work on detecting the teleporting first because the mining portion of the script is rather easy IMO (as well as the walking for the most part, and banking procedures) so I was going to leave it for last :p



From: Footy
You could try this:

Function IstherePixelShift(Timestotry, WaitBetweenTries:integer):boolean;
var
Shift:integer;
begin
for i := 0 to TimesToTry do
begin
Shift := AveragePixelShift(YourBox, 250, 500);
if Shift > 500 then
begin
Result := True;
Break;
end;
wait(randomrange(WaitBetweenTries - 100, WaitBetweenTries + 100));
end;
end;

I'll give it a try tomorrow probably, stupid hurricane isn't going to let me do any further scripting tonight :(

Rezozo

2012-10-29 17:44:44

Hmm, then why Dung necessarily? Why not one of the Falador banks?
If you have to do Dung, then it is an almost immediate tele, so only 3-4 seconds wait, for teleporting back, maybe try Footy's suggestion :P

Olly

2012-10-29 17:48:27

How could you missclick a teleport though :s providing you have the failsafes leading up to the actual last click.

Roflme

2012-10-29 18:09:02

From: Ollybest
How could you missclick a teleport though :s providing you have the failsafes leading up to the actual last click.


I don't know, for some reason sometimes the loadstones don't click but the script thinks it did. And sometimes it'll right click the ring and not choose the teleport option.




It could be a Falador bank, but Dung bank is just much closer. It's a quick teleport and a very short walk away from a bank. Falador home tele is a little further of a walk and a longer tele.

Roflme

2012-10-29 19:09:48

Thank you for the function Footy. I'll have to play around with the settings because there are some parts where it just doesn't detect anything going on.


Played around with the settings on my function (just upped the minimum count) and it seems to be working fine now.



EDIT: Came back after a few days of no power (hurricane) and running at friends house.

Thank you for the function Footy; mine keeps giving me false results. I've yet to get yours to result true when it's standing still.