Jump to content

Smoking rock detection


deathbydoob

Recommended Posts

 This is what Ive got working in one of my private scripts.

 

Ive been trying to figure out this for awhile now and have seen multiple topics on it but no solutions

 

Ive yet to test this extensively so Im not sure if it actually works on smoking rocks, but in theory it does.

Also this makes the bot choose a new rock if someone else steals your ore instead of standing around animating while the human player beats you to the next rock.

 

Edit: After a night of testing (9 hours) the bot broke one pickaxe so Im not sure whether the smoking rock is considered to still be the current rock. To further avoid this I added a check on the triangle count. Again in theory this will work.

 

Edit: The original code worked great but had the one bug where the player wouldnt move on from the smoking rock if there were no other ores spawned. I edited the code slightly to fix this and also removed tCount as it didnt do anything.

Will update when Ive had time to test.

//Global variables
RS2Object curRock = null;
int[] rockIds = {1111, 1112} //put the ids for the rock with ore in it here
//tCount is useless as the smoking rock is a new object
int[] tCount = {41, 56} //put the triangle count of the rocks you are mining here 


//if rock doesnt exist or we are done animating
//go find a new rock
if(!checkRock(curRock) || !player.isAnimating())
{
	RS2Object rock = closestObject(rockIds);
        if(rock != null)
	{
		rock.interact("Mine");
                //set the new rock to current rock
		curRock = rock;
	}
        else if(player.isAnimating()) 
        {
                //If there is no new rock we have to stop the player from mining
                //simply check if the player is still animating and walk to a position to stop mining
                walk(MINING_POSITION);
        }
	Thread.sleep(random(700, 900));
}

private boolean checkRock(RS2Object currentRock) 
{
	if(currentRock!=null)
	{
	        if(currentRock.exists())
		{
                     return true;
                }
	}
        return false;
}

 Happy botting!

Edited by deathbydoob
Link to comment
Share on other sites

I personally wouldn't check for animation this way because there might be loop in the animation and a break which causes the bot to think that it is done animating though it is only looping the animation. Now ofcourse the rock you are currently mining will probably still be the rock it sees as new closestObject but this does cause the script to click it again. 

  • Like 2
Link to comment
Share on other sites

I personally wouldn't check for animation this way because there might be loop in the animation and a break which causes the bot to think that it is done animating though it is only looping the animation. Now ofcourse the rock you are currently mining will probably still be the rock it sees as new closestObject but this does cause the script to click it again. 

 

This was my first thought so I left it out, although if it is left out occasionally the bot wont succesfully interact with the rock but the rock is there. Therefore the bot wont do anything so i just do a check so that if the player isnt doing anything then find a rock.

Also most humans will sometimes click the rock twice, I know i do when Im, and with the random delay, the bot will occasionally click the rock twice but not after it has started mining.

Link to comment
Share on other sites

How do you find the tcount of the rock you're doing? I'm just doing iron ore.

 

Set up a global integer called tCount or something and instantiate it to 0.

When you have your player interact with the rock use this code.

tCount = rock.getModel().getTriangleCount();

Then display that value in your paint and run your bot. Once he mines the different modeled rocks the paint will show you your tcount.

 

Take any default tCounts and toss them in an array and use the code from the original post

Link to comment
Share on other sites

Set up a global integer called tCount or something and instantiate it to 0.

When you have your player interact with the rock use this code.

tCount = rock.getModel().getTriangleCount();

Then display that value in your paint and run your bot. Once he mines the different modeled rocks the paint will show you your tcount.

 

Take any default tCounts and toss them in an array and use the code from the original post

 

I figured it out earlier and ran my script for 10 hours. Then my pickaxe broke. I ran it again for 30 minutes and it broke again.  It seems that the code doesn't work? The idea seems logical but in practice my pickaxes are still getting broken :/

Link to comment
Share on other sites

2 ways i can think of:

Parse Model Height (non smoking has the aprox y triangles of 90) so if model.height > normal height

Parse current ID, log the ID's on start in an array and then if the current interacting Id != logged ID's

 

How do you tell the current ID of the rock? I read that getFacingId() doesn't work for objects.

Link to comment
Share on other sites

Here's what I'm currently trying. I'll post back the results:

RS2Object rock = closestObject(GEM_ID);
			if (rock != null) {
				currrentRockID = rock.getId();
				if (!myPlayer().isAnimating()) {
						if (Arrays.binarySearch(GEM_ID, currrentRockID) != -1) {
								if (rock.interact("Mine"))
									sleep(random(1000, 1500));
									
						} else {
							traversePath(avoid, true);
							sleep(random(1500, 2500));
						}
				}
			}
Link to comment
Share on other sites

I don't think that's going to stop your player from keeping on mining while your rock changed in smoking rock.

 

Maybe you should try something with states: (I'm just writing this now and I never wrote a mining script so it could be wrong)

private Enum State { MINING,WAITING}
private State state = State.MINING;
private RS2Object currentRock = null;
private int rockId = <ROCK_ID>;// replace with your rock id
switch (state){
 case WAITING:
   if(currentRock.getId() == rockId){// currentRock still is normal rock (I don't know what to check for, could be id or modelHeight or something)
   // sleep or antiban or w/e
   }else{
    currentRock = null;
   state = State.MINING;
   }
break;
case MINING:
   currentRock = closestObject(rockId);
   if(currentRock!=null){
     currentRock.interact("Mine");
   }
break;
}
Link to comment
Share on other sites

 

I don't think that's going to stop your player from keeping on mining while your rock changed in smoking rock.

 

Maybe you should try something with states: (I'm just writing this now and I never wrote a mining script so it could be wrong)

private Enum State { MINING,WAITING}
private State state = State.MINING;
private RS2Object currentRock = null;
private int rockId = <ROCK_ID>;// replace with your rock id
switch (state){
 case WAITING:
   if(currentRock.getId() == rockId){// currentRock still is normal rock (I don't know what to check for, could be id or modelHeight or something)
   // sleep or antiban or w/e
   }else{
    currentRock = null;
   state = State.MINING;
   }
break;
case MINING:
   currentRock = closestObject(rockId);
   if(currentRock!=null){
     currentRock.interact("Mine");
   }
break;
}

 

Is there a way that I can define an RS2Object as the object (the rock) in front of me?

 

I think that I can make this work this way :

case MINE:
			RS2Object rock = closestObject(GEM_ID);
			int GemHeight = rock.getModel().getHeight();
			RS2Object facing = getFacingObject();
			int currentHeight = facing.getModel().getHeight();
			if (rock != null) {
				if ( GemHeight == currentHeight ) { 
					if (!myPlayer().isAnimating()) {
									if (rock.interact("Mine"))
										sleep(random(1000, 1500));
										
								
					}
				} else {
					traversePath(avoid, true);
					sleep(random(1500, 2500));
				}
			}
		break;

But I have to define

 

RS2Object facing = getFacingObject();

 

as obviously getFacingObject isn't real. Is there a method I can actually use that would do that? If not, I'll try your state switching idea.

 

 

Even if there isn't a prebuilt function for it, is there a way I could manually determine it?

Edited by lingoling
Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

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