- Joined
- Nov 3, 2013
- Messages
- 609
By registering with us, you'll be able to discuss, share and private message with other members of our community.
Sign up now!Building the path:Show me your code.
public Path buildTo(Locatable dest){
Path path = RegionPath.buildTo(dest);
if(path == null || path.getNext() == null)
path = web.getPathBuilder().buildTo(dest);
if(path == null || path.getNext() == null)
path = BresenhamPath.buildTo(dest);
return path;
}
public void walkToBank() {
if(bankPath == null) bankPath = pathBuilder.buildTo(bank.getArea());
else if(!bank.contains(Traversal.getDestination())){
/*Path tempPath = bankPath;
if(Random.nextInt(100) <= PlayerSense.getAsInteger(CustomPlayerSense.Key.VIEW_PORT_WALKING.playerSenseKey)){
tempPath = ViewportPath.convert(tempPath);
}*/
System.out.println(bankPath.getNext() + ": " + bankPath.step());
if(bankPath instanceof BresenhamPath){
bankPath = pathBuilder.buildTo(bank.getArea());
}
Execution.delay(400,600);
}else{
Execution.delay(400,600);
}
}
If I've generated a path from location A -> B, why would it ever go to C unless C is on the path between A->B? And if C is on the path, then it is moving from C -> B anyway.The primary issue here is that path's are being generated with teleports that actually result in a *larger* traversal cost than those without teleports. This is demonstrated in my first post where instead of stepping 3 tiles west & 1 south, a teleport is instead performed. This will almost certainly result in closed traversal loops for certain sets of {origin, destination}.
TheBat: Although your code should work in most cases*[and is very efficient!], I can see a potential pitfall... Consider: If your at location A, build path to B, then move to a new location C that is far away, the original path will not retain information relevant to location C.
*Given path's are generated correctly.
Try from the West Varrock mine to the West Varrock bank. I know @mjmfighter was having the same problem in that location with his own script.I'll investigate why it's happening further, but @TheBat lodestones currently have a cost of 25.
Try from the West Varrock mine to the West Varrock bank. I know @mjmfighter was having the same problem in that location with his own script.
I've gone ahead and revised the Lodestone#teleport method to wait until completion of the teleport (aka, until you're off the lodestone and no longer moving) before it returns.@Cloud
It keeps happening when I generate a path from:
bank = new Area.Rectangular(new Coordinate(3267,3169), new Coordinate(3273,3165));
mine = new Area.Rectangular(new Coordinate(3290,3319), new Coordinate(3305,3285));
@Cloud
So, a bit more info, if you stand right next to the Falador lodestone and try to walk to the dwarven mine north-east of there, it has two problems:
1. It uses the teleport right off the bat, instead of just walking there.
2. After it teleports, it clicks the next step just north east of the lodestone before the animation has completed. That step disappears, so it teleports to the lodestone again for whatever reason.
I know that calling step on a path will return false and not take the step if the current traversal destination is far enough away or it's not on the mini map, which means #2 can be easily fixed by simply adjusting the time that it waits for the animation to finish be a bit longer.
It no longer spam click when it's waiting, which is something. I did some debugging, and I think I found something interesting. I don't know exactly what the problem is, but it is VERY easy to replicate.I've gone ahead and revised the Lodestone#teleport method to wait until completion of the teleport (aka, until you're off the lodestone and no longer moving) before it returns.
if(path == null){
path = web.getPathBuilder().buildTo(new Coordinate(3018, 3450));
System.out.println("New Path created: " + Players.getLocal().getPosition() + " -> " + new Coordinate(3018, 3450));
}else{
System.out.println("Current Location: " + Players.getLocal().getPosition() + " Vertex: " + path.getNext());
path.step();
}
Execution.delay(Random.nextInt(600,800));
So what parts of that are actually valid if part of it was because of your code?It no longer spam click when it's waiting, which is something. I did some debugging, and I think I found something interesting. I don't know exactly what the problem is, but it is VERY easy to replicate.
To replicate:
1. Home teleport to lumbridge
2. Build a path to new Coordinate(3018, 3450)
3. Let it teleport and a loop will start.
4. Stop it after a loop or two.
5. Build a path from the current location to new Coordinate(3018, 3450)
6. It will loop again.
(Actually, I just realized the following is because my path generator switches to a region path once I get it to load the region)
7. Manually walk to destination.
8. Build a path to new Coordinate(3018, 3450)
9. Manually walk back to lodestone.
10. Paths will build normally now.
Here's some data I collected, I don't know if it will help, but let me know if you can't replicate it, or you need anything else from me.
http://pastebin.com/raw.php?i=pw2nK8iw
The code I ran looks like this:
And that is simply continuously looped until the player is at the proper destination.Code:if(bankPath == null){ bankPath = web.getPathBuilder().buildTo(new Coordinate(3018, 3450)); System.out.println("New Path created: " + Players.getLocal().getPosition() + " -> " + new Coordinate(3018, 3450)); }else{ System.out.println("Current Location: " + Players.getLocal().getPosition() + " Vertex: " + bankPath.getNext()); bankPath.step(); } Execution.delay(Random.nextInt(600,800));
It's not just my code. I was using Alpha Divination(@SlashnHax), and started it away from the location it was meant to be run at, and it went to walk there and got stuck in a loop on the Varrock lodestone.So what parts of that are actually valid if part of it was because of your code?
import com.runemate.game.api.hybrid.location.Coordinate;
import com.runemate.game.api.hybrid.location.navigation.Path;
import com.runemate.game.api.hybrid.location.navigation.Traversal;
import com.runemate.game.api.hybrid.location.navigation.web.Web;
import com.runemate.game.api.hybrid.region.Players;
import com.runemate.game.api.hybrid.util.calculations.Random;
import com.runemate.game.api.script.Execution;
import com.runemate.game.api.script.framework.LoopingScript;
public class WebTest extends LoopingScript{
Path path = null;
Web web = Traversal.getDefaultWeb();
@Override
public void onLoop() {
if(Players.getLocal().getPosition().distanceTo(new Coordinate(3018, 3450)) > 5)walk();
else stop();
}
public void walk(){
if(path == null){
path = web.getPathBuilder().buildTo(new Coordinate(3018, 3450));
System.out.println("New Path created: " + Players.getLocal().getPosition() + " -> " + new Coordinate(3018, 3450));
}else{
System.out.println("Current Location: " + Players.getLocal().getPosition() + " Vertex: " + path.getNext());
path.step();
}
Execution.delay(Random.nextInt(600,800));
}
}
(01:21:20) New Path created: Coordinate(2735, 3416, 0) -> Coordinate(3018, 3450, 0)
(01:21:21) Current Location: Coordinate(2735, 3416, 0) Vertex: LodestoneVertex(2967, 3404, 0)
(01:21:37) Current Location: Coordinate(2967, 3404, 0) Vertex: CoordinateVertex(2983, 3420, 0)
(01:21:38) Current Location: Coordinate(2967, 3404, 0) Vertex: CoordinateVertex(2983, 3420, 0)
(01:21:40) Current Location: Coordinate(2967, 3403, 0) Vertex: LodestoneVertex(2967, 3404, 0)
(01:21:55) Current Location: Coordinate(2967, 3404, 0) Vertex: CoordinateVertex(2983, 3420, 0)
(01:21:56) Current Location: Coordinate(2967, 3404, 0) Vertex: CoordinateVertex(2983, 3420, 0)
(01:21:58) Current Location: Coordinate(2967, 3403, 0) Vertex: LodestoneVertex(2967, 3404, 0)
(01:22:12) Current Location: Coordinate(2967, 3404, 0) Vertex: CoordinateVertex(2983, 3420, 0)
(01:22:14) Current Location: Coordinate(2967, 3404, 0) Vertex: CoordinateVertex(2983, 3420, 0)
(01:22:16) Current Location: Coordinate(2966, 3404, 0) Vertex: LodestoneVertex(2967, 3404, 0)
(01:22:17) Current Location: Coordinate(2967, 3406, 0) Vertex: LodestoneVertex(2967, 3404, 0)
(01:22:18) Current Location: Coordinate(2970, 3409, 0) Vertex: LodestoneVertex(2967, 3404, 0)
(01:22:19) Current Location: Coordinate(2973, 3410, 0) Vertex: LodestoneVertex(2967, 3404, 0)
(01:22:20) Current Location: Coordinate(2975, 3413, 0) Vertex: LodestoneVertex(2967, 3404, 0)
(01:22:21) Current Location: Coordinate(2977, 3414, 0) Vertex: LodestoneVertex(2967, 3404, 0)
(01:22:22) Current Location: Coordinate(2981, 3417, 0) Vertex: LodestoneVertex(2967, 3404, 0)
(01:22:36) Current Location: Coordinate(2967, 3404, 0) Vertex: CoordinateVertex(2983, 3420, 0)
(01:22:38) Current Location: Coordinate(2967, 3404, 0) Vertex: CoordinateVertex(2983, 3420, 0)
(01:22:39) Current Location: Coordinate(2967, 3403, 0) Vertex: LodestoneVertex(2967, 3404, 0)
(01:22:53) Current Location: Coordinate(2967, 3404, 0) Vertex: CoordinateVertex(2983, 3420, 0)
(01:22:55) Current Location: Coordinate(2967, 3404, 0) Vertex: CoordinateVertex(2983, 3420, 0)
(01:22:57) Current Location: Coordinate(2967, 3403, 0) Vertex: LodestoneVertex(2967, 3404, 0)
(01:23:11) Current Location: Coordinate(2967, 3404, 0) Vertex: CoordinateVertex(2983, 3420, 0)
(01:23:13) Current Location: Coordinate(2967, 3404, 0) Vertex: CoordinateVertex(2983, 3420, 0)
(01:23:14) Current Location: Coordinate(2967, 3403, 0) Vertex: LodestoneVertex(2967, 3404, 0)
(01:23:15) Current Location: Coordinate(2967, 3403, 0) Vertex: LodestoneVertex(2967, 3404, 0)
(01:23:30) Current Location: Coordinate(2967, 3404, 0) Vertex: CoordinateVertex(2983, 3420, 0)
(01:23:31) Current Location: Coordinate(2967, 3404, 0) Vertex: CoordinateVertex(2983, 3420, 0)
(01:23:33) Current Location: Coordinate(2967, 3403, 0) Vertex: LodestoneVertex(2967, 3404, 0)
(01:23:47) Current Location: Coordinate(2967, 3404, 0) Vertex: CoordinateVertex(2983, 3420, 0)
(01:23:49) Current Location: Coordinate(2967, 3404, 0) Vertex: CoordinateVertex(2983, 3420, 0)
(01:23:50) Current Location: Coordinate(2967, 3403, 0) Vertex: LodestoneVertex(2967, 3404, 0)
public class WebTest extends LoopingScript{
Path path = null;
Web web = Traversal.getDefaultWeb();
@Override
public void onStart(String... args){
path = null;
}
@Override
public void onLoop() {
if(Players.getLocal().getPosition().distanceTo(new Coordinate(3018, 3450)) > 5)walk();
else stop();
}
public void walk(){
path = web.getPathBuilder().buildTo(new Coordinate(3018, 3450));
System.out.println("New Path created: " + Players.getLocal().getPosition() + " -> " + new Coordinate(3018, 3450));
path.step();
Execution.delay(Random.nextInt(600,800));
}
}
We use essential cookies to make this site work, and optional cookies to enhance your experience.