Guest User

Untitled

a guest
Jul 18th, 2018
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.83 KB | None | 0 0
  1. /*
  2. * TODO: Nothing atm
  3. */
  4.  
  5. import java.awt.Color;
  6. import java.awt.Graphics;
  7. import java.awt.Point;
  8. import java.util.ArrayList;
  9. import java.util.List;
  10. import java.util.Map;
  11.  
  12. import org.rsbot.bot.Bot;
  13. import org.rsbot.event.events.ServerMessageEvent;
  14. import org.rsbot.event.listeners.PaintListener;
  15. import org.rsbot.event.listeners.ServerMessageListener;
  16. import org.rsbot.script.*;
  17. import org.rsbot.script.wrappers.*;
  18.  
  19.  
  20. @ScriptManifest(authors = { "Nobody" }, category = "Combat", name = "Ogre Cage Ranger", version = 1.9, description =
  21. "<html><body bgcolor =\"#AAAAAAAA\"><font color =\"#3333FF\"><center><h2>Nobody's Ogre Cage Ranger</h2><BR>"
  22. + "<font size =\"3\">Start in Traning Ground with Range Equipment,airs & laws<br />"
  23. + "<tr><td>Tele - Grab Seeds: </td><td><center><input type='checkbox' name='Seed' value='true'></font><br />"
  24. + "</font></body></html>")
  25. public class OgreCageRanger extends Script implements ServerMessageListener, PaintListener {
  26.  
  27. long startTime;
  28. long minutes;
  29. long seconds;
  30. long hours;
  31. long runTime;
  32.  
  33. RSTile StartSpot;
  34.  
  35. public int speed = 300;
  36. public int walkSpeed = 300;
  37.  
  38. public long lastCheck = -1, lastcheck1 = -1, lastCheck2, lastCheck3 = System.currentTimeMillis();
  39.  
  40. public Point mousePos;
  41.  
  42. boolean Seed = false;
  43.  
  44. int seed;
  45. int MONSTER = 2801;
  46. int LawRune = 563;
  47. int AirRune = 556;
  48. int expGained;
  49. int levelsGained;
  50. int startXp;
  51. int startLevel;
  52. int amountleft;
  53. int RanarrID = 5295;
  54. int WaterID = 5321;
  55. int SnapeID = 5300;
  56. int KwuarmID = 5299;
  57. int LimpID = 5100;
  58. int StrawbID = 5323;
  59. int LoopkID = 987;
  60. int ToothkID = 985;
  61. int ToadfID = 5296;
  62.  
  63. int[] totalSeeds = {RanarrID, WaterID, SnapeID, KwuarmID, LimpID, StrawbID, LoopkID, ToothkID, ToadfID};
  64.  
  65. @Override
  66. protected int getMouseSpeed() {
  67. return random(5, 7);
  68. }
  69.  
  70. public boolean onStart(Map<String, String> args) {
  71. StartSpot = getMyPlayer().getLocation();
  72. if (args.get("Seed") != null && inventoryContains(LawRune)
  73. && inventoryContains(AirRune)) {
  74. Seed = true;
  75. }
  76. seed = 0;
  77. startTime = System.currentTimeMillis();
  78. startXp = skills.getCurrentSkillExp(STAT_RANGE);
  79. startLevel = skills.getCurrentSkillLevel(STAT_RANGE);
  80. return true;
  81. }
  82.  
  83. public void onFinish() {
  84. Bot.getEventManager().removeListener(PaintListener.class, this);
  85. Bot.getEventManager().removeListener(ServerMessageListener.class, this);
  86. }
  87.  
  88. @Override
  89. public RSInterfaceChild getInventoryInterface() {
  90. if (getInterface(Constants.INVENTORY_COM_X).isValid()) {
  91. return RSInterface.getChildInterface(Constants.INVENTORY_COM_X,
  92. Constants.INVENTORY_COM_Y);
  93. }
  94.  
  95. return RSInterface.getChildInterface(Constants.INVENTORY_X,
  96. Constants.INVENTORY_Y);
  97. }
  98.  
  99. @SuppressWarnings("unused")
  100. private boolean clickInventoryArray(int[] itemID, String option) {
  101. if (getCurrentTab() != TAB_INVENTORY
  102. && !RSInterface.getInterface(INTERFACE_BANK).isValid()
  103. && !RSInterface.getInterface(INTERFACE_STORE).isValid()) {
  104. openTab(TAB_INVENTORY);
  105. }
  106. int[] items = getInventoryArray();
  107. java.util.List<Integer> possible = new ArrayList<Integer>();
  108. for (int X = 0; X < itemID.length; X++) {
  109. for (int i = 0; i < items.length; i++) {
  110. if (items[i] == itemID[X]) {
  111. possible.add(i);
  112. }
  113. }
  114. }
  115. if (possible.size() == 0) {
  116. return false;
  117. } else {
  118. int IDE = random(0, possible.size());
  119. int idx = possible.get(IDE);
  120. Point t = getInventoryItemPoint(idx);
  121. clickMouse(t, 5, 5, false);
  122. return atMenu(option);
  123. }
  124. }
  125.  
  126. public void checkForLevelUpMessage() {
  127. if (RSInterface.getInterface(INTERFACE_LEVELUP).isValid()) {
  128. wait(random(800, 2000));
  129. atInterface(INTERFACE_LEVELUP, 3);
  130. wait(random(1000, 2000));
  131. }
  132. }
  133.  
  134. public boolean CheckSeed() {
  135. RSTile Ranarr = getGroundItemByID(5295);
  136. RSTile Water = getGroundItemByID(5321);
  137. RSTile Snape = getGroundItemByID(5300);
  138. RSTile Kwuarm = getGroundItemByID(5299);
  139. RSTile Strawb = getGroundItemByID(5323);
  140. RSTile Toothk = getGroundItemByID(985);
  141. RSTile Loopk = getGroundItemByID(987);
  142. RSTile Limp = getGroundItemByID(5100);
  143. RSTile Toadf = getGroundItemByID(5296);
  144.  
  145. if (Seed) {
  146. if (Ranarr != null || Water != null || Snape != null
  147. || Kwuarm != null || Limp != null || Strawb != null
  148. || Toothk != null || Loopk != null || Limp != null
  149. || Toadf != null) {
  150. return false;
  151. }
  152. }
  153. return true;
  154. }
  155.  
  156.  
  157. public boolean rightClickTile(RSTile tile, String action) {
  158. Point p = Calculations.tileToScreen(tile);
  159. clickMouse(p, false);
  160. wait(random(500, 800));
  161. return atMenu(action);
  162. }
  163.  
  164. @Override
  165. public int loop() {
  166. if (distanceTo(StartSpot) > 3) {
  167. walkTileMM(StartSpot);
  168. }
  169.  
  170. {
  171. checkForLevelUpMessage();
  172. }
  173. if (Seed) {
  174. RSTile Ranarr = getGroundItemByID(RanarrID);
  175. RSTile Water = getGroundItemByID(WaterID);
  176. RSTile Snape = getGroundItemByID(SnapeID);
  177. RSTile Kwuarm = getGroundItemByID(KwuarmID);
  178. RSTile Limp = getGroundItemByID(LimpID);
  179. RSTile Strawb = getGroundItemByID(StrawbID);
  180. RSTile Toothk = getGroundItemByID(ToothkID);
  181. RSTile Loopk = getGroundItemByID(LoopkID);
  182. RSTile Toadf = getGroundItemByID(ToadfID);
  183.  
  184. if (Toadf != null) {
  185. openTab(Constants.TAB_MAGIC);
  186. if (getCurrentTab() == Constants.TAB_MAGIC) {
  187. castSpell(Constants.SPELL_TELEKINETIC_GRAB);
  188. rightClickTile(Toadf, "Grab -> Toadflax");
  189. seed++;
  190. openTab(Constants.TAB_INVENTORY);
  191. wait(random(1400, 2200));
  192. clickNPC(getNearestFreeNPCByID(MONSTER), "Attack");
  193. wait(random(100, 200));
  194. }
  195. }
  196. if (Ranarr != null) {
  197. openTab(Constants.TAB_MAGIC);
  198. if (getCurrentTab() == Constants.TAB_MAGIC) {
  199. castSpell(Constants.SPELL_TELEKINETIC_GRAB);
  200. rightClickTile(Ranarr, "Grab -> Ranarr");
  201. seed++;
  202. openTab(Constants.TAB_INVENTORY);
  203. wait(random(1400, 2200));
  204. clickNPC(getNearestFreeNPCByID(MONSTER), "Attack");
  205. wait(random(100, 200));
  206. }
  207. }
  208. if (Loopk != null) {
  209. openTab(Constants.TAB_MAGIC);
  210. if (getCurrentTab() == Constants.TAB_MAGIC) {
  211. castSpell(Constants.SPELL_TELEKINETIC_GRAB);
  212. rightClickTile(Loopk, "Grab -> Loop");
  213. seed++;
  214. openTab(Constants.TAB_INVENTORY);
  215. wait(random(1400, 2200));
  216. clickNPC(getNearestFreeNPCByID(MONSTER), "Attack");
  217. wait(random(100, 200));
  218. }
  219. }
  220. if (Toothk != null) {
  221. openTab(Constants.TAB_MAGIC);
  222. if (getCurrentTab() == Constants.TAB_MAGIC) {
  223. castSpell(Constants.SPELL_TELEKINETIC_GRAB);
  224. rightClickTile(Toothk, "Grab -> Tooth");
  225. seed++;
  226. openTab(Constants.TAB_INVENTORY);
  227. wait(random(1400, 2200));
  228. clickNPC(getNearestFreeNPCByID(MONSTER), "Attack");
  229. wait(random(100, 200));
  230. }
  231. }
  232. if (Strawb != null) {
  233. openTab(Constants.TAB_MAGIC);
  234. if (getCurrentTab() == Constants.TAB_MAGIC) {
  235. castSpell(Constants.SPELL_TELEKINETIC_GRAB);
  236. rightClickTile(Strawb, "Grab -> Strawberry");
  237. seed++;
  238. openTab(Constants.TAB_INVENTORY);
  239. wait(random(1400, 2200));
  240. clickNPC(getNearestFreeNPCByID(MONSTER), "Attack");
  241. wait(random(100, 200));
  242. }
  243. }
  244. if (Water != null) {
  245. openTab(Constants.TAB_MAGIC);
  246. if (getCurrentTab() == Constants.TAB_MAGIC) {
  247. castSpell(Constants.SPELL_TELEKINETIC_GRAB);
  248. rightClickTile(Water, "Grab -> Watermelon");
  249. seed++;
  250. openTab(Constants.TAB_INVENTORY);
  251. wait(random(1400, 2200));
  252. clickNPC(getNearestFreeNPCByID(MONSTER), "Attack");
  253. wait(random(100, 200));
  254. }
  255. }
  256. if (Snape != null) {
  257. openTab(Constants.TAB_MAGIC);
  258. if (getCurrentTab() == Constants.TAB_MAGIC) {
  259. castSpell(Constants.SPELL_TELEKINETIC_GRAB);
  260. rightClickTile(Snape, "Grab -> Snapdragon");
  261. seed++;
  262. openTab(Constants.TAB_INVENTORY);
  263. wait(random(1400, 2200));
  264. clickNPC(getNearestFreeNPCByID(MONSTER), "Attack");
  265. wait(random(100, 200));
  266. }
  267. }
  268. if (Kwuarm != null) {
  269. openTab(Constants.TAB_MAGIC);
  270. if (getCurrentTab() == Constants.TAB_MAGIC) {
  271. castSpell(Constants.SPELL_TELEKINETIC_GRAB);
  272. rightClickTile(Kwuarm, "Grab -> Kwuarm");
  273. seed++;
  274. openTab(Constants.TAB_INVENTORY);
  275. wait(random(1400, 2200));
  276. clickNPC(getNearestFreeNPCByID(MONSTER), "Attack");
  277. wait(random(100, 200));
  278. }
  279. }
  280. if (Limp != null) {
  281. openTab(Constants.TAB_MAGIC);
  282. if (getCurrentTab() == Constants.TAB_MAGIC) {
  283. castSpell(Constants.SPELL_TELEKINETIC_GRAB);
  284. rightClickTile(Limp, "Grab -> Limp");
  285. seed++;
  286. openTab(Constants.TAB_INVENTORY);
  287. wait(random(1400, 2200));
  288. clickNPC(getNearestFreeNPCByID(MONSTER), "Attack");
  289. wait(random(100, 200));
  290. }
  291. }
  292. }
  293. if (CheckSeed() && getMyPlayer().getInteracting() == null
  294. && getNearestFreeNPCByID(MONSTER) != null) {
  295. clickNPC(getNearestFreeNPCByID(MONSTER), "Attack");
  296. }
  297. return 800;
  298. }
  299.  
  300. public void serverMessageRecieved(ServerMessageEvent e) {
  301. String message = e.getMessage();
  302. if (message.contains("There is no ammo left in your quiver.")) {
  303. log("No Arrows!!");
  304. stopScript();
  305. }
  306. if (message.contains("That was your last one!")) {
  307. log("No knives!!");
  308. stopScript();
  309. }
  310. }
  311.  
  312. public boolean activateCondition() {
  313. if (getMyPlayer().isMoving()) {
  314. return random(1, walkSpeed) == 1;
  315. } else {
  316. return random(1, speed) == 1;
  317. }
  318. }
  319.  
  320. public boolean clickNPC(RSNPC npc, String action) {
  321. try {
  322. int a;
  323. StringBuffer npcCommandBuf = new StringBuffer();
  324. npcCommandBuf.append(action);
  325. npcCommandBuf.append(" ");
  326. npcCommandBuf.append(npc.getName());
  327. String npcCommand = npcCommandBuf.toString();
  328. for (a = 10; a-- >= 0;) {
  329. if (npc.getInteracting() != null
  330. && !npc.isInteractingWithLocalPlayer()) {
  331. return false;
  332. }
  333. List<String> menuItems = getMenuItems();
  334. if (menuItems.size() > 1) {
  335. if (listContainsString(menuItems, npcCommand)) {
  336. if (menuItems.get(0).contains(npcCommand)) {
  337. clickMouse(true);
  338. return true;
  339. } else {
  340. clickMouse(false);
  341. wait(random(230, 520));
  342. return atMenu(npcCommand);
  343. }
  344. }
  345. }
  346. Point screenLoc = npc.getScreenLocation();
  347. if (!pointOnScreen(screenLoc)) {
  348. return false;
  349. }
  350. Point randomP = new Point(random(screenLoc.x - 15,
  351. screenLoc.x + 15), random(screenLoc.y - 15,
  352. screenLoc.y + 15));
  353. if (randomP.x >= 0 && randomP.y >= 0) {
  354. moveMouse(randomP);
  355. }
  356. }
  357. return false;
  358. } catch (Exception e) {
  359. System.out.print("clickNPC(RSNPC, String) error: " + e);
  360. return false;
  361. }
  362. }
  363.  
  364. public boolean listContainsString(List<String> list, String string) {
  365. try {
  366. int a;
  367. for (a = list.size() - 1; a-- >= 0;) {
  368. if (list.get(a).contains(string)) {
  369. return true;
  370. }
  371. }
  372. } catch (Exception e) {
  373. }
  374. return false;
  375. }
  376.  
  377. public void onRepaint(Graphics g) {
  378. runTime = System.currentTimeMillis( ) - startTime;
  379. seconds = runTime / 1000;
  380. if ( seconds >= 60 ) {
  381. minutes = seconds / 60;
  382. seconds -= (minutes * 60);
  383. }
  384. if ( minutes >= 60 ) {
  385. hours = minutes / 60;
  386. minutes -= (hours * 60);
  387. }
  388.  
  389. expGained = skills.getCurrentSkillExp(STAT_RANGE) - startXp;
  390. g.setColor( new Color(0, 0, 0, 50) );
  391. g.fillRoundRect(3, 180, 155, 130, 5, 5);
  392.  
  393. levelsGained = skills.getCurrentSkillLevel(STAT_RANGE) - startLevel;
  394.  
  395. g.setColor( Color.WHITE );
  396. g.drawString("Ogre Cage Ranger V 1.89", 12, 216);
  397. g.drawString("Run time: " + hours + ":" + minutes + ":" + seconds, 12, 232);
  398. g.drawString("Seeds Collected: " + seed + " seeds.", 12, 248);
  399. g.drawString("XP Gained: " + expGained, 12, 264);
  400. g.drawString("Levels Gained: " + levelsGained, 12, 280);
  401. g.drawString("Percent to next level: " + skills.getPercentToNextLevel(STAT_RANGE), 12, 296);
  402. }
  403. }
Add Comment
Please, Sign In to add comment