joedezzy1

Untitled

Jul 30th, 2014
365
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 18.08 KB | None | 0 0
  1. package scripts.abyssCrafter;
  2.  
  3. import org.tribot.api.Clicking;
  4. import org.tribot.api.General;
  5. import org.tribot.api.input.Mouse;
  6. import org.tribot.api2007.Banking;
  7. import org.tribot.api2007.Camera;
  8. import org.tribot.api2007.Constants;
  9. import org.tribot.api2007.Equipment;
  10. import org.tribot.api2007.Game;
  11. import org.tribot.api2007.GameTab;
  12. import org.tribot.api2007.GameTab.TABS;
  13. import org.tribot.api2007.Inventory;
  14. import org.tribot.api2007.Magic;
  15. import org.tribot.api2007.NPCs;
  16. import org.tribot.api2007.Objects;
  17. import org.tribot.api2007.PathFinding;
  18. import org.tribot.api2007.Player;
  19. import org.tribot.api2007.Skills;
  20. import org.tribot.api2007.Skills.SKILLS;
  21. import org.tribot.api2007.Walking;
  22. import org.tribot.api2007.WebWalking;
  23. import org.tribot.api2007.ext.Filters;
  24. import org.tribot.api2007.types.RSObject;
  25. import org.tribot.api2007.types.RSTile;
  26. import org.tribot.api2007.util.DPathNavigator;
  27. import org.tribot.script.Script;
  28. import org.tribot.script.ScriptManifest;
  29.  
  30. @ScriptManifest(authors = { "Jdez" }, category = "Runecrafting", name = "Abyss aio")
  31. public class Crafter extends Script {
  32.  
  33.     // *****userSet***** \\
  34.     public static int SAFE_HEALTH   = 0;
  35.     public static int FOOD_HEAL_AMT = 0;
  36.     public static int USERSET_DRINK_POINT;
  37.     public static String FOOD_NAME;
  38.     public static String ESSENCE_TYPE  = "Pure essence";
  39.     public static String ENERGY_ITEM;
  40.     public static String RUNE_TYPE;
  41.     public static final String[] ALTAR_NAMES = { "Altar" };
  42.     public static boolean usingEmergencyTeleport = false;
  43.     public static boolean usingEnergyPotion = false;
  44.     // *****userSetEnd***** \\
  45.    
  46.     public static String[] ENERGY_ITEMS
  47.     = { "Strange fruit", "Super energy potion (4)", "Super energy potion (4)",
  48.             "Super energy potion (4)", "Super energy potion (4)", "Energy potion (4)",
  49.             "Energy potion (3)", "Energy potion (2)", "Energy potion (1)"};
  50.    
  51.     public final static String[] BOOTH_NAMES
  52.     = { "Bank booth", "Chest" };
  53.    
  54.     public final static String[] GLORY
  55.     = { "Amulet of glory(4)", "Amulet of glory(3)",
  56.             "Amulet of glory(2)", "Amulet of glory(1)" };
  57.    
  58.     public final String[] ROD = {
  59.         "Ring of dueling(8)", "Ring of dueling(7)",
  60.         "Ring of dueling(6)", "Ring of dueling(5)",
  61.         "Ring of dueling(4)", "Ring of dueling(3)",
  62.         "Ring of dueling(2)", "Ring of dueling(1)"
  63.     };
  64.    
  65.     public final static String[] GAMES_NECKLACE
  66.     = { "Games necklace(8)", "Games necklace(7)",
  67.         "Games necklace(6)", "Games necklace(5)",
  68.         "Games necklace(4)", "Games necklace(3)",
  69.         "Games necklace(2)", "Games necklace(1)"};
  70.    
  71.     public final static String[] POUCHES              
  72.     = { "Giant pouch", "Large pouch",
  73.             "Medium pouch", "Small pouch" };
  74.    
  75.     public final static String[] TELE_TABS            
  76.     = { "Lumbridge teleport", "Varrock teleport",
  77.             "Falador teleport", "Camelot teleport"};
  78.    
  79.     public  final static String   FILL_POUCH     = "Fill";
  80.     private final String   WILD_DITCH            = "Wilderness ditch";
  81.     private final String   ZAMMY_MAGE            = "Mage of Zamorak";
  82.     private final String   TRAVEL_OPTION         = "Teleport";
  83.     private final String   EDGE_TELEPORT_OPTION  = "Edgeville";
  84.     private final String   CWARS_TELEPORT_OPTION = "Castle wars";
  85.     private final String   TELE_HOME             = "Lumbridge Home Teleport";
  86.     private final String   TINDERBOX             = "Tinderbox";
  87.     private final String   CHOP          = "Chop";
  88.     private final String   DISTRACT          = "Distract";
  89.     private final String   MINE          = "Mine";
  90.     private final String   BURN          = "Burn-down";
  91.     private final RSTile   TO_WILD_DITCH         = new RSTile(3110, 3520, 0);
  92.     private final RSTile   TO_ZAMMY_MAGE_AREA    = new RSTile(3105, 3557, 0);
  93.     private final int      DISTRACT_EYES_LEVEL   = 20;    
  94.     public final static int  SMALL_POUCH_SETTING = 486;
  95.     public final static int  MED_POUCH_SETTING   = 486;
  96.     public final static int  LRG_POUCH_SETTING   = 486;
  97.     public final static int  GIANT_POUCH_SETTING = 486;
  98.     public final static int  SMALL_FILLED_ID     = 1073741827;
  99.     public final static int  MED_FILLED_ID       = 1073741875;
  100.     public final static int  LRG_FILLED_ID       = 1073746483;
  101.     public final static int  GIANT_FILLED_ID     = 0;
  102.    
  103.     public static boolean  running               = true;
  104.     public static boolean  GUI_COMPLETE          = false;
  105.     private int BANK_MOUSE_SPEED                 = 10;
  106.     private String DEGRADED_POUCHES;
  107.     private ABC abc;
  108.    
  109.     private STATE state;
  110.    
  111.     enum STATE {
  112.     CRAFTING,
  113.     ENTERING_RIFT,
  114.     FIND_RIFT,
  115.     FINDING_SHORTCUT,
  116.     GEARING_UP,
  117.     OPENING_BANK,
  118.     PASSING_DITCH,
  119.     RECHARGING_POUCHES,
  120.     TELEPORTING,
  121.     TO_ABYSS,
  122.     USING_SHORTCUT,
  123.     WAIT
  124.    }
  125.    
  126.    private STATE getState() {
  127.     if (canCraft()) {
  128.             println("We can craft");
  129.             //* Checks for if we have pouches
  130.             /* and if they're filled,
  131.              * our health is good
  132.              * and we have essence in our inventory
  133.              */      
  134.             if (inEdgeville()) {
  135.                 //**checks if in edgeville by co-ordinates & passes ditch**\\
  136.                 println("Passing wild ditch!");                
  137.                 return STATE.PASSING_DITCH;                  
  138.             }                
  139.             else if (inWild()) {
  140.                 //**Walks to zammy mage and teleports to abyss**\\
  141.                 return STATE.TO_ABYSS;                    
  142.             }                
  143.             else if (atAbyss()) {                  
  144.                 if (!inAbyssR2()) {
  145.                     //**if in the first room,
  146.                     /* it will look for a shortcut
  147.                      *  to use and use it **/                  
  148.                     if(getValidShortcut() != null && getValidShortcut().isOnScreen()){
  149.                     println("found shortcut, using it!");
  150.                     return STATE.USING_SHORTCUT;
  151.                     }                  
  152.                     else if(getValidShortcut() != null) {
  153.                         println("walking to shortcut!");
  154.                     return STATE.FINDING_SHORTCUT;
  155.                     }
  156.                 }
  157.                 else if(Inventory.find(DEGRADED_POUCHES).length > 0){
  158.                     return STATE.RECHARGING_POUCHES;                  
  159.                 }                    
  160.                 else if (canSeeTeleporter()) {
  161.                     println("spotted rift");
  162.                     //**if in the second room,
  163.                     /* uses the specified teleporter**/
  164.                     return STATE.ENTERING_RIFT;                      
  165.                 }                    
  166.                 else {
  167.                     //**if in the second room,
  168.                     /* looks for our teleporter
  169.                      * and walks to it **/
  170.                     return STATE.FIND_RIFT;
  171.                 }                  
  172.             }                
  173.             else if (atAltar()) {
  174.                 println("Crafting runes");                 
  175.                 return STATE.CRAFTING;                  
  176.             }                              
  177.         }            
  178.         else if (!atBank()) {
  179.             println("Banking, cannot craft anymore!");
  180.             return STATE.TELEPORTING;          
  181.         }          
  182.         else if(!Banking.isBankScreenOpen()){
  183.             return STATE.OPENING_BANK;             
  184.         }            
  185.         else {
  186.             return STATE.GEARING_UP;            
  187.         }    
  188.     return STATE.WAIT;
  189.     }
  190.  
  191.     @Override
  192.     public void run() {    
  193.         GUI();
  194.         abc = new ABC();
  195.         while (running) {
  196.             abc.start();           
  197.             Mouse.setSpeed(General.random(105, 115));
  198.            
  199.             state = getState();
  200.             switch (state){
  201.         case CRAFTING:
  202.         craftRunes();
  203.         break;
  204.         case ENTERING_RIFT:
  205.         enterTeleporter();
  206.         break;
  207.         case FINDING_SHORTCUT:
  208.         toValidShortcut(getValidShortcut());
  209.         break;
  210.         case FIND_RIFT:
  211.         lookForTeleporter();
  212.         break;
  213.         case GEARING_UP:
  214.         Mouse.setSpeed(Mouse.getSpeed() + BANK_MOUSE_SPEED);
  215.                 Banker.gearUp();
  216.         break;
  217.         case OPENING_BANK:
  218.         if(Banking.openBank()){
  219.                     sleep(800, 1800);
  220.                 }
  221.         break;
  222.         case PASSING_DITCH:
  223.         passWildDitch();
  224.         break;
  225.         case RECHARGING_POUCHES:
  226.         rechargePouches();
  227.         break;
  228.         case TELEPORTING:
  229.         toBank();
  230.         break;
  231.         case TO_ABYSS:
  232.         toAbyss();
  233.         break;
  234.         case USING_SHORTCUT:
  235.         Clicker.interactObject(getValidShortcut());
  236.         break;
  237.         case WAIT:
  238.                 sleep(800);
  239.         break;
  240.         default:
  241.         break;
  242.             }
  243.             sleep(400, 600);
  244.         }
  245.     }
  246.  
  247.     private void rechargePouches() {
  248.     RSNPC[] mage = NPCs.findNearest("Dark mage");
  249.     RSInterfaceChild[][] chat
  250.     = {Interfaces.get(242).getChildren(), Interfaces.get(64).getChildren()};
  251.     if (mage.length > 0 && mage[0].isOnScreen()) { 
  252.         for (RSInterfaceChild[] i : chat) {
  253.             if (i != null) {
  254.             for (RSInterface t : i) {
  255.             if (t.getText().contains("continue")) {
  256.                 break;
  257.             }
  258.             }
  259.         }
  260.         }
  261.     }
  262.     else if (PathFinding.aStarWalk(new RSTile(3039, 4835, 0))) {
  263.         General.sleep(1200, 1900);
  264.     }  
  265.     }
  266.  
  267.     private void passWildDitch() {
  268.     RSObject[] ditch = Objects.find(10, WILD_DITCH);   
  269.         if (ditch.length > 0) {        
  270.             Clicker.interactObject(ditch[0]);
  271.         }          
  272.         else {
  273.             Walker.takePath(TO_WILD_DITCH);
  274.         }  
  275.     }
  276.  
  277.     public static boolean inWild() {    
  278.         RSTile pos = Player.getRSPlayer().getPosition();
  279.         return (pos.getY() >= 3523) && (pos.getX() >= 3066) && (pos.getX() <= 3143);
  280.     }
  281.  
  282.     private void toAbyss() {       
  283.         if (NPCs.findNearest(ZAMMY_MAGE).length > 0 &&!NPCs.findNearest(ZAMMY_MAGE)[0].isOnScreen()) {
  284.             println("Retrying zammy mage walk!");
  285.             Walker.takePath(NPCs.findNearest(ZAMMY_MAGE)[0].getPosition());
  286.         }        
  287.         else if (NPCs.findNearest(ZAMMY_MAGE).length > 0 && NPCs.findNearest(ZAMMY_MAGE)[0].isOnScreen()) {
  288.             println("Teleporting to abyss!");
  289.             travelZammyMage();         
  290.         }        
  291.         else {
  292.             println("Walking to zammy mage!");
  293.             Walker.takePath(TO_ZAMMY_MAGE_AREA);            
  294.         }
  295.     }
  296.  
  297.     private void travelZammyMage() {
  298.         if(NPCs.findNearest(ZAMMY_MAGE)[0].hover()){
  299.         if (Clicking.click(TRAVEL_OPTION, NPCs.findNearest(ZAMMY_MAGE)[0])) {
  300.             sleep(4100, 4600);
  301.             }
  302.         }
  303.     }
  304.  
  305.     private boolean inAbyssR2() {
  306.         RSTile pos = Player.getRSPlayer().getPosition();
  307.         return (pos.getX() > 3022) && (pos.getY() > 4815)
  308.                     && (pos.getX() < 3056) && (pos.getY() < 4848);
  309.     }
  310.  
  311.     private String getTeleporterName() {    
  312.         switch (RUNE_TYPE) {
  313.         case "Air rune" :
  314.             return "Air rift";
  315.         case "Mind rune" :
  316.             return "Mind rift";
  317.         case "Body rune" :
  318.             return "Body rift";
  319.         case "Earth rune" :
  320.             return "Earth rift";
  321.         case "Fire rune" :
  322.             return "Fire rift";
  323.         case "Blood rune" :
  324.             return "Blood rift";
  325.         case "Cosmic rune" :
  326.             return "Cosmic rift";
  327.         case "Nature rune" :
  328.             return "Nature rift";
  329.         case "Chaos rune" :
  330.             return "Chaos rift";
  331.         case "Law rune" :
  332.             return "Law rift";
  333.         case "Death rune" :
  334.             return "Death rift";
  335.         case "Water rune" :
  336.             return "Water rift";
  337.         case "Soul rune" :
  338.             return "Soul rift";
  339.         }
  340.         return null;
  341.     }
  342.  
  343.     private void enterTeleporter() {
  344.         RSObject[] teleporter = Objects.findNearest(10, getTeleporterName());
  345.         if (teleporter.length > 0) {
  346.             Clicker.interactObject(teleporter[0]);
  347.         }
  348.     }
  349.    
  350.     private void lookForTeleporter() {
  351.         RSObject[] altarTeleport = Objects.findNearest(100, getTeleporterName());
  352.         if (altarTeleport.length > 0) {
  353.             if (Walking.walkPath(new DPathNavigator().findPath(altarTeleport[0]))) {
  354.                 sleep(400, 600);
  355.             }
  356.         }
  357.     }
  358.  
  359.     private boolean canSeeTeleporter() {       
  360.         RSObject[] altarTeleport = Objects.findNearest(5, getTeleporterName());
  361.         if (altarTeleport.length > 0) {
  362.             if (altarTeleport[0].isOnScreen()) {
  363.                 return true;
  364.             }
  365.         }
  366.         return false;
  367.     }
  368.  
  369.     private void toValidShortcut(RSObject shortcut) {  
  370.         if(shortcut != null){
  371.         if (PathFinding.aStarWalk(shortcut.getPosition())){
  372.             sleep(400, 700);
  373.             }
  374.         }
  375.     }
  376.  
  377.     private RSObject getValidShortcut() {      
  378.         RSObject[] s = Objects.findNearest(200, Filters.Objects.actionsContains(getAction()));
  379.         return s.length > 0 ? s[0] : null;
  380.     }
  381.    
  382.     private String getAction() {
  383.         if (Equipment.find(Constants.IDs.Items.hatchets).length > 0) {
  384.             return CHOP;
  385.         } else if (Equipment.find(Constants.IDs.Items.pickaxes).length > 0) {
  386.             return MINE;
  387.         } else if (Inventory.find(TINDERBOX).length > 0) {
  388.             return BURN;
  389.         } else if (Skills.getActualLevel(SKILLS.THIEVING) >= DISTRACT_EYES_LEVEL) {
  390.             return DISTRACT;
  391.         }        
  392.         return "No option";
  393.     }
  394.  
  395.     private void toBank() {
  396.         if(Skills.getCurrentLevel(SKILLS.HITPOINTS) <= SAFE_HEALTH && usingEmergencyTeleport &&!atTeleportLocation()){
  397.             if (Clicking.click(Inventory.find(TELE_TABS))){
  398.                 sleep(400, 900);
  399.             }
  400.         }
  401.         else if (!atTeleportLocation()) {
  402.             teleportOut();
  403.         }      
  404.         else if (WebWalking.walkToBank()) {
  405.             sleep(2400, 3700);
  406.         }
  407.     }
  408.  
  409.     private boolean atTeleportLocation() {      
  410.         return !inWild() &&!atAbyss() &&!atAltar();
  411.     }
  412.  
  413.     private boolean inEdgeville() {    
  414.         RSTile pos = Player.getRSPlayer().getPosition();
  415.         return (3082 <= pos.getX()) && (pos.getX() <= 3128)
  416.                 && (3483 <= pos.getY()) && (pos.getY() <= 3520);
  417.     }
  418.  
  419.     private void teleportOut() {
  420.         if(Banking.isBankScreenOpen()){
  421.             Banking.close();
  422.         }      
  423.         if (Equipment.isEquipped(GLORY)) {         
  424.             if (GameTab.open(TABS.EQUIPMENT)) {
  425.                 if (Clicking.click(EDGE_TELEPORT_OPTION, Equipment.find(GLORY))) {
  426.                     sleep(3400, 4200);
  427.                 }
  428.             }
  429.         }        
  430.         else if (Equipment.isEquipped(ROD)) {
  431.             if (GameTab.open(TABS.EQUIPMENT)) {
  432.                 if (Clicking.click(CWARS_TELEPORT_OPTION, Equipment.find(ROD))) {
  433.                     sleep(3400, 4200);
  434.                 }
  435.             }
  436.         }        
  437.         else if(Inventory.find(TELE_TABS).length > 0){
  438.             if(Clicking.click(Inventory.find(TELE_TABS))){
  439.             sleep(3400, 4900);
  440.             }
  441.         }        
  442.         else if (GameTab.open(TABS.MAGIC)) {
  443.             if (Magic.selectSpell(TELE_HOME)) {
  444.                 sleep(15000, 21000);
  445.             }
  446.         }
  447.     }
  448.  
  449.     private boolean canCraft() {    
  450.         return  Inventory.find(POUCHES).length > 0
  451.                 ? Banker.pouchesFilled()
  452.                 : true
  453.                 &&  
  454.                 atBank()
  455.                 ? Inventory.find(ESSENCE_TYPE).length >= Inventory.find(ESSENCE_TYPE).length + inventorySpace()
  456.                 : Inventory.find(ESSENCE_TYPE).length > 0
  457.                 &&
  458.                 (Skills.getCurrentLevel(SKILLS.HITPOINTS) >= SAFE_HEALTH);
  459.     }
  460.  
  461.  
  462.     public static boolean needEnergyPotion() { 
  463.         return Game.getRunEnergy() <= USERSET_DRINK_POINT;
  464.     }
  465.  
  466.     public static int inventorySpace() {
  467.         return 28 - Inventory.getAll().length;
  468.     }
  469.  
  470.     public static boolean atBank() {   
  471.         return Objects.find(10, BOOTH_NAMES).length > 0;
  472.     }
  473.  
  474.     private boolean atAltar() {
  475.         return Objects.find(10, ALTAR_NAMES).length > 0;
  476.     }
  477.  
  478.     public static int getFoodCount() {
  479.         return (Skills.getActualLevel(SKILLS.HITPOINTS) - Skills.getCurrentLevel(SKILLS.HITPOINTS))
  480.                 / FOOD_HEAL_AMT;
  481.     }
  482.  
  483.     public static boolean atAbyss() {      
  484.         RSTile pos = Player.getRSPlayer().getPosition();
  485.         return (pos.getX() > 3000) && (pos.getY() > 4804)
  486.                 && (pos.getX() < 3100) && (pos.getY() < 4900);
  487.     }
  488.  
  489.     private void craftRunes() {    
  490.         RSObject[] altar = Objects.findNearest(20, ALTAR_NAMES);       
  491.         if(altar.length > 0){
  492.             if(!altar[0].isOnScreen()) {
  493.                 Camera.turnToTile(altar[0]);
  494.             }          
  495.             else if(Inventory.find(ESSENCE_TYPE).length < 1 && Inventory.find(POUCHES).length > 0
  496.                         && Banker.pouchesFilled()){
  497.             emptyPouches();
  498.             }          
  499.             else {
  500.                 Clicker.interactObject(altar[0]);
  501.             }
  502.         }
  503.     }
  504.  
  505.     private void emptyPouches() {      
  506.         if(Inventory.find(POUCHES[0]).length > 0){
  507.             if(Game.getSetting(GIANT_POUCH_SETTING) == GIANT_FILLED_ID){
  508.                 if(Clicking.click("Empty", Inventory.find(POUCHES[0]))){
  509.                 sleep(1200, 1900);
  510.             }
  511.             }
  512.         }
  513.         if(Inventory.find(POUCHES[1]).length > 0){
  514.             if(Game.getSetting(LRG_POUCH_SETTING) == LRG_FILLED_ID){
  515.                 if(Clicking.click("Empty", Inventory.find(POUCHES[1]))){
  516.                 sleep(1200, 1900);
  517.             }
  518.             }
  519.         }
  520.         if(Inventory.find(POUCHES[2]).length > 0){
  521.             if(Game.getSetting(MED_POUCH_SETTING) == MED_FILLED_ID){
  522.                 if(Clicking.click("Empty", Inventory.find(POUCHES[2]))){
  523.                 sleep(1200, 1900);
  524.             }
  525.             }
  526.         }
  527.         if(Inventory.find(POUCHES[3]).length > 0){
  528.             if(Game.getSetting(SMALL_POUCH_SETTING) == SMALL_FILLED_ID){
  529.             if(Clicking.click("Empty", Inventory.find(POUCHES[3]))){
  530.                 sleep(1200, 1900);
  531.             }
  532.             }
  533.         }  
  534.     }
  535.  
  536.     private void GUI() {
  537.         new GUI();
  538.         while(!GUI_COMPLETE){
  539.             sleep(100);
  540.         }
  541.     }
  542. }
Advertisement
Add Comment
Please, Sign In to add comment