Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package scripts.abyssCrafter;
- import org.tribot.api.Clicking;
- import org.tribot.api.General;
- import org.tribot.api.input.Mouse;
- 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.GameTab.TABS;
- import org.tribot.api2007.Inventory;
- import org.tribot.api2007.Magic;
- import org.tribot.api2007.NPCs;
- import org.tribot.api2007.Objects;
- import org.tribot.api2007.PathFinding;
- import org.tribot.api2007.Player;
- import org.tribot.api2007.Skills;
- import org.tribot.api2007.Skills.SKILLS;
- import org.tribot.api2007.Walking;
- import org.tribot.api2007.WebWalking;
- import org.tribot.api2007.ext.Filters;
- import org.tribot.api2007.types.RSObject;
- import org.tribot.api2007.types.RSTile;
- import org.tribot.api2007.util.DPathNavigator;
- import org.tribot.script.Script;
- import org.tribot.script.ScriptManifest;
- @ScriptManifest(authors = { "Jdez" }, category = "Runecrafting", name = "Abyss aio")
- public class Crafter extends Script {
- // *****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;
- // *****userSetEnd***** \\
- public final static String[] BOOTH_NAMES
- = { "Bank booth", "Chest" };
- public final static String[] GLORY
- = { "Amulet of glory(4)", "Amulet of glory(3)",
- "Amulet of glory(2)", "Amulet of glory(1)", "Amulet of glory" };
- 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 = {};
- public final static String[] POUCHES
- = { "Giant pouch", "Large pouch",
- "Medium pouch", "Small pouch" };
- public final static String[] TELE_TABS
- = { "Lumbridge teleport", "Varrock teleport",
- "Falador teleport", "Camelot teleport"};
- public final static String FILL_POUCH = "Fill";
- private final String WILD_DITCH = "Wilderness ditch";
- private final String ZAMMY_MAGE = "Mage of Zamorak";
- private final String TRAVEL_OPTION = "Teleport";
- private final String EDGE_TELEPORT_OPTION = "Edgeville";
- private final String CWARS_TELEPORT_OPTION = "Castle wars";
- private final String TELE_HOME = "Lumbridge Home Teleport";
- private final String TINDERBOX = "Tinderbox";
- private final String CHOP = "Chop";
- private final String DISTRACT = "Distract";
- private final String SQUEEZE = "Squeeze through";
- private final String GO_THROUGH = "Go-through";
- private final String MINE = "Mine";
- private final String BURN = "Burn-down";
- private final RSTile TO_WILD_DITCH = new RSTile(3110, 3520, 0);
- private final RSTile TO_ZAMMY_MAGE_AREA = new RSTile(3105, 3557, 0);
- private final int DISTRACT_EYES_LEVEL = 20;
- public final static int SMALL_POUCH_SETTING = 486;
- public final static int MED_POUCH_SETTING = 486;
- public final static int LRG_POUCH_SETTING = 486;
- public final static int GIANT_POUCH_SETTING = 486;
- public final static int SMALL_FILLED_ID = 1073741827;
- public final static int MED_FILLED_ID = 1073741875;
- public final static int LRG_FILLED_ID = 1073746483;
- public final static int GIANT_FILLED_ID = 0;
- public static boolean running = true;
- public static boolean GUI_COMPLETE = false;
- private RSObject ourShortcut;
- private int BANK_MOUSE_SPEED = 10;
- @Override
- public void run() {
- GUI();
- while (running) {
- ABC.start();
- Mouse.setSpeed(General.random(105, 115));
- if (canCraft()) {
- //* Checks for if we have pouches
- /* and if they're filled,
- * our health is good
- * and we have essence in our inventory
- */
- if (inEdgeville()) {
- //**checks if in edgeville by co-ordinates & passes ditch**\\
- passWildDitch();
- }
- else if (inWild()) {
- //**Walks to zammy mage and teleports to abyss**\\
- toAbyss();
- }
- else if (atAbyss()) {
- if (!inAbyssR2()) {
- //**if in the first room,
- /* it will look for a shortcut
- * to use and use it **/
- if(canSeeShortcut()){
- useShortcut();
- }
- else {
- toValidShortcut();
- }
- }
- else if(needPouchRecharge()){
- rechargePouches();
- }
- else if (canSeeTeleporter()) {
- println("spotted rift");
- //**if in the second room,
- /* uses the specified teleporter**/
- enterTeleporter();
- }
- else {
- //**if in the second room,
- /* looks for our teleporter
- * and walks to it **/
- lookForTeleporter();
- }
- }
- else if (atAltar()) {
- craftRunes();
- }
- else {
- teleportOut();
- //*should teleport
- /*to edgeville no
- * matter what
- */
- }
- }
- else if (!atBank()) {
- toBank();
- }
- else if(!Banking.isBankScreenOpen()){
- if(Banking.openBank()){
- sleep(800, 1800);
- }
- }
- else {
- Mouse.setSpeed(Mouse.getSpeed() + BANK_MOUSE_SPEED);
- Banker.gearUp();
- }
- sleep(400, 600);
- }
- }
- private void rechargePouches() {
- // TODO Auto-generated method stub
- }
- private boolean needPouchRecharge() {
- // TODO Auto-generated method stub
- return false;
- }
- private void passWildDitch() {
- if (Objects.find(10, WILD_DITCH).length > 0) {
- if(!Player.isMoving()){
- useDitch();
- }
- }
- else {
- toWildDitch();
- }
- }
- private void useDitch() {
- if (Clicking.click(Objects.findNearest(10, WILD_DITCH))) {
- sleep(1400, 1600);
- }
- }
- private void toWildDitch() {
- if (WebWalking.walkTo(TO_WILD_DITCH)) {
- sleep(400, 1700);
- }
- }
- public static boolean inWild() {
- RSTile pos = Player.getRSPlayer().getPosition();
- return (pos.getY() >= 3523)
- && (pos.getX() >= 3066) && (pos.getX() <= 3143);
- }
- private void toAbyss() {
- if (NPCs.findNearest(ZAMMY_MAGE).length > 0
- &&!NPCs.findNearest(ZAMMY_MAGE)[0].isOnScreen()) {
- walkToAvoidingDeath(NPCs.findNearest(ZAMMY_MAGE)[0].getPosition()); //walks to mages position of we cannot see it
- }
- else if ((NPCs.findNearest(ZAMMY_MAGE).length > 0)
- && NPCs.findNearest(ZAMMY_MAGE)[0].isOnScreen()) {
- travelZammyMage();
- }
- else {
- walkToAvoidingDeath(TO_ZAMMY_MAGE_AREA);
- }
- }
- private void travelZammyMage() {
- if(NPCs.findNearest(ZAMMY_MAGE)[0].hover()){
- if(Game.getUptext().contains("Talk")){
- if (Clicking.click(TRAVEL_OPTION, NPCs.findNearest(ZAMMY_MAGE)[0])) {
- sleep(2100, 3600);
- }
- }
- }
- }
- private void walkToAvoidingDeath(RSTile pos) {
- if (WebWalking.walkTo(pos, new Condition(){
- @Override
- public boolean active() {
- return Skills.getCurrentLevel(SKILLS.HITPOINTS) <= SAFE_HEALTH;
- }
- }, 200)) {
- sleep(400, 600);
- }
- }
- private boolean inAbyssR2() {
- RSTile pos = Player.getRSPlayer().getPosition();
- return (pos.getX() > 3022) && (pos.getY() > 4815) && (pos.getX() < 3056) && (pos.getY() < 4848);
- }
- private String getTeleporterName() {
- 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 void enterTeleporter() {
- if (!Player.isMoving()) {
- if(Objects.findNearest(10, getTeleporterName())[0].hover()){
- if(Game.getUptext().contains(getTeleporterName())){
- if (Clicking.click(Objects.findNearest(10, getTeleporterName()))) {
- sleep(400, 600);
- }
- }
- }
- }
- }
- private void lookForTeleporter() {
- RSObject[] altarTeleport = Objects.findNearest(100, getTeleporterName());
- if (altarTeleport.length > 0) {
- if (Walking.walkPath(new DPathNavigator().findPath(altarTeleport[0]))) {
- sleep(400, 600);
- }
- }
- }
- private boolean canSeeTeleporter() {
- RSObject[] altarTeleport = Objects.findNearest(5, getTeleporterName());
- if (altarTeleport.length > 0) {
- if (altarTeleport[0].isOnScreen()) {
- return true;
- }
- }
- return false;
- }
- private void useShortcut() {
- String[] actions = {getAction(), SQUEEZE, GO_THROUGH};
- if (ourShortcut != null){
- if (ourShortcut.hover()) {
- for(String a: actions){
- if (Game.getUptext().contains(a)) {
- if (Clicking.click(ourShortcut)) {
- sleep(400, 900);
- }
- }
- }
- }
- }
- }
- private boolean canSeeShortcut() {
- //will not get here unless is successfully walks a path to the shortcut
- if(ourShortcut != null){
- if (ourShortcut.isOnScreen()) {
- General.println("see shortcut");
- return true;
- }
- }
- return false;
- }
- private void toValidShortcut() {
- RSObject[] shortcut = getValidShortcut();
- if (shortcut.length > 0) {
- RSTile shortcutPos = shortcut[0].getPosition();
- if (PathFinding.aStarWalk(shortcutPos)){
- sleep(400, 700);
- }
- }
- ourShortcut = shortcut[0];
- }
- private RSObject[] getValidShortcut() {
- return Objects.findNearest(200, Filters.Objects.actionsContains(getAction()));
- }
- private String getAction() {
- if (Equipment.find(Constants.IDs.Items.hatchets).length > 0) {
- return CHOP;
- } else if (Equipment.find(Constants.IDs.Items.pickaxes).length > 0) {
- return MINE;
- } else if (Inventory.find(TINDERBOX).length > 0) {
- return BURN;
- } else if (Skills.getActualLevel(SKILLS.THIEVING) >= DISTRACT_EYES_LEVEL) {
- return DISTRACT;
- }
- return "No option";
- }
- private void toBank() {
- if(Skills.getCurrentLevel(SKILLS.HITPOINTS) <= SAFE_HEALTH
- && usingEmergencyTeleport &&!atTeleportLocation()){
- if (Clicking.click(Inventory.find(TELE_TABS))){
- sleep(400, 900);
- }
- }
- else if (!atTeleportLocation()) {
- teleportOut();
- }
- else if (WebWalking.walkToBank()) {
- sleep(2400, 3700);
- }
- }
- private boolean atTeleportLocation() {
- return !inWild()
- &&!atAbyss()
- &&!atAltar();
- }
- private boolean inEdgeville() {
- RSTile pos = Player.getRSPlayer().getPosition();
- return (3082 <= pos.getX()) && (pos.getX() <= 3128)
- && (3483 <= pos.getY()) && (pos.getY() <= 3520);
- }
- private void teleportOut() {
- if (Equipment.isEquipped(GLORY)) {
- if(Banking.isBankScreenOpen()){
- Banking.close();
- }
- if (GameTab.open(TABS.EQUIPMENT)) {
- if (Clicking.click(EDGE_TELEPORT_OPTION, Equipment.find(GLORY))) {
- sleep(3400, 4200);
- }
- }
- }
- else if (Equipment.isEquipped(ROD)) {
- if (GameTab.open(TABS.EQUIPMENT)) {
- if (Clicking.click(CWARS_TELEPORT_OPTION, Equipment.find(ROD))) {
- sleep(3400, 4200);
- }
- }
- }
- else if(Inventory.find(TELE_TABS).length > 0){
- if(Clicking.click(Inventory.find(TELE_TABS))){
- sleep(3400, 4900);
- }
- }
- else if (GameTab.open(TABS.MAGIC)) {
- if (Magic.selectSpell(TELE_HOME)) {
- sleep(15000, 21000);
- }
- }
- }
- private boolean canCraft() {
- return (((Inventory.find(POUCHES).length > 0)
- ? Banker.pouchesFilled() : true)
- &&
- (Inventory.find(ESSENCE_TYPE).length
- >= Inventory.find(ESSENCE_TYPE).length
- + (28 - Inventory.getAll().length))
- &&
- (Skills.getCurrentLevel(SKILLS.HITPOINTS)
- >= SAFE_HEALTH))
- ||
- (atAltar()
- && ((Inventory.find(POUCHES).length > 0 && Banker.pouchesFilled())
- ||
- Inventory.find(ESSENCE_TYPE).length > 0)); //Dont think i need this
- }
- public static boolean needEnergyPotion() {
- return Game.getRunEnergy() <= USERSET_DRINK_POINT;
- }
- public static int inventorySpace() {
- return 28 - Inventory.getAll().length;
- }
- public static boolean atBank() {
- return Objects.find(10, BOOTH_NAMES).length > 0;
- }
- private boolean atAltar() {
- return Objects.find(10, ALTAR_NAMES).length > 0;
- }
- public static int getFoodCount() {
- return (Skills.getActualLevel(SKILLS.HITPOINTS)
- - Skills.getCurrentLevel(SKILLS.HITPOINTS)) / FOOD_HEAL_AMT;
- }
- public static boolean atAbyss() {
- RSTile pos = Player.getRSPlayer().getPosition();
- return (pos.getX() > 3000) && (pos.getY() > 4804)
- && (pos.getX() < 3100) && (pos.getY() < 4900);
- }
- private void craftRunes() {
- if(Objects.findNearest(20, ALTAR_NAMES).length > 0){
- if(!Objects.findNearest(20, ALTAR_NAMES)[0].isOnScreen()) {
- if (Walking.walkTo(Objects.findNearest(20, ALTAR_NAMES)[0])) { // may have to nullcheck
- sleep(800, 1800);
- }
- }
- else if(Inventory.find(ESSENCE_TYPE).length < 1
- && Inventory.find(POUCHES).length > 0
- && Banker.pouchesFilled()){
- emptyPouches();
- }
- else if (Clicking.click(Objects.findNearest(20, ALTAR_NAMES))) {
- sleep(2800, 4800);
- }
- }
- }
- private void emptyPouches() {
- if(Inventory.find(POUCHES[3]).length > 0){
- if(Game.getSetting(SMALL_POUCH_SETTING) == SMALL_FILLED_ID){
- if(Clicking.click("Empty", Inventory.find(POUCHES[3]))){
- sleep(1200, 1900);
- }
- }
- }
- else if(Inventory.find(POUCHES[2]).length > 0){
- if(Game.getSetting(MED_POUCH_SETTING) == MED_FILLED_ID){
- if(Clicking.click("Empty", Inventory.find(POUCHES[2]))){
- sleep(1200, 1900);
- }
- }
- }
- else if(Inventory.find(POUCHES[1]).length > 0){
- if(Game.getSetting(LRG_POUCH_SETTING) == LRG_FILLED_ID){
- if(Clicking.click("Empty", Inventory.find(POUCHES[1]))){
- sleep(1200, 1900);
- }
- }
- }
- else if(Inventory.find(POUCHES[0]).length > 0){
- if(Game.getSetting(GIANT_POUCH_SETTING) == GIANT_FILLED_ID){
- if(Clicking.click("Empty", Inventory.find(POUCHES[0]))){
- sleep(1200, 1900);
- }
- }
- }
- }
- private void GUI() {
- new GUI();
- while(!GUI_COMPLETE ){
- sleep(100);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment