Jump to content

2 NPC's next to player


Recommended Posts

Posted (edited)

Hi,

I have a script, which generally works. Except when this happens:

 

post-222066-0-53977200-1468968913_thumb.jpg

 

This is the code I use:

case FISHING:
	NPC fishingSpot = npcs.closest(true, 1511);
				
	camera.toTop();
	camera.moveYaw(0);
				
	if (!myPlayer().isInteracting(fishingSpot)) {
		if (fishingArea.contains(fishingSpot) && fishingArea.contains(myPlayer())) {
			log("Fishing at area 1");
			fishingSpot.interact("Harpoon");
			sleep(random(3000));
		}
		else if (fishingArea.contains(fishingSpot) && !fishingArea.contains(myPlayer())) {
			log("Area 1 is suitable, but not in reach. Walking there now");
			getWalking().walk(fishingArea);
		}
	}
	if (myPlayer().isInteracting(fishingSpot)) {
		// Do things while waiting
	}
break;

The problem is, it finds one of the spots, starts fishing, waits, then searches again, finding the other spot, and then interacting with that instead. So it is just looping, clicking at each spot every 3 seconds (the sleep timer).
 

How can I improve it?

Any help/advice is highly appreciated! smile.png

Edited by Flexeren
Posted

Hi,

I have a script, which generally works. Except when this happens:

 

attachicon.gifScript issue.jpg

 

This is the code I use:

case FISHING:
	NPC fishingSpot = npcs.closest(true, 1511);
				
	camera.toTop();
	camera.moveYaw(0);
				
	if (!myPlayer().isInteracting(fishingSpot)) {
		if (fishingArea.contains(fishingSpot) && fishingArea.contains(myPlayer())) {
			log("Fishing at area 1");
			fishingSpot.interact("Harpoon");
			sleep(random(3000));
		}
		else if (fishingArea.contains(fishingSpot) && !fishingArea.contains(myPlayer())) {
			log("Area 1 is suitable, but not in reach. Walking there now");
			getWalking().walk(fishingArea);
		}
	}
	if (myPlayer().isInteracting(fishingSpot)) {
		// Do things while waiting
	}
break;

The problem is, it finds one of the spots, starts fishing, waits, then searches again, finding the other spot, and then interacting with that instead. So it is just looping, clicking at each spot every 3 seconds (the sleep timer).

 

How can I improve it?

Any help/advice is highly appreciated! smile.png

 

use isAnimating instead? 

Posted

I may have a solution, but I need some help making it reality.


My idea:

 

First time the case is running:

- find the nearest fishing spot

- get and save the position of said fishing spot

- start fishing

 

Everytime the case is running, except first time:

- find all nearby fishing spots

- check if one of the fishing spot's positions equals the one already fishing at

 

 

I think I can figure out the rest, but that part I can't seem to figure out.

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