Advertisement
Guest User

Untitled

a guest
May 27th, 2015
256
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.24 KB | None | 0 0
  1.  
  2.  
  3. import java.awt.Color;
  4. import java.awt.Graphics2D;
  5. import java.awt.Image;
  6. import java.io.IOException;
  7. import java.net.URL;
  8.  
  9. import org.osbot.rs07.api.model.Entity;
  10. import org.osbot.rs07.api.ui.Skill;
  11. import org.osbot.rs07.script.Script;
  12. import org.osbot.rs07.script.ScriptManifest;
  13.  
  14.  
  15. import java.awt.*;
  16. import java.util.concurrent.TimeUnit;
  17.  
  18. import javax.imageio.ImageIO;
  19. import javax.swing.JOptionPane;
  20.  
  21. @ScriptManifest(name = "Dubzie's Power Chopper", author = "Dubzieisme23", version = 1.1, info = "", logo = "http://s30.postimg.org/6qt1wvnzx/logo1.png")
  22. public class main extends Script {
  23.  
  24.  
  25.  
  26. int[] axes = {1352, 1349, 1353, 1361, 1355, 1357, 1359, 6739};
  27.  
  28. int[] logs = {1511, 1521, 1519, 1515, 1513};
  29.  
  30. private final Image bg = getImage("http://s13.postimg.org/mhc3szdnr/awesome_signature_dubzieisme23.png");
  31. private long timeBegan;
  32. private long timeRan;
  33. private int beginningXP;
  34. private int currentXp;
  35. private int xpGained;
  36. private int currentLevel;
  37. private int beginningLevel;
  38. private int levelsGained;
  39. private int xpPerHour;
  40. private int cameraPitch = (0 - 50);
  41. private double nextLevelXp;
  42. private double xpTillNextLevel;
  43. private long timeTNL;
  44.  
  45.  
  46. String input;
  47. boolean isnotvisable;
  48.  
  49. final int[] XP_TABLE =
  50. {
  51. 0, 0, 83, 174, 276, 388, 512, 650, 801, 969, 1154,
  52. 1358, 1584, 1833, 2107, 2411, 2746, 3115, 3523, 3973, 4470, 5018,
  53. 5624, 6291, 7028, 7842, 8740, 9730, 10824, 12031, 13363, 14833,
  54. 16456, 18247, 20224, 22406, 24815, 27473, 30408, 33648, 37224,
  55. 41171, 45529, 50339, 55649, 61512, 67983, 75127, 83014, 91721,
  56. 101333, 111945, 123660, 136594, 150872, 166636, 184040, 203254,
  57. 224466, 247886, 273742, 302288, 333804, 368599, 407015, 449428,
  58. 496254, 547953, 605032, 668051, 737627, 814445, 899257, 992895,
  59. 1096278, 1210421, 1336443, 1475581, 1629200, 1798808, 1986068,
  60. 2192818, 2421087, 2673114, 2951373, 3258594, 3597792, 3972294,
  61. 4385776, 4842295, 5346332, 5902831, 6517253, 7195629, 7944614,
  62. 8771558, 9684577, 10692629, 11805606, 13034431, 200000000
  63. };
  64.  
  65. @Override
  66. public void onStart() {
  67.  
  68. timeTNL = 0;
  69. beginningLevel = skills.getStatic(Skill.WOODCUTTING);
  70. timeBegan = System.currentTimeMillis();
  71. beginningXP = skills.getExperience(Skill.WOODCUTTING);
  72. input = JOptionPane.showInputDialog("What would you like to cut? " + "Type exact type of tree ex. Tree, Oak, Willow, Yew, Magic");
  73.  
  74. }
  75.  
  76. private Image getImage(String url)
  77. {
  78. try
  79. {
  80. return ImageIO.read(new URL(url));
  81. }
  82. catch (IOException e) {}
  83. return null;
  84. }
  85.  
  86.  
  87. private boolean canUseRun(){
  88. // The coordinates we check for the color
  89. int x = 588, y = 135;
  90. // The color when the orb is NOT full at this coordinate (black)
  91. int runOrbColorEmpty = new Color(11,11,11).getRGB();
  92. // We have not went below about half (50%) run energy yet
  93. return (colorPicker.colorAt(x, y).getRGB() != runOrbColorEmpty);
  94. }
  95. private boolean enableRun() throws InterruptedException{
  96. int orbTopLeftX=544, orbTopY=128;
  97. int orbBotRightX = 593, orbBotY = 151;
  98. Rectangle rect = new Rectangle(orbTopLeftX, orbTopY, orbBotRightX, orbBotY);
  99.  
  100. int mouseX = random (orbTopLeftX, orbBotRightX);
  101. int mouseY = random (orbTopY, orbBotY);
  102.  
  103. mouse.move (mouseX, mouseY);
  104.  
  105. while (!rect.contains (mouse.getPosition())){
  106. // TODO: Failsafe...
  107.  
  108. sleep (random(250, 500));
  109. }
  110.  
  111. mouse.click (false);
  112.  
  113. return true;
  114. }
  115.  
  116. @Override
  117. public void onExit() {
  118. //Code here will execute after the script ends
  119. log("Thank you for using a dubzie script.");
  120. }
  121.  
  122. @Override
  123. public int onLoop() throws InterruptedException {
  124.  
  125. Entity Tree = objects.closest(input);
  126.  
  127. if(getInventory().isFull()){
  128.  
  129. getInventory().dropAllExcept(axes);
  130.  
  131. return random(899, 1889);
  132. }
  133.  
  134. if(getInventory().isItemSelected()) {
  135. getInventory().deselectItem();
  136. }
  137. if(canUseRun() && !settings.isRunning()){
  138. enableRun();
  139. return random(800, 985);
  140. }
  141.  
  142. if(getCamera().getPitchAngle() != cameraPitch) {
  143. getCamera().movePitch(random.nextInt(20) + 5);
  144. }else if(getCamera().getYawAngle() != cameraPitch) {
  145. getCamera().moveYaw(random.nextInt(25 + 10));
  146. }
  147.  
  148. if(!myPlayer().isAnimating() && !myPlayer().isMoving()) {
  149. if(Tree != null) {
  150. if (Tree.isVisible()) {
  151. Tree.interact("Chop down");
  152. return(random(250, 1455));
  153. }else{
  154.  
  155. map.walk(Tree);
  156. return random (800, 1000);
  157.  
  158. }
  159.  
  160. }
  161.  
  162. }
  163.  
  164.  
  165. return 400; //The amount of time in milliseconds before the loop starts over
  166. }
  167.  
  168.  
  169.  
  170. @Override
  171. public void onPaint(Graphics2D g) {
  172.  
  173. timeRan = System.currentTimeMillis() - this.timeBegan;
  174.  
  175. g.drawImage(bg, 2, 279, null);
  176. g.setColor(Color.BLACK);
  177. g.setFont(new Font("Impact", Font.BOLD, 18));
  178. g.drawString(ft(timeRan), 157, 371);
  179. currentXp = skills.getExperience(Skill.WOODCUTTING);
  180. g.drawString("" + xpGained, 157, 420);
  181. currentLevel = skills.getStatic(Skill.WOODCUTTING);
  182. levelsGained = currentLevel - beginningLevel;
  183. xpGained = currentXp - beginningXP;
  184. xpPerHour = (int)( xpGained / ((System.currentTimeMillis() - this.timeBegan) / 3600000.0D));
  185. nextLevelXp = XP_TABLE[currentLevel + 1];
  186. xpTillNextLevel = nextLevelXp - currentXp;
  187. if (xpGained >= 1)
  188. {
  189. timeTNL = (long) ((xpTillNextLevel / xpPerHour) * 3600000);
  190. }
  191. g.drawString("" + ft(timeTNL), 157, 464);
  192. g.drawString("" + beginningLevel, 430, 462);
  193. g.drawString("" + levelsGained, 413, 419);
  194. g.drawString("" + currentLevel, 376, 372);
  195.  
  196. }
  197.  
  198. private String ft(long duration)
  199. {
  200. String res = "";
  201. long days = TimeUnit.MILLISECONDS.toDays(duration);
  202. long hours = TimeUnit.MILLISECONDS.toHours(duration)
  203. - TimeUnit.DAYS.toHours(TimeUnit.MILLISECONDS.toDays(duration));
  204. long minutes = TimeUnit.MILLISECONDS.toMinutes(duration)
  205. - TimeUnit.HOURS.toMinutes(TimeUnit.MILLISECONDS
  206. .toHours(duration));
  207. long seconds = TimeUnit.MILLISECONDS.toSeconds(duration)
  208. - TimeUnit.MINUTES.toSeconds(TimeUnit.MILLISECONDS
  209. .toMinutes(duration));
  210. if (days == 0) {
  211. res = (hours + ":" + minutes + ":" + seconds);
  212. } else {
  213. res = (days + ":" + hours + ":" + minutes + ":" + seconds);
  214. }
  215. return res;
  216. }
  217. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement