Jump to content

Walking to a Sleeping Rock Crab


Recommended Posts

Posted (edited)

Hi, I've noticed my script after walking to one of the dormant crabs on the far eastern side of the East side of rock crabs it kind of just gets stuck in that area and spams the logger with this, any help or ideas would be awesome.

Quote

[INFO][Bot #1][01/04 11:35:56 PM]: WebWalkingEvent; We have reached the final destination!

Here's the code.

package task.impl;

import org.osbot.rs07.api.model.NPC;

import Wrapper.Timing;
import script.RockCrab;
import task.Task;

public class FindCrab extends Task {
	@Override
	public boolean activate() {
		if (!RockCrab.Instance.combat.isFighting() && !RockCrab.Instance.myPlayer().isUnderAttack()) {
			return true;
		}
		return false;
	}

	@Override
	public void execute() {
		NPC rock = RockCrab.Instance.getNpcs().closest("Rocks");
		if (rock != null) {
			RockCrab.Instance.getCamera().toEntity(rock);
			rock.hover();
			RockCrab.Instance.getWalking().webWalk(rock.getPosition());
		}
		
		Timing.waitCondition(() -> RockCrab.Instance.myPlayer().isMoving(), 1000);
	}
}

I don't feel I need to be spoon fed just a push in the right direction if I'm doing something wrong =).

Also I've tried the walking#walk method also same issue.

Image below of issue:

https://gyazo.com/596f7031657fd2521fb5b38a50e41e7c

Edited by 01053
Posted (edited)
6 minutes ago, 01053 said:

Hi, I've noticed my script after walking to one of the dormant crabs on the far eastern side of the East side of rock crabs it kind of just gets stuck in that area and spams the logger with this, any help or ideas would be awesome.

Here's the code.


package task.impl;

import org.osbot.rs07.api.model.NPC;

import Wrapper.Timing;
import script.RockCrab;
import task.Task;

public class FindCrab extends Task {
	@Override
	public boolean activate() {
		if (!RockCrab.Instance.combat.isFighting() && !RockCrab.Instance.myPlayer().isUnderAttack()) {
			return true;
		}
		return false;
	}

	@Override
	public void execute() {
		NPC rock = RockCrab.Instance.getNpcs().closest("Rocks");
		if (rock != null) {
			RockCrab.Instance.getCamera().toEntity(rock);
			rock.hover();
			RockCrab.Instance.getWalking().webWalk(rock.getPosition());
		}
		
		Timing.waitCondition(() -> RockCrab.Instance.myPlayer().isMoving(), 1000);
	}
}

I don't feel I need to be spoon fed just a push in the right direction if I'm doing something wrong =).

Also I've tried the walking#walk method also same issue.

Image below of issue:

https://gyazo.com/596f7031657fd2521fb5b38a50e41e7c

 

Your FindCrab task will always execute unless isFighting or isUnderAttack is true.

In this case neither are true so it will continue to try and walk.

Web walking will not walk to the exact position you specify, it will stop walking a few tiles away. To walk to a closer tile / an exact tile you will need to use a custom WalkingEvent and set the minDistanceThreshold. The minDistanceThreshold specifies how close the player must be from the destination position before the WalkingEvent finishes.

You will also need to account for when mr crab does not wake up from his peaceful sleep. If the crab doesn't attack your player, then you will continue to execute the FindCrab task and try to walk.

Edited by Explv
Posted
7 minutes ago, Explv said:

 

Your FindCrab task will always execute unless isFighting or isUnderAttack is true.

In this case neither are true so it will continue to try and walk.

Web walking will not walk to the exact position you specify, it will stop walking a few tiles away. To walk to a closer tile / an exact tile you will need to use a custom WalkingEvent and set the minDistanceThreshold. The minDistanceThreshold specifies how close the player must be from the destination position before the WalkingEvent finishes.

You will also need to account for when mr crab does not wake up from his peaceful sleep. If the crab doesn't attack your player, then you will continue to execute the FindCrab task and try to walk.

Hey thanks for the reply. I'll give it a try. :)

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...