Jump to content

Walking to a Sleeping Rock Crab


01053

Recommended Posts

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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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. :)

Link to comment
Share on other sites

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.

  • Recently Browsing   0 members

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