ModAssh 0 Posted August 1, 2018 Here's my code NPC spot = getNpcs().closest("Fishing spot"); if(failSafe && System.currentTimeMillis() - lastClick > 700) { spot.interact("Use-rod"); failSafe = false; sleep((int) (500 + (Math.random()*1000))); } if(SouthSpot.contains(getLocalPlayer())) { sleep((int) (800 + Math.random()*1000)); if(!SouthSpot.contains(spot.getTile())) { if(MiddleSpot.contains(spot.getTile())) { getWalking().clickTileOnMinimap(tileNearSpot(spot.getTile()).getRandomTile()); lastClick = System.currentTimeMillis(); running = true; return; } if(NWSpot.contains(spot.getTile())) { sleep((int) (800 + Math.random()*1000)); getWalking().clickTileOnMinimap(MiddleBarb.getRandomTile()); sleep((int) (2000 + Math.random()*200)); getWalking().clickTileOnMinimap(tileNearSpot(spot.getTile()).getRandomTile()); lastClick = System.currentTimeMillis(); running = true; return; } } } Sometimes this will move me from an area (ie SouthSpot, MiddleSpot, or NW Spot) even if there are other fishing spots in that area to one significantly further away. (Particularly running me about 10 tiles to the south to start fishing at the southern area) Sort of bamboozled by it
Nuclear Nezz 2104 Posted August 1, 2018 Have you logged the tile of the fishing spot to double check it's finding that, and not just walking to a different spot?
ModAssh 0 Author Posted August 1, 2018 Yes, my method pulls the closest fishing spot npc at the top of the method to train fishing. The tile from this spot is passed into the check for if the tile is in the area I'm in. It doesn't run to a new area without recognizing that the 'closest' available tile is in that area. For some reason it seems to prefer spots to the south when other spots are closer.
ArmyofDragons 28 Posted August 1, 2018 This is why I suggest using the all() method with Filter<NPC> and just sort by distance to the player, if it can be reached, is in combat and so on. I was working on a script for combat a few weeks ago and noticed that using closest() actually is broken in some forms because it targeted NPCs that were far away and were in combat and whatnot, and ideally did not pick the "closest" NPC.
ModAssh 0 Author Posted August 2, 2018 How are you sorting by distance and what kind of delay does it add? EDIT : Nevermind, I figured it out thanks
Recommended Posts
Archived
This topic is now archived and is closed to further replies.