Advertisement
Guest User

Untitled

a guest
May 25th, 2015
252
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.21 KB | None | 0 0
  1. import org.osbot.rs07.api.model.Entity;
  2. import org.osbot.rs07.api.model.NPC;
  3. import org.osbot.rs07.api.ui.Message;
  4. import org.osbot.rs07.api.ui.Skill;
  5. import org.osbot.rs07.script.Script;
  6. import org.osbot.rs07.script.ScriptManifest;
  7. import org.osbot.rs07.utility.Area;
  8.  
  9. import java.awt.*;
  10. import java.util.Timer;
  11. import java.util.concurrent.TimeUnit;
  12.  
  13. import javax.swing.*;
  14.  
  15. @ScriptManifest(name = "Dubzie's Bracelets", author = "Dubzieisme23", version = 1.6, info = "", logo = "")
  16. public class main6 extends Script {
  17.  
  18. gbfilter goldbarm = new gbfilter();
  19. int goldbar = 2357;
  20. int mould = 11065;
  21. int bracelet = 11069;
  22. int furnace = 16469;
  23. String keyboard = "33";
  24.  
  25. private int BraceletsMade;
  26. public static Timer runTime;
  27. public int startExp;
  28. private int currentLevel;
  29. private int beginningLevel;
  30. private int levelsGained;
  31. private long timeBegan;
  32. private int xpGained;
  33. private int xpPerHour;
  34. private int currentXp;
  35. private int beginningXp;
  36. private double nextLevelXp;
  37. private long timeTNL;
  38. private double xpTillNextLevel;
  39.  
  40.  
  41. final int[] XP_TABLE = { 0, 0, 83, 174, 276, 388, 512, 650, 801, 969, 1154,
  42. 1358, 1584, 1833, 2107, 2411, 2746, 3115, 3523, 3973, 4470, 5018,
  43. 5624, 6291, 7028, 7842, 8740, 9730, 10824, 12031, 13363, 14833,
  44. 16456, 18247, 20224, 22406, 24815, 27473, 30408, 33648, 37224,
  45. 41171, 45529, 50339, 55649, 61512, 67983, 75127, 83014, 91721,
  46. 101333, 111945, 123660, 136594, 150872, 166636, 184040, 203254,
  47. 224466, 247886, 273742, 302288, 333804, 368599, 407015, 449428,
  48. 496254, 547953, 605032, 668051, 737627, 814445, 899257, 992895,
  49. 1096278, 1210421, 1336443, 1475581, 1629200, 1798808, 1986068,
  50. 2192818, 2421087, 2673114, 2951373, 3258594, 3597792, 3972294,
  51. 4385776, 4842295, 5346332, 5902831, 6517253, 7195629, 7944614,
  52. 8771558, 9684577, 10692629, 11805606, 13034431, 200000000 };
  53.  
  54. private static final Area BANK_AREA = new Area(3098, 3495, 3095, 3494);
  55. static final Area SMELT_AREA = new Area(3106, 3501, 3110, 3497);
  56. static final Area BIGBANK_AREA = new Area(3099, 3501, 3090, 3487);
  57.  
  58.  
  59.  
  60. public void onStart() {
  61. //Code here will execute before the loop is started
  62. JOptionPane.showMessageDialog(null, "Welcome to Dubzie's Gold Bracelet Maker Muhaha");
  63.  
  64. BraceletsMade = 0;
  65. timeBegan = System.currentTimeMillis();
  66. beginningXp = skills.getExperience(Skill.CRAFTING);
  67. timeTNL = 0;
  68. runTime = new Timer();
  69. startExp = getSkills().getExperience(Skill.CRAFTING);
  70. beginningLevel = skills.getStatic(Skill.CRAFTING);
  71.  
  72. }
  73.  
  74. private boolean canUseRun(){
  75. // The coordinates we check for the color
  76. int x = 588, y = 135;
  77. // The color when the orb is NOT full at this coordinate (black)
  78. int runOrbColorEmpty = new Color(11,11,11).getRGB();
  79. // We have not went below about half (50%) run energy yet
  80. return (colorPicker.colorAt(x, y).getRGB() != runOrbColorEmpty);
  81. }
  82.  
  83. private boolean enableRun() throws InterruptedException{
  84. int orbTopLeftX=544, orbTopY=128;
  85. int orbBotRightX = 593, orbBotY = 151;
  86. Rectangle rect = new Rectangle(orbTopLeftX, orbTopY, orbBotRightX, orbBotY);
  87.  
  88. int mouseX = random (orbTopLeftX, orbBotRightX);
  89. int mouseY = random (orbTopY, orbBotY);
  90.  
  91. mouse.move (mouseX, mouseY);
  92.  
  93. while (!rect.contains (mouse.getPosition())){
  94.  
  95. sleep (random(250, 500));
  96. }
  97.  
  98. mouse.click (false);
  99.  
  100. return true;
  101. }
  102.  
  103. public void onExit() {
  104. //Code here will execute after the script ends
  105.  
  106.  
  107. }
  108.  
  109.  
  110. public int onLoop() throws InterruptedException {
  111.  
  112. Entity Furnace = objects.closest(furnace);
  113. Entity bank = objects.closest("Bank booth");
  114. NPC banker = npcs.closest("Banker");
  115.  
  116. if (getWidgets().isVisible(446, 44)) {
  117. log("getting interface");
  118. getWidgets().interact(446, 44, "Make-X");
  119. sleep (random(777, 899));
  120. }
  121.  
  122. if(canUseRun() && !settings.isRunning()){
  123. enableRun();
  124. return random(2000, 4000);
  125. }
  126. if(getInventory().onlyContains(mould, bracelet) && SMELT_AREA.contains(myPlayer())){
  127. map.walk(BANK_AREA);
  128. }
  129. if(!myPlayer().isMoving() && BIGBANK_AREA.contains(myPlayer())){
  130. if(!getInventory().onlyContains(mould, goldbar) && !getInventory().onlyContains(mould) && getInventory().onlyContains(mould, bracelet) && bank != null && bank.isVisible()){
  131. log("Depositing Bracelets");
  132. map.walk(bank);
  133. bank.interact("Bank");
  134. sleep (random(1111, 2222));
  135. getBank().depositAll(bracelet);
  136. return random(1111, 2222);
  137. }
  138. if(getWidgets().isVisible(12, 10) && !myPlayer().isMoving() && getInventory().isEmptyExcept(mould) && bank != null && bank.isVisible()){
  139. log("Withdrawing Gold Bars");
  140. sleep (random(444, 687));
  141. getBank().withdrawAll("Gold bar");
  142. if(!getWidgets().isVisible(12, 10)){
  143. bank.interact("Bank");
  144. }
  145. }
  146. }
  147. if(!SMELT_AREA.contains(myPlayer()) && !myPlayer().isMoving() && getInventory().onlyContains(goldbar, mould)){
  148. log("Walking to smelt area");
  149. map.walk(3109, 3499);
  150. sleep (random(1111, 2222));
  151. }
  152. if(myPlayer().isAnimating()){
  153. log("Not doing squat because i is animating yo");
  154.  
  155. return random(4000, 8000);
  156. }
  157. if(Furnace != null &&
  158. Furnace.isVisible() &&
  159. SMELT_AREA.contains(myPlayer())){
  160.  
  161.  
  162. if(getWidgets().isVisible(446, 44)){
  163. log("widget is visable not doing sht");
  164. }
  165. if(!getWidgets().isVisible(446, 44) &&
  166. !myPlayer().isAnimating())
  167. {
  168. sleep(random(666, 1244));
  169. getInventory().interact("Use", "Gold bar");
  170. log("Using gold bar");
  171.  
  172. }
  173.  
  174. }
  175. if( Furnace != null &&
  176. Furnace.isVisible() &&
  177. SMELT_AREA.contains(myPlayer())){
  178.  
  179.  
  180. if(!getWidgets().isVisible(446, 44) &&
  181. !myPlayer().isAnimating())
  182. {
  183. log("Interacting with furnace");
  184. sleep(1433);
  185. Furnace.interact("Use");
  186.  
  187. }
  188. }
  189.  
  190. if(getInventory().onlyContains(mould) && !BANK_AREA.contains(myPlayer())){
  191. log("Walking to bank");
  192. map.walk(BANK_AREA);
  193. return random(1111, 3333);
  194. }
  195.  
  196. if (!getWidgets().isVisible(12, 10, 0) && getInventory().onlyContains(mould) && BANK_AREA.contains(myPlayer())){
  197. log("Getting some gold up in here");
  198. banker.interact("Bank");
  199. return random(1111, 3333);
  200. }
  201.  
  202. if (SMELT_AREA.contains(myPlayer()) && getWidgets().isVisible(548, 120)){
  203. log("Making bracelets");
  204. getKeyboard().typeString(keyboard);
  205. return random(1111, 1888);
  206. }
  207. return 222;
  208. }
  209.  
  210. public void onPaint(Graphics2D g) {
  211. //This is where you will put your code for paint(s)
  212.  
  213. g.setColor(Color.CYAN);
  214. g.setFont(new Font("Impact", Font.BOLD, 15));
  215. currentXp = skills.getExperience(Skill.CRAFTING);
  216. currentLevel = skills.getStatic(Skill.CRAFTING);
  217. xpGained = currentXp - beginningXp;
  218. xpPerHour = (int) (xpGained / ((System.currentTimeMillis() - this.timeBegan) / 3600000.0D));
  219. nextLevelXp = XP_TABLE[currentLevel + 1];
  220. xpTillNextLevel = nextLevelXp - currentXp;
  221. if (xpGained >= 1) {
  222. timeTNL = (long) ((xpTillNextLevel / xpPerHour) * 3600000);
  223. }
  224.  
  225. g.drawString("Time until level " + ft(timeTNL), 10, 200);
  226. currentLevel = skills.getStatic(Skill.CRAFTING);
  227. levelsGained = currentLevel - beginningLevel;
  228. g.drawString("Beginning Level " + beginningLevel, 10, 225);
  229. g.drawString("Current Level " + currentLevel, 10, 250);
  230. g.drawString("Levels Gained " + levelsGained, 10, 275);
  231. g.drawString("Bracelets Made " + BraceletsMade, 10, 300);
  232.  
  233.  
  234. }
  235.  
  236. public void onMessage(Message message)
  237. throws java.lang.InterruptedException {
  238. String OreTxt = message.getMessage().toLowerCase();
  239.  
  240. if (OreTxt.contains("a bracelet")
  241. && (getInventory().contains("Gold bracelet"))) {
  242. BraceletsMade++;
  243. }
  244. }
  245.  
  246. private String ft(long duration) {
  247. String res = "";
  248. long days = TimeUnit.MILLISECONDS.toDays(duration);
  249. long hours = TimeUnit.MILLISECONDS.toHours(duration)
  250. - TimeUnit.DAYS.toHours(TimeUnit.MILLISECONDS.toDays(duration));
  251. long minutes = TimeUnit.MILLISECONDS.toMinutes(duration)
  252. - TimeUnit.HOURS.toMinutes(TimeUnit.MILLISECONDS
  253. .toHours(duration));
  254. long seconds = TimeUnit.MILLISECONDS.toSeconds(duration)
  255. - TimeUnit.MINUTES.toSeconds(TimeUnit.MILLISECONDS
  256. .toMinutes(duration));
  257. if (days == 0) {
  258. res = (hours + ":" + minutes + ":" + seconds);
  259. } else {
  260. res = (days + ":" + hours + ":" + minutes + ":" + seconds);
  261. }
  262. return res;
  263.  
  264. }
  265. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement