July 19, 20169 yr 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, 20169 yr by Flexeren
July 19, 20169 yr 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?
July 19, 20169 yr Author 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, 20169 yr by Flexeren
July 20, 20169 yr Author 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.
July 20, 20169 yr Save a reference to the fishing spot you interact with. Change when it no longer exists()?
July 20, 20169 yr Yeah just do if(myPlayer.isAnimating() && fishSpot.exists(){ //We are fishing } else { fishSpot.interact("Harpoon"); } Edited July 20, 20169 yr by GaetanoH
July 20, 20169 yr 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
Create an account or sign in to comment