Advertisement
Guest User

KanyesSheepShearer V2

a guest
May 7th, 2015
454
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.36 KB | None | 0 0
  1. import java.util.ArrayList;
  2. import java.util.List;
  3.  
  4. import org.dreambot.api.methods.Calculations;
  5. import org.dreambot.api.methods.map.Area;
  6. import org.dreambot.api.methods.map.Tile;
  7. import org.dreambot.api.script.AbstractScript;
  8. import org.dreambot.api.script.Category;
  9. import org.dreambot.api.script.ScriptManifest;
  10. import org.dreambot.api.wrappers.interactive.GameObject;
  11. import org.dreambot.api.wrappers.interactive.NPC;
  12.  
  13. @ScriptManifest(author = "KanyeWest", name = "SheepShearer", version = 1.0, description = "SheepShearer", category = Category.MONEYMAKING)
  14. public class main extends AbstractScript {
  15. private Area sheepArea;
  16. private State state;
  17. private int inventorySize;
  18. private int woolAmount = 0;
  19. private int woolPrice = 200;
  20. private long startTime;
  21.  
  22. public void onStart() {
  23. if(!getInventory().contains(1735)){
  24. log("SCRIPT STOPPED: YOU NEED SHEARS IN INVENTORY!!");
  25. stop();
  26. }
  27. // new Tile(3212, 3258, 0),new Tile(3193, 3276, 0)
  28. sheepArea = new Area(new Tile(3194, 3258, 0), new Tile(3212, 3274, 0));
  29. state = State.SHEARING;
  30. inventorySize = getInventory().count(1737);
  31. startTime = System.currentTimeMillis();
  32. }
  33.  
  34. public enum State {
  35. SHEARING, WALKTOBANK, WALKTOSHEEP, WAITING, BANK, OPENGATE;
  36. }
  37.  
  38. public void onExit() {
  39. log("Goodbye scrub shearers");
  40. }
  41.  
  42. @Override
  43. public int onLoop() {
  44. int timeout = 0;
  45. switch (state) {
  46. case SHEARING:
  47. NPC sheep = getNpcs().closest(2794, 2801, 2800, 2795, 2796, 2802);
  48. // System.out.println((sheepArea.contains(sheepPos)));
  49. inventorySize = getInventory().count(1737);
  50. if (sheepArea.contains(sheep)) {
  51. sheep.interact("Shear");
  52. } else {
  53. List<NPC> sheeps = new ArrayList<NPC>();
  54. sheeps.addAll(getNpcs().all(2794, 2801, 2800, 2795, 2796, 2802));
  55. boolean found = false;
  56. for (NPC n : sheeps) {
  57. if (sheepArea.contains(n) && !found) {
  58. n.interact("Shear");
  59. found = true;
  60. }
  61. }
  62. }
  63. state = State.WAITING;
  64. break;
  65. case WAITING:
  66. int newInv = getInventory().count(1737);
  67. if (getInventory().isFull()) {
  68. state = State.WALKTOBANK;
  69. } else if (newInv > inventorySize) {
  70. state = State.SHEARING;
  71.  
  72. } else if (!getLocalPlayer().isMoving()) {
  73. sleep(Calculations.random(300, 400));
  74. if (!getLocalPlayer().isMoving())
  75. state = State.SHEARING;
  76. }
  77. break;
  78. case WALKTOBANK:
  79.  
  80. getWalking().walk(new Tile(3209, 3261, 0));
  81. do {
  82. sleep(Calculations.random(400, 600));
  83. } while (getWalking().getDestinationDistance() > 2);
  84. GameObject[] gateZone = getGameObjects().getObjectsOnTile(
  85. new Tile(3213, 3262));
  86. GameObject gate = null;
  87. for (GameObject g : gateZone) {
  88. if (g.getID() == 12987 || g.getID() == 12986)
  89. gate = g;
  90. }
  91. if (gate != null)
  92. gate.interact("Open");
  93. do {
  94. timeout++;
  95. if (timeout > 4) {
  96. gate.interact("Open");
  97. timeout = 0;
  98. }
  99. sleep(Calculations.random(500, 600));
  100. } while (getGameObjects().closest(12989, 12988) == null);
  101.  
  102. getWalking().walk(new Tile(3216, 3261, 0));
  103. sleep(Calculations.random(500, 600));
  104. do {
  105. timeout++;
  106. if (timeout > 4) {
  107. getWalking().walk(new Tile(3216, 3261, 0));
  108. timeout = 0;
  109. }
  110. sleep(Calculations.random(500, 600));
  111. } while (getWalking().getDestinationDistance() > 2);
  112.  
  113. getWalking().walk(new Tile(3216, 3254, 0));
  114. sleep(Calculations.random(500, 600));
  115. do {
  116. timeout++;
  117. if (timeout > 4) {
  118. getWalking().walk(new Tile(3216, 3254, 0));
  119. timeout = 0;
  120. }
  121. sleep(Calculations.random(500, 600));
  122. } while (getWalking().getDestinationDistance() > 2);
  123.  
  124. getWalking().walk(new Tile(3219, 3246, 0));
  125. sleep(Calculations.random(500, 600));
  126. do {
  127. timeout++;
  128. if (timeout > 4) {
  129. getWalking().walk(new Tile(3219, 3246, 0));
  130. timeout = 0;
  131. }
  132. sleep(Calculations.random(500, 600));
  133. } while (getWalking().getDestinationDistance() > 2);
  134.  
  135. getWalking().walk(new Tile(3224, 3237, 0));
  136. sleep(Calculations.random(500, 600));
  137. do {
  138. timeout++;
  139. if (timeout > 4) {
  140. getWalking().walk(new Tile(3224, 3237, 0));
  141. timeout = 0;
  142. }
  143. sleep(Calculations.random(500, 600));
  144. } while (getWalking().getDestinationDistance() > 2);
  145.  
  146. getWalking().walk(new Tile(3231, 3231, 0));
  147. sleep(Calculations.random(500, 600));
  148. do {
  149. timeout++;
  150. if (timeout > 4) {
  151. getWalking().walk(new Tile(3231, 3231, 0));
  152. timeout = 0;
  153. }
  154. sleep(Calculations.random(500, 600));
  155. } while (getWalking().getDestinationDistance() > 2);
  156.  
  157. getWalking().walk(new Tile(3231, 3231, 0));
  158. sleep(Calculations.random(500, 600));
  159. do {
  160. timeout++;
  161. if (timeout > 4) {
  162. getWalking().walk(new Tile(3231, 3231, 0));
  163. timeout = 0;
  164. }
  165. sleep(Calculations.random(500, 600));
  166. } while (getWalking().getDestinationDistance() > 2);
  167.  
  168. getWalking().walk(new Tile(3224, 3218, 0));
  169. sleep(Calculations.random(500, 600));
  170. do {
  171. timeout++;
  172. if (timeout > 4) {
  173. getWalking().walk(new Tile(3224, 3218, 0));
  174. timeout = 0;
  175. }
  176. sleep(Calculations.random(500, 600));
  177. } while (getWalking().getDestinationDistance() > 2);
  178.  
  179. getWalking().walk(new Tile(3217, 3218, 0));
  180. sleep(Calculations.random(500, 600));
  181. do {
  182. timeout++;
  183. if (timeout > 4) {
  184. getWalking().walk(new Tile(3217, 3218, 0));
  185. timeout = 0;
  186. }
  187. sleep(Calculations.random(500, 600));
  188. } while (getLocalPlayer().isMoving());
  189.  
  190. getWalking().walk(new Tile(3215, 3210, 0));
  191. sleep(Calculations.random(500, 600));
  192. do {
  193. timeout++;
  194. if (timeout > 4) {
  195. getWalking().walk(new Tile(3215, 3210, 0));
  196. timeout = 0;
  197. }
  198. sleep(Calculations.random(500, 600));
  199. } while (getLocalPlayer().isMoving());
  200.  
  201. getWalking().walk(new Tile(3207, 3209, 0));
  202. sleep(Calculations.random(500, 600));
  203. do {
  204. timeout++;
  205. if (timeout > 4) {
  206. getWalking().walk(new Tile(3210, 3211, 0));
  207. timeout = 0;
  208. }
  209. sleep(Calculations.random(500, 600));
  210. } while (getLocalPlayer().isMoving());
  211.  
  212. GameObject stairs = getGameObjects().closest(16671);
  213. stairs.interact("Climb-up");
  214. do {
  215. timeout++;
  216. if (timeout > 4) {
  217. stairs.interact("Climb-up");
  218. timeout = 0;
  219. }
  220. sleep(Calculations.random(500, 600));
  221. } while (getGameObjects().closest(16672) == null);
  222. sleep(Calculations.random(500, 600));
  223. stairs = getGameObjects().closest(16672);
  224. stairs.interact("Climb-up");
  225. do {
  226. timeout++;
  227. if (timeout > 4) {
  228. stairs.interact("Climb-up");
  229. timeout = 0;
  230. }
  231. sleep(Calculations.random(500, 600));
  232. } while (getGameObjects().closest(16673) == null);
  233. getWalking().walk(new Tile(3208, 3219, 2));
  234. sleep(Calculations.random(500, 600));
  235. do {
  236. timeout++;
  237. if (timeout > 4) {
  238. getWalking().walk(new Tile(3208, 3219, 2));
  239. timeout = 0;
  240. }
  241. } while (getWalking().getDestinationDistance() > 2);
  242. sleep(Calculations.random(500, 600));
  243. state = State.BANK;
  244. break;
  245. case BANK:
  246. woolAmount = woolAmount + getInventory().count(1737);
  247. log("Wool gathered: \t" + woolAmount);
  248. long profit = woolAmount * woolPrice;
  249. log("Proft: \t" + profit);
  250. long currentTime = System.currentTimeMillis();
  251. long timeTaken = currentTime - startTime;
  252. timeTaken = (timeTaken / (1000 * 60)) % 60;
  253. log("Time taken: \t" + timeTaken + " minutes");
  254. getBank().open();
  255. sleep(Calculations.random(800, 1000));
  256.  
  257. do {
  258. sleep(Calculations.random(800, 1000));
  259. getBank().open();
  260. } while (!getBank().isOpen());
  261. getBank().depositAll(1737);
  262. do {
  263. sleep(Calculations.random(800, 1000));
  264. getBank().depositAll(1737);
  265. } while (getInventory().contains(1737));
  266. sleep(Calculations.random(500, 600));
  267. getBank().close();
  268. state = State.WALKTOSHEEP;
  269. break;
  270. case WALKTOSHEEP:
  271. GameObject[] stairsZone = getGameObjects().getObjectsOnTile(
  272. new Tile(3205, 3208, 2));
  273. GameObject stairs2 = null;
  274. for (GameObject g : stairsZone) {
  275. if (g != null)
  276. if (g.getID() == 16673)
  277. stairs2 = g;
  278. }
  279. if (stairs2 != null)
  280. stairs2.interact("Climb-down");
  281. timeout = 0;
  282. do {
  283. timeout++;
  284. if (timeout > 4) {
  285. stairs2.interact("Climb-down");
  286. timeout = 0;
  287. }
  288. sleep(Calculations.random(500, 600));
  289. } while (getGameObjects().closest(16672) == null);
  290.  
  291. stairs2 = getGameObjects().closest(16672);
  292. stairs2.interact("Climb-down");
  293. do {
  294. timeout++;
  295. if (timeout > 4) {
  296. stairs2.interact("Climb-down");
  297. timeout = 0;
  298. }
  299. sleep(Calculations.random(500, 600));
  300. } while (getGameObjects().closest(16671) == null);
  301.  
  302. getWalking().walk(new Tile(3207, 3209, 0));
  303. do {
  304. timeout++;
  305. if (timeout > 4) {
  306. getWalking().walk(new Tile(3207, 3209, 0));
  307. timeout = 0;
  308. }
  309. sleep(Calculations.random(500, 600));
  310. } while (getWalking().getDestinationDistance() > 2);
  311.  
  312. getWalking().walk(new Tile(3215, 3210, 0));
  313. do {
  314. timeout++;
  315. if (timeout > 4) {
  316. getWalking().walk(new Tile(3215, 3210, 0));
  317. timeout = 0;
  318. }
  319. sleep(Calculations.random(500, 600));
  320. } while (getWalking().getDestinationDistance() > 2);
  321.  
  322. getWalking().walk(new Tile(3217, 3218, 0));
  323. do {
  324. timeout++;
  325. if (timeout > 4) {
  326. getWalking().walk(new Tile(3217, 3218, 0));
  327. timeout = 0;
  328. }
  329. sleep(Calculations.random(500, 600));
  330. } while (getWalking().getDestinationDistance() > 2);
  331.  
  332. getWalking().walk(new Tile(3224, 3218, 0));
  333. do {
  334. timeout++;
  335. if (timeout > 4) {
  336. getWalking().walk(new Tile(3224, 3218, 0));
  337. timeout = 0;
  338. }
  339. sleep(Calculations.random(500, 600));
  340. } while (getWalking().getDestinationDistance() > 2);
  341.  
  342. getWalking().walk(new Tile(3233, 3222, 0));
  343. do {
  344. timeout++;
  345. if (timeout > 4) {
  346. getWalking().walk(new Tile(3233, 3222, 0));
  347. timeout = 0;
  348. }
  349. sleep(Calculations.random(500, 600));
  350. } while (getWalking().getDestinationDistance() > 2);
  351.  
  352. getWalking().walk(new Tile(3231, 3231, 0));
  353. do {
  354. timeout++;
  355. if (timeout > 4) {
  356. getWalking().walk(new Tile(3231, 3231, 0));
  357. timeout = 0;
  358. }
  359. sleep(Calculations.random(500, 600));
  360. } while (getWalking().getDestinationDistance() > 2);
  361.  
  362. getWalking().walk(new Tile(3224, 3237, 0));
  363. do {
  364. timeout++;
  365. if (timeout > 4) {
  366. getWalking().walk(new Tile(3224, 3237, 0));
  367. timeout = 0;
  368. }
  369. sleep(Calculations.random(500, 600));
  370. } while (getWalking().getDestinationDistance() > 2);
  371.  
  372. getWalking().walk(new Tile(3219, 3246, 0));
  373. do {
  374. timeout++;
  375. if (timeout > 4) {
  376. getWalking().walk(new Tile(3219, 3246, 0));
  377. timeout = 0;
  378. }
  379. sleep(Calculations.random(500, 600));
  380. } while (getWalking().getDestinationDistance() > 2);
  381.  
  382. getWalking().walk(new Tile(3216, 3254, 0));
  383. do {
  384. timeout++;
  385. if (timeout > 4) {
  386. getWalking().walk(new Tile(3216, 3254, 0));
  387. timeout = 0;
  388. }
  389. sleep(Calculations.random(500, 600));
  390. } while (getWalking().getDestinationDistance() > 2);
  391.  
  392. getWalking().walk(new Tile(3215, 3260, 0));
  393. do {
  394. timeout++;
  395. if (timeout > 4) {
  396. getWalking().walk(new Tile(3215, 3260, 0));
  397. timeout = 0;
  398. }
  399. sleep(Calculations.random(500, 600));
  400. } while (getWalking().getDestinationDistance() > 2);
  401.  
  402. GameObject[] gateZone2 = getGameObjects().getObjectsOnTile(
  403. new Tile(3213, 3262));
  404. GameObject gate2 = null;
  405. for (GameObject g : gateZone2) {
  406. if (g.getID() == 12987)
  407. gate2 = g;
  408. }
  409. if (gate2 != null)
  410. gate2.interact("Open");
  411. do {
  412. timeout++;
  413. if (timeout > 4) {
  414. if (gate2 != null)
  415. gate2.interact("Open");
  416. timeout = 0;
  417. }
  418. sleep(Calculations.random(500, 600));
  419. } while (getGameObjects().closest(12989) == null);
  420. getWalking().walk(new Tile(3208, 3261, 0));
  421. do {
  422.  
  423. } while (getWalking().getDestinationDistance() > 2);
  424. state = State.SHEARING;
  425. break;
  426. default:
  427. break;
  428.  
  429. }
  430. return Calculations.random(500, 600);
  431. }
  432.  
  433. public void deadFunc() {
  434. GameObject stairs = getGameObjects().closest(16671);
  435. stairs.interact("Climb-up");
  436. sleep(Calculations.random(300, 400));
  437. stairs = getGameObjects().closest(16672);
  438. stairs.interact("Climb-up");
  439. sleep(Calculations.random(300, 400));
  440. getWalking().walk(new Tile(3208, 3219, 0));
  441. }
  442. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement