Guest User

Untitled

a guest
Jul 21st, 2018
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.66 KB | None | 0 0
  1. import com.kbotpro.scriptsystem.events.PaintEventListener;
  2. import com.kbotpro.scriptsystem.fetch.Bank;
  3. import com.kbotpro.scriptsystem.fetch.Game;
  4. import com.kbotpro.scriptsystem.fetch.Skills;
  5. import com.kbotpro.scriptsystem.interfaces.Looped;
  6. import com.kbotpro.scriptsystem.runnable.Script;
  7. import com.kbotpro.scriptsystem.wrappers.IComponent;
  8. import com.kbotpro.scriptsystem.wrappers.Interface;
  9. import com.kbotpro.scriptsystem.wrappers.Item;
  10. import com.kbotpro.scriptsystem.wrappers.PhysicalObject;
  11.  
  12. import java.awt.*;
  13.  
  14. /**
  15. * Created by IntelliJ IDEA.
  16. * User: Liked
  17. * Date: 22-Dec-2009
  18. * Time: 23:49:30
  19. * To change this template use File | Settings | File Templates.
  20. */
  21. public class SuperGlassMaker extends Script implements PaintEventListener {
  22.  
  23. //Stuff we need
  24. private final int[] Staffs = {1381}; // Staffs of air
  25. private final int[] Runes = {9075, 554}; // Astral Runes and Fire Runes.
  26. int Seaweed = 401;
  27. int BucketOfSand = 1783; //Seaweed and Bucket of Sand.
  28. //Stuff we want
  29. private int MoltenGlass = 1775; // A product of the spell
  30. //Bank
  31. private int BankChest = -23344; // Bank Chest in Soul Wars, no randoms!
  32. //Paint
  33. private final long SCRIPT_START = System.currentTimeMillis(); // gets the start time
  34. private int onStartExp; // gets the start exp
  35. private int craftStartExp;
  36. //Bank Withdrawing
  37. private final int WITHDRAW_ALL = 0;
  38. private final int WITHDRAW_X = 1;
  39. private final int WITHDRAW_ALL_BUT_ONE = 2;
  40.  
  41.  
  42. public String getName() {
  43. return "LKSuperGlassMaker";
  44.  
  45. }
  46.  
  47. public boolean canStart() {
  48. return true;
  49. }
  50.  
  51. public void onStart() {
  52. craftStartExp = skills.getExperience(Skills.SKILL_CRAFTING);
  53. onStartExp = skills.getExperience(Skills.SKILL_MAGIC);
  54. }
  55.  
  56. public void pause() {
  57. // We don't need to care about this method for now
  58. }
  59.  
  60. public void stop() {
  61. // We wont do anything here for now
  62. }
  63.  
  64.  
  65. public void registerWorkers() {
  66. createWorker(new Looped() {// Lets create a basic worker
  67.  
  68. public int loop() {
  69.  
  70. if (bank.isOpen()) {
  71. if (bank.contains(Seaweed) && bank.contains(BucketOfSand))
  72. if (bank.getCount(Seaweed) < 13 || bank.getCount(BucketOfSand) < 13) {
  73. game.logout();
  74. return -1;
  75. }
  76. } else {
  77. game.logout();
  78. return -1;
  79. }
  80. if (game.getCurrentTab() != Game.TAB_INVENTORY) {
  81. game.openTab(Game.TAB_INVENTORY);
  82. sleep(150);
  83. }
  84. if (!inventory.contains(Runes)) {//If we have no Astrals or Fires in our inventory log out.
  85. game.logout();
  86. return -1;
  87. }
  88. if (inventory.contains(Seaweed) && (inventory.contains(BucketOfSand))) { //Spell time.
  89. if (game.getCurrentTab() != Game.TAB_MAGIC) {
  90. game.openTab(Game.TAB_MAGIC);
  91. sleep(500);
  92. IComponent SuperGlassMakerSpell = interfaces.getComponent(430, 47);
  93. SuperGlassMakerSpell.doAction("Cast");
  94. sleep(2000, 3000);
  95. }
  96. }
  97. if (inventory.contains(MoltenGlass)) { //If we have molten glass in our inventory, bank it.
  98. PhysicalObject bankObj = objects.getClosestObject(4, BankChest);
  99. if (bankObj == null) return 100;
  100. bankObj.doAction("Use Bank Chest");
  101. sleep(500, 1000);
  102. Item Glass = inventory.getItems(MoltenGlass)[1];
  103. Glass.doAction("Deposit-All");
  104. sleep(500, 1000);
  105. withdraw(401, 13);
  106. sleep(500, 1000);
  107. withdrawAll(1783);
  108. close();
  109.  
  110.  
  111. }
  112. if (!inventory.contains(Seaweed) && (!inventory.contains(BucketOfSand))) { //If we don't have any Seaweed and Sand, get them out of bank.
  113. PhysicalObject bankObj = objects.getClosestObject(4, BankChest);
  114. if (bankObj == null) return 100;
  115. bankObj.doAction("Use Bank Chest");
  116. sleep(500, 1000);
  117. withdraw(401, 13);
  118. sleep(500, 1000);
  119. withdrawAll(1783);
  120. close();
  121.  
  122.  
  123. }
  124. if (inventory.contains(Seaweed) && (!inventory.contains(BucketOfSand))) { //If we don't have any Seaweed and Sand, get them out of bank.
  125. PhysicalObject bankObj = objects.getClosestObject(4, BankChest);
  126. if (bankObj == null) return 100;
  127. bankObj.doAction("Use Bank Chest");
  128. sleep(500, 1000);
  129. Item Glass = inventory.getItems(MoltenGlass)[1];
  130. Glass.doAction("Deposit-All");
  131. close();
  132.  
  133.  
  134. }
  135. return 1000;
  136. }
  137. });
  138. }
  139.  
  140.  
  141. /**
  142. * @param id Id of the item you want to withdraw.
  143. */
  144. public void withdrawAll(int id) {
  145. withdraw(id, 0, WITHDRAW_ALL);
  146. }
  147.  
  148. /**
  149. * @param id Id of the item you want to withdraw.
  150. * @param amount Amount of the item you want to withdraw.
  151. */
  152. public void withdraw(int id, int amount) {
  153. withdraw(id, amount, WITHDRAW_X);
  154.  
  155. }
  156.  
  157.  
  158. /**
  159. * @param id Id of the item you want to withdraw.
  160. * @param amount Amount of the item you want to withdraw.
  161. * @param type Withdraw type - withdraw-x, all, all-but-one
  162. */
  163. private void withdraw(int id, int amount, int type) {
  164. boolean doAction = false;
  165. Item item = bank.getItem(id);
  166. if (bank.contains(id) && item != null) {
  167. if (bank.getCount(id) >= amount) {
  168. IComponent visible = interfaces.getComponent(Bank.BANK_INTERFACE_ID, 3);
  169. if (visible != null) {
  170. if (visible.getBounds().contains(item.getBounds())) { //visible
  171. doAction = true;
  172. } else while (!visible.getBounds().contains(item.getBounds())) {
  173. item = bank.getItem(id);
  174. int scroll;
  175. if (item.getCenter().y < visible.getCenter().y) { //scroll up
  176. scroll = Bank.BANK_SCROLLBAR_UP;
  177. } else scroll = Bank.BANK_SCROLLBAR_DOWN;
  178. IComponent button = interfaces.getComponent(Bank.BANK_INTERFACE_ID, Bank.BANK_SCROLLBAR);
  179. if (button != null) {
  180. button.getChildren()[scroll].doClick();
  181. } else return;
  182. }
  183. doAction = true;
  184. }
  185. }
  186. }
  187. if (doAction) {
  188. Rectangle r = item.getBounds();
  189. mouse.moveMouse(new Point(random(r.x + 2, r.x + r.width - 2), random(r.y + 2, r.y + r.height - 2)));
  190. String action = "Withdraw-" + amount + " ";
  191. if (type == WITHDRAW_ALL) {
  192. action = "Withdraw-All";
  193. } else if (type == WITHDRAW_ALL_BUT_ONE) {
  194. action = "Withdraw-All but one";
  195. }
  196. if (menu.contains(action)) {
  197. menu.atMenu(action);
  198. } else { //withdraw X
  199. menu.atMenu("Withdraw-X");
  200. sleep(random(1000, 2000));
  201. keyboard.writeText(Integer.toString(amount), true);
  202. }
  203. }
  204. }
  205.  
  206. public boolean close() {
  207. if (!bank.isOpen()) return true;
  208.  
  209. Interface bankIFace = interfaces.getInterface(Bank.BANK_INTERFACE_ID);
  210.  
  211. if (bankIFace != null && bankIFace.isValid()) {
  212. IComponent closeButton = interfaces.getComponent(Bank.BANK_INTERFACE_ID, Bank.BANK_BUTTON_CLOSE);
  213. Point closeUL = closeButton.getUpperLeftScreenPos();
  214. try {
  215. mouse.moveMouse(new Point((int) closeUL.getX() + random(0, (int) closeButton.getBounds().getWidth()), (int) closeUL.getY() + random(0, (int) closeButton.getBounds().getHeight())));
  216. sleep(10, 20);
  217. if (menu.atMenu("Close"))
  218. return true;
  219. } catch (Exception e) {
  220. }
  221. }
  222.  
  223. return false;
  224. }
  225.  
  226.  
  227. public void onRepaint(Graphics g) {
  228. float expPerHour = 0;
  229. float moneyPerHour = 0;
  230. float craftExpPerHour = 0;
  231. int xpGained = skills.getExperience(Skills.SKILL_MAGIC) - onStartExp;
  232. int craftXpGained = skills.getExperience(Skills.SKILL_CRAFTING) - craftStartExp;
  233. long runTime = System.currentTimeMillis() - SCRIPT_START;
  234. int secs = ((int) ((runTime / 1000) % 60));
  235. int mins = ((int) (((runTime / 1000) / 60) % 60));
  236. int hours = ((int) ((((runTime / 1000) / 60) / 60) % 60));
  237. int casts = ((skills.getExperience(Skills.SKILL_MAGIC) - onStartExp) / 78);
  238. int profit = ((int) ((461 * 17.5) - (255 + 239) * 13) * casts);
  239. if ((mins > 0 || hours > 0 || secs > 0) && (craftXpGained) > 0) {
  240. craftExpPerHour = ((float) (craftXpGained) / (float) (secs + (mins * 60) + (hours * 60 * 60)));
  241. }
  242. if ((mins > 0 || hours > 0 || secs > 0) && (xpGained) > 0) {
  243. expPerHour = ((float) (xpGained) / (float) (secs + (mins * 60) + (hours * 60 * 60)));
  244. }
  245. if ((mins > 0 || hours > 0 || secs > 0) && (profit) > 0) {
  246. moneyPerHour = ((float) (profit) / (float) (secs + (mins * 60) + (hours * 60 * 60)));
  247. }
  248. int x = 20;
  249. int y = 40;
  250. g.setColor(new Color(230, 230, 50, 80));
  251. y += 18;
  252. g.setColor(Color.red);
  253. g.setFont(new Font("Comic Sans", Font.BOLD, 12));
  254. y += 15;
  255. g.drawString("Liked's SuperGlass Maker 0.1", x, y);
  256. y += 15;
  257. g.drawString("Run Time: " + hours + "." + mins + "." + secs, x, y);
  258. y += 15;
  259. g.drawString("Current Level: " + skills.getLevel(Skills.SKILL_MAGIC), x, y);
  260. y += 15;
  261. g.drawString(("Profit: " + profit), x, y);
  262. y += 15;
  263. g.drawString(("Profit P/H: " + moneyPerHour), x, y);
  264. y += 15;
  265. g.drawString(("Magic Exp P/H: " + expPerHour), x, y);
  266. y += 15;
  267. g.drawString("Craft Exp P/H: " + craftExpPerHour, x, y);
  268. y += 15;
  269. g.drawString(("Casts: " + (casts)), x, y);
  270. }
  271. }
Add Comment
Please, Sign In to add comment