joedezzy1

Untitled

Jun 26th, 2014
260
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 18.40 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.api.types.generic.Condition;
  7. import org.tribot.api2007.Banking;
  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 final static String[] BOOTH_NAMES
  47.     = { "Bank booth", "Chest" };
  48.    
  49.     public final static String[] GLORY
  50.     = { "Amulet of glory(4)", "Amulet of glory(3)",
  51.             "Amulet of glory(2)", "Amulet of glory(1)", "Amulet of glory" };
  52.    
  53.     public final String[] ROD = {
  54.         "Ring of dueling(8)", "Ring of dueling(7)",
  55.         "Ring of dueling(6)", "Ring of dueling(5)",
  56.         "Ring of dueling(4)", "Ring of dueling(3)",
  57.         "Ring of dueling(2)", "Ring of dueling(1)"
  58.     };
  59.    
  60.     public final static String[] GAMES_NECKLACE = {};
  61.    
  62.     public final static String[] POUCHES              
  63.     = { "Giant pouch", "Large pouch",
  64.             "Medium pouch", "Small pouch" };
  65.    
  66.     public final static String[] TELE_TABS            
  67.     = { "Lumbridge teleport", "Varrock teleport",
  68.             "Falador teleport", "Camelot teleport"};
  69.    
  70.     public  final static String   FILL_POUCH     = "Fill";
  71.     private final String   WILD_DITCH            = "Wilderness ditch";
  72.     private final String   ZAMMY_MAGE            = "Mage of Zamorak";
  73.     private final String   TRAVEL_OPTION         = "Teleport";
  74.     private final String   EDGE_TELEPORT_OPTION  = "Edgeville";
  75.     private final String   CWARS_TELEPORT_OPTION = "Castle wars";
  76.     private final String   TELE_HOME             = "Lumbridge Home Teleport";
  77.     private final String   TINDERBOX             = "Tinderbox";
  78.     private final String   CHOP                  = "Chop";
  79.     private final String   DISTRACT              = "Distract";
  80.     private final String   SQUEEZE               = "Squeeze through";
  81.     private final String   GO_THROUGH            = "Go-through";
  82.     private final String   MINE                  = "Mine";
  83.     private final String   BURN                  = "Burn-down";
  84.     private final RSTile   TO_WILD_DITCH         = new RSTile(3110, 3520, 0);
  85.     private final RSTile   TO_ZAMMY_MAGE_AREA    = new RSTile(3105, 3557, 0);
  86.     private final int      DISTRACT_EYES_LEVEL   = 20;    
  87.     public final static int        SMALL_POUCH_SETTING   = 486;
  88.     public final static int        MED_POUCH_SETTING     = 486;
  89.     public final static int        LRG_POUCH_SETTING     = 486;
  90.     public final static int        GIANT_POUCH_SETTING   = 486;
  91.     public final static int        SMALL_FILLED_ID       = 1073741827;
  92.     public final static int        MED_FILLED_ID         = 1073741875;
  93.     public final static int        LRG_FILLED_ID         = 1073746483;
  94.     public final static int        GIANT_FILLED_ID       = 0;
  95.    
  96.     public static boolean  running               = true;
  97.     public static boolean  GUI_COMPLETE          = false;
  98.     private RSObject ourShortcut;
  99.     private int BANK_MOUSE_SPEED = 10;
  100.    
  101.     @Override
  102.     public void run() {
  103.         GUI();
  104.  
  105.         while (running) {
  106.  
  107.             ABC.start();
  108.            
  109.             Mouse.setSpeed(General.random(105, 115));
  110.            
  111.             if (canCraft()) {
  112.                 //* Checks for if we have pouches
  113.                 /* and if they're filled,
  114.                  * our health is good
  115.                  * and we have essence in our inventory
  116.                  */      
  117.                 if (inEdgeville()) {
  118.                     //**checks if in edgeville by co-ordinates & passes ditch**\\
  119.                     passWildDitch();
  120.                    
  121.                 }
  122.                
  123.                 else if (inWild()) {
  124.                     //**Walks to zammy mage and teleports to abyss**\\
  125.                     toAbyss();
  126.                    
  127.                 }
  128.                
  129.                 else if (atAbyss()) {
  130.                    
  131.                     if (!inAbyssR2()) {
  132.                         //**if in the first room,
  133.                         /* it will look for a shortcut
  134.                          *  to use and use it **/                  
  135.                         if(canSeeShortcut()){
  136.                             useShortcut();
  137.                         }
  138.                        
  139.                         else {
  140.                             toValidShortcut();
  141.                         }
  142.                        
  143.                     }
  144.                    
  145.                     else if(needPouchRecharge()){
  146.                         rechargePouches();
  147.                        
  148.                     }
  149.                    
  150.                     else if (canSeeTeleporter()) {
  151.                         println("spotted rift");
  152.                         //**if in the second room,
  153.                         /* uses the specified teleporter**/
  154.                         enterTeleporter();
  155.                        
  156.                     }
  157.                    
  158.                     else {
  159.                         //**if in the second room,
  160.                         /* looks for our teleporter
  161.                          * and walks to it **/
  162.                         lookForTeleporter();
  163.                     }
  164.                    
  165.                 }
  166.                
  167.                 else if (atAltar()) {
  168.                     craftRunes();
  169.                    
  170.                 }
  171.                
  172.                 else {
  173.                     teleportOut();
  174.                     //*should teleport
  175.                     /*to edgeville no
  176.                      * matter what              
  177.                      */
  178.                 }
  179.                
  180.             }
  181.            
  182.             else if (!atBank()) {
  183.                 toBank();
  184.                
  185.             }
  186.            
  187.             else if(!Banking.isBankScreenOpen()){
  188.                 if(Banking.openBank()){
  189.                     sleep(800, 1800);
  190.                 }
  191.                
  192.             }
  193.            
  194.             else {
  195.                 Mouse.setSpeed(Mouse.getSpeed() + BANK_MOUSE_SPEED);
  196.                 Banker.gearUp();
  197.                
  198.             }
  199.            
  200.             sleep(400, 600);
  201.         }
  202.     }
  203.  
  204.     private void rechargePouches() {
  205.         // TODO Auto-generated method stub
  206.        
  207.     }
  208.  
  209.     private boolean needPouchRecharge() {
  210.         // TODO Auto-generated method stub
  211.         return false;
  212.     }
  213.  
  214.     private void passWildDitch() {
  215.        
  216.         if (Objects.find(10, WILD_DITCH).length > 0) {
  217.             if(!Player.isMoving()){
  218.                 useDitch();
  219.             }      
  220.         }
  221.        
  222.         else {
  223.             toWildDitch();
  224.         }
  225.     }
  226.    
  227.     private void useDitch() {
  228.        
  229.         if (Clicking.click(Objects.findNearest(10, WILD_DITCH))) {
  230.             sleep(1400, 1600);
  231.         }
  232.     }
  233.  
  234.     private void toWildDitch() {
  235.        
  236.         if (WebWalking.walkTo(TO_WILD_DITCH)) {
  237.             sleep(400, 1700);
  238.         }
  239.     }
  240.  
  241.     public static boolean inWild() {
  242.        
  243.         RSTile pos = Player.getRSPlayer().getPosition();
  244.  
  245.         return (pos.getY() >= 3523)
  246.                 && (pos.getX() >= 3066) && (pos.getX() <= 3143);
  247.     }
  248.  
  249.     private void toAbyss() {
  250.        
  251.         if (NPCs.findNearest(ZAMMY_MAGE).length > 0
  252.                 &&!NPCs.findNearest(ZAMMY_MAGE)[0].isOnScreen()) {
  253.             walkToAvoidingDeath(NPCs.findNearest(ZAMMY_MAGE)[0].getPosition()); //walks to mages position of we cannot see it
  254.            
  255.         }
  256.        
  257.         else if ((NPCs.findNearest(ZAMMY_MAGE).length > 0)
  258.                     && NPCs.findNearest(ZAMMY_MAGE)[0].isOnScreen()) {
  259.             travelZammyMage();
  260.            
  261.         }
  262.        
  263.         else {
  264.             walkToAvoidingDeath(TO_ZAMMY_MAGE_AREA);
  265.            
  266.         }
  267.     }
  268.  
  269.     private void travelZammyMage() {
  270.  
  271.         if(NPCs.findNearest(ZAMMY_MAGE)[0].hover()){
  272.             if(Game.getUptext().contains("Talk")){
  273.                 if (Clicking.click(TRAVEL_OPTION, NPCs.findNearest(ZAMMY_MAGE)[0])) {
  274.                     sleep(2100, 3600);
  275.                 }
  276.             }
  277.         }
  278.     }
  279.  
  280.     private void walkToAvoidingDeath(RSTile pos) {
  281.  
  282.         if (WebWalking.walkTo(pos, new Condition(){
  283.  
  284.             @Override
  285.             public boolean active() {
  286.                 return Skills.getCurrentLevel(SKILLS.HITPOINTS) <= SAFE_HEALTH;
  287.             }
  288.            
  289.         }, 200)) {
  290.             sleep(400, 600);
  291.            
  292.         }
  293.     }
  294.  
  295.     private boolean inAbyssR2() {
  296.        
  297.         RSTile pos = Player.getRSPlayer().getPosition();
  298.  
  299.         return (pos.getX() > 3022) && (pos.getY() > 4815) && (pos.getX() < 3056) && (pos.getY() < 4848);
  300.     }
  301.  
  302.     private String getTeleporterName() {
  303.        
  304.         switch (RUNE_TYPE) {
  305.         case "Air rune" :
  306.             return "Air rift";
  307.  
  308.         case "Mind rune" :
  309.             return "Mind rift";
  310.  
  311.         case "Body rune" :
  312.             return "Body rift";
  313.  
  314.         case "Earth rune" :
  315.             return "Earth rift";
  316.  
  317.         case "Fire rune" :
  318.             return "Fire rift";
  319.  
  320.         case "Blood rune" :
  321.             return "Blood rift";
  322.  
  323.         case "Cosmic rune" :
  324.             return "Cosmic rift";
  325.  
  326.         case "Nature rune" :
  327.             return "Nature rift";
  328.  
  329.         case "Chaos rune" :
  330.             return "Chaos rift";
  331.  
  332.         case "Law rune" :
  333.             return "Law rift";
  334.  
  335.         case "Death rune" :
  336.             return "Death rift";
  337.  
  338.         case "Water rune" :
  339.             return "Water rift";
  340.  
  341.         case "Soul rune" :
  342.             return "Soul rift";
  343.         }
  344.  
  345.         return null;
  346.     }
  347.  
  348.     private void enterTeleporter() {
  349.        
  350.         if (!Player.isMoving()) {
  351.             if(Objects.findNearest(10, getTeleporterName())[0].hover()){
  352.                 if(Game.getUptext().contains(getTeleporterName())){
  353.                     if (Clicking.click(Objects.findNearest(10, getTeleporterName()))) {
  354.                         sleep(400, 600);
  355.                     }
  356.                 }
  357.             }
  358.         }
  359.     }
  360.    
  361.     private void lookForTeleporter() {
  362.        
  363.         RSObject[] altarTeleport = Objects.findNearest(100, getTeleporterName());
  364.  
  365.         if (altarTeleport.length > 0) {
  366.             if (Walking.walkPath(new DPathNavigator().findPath(altarTeleport[0]))) {
  367.                 sleep(400, 600);
  368.             }
  369.         }
  370.     }
  371.  
  372.     private boolean canSeeTeleporter() {
  373.        
  374.         RSObject[] altarTeleport = Objects.findNearest(5, getTeleporterName());
  375.  
  376.         if (altarTeleport.length > 0) {
  377.             if (altarTeleport[0].isOnScreen()) {
  378.                 return true;
  379.             }
  380.         }
  381.  
  382.         return false;
  383.     }
  384.  
  385.     private void useShortcut() {
  386.        
  387.         String[] actions = {getAction(), SQUEEZE, GO_THROUGH};
  388.        
  389.         if (ourShortcut != null){
  390.             if (ourShortcut.hover()) {
  391.                 for(String a: actions){
  392.                     if (Game.getUptext().contains(a)) {
  393.                         if (Clicking.click(ourShortcut)) {
  394.                             sleep(400, 900);
  395.                         }
  396.                     }
  397.                 }
  398.             }
  399.         }
  400.     }
  401.        
  402.     private boolean canSeeShortcut() {
  403.        
  404.         //will not get here unless is successfully walks a path to the shortcut
  405.        
  406.         if(ourShortcut != null){
  407.             if (ourShortcut.isOnScreen()) {
  408.                 General.println("see shortcut");
  409.                 return true;
  410.             }
  411.         }
  412.  
  413.         return false;
  414.     }
  415.  
  416.     private void toValidShortcut() {
  417.        
  418.         RSObject[] shortcut = getValidShortcut();
  419.        
  420.         if (shortcut.length > 0) {
  421.             RSTile shortcutPos = shortcut[0].getPosition();
  422.             if (PathFinding.aStarWalk(shortcutPos)){
  423.                 sleep(400, 700);
  424.             }
  425.         }
  426.            
  427.         ourShortcut = shortcut[0];
  428.     }
  429.  
  430.     private RSObject[] getValidShortcut() {
  431.        
  432.         return Objects.findNearest(200, Filters.Objects.actionsContains(getAction()));
  433.     }
  434.    
  435.     private String getAction() {
  436.        
  437.         if (Equipment.find(Constants.IDs.Items.hatchets).length > 0) {
  438.             return CHOP;
  439.         } else if (Equipment.find(Constants.IDs.Items.pickaxes).length > 0) {
  440.             return MINE;
  441.         } else if (Inventory.find(TINDERBOX).length > 0) {
  442.             return BURN;
  443.         } else if (Skills.getActualLevel(SKILLS.THIEVING) >= DISTRACT_EYES_LEVEL) {
  444.             return DISTRACT;
  445.         }
  446.        
  447.         return "No option";
  448.     }
  449.  
  450.     private void toBank() {
  451.        
  452.         if(Skills.getCurrentLevel(SKILLS.HITPOINTS) <= SAFE_HEALTH
  453.                 && usingEmergencyTeleport &&!atTeleportLocation()){
  454.             if (Clicking.click(Inventory.find(TELE_TABS))){
  455.                 sleep(400, 900);
  456.             }
  457.         }
  458.        
  459.         else if (!atTeleportLocation()) {
  460.             teleportOut();
  461.         }
  462.        
  463.         else if (WebWalking.walkToBank()) {
  464.             sleep(2400, 3700);
  465.         }
  466.     }
  467.  
  468.     private boolean atTeleportLocation() {
  469.        
  470.         return !inWild()
  471.                 &&!atAbyss()
  472.                     &&!atAltar();
  473.     }
  474.  
  475.     private boolean inEdgeville() {
  476.        
  477.         RSTile pos = Player.getRSPlayer().getPosition();
  478.  
  479.         return (3082 <= pos.getX()) && (pos.getX() <= 3128)
  480.                 && (3483 <= pos.getY()) && (pos.getY() <= 3520);
  481.     }
  482.  
  483.     private void teleportOut() {
  484.        
  485.         if (Equipment.isEquipped(GLORY)) {
  486.             if(Banking.isBankScreenOpen()){
  487.                 Banking.close();
  488.             }
  489.            
  490.             if (GameTab.open(TABS.EQUIPMENT)) {
  491.                 if (Clicking.click(EDGE_TELEPORT_OPTION, Equipment.find(GLORY))) {
  492.                     sleep(3400, 4200);
  493.                 }
  494.             }
  495.         }
  496.        
  497.         else if (Equipment.isEquipped(ROD)) {
  498.             if (GameTab.open(TABS.EQUIPMENT)) {
  499.                 if (Clicking.click(CWARS_TELEPORT_OPTION, Equipment.find(ROD))) {
  500.                     sleep(3400, 4200);
  501.                 }
  502.             }
  503.         }
  504.        
  505.         else if(Inventory.find(TELE_TABS).length > 0){
  506.             if(Clicking.click(Inventory.find(TELE_TABS))){
  507.                 sleep(3400, 4900);
  508.             }
  509.         }
  510.        
  511.         else if (GameTab.open(TABS.MAGIC)) {
  512.             if (Magic.selectSpell(TELE_HOME)) {
  513.                 sleep(15000, 21000);
  514.             }
  515.         }
  516.     }
  517.  
  518.     private boolean canCraft() {
  519.        
  520.         return (((Inventory.find(POUCHES).length > 0)
  521.                 ? Banker.pouchesFilled() : true)
  522.                 &&  
  523.                 (Inventory.find(ESSENCE_TYPE).length
  524.                         >= Inventory.find(ESSENCE_TYPE).length
  525.                                 + (28 - Inventory.getAll().length))
  526.                 &&
  527.                 (Skills.getCurrentLevel(SKILLS.HITPOINTS)
  528.                         >= SAFE_HEALTH))                      
  529.                 ||
  530.                 (atAltar()
  531.                         &&  ((Inventory.find(POUCHES).length > 0 && Banker.pouchesFilled())
  532.                                 ||
  533.                             Inventory.find(ESSENCE_TYPE).length > 0)); //Dont think i need this
  534.     }
  535.  
  536.  
  537.     public static boolean needEnergyPotion() {
  538.        
  539.         return Game.getRunEnergy() <= USERSET_DRINK_POINT;
  540.     }
  541.  
  542.     public static int inventorySpace() {
  543.        
  544.         return 28 - Inventory.getAll().length;
  545.     }
  546.  
  547.     public static boolean atBank() {
  548.        
  549.         return Objects.find(10, BOOTH_NAMES).length > 0;
  550.     }
  551.  
  552.     private boolean atAltar() {
  553.        
  554.         return Objects.find(10, ALTAR_NAMES).length > 0;
  555.     }
  556.  
  557.     public static int getFoodCount() {
  558.        
  559.         return (Skills.getActualLevel(SKILLS.HITPOINTS)
  560.                 - Skills.getCurrentLevel(SKILLS.HITPOINTS)) / FOOD_HEAL_AMT;
  561.     }
  562.  
  563.     public static boolean atAbyss() {
  564.        
  565.         RSTile pos = Player.getRSPlayer().getPosition();
  566.  
  567.         return (pos.getX() > 3000) && (pos.getY() > 4804)
  568.                 && (pos.getX() < 3100) && (pos.getY() < 4900);
  569.     }
  570.  
  571.     private void craftRunes() {
  572.        
  573.         if(Objects.findNearest(20, ALTAR_NAMES).length > 0){
  574.             if(!Objects.findNearest(20, ALTAR_NAMES)[0].isOnScreen()) {
  575.                 if (Walking.walkTo(Objects.findNearest(20, ALTAR_NAMES)[0])) {    // may have to nullcheck
  576.                     sleep(800, 1800);
  577.                 }
  578.             }
  579.            
  580.             else if(Inventory.find(ESSENCE_TYPE).length < 1
  581.                         && Inventory.find(POUCHES).length > 0
  582.                             && Banker.pouchesFilled()){
  583.                 emptyPouches();
  584.             }
  585.            
  586.             else if (Clicking.click(Objects.findNearest(20, ALTAR_NAMES))) {
  587.                 sleep(2800, 4800);
  588.             }
  589.         }
  590.     }
  591.  
  592.     private void emptyPouches() {
  593.        
  594.         if(Inventory.find(POUCHES[3]).length > 0){
  595.             if(Game.getSetting(SMALL_POUCH_SETTING) == SMALL_FILLED_ID){
  596.                 if(Clicking.click("Empty", Inventory.find(POUCHES[3]))){
  597.                     sleep(1200, 1900);
  598.                 }
  599.             }
  600.         }
  601.        
  602.         else if(Inventory.find(POUCHES[2]).length > 0){
  603.             if(Game.getSetting(MED_POUCH_SETTING) == MED_FILLED_ID){
  604.                 if(Clicking.click("Empty", Inventory.find(POUCHES[2]))){
  605.                     sleep(1200, 1900);
  606.                 }
  607.             }
  608.         }
  609.        
  610.         else if(Inventory.find(POUCHES[1]).length > 0){
  611.             if(Game.getSetting(LRG_POUCH_SETTING) == LRG_FILLED_ID){
  612.                 if(Clicking.click("Empty", Inventory.find(POUCHES[1]))){
  613.                     sleep(1200, 1900);
  614.                 }
  615.             }
  616.         }
  617.        
  618.         else if(Inventory.find(POUCHES[0]).length > 0){
  619.            if(Game.getSetting(GIANT_POUCH_SETTING) == GIANT_FILLED_ID){
  620.                if(Clicking.click("Empty", Inventory.find(POUCHES[0]))){
  621.                     sleep(1200, 1900);
  622.                }
  623.            }
  624.         }
  625.     }
  626.  
  627.     private void GUI() {
  628.  
  629.         new GUI();
  630.         while(!GUI_COMPLETE ){
  631.             sleep(100);
  632.         }
  633.     }
  634. }
Advertisement
Add Comment
Please, Sign In to add comment