rcrd Posted June 21, 2017 Share Posted June 21, 2017 (edited) EDIT: Only thing left now! Error 4) Not exactly an error, but I've noticed that hover() has a tendency to hover the trees in a way that are not very humanlike (it seems to love to hover the edges of trunk of the tree and it aso hovers through other trees). Is there anyway I can force it to hover the way I want? Hello. I'm rcrd, new to scripting and while trying to make my first attempt at a WCer, I've came across a couple of bugs that I can't seem to be able to fix by myself. Fixed Error 1) by doing this: else if(!myPlayer().isAnimating() || currentTree == null || (currentTree != null && !currentTree.exists())) { return State.WOODCUTTING; } It was a matter of the script trying to check if the tree existed on the first attempt and the currentTree value was null before chop() ran for the first time. Error 1) If I start the script and the player is already chopping down a tree (basically if he's doing the chopping animation), I get a NullPointer thrown by the getState function. Corresponding snippet: private State getState() { if(currentLevel == 0 || skills.getStatic(Skill.WOODCUTTING) > currentLevel) { return State.SETTINGS; } if(myPlayer().isUnderAttack()) { return State.ANTIATTACK; } else if(inventory.isFull()) { return State.BANKING; } else if(!currentArea.contains(myPosition())) { return State.WALKING; } else if(!myPlayer().isAnimating() || !currentTree.exists()) { return State.WOODCUTTING; } else { return State.ANTIBAN; } } @Override public int onLoop() throws InterruptedException { switch(getState()) { case SETTINGS: settingsFinder(); break; case ANTIATTACK: runAway(); break; case BANKING: bank(); break; case WALKING: walk(); break; case WOODCUTTING: chop(); break; case ANTIBAN: antiBan(); break; } return random(50, 200); } Fixed Error 2) by doing this: else if(r >= 680 && r < 685){ log("Antiban, Reporting"); Player cPlayer = players.closest(cp -> !cp.getName().equals("Ruffler")); if(cPlayer != null && !cPlayer.isVisible()) { camera.toEntity(cPlayer); } if(cPlayer != null && cPlayer.isVisible()) { Rectangle rect = null; cPlayer.interact("Report"); sleep(random(1111, 4444)); RS2Widget macroReport = getWidgets().getWidgetContainingText("Macroing or use of bots"); if(macroReport != null) { rect = macroReport.getRectangle(); if (rect != null) { mouse.click(new RectangleDestination(bot, rect)); } else { log("Couldn't close, we fucked!"); } } } sleep(random(111, 444)); } After a lot of searching on the forums, found a post by Token which helped a lot. Seems to work decent enough. Error 2) Certain widgets are giving me some issues. More specifically the various report options, where the bot doesn't feel like clicking them. I've "solved" it by using mouse.click, but I'd rather do it right if possible. else if(r >= 680 && r < 685){ log("Antiban, Reporting"); Player cPlayer = players.closest(cp -> !cp.getName().equals("Ruffler")); if(cPlayer != null && !cPlayer.isVisible()) { camera.toEntity(cPlayer); } if(cPlayer != null && cPlayer.isVisible()) { cPlayer.interact("Report"); sleep(random(1111, 4444)); RS2Widget macroReport = getWidgets().get(553, 9, 18); if (macroReport != null) { macroReport.interact("Send report"); } } } Fixed Error 3). My chop() function was only checking if the tree existed, I forgot to make a check for the player animation there as well. So until the currentTree stopped existing, it did nothing. Works fine now! Error 3) The one issue I haven't found a workaround for is the following: else if(r >= 680 && r < 685){ log("Antiban, Reporting"); Player cPlayer = players.closest(cp -> !cp.getName().equals("Ruffler")); if(cPlayer != null && !cPlayer.isVisible()) { camera.toEntity(cPlayer); } if(cPlayer != null && cPlayer.isVisible()) { cPlayer.interact("Report"); sleep(random(1111, 4444)); mouse.click(random(50, 160), random(281, 291), false); sleep(random(1111, 4444)); chop(); } } - Bot is chopping fine; - Executes every other antiban code without any issue and returns to the loop. - Unless it goes to the piece of code from above. If it does, it gets stuck there after doing everything. I even added that "chop()" to try and force it to unstuck itself, but it didn't work. It simply reports the player and then just sits there waiting. I seriously have no clue why it does this. If you guys need more code to check it, just warn me. I'm gonna end up releasing this for free anyway, I just want to get it better before I do. Thanks in advance, rcrd Edited June 21, 2017 by rcrd Quote Link to comment Share on other sites More sharing options...
Alek Posted June 22, 2017 Share Posted June 22, 2017 You spent a lot of time on ridiculous antiban and not a lot of time on solid logic. Remove all of the bullshit antiban and I'll look it over when I get a chance, if you're still having the issue. 2 Quote Link to comment Share on other sites More sharing options...
Muffins Posted June 22, 2017 Share Posted June 22, 2017 (edited) 2 minutes ago, Alek said: You spent a lot of time on ridiculous antiban and not a lot of time on solid logic. Remove all of the bullshit antiban and I'll look it over when I get a chance, if you're still having the issue. b-b-b-but antiban helps reduce bans! Edited June 22, 2017 by Muffins Quote Link to comment Share on other sites More sharing options...
Alek Posted June 22, 2017 Share Posted June 22, 2017 Just now, Muffins said: b-b-b-but antiban helps reduce bans! Get back in the Chatbox. 3 Quote Link to comment Share on other sites More sharing options...
Juggles Posted June 22, 2017 Share Posted June 22, 2017 You put so much useless code in there Quote Link to comment Share on other sites More sharing options...
Muffins Posted June 22, 2017 Share Posted June 22, 2017 (edited) 5 minutes ago, Alek said: Get back in the Chatbox. yes father please help me he beats me every night with a laptop cord and makes me listen to Romanian house music 6 minutes ago, Juggles said: You put so much useless code in there GET BACK TO STUDYING JOEY Edited June 22, 2017 by Muffins 1 Quote Link to comment Share on other sites More sharing options...
rcrd Posted June 22, 2017 Author Share Posted June 22, 2017 (edited) 46 minutes ago, Alek said: You spent a lot of time on ridiculous antiban and not a lot of time on solid logic. Remove all of the bullshit antiban and I'll look it over when I get a chance, if you're still having the issue. Yeah, I wasted a crapload of time on mostly useless antiban, but it was useful to learn how most stuff works. I've solved pretty much every bug I had though, I was just wondering if there was any way I could change the behavior of the hover() method or if the only way to do that would be to use mouse.move? Also, I'll probably be done with the initial "release" of this later today or tomorrow at most, just got to add the rest of the F2P spots, improve my hovering and chopping methods a bit and do a simple GUI. I'd be glad if you could take a quick glance at the code after that, as I'm sure there are loads of rookies mistakes there. 45 minutes ago, Muffins said: b-b-b-but antiban helps reduce bans! I like the placebo, sue me. 44 minutes ago, Juggles said: You put so much useless code in there Quite possible, it's literally my first actual attempt at scripting, but where exactly? Also, I would ignore the original snippets, if the current ones are bad, the old ones are terrible. Edited June 22, 2017 by rcrd Quote Link to comment Share on other sites More sharing options...
Explv Posted June 22, 2017 Share Posted June 22, 2017 15 minutes ago, rcrd said: I've solved pretty much every bug I had though, I was just wondering if there was any way I could change the behavior of the hover() method or if the only way to do that would be to use mouse.move? Write your own hover method Quote Link to comment Share on other sites More sharing options...
rcrd Posted June 22, 2017 Author Share Posted June 22, 2017 18 minutes ago, Explv said: Write your own hover method Figured that was the only way. That's probably a bit too much for me right now, but I'll give it a shot as soon as I fix the easier issues. Thanks! Quote Link to comment Share on other sites More sharing options...