Advertisement
Guest User

Untitled

a guest
Oct 27th, 2016
349
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.73 KB | None | 0 0
  1. package com.plaguedoctor.oldschoolscripts.pmagicguild;
  2.  
  3. import org.osbot.rs07.api.map.Area;
  4. import org.osbot.rs07.api.map.Position;
  5. import org.osbot.rs07.api.model.NPC;
  6. import org.osbot.rs07.api.ui.RS2Widget;
  7. import org.osbot.rs07.api.ui.Tab;
  8. import org.osbot.rs07.script.Script;
  9. import org.osbot.rs07.script.ScriptManifest;
  10. import org.osbot.rs07.utility.ConditionalSleep;
  11.  
  12.  
  13.  
  14. import java.awt.*;
  15. import java.util.LinkedList;
  16. import java.util.concurrent.ThreadLocalRandom;
  17.  
  18.  
  19. @ScriptManifest(name = "PMagicGuild", author = "Plague Doctor", version = 1.0, info = "Buys runes and battlestaves", logo = "")
  20. public class Main extends Script {
  21.  
  22. // Variables
  23.  
  24. Area magicGuild = new Area(new Position(2584, 3094, 1), new Position(2596, 3081, 1));
  25. Area yanilleBank = new Area(2616, 3088, 2609, 3097);
  26. String items[] = new String[] {"Death rune", "Nature rune", "Battlestaff", };
  27. int rand = ThreadLocalRandom.current().nextInt(1,10);
  28. int randResponse = ThreadLocalRandom.current().nextInt(1,10);
  29.  
  30.  
  31. @Override
  32. public void onStart() {
  33. }
  34.  
  35. private enum State {
  36. BANK_INVENTORY, SHOP, HOP, CHAT1// Declares the different states of the program.
  37. };
  38.  
  39. private State getState()
  40. {
  41. RS2Widget response = getWidgets().get(162, 41);
  42. if(getStore().isOpen()) {
  43. if(getStore().getAmount(items) <= 0) {
  44. return State.HOP;
  45. }
  46. }
  47.  
  48.  
  49. if(inventory.isFull()) {
  50. return State.BANK_INVENTORY;
  51. }
  52.  
  53. if(response.getMessage().contains("hi") || response.getMessage().contains("hey") || response.getMessage().contains("sup") ||
  54. response.getMessage().contains("yo") || response.getMessage().contains("hello") || response.getMessage().contains("heya")) {
  55. return State.CHAT1;
  56. }
  57.  
  58. return State.SHOP;
  59. }
  60.  
  61.  
  62. @Override
  63. public int onLoop() throws InterruptedException {
  64. State state = getState();
  65. log(state);
  66. switch (state) {
  67. case SHOP:
  68. RS2Widget chatBox = getWidgets().get(162, 43, 0);
  69. rand = ThreadLocalRandom.current().nextInt(1,10);
  70. if(rand == 5) {
  71. getMouse().moveSlightly();
  72. }
  73. if(rand == 10) {
  74. getMouse().moveOutsideScreen();
  75. sleep(random(2000-7000));
  76. }
  77. NPC Store = npcs.closest("Magic Store owner");
  78. if(chatBox.getMessage().contains("coins")) {
  79. stop();
  80. }
  81. if(magicGuild.contains(myPlayer())) {
  82. if(Store != null && getStore().isOpen()) {
  83. if(getStore().getAmount("Death rune") >= 1) {
  84. getStore().buy("Death rune", 10);
  85. if(getStore().getAmount("Chaos rune") >= 1) {
  86. getStore().buy("Chaos rune", 10);
  87. }
  88. }
  89. if(getStore().getAmount("Nature rune") >= 1) {
  90. getStore().buy("Nature rune", 10);
  91. if(getStore().getAmount("Chaos rune") >= 1) {
  92. getStore().buy("Chaos rune", 10);
  93. }
  94. }
  95. if(getStore().getAmount("Battlestaff") >= 1) {
  96. getStore().buy("Battlestaff", 10);
  97. if(getStore().getAmount("Chaos rune") >= 1) {
  98. getStore().buy("Chaos rune", 10);
  99. }
  100. }
  101. }
  102. if(!getStore().isOpen() && Store != null) {
  103. Store.interact("Trade");
  104. new ConditionalSleep(7000, 10000) {
  105. @Override
  106.  
  107. public boolean condition() throws InterruptedException {
  108. return getStore().isOpen();
  109. }
  110. }.sleep();
  111. }
  112. }
  113. else {
  114. getWalking().webWalk(magicGuild);
  115. }
  116. break;
  117.  
  118. case HOP:
  119. rand = ThreadLocalRandom.current().nextInt(1,10);
  120. if(rand == 5) {
  121. getMouse().moveSlightly();
  122. }
  123. if(rand == 10) {
  124. getMouse().moveOutsideScreen();
  125. sleep(random(2000-7000));
  126. }
  127. if(rand == 2) {
  128. getMouse().moveOutsideScreen();
  129. sleep(random(7000-13000));
  130. }
  131. if(rand == 7) {
  132. tabs.open(Tab.IGNORES);
  133. sleep(random(200,500));
  134. }
  135. if(getStore().isOpen()) {
  136. getStore().close();
  137. new ConditionalSleep(20000, 25000) {
  138. @Override
  139.  
  140. public boolean condition() throws InterruptedException {
  141. return !getStore().isOpen();
  142. }
  143. }.sleep();
  144. }
  145. sleep(random(1000,4000));
  146. getWorlds().hopToP2PWorld();
  147. new ConditionalSleep(20000, 25000) {
  148. @Override
  149.  
  150. public boolean condition() throws InterruptedException {
  151. return Main.this.myPlayer().exists();
  152. }
  153. }.sleep();
  154.  
  155. break;
  156.  
  157.  
  158. case BANK_INVENTORY:
  159. rand = ThreadLocalRandom.current().nextInt(1,10);
  160. if(rand == 5) {
  161. getMouse().moveSlightly();
  162. }
  163. if(rand == 10) {
  164. getMouse().moveOutsideScreen();
  165. sleep(random(2000-7000));
  166. }
  167. if(yanilleBank.contains(myPlayer()))
  168. {
  169. if(!getBank().isOpen())
  170. {
  171. getBank().open();
  172. new ConditionalSleep(10000) {
  173. @Override
  174.  
  175. public boolean condition() throws InterruptedException {
  176. return bank.isOpen();
  177. }
  178. }.sleep();
  179. }
  180. else
  181. {
  182. getBank().depositAllExcept("Coins");
  183. }
  184.  
  185. }
  186. else
  187. {
  188. getWalking().webWalk(yanilleBank);
  189. }
  190. break;
  191.  
  192. case CHAT1:
  193.  
  194. randResponse = ThreadLocalRandom.current().nextInt(1,10);
  195. if(randResponse == 1)
  196. getKeyboard().typeString("hi");
  197. if(randResponse == 2)
  198. getKeyboard().typeString("heya");
  199. if(randResponse == 3)
  200. getKeyboard().typeString("sup");
  201. if(randResponse == 4)
  202. getKeyboard().typeString("yo");
  203. if(randResponse == 5)
  204. getKeyboard().typeString("hihi");
  205. if(randResponse == 6)
  206. getKeyboard().typeString("hallo");
  207. if(randResponse == 7)
  208. getKeyboard().typeString("hello");
  209. if(randResponse == 8)
  210. getKeyboard().typeString("hiiiii");
  211. if(randResponse == 9)
  212. getKeyboard().typeString("howdy");
  213. if(randResponse == 10)
  214. getKeyboard().typeString("heeey");
  215. else
  216. getKeyboard().typeString("que?");
  217.  
  218.  
  219. break;
  220.  
  221.  
  222. }
  223.  
  224.  
  225.  
  226. return random(600, 800); //The amount of time in milliseconds before the loop is called again
  227. }
  228.  
  229.  
  230.  
  231. @Override
  232. public void onExit() {
  233. // This will get executed when the user hits the stop script button.
  234.  
  235. }
  236.  
  237. LinkedList<MousePathPoint> mousePath = new LinkedList<MousePathPoint>();
  238. public class MousePathPoint extends Point {
  239.  
  240. /**
  241. *
  242. */
  243. private static final long serialVersionUID = 8948307125632779948L;
  244. private long finishTime;
  245.  
  246. public MousePathPoint(int x, int y, int lastingTime) {
  247. super(x, y);
  248. finishTime = System.currentTimeMillis() + lastingTime;
  249. }
  250.  
  251. public boolean isUp() {
  252. return System.currentTimeMillis() > finishTime;
  253. }
  254. }
  255.  
  256. @Override
  257. public void onPaint(Graphics2D g) {
  258. g.setPaint(Color.cyan);
  259.  
  260. while (!mousePath.isEmpty() && mousePath.peek().isUp())
  261. mousePath.remove();
  262.  
  263. Point clientCursor = mouse.getPosition();
  264.  
  265. g.drawLine(clientCursor.x, clientCursor.y, clientCursor.x, clientCursor.y);
  266.  
  267. MousePathPoint mpp = new MousePathPoint(clientCursor.x, clientCursor.y, 500);
  268. if (mousePath.isEmpty() || !mousePath.getLast().equals(mpp))
  269. mousePath.add(mpp);
  270. MousePathPoint lastPoint = null;
  271. for (MousePathPoint a : mousePath) {
  272. if (lastPoint != null) {
  273. g.drawLine(a.x, a.y, lastPoint.x, lastPoint.y);
  274. }
  275. lastPoint = a;
  276. }
  277. }
  278.  
  279.  
  280. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement