Guest User

CoalPowerminer OSBot

a guest
Apr 13th, 2013
214
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.14 KB | None | 0 0
  1. import java.awt.*
  2.  
  3. import org.osbot.script.Script
  4. import org.osbot.script.ScriptManifest
  5. import org.osbot.script.mouse.*
  6. import org.osbot.script.rs2.*
  7. import org.osbot.script.rs2.map.Position
  8. import org.osbot.script.rs2.model.GroundItem
  9. import org.osbot.script.rs2.model.Item
  10. import org.osbot.script.rs2.model.PrimaryObject
  11. import org.osbot.script.rs2.model.RS2Object
  12. import org.osbot.script.rs2.ui.*
  13.  
  14.  
  15. @ScriptManifest(name = "CoalPowerminer", author="Xerion & that1guy", version = 1.2D, info = "CoalPowerminer")
  16. class CoalPowerminer extends Script {
  17.  
  18. enum State {
  19. START, IDLE, MINING, DROP, BANK, BANKING
  20. }
  21.  
  22. private final Color color1 = new Color(0.1f, 0.1f, 0.1f, 0.7f);
  23. private final Color color2 = new Color(255, 0, 0);
  24.  
  25. private final Font font1 = new Font("Calisto MT", 0, 16);
  26. private final Font font2 = new Font("Calisto MT", 0, 11);
  27.  
  28. int[] pickhandle = [480,482,484,486,488,490];
  29. int[] coal = [ 2096,2097,11963,11964,11965,11930,11931,11932,14850,14851,14852];
  30. int[] items = [480,482,484,486,488,490,1265 , 1267, 1269, 1271,1273,1275,1617,1619,1621,1623]
  31. def timeout = null;
  32. def starttime = null;
  33. def Newantiban = null;
  34. def MinedOre = 0;
  35. boolean Antibans = true
  36. State state = State.START;
  37. PrimaryObject currentRock = null;
  38.  
  39.  
  40.  
  41. void onStart() {
  42. starttime = System.currentTimeMillis();
  43. Newantiban = System.currentTimeMillis() + random(10000, 20000);
  44.  
  45. def th = Thread.start {
  46. antiban()
  47. }
  48.  
  49. if (client.getInventory().isFull()){
  50. state = State.DROP;
  51. }
  52. else { state = State.IDLE; }
  53. }
  54.  
  55. int onLoop() {
  56. if (!randoms()){
  57. switch(state) {
  58. case State.IDLE:
  59. return mine();
  60. case State.MINING:
  61. return check();
  62. case State.DROP:
  63. return drop();
  64. }
  65. }
  66. return 1000 + gRandom(400, 800);
  67. }
  68.  
  69. int mine() {
  70. currentRock = closestObject(coal);
  71. if (currentRock != null) {
  72. if (selectEntityOption(currentRock, "Mine")) {
  73. timeout = Calendar.instance.timeInMillis / 1000
  74. state = State.MINING;
  75. }
  76. }
  77. return 100;
  78. }
  79.  
  80. int check(){
  81. if (!currentRock.exists() || !currentRock.getId() == 11435 ||timeout + 15 < Calendar.instance.timeInMillis / 1000){
  82. if (!client.getInventory().isFull()){
  83. state = State.IDLE;
  84. return 500 + random(100, 1000)
  85. }
  86. else {
  87. if (currentTab() != Tab.INVENTORY){
  88. openTab(Tab.INVENTORY);
  89. }
  90. state = State.DROP;
  91. return 500 + random(100, 1000)
  92. }
  93. }
  94. return 100
  95. }
  96.  
  97. boolean randoms(){
  98. //Losing Pickhandle
  99. GroundItem[] list = client.currentRegion.getItems()
  100. for(GroundItem g : list){
  101. for(int i : pickhandle){
  102. if (i == g.getId()){
  103. selectEntityOption(g,"Take")
  104. sleep(500 + random(500,1000))
  105. return true
  106. }
  107. }
  108. }
  109.  
  110. }
  111.  
  112. int drop(){
  113. client.getInventory().dropAllExcept(items)
  114. state = State.IDLE;
  115.  
  116. return 1000 + random(500,4000)
  117.  
  118. }
  119.  
  120. void onMessage(String message){
  121. if ("You manage to mine some coal." == message){
  122. MinedOre++
  123. }
  124. else if (message == "This rock contains coal." || message == "There is no ore currently available in this rock."){
  125. state = State.IDLE;
  126. }
  127. }
  128.  
  129. void onExit(){
  130. Antibans = false
  131. }
  132.  
  133. void onPaint(Graphics g) {
  134. g.setColor(color1);
  135. g.fillRect(1, 51, 209, 94);
  136. g.setFont(font1);
  137. g.setColor(color2);
  138. g.drawString("CoalPowerminer", 7, 76);
  139. g.setFont(font2);
  140. g.drawString("Time: " + format(System.currentTimeMillis() - starttime), 7, 130);
  141. g.drawString("Ore: Coal(${MinedOre})", 7, 100);
  142. g.drawString("State: ${state}", 7, 115);
  143. }
  144.  
  145.  
  146.  
  147.  
  148. String format(final long time) {
  149. final StringBuilder t = new StringBuilder();
  150. final long total_secs = time / 1000;
  151. final long total_mins = total_secs / 60;
  152. final long total_hrs = total_mins / 60;
  153. final int secs = (int) total_secs % 60;
  154. final int mins = (int) total_mins % 60;
  155. final int hrs = (int) total_hrs % 24;
  156. if (hrs < 10) {
  157. t.append("0");
  158. }
  159. t.append(hrs);
  160. t.append(":");
  161. if (mins < 10) {
  162. t.append("0");
  163. }
  164. t.append(mins);
  165. t.append(":");
  166. if (secs < 10) {
  167. t.append("0");
  168. }
  169. else if (secs < 0){
  170. t.append("0")
  171. }
  172. else{
  173. t.append(secs);
  174. }
  175. return t.toString();
  176. }
  177.  
  178. void antiban(){
  179. while(Antibans){
  180. if (state == State.MINING && Newantiban < System.currentTimeMillis()){
  181.  
  182. int Anti = random(0 , 3)
  183. switch(Anti){
  184. case 0:
  185. log("Antiban: Move mouse")
  186. moveMouseOutsideScreen()
  187. Newantiban = System.currentTimeMillis() + random(40000, 120000)
  188. break;
  189. case 1:
  190. log("Antiban: Move camera")
  191. client.moveCameraToEntity(currentRock)
  192. Newantiban = System.currentTimeMillis() + random(40000, 120000)
  193. break;
  194. case 2:
  195. log("Antiban: Open Skills tab")
  196. if (currentTab() != Tab.SKILLS){
  197. openTab(Tab.SKILLS);
  198. }
  199. Newantiban = System.currentTimeMillis() + random(40000, 120000)
  200. break;
  201. case 3:
  202. log("Antiban: Open Friends tab")
  203. if (currentTab() != Tab.FRIENDS){
  204. openTab(Tab.FRIENDS);
  205. }
  206. Newantiban = System.currentTimeMillis() + random(40000, 120000)
  207. break;
  208. }
  209. }
  210. Thread.sleep(1000)
  211. }
  212. }
  213.  
  214. }
Advertisement
Add Comment
Please, Sign In to add comment