- Joined
- Jan 8, 2015
- Messages
- 1,427
- Thread Author
- #1
Started with setting up IntelliJ by following the simple Setting up IntelliJ for RuneMate guide made by @Viewer.
Source code so far: https://bitbucket.org/Erikdekamps/geashawscripts/
Source code so far: https://bitbucket.org/Erikdekamps/geashawscripts/
Code:
package com.runemate.geashawscripts.makeleather;
//Imports are all the classes that we are going to use methods from
import com.runemate.game.api.client.paint.PaintListener;
import com.runemate.game.api.hybrid.RuneScape;
import com.runemate.game.api.hybrid.input.Keyboard;
import com.runemate.game.api.hybrid.local.hud.interfaces.*;
import com.runemate.game.api.rs3.local.hud.interfaces.eoc.ActionBar;
import com.runemate.game.api.rs3.local.hud.interfaces.eoc.SlotAction;
import com.runemate.game.api.script.Execution;
import com.runemate.game.api.script.framework.LoopingScript;
import java.awt.*;
public class autotanner extends LoopingScript implements PaintListener {
private final int MAKE_LEATHER_ID = 2150, FIRE_STAFF = 1387;
final String HIDE = "Cowhide", TANNED_HIDE = "Leather";
@Override
public void onStart(String... args) {
setLoopDelay(100, 200);
}
@Override
public void onLoop() {
// Check if the user is logged in.
if (RuneScape.isLoggedIn()) {
if (runesInInventory() && staffEquiped()) {
// Checking which state of the script we're in.
if (gotHides() && !gotLeather()) {
if (Bank.isOpen()) {
Bank.close();
} else {
if (interfaceIsVisible()) {
pressSpacebar();
} else {
if (spellSelected()) {
clickHide();
} else {
selectSpell();
}
}
}
} else if (gotLeather() && !gotHides()) {
if (Bank.isOpen()) {
depositLeather();
} else {
if (Bank.open()) {
Execution.delayUntil(() -> Bank.isOpen(), 500);
}
}
} else {
if (Bank.isOpen()) {
withdrawHides();
}
}
}
}
}
/**
* @return Whether or not you have a staff of fire equiped.
*/
private boolean staffEquiped() {
return Equipment.getItemIn(Equipment.Slot.WEAPON).getId() == FIRE_STAFF ? true : false;
}
/**
* @return Whether or not you have the body & astral runes in your inventory.
*/
private boolean runesInInventory() {
return Inventory.containsAllOf("Body rune") && Inventory.containsAllOf("Astral rune") ? true : false;
}
/**
* @return Whether or not the spell is selected.
*/
public boolean spellSelected() {
SlotAction action = ActionBar.getFirstAction(MAKE_LEATHER_ID);
if (action != null) {
if (action.isSelected()) {
return true;
} else {
Execution.delayUntil(() -> action.isSelected(), 500);
}
}
return false;
}
/**
* @return Whether or not the interface with the "Tan" button is not null and visible.
*/
public boolean interfaceIsVisible() {
InterfaceComponent tanButton = Interfaces.getAt(1370, 38);
if (tanButton != null) {
if (tanButton.isVisible()) {
return true;
}
}
return false;
}
/**
* @return Whether or not the inventory contains green dragon hides.
*/
private boolean gotHides() {
return (Inventory.contains(HIDE) && Inventory.getQuantity(HIDE) == 25);
}
/**
* @return Whether or not the inventory contains green dragon leather.
*/
private boolean gotLeather() {
return (Inventory.contains(TANNED_HIDE) && Inventory.getQuantity(TANNED_HIDE) == 25);
}
/**
* Used to select the Make Leather spell from the ability bar.
*/
private boolean selectSpell() {
SlotAction action = ActionBar.getFirstAction(MAKE_LEATHER_ID);
if (action != null) {
if (Keyboard.typeKey(action.getSlot().getKeyBind())) {
if (!action.isSelected()) {
Execution.delayUntil(() -> action.isSelected(), 500);
}
debug("Selecting spell from ability bar.");
return true;
}
}
return false;
}
/**
* Presses space bar.
*/
private boolean pressSpacebar() {
if (Keyboard.typeKey(" ")) {
debug("Pressing spacebar to tan hides.");
if (interfaceIsVisible()) {
Execution.delayUntil(() -> !interfaceIsVisible(), 1000);
}
return true;
}
return false;
}
/**
* Used to click the dragon hide in inventory
* when the Make Leather spell is activated.
*/
private boolean clickHide() {
final SpriteItem hide = Inventory.getItems(HIDE).first();
if (hide != null) {
if (hide.interact("Cast")) {
debug("Clicking Make Leather on the hide.");
Execution.delayUntil(() -> interfaceIsVisible(), 1000, 2000);
}
return true;
}
return false;
}
/**
* Used to deposit leather into bank.
*/
private boolean depositLeather() {
if (Bank.deposit(TANNED_HIDE, 0)) {
debug("Depositing the tanned hides.");
Execution.delayUntil(() -> !gotLeather(), 1000);
return true;
}
return false;
}
/**
* Used to withdraw hides from bank.
*/
private boolean withdrawHides() {
if (Bank.withdraw(HIDE, 25)) {
debug("Withdrawing hides.");
if (!gotHides()) {
Execution.delayUntil(() -> gotHides(), 1000);
}
return true;
}
return false;
}
/**
* Used to replace System.out.println(text);
*
* @param text The text to send to the console.
*/
private void debug(String text) {
System.out.println(text);
}
@Override
public void onPaint(final Graphics2D g) {
}
}
Last edited: