Advertisement
Guest User

Simple Log Burner

a guest
Feb 28th, 2015
226
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.68 KB | None | 0 0
  1. package main;
  2.  
  3. import java.awt.BasicStroke;
  4. import java.awt.Color;
  5. import java.awt.Font;
  6. import java.awt.Graphics;
  7. import java.awt.Graphics2D;
  8. import java.awt.Stroke;
  9.  
  10. import org.dreambot.api.methods.Calculations;
  11. import org.dreambot.api.methods.MethodProvider;
  12. import org.dreambot.api.methods.bank.BankLocation;
  13. import org.dreambot.api.methods.map.Area;
  14. import org.dreambot.api.methods.map.Tile;
  15. import org.dreambot.api.script.AbstractScript;
  16. import org.dreambot.api.script.Category;
  17. import org.dreambot.api.script.ScriptManifest;
  18. import org.dreambot.api.utilities.Timer;
  19. import org.dreambot.api.utilities.impl.Condition;
  20. import org.dreambot.api.wrappers.interactive.Player;
  21. import org.dreambot.api.wrappers.items.Item;
  22.  
  23. import data.Settings;
  24.  
  25.  
  26. @ScriptManifest(author = "Franjey", category = Category.FIREMAKING, name = "Franjey's Log Burner", version = 0.1, description = "Trains Firemaking")
  27.  
  28.  
  29. public class LogBurner extends AbstractScript{
  30.  
  31. /////////////////////////////////////////////////////////////////////////////////////////////////
  32. ////////////***
  33. ////////////***Variable Declarations
  34. /////////////////////////////////////////////////////////////////////////////////////////////////
  35. private final Color color1 = new Color(51, 51, 51, 147);
  36. private final Color color2 = new Color(0, 233, 165);
  37. private final Color color3 = new Color(255, 255, 255);
  38. private final BasicStroke stroke1 = new BasicStroke(5);
  39. private final Font font1 = new Font("Century Gothic", 0, 13);
  40. private final Font font2 = new Font("Century Gothic", 0, 13);
  41. private final Font font3 = new Font("Century Gothic", 0, 13);
  42. private Timer t = new Timer();
  43.  
  44. private LogBurner script;
  45. private Area rangeArea;
  46. private Tile burnTile = new Tile(3227, 3159, 0);
  47. int tinderbox;
  48. Player myPlayer = getPlayers().myPlayer();
  49.  
  50. public void setBurnTile(Tile tile) {
  51. this.burnTile = tile;
  52. }
  53.  
  54. /////////////////////////////////////////////////////////////////////////////////////////////////
  55. ////////////***
  56. ////////////***Enum Declarations
  57. /////////////////////////////////////////////////////////////////////////////////////////////////
  58. private State state;
  59. private enum State{
  60. WALK_TO_BANK, WALK_TO_BURNAREA, BANK, BURN
  61. }
  62.  
  63. private State getState(){
  64. if(getInventory().onlyContains("Tinderbox")){
  65. if(BankLocation.AL_KHARID.getArea(3).contains(getLocalPlayer())) {
  66. return State.BANK;
  67. }
  68. else
  69. return State.WALK_TO_BANK;
  70. }
  71. else {
  72. if(rangeArea.contains(getLocalPlayer())){
  73. return State.BURN;
  74. }
  75. else
  76. return State.WALK_TO_BURNAREA;
  77. }
  78. }
  79.  
  80. /////////////////////////////////////////////////////////////////////////////////////////////////
  81. ////////////***
  82. ////////////***onStart()
  83. /////////////////////////////////////////////////////////////////////////////////////////////////
  84. @Override
  85. public void onStart(){
  86. log("Welcome to the script");
  87. }
  88.  
  89. /////////////////////////////////////////////////////////////////////////////////////////////////
  90. ////////////***
  91. ////////////***onExit()
  92. /////////////////////////////////////////////////////////////////////////////////////////////////
  93. public void onExit() {
  94. log("Ending script");
  95. }
  96.  
  97. /////////////////////////////////////////////////////////////////////////////////////////////////
  98. ////////////***
  99. ////////////***Main Processing - onLoop()
  100. /////////////////////////////////////////////////////////////////////////////////////////////////
  101. @Override
  102. public int onLoop() {
  103.  
  104. getDialogues().clickContinue();
  105.  
  106. if(!getWalking().isRunEnabled() && getWalking().getRunEnergy() > (int)Calculations.random(30,50)){
  107. getWalking().toggleRun();
  108. }
  109.  
  110. state = getState();
  111. switch(state){
  112. case WALK_TO_BURNAREA:
  113. if(getBank().isOpen()) {
  114. getBank().close();
  115. }
  116.  
  117. if (script.getWalking().walk(Settings.rangeArea.getRandomTile())) {
  118. MethodProvider.sleepWhile(() -> script.getLocalPlayer().isMoving(), (int)Calculations.gRandom(600, 200));
  119. }
  120. break;
  121.  
  122. case BURN:
  123.  
  124. Item tinderbox = getInventory().getItem("Tinderbox");
  125. Item logs = getInventory().getItem("Logs");
  126.  
  127. if(tinderbox != null && logs != null){
  128. getWalking().walk(burnTile);
  129. getInventory().interactWithItem("Tinderbox", "Use");
  130. getInventory().interactWithItem("Logs", "Use");
  131. log("Burning logs");
  132.  
  133. MethodProvider.sleepUntil(new Condition() {
  134. @Override
  135. public boolean verify() {
  136. return getInventory().getItem("Tinderbox").useOn("Logs");
  137. }
  138. }, 7000);
  139. }
  140. break;
  141.  
  142. case BANK:
  143. if(getBank().isOpen()){
  144. getBank().withdrawAll("Logs");
  145. }
  146. else{
  147. getBank().openBank(BankLocation.AL_KHARID.getBankType());
  148. sleepUntil(new Condition(){
  149. public boolean verify(){
  150. return getBank().isOpen();
  151. }
  152. },1200);
  153. }
  154. break;
  155.  
  156. case WALK_TO_BANK:
  157. if(rangeArea.contains(getLocalPlayer())){
  158. getWalking().walk(BankLocation.AL_KHARID.getCenter());
  159. //getWalking().walkTilePath(druidsToBank, Calculations.random(20,30));
  160. }
  161. break;
  162. }
  163. return Calculations.random(200,300);
  164. }
  165.  
  166. public void onPaint(Graphics g1) {
  167. if(t == null){
  168. t = new Timer(0);
  169. }
  170. Graphics2D g = (Graphics2D)g1;
  171. Stroke stroke = g.getStroke();
  172. g.setColor(color1);
  173. g.fillRect(3, 4, 199, 159);
  174. g.setColor(color2);
  175. g.setStroke(stroke1);
  176. g.drawRect(3, 4, 225, 233);
  177. g.setFont(font1);
  178. g.setColor(color3);
  179. g.drawString(getManifest().name(), 8, 225); //Will list the name of the script
  180. g.setFont(font2);
  181. g.drawString("v" + getManifest().version(), 165, 225); //Will list the version number
  182. g.setFont(font3);
  183. g.setStroke(stroke);
  184. }
  185.  
  186. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement