Advertisement
kulers

Old tribot script

Jan 22nd, 2017
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 13.64 KB | None | 0 0
  1. package scripts;
  2.  
  3. import java.awt.Color;
  4. import java.awt.Font;
  5. import java.awt.Graphics;
  6. import java.awt.Image;
  7. import java.io.IOException;
  8. import java.net.URL;
  9.  
  10.  
  11. import javax.imageio.ImageIO;
  12.  
  13. import org.tribot.api.General;
  14. import org.tribot.api.Timing;
  15. import org.tribot.api.input.Keyboard;
  16. import org.tribot.api2007.Interfaces;
  17. import org.tribot.api2007.Inventory;
  18.  
  19. import org.tribot.api2007.NPCChat;
  20. import org.tribot.api2007.NPCs;
  21. import org.tribot.api2007.Objects;
  22. import org.tribot.api2007.Player;
  23.  
  24. import org.tribot.api2007.Prayer;
  25. import org.tribot.api2007.Prayer.PRAYERS;
  26. import org.tribot.api2007.Skills;
  27. import org.tribot.api2007.Skills.SKILLS;
  28. import org.tribot.api2007.Walking;
  29. import org.tribot.api2007.types.RSTile;
  30. import org.tribot.script.Script;
  31. import org.tribot.script.ScriptManifest;
  32. import org.tribot.script.interfaces.Painting;
  33.  
  34. @ScriptManifest(authors = { "kulers"}, category = "Mini-games", name = "kulersNMZ", description = "You need dwarven rock cake in you inventory only! And you must have 255 Absorption and Overload potions in barrel")
  35. public class nmz_dh extends Script implements Painting {
  36.  
  37.     public static long nextPrayFlick = Time();
  38.     public static int nextAbsorption = General.random(80, 160);
  39.  
  40.     public static long startTime = Time();
  41.     public static long timmer = Time();
  42.     public static long obPot = Time()+300000;
  43.  
  44.     public static int strXp = Skills.getXP(SKILLS.STRENGTH);
  45.     public static int hpXp = Skills.getXP(SKILLS.HITPOINTS);
  46.     public static int ranXp = Skills.getXP(SKILLS.RANGED);
  47.     public static int attXp = Skills.getXP(SKILLS.ATTACK);
  48.     public static int magXp = Skills.getXP(SKILLS.MAGIC);
  49.     public static int defXp = Skills.getXP(SKILLS.DEFENCE);
  50.  
  51.     public static RSTile poTitle;
  52.    
  53.     private final Image img = getImage("http://i.imgur.com/g3qJdov.png?1");
  54.     public Font font = new Font("Verdana", Font.BOLD, 14);
  55.  
  56.     @Override
  57.     public void run() {
  58.         // TODO Auto-generated method stub
  59.         while (true) {
  60.             if (getNmzPoints() != -1) {
  61.  
  62.                 if (timmer + 30000 > Time())
  63.                     sleep(get51Hp());
  64.  
  65.                 int i = checkPrayFlick();
  66.                 sleep(i);
  67.                 if (i == 0 && getHp() <= 51) {
  68.                     sleep(checkOverloads());
  69.                     sleep(checkAbsorption());
  70.                     //sleep(checkRanging());
  71.  
  72.                 }
  73.                 if (i == 0 && getHp() == 1 && (nextPrayFlick - Time()) >= 5000) {
  74.                     if (Objects.findNearest(5, "<col=ff9040>Potion").length != 0) {
  75.                         poTitle = Objects.findNearest(5, "<col=ff9040>Potion")[0].getPosition();
  76.                     }
  77.  
  78.                     try {
  79.                         RSTile pos = new RSTile(poTitle.getX() - 20, poTitle.getY() + 32, 3);
  80.                         if (pos.getX() != Player.getPosition().getX() || pos.getY() != Player.getPosition().getY()) {
  81.                             //Walking.walkPath(Walking.generateStraightPath(pos));
  82.                             Walking.walkScreenPath(Walking.generateStraightScreenPath(pos));
  83.                             sleep(General.random(500, 2000));
  84.                         }
  85.                     } catch (Exception e) {
  86.                         // TODO: handle exception
  87.                     }
  88.                 }
  89.             } else {
  90.                 //sleep(get51Hp());
  91.                 //Login.logout();
  92.                 int i = payForDream();
  93.                 sleep(i);
  94.                 if (i == 0) {
  95.                     RSTile tt = new RSTile(2601, 3116, 0);
  96.                     if (Player.getPosition().distanceTo(tt) >= 5) {
  97.                         Walking.walkPath(Walking.generateStraightPath(tt));
  98.                         sleep(General.random(1000, 2000));
  99.                     } else
  100.                     if (Inventory.find("Overload (4)", "Overload (3)", "Overload (2)", "Overload (1)").length != 13 && Player.getAnimation() == -1) {
  101.                         try {
  102.  
  103.                             if (Objects.findNearest(20, "Overload potion").length == 1) {
  104.                                 Objects.findNearest(20, "Overload potion")[0].click("Store");
  105.                                 sleep(General.random(3000, 5000));
  106.                                 try {
  107.                                     NPCChat.selectOption(NPCChat.getOptions()[0], true);
  108.                                 } catch (Exception e) {}
  109.                                 sleep(General.random(1000, 2000));
  110.                                 Objects.findNearest(20, "Overload potion")[0].click("Take");
  111.                                 sleep(General.random(1000, 2000));
  112.                                 Keyboard.typeKeys('5', '2');
  113.                                 sleep(General.random(200, 300));
  114.                                 Keyboard.pressEnter();
  115.                                 sleep(General.random(3000, 5000));
  116.                             }
  117.  
  118.                         } catch (Exception e) {
  119.                             // TODO: handle exception
  120.                         }
  121.  
  122.                     } else
  123.                     if (Inventory.find("Absorption (4)", "Absorption (3)", "Absorption (2)", "Absorption (1)").length != 14 && Player.getAnimation() == -1) {
  124.                         try {
  125.  
  126.                             if (Objects.findNearest(20, "Absorption potion").length == 1) {
  127.                                 Objects.findNearest(20, "Absorption potion")[0].click("Store");
  128.                                 sleep(General.random(3000, 5000));
  129.                                 try {
  130.                                     NPCChat.selectOption(NPCChat.getOptions()[0], true);
  131.                                 } catch (Exception e) {}
  132.                                 sleep(General.random(1000, 2000));
  133.                                 Objects.findNearest(20, "Absorption potion")[0].click("Take");
  134.                                 sleep(General.random(1000, 2000));
  135.                                 Keyboard.typeKeys('5', '6');
  136.                                 sleep(General.random(200, 300));
  137.                                 Keyboard.pressEnter();
  138.                                 sleep(General.random(3000, 5000));
  139.                             }
  140.  
  141.                         } catch (Exception e) {
  142.                             // TODO: handle exception
  143.                         }
  144.                     } else {
  145.                         if (Inventory.find("Overload (4)", "Overload (3)", "Overload (2)", "Overload (1)").length == 13 && Inventory.find("Absorption (4)", "Absorption (3)", "Absorption (2)", "Absorption (1)").length == 14) {
  146.                             if (getIsDreamOpened() == -1)
  147.                                 Objects.findNearest(20, 26291)[0].click("Drink");
  148.                             sleep(General.random(4000, 5000));
  149.                             timmer = Time();
  150.                         }
  151.                     }
  152.                 }
  153.  
  154.             }
  155.         }
  156.     }
  157.    
  158.     @Override
  159.     public void onPaint(Graphics g) {
  160.         //
  161.         long timeRan = Time() - startTime;
  162.         g.drawImage(img, 0, 338, null);
  163.         g.setFont(font);
  164.         drawTextShadow(g,""+Math.max((int)((nextPrayFlick - Time())/1000),0), 70, 392); //Pray flick
  165.         drawTextShadow(g, "" + nextAbsorption, 82, 447);
  166.         drawTextShadow(g, ""+Timing.msToString(timeRan), 162, 392);
  167.         drawTextShadow(g, "" + Math.max((int)((obPot-Time())/1000),0),  190, 447);
  168.        
  169.         if( Math.floor((timeRan / 10000))  % 2 == 0){
  170.             //xp
  171.             drawTextShadow(g, ""+coolFormat((Skills.getXP(SKILLS.HITPOINTS) - hpXp),0), 312, 392);//HP
  172.             drawTextShadow(g, ""+coolFormat((Skills.getXP(SKILLS.STRENGTH) - strXp),0), 430, 392);//Str
  173.            
  174.             drawTextShadow(g, ""+coolFormat((Skills.getXP(SKILLS.RANGED) - ranXp),0), 312, 422);//Range
  175.             drawTextShadow(g, ""+coolFormat((Skills.getXP(SKILLS.ATTACK) - attXp),0), 430, 422);//Att
  176.            
  177.             drawTextShadow(g, ""+coolFormat((Skills.getXP(SKILLS.MAGIC) - magXp),0), 312, 450);//mage
  178.             drawTextShadow(g, ""+coolFormat((Skills.getXP(SKILLS.DEFENCE) - defXp),0), 430, 450);//def
  179.         }else{
  180.             //xp/h
  181.             drawTextShadow(g, ""+coolFormat(((Skills.getXP(SKILLS.HITPOINTS) - hpXp)/ (timeRan / 3600000.0D)),0)+"/h", 312, 392);//HP
  182.             drawTextShadow(g, ""+coolFormat(((Skills.getXP(SKILLS.STRENGTH) - strXp )/ (timeRan / 3600000.0D)),0)+"/h", 430, 392);//Str
  183.            
  184.             drawTextShadow(g, ""+coolFormat(((Skills.getXP(SKILLS.RANGED) - ranXp)/ (timeRan / 3600000.0D)),0)+"/h", 312, 422);//Range
  185.             drawTextShadow(g, ""+coolFormat(((Skills.getXP(SKILLS.ATTACK) - attXp)/ (timeRan / 3600000.0D)),0)+"/h", 430, 422);//Att
  186.            
  187.             drawTextShadow(g, ""+coolFormat(((Skills.getXP(SKILLS.MAGIC) - magXp)/ (timeRan / 3600000.0D)),0)+"/h", 312, 450);//mage
  188.             drawTextShadow(g, ""+coolFormat(((Skills.getXP(SKILLS.DEFENCE) - defXp)/ (timeRan / 3600000.0D)),0)+"/h", 430, 450);//def
  189.         }
  190.        
  191.        
  192.        
  193.         /*drawTextShadow(g, "STRENGTH: " + (Skills.getXP(SKILLS.STRENGTH) - strXp) + "  (" + NumberFormat.getNumberInstance(Locale.US).format((int)((Skills.getXP(SKILLS.STRENGTH) - strXp) / (timeRan / 3600000.0D))) + ") per hour", 10, 100);
  194.         drawTextShadow(g, "HITPOINTS: " + (Skills.getXP(SKILLS.HITPOINTS) - hpXp) + "  (" + NumberFormat.getNumberInstance(Locale.US).format((int)((Skills.getXP(SKILLS.HITPOINTS) - hpXp) / (timeRan / 3600000.0D))) + ") per hour", 10, 120);
  195.         drawTextShadow(g, "RANGED: " + (Skills.getXP(SKILLS.RANGED) - ranXp) + "  (" + NumberFormat.getNumberInstance(Locale.US).format((int)((Skills.getXP(SKILLS.RANGED) - ranXp) / (timeRan / 3600000.0D))) + ") per hour", 10, 140);
  196.         drawTextShadow(g, "TOTAL: " + (Skills.getXP(SKILLS.HITPOINTS) - hpXp + Skills.getXP(SKILLS.STRENGTH) - strXp + Skills.getXP(SKILLS.RANGED) - ranXp) + "  (" + NumberFormat.getNumberInstance(Locale.US).format((int)((Skills.getXP(SKILLS.HITPOINTS) - hpXp + Skills.getXP(SKILLS.STRENGTH) - strXp + Skills.getXP(SKILLS.RANGED) - ranXp) / (timeRan / 3600000.0D))) + ") per hour", 10, 180);
  197.         */
  198.         //
  199.         /*if (getNmzPoints() == -1) {
  200.             drawTextShadow(g, "In arena: False", 10, 258);
  201.             drawTextShadow(g, "Absorption: " + getNmzAmsorbtion(), 10, 258 + 20);
  202.         } else {
  203.             drawTextShadow(g, "Absorption: " + getNmzAmsorbtion(), 10, 258 + 20);
  204.         }*/
  205.  
  206.     }
  207.  
  208.     public void drawTextShadow(Graphics g, String t, int x, int y) {
  209.         g.setColor(Color.BLACK);
  210.         g.drawString(t, x + 1, y + 1);
  211.         g.setColor(Color.WHITE);
  212.         g.drawString(t, x, y);
  213.     }
  214.    
  215.     private Image getImage(String url) {
  216.         try {
  217.         return ImageIO.read(new URL(url));
  218.         } catch(IOException e) {
  219.         return null;
  220.         }
  221.         }
  222.  
  223.     public static int checkPrayFlick() {
  224.         if (Prayer.isPrayerEnabled(PRAYERS.RAPID_HEAL)) {
  225.             Prayer.disable(PRAYERS.RAPID_HEAL);
  226.             return General.random(1000, 3000);
  227.         } else
  228.         if (Time() >= nextPrayFlick) {
  229.             nextPrayFlick = Time() + General.random(General.random(10000, 30000), 40000);
  230.             Prayer.enable(PRAYERS.RAPID_HEAL);
  231.             return General.random(100, 300);
  232.         }
  233.         return 0;
  234.     }
  235.  
  236.     public static int checkAbsorption() {
  237.         if (getNmzAmsorbtion() < nextAbsorption) {
  238.  
  239.             if (Inventory.find("Absorption (4)", "Absorption (3)", "Absorption (2)", "Absorption (1)").length != 0) {
  240.                 Inventory.find("Absorption (4)", "Absorption (3)", "Absorption (2)", "Absorption (1)")[0].click("Drink");
  241.                 nextAbsorption = General.random(80, 160);
  242.                 return General.random(1000, 3000);
  243.             }
  244.             return 0;
  245.         }
  246.         return 0;
  247.     }
  248.  
  249.     public static int checkOverloads() {
  250.         if (Inventory.find("Overload (4)", "Overload (3)", "Overload (2)", "Overload (1)").length != 0 && Skills.getActualLevel(SKILLS.STRENGTH) == Skills.getCurrentLevel(SKILLS.STRENGTH)) {
  251.             Inventory.find("Overload (4)", "Overload (3)", "Overload (2)", "Overload (1)")[0].click("Drink");
  252.             obPot = Time()+300000;
  253.             return General.random(1000, 3000);
  254.         }
  255.         return 0;
  256.     }
  257.  
  258.     public static int checkRanging() {
  259.         if (Skills.getActualLevel(SKILLS.RANGED) + 7 >= Skills.getCurrentLevel(SKILLS.RANGED)) {
  260.             Inventory.find("Super ranging (4)", "Super ranging (3)", "Super ranging (2)", "Super ranging (1)")[0].click("Drink");
  261.             return General.random(1000, 3000);
  262.         }
  263.         return 0;
  264.     }
  265.  
  266.     public static long Time() {
  267.         return System.currentTimeMillis();
  268.     }
  269.  
  270.     public static int get51Hp() {
  271.         //General.println("HP:"+getHp() );
  272.         if (getHp() >= 67 || getHp() == 0) {
  273.             Inventory.find("Dwarven rock cake")[0].click("Guzzle");
  274.             return General.random(200, 400);
  275.         } else
  276.         if (getHp() >= 65 && getHp() <= 67 || getHp() == 0) {
  277.             Inventory.find("Dwarven rock cake")[0].click("Guzzle");
  278.             return General.random(200, 400);
  279.         } else
  280.         if (getHp() >= 52 && getHp() <= 65 || getHp() == 0) {
  281.             Inventory.find("Dwarven rock cake")[0].click("Eat");
  282.             return General.random(1000, 1200);
  283.         }
  284.         return General.random(200, 400);
  285.     }
  286.  
  287.     public static int getNmzAmsorbtion() {
  288.         try {
  289.             if (Interfaces.get(202, 1).getChild(9).isHidden()) {
  290.                 return -2;
  291.             }
  292.             return Integer.parseInt(Interfaces.get(202, 1).getChild(9).getText());
  293.         } catch (Exception e) {
  294.             return -1;
  295.         }
  296.     }
  297.  
  298.     public static int getHp() {
  299.         try {
  300.             if (Interfaces.get(160, 5).isHidden()) {
  301.                 return 0;
  302.             }
  303.             return Integer.parseInt(Interfaces.get(160, 5).getText());
  304.         } catch (Exception e) {
  305.             return 0;
  306.         }
  307.     }
  308.  
  309.     public static int getNmzPoints() {
  310.         try {
  311.             if (Interfaces.get(202, 1).getChild(3).isHidden()) {
  312.                 return -1;
  313.             }
  314.             return Integer.parseInt(Interfaces.get(202, 1).getChild(3).getText().split("<br>")[1].replace(",", ""));
  315.         } catch (Exception e) {
  316.             return -1;
  317.         }
  318.     }
  319.  
  320.     public static int payForDream() {
  321.         if (Objects.findNearest(20, "<col=ff9040>Potion").length == 0) {
  322.  
  323.             try {
  324.                 NPCs.find("Dominic Onion")[0].click("Dream");
  325.                 General.sleep(General.random(8000, 15000));
  326.                 if (NPCChat.getOptions().length == 4) {
  327.                     NPCChat.selectOption(NPCChat.getOptions()[3], true);
  328.                     General.sleep(General.random(1000, 2000));
  329.                     NPCChat.clickContinue(true);
  330.                     General.sleep(General.random(1000, 2000));
  331.                     if (NPCChat.getOptions().length == 2) {
  332.                         NPCChat.selectOption(NPCChat.getOptions()[0], true);
  333.                         General.sleep(General.random(1000, 2000));
  334.                         NPCChat.clickContinue(true);
  335.                         General.sleep(General.random(1000, 2000));
  336.                     }
  337.  
  338.                 }
  339.             } catch (Exception e) {
  340.                 // TODO: handle exception
  341.             }
  342.  
  343.             return General.random(4000, 5000);
  344.         }
  345.         return 0;
  346.     }
  347.  
  348.  
  349.     public static int getIsDreamOpened() {
  350.         try {
  351.             Interfaces.get(129, 6).getChild(9).click("Continue");
  352.             return 1;
  353.         } catch (Exception e) {
  354.             return -1;
  355.         }
  356.     }
  357.    
  358.     private static char[] c = new char[]{'k', 'm', 'b', 't'};
  359.  
  360.     /**
  361.      * Recursive implementation, invokes itself for each factor of a thousand, increasing the class on each invokation.
  362.      * @param n the number to format
  363.      * @param iteration in fact this is the class from the array c
  364.      * @return a String representing the number n formatted in a cool looking way.
  365.      */
  366.     private static String coolFormat(double n, int iteration) {
  367.         double d = ((long) n / 100) / 10.0;
  368.         boolean isRound = (d * 10) %10 == 0;//true if the decimal part is equal to 0 (then it's trimmed anyway)
  369.         return (d < 1000? //this determines the class, i.e. 'k', 'm' etc
  370.             ((d > 99.9 || isRound || (!isRound && d > 9.99)? //this decides whether to trim the decimals
  371.              (int) d * 10 / 10 : d + "" // (int) d * 10 / 10 drops the decimal
  372.              ) + "" + c[iteration])
  373.             : coolFormat(d, iteration+1));
  374.  
  375.     }
  376.  
  377. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement