Jump to content

Smoking Rock Detection


Swizzbeat

Recommended Posts

public boolean checkIfMiningSmokingRock() {
	if (myPlayer().isAnimating()) {
		RS2Object rock;
		Position myPosition = myPlayer().getPosition();
		switch (myPlayer().getRotation()) {
			case 0:       //SOUTH
				rock = getRockAtPosition(new Position(myPosition.getX(), myPosition.getY() - 1, 0));
				break;
			case 511:
			case 512:    //WEST
			case 513:
				rock = getRockAtPosition(new Position(myPosition.getX() - 1, myPosition.getY(), 0));
				break;
			case 1023:
			case 1024:    //NORTH
			case 1025:
				rock = getRockAtPosition(new Position(myPosition.getX(), myPosition.getY() + 1, 0));
				break;
			case 1535:
			case 1536:    //EAST
			case 1537:
				rock = getRockAtPosition(new Position(myPosition.getX() + 1, myPosition.getY(), 0));
				break;
		}
		return rock != null && !arrayContainsPrimitiveInt(MINABLE_ROCK_ID_ARRAY, rock.getId());    //method is not needed if the rock id's are stored in a list, #contains() would work fine
	}
	return false;
}

private RS2Object getRockAtPosition(Position position) {
	for (RS2Object current : client.getCurrentRegion().getObjects()) {
		if (current != null && current.getName().contains("Rock") && position.equals(current.getPosition())) {
			return current;
		}
	}
	return null;
}

private boolean arrayContainsPrimitiveInt(int[] array, int integer) {
	for (int current : array) {
		if (current == integer)
			return true;
	}
	return false;
}

FYI switch statement looks like that because when mining you're rotation isn't "exactly" what it's supposed to be and may be off by +- 1. This should give people a good idea on how to implement smoking rock detection into their own mining scripts.

Edited by Swizzbeat
  • Like 1
Link to comment
Share on other sites

Guest Apogee

thank you. Finally. Added it to my script, i'll be sure to credit.

Unsure of how to get it working, but at least i have somewhere to start now.

Link to comment
Share on other sites

Guest Apogee
public boolean checkIfMiningSmokingRock() {
	if (myPlayer().isAnimating()) {
		RS2Object rock;
		Position myPosition = myPlayer().getPosition();
		switch (myPlayer().getRotation()) {
			case 0:       //SOUTH
				rock = getRockAtPosition(new Position(myPosition.getX(), myPosition.getY() - 1, 0));
				break;
			case 511:
			case 512:    //WEST
			case 513:
				rock = getRockAtPosition(new Position(myPosition.getX() - 1, myPosition.getY(), 0));
				break;
			case 1023:
			case 1024:    //NORTH
			case 1025:
				rock = getRockAtPosition(new Position(myPosition.getX(), myPosition.getY() + 1, 0));
				break;
			case 1535:
			case 1536:    //EAST
			case 1537:
				rock = getRockAtPosition(new Position(myPosition.getX() + 1, myPosition.getY(), 0));
				break;
		}
		return rock != null && !arrayContainsPrimitiveInt(MINABLE_ROCK_ID_ARRAY, rock.getId());    //method is not needed if the rock id's are stored in a list, #contains() would work fine
	}
	return false;
}

private RS2Object getRockAtPosition(Position position) {
	for (RS2Object current : client.getCurrentRegion().getObjects()) {
		if (current != null && current.getName().contains("Rock") && position.equals(current.getPosition())) {
			return current;
		}
	}
	return null;
}

private boolean arrayContainsPrimitiveInt(int[] array, int integer) {
	for (int current : array) {
		if (current == integer)
			return true;
	}
	return false;
}

FYI switch statement looks like that because when mining you're rotation isn't "exactly" what it's supposed to be and may be off by +- 1. This should give people a good idea on how to implement smoking rock detection into their own mining scripts.

 

 

 

I implemented this, and changed the variables. What do i need to add into my loop to check if what it is mining is or isn't the rock?

 

Link to comment
Share on other sites

public boolean checkIfMiningSmokingRock() {
	if (myPlayer().isAnimating()) {
		RS2Object rock;
		Position myPosition = myPlayer().getPosition();
		switch (myPlayer().getRotation()) {
			case 0:       //SOUTH
				rock = getRockAtPosition(new Position(myPosition.getX(), myPosition.getY() - 1, 0));
				break;
			case 511:
			case 512:    //WEST
			case 513:
				rock = getRockAtPosition(new Position(myPosition.getX() - 1, myPosition.getY(), 0));
				break;
			case 1023:
			case 1024:    //NORTH
			case 1025:
				rock = getRockAtPosition(new Position(myPosition.getX(), myPosition.getY() + 1, 0));
				break;
			case 1535:
			case 1536:    //EAST
			case 1537:
				rock = getRockAtPosition(new Position(myPosition.getX() + 1, myPosition.getY(), 0));
				break;
		}
		return rock != null && !arrayContainsPrimitiveInt(MINABLE_ROCK_ID_ARRAY, rock.getId());    //method is not needed if the rock id's are stored in a list, #contains() would work fine
	}
	return false;
}

private RS2Object getRockAtPosition(Position position) {
	for (RS2Object current : client.getCurrentRegion().getObjects()) {
		if (current != null && current.getName().contains("Rock") && position.equals(current.getPosition())) {
			return current;
		}
	}
	return null;
}

private boolean arrayContainsPrimitiveInt(int[] array, int integer) {
	for (int current : array) {
		if (current == integer)
			return true;
	}
	return false;
}

FYI switch statement looks like that because when mining you're rotation isn't "exactly" what it's supposed to be and may be off by +- 1. This should give people a good idea on how to implement smoking rock detection into their own mining scripts.

 

I've tried to implement this - have I implemented it right? tongue.png

public boolean checkIfMiningSmokingRock() {
		if (myPlayer().isAnimating()) {
			RS2Object vein = closestObject(MINE_AREA, GEM_ID);
			;
			Position myPosition = myPlayer().getPosition();
			switch (myPlayer().getRotation()) {
			case 0: // SOUTH
				vein = getRockAtPosition(new Position(myPosition.getX(),
						myPosition.getY() - 1, 0));
				break;
			case 511:
			case 512: // WEST
			case 513:
				vein = getRockAtPosition(new Position(myPosition.getX() - 1,
						myPosition.getY(), 0));
				break;
			case 1023:
			case 1024: // NORTH
			case 1025:
				vein = getRockAtPosition(new Position(myPosition.getX(),
						myPosition.getY() + 1, 0));
				break;
			case 1535:
			case 1536: // EAST
			case 1537:
				vein = getRockAtPosition(new Position(myPosition.getX() + 1,
						myPosition.getY(), 0));
				break;
			}
			return vein != null
					&& !arrayContainsPrimitiveInt(GEM_ID, vein.getId());

			// method is not needed if the rock id's are stored in a list,
			// #contains() would work fine - swizz
		}
		return false;
	}

	private RS2Object getRockAtPosition(Position position) {
		for (RS2Object current : client.getCurrentRegion().getObjects()) {
			if (current != null && current.getName().contains("Rock")
					&& position.equals(current.getPosition())) {
				return current;
			}
		}
		return null;
	}

	private boolean arrayContainsPrimitiveInt(int[] array, int integer) {
		for (int current : array) {
			if (current == integer)
				return true;
		}
		return false;
	}

	// onLoop()
	@Override
	public int onLoop() throws InterruptedException {
		if (hopIfCrashed == 1) {
			crashManager();
		}
		while (GUI.isVisible()) {
			sleep(200);
		}
		sleep(200);
		if (GUI.getGaDicht()) {
			stop();
		} else {
			hopForRocks = GUI.hopForRocks;
			hopIfCrashed = GUI.hopIfCrashed;
			powermine = GUI.powermine;
			consoleInfo = GUI.consoleInfo;
			Antiban = GUI.Antiban;
		}
		t = new Timer(0);
		idleTimer();
		switch (getState()) {
		case MINE:
			AntiBan();
			RS2Object vein = closestObject(MINE_AREA, GEM_ID);
			if (!myPlayer().isAnimating()) {
				if (vein != null)
					if (vein.interact("Mine")) {
						sleep(random(300, 600));
						checkIfMiningSmokingRock();
					}

			}

			if (equipmentTab.isWieldingWeaponThatContains("Broken pickaxe")) {
				status = "Broken Pickaxe";
				sleep(random(400, 600));
				logoutTab.logOut();
				if (consoleInfo == 1) {
					log("[APA Shilo Miner] Logged out - Reason: Broken Pickaxe.");
				}
				stop();
			}
			if (vein == null) {
				status = "Waiting for rock";
				if (hopForRocks == 1) {
					worldSwitcher();
				}
				if (Antiban == 1) {
					AntiBan();
				}
			}
			break;

Thanks for the help smile.png

EDIT: Dang, doesn't work. must have screwed something up somewhere ^.^

Edited by Apaec
Link to comment
Share on other sites

I've always just checked entity height.

 

public boolean isRockSmoking(RS2Object r) {
  boolean ret = false;
  if (r.getModel().getHeight() > 150) {
    // rock is smoking
    ret = true;
  }
  return ret;
}

 

As dreamliner said, I'm pretty sure you can just do this via model height.

Hmm I never even thought of height, thanks. 

Link to comment
Share on other sites

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

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