Bladez 0 Share Posted April 3, 2020 Hello guys, im trying to script a simple sandcrabs script that wakes up sleeping crabs. i've found the sandcrab ID's and tried to do a simple script to see if i can get the client to simply walk to the crabs but i'm getting nullpointer error codes in the log. GameObject rock = getGameObjects().closest(crab -> crab.getID() == 101 || crab.getID() == 103);if (rock != null) {getWalking().walk(rock);sleep(2000);} [/CODE] Does anyone know a work around for this? Many TIA Link to comment Share on other sites More sharing options...
Bladez 0 Author Share Posted April 3, 2020 Ok i fixed it by researching the actual ID's by using: Tile rockLocation = new Tile(2676,3713,0); GameObject Rocklocation = getGameObjects().getTopObjectOnTile(rockLocation); if (!getLocalPlayer().isInCombat()) { int ID = Rocklocation.getID(); log("Rock ID =" + ID); sleep(2000); sleep(2000); } The crabs seem to return many different ID's, so i compiled them all into: GameObject rock = getGameObjects().closest(crab -> crab.getID() it seemed to be working with the new ID's but it sometimes just clicks random spots on the minimap. any ideas? Link to comment Share on other sites More sharing options...
Pseudo 178 Share Posted April 3, 2020 You can simply do: getGameObjects().closest(o -> o.getName().equals("Sandy rocks"); Or swap out 'Sandy rocks' for the correct 'name' string. Link to comment Share on other sites More sharing options...
yetanotherbot 4 Share Posted April 3, 2020 Clicking on minimap sounds like walking. When are you doing this check? Maybe put a log event in here and check if it happens when your minimap is clickced. if (rock != null) {getWalking().walk(rock);sleep(2000);} getGameObjects().closest() can return objects relatively far away. There might be another rock further out that isn't obvious on screen. In addition to Pseudo's code I'd maybe add an area check getGameObjects().closest(o -> o.getName().equals("Sandy rocks") && YOUR_AREA.contains(o)); Link to comment Share on other sites More sharing options...
Nuclear Nezz 1969 Share Posted April 3, 2020 You need a null check in filters, you should null check everything. Then also as suggested above, you can use an area in the filter as well. Link to comment Share on other sites More sharing options...
Bladez 0 Author Share Posted April 3, 2020 Cheers for the reply guys, the trouble is it sometimes finds a rock crab but then other times just spam clicks a random point on the minimap and just stands there doing nothing. Almost like its clicking a crab that hasn't spawned yet. using get getTopObjectOnTile() and dumping the ID's i found to the log i found all of these ID's when scanning different tiles with the sleeping crabs on. What happens is it will click the minimap and spam click one location, sometimes it gets the crab location right, other times its like its clicking an invisible crab that hasn't spawned yet or something. Also if you've been to rock crabs before you'll see that they aren't named if you hover your mouse over them it shows nothing to return a named string for: getName().equals("Sandy rocks") This is the code i have at the moment and as you can see using getTopObject rather than using the enitity tool returns quite a few ID's GameObject rock = getGameObjects().closest(crab -> crab.getID() == 4894 || crab.getID() == 3703 || crab.getID() == 3721 || crab.getID() == 4910 || crab.getID() == 4907 || crab.getID() == 4908 || crab.getID() == 4911 || crab.getID() == 4904 || crab.getID() == 4899 || crab.getID() == 4902); if (!getLocalPlayer().isInCombat() && rock != null && rock.exists() && rock.isOnScreen() && rock.distance() > 2) { getWalking().walk(rock); sleep(2000); } return 1000; } } Link to comment Share on other sites More sharing options...
Shy 14 Share Posted April 3, 2020 42 minutes ago, Bladez said: Also if you've been to rock crabs before you'll see that they aren't named if you hover your mouse over them it shows nothing to return a named string for. It doesn't show when you hover over it, but it does if you right click doesn't it. I haven't been there in a long time. Not sure if this will work as I don't have an account to test it. GameObject crab = getGameObjects().closest(gameObject -> gameObject != null && gameObject.getName().contains("Sandy rocks")); if (!getLocalPlayer().isInCombat() && crab != null && crab.exists() && crab.distance(getLocalPlayer()) > 2) { if (getWalking().walk(crab)) { sleepUntil(()-> getLocalPlayer().isInCombat() || !crab.exists() || crab.distance(getLocalPlayer()) <= 2 , 5000); } } Link to comment Share on other sites More sharing options...
Bladez 0 Author Share Posted April 3, 2020 9 minutes ago, Shy said: It doesn't show when you hover over it, but it does if you right click doesn't it. I haven't been there in a long time. Not sure if this will work as I don't have an account to test it. GameObject crab = getGameObjects().closest(gameObject -> gameObject != null && gameObject.getName().contains("Sandy rocks")); if (!getLocalPlayer().isInCombat() && crab != null && crab.exists() && crab.distance(getLocalPlayer()) > 2) { if (getWalking().walk(crab)) { sleepUntil(()-> getLocalPlayer().isInCombat() || !crab.exists() || crab.distance(getLocalPlayer()) <= 2 , 5000); } } Ok i tried doing it this way, trouble is i'm at rock crabs in rellekka and it completely ignores the Rock crabs which are shown as Rocks when you right click them and goes for the mining nodes nearby. GameObject crab = getGameObjects().closest(gameObject -> gameObject != null && gameObject.getName().contains("Rocks")); if (!getLocalPlayer().isInCombat() && crab != null && crab.exists() && crab.distance(getLocalPlayer()) > 2) { if (crab.interact()) { sleepUntil(()-> getLocalPlayer().isInCombat() || !crab.exists() || crab.distance(getLocalPlayer()) <= 2 , 5000); } } Link to comment Share on other sites More sharing options...
Shy 14 Share Posted April 3, 2020 (edited) Then define an area that doesn't include the mine south of rock crabs(I assume that's what you're talking about), and check if the Game Object is in that area as was previously recommended. Though I think another problem is that some rocks are just rocks at rock crabs if I remember correctly. GameObject crab = getGameObjects().closest(gameObject -> gameObject != null && gameObject.getName().contains("Rocks") && rockCrabArea.contains(gameObject) && !gameObject.hasAction("Mine")); Edited April 3, 2020 by Shy Link to comment Share on other sites More sharing options...
Bladez 0 Author Share Posted April 3, 2020 21 minutes ago, Shy said: Then define an area that doesn't include the mine south of rock crabs(I assume that's what you're talking about), and check if the Game Object is in that area as was previously recommended. Though I think another problem is that some rocks are just rocks at rock crabs if I remember correctly. GameObject crab = getGameObjects().closest(gameObject -> gameObject != null && gameObject.getName().contains("Rocks") && rockCrabArea.contains(gameObject) && !gameObject.hasAction("Mine")); still nothing, just stands there doing nothing now I'm stumped. GameObject crab = getGameObjects().closest(gameObject -> gameObject != null && gameObject.getName().contains("Rocks") && KILL_AREA.contains(gameObject) && !gameObject.hasAction("Mine")); if (!getLocalPlayer().isInCombat() && crab != null && crab.exists() && crab.distance(getLocalPlayer()) > 2 && KILL_AREA.contains(crab)) { if (crab.interact()) { sleepUntil(()-> getLocalPlayer().isInCombat() || !crab.exists() || crab.distance(getLocalPlayer()) <= 2 , 5000); } } Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now