Advertisement
joedezzy1

Untitled

Jul 31st, 2014
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 6.73 KB | None | 0 0
  1. package scripts.abyssCrafterV2;
  2.  
  3. import org.tribot.api.Clicking;
  4. import org.tribot.api.General;
  5. import org.tribot.api.Timing;
  6. import org.tribot.api.interfaces.Positionable;
  7. import org.tribot.api2007.Skills;
  8. import org.tribot.api2007.GameTab.TABS;
  9. import org.tribot.api2007.Skills.SKILLS;
  10. import org.tribot.api.types.generic.Condition;
  11. import org.tribot.api2007.Banking;
  12. import org.tribot.api2007.Camera;
  13. import org.tribot.api2007.Equipment;
  14. import org.tribot.api2007.GameTab;
  15. import org.tribot.api2007.Inventory;
  16. import org.tribot.api2007.NPCs;
  17. import org.tribot.api2007.Objects;
  18. import org.tribot.api2007.PathFinding;
  19. import org.tribot.api2007.Player;
  20. import org.tribot.api2007.Walking;
  21. import org.tribot.api2007.WebWalking;
  22. import org.tribot.api2007.types.RSItem;
  23. import org.tribot.api2007.types.RSNPC;
  24. import org.tribot.api2007.types.RSObject;
  25. import org.tribot.api2007.types.RSTile;
  26.  
  27. public class DezUtils {
  28.  
  29.     public static boolean characterCanDie() {
  30.         return Player.getRSPlayer().getHealth() < getHealthPercentage(.75);
  31.     }
  32.  
  33.     public static int getHealthPercentage(double percentageBelow) {
  34.         return (int) (Skills.getActualLevel(SKILLS.HITPOINTS)
  35.                 - (Skills.getActualLevel(SKILLS.HITPOINTS)
  36.                 * (Skills.getActualLevel(SKILLS.HITPOINTS) * percentageBelow)));
  37.     }
  38.    
  39.     public static boolean interactObject(String name, int dist) {
  40.         RSObject[] obj = Objects.findNearest(dist, name);
  41.         if (!Player.isMoving() && obj.length > 0 && obj[0].hover()) {
  42.             if (Timing.waitUptext(name, General.random(700, 1100))) {
  43.                 if (obj[0] != null && obj[0].click()) {
  44.                     General.sleep(1100, 1600);
  45.                     return true;
  46.                 }
  47.             }
  48.             else {
  49.                 fixCam();
  50.             }
  51.         }
  52.         return false;
  53.     }
  54.    
  55.     public static boolean interactObject(RSObject obj, String option) {
  56.         if (!Player.isMoving() && obj != null) {
  57.             if (obj.hover() && Timing.waitUptext(obj.getDefinition().getName(), General.random(700, 1100))) {
  58.                 if (obj != null && obj.click(option)) {                    
  59.                     General.sleep(1100, 1600);
  60.                     return true;
  61.                 }
  62.             }
  63.             else {
  64.                 fixCam();
  65.             }
  66.         }
  67.         return false;
  68.     }
  69.    
  70.     public static boolean interactObject(RSObject obj) {
  71.         if (!Player.isMoving() && obj != null) {
  72.             if (obj.hover() && Timing.waitUptext(obj.getDefinition().getName(), General.random(700, 1100))) {
  73.                 if (obj != null && obj.click()) {
  74.                     General.sleep(1100, 1600);
  75.                     return true;
  76.                 }
  77.             }
  78.             else {
  79.                 fixCam();
  80.             }
  81.         }
  82.         return false;
  83.     }
  84.    
  85.     public static boolean interactObject(RSObject obj, int min, int max) {
  86.         if (!Player.isMoving() && obj != null) {
  87.             if (obj.hover() && Timing.waitUptext(obj.getDefinition().getName(), General.random(700, 1100))) {
  88.                 if (obj != null && obj.click()) {
  89.                     General.sleep(min, max);
  90.                     return true;
  91.                 }
  92.             }
  93.             else {
  94.                 fixCam();
  95.             }
  96.         }
  97.         return false;
  98.     }
  99.    
  100.     public static boolean interactObject(Positionable tile) {
  101.         RSObject[] obj = Objects.getAt(tile);
  102.         if (!Player.isMoving() && obj.length > 0){
  103.             if(obj[0].hover() && Timing.waitUptext(obj[0].getDefinition().getName(), General.random(700, 1100))) {
  104.                 if (obj[0] != null && obj[0].click()) {
  105.                     General.sleep(1100, 1600);
  106.                     return true;
  107.                 }
  108.                 else {
  109.                     fixCam();
  110.                 }
  111.             }
  112.         }
  113.         return false;
  114.     }
  115.    
  116.     public static boolean interactNpc(String name, String option) {
  117.         RSNPC[] npc = NPCs.find(name);
  118.         if (!Player.isMoving() && npc.length > 0) {
  119.             if (npc[0].hover() && Timing.waitUptext(npc[0].getDefinition().getName(), General.random(700, 1100))) {
  120.                 if (npc[0] != null && option != null ? npc[0].click(option) : npc[0].click()) {
  121.                     General.sleep(1100, 1600);
  122.                     return true;
  123.                 }
  124.             }
  125.             else {
  126.                 fixCam();
  127.             }
  128.         }
  129.         return false;
  130.     }
  131.    
  132.     public static boolean interactNpc(RSNPC npc, String option) {
  133.         if (!Player.isMoving() && npc != null && npc.hover()){
  134.             if (Timing.waitUptext(npc.getDefinition().getName(), General.random(700, 1100))) {
  135.                 if (npc != null && npc.click(option)) {
  136.                     General.sleep(1100, 1600);
  137.                     return true;
  138.                 }
  139.             }
  140.             else {
  141.                 fixCam();
  142.             }
  143.         }
  144.         return false;
  145.     }
  146.  
  147.     public static void fixCam() {
  148.         Camera.setCameraRotation(Camera.getCameraRotation() + General.random(-5, 5));
  149.     }  
  150.    
  151.     public static boolean withdrawItem(final String name, String deposit, int amt, boolean killBot){
  152.         if (!Banking.isBankScreenOpen()) {
  153.             if (Banking.openBank()) {
  154.                 Timing.waitCondition(new Condition(){
  155.                     @Override
  156.                     public boolean active() {
  157.                         return Banking.isBankScreenOpen();
  158.                     }                  
  159.                 }, General.random(3000, 5000));
  160.             }
  161.         }
  162.         else if (Banking.find(name).length > 0 && Banking.find(name)[0] != null) {
  163.             if (Inventory.isFull()) {
  164.                 if (deposit != null && Banking.deposit(1, deposit)) {
  165.                     General.sleep(1200, 1400);
  166.                 }
  167.             }
  168.             else if (Banking.withdraw(amt, name)) {
  169.                 return Timing.waitCondition(new Condition() {
  170.                         @Override
  171.                         public boolean active() {
  172.                             return Inventory.find(name).length > 0;
  173.                         }                          
  174.                 }, General.random(1200, 1600));
  175.             }
  176.         }
  177.         else {
  178.             Main.running = false;
  179.         }      
  180.         return false;
  181.     }
  182.    
  183.     public static boolean toObject(final RSObject obj) {
  184.         if (obj != null && PathFinding.aStarWalk(obj)) {
  185.             return Timing.waitCondition(new Condition(){
  186.                 @Override
  187.                 public boolean active() {
  188.                     return obj.isOnScreen();
  189.                 }              
  190.             }, General.random(2000, 3500));
  191.         }
  192.         return false;
  193.     }
  194.    
  195.     public static boolean toNpc(final RSNPC npc) {
  196.         if (npc != null && PathFinding.aStarWalk(npc)) {
  197.             return Timing.waitCondition(new Condition(){
  198.                 @Override
  199.                 public boolean active() {
  200.                     return npc.isOnScreen();
  201.                 }              
  202.             }, General.random(2000, 3500));
  203.         }
  204.         return false;
  205.     }
  206.    
  207.     public static void takePath(Positionable[] tile) {
  208.         if (Walking.walkPath(tile, new Condition(){
  209.             @Override
  210.             public boolean active() {
  211.                 return !Player.isMoving() || characterCanDie();
  212.             }          
  213.         }, 2300)) {
  214.             General.sleep(1400, 2400);
  215.         }
  216.     }
  217.    
  218.     public static void takePath(Positionable tile) {
  219.         if (WebWalking.walkTo(tile, new Condition(){
  220.             @Override
  221.             public boolean active() {
  222.                 return !Player.isMoving() || characterCanDie();
  223.             }          
  224.         }, 2300)) {
  225.             General.sleep(1400, 2400);
  226.         }
  227.     }
  228.  
  229.     public static boolean useJewlery(String destination, String... names) {
  230.         RSItem[] item = Equipment.find(names);
  231.         final RSTile origin = Player.getPosition();
  232.         if (item.length > 0 && GameTab.open(TABS.EQUIPMENT)) {
  233.             if (Clicking.click(destination, item[0])) {
  234.                 return Timing.waitCondition(new Condition(){
  235.                     @Override
  236.                     public boolean active() {
  237.                         return !Player.getPosition().equals(origin);
  238.                     }                  
  239.                 }, General.random(7000, 9000));
  240.             }
  241.         }  
  242.         return false;
  243.     }
  244.  
  245.     public static void useTeleportTab() {
  246.         // TODO Auto-generated method stub
  247.        
  248.     }
  249. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement