SRL Archive - Snippets

True waitWhileMoving - even when using objects that move you.


Davi

2015-05-16 13:21:27

I noticed that isMoving would return False when using agility obstacles, your destination would return as your current position and most of the walk on obstacles registered no animation.

I wrote a procedure to wait- checking every 2 game ticks (1200 ms) if you have moved to a new tile, breaking if you have not.


procedure waitWhileMoving;
var
tim : Timer;
lastTile : TTile;
finished : Boolean;
Player: TReflectLocalPlayer;
begin
player.create; //Take this and the player declaration out if you've already created your player.
tim.start;
repeat
if tim.timeElapsed > 20000 then
break;
lastTile := player.GetTile;
wait(1200); // 600ms is 1 game tick, so this corresponds to two in game ticks.
if (player.GetTile.X = lastTile.X) and (player.GetTile.Y = lastTile.Y) then
finished := True;
until(finished);
end;

I imagine an isMoving function would look something like this (Although the wait involved would make it unsuitable for a few tasks)


function isMoving(ticks : Integer) : Boolean;
var
lastTile : TTile;
Player: TReflectLocalPlayer;
begin
result := True;
player.create; //Take this and the player declaration out if you've already created your player.
lastTile := player.GetTile;
wait(ticks * 600); // 600ms is 1 game tick.
if (player.GetTile.X = lastTile.X) and (player.GetTile.Y = lastTile.Y) then
result := False;
end;

tls

2015-05-16 14:18:58

Check walk queue length.

Davi

2015-05-16 14:38:31

From: tls
Check walk queue length.


Is empty when using agility obstacles.

tls

2015-05-16 16:43:04

For agility specifically, I would handle it like this:
1. Click obstacle
2. If click was successful(red cross), then go into wait loop
3. In wait loop check for tile position equal to the destination tile and plane of the obstacle
I would also include the timeout of tile position not changing for like 3 seconds(loading time between obstacles can vary).

Davi

2015-05-16 17:15:14

From: tls
For agility specifically, I would handle it like this:
1. Click obstacle
2. If click was successful(red cross), then go into wait loop
3. In wait loop check for tile position equal to the destination tile and plane of the obstacle
I would also include the timeout of tile position not changing for like 3 seconds(loading time between obstacles can vary).


That was my 5th or 6th attempted solution. It had two major problems in that it involved setting a destination tile for a huge number of obstacles, in my rooftop script I have 52? or around that number defined obstacles so far. The second problem is that certain obstacles would have variable destination tiles not just in the X-axis but the Y-axis as well (Gaps would drop you in a different X-plane depending on where you clicked, swings a different Y-plane) So then you have to define destination regions for each obstacle, iterate through the possible tiles in the region checking if it's equal to your current tile. I think for practicalities sake I did a simple > check for the lowest possible tile within the region.

I settled on the above solution as it works for all obstacles with no extra data required.

Hoodz

2015-05-16 17:24:07

@Davi; what i used in my color agility script is just checking in what area you are in.

for example: after clicking on an object, you'll get a red cross. After that you are going to wait until you are on a new platform or a time out happened (missclick perhaps).

Davi

2015-05-16 17:31:22

From: hoodz
@Davi; what i used in my color agility script is just checking in what area you are in.

for example: after clicking on an object, you'll get a red cross. After that you are going to wait until you are on a new platform or a time out happened (missclick perhaps).


Yeah, that's the basic principle I started with, but how do you check if you're in a new area? Take a snapshot of the area before you traverse the obstacle and compare it to MS until it's different? That would trigger during traversing the obstacle. If it involves knowing any data about the destination location it's simply not viable for a script of this size.

Hoodz

2015-05-16 18:06:15

From: Davi
Yeah, that's the basic principle I started with, but how do you check if you're in a new area? Take a snapshot of the area before you traverse the obstacle and compare it to MS until it's different? That would trigger during traversing the obstacle. If it involves knowing any data about the destination location it's simply not viable for a script of this size.


i got every location defined.
here an example, every roof is a different location/area:

Davi

2015-05-16 18:07:41

From: hoodz
i got every location defined.
here an example, every roof is a different location/area:


Is that done with an automated process that can be applied to all agility courses?

Hoodz

2015-05-16 18:15:18

From: Davi
Is that done with an automated process that can be applied to all agility courses?


yes, took a while before i finished it. But im proud in the result!

here a progress report from the script:

seers village rooftop, including breaks (hence the low xp/h)

Davi

2015-05-16 18:18:45

From: hoodz
yes, took a while before i finished it. But im proud in the result!

here a progress report from the script:

seers village rooftop, including breaks (hence the low xp/h)


Nice, I'm not sure how I would go about grabbing the areas automatically, I suppose looking for the borders on the minimap? I think I'll stick to my above method as it works perfectly on all the courses I've coded so far: (Gnome Village, Draynor, Varrock, Canafis, Falador)

This is proggie:


This was on varrock shortly after implementing the above, with a break or two in there.