Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package scripts.abyssCrafterV2;
- import org.tribot.api.Clicking;
- import org.tribot.api.General;
- import org.tribot.api.input.Mouse;
- import org.tribot.api.interfaces.Positionable;
- import org.tribot.api.types.generic.Condition;
- import org.tribot.api2007.Banking;
- import org.tribot.api2007.Constants;
- import org.tribot.api2007.Equipment;
- import org.tribot.api2007.Game;
- import org.tribot.api2007.GameTab;
- import org.tribot.api2007.Interfaces;
- import org.tribot.api2007.Inventory;
- import org.tribot.api2007.Magic;
- import org.tribot.api2007.Objects;
- import org.tribot.api2007.PathFinding;
- import org.tribot.api2007.Skills;
- import org.tribot.api2007.Walking;
- import org.tribot.api2007.WebWalking;
- import org.tribot.api2007.GameTab.TABS;
- import org.tribot.api2007.Skills.SKILLS;
- import org.tribot.api2007.ext.Filters;
- import org.tribot.api2007.types.RSInterface;
- import org.tribot.api2007.types.RSInterfaceChild;
- import org.tribot.api2007.types.RSObject;
- import org.tribot.api2007.types.RSTile;
- import org.tribot.api2007.util.DPathNavigator;
- import org.tribot.script.Script;
- public class Main extends Script {
- public static boolean running;
- // *****userSet***** \\
- public static int SAFE_HEALTH = 0;
- public static int FOOD_HEAL_AMT = 0;
- public static int USERSET_DRINK_POINT;
- public static String FOOD_NAME;
- public static String ESSENCE_TYPE = "Pure essence";
- public static String ENERGY_ITEM;
- public static String RUNE_TYPE;
- public static final String[] ALTAR_NAMES = { "Altar" };
- public static boolean usingEmergencyTeleport = false;
- public static boolean usingEnergyPotion = false;
- public static boolean usingMountedGlory = false;
- // *****userSetEnd***** \\
- private final RSTile[] TO_WILD_DITCH = {
- new RSTile(3094, 3493, 0), new RSTile(3094, 3496, 0), new RSTile(3093, 3498, 0),
- new RSTile(3093, 3500, 0), new RSTile(3096, 3500, 0), new RSTile(3097, 3501, 0),
- new RSTile(3099, 3503, 0), new RSTile(3101, 3505, 0), new RSTile(3103, 3507, 0),
- new RSTile(3103, 3508, 0), new RSTile(3102, 3510, 0), new RSTile(3102, 3513, 0),
- new RSTile(3102, 3515, 0), new RSTile(3102, 3517, 0), new RSTile(3103, 3520, 0)
- };
- private final RSTile[] TO_ZAMMY_MAGE = {
- new RSTile(3103, 3524, 0), new RSTile(3103, 3527, 0), new RSTile(3104, 3530, 0),
- new RSTile(3106, 3533, 0), new RSTile(3105, 3538, 0), new RSTile(3105, 3540, 0),
- new RSTile(3105, 3542, 0), new RSTile(3105, 3545, 0), new RSTile(3105, 3548, 0),
- new RSTile(3105, 3551, 0), new RSTile(3105, 3554, 0), new RSTile(3104, 3557, 0),
- new RSTile(3105, 3558, 0)
- };
- public static String[] ENERGY_ITEMS = {
- "Strange fruit", "Super energy potion (4)", "Super energy potion (4)",
- "Super energy potion (4)", "Super energy potion (4)", "Energy potion (4)",
- "Energy potion (3)", "Energy potion (2)", "Energy potion (1)"
- };
- public final static String[] GLORY = {
- "Amulet of glory(4)", "Amulet of glory(3)",
- "Amulet of glory(2)", "Amulet of glory(1)"
- };
- public final String[] ROD = {
- "Ring of dueling(8)", "Ring of dueling(7)",
- "Ring of dueling(6)", "Ring of dueling(5)",
- "Ring of dueling(4)", "Ring of dueling(3)",
- "Ring of dueling(2)", "Ring of dueling(1)"
- };
- public final static String[] GAMES_NECKLACE = {
- "Games necklace(8)", "Games necklace(7)",
- "Games necklace(6)", "Games necklace(5)",
- "Games necklace(4)", "Games necklace(3)",
- "Games necklace(2)", "Games necklace(1)"
- };
- public static final String[] POUCHES = {
- "Giant pouch", "Large pouch",
- "Medium pouch", "Small pouch"
- };
- private String[] DEGRADED_POUCHES = {
- }; //TODO
- public final static String[] TELE_TABS = {
- "Lumbridge teleport", "Varrock teleport",
- "Falador teleport", "Camelot teleport"
- };
- private final int POUCH_SETTING = 486;
- private final int SMALL_FILLED_ID = 1073741827;
- private final int MED_FILLED_ID = 1073741875;
- private final int LRG_FILLED_ID = 1073746483;
- private final int GIANT_FILLED_ID = 0;
- public static Area abyss = new Area(3000, 3100, 4804, 4900);
- public static Area abyssInnerCircle = new Area(3022, 3056, 4815, 4848);
- public static Area edgeville = new Area(3082, 3128, 3483, 3520);
- public static Area wild = new Area(3066, 3143, 3523, 4000);
- public static Area house = new Area(7000, 8000, 7000, 8000);
- public static boolean GUI_COMPLETE;
- enum STATE {
- CRAFTING,
- ENTERING_RIFT,
- FIND_RIFT,
- FINDING_SHORTCUT,
- GEARING_UP,
- OPENING_BANK,
- PASSING_DITCH,
- RECHARGING_POUCHES,
- TELEPORTING,
- TELEPORT_ZAMORAK_MAGE,
- TO_ZAMORAK_MAGE,
- TO_DITCH,
- TO_ABYSS,
- USING_SHORTCUT,
- WAIT,
- }
- private String getRift() {
- switch (RUNE_TYPE) {
- case "Air rune" :
- return "Air rift";
- case "Mind rune" :
- return "Mind rift";
- case "Body rune" :
- return "Body rift";
- case "Earth rune" :
- return "Earth rift";
- case "Fire rune" :
- return "Fire rift";
- case "Blood rune" :
- return "Blood rift";
- case "Cosmic rune" :
- return "Cosmic rift";
- case "Nature rune" :
- return "Nature rift";
- case "Chaos rune" :
- return "Chaos rift";
- case "Law rune" :
- return "Law rift";
- case "Death rune" :
- return "Death rift";
- case "Water rune" :
- return "Water rift";
- case "Soul rune" :
- return "Soul rift";
- }
- return null;
- }
- private String getAction() {
- if (Equipment.find(Constants.IDs.Items.hatchets).length > 0 ||Inventory.find(Constants.IDs.Items.hatchets).length > 0) {
- return "Chop";
- }
- else if (Equipment.find(Constants.IDs.Items.pickaxes).length > 0 || Inventory.find(Constants.IDs.Items.pickaxes).length > 0) {
- return "Mine";
- }
- else if (Inventory.find("Tinderbox").length > 0) {
- return "Burn";
- }
- else if (Skills.getActualLevel(SKILLS.THIEVING) >= 20) {
- return "Distract";
- }
- return null;
- }
- public static int inventorySpace() {
- return 28 - Inventory.getAll().length;
- }
- public static int getFoodCount() {
- return (Skills.getActualLevel(SKILLS.HITPOINTS)
- - Skills.getCurrentLevel(SKILLS.HITPOINTS)) / FOOD_HEAL_AMT;
- }
- private RSObject getValidShortcut() {
- RSObject[] s = Objects.findNearest(200, Filters.Objects.actionsContains(getAction()));
- return s.length > 0 ? s[0] : null;
- }
- private STATE getState() {
- if (canCraft()) {
- if (edgeville.inArea()) {
- return STATE.PASSING_DITCH;
- }
- else if (wild.inArea()) {
- return STATE.TO_ABYSS;
- }
- else if (abyss.inArea()) {
- if (!abyssInnerCircle.inArea()) {
- if(getValidShortcut() != null && getValidShortcut().isOnScreen()){
- return STATE.USING_SHORTCUT;
- }
- else if(getValidShortcut() != null) {
- return STATE.FINDING_SHORTCUT;
- }
- }
- else if(Inventory.find(DEGRADED_POUCHES).length > 0){
- return STATE.RECHARGING_POUCHES;
- }
- else if (canSeeTeleporter()) {
- return STATE.ENTERING_RIFT;
- }
- else {
- return STATE.FIND_RIFT;
- }
- }
- else if (atAltar()) {
- return STATE.CRAFTING;
- }
- }
- else if (!Banking.isInBank()) {
- return STATE.TELEPORTING;
- }
- else if(!Banking.isBankScreenOpen()){
- return STATE.OPENING_BANK;
- }
- else {
- return STATE.GEARING_UP;
- }
- return STATE.WAIT;
- }
- private void GUI() {
- new GUI();
- while(!GUI_COMPLETE){
- sleep(100);
- }
- }
- @Override
- public void run() {
- GUI();
- ABC abc = new ABC();
- while (running) {
- abc.start();
- Mouse.setSpeed(General.random(135, 165));
- switch (getState()){
- case CRAFTING:
- craftRunes();
- break;
- case ENTERING_RIFT:
- DezUtils.interactObject(getRift(), null, 10, new Condition(){
- @Override
- public boolean active() {
- return Objects.find(20, "Altar").length > 0;
- }
- }, General.random(4300, 5300));
- break;
- case PASSING_DITCH:
- DezUtils.interactObject("Wilderness ditch", null, 10, new Condition(){
- @Override
- public boolean active() {
- return wild.inArea();
- }
- }, General.random(2300, 3300));
- break;
- case USING_SHORTCUT:
- DezUtils.interactObject(getRift(), null, 10, new Condition(){
- @Override
- public boolean active() {
- return abyssInnerCircle.inArea();
- }
- }, General.random(300, 500));
- break;
- case TELEPORT_ZAMORAK_MAGE:
- DezUtils.interactNpc("Mage of Zamorak", "Travel", new Condition() {
- @Override
- public boolean active() {
- return abyss.inArea();
- }
- }, General.random(2300, 4300));
- break;
- case TO_DITCH:
- DezUtils.takePath(TO_WILD_DITCH);
- break;
- case TO_ZAMORAK_MAGE:
- DezUtils.takePath(TO_ZAMMY_MAGE);
- break;
- case FINDING_SHORTCUT:
- findShortcut(getValidShortcut());
- break;
- case FIND_RIFT:
- findRift(Objects.findNearest(100, getRift()));
- break;
- case GEARING_UP:
- CharacterPreparation.start();
- break;
- case RECHARGING_POUCHES:
- rechargePouches();
- break;
- case TELEPORTING:
- toBank();
- break;
- case WAIT:
- sleep(900);
- break;
- default:
- break;
- }
- sleep(400, 600);
- }
- }
- private void craftRunes() {
- final int originalAmount = Inventory.find(RUNE_TYPE).length;
- if(Inventory.find(ESSENCE_TYPE).length < 1 && pouchesFilled()){
- emptyPouches();
- }
- else {
- DezUtils.interactObject("Altar", null, 20, new Condition(){
- @Override
- public boolean active() {
- return Inventory.find(RUNE_TYPE).length > originalAmount;
- }
- }, General.random(3300, 4700));
- }
- }
- private void emptyPouches() {
- if(Inventory.find(POUCHES[0]).length > 0){
- if(Game.getSetting(POUCH_SETTING) == GIANT_FILLED_ID){
- if(Clicking.click("Empty", Inventory.find(POUCHES[0]))){
- sleep(1200, 1900);
- }
- }
- }
- if(Inventory.find(POUCHES[1]).length > 0){
- if(Game.getSetting(POUCH_SETTING) == LRG_FILLED_ID){
- if(Clicking.click("Empty", Inventory.find(POUCHES[1]))){
- sleep(1200, 1900);
- }
- }
- }
- if(Inventory.find(POUCHES[2]).length > 0){
- if(Game.getSetting(POUCH_SETTING) == MED_FILLED_ID){
- if(Clicking.click("Empty", Inventory.find(POUCHES[2]))){
- sleep(1200, 1900);
- }
- }
- }
- if(Inventory.find(POUCHES[3]).length > 0){
- if(Game.getSetting(POUCH_SETTING) == SMALL_FILLED_ID){
- if(Clicking.click("Empty", Inventory.find(POUCHES[3]))){
- sleep(1200, 1900);
- }
- }
- }
- }
- private void rechargePouches() {
- if (!chatting()) {
- DezUtils.interactNpc("Dark mage", "Repairs", new Condition() {
- @Override
- public boolean active() {
- return chatting();
- }
- }, General.random(1800, 2200));
- }
- else {
- clickDialouge();
- }
- }
- private void clickDialouge() {
- //*
- /* Searches through all interfaces to determine
- * what option to click, and repairs the pouch
- */
- RSInterfaceChild[][] chat = {
- Interfaces.get(242).getChildren(), Interfaces.get(64).getChildren()
- };
- for (RSInterfaceChild[] i : chat) {
- if (i != null) {
- for (RSInterface t : i) {
- if (t.getText().contains("continue")) {
- if (Clicking.click(t)){
- break;
- }
- }
- }
- }
- }
- }
- private void findRift(RSObject[] rift) {
- //*
- /* attempts to traverse to a valid teleport rift
- */
- if (rift.length > 0) {
- if (Walking.walkPath(new DPathNavigator().findPath(rift[0]))) {
- sleep(1400, 1600);
- }
- }
- }
- private void findShortcut(RSObject shortcut) {
- //*
- /* attempts to traverse to a valid shortcut
- */
- if(shortcut != null){
- if (PathFinding.aStarWalk(shortcut.getPosition())){
- sleep(400, 700);
- }
- }
- }
- private void toBank() {
- //*
- /* Gets to bank based on the users banking desire
- */
- if (usingMountedGlory) {
- if (!house.inArea()) {
- DezUtils.useTeleportTab("Teleport to house");
- }
- else {
- HouseNavigator.traverseToDestination("Amulet of Glory");
- }
- }
- else if (wild.inArea() || abyss.inArea() || Objects.find(20, "Altar").length > 0) {
- teleportOut();
- }
- else if (!Banking.isInBank() && WebWalking.walkToBank()) {
- sleep(2400, 3700);
- }
- }
- private void teleportOut() {
- //*
- /* Teleports out based on various available telly methods
- */
- if (Equipment.isEquipped(GLORY)) {
- DezUtils.useJewlery("Edgeville", GLORY);
- }
- else if (Equipment.isEquipped(ROD)) {
- DezUtils.useJewlery("Casle Wars", ROD);
- }
- else if(Inventory.find(TELE_TABS).length > 0){
- DezUtils.useTeleportTab();
- }
- else if (!abyss.inArea() && !wild.inArea() && GameTab.open(TABS.MAGIC)) {
- if (Magic.selectSpell("Lumbridge Home Teleport")) {
- sleep(15000, 21000);
- }
- }
- }
- private boolean canCraft() {
- // *
- /* Checks if our pouches are filled, our inventory is full
- * and our health is good. If we are at an altar it will return true
- * if there are pouches still filled, or essence in inventory.
- */
- return (Inventory.find(POUCHES).length > 0
- ? pouchesFilled() || (atAltar() && Inventory.find(ESSENCE_TYPE).length > 0)
- : true)
- &&
- (Banking.isInBank()
- ? Inventory.find(ESSENCE_TYPE).length >= Inventory.find(ESSENCE_TYPE).length + inventorySpace()
- : Inventory.find(ESSENCE_TYPE).length > 0 || (atAltar() && pouchesFilled()))
- &&
- (Skills.getCurrentLevel(SKILLS.HITPOINTS) >= SAFE_HEALTH);
- }
- public boolean pouchesFilled() {
- // *
- /* Determines if pouches are filled based off of game settings
- * I use ternary so this method will always pass if they are not using
- * pouches
- */
- return ((Inventory.find(POUCHES[3]).length > 0)
- ? Game.getSetting(POUCH_SETTING) >= SMALL_FILLED_ID : true)
- &&
- ((Inventory.find(POUCHES[2]).length > 0)
- ? Game.getSetting(POUCH_SETTING) >= MED_FILLED_ID : true)
- &&
- ((Inventory.find(POUCHES[1]).length > 0)
- ? Game.getSetting(POUCH_SETTING) >= LRG_FILLED_ID : true)
- &&
- ((Inventory.find(POUCHES[0]).length > 0)
- ? Game.getSetting(POUCH_SETTING) >= GIANT_FILLED_ID : true);
- }
- private boolean chatting() {
- //Chatting with darkmage pouch repair
- return Interfaces.isInterfaceValid(242) || Interfaces.isInterfaceValid(64)
- || Interfaces.isInterfaceValid(0); //TODO get all indicies
- }
- private boolean canSeeTeleporter() {
- RSObject[] altarTeleport = Objects.findNearest(10, getRift());
- return altarTeleport.length > 0 && altarTeleport[0].isOnScreen();
- }
- public static boolean needEnergyPotion() {
- return Game.getRunEnergy() <= USERSET_DRINK_POINT;
- }
- private boolean atAltar() {
- return Objects.find(10, ALTAR_NAMES).length > 0;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment