Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2017
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.90 KB | None | 0 0
  1. import org.rsbot.event.events.MessageEvent;
  2. import org.rsbot.event.listeners.MessageListener;
  3. import org.rsbot.event.listeners.PaintListener;
  4. import org.rsbot.script.*;
  5. import org.rsbot.script.ScriptManifest;
  6. import org.rsbot.script.util.Filter;
  7. import org.rsbot.script.util.Timer;
  8. import org.rsbot.script.wrappers.*;
  9. import org.rsbot.script.methods.*;
  10.  
  11.  
  12. import java.awt.*;
  13. import java.applet.*;
  14. import java.util.HashSet;
  15. import java.util.Set;
  16. import java.util.EventListener;
  17.  
  18. @ScriptManifest(authors = "Cyrus",
  19. name = "PureStarter",
  20. version = 0.2,
  21. description = "Kills bitch ass cows")
  22. /*
  23. * Must start with:
  24. * A log you have the firemaking to light or an empty space
  25. * A hatchet you have the Woodcutting level to use
  26. * A tinderbox
  27. * Your fight-type already selected
  28. */
  29. public class PureStarter extends Script implements MessageListener{
  30.  
  31. public enum ScriptState {
  32. FINDING, KILLING, LOOTING, TOTREES, CUTTING, LIGHTING, COOKING, DROPPING, TOCOWS
  33. }
  34.  
  35. boolean finding = false;
  36. boolean killing = false;
  37. boolean looting = false;
  38. boolean totrees = false;
  39. boolean cutting = false;
  40. boolean lighting = false;
  41. boolean cooking = false;
  42. boolean dropping = false;
  43. boolean tocows = false;
  44.  
  45. private static final RSArea northGuildPen = new RSArea (2918, 3275, 2927, 3291);
  46. private static final RSArea southGuildPen = new RSArea (2923, 3270, 2938, 3275);
  47.  
  48. private static final RSTile guildGate = new RSTile (2923, 3292);
  49.  
  50. private static final int[] cowIDs = {
  51. 81, 397, 2310, 12362, 12364, 12365, 1766, 1767, 1768, 2310};
  52. private static final int[] hatchetIDs = {
  53. 1351, 1349, 1353, 1361, 1355, 1357, 1359, 6739};
  54.  
  55. //1351 = Bronze
  56. //1349 = Iron
  57. //1353 = Steel
  58. //1361 = Black
  59. //1355 = Mith
  60. //1357 = Adamant
  61. //1359 = Rune
  62. //6739 = Dragon
  63. //3082/3247 = ???
  64.  
  65. private static final int[] logIDs = {
  66. 1511, 1521, 1519, 1517, 1515, 1513};
  67. private static final int treeID = 1276;
  68. private static final int fireID = 2732;
  69.  
  70. private static final int cowHide = 1739; //Safe to drop item
  71. private static final int bones = 526; //Safe to drop
  72. private static final int[] safeToDropItems = {
  73. 1739, 526, 2146};
  74.  
  75. private static final int rawBeef = 2132;
  76. private static final int cookedBeef = 2142;
  77. private static final int burntBeef = 2146; //Safe to drop item
  78.  
  79. private static final int tinderBox = 590;
  80.  
  81. private boolean fireLit = false;
  82.  
  83. private int lastConstitutionXP;
  84. private int lastAttackXP;
  85. private int lastStrengthXP;
  86. private int lastDefenseXP;
  87. private int lastRangeXP;
  88. private int lastMageXP;
  89.  
  90. private String fightType;
  91.  
  92. private RSNPC cow;
  93.  
  94. public boolean onStart() {
  95. log("Cyrus is the greatest. ");
  96.  
  97. if (!haveUsableHatchet() || !inventory.contains(tinderBox) || (inventory.isFull() && haveUsableLogs() == false)) {
  98. log("Read the directions, dumbass");
  99. return false;
  100. }
  101.  
  102. lastAttackXP = skills.getCurrentExp(Skills.ATTACK);
  103. lastStrengthXP = skills.getCurrentExp(Skills.STRENGTH);
  104. lastDefenseXP = skills.getCurrentExp(Skills.DEFENSE);
  105. lastRangeXP = skills.getCurrentExp(Skills.RANGE);
  106. lastMageXP = skills.getCurrentExp(Skills.MAGIC);
  107. cow = null;
  108.  
  109. return true;
  110. }
  111.  
  112. public void messageReceived (MessageEvent e) {
  113. if (e.getID() == MessageEvent.MESSAGE_SERVER && e.getMessage().contains("The fire catches")) {
  114. fireLit = true;
  115. }
  116. }
  117.  
  118. private void dealWithGate() {
  119. RSObject gate = objects.getTopAt(guildGate);
  120.  
  121. if (gate != null) {
  122. if (!gate.isOnScreen()) {
  123. log("Walking to gate");
  124. walking.walkTo(gate.getLocation());
  125. }
  126. log("Opening gate");
  127.  
  128. gate.doClick();
  129. sleep(random(1000,2000));
  130. }
  131. else
  132. log("gate null");
  133. }
  134.  
  135.  
  136.  
  137. private boolean haveUsableLogs() {
  138. int fmLevel = skills.getRealLevel(Skills.FIREMAKING);
  139. if (fmLevel >= 75 && inventory.containsOneOf(logIDs)) {
  140. return true;
  141. }
  142. if (fmLevel >= 60 && inventory.containsOneOf(1511, 1521, 1519, 1517, 1515)) {
  143. return true;
  144. }
  145. if (fmLevel >=45 && inventory.containsOneOf(1511, 1521, 1519, 1517)) {
  146. return true;
  147. }
  148. if (fmLevel >=30 && inventory.containsOneOf(1511, 1521, 1519)) {
  149. return true;
  150. }
  151. if (fmLevel >=15 && inventory.containsOneOf(1511, 1521)) {
  152. return true;
  153. }
  154. if (inventory.contains(1511)) {
  155. return true;
  156. }
  157. return false;
  158. }
  159.  
  160. private boolean haveUsableHatchet() {
  161. int wcLevel = skills.getRealLevel(Skills.WOODCUTTING);
  162. if (wcLevel >= 61 && inventory.containsOneOf(hatchetIDs)) {
  163. return true;
  164. }
  165. if (wcLevel >= 41 && inventory.containsOneOf(1351, 1353, 1361, 1355, 1357, 1359)) {
  166. return true;
  167. }
  168. if (wcLevel >= 31 && inventory.containsOneOf(1351, 1349, 1353, 1361, 1355, 1357)) {
  169. return true;
  170. }
  171. if (wcLevel >= 21 && inventory.containsOneOf(1351, 1349, 1353, 1361, 1355)) {
  172. return true;
  173. }
  174. if (wcLevel >= 11 && inventory.containsOneOf(1351, 1349, 1353, 1361)) {
  175. return true;
  176. }
  177. if (wcLevel >= 6 && inventory.containsOneOf(1351, 1349, 1353)) {
  178. return true;
  179. }
  180. if (inventory.containsOneOf(1351, 1349)) {
  181. return true;
  182. }
  183.  
  184. return false;
  185. }
  186.  
  187. //TYVM Taw (#RSCode), walked me through filters, if you are hot female
  188. //and you like this script, sex him.
  189.  
  190. private Filter cowFilter = new Filter <RSNPC>() {
  191. public boolean accept (RSNPC all) {
  192. for (int i=0; i < cowIDs.length; i++) {
  193. if (all.getID() == cowIDs[i]) {
  194. return !all.isInCombat();
  195. }
  196. }
  197. return false;
  198. }
  199. };
  200.  
  201. private RSNPC getCow() {
  202. RSNPC nearestCow = npcs.getNearest(cowFilter);
  203. return nearestCow;
  204. }
  205.  
  206. private void attackCows() {
  207. boolean lootReady = false;
  208. if (cow == null || !cow.isValid()) {
  209. cow = getCow();
  210. }
  211. if (cow != null) {
  212. if (cow.isOnScreen()) {
  213. cow.doAction("Attack");
  214. }
  215. else {
  216. walking.walkTo(cow.getLocation());
  217. sleep(random(1500,2300));
  218. cow.doAction("Attack");
  219. }
  220. }
  221. sleep(random(1500,2000));
  222. if (cow != null) {
  223. while (getMyPlayer().isInCombat()) {
  224. if (lootReady != true) {
  225. lootReady = true;
  226. }
  227. sleep(random(50,100));
  228. }
  229. if (lootReady == true) {
  230. if (!inventory.isFull()) {
  231. lootBeef();
  232. }
  233. if (!getMyPlayer().isInCombat()) {
  234. cow = null;
  235. }
  236. }
  237. }
  238. }
  239.  
  240. private boolean lootBeef() {
  241. //Thank you biking11
  242. int originalBeefs = inventory.getCount(false, rawBeef);
  243. int iFailAtJavaNaming = originalBeefs + 1;
  244. RSGroundItem loot = groundItems.getNearest(rawBeef);
  245. for (int i = 1; i < 3 && loot != null; i++) {
  246. loot.doAction("Take");
  247. if (inventory.getCount(false, rawBeef) == iFailAtJavaNaming) {
  248. return true;
  249. }
  250. }
  251. return false;
  252. }
  253.  
  254. private boolean getLogs() {
  255. RSObject tree = null;
  256. for (int i = 0; i < 5; i++) {
  257. tree = objects.getNearest(treeID);
  258. if (tree == null) {
  259. continue;
  260. }
  261. if (!tree.isOnScreen()) {
  262. walking.walkTo(tree.getLocation());
  263. sleep(random(1000,2500));
  264. }
  265. if (tree != null) {
  266. tree.doAction("Chop");
  267. sleep (random(2000,5000));
  268. if (haveUsableLogs()) {
  269. return true;
  270. }
  271. }
  272. }
  273. return false;
  274. }
  275.  
  276. private boolean walkOneTile() {
  277. RSTile originalLocation = getMyPlayer().getLocation();
  278. int xValue = originalLocation.getX();
  279. int yValue = originalLocation.getY();
  280. for (int i = 0; i < 3; i++) {
  281. switch (random(1,4)) {
  282. case 1: //North
  283. RSTile northTile = new RSTile (xValue, (yValue+1));
  284. walking.walkTileOnScreen(northTile);
  285. if (getMyPlayer().getLocation() == northTile) {
  286. return true;
  287. }
  288. break;
  289. case 2: //East
  290. RSTile eastTile = new RSTile ((xValue + 1), yValue);
  291. walking.walkTileOnScreen(eastTile);
  292. if (getMyPlayer().getLocation() == eastTile) {
  293. return true;
  294. }
  295. break;
  296. case 3: //South
  297. RSTile southTile = new RSTile (xValue, (yValue-1));
  298. walking.walkTileOnScreen(southTile);
  299. if (getMyPlayer().getLocation() == southTile) {
  300. return true;
  301. }
  302. break;
  303. case 4: //West
  304. RSTile westTile = new RSTile ((xValue-1), yValue);
  305. walking.walkTileOnScreen(westTile);
  306. if (getMyPlayer().getLocation() == westTile) {
  307. return true;
  308. }
  309. break;
  310. }
  311. }
  312. return false;
  313. }
  314.  
  315. private boolean lightLogs() {
  316. RSItem log = inventory.getItem(logIDs);
  317. RSItem tinderbox = inventory.getItem(tinderBox);
  318. RSTile originalLocation = getMyPlayer().getLocation();
  319.  
  320. for (int i = 0; i < 2; i++) {
  321. if (!canLightOn(originalLocation)) {
  322. walkOneTile();
  323. originalLocation = getMyPlayer().getLocation();
  324. }
  325. }
  326.  
  327. for (int i = 0; i < 2 || fireLit != true;i++) {
  328. inventory.useItem (log, tinderbox);
  329. sleep(random(4000,9000));
  330. //if (objects.getNearest(fireID).getLocation().equals(originalLocation)) {
  331. if (objects.getTopAt(originalLocation) != null) {
  332. return true;
  333. }
  334.  
  335. }
  336. return false;
  337. }
  338.  
  339. boolean canLightOn(RSTile tile) {
  340. for (int i = 0; i < 2; i++) {
  341. if (objects.getTopAt(tile) == null) {
  342. return true;
  343. }
  344. else
  345. walkOneTile();
  346. }
  347. return false;
  348. }
  349.  
  350. private boolean cookBeef () {
  351. RSObject fire = objects.getNearest(fireID);
  352. RSItem[] allBeef = inventory.getItems(rawBeef);
  353. if (fire == null || allBeef == null) {
  354. log(fire);
  355. log(allBeef);
  356. return false;
  357. }
  358. RSItem beef = allBeef[random(0, allBeef.length)];
  359. for (int i = 0; i < 2; i++) {
  360. if (beef.doAction("Use")) {
  361. sleep(random(600,800));
  362. mouse.move(calc.tileToScreen(fire.getLocation()));
  363. mouse.click(true);
  364. sleep(random(1500,3000));
  365. if (interfaces.get(905).isValid()) {
  366. log("Interface is valid");
  367. interfaces.getComponent (905, 14).doClick();
  368. while(inventory.contains(rawBeef)) {
  369. sleep(random(50,3000));
  370. }
  371. fireLit = false;
  372. if (!inventory.contains(rawBeef)) {
  373. return true;
  374. }
  375. }
  376. else
  377. log("Interface is not valid");
  378. }
  379. }
  380. return true;
  381. }
  382.  
  383. private void dropUnwantedItems() {
  384. inventory.dropAllExcept(safeToDropItems);
  385. }
  386.  
  387. public int loop() {
  388. if (!inventory.isFull()) {
  389. if (haveUsableLogs() && inventory.contains(cookedBeef)) {
  390. attackCows();
  391. }
  392. if (!haveUsableLogs()) {
  393. dealWithGate();
  394. sleep(random(25,100));
  395. if (!getLogs()) {
  396. log("Can't get logs");
  397. stopScript();
  398. }
  399. if (haveUsableLogs()) {
  400. return 0;
  401. }
  402. }
  403. else if (inventory.isFull()) {
  404. if (haveUsableLogs() && inventory.contains(cookedBeef)) {
  405. attackCows();
  406. }
  407. else if (!haveUsableLogs() && inventory.containsOneOf(safeToDropItems)) {
  408. RSItem itemToDrop = inventory.getItem(safeToDropItems);
  409. itemToDrop.doAction("Drop");
  410. dealWithGate();
  411. if (!getLogs()) {
  412. log("Can't get logs");
  413. stopScript();
  414. }
  415. if (haveUsableLogs()) {
  416. return 0;
  417. }
  418. }
  419. else if (!haveUsableLogs() && !inventory.containsOneOf(safeToDropItems) && inventory.containsOneOf(rawBeef)) {
  420. RSItem itemToDrop = inventory.getItem(rawBeef);
  421. itemToDrop.doAction("Drop");
  422. return 0;
  423. }
  424. else if (haveUsableLogs()) {
  425. lightLogs();
  426. cookBeef();
  427. dropUnwantedItems();
  428. return 0;
  429. }
  430. }
  431. else {
  432. log("Your shit's fucked up, yo");
  433. stopScript();
  434. }
  435. walkOneTile();
  436. return random(50,1000);
  437. }
  438. return 0;
  439. }
  440.  
  441. public void onFinish() {
  442. log("Goodbye!");
  443. }
  444. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement