Rsbothelper

Walk from random tile in area to random tile in another area?

Recommended Posts

How do I go from a random tile in the cow area (near lumbridge) to a random tile in the tree area (right next to the cows)?

 

The cow area is somewhat large and since I will attack cows in random places in this area, I don't think I can use the Path Generaor as I don't know the starting point. I also want to end at a random tile in the tree area. 


I do not think I can use https://explv.github.io/ to sketch out the area. It worked fine for the cow area, but not with the tree area for some reason 😕 There are more tiles where it says I'm not in the trees area than there are tiles where it says that player IS in tree area. Have no Idea why.

I also read that using Area is not recomended so what should I do and research?

 

 

My current code:
WalkToTrees.java

import static scripts.resources.Constants.TREE_AREA;


public class WalkToTrees extends Task {

    public Tile[] pathToTrees;
    private final STWalker walker2 = new STWalker(ctx);


    public WalkToTrees(ClientContext ctx, Tile[] pathToTrees) {
        super(ctx);
        this.pathToTrees = pathToTrees;
    }

    @Override
    public boolean activate() {
        Heal heal = new Heal(ctx);
        return !heal.hasFood()
                && !TREE_AREA.contains(ctx.players.local())
                && getNearestTree().tile().distanceTo(ctx.players.local()) > 8;
    }

    @Override
    public void execute() {
        if (!ctx.movement.running() &&
                ctx.movement.energyLevel() > Random.nextInt(5, 95)) {
            ctx.movement.running(true);
        }
        if (!getNearestTree().inViewport() ||
                !ctx.players.local().inMotion() && ctx.players.local().animation() != -1 ||
                ctx.movement.destination().equals(Tile.NIL)) {
            System.out.println("Traversing to tree area now");
            walker2.walkPath(Constants.PATH_TO_TREES);
        }
        Condition.wait(() -> ctx.players.local().animation() != -1, 200, 10); 
    }

    public GameObject getNearestTree() {
        return ctx.objects.select().name("Tree").nearest().poll();

    }
}

PATH_TO_TREES:
 

    public static final Tile[] PATH_TO_TREES = {new Tile(3265, 3296, 0), new Tile(3261, 3298, 0), new Tile(3257, 3297, 0), new Tile(3253, 3297, 0), new Tile(3249, 3296, 0), new Tile(3245, 3296, 0), new Tile(3241, 3298, 0), new Tile(3244, 3295, 0), new Tile(3248, 3295, 0), new Tile(3252, 3295, 0), new Tile(3256, 3295, 0), new Tile(3260, 3295, 0), new Tile(3264, 3295, 0), new Tile(3260, 3294, 0), new Tile(3256, 3294, 0), new Tile(3252, 3294, 0), new Tile(3248, 3294, 0), new Tile(3244, 3294, 0), new Tile(3248, 3293, 0), new Tile(3252, 3293, 0), new Tile(3256, 3293, 0), new Tile(3260, 3293, 0), new Tile(3264, 3293, 0), new Tile(3260, 3292, 0), new Tile(3256, 3292, 0), new Tile(3252, 3291, 0), new Tile(3248, 3292, 0), new Tile(3244, 3292, 0), new Tile(3248, 3291, 0), new Tile(3252, 3291, 0), new Tile(3256, 3291, 0), new Tile(3260, 3291, 0), new Tile(3264, 3291, 0), new Tile(3265, 3287, 0), new Tile(3262, 3290, 0), new Tile(3258, 3290, 0), new Tile(3254, 3290, 0), new Tile(3250, 3290, 0), new Tile(3246, 3290, 0), new Tile(3250, 3289, 0), new Tile(3254, 3289, 0), new Tile(3258, 3288, 0), new Tile(3262, 3290, 0), new Tile(3265, 3287, 0), new Tile(3261, 3288, 0), new Tile(3257, 3288, 0), new Tile(3253, 3288, 0), new Tile(3249, 3288, 0), new Tile(3245, 3288, 0), new Tile(3241, 3287, 0), new Tile(3242, 3283, 0), new Tile(3245, 3286, 0), new Tile(3249, 3286, 0), new Tile(3253, 3286, 0), new Tile(3257, 3286, 0), new Tile(3261, 3287, 0), new Tile(3265, 3287, 0), new Tile(3262, 3284, 0), new Tile(3265, 3281, 0), new Tile(3265, 3285, 0), new Tile(3261, 3285, 0), new Tile(3257, 3285, 0), new Tile(3253, 3285, 0), new Tile(3249, 3285, 0), new Tile(3245, 3285, 0), new Tile(3241, 3284, 0), new Tile(3245, 3283, 0), new Tile(3249, 3283, 0), new Tile(3253, 3283, 0), new Tile(3257, 3283, 0), new Tile(3261, 3283, 0), new Tile(3265, 3284, 0), new Tile(3262, 3281, 0), new Tile(3265, 3278, 0), new Tile(3262, 3281, 0), new Tile(3258, 3281, 0), new Tile(3254, 3281, 0), new Tile(3250, 3281, 0), new Tile(3246, 3281, 0), new Tile(3250, 3281, 0), new Tile(3254, 3279, 0), new Tile(3258, 3279, 0), new Tile(3262, 3279, 0), new Tile(3265, 3282, 0), new Tile(3265, 3278, 0), new Tile(3261, 3278, 0), new Tile(3257, 3277, 0), new Tile(3253, 3278, 0), new Tile(3253, 3274, 0), new Tile(3257, 3276, 0), new Tile(3261, 3276, 0), new Tile(3265, 3276, 0), new Tile(3261, 3274, 0), new Tile(3257, 3274, 0), new Tile(3253, 3274, 0), new Tile(3257, 3272, 0), new Tile(3261, 3272, 0), new Tile(3265, 3272, 0), new Tile(3261, 3270, 0), new Tile(3257, 3269, 0), new Tile(3254, 3266, 0), new Tile(3258, 3266, 0), new Tile(3262, 3268, 0), new Tile(3265, 3265, 0), new Tile(3265, 3269, 0), new Tile(3263, 3265, 0), new Tile(3259, 3265, 0), new Tile(3255, 3265, 0), new Tile(3259, 3263, 0), new Tile(3263, 3263, 0), new Tile(3259, 3261, 0), new Tile(3263, 3261, 0), new Tile(3259, 3261, 0), new Tile(3255, 3261, 0), new Tile(3253, 3257, 0), new Tile(3253, 3261, 0), new Tile(3254, 3265, 0), new Tile(3254, 3261, 0), new Tile(3258, 3260, 0), new Tile(3262, 3260, 0), new Tile(3265, 3257, 0), new Tile(3261, 3258, 0), new Tile(3265, 3261, 0), new Tile(3261, 3261, 0), new Tile(3257, 3258, 0), new Tile(3254, 3255, 0), new Tile(3258, 3255, 0), new Tile(3262, 3255, 0), new Tile(3265, 3258, 0), new Tile(3261, 3258, 0), new Tile(3257, 3261, 0), new Tile(3254, 3265, 0), new Tile(3250, 3266, 0), new Tile(3246, 3265, 0), new Tile(3242, 3265, 0), new Tile(3240, 3269, 0), new Tile(3244, 3268, 0), new Tile(3248, 3268, 0), new Tile(3244, 3270, 0), new Tile(3241, 3273, 0), new Tile(3238, 3277, 0), new Tile(3240, 3273, 0), new Tile(3240, 3269, 0), new Tile(3241, 3265, 0), new Tile(3244, 3262, 0), new Tile(3245, 3258, 0), new Tile(3244, 3254, 0), new Tile(3241, 3250, 0), new Tile(3245, 3252, 0), new Tile(3248, 3255, 0), new Tile(3248, 3259, 0), new Tile(3247, 3263, 0), new Tile(3244, 3266, 0)};

I got the tiles by using the Path Generator script by walking over ALL tiles in the cow location and then to a random place in the trees location. I know it's not the way to do it, but I can't figure out how else to do it?

 

TREES_AREA
 

    public static final Area TREE_AREA = new Area(
            new Tile(3232, 3276),
            new Tile(3250, 3269)
    );

 

TLDR; How do I:

 

1) How do I walk from a random tile in one location to a random tile in a completly different location (when I don't know on which tile the player is as it could be in a large area)?

2) How do I figure out if the player (or an object) is in a location (i.e. how do I know player is in tree location)?

 

Share this post


Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.