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