Advertisement
Guest User

Untitled

a guest
Aug 17th, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.32 KB | None | 0 0
  1. package scripts;
  2.  
  3. import java.awt.Color;
  4. import java.awt.Graphics;
  5.  
  6. import org.tribot.api2007.Interfaces;
  7. import org.tribot.api2007.Inventory;
  8. import org.tribot.api2007.Magic;
  9. import org.tribot.api2007.Skills;
  10. import org.tribot.api.General;
  11. import org.tribot.api.Timing;
  12. import org.tribot.api.input.Mouse;
  13. import org.tribot.api2007.GameTab.TABS;
  14. import org.tribot.api2007.Skills.SKILLS;
  15. import org.tribot.api2007.types.RSInterface;
  16. import org.tribot.api2007.types.RSInterfaceChild;
  17. import org.tribot.api2007.types.RSItem;
  18. import org.tribot.script.Script;
  19. import org.tribot.script.ScriptManifest;
  20. import org.tribot.script.interfaces.Painting;
  21.  
  22. import scripts.DeadmanBar.State;
  23.  
  24. @ScriptManifest(authors = { "helloworldlol" }, category = "Magic", name = " Emerald bolts")
  25. public class Enchanting extends Script implements Painting {
  26.  
  27. @Override
  28. public void onPaint(Graphics g) {
  29. g.setColor(Color.WHITE);
  30. g.drawString("State: " + SCRIPT_STATE, 10, 65);
  31. int xpGained = (CURRENT_XP - START_XP);
  32. long timeRan = System.currentTimeMillis() - START_TIME;
  33. double multiplier = timeRan / 3600000D;
  34. int xpPerHour = (int) (xpGained / multiplier);
  35. g.drawString("Mage XP Gained: " + (int) (xpGained) + " | " + "Per Hour: " + (int) (xpPerHour), 10, 80);
  36. }
  37.  
  38. private final int START_XP = Skills.getXP(SKILLS.MAGIC);
  39. private final long START_TIME = System.currentTimeMillis();
  40. private int CURRENT_XP = START_XP;
  41. private boolean running = true;
  42. private State SCRIPT_STATE = getState();
  43.  
  44. @Override
  45. public void run() {
  46. while (running) {
  47. CURRENT_XP = Skills.getXP(SKILLS.MAGIC);
  48. SCRIPT_STATE = getState();
  49. switch (SCRIPT_STATE) {
  50. case ENCHANT:
  51. enchant();
  52. break;
  53. case LOG_OUT:
  54. running = false;
  55. break;
  56. default:
  57. break;
  58.  
  59. }
  60. }
  61. }
  62.  
  63. private State getState() {
  64. State state = hasRunes() ? State.ENCHANT : State.LOG_OUT;
  65. return state;
  66. }
  67.  
  68. private void enchant() {
  69. if (TABS.MAGIC.isOpen()) {
  70. if (isEnchantOpen()) {
  71. RSInterfaceChild emeralds = Interfaces.get(80, getBoltInterface());
  72. if (emeralds != null && !emeralds.isHidden()) {
  73. Mouse.clickBox(emeralds.getAbsoluteBounds(), 1);
  74. long t = System.currentTimeMillis();
  75. int r = General.random(750, 1750);
  76. while (Timing.timeFromMark(t) < r) {
  77. sleep(25, 50);
  78. if (!isEnchantOpen())
  79. break;
  80. }
  81. }
  82. } else {
  83. if (Magic.selectSpell("Enchant Crossbow Bolt")) {
  84. long t = System.currentTimeMillis();
  85. int r = General.random(400, 1850);
  86. while (Timing.timeFromMark(t) < r) {
  87. sleep(25, 50);
  88. if (isEnchantOpen())
  89. break;
  90. }
  91. }
  92.  
  93. }
  94. } else
  95. TABS.MAGIC.open();
  96. }
  97.  
  98. private int getBoltInterface() {
  99. int mage = Skills.SKILLS.MAGIC.getActualLevel();
  100. if (mage >= 4 && mage < 7) {
  101. return 2;
  102. } else if (mage >= 7 && mage < 27)
  103. return 3;
  104. else
  105. return 6;
  106. }
  107.  
  108. private boolean isEnchantOpen() {
  109. RSInterface enchant = Interfaces.get(80);
  110. return enchant != null && !enchant.isHidden();
  111. }
  112.  
  113. private boolean hasRunes() {
  114. RSItem[] nature = Inventory.find("Nature rune");
  115. RSItem[] cosmic = Inventory.find("Cosmic rune");
  116. RSItem[] bolts = Inventory.find("Emerald bolts");
  117. return nature.length > 0 && cosmic.length > 0 && bolts.length > 0;
  118. }
  119.  
  120. private enum State {
  121. ENCHANT, LOG_OUT;
  122. }
  123.  
  124. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement