Advertisement
Guest User

Untitled

a guest
Jan 11th, 2018
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.75 KB | None | 0 0
  1. /*
  2. * To change this license header, choose License Headers in Project Properties.
  3. * To change this template file, choose Tools | Templates
  4. * and open the template in the editor.
  5. */
  6. package main;
  7.  
  8. import org.dreambot.api.methods.Calculations;
  9. import org.dreambot.api.methods.container.impl.bank.BankLocation;
  10. import org.dreambot.api.methods.container.impl.bank.BankType;
  11. import org.dreambot.api.methods.map.Tile;
  12. import org.dreambot.api.methods.skills.Skill;
  13. import org.dreambot.api.script.AbstractScript;
  14. import org.dreambot.api.script.Category;
  15. import org.dreambot.api.script.ScriptManifest;
  16. import org.dreambot.api.wrappers.interactive.GameObject;
  17. import org.dreambot.api.wrappers.widgets.WidgetChild;
  18.  
  19. @ScriptManifest(author = "Pelli", category = Category.MISC, name = "Amulet Maker", version = 0)
  20. public class Main extends AbstractScript {
  21.  
  22. private int amuletsMade = 0;
  23. private final int startingLevel = getSkills().getRealLevel(Skill.CRAFTING);
  24.  
  25. private final int FURNANCE_ID = 24009;
  26. private final Tile TILE_FURNANCE = new Tile(2975, 3369);
  27. private final Tile TILE_BANK = BankLocation.FALADOR_WEST.getCenter();
  28.  
  29. private State state;
  30.  
  31. public enum State {
  32. BANK, MELT;
  33. }
  34.  
  35. public State getState() {
  36. if (getInventory().isFull() && !getInventory().contains("Gold bar")) {
  37. return State.BANK;
  38. } else {
  39. return State.MELT;
  40. }
  41. }
  42.  
  43. private void walkToFurnance() {
  44. getWalking().walk(TILE_FURNANCE);
  45. sleepUntil(() -> getLocalPlayer().getTile().distance(TILE_FURNANCE) < 4, Calculations.random(11045, 15478));
  46. }
  47.  
  48. @Override
  49. public void onStart(){
  50. log("Started");
  51. }
  52.  
  53. @Override
  54. public int onLoop() {
  55. state = getState();
  56.  
  57. switch (state) {
  58. case BANK:
  59. if (getLocalPlayer().getTile().distance(TILE_BANK) > 2) {
  60. if (getWalking().shouldWalk()) {
  61. getWalking().walk(TILE_BANK);
  62. }
  63. } else {
  64. getBank().getClosestBank(BankType.BOOTH).interact("Bank");
  65. sleepUntil(() -> getBank().isOpen(), Calculations.random(2322, 3480));
  66. if (getBank().isOpen()) {
  67. getBank().depositAllExcept("Amulet mould");
  68. amuletsMade+=27;
  69. log("Amulets made:" +amuletsMade);
  70. getBank().withdrawAll("Gold bar");
  71. }
  72. if (Calculations.random(0, 100) > 90) {
  73. getBank().close();
  74. walkToFurnance();
  75. } else {
  76. walkToFurnance();
  77. }
  78. }
  79. break;
  80. case MELT:
  81. if (!getLocalPlayer().isAnimating()) {
  82. GameObject furnance = getGameObjects().closest(FURNANCE_ID);
  83. getInventory().interact(Calculations.random(1, 9), "use");
  84. furnance.interact();
  85.  
  86. //widgets
  87. WidgetChild makeAll = getWidgets().getWidgetChild(446,34);
  88. if(makeAll != null && makeAll.isVisible()){
  89. makeAll.interact("Make-All");
  90. }
  91. //wait untill everything is smelted
  92. sleepUntil(()->{
  93. sleep(2000);
  94. return getInventory().contains("Gold bar") || !getLocalPlayer().isAnimating();
  95. }, Calculations.random(2*60*1000));
  96. }
  97. break;
  98. }
  99. return Calculations.random(354, 689);
  100. }
  101. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement