Jump to content

2 NPC's next to player


Flexeren

Recommended Posts

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

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? 

Link to comment
Share on other sites

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.

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