Guest User

Untitled

a guest
Oct 22nd, 2017
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.94 KB | None | 0 0
  1. import java.awt.*;
  2. import org.rsbot.event.listeners.PaintListener;
  3. import org.rsbot.script.*;
  4. import org.rsbot.script.util.Timer;
  5. import org.rsbot.script.wrappers.*;
  6.  
  7. @ScriptManifest(name = "Cooking Guild Re-Write", authors = {"Joe Titus"}, keywords = "Cooks Guild", version = 1.1, description = "Collects stuff in the guild")
  8.  
  9. public class Methods extends Script implements PaintListener{
  10.  
  11. public int doorID = 2712, hatID = 1949, bottomStairID = 24073, middleStairID = 24074,
  12. topStairID = 24075, chocolateID = 1973, pieDishID = 2313, jugID = 1935,
  13. grapeID = 1987, appleID = 1955, bankBoothID = 782, pathOptions = 0, grapesCollected = 0,
  14. applesCollected = 0, chocolatesCollected = 0, pieDishesCollected = 0, jugsCollected = 0;
  15. public int secondsWaited, missesSupressed = 0;
  16. public int grapeAmount, appleAmount, chocolateAmount, jugAmount, pieDishAmount;
  17. public int grapeAmount2, appleAmount2, chocolateAmount2, jugAmount2, pieDishAmount2;
  18. public int chocolatePrice = 0, pieDishPrice = 0, jugPrice = 0, grapePrice = 0, applePrice = 0, startLvl;
  19. public int profit, loop1 = 0, itemID, itemsDone = 0;
  20. public RSTile objTile = null;
  21. public int items [];
  22. int pickUpIDS [] = {1973, 2313, 1935, 1987, 1955}, stairIDS [] = {24073, 24074, 24075};
  23. boolean paused = false, returnStatement, climbStairs, startPaint = true, inAFK = false,
  24. pricesChecked = false, clickDone = false, pricesLoaded = false, loadingPrices = false, stairsClimbed = false;
  25. String lastFloor = "null", currentFloor = "Bottom", currentLoc;
  26. static String status = "Starting";
  27. String itemPicked = null, itemString = null;
  28.  
  29. public RSTile doorTile = new RSTile (3143, 3443), bank1 = new RSTile(3186, 3445), bank2 = new RSTile(3186, 3435);
  30.  
  31. public RSGroundItem groundItem1;
  32. public boolean grapesYes = true, applesYes = true, chocolatesYes = true, jugsYes = true, pieDishesYes = true, started = false;;
  33. public final RSArea westBank = new RSArea(new RSTile[] {
  34. new RSTile(3179, 3447), new RSTile(3179, 3432),
  35. new RSTile(3194, 3432), new RSTile(3194, 3447)
  36. });
  37. Timer AFKTimer = new Timer (0);
  38. public RSGroundItem pGrape, pApple, pChocolate, pPieDish, pJug, paintItem;
  39.  
  40. public Polygon polly;
  41.  
  42. public boolean antiBanTab = false, generalTab = true, paintTab = false;
  43.  
  44.  
  45. public final RSArea insideGuild = new RSArea(new RSTile[] {
  46. new RSTile(3141, 3444), new RSTile(3144, 3444),
  47. new RSTile(3148, 3448), new RSTile(3147, 3452),
  48. new RSTile(3142, 3454), new RSTile(3137, 3451),
  49. new RSTile(3137, 3448)
  50. });
  51.  
  52.  
  53. public int loop() {
  54.  
  55. mouse.setSpeed(random(4, 9));
  56. return doAction(getState());
  57.  
  58. }
  59.  
  60.  
  61.  
  62. public state getState(){
  63.  
  64. getLocation();
  65. if(AFKTimer.isRunning()) {
  66. return state.Paused;
  67. } else if (inventory.contains(1931)){
  68. return state.DropItem;
  69. } else if (inventory.isFull()){
  70.  
  71. if (currentLoc.toLowerCase().contains("floor")){
  72. if (currentFloor == "Top"){
  73. return state.ClimbDownFromTop;
  74. } else if (currentFloor == "Middle"){
  75. return state.ClimbDownFromMiddle;
  76. } else if(currentFloor == "Bottom"){
  77. return state.ExitGuild;
  78. } else {
  79. return state.Sleep;
  80. }
  81. } else if (objects.getNearest(bankBoothID) == null || !objects.getNearest(bankBoothID).isOnScreen()){
  82. return state.WalkToBank;
  83. } else {
  84. return state.Bank;
  85. }
  86. } else if (!inventory.isFull()){
  87. if (currentLoc.toLowerCase().contains("floor")){
  88. if (grapesYes == true && groundItems.getNearest(grapeID) != null){
  89. secondsWaited = 0;
  90. return state.PickUpGrapes;
  91. } else if (applesYes == true && groundItems.getNearest(appleID) != null){
  92. secondsWaited = 0;
  93. return state.PickUpApple;
  94. } else if (chocolatesYes == true && groundItems.getNearest(chocolateID) != null){
  95. secondsWaited = 0;
  96. return state.PickUpChocolate;
  97. } else if (jugsYes == true && groundItems.getNearest(jugID) != null){
  98. secondsWaited = 0;
  99. return state.PickUpJug;
  100. } else if (pieDishesYes == true && groundItems.getNearest(pieDishID) != null){
  101. secondsWaited = 0;
  102. return state.PickUpPieDish;
  103. } else {
  104. return state.ClimbStairs;
  105. }
  106.  
  107. } else if (currentLoc.toLowerCase().contains("inside")){
  108. return state.WalkToGuild;
  109. } else if (currentLoc.toLowerCase().contains("outside") &&
  110. calc.distanceTo(doorTile) > 5) {
  111. return state.WalkToGuild;
  112. } else if (currentLoc.toLowerCase().contains("outside") &&
  113. calc.distanceTo(doorTile) <= 5) {
  114. return state.EnterGuild;
  115. } else {
  116. return state.Sleep;
  117. }
  118. } else {
  119. return state.Sleep;
  120. }
  121. }
  122.  
  123. private int sleep(){
  124. boolean exit = false;
  125. while (!getMyPlayer().isIdle() && !exit){
  126. sleep(300, 400);
  127. exit = (random(0, 4) == 0);
  128. }
  129. return random(0, 200);
  130. }
  131.  
  132. RSWeb currentWeb = null;
  133.  
  134. private boolean walkTo(RSTile tile){
  135. if (currentWeb == null || currentWeb.getEnd() != tile){
  136. currentWeb = web.getWeb(tile);
  137. return false;
  138. } else {
  139. return (currentWeb.step() && !currentWeb.finished());
  140. }
  141. }
  142.  
  143. private int doAction(state theState) {
  144.  
  145. switch (theState){
  146. case Paused:
  147. return sleep();
  148.  
  149.  
  150. case ClimbDownFromTop:
  151. status = "Leaving the guild";
  152. return interactObject(topStairID, "Climb-down") ? random(1500, 2000) : random(350, 750);
  153.  
  154. case ClimbDownFromMiddle:
  155. status = "Leaving the guild";
  156. return interactObject(middleStairID, "Climb-down") ? random(1500, 2000) : random(350, 750);
  157.  
  158. case ExitGuild:
  159. status = "Leaving the guild";
  160. return interactObject(doorID, "Open") ? random(1500, 2000) : random(350, 750);
  161.  
  162. case WalkToBank:
  163. status = "Banking";
  164. return (walkTo(bank1) ? random(350, 750) : 50);
  165.  
  166.  
  167. case Bank:
  168. status = "Banking";
  169. return bank() ? random(500, 750) : 50;
  170.  
  171. case WalkToGuild:
  172. status = "Walking to guild";
  173. return (walkTo(doorTile) ? random(350, 750) : 50);
  174.  
  175. case EnterGuild:
  176. status = "Entering guild";
  177. return interactObject(doorID, "Open") ? random(1500, 2000) : random(350, 750);
  178.  
  179. case ClimbStairs:
  180. status = "Climbing Stairs";
  181. return climbStairs() ? random(1500, 2000) : sleep();
  182.  
  183. case DropItem:
  184. status = "Dropping Pot";
  185. RSItem i = inventory.getItem(1931);
  186. i.interact("Drop Empty pot");
  187. return random(500, 1000);
  188.  
  189.  
  190. case PickUpGrapes:
  191. status = "Picking up grapes";
  192.  
  193. return pickUpItem(grapeID) ? random(750, 1250) : sleep();
  194.  
  195. case PickUpApple:
  196. status = "Picking up apples";
  197.  
  198. return pickUpItem(appleID) ? random(750, 1250) : sleep();
  199.  
  200. case PickUpChocolate:
  201. status = "Picking up chocolates";
  202.  
  203. return pickUpItem(chocolateID) ? random(750, 1250) : sleep();
  204.  
  205. case PickUpJug:
  206. status = "Picking up jugs";
  207.  
  208. return pickUpItem(jugID) ? random(750, 1250) : sleep();
  209.  
  210. case PickUpPieDish:
  211. status = "Picking up pie dishes";
  212.  
  213. return pickUpItem(pieDishID) ? random(750, 1250) : sleep();
  214.  
  215. case Sleep:
  216. return sleep();
  217. default:
  218. return 0;
  219. }
  220. }
  221.  
  222. private boolean bank(){
  223. if (bank.isOpen()){
  224. if (inventory.isFull()){
  225. return bank.depositAll();
  226. } else {
  227. return bank.close();
  228. }
  229. } else {
  230. return bank.open();
  231. }
  232. }
  233.  
  234. public boolean interactObject(int ID, String s){
  235. RSObject obj = objects.getNearest(ID);
  236. if (obj == null || !obj.isReachable()){
  237. return false;
  238. }
  239.  
  240. if (!obj.isOnScreen()){
  241. return walking.walkTileMM(obj.getLocation());
  242. }
  243.  
  244. return obj.interact(s);
  245. }
  246.  
  247. public boolean pickUpItem(int ID){
  248. RSGroundItem g = groundItems.getNearest(ID);
  249.  
  250.  
  251. if (g == null){
  252. return false;
  253. }
  254.  
  255. if (!g.isOnScreen()){
  256. return walking.walkTileMM(g.getLocation());
  257. }
  258.  
  259. return newTaker(g);
  260. }
  261.  
  262. public enum state{
  263. ClimbDownFromTop, ClimbDownFromMiddle, ExitGuild, WalkToBank, Bank,
  264. WalkToGuild, EnterGuild, ClimbStairs, DropItem, Sleep, NOTHING, Paused,
  265. PickUpGrapes, PickUpApple, PickUpChocolate, PickUpJug, PickUpPieDish
  266. }
  267.  
  268.  
  269. public boolean newTaker(RSGroundItem g){
  270.  
  271. RSTile t = g.getLocation();
  272. if (getMyPlayer().isIdle()) {
  273. if (objects.getTopAt(t) != null){
  274. if(atTile(t, -500, .5, .5, g.getItem().getName())){
  275. clickDone = true;
  276. return true;
  277. } else {
  278. return false;
  279. }
  280. } else {
  281. if(atTile(t, 0, .5, .5, g.getItem().getName())){
  282. clickDone = true;
  283. return true;
  284. } else {
  285. return false;
  286. }
  287. }
  288.  
  289. } else {
  290. return false;
  291. }
  292.  
  293. }
  294.  
  295. public boolean atTile(final RSTile tile, final int h, final double xd, final double yd, String s) {
  296. try {
  297. final Point location = calc.tileToScreen(tile, xd, yd, h);
  298. if (location.x == -1 || location.y == -1) {
  299. return false;
  300. }
  301. mouse.move(location, 4, 4);
  302. if (menu.contains("Take " + s)){
  303. menu.doAction("Take " + s);
  304. } else {
  305. return false;
  306. }
  307. return true;
  308. } catch (final Exception e) {
  309. return false;
  310. }
  311. }
  312.  
  313. public void getLocation() {
  314. if (insideGuild.contains(new RSTile(getMyPlayer().getLocation().getX(), getMyPlayer().getLocation().getY(), 0))){
  315. RSObject stairs = objects.getNearest(stairIDS);
  316. if (stairs.getID() == bottomStairID) {
  317. currentLoc = "Bottom Floor";
  318. currentFloor = "Bottom";
  319. if (lastFloor == "null") {
  320. lastFloor = "Bottom";
  321. }
  322. } else if (stairs.getID() == middleStairID) {
  323. currentLoc = "Middle Floor";
  324. currentFloor = "Middle";
  325. if (lastFloor == "null") {
  326. lastFloor = "Bottom";
  327. }
  328. } else if (stairs.getID() == topStairID) {
  329. currentLoc = "Top Floor";
  330. currentFloor = "Top";
  331. if (lastFloor == "null") {
  332. lastFloor = "Top";
  333. }
  334. }
  335. } else if (westBank.contains(getMyPlayer().getLocation())){
  336. currentLoc = "Inside Bank";
  337. if (lastFloor == "null") {
  338. lastFloor = "Bottom";
  339. }
  340. } else {
  341. currentLoc = "Outside";
  342. if (lastFloor == "null") {
  343. lastFloor = "Bottom";
  344. }
  345. }
  346. }
  347.  
  348. public boolean climbStairs() {
  349.  
  350.  
  351. RSObject stairs = objects.getNearest(stairIDS);
  352.  
  353. if (!getMyPlayer().isIdle() || stairs == null){
  354. return false;
  355. }
  356.  
  357. if (!stairs.isOnScreen()){
  358. return walking.walkTileMM(stairs.getLocation());
  359. }
  360.  
  361. try{
  362. if (stairs.getID() == bottomStairID) {
  363. stairsClimbed = true;
  364.  
  365. stairs.interact("Climb-up");
  366.  
  367. lastFloor = "Bottom";
  368. currentFloor = "Middle";
  369.  
  370. } else if (stairs.getID() == middleStairID) {
  371. stairsClimbed = true;
  372.  
  373.  
  374. if (lastFloor == "Bottom") {
  375. currentFloor = "Top";
  376. stairs.interact("Climb-up");
  377. } else if (lastFloor == "Top") {
  378. stairs.interact("Climb-down");
  379. currentFloor = "Bottom";
  380. }
  381. } else if (stairs.getID() == topStairID) {
  382. stairsClimbed = true;
  383.  
  384. stairs.interact("Climb-down");
  385. lastFloor = "Top";
  386. currentFloor = "Middle";
  387. }
  388. return true;
  389. } catch (Exception e){
  390. return false;
  391. }
  392.  
  393. }
  394.  
  395.  
  396.  
  397. @Override
  398. public void onRepaint(Graphics g1) {
  399. Graphics2D g = (Graphics2D) g1;
  400. g.setColor(Color.WHITE);
  401. g.drawString("Status: " + status, 5, 35);
  402.  
  403. g.drawOval(mouse.getLocation().x-1, mouse.getLocation().y-1, 2, 2);
  404.  
  405. }
  406.  
  407.  
  408.  
  409. }
Add Comment
Please, Sign In to add comment