Guest User

Untitled

a guest
Jun 22nd, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.86 KB | None | 0 0
  1. package com.scripts;
  2.  
  3. import com.kbot2.scriptable.Script;
  4. import com.kbot2.scriptable.*;
  5. import com.kbot2.scriptable.methods.*;
  6. import com.kbot2.scriptable.methods.data.*;
  7. import com.kbot2.scriptable.methods.wrappers.*;
  8. import com.kbot2.scriptable.methods.data.Inventory.*;
  9. import com.kbot2.handlers.eventSystem.eventListeners.PaintListener;
  10. import com.kbot2.handlers.eventSystem.eventListeners.ServerMessageListener;
  11. import java.awt.Graphics;
  12. import java.awt.Color;
  13. import java.awt.Font;
  14.  
  15. import java.awt.*;
  16.  
  17. public class CutBurn extends Script implements PaintListener, ServerMessageListener {
  18.  
  19. //~ Tree ID ~\\
  20. public int willowTree[] = {5551, 5552, 5553, 1308};
  21.  
  22. //~ Paint Variables ~\\
  23. public int NumberCut = 0;
  24. public int NumberBurnt = 0;
  25. public double xpCutLog = 0;
  26. public double xpBurnLog = 0;
  27. public int origWoodcut = 0;
  28. public int origFiremake = 0;
  29. long startTime = System.currentTimeMillis();
  30.  
  31. //~ Other Variables ~\\
  32. public Tile[] pathToBurn = new Tile[]{ new Tile(2913,3306), new Tile(2916,3302), new Tile(2921,3301), new Tile(2923,3296), new Tile(2928,3295), new Tile(2933,3296), new Tile(2938,3295), };
  33. public int cuttingID = 867;
  34. public int antibanTimer = -1;
  35. public boolean burnFlag = false;
  36. public Tile startTile = new Tile(2940, 3293);
  37. public int TinderboxID = 590;
  38. public int WillowLogID = 1519;
  39.  
  40. //~ Basic Script Information ~\\
  41. public String getName() { return "Cut And Burn"; }
  42.  
  43. public String getAuthor() { return "santa"; }
  44.  
  45. public String getDescription() { return "Cuts willows outside crafting guild /n and then burns them. /n /n Written by santa."; }
  46.  
  47. public double getVersion() { return 1.0; } //First
  48.  
  49. //~ Starting and Ending the Script ~\\
  50. public boolean onStart() {
  51.  
  52. origWoodcut = skills.getLevel(Skills.SKILL_WOODCUTTING);
  53. origFiremake = skills.getLevel(Skills.SKILL_FIREMAKING);
  54.  
  55. log("Cut and Burner version " + getVersion() + " written by santa.");
  56.  
  57. return true; }
  58.  
  59. public void onStop(){
  60. log("Cut and Burner version " + getVersion() + " written by santa.");
  61. log(" ");
  62. log("Cut: " + NumberCut + " willow logs");
  63. log("Burnt: " + NumberBurnt + " willow logs");
  64. log("Gained " + (xpCutLog * NumberCut) + " woodcutting xp and " + (xpBurnLog * NumberBurnt) + " firemaking xp.");
  65. return; }
  66.  
  67. //~ The stuff that controls your character ~\\
  68. public int loop() {
  69.  
  70. /* Do you have inventory spaces? */
  71. if(inventory.isFull()) {
  72. burnFlag = true; //Says we should be burning logs
  73. if(walking.getEnergy() > random(30,45)) walking.setRunning(true); //turns on run
  74. antiban();
  75. walking.walkPath(walking.randomizePath(pathToBurn, 3, 3)); //walks to burning spot.
  76.  
  77. /* Burn the first log */
  78. inventory.atItem("Use", TinderboxID);
  79. inventory.atItem("->", WillowLogID);
  80.  
  81. return random(1300,1600);
  82. }
  83.  
  84. /* Burn the rest of the logs */
  85. if(burnFlag == true && inventory.contains(true, WillowLogID)) {
  86. inventory.atItem("Use", TinderboxID);
  87. inventory.atItem("->", WillowLogID);
  88. antiban();
  89. return random(900,1300); }
  90.  
  91. /* Set burnFlag to false and empty rest of inventory if we're out of willows */
  92. if(inventory.contains(false, WillowLogID)) {
  93. burnFlag = false;
  94. inventory.dropAllExcept(TinderboxID);
  95. return random(800,1000); }
  96.  
  97. /* Are you currently walking around? */
  98. if (getMyPlayer().isMoving()) {
  99. setAltitude(true);
  100. return random(1000,1500); }
  101.  
  102. /*Currently not doing anything, so we can burn logs */
  103. Obj tree = getClosestObject(25, willowTree);
  104. if (tree == null) return random(800,1000);
  105.  
  106. setMouseSpeed(random(0,4));
  107.  
  108. tree.doAction("Chop Down");
  109. antiban();
  110.  
  111. return random(800,1000);
  112. }
  113.  
  114. //~ Check to see if log is cut and burnt ~\\
  115. public void onServerMessage(String m) {
  116. if(m.contains("You get some")) { NumberCut++; }
  117. if(m.contains("fire catches")) { NumberBurnt++; }
  118. }
  119.  
  120. //~ Antiban ~\\
  121. public void antiban() {
  122. int banNumber = random(1,9);
  123.  
  124. /* This one will examine random things if you're cutting a tree */
  125. if (banNumber == 1 && getMyPlayer().getAnimation() == cuttingID) {
  126. Obj[] objectsAround = objects.getObjects(10);
  127. if(objectsAround.length == 0) // Shouldnt be 0;
  128. return;
  129. int randObjs = random(0, objectsAround.length-1);
  130. objectsAround[randObjs].doAction("Examine"); }
  131.  
  132. /* This one will open the friends tab on rare occasions if you're cutting a tree */
  133. if (banNumber == 2 && (random(0,2) == 1) && (getMyPlayer().getAnimation() == cuttingID)) {
  134. gameScreen.openTab(GameScreen.TAB_FRIENDS);
  135. sleep(800, 1500); }
  136.  
  137. /* This one will check your woodcutting lvl and xp every so often */
  138. if (banNumber == 3 && getMyPlayer().getAnimation() == cuttingID) {
  139. gameScreen.openTab(GameScreen.TAB_STATS);
  140. int xx = 666;
  141. int yy = 393;
  142. moveMouse(new Point(xx, yy), 43, 17);
  143. sleep(2000, 4000); }
  144.  
  145. /* this will move the mouse in random positions whilst cutting trees */
  146. if ((banNumber == 4 || banNumber = 9) && (getMyPlayer().getAnimation() == cuttingID)) {
  147. mouse.moveMouse(random(5, 420), random(5, 420));
  148. sleep(300, 700); }
  149.  
  150. /* This will move camera up or down at any random time */
  151. if (banNumber == 5 || banNumber == 6) {
  152. char k = (random(0, 1) == 0 ? (char)KeyEvent.VK_DOWN : (char)KeyEvent.VK_UP);
  153. keyboard.pressKey(k);
  154. sleep(random(10, 400));
  155. keyboard.releaseKey(k); }
  156.  
  157. /* This one will spin the camera round at any random time */
  158. if (banNumber == 7 || banNumber == 8) camera.setAngle(random(1, 359));
  159.  
  160. /* This sets a timer for doing the antiban again */
  161. gameScreen.openTab(GameScreen.TAB_INVENTORY);
  162. antibanTimer = System.currentTimeMillis() + random(15000, 40000);
  163.  
  164. }
  165.  
  166. //~ Paint ~\\
  167. public void onRepaint(Graphics g) {
  168.  
  169. long runTime = System.currentTimeMillis() - startTime;
  170.  
  171. int secs = ((int) ((runTime / 1000) % 60));
  172. int mins = ((int) (((runTime / 1000) / 60) % 60));
  173. int hours = ((int) ((((runTime / 1000) / 60) / 60) % 60));
  174.  
  175. g.setColor(new Color(0, 0, 0, 155));
  176.  
  177. int x = 10;
  178. int y = 235;
  179.  
  180. g.fill3DRect(x, y, 215, 100, true);
  181.  
  182. x += 5;
  183. y += 15;
  184. g.setColor(Color.RED);
  185. g.drawString("santa's Cut and Burner v" + getVersion(), x, y);
  186. g.setColor(Color.WHITE);
  187. y += 20;
  188. g.drawString("Logs cut & burnt: " + NumberBurnt, x, y);
  189. y += 15;
  190. g.drawString("Run time: " + (hours < 10 ? "0" : "") + hours + ":" + (mins < 10 ? "0" : "") + mins + ":" + (secs < 10 ? "0" : "") + secs, x, y);
  191. y += 15;
  192. g.drawString("Woodcutting Levels gained: " + (skills.getLevel(Skills.SKILL_WOODCUTTING) - origWoodcut), x, y);
  193. y += 15;
  194. g.drawString("Firemaking Levels gained: " + (skills.getLevel(Skills.SKILL_FIREMAKING) - origFiremake), x, y);
  195. y += 15;
  196. g.drawString("Woodcut XP gained: " + (xpCutLog * NumberCut), x, y);
  197. y += 15;
  198. g.drawString("Firemake XP gained: " + (NumberBurnt * xpBurnLog), x, y);
  199. }
  200. }
Add Comment
Please, Sign In to add comment