Flexeren Posted July 19, 2016 Share Posted July 19, 2016 (edited) Hi,I have a script, which generally works. Except when this happens: 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! Edited July 19, 2016 by Flexeren Quote Link to comment Share on other sites More sharing options...
Precise Posted July 19, 2016 Share Posted July 19, 2016 Hi, I have a script, which generally works. Except when this happens: Script 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! use isAnimating instead? Quote Link to comment Share on other sites More sharing options...
Juggles Posted July 19, 2016 Share Posted July 19, 2016 if (myPlayer.isAnimating()) { //DoNothing } else { //Fish } Quote Link to comment Share on other sites More sharing options...
Flexeren Posted July 19, 2016 Author Share Posted July 19, 2016 (edited) I tried that earlier, but that creates another problem.When the fishing spot disappears, the character is still "fishing" in empty water for a couple of seconds, which still counts as "isAnimating".How do I fix that then? Edited July 19, 2016 by Flexeren Quote Link to comment Share on other sites More sharing options...
Flexeren Posted July 20, 2016 Author Share Posted July 20, 2016 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. Quote Link to comment Share on other sites More sharing options...
FrostBug Posted July 20, 2016 Share Posted July 20, 2016 Save a reference to the fishing spot you interact with. Change when it no longer exists()? Quote Link to comment Share on other sites More sharing options...
GaetanoH Posted July 20, 2016 Share Posted July 20, 2016 (edited) Yeah just do if(myPlayer.isAnimating() && fishSpot.exists(){ //We are fishing } else { fishSpot.interact("Harpoon"); } Edited July 20, 2016 by GaetanoH Quote Link to comment Share on other sites More sharing options...
FrostBug Posted July 20, 2016 Share Posted July 20, 2016 Yeah just do if(myPlayer.isAnimating() && fishSpot.exists(){ //We are fishing } else { fishSpot.interact("Harpoon"); } ^ This, but make sure fishSpot is a class member and only update it if it's null or doesn't exist 2 Quote Link to comment Share on other sites More sharing options...