Jump to content

Need help with a couple of bugs


rcrd

Recommended Posts

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 by rcrd
Link to comment
Share on other sites

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 by Muffins
Link to comment
Share on other sites

5 minutes ago, Alek said:

Get back in the Chatbox.

yes father :feels: 

 

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 by Muffins
  • Like 1
Link to comment
Share on other sites

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 by rcrd
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...