Guest User

Untitled

a guest
Jul 22nd, 2018
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 17.08 KB | None | 0 0
  1. /*
  2. * TODO: Add Range Pots - Low Priority
  3. * Walk Out Of Cage Failsafe (shouldnt walk in)-med-
  4. * GUI? -low-
  5. * spec at 55% -low-
  6. *
  7. */
  8.  
  9. import java.awt.Color;
  10. import java.awt.Font;
  11. import java.awt.Graphics;
  12. import java.awt.Point;
  13. import java.util.List;
  14. import java.util.Map;
  15.  
  16. import org.rsbot.bot.Bot;
  17. import org.rsbot.bot.input.Mouse;
  18. import org.rsbot.event.events.ServerMessageEvent;
  19. import org.rsbot.event.listeners.PaintListener;
  20. import org.rsbot.event.listeners.ServerMessageListener;
  21. import org.rsbot.script.*;
  22. import org.rsbot.script.wrappers.*;
  23.  
  24.  
  25. @ScriptManifest(authors = { "Nobody" }, category = "Combat", name = "Ogre Cage Ranger", version = 3.0, description =
  26. "<html><body bgcolor =\"#AAAAAAAA\"><font color =\"#3333FF\"><center><h2>Nobody's Ogre Cage Ranger</h2><BR>"
  27. + "<font size =\"3\">Start in Traning Ground with Range Equipment,airs & laws<br />"
  28. + "<tr><td>Tele-Grab Seeds: </td><td><center><input type='checkbox' name='Seed' value='true'></font><br />"
  29. + "<tr><td>Special Attack: </td><td><center><input type='checkbox' name='Spec' value='true'></font><br />"
  30. + "</font></body></html>")
  31. public class OgreCageRanger extends Script implements ServerMessageListener, PaintListener {
  32.  
  33. //SpecTimer//
  34. long nextSpecialTime = 0;
  35.  
  36. //RSTile//
  37. RSTile StartSpot;
  38.  
  39. //Paint Times//
  40. public long startTime = System.currentTimeMillis();
  41.  
  42. public Point mousePos;
  43.  
  44. //Booleans// returns true if selected.
  45. public boolean Spec = false;
  46. public boolean Seed = false;
  47.  
  48. //Ints//
  49. int seed;
  50. int Ogre = 2801;
  51. int LawRune = 563;
  52. int AirRune = 556;
  53.  
  54. public int amountleft;
  55. public int RanarrID = 5295;
  56. public int WaterID = 5321;
  57. public int SnapeID = 5300;
  58. public int KwuarmID = 5299;
  59. public int LimpID = 5100;
  60. public int StrawbID = 5323;
  61. public int LoopkID = 987;
  62. public int ToothkID = 985;
  63. public int ToadfID = 5296;
  64. public int LongBoneID = 10976;
  65. public int CurvedBoneID = 10977;
  66. public int TorstolID = 5304;
  67. public int specialCost = 0;
  68. public int lastSpecialValue = 0;
  69. public int statIndex = 0;
  70. public int paintSelection = 1;
  71. public int startexp;
  72. public int expgained;
  73. public int HPstartexp;
  74. public int HPexpgained;
  75. public int speed = 300;
  76. public int walkSpeed = 300;
  77. public int antiban;
  78.  
  79. //Paint Colors//
  80. //By Epic_ //
  81. private final Color background = new Color(0,0,0,200),
  82. blue = new Color(51, 204, 255, 200),
  83. white = new Color(255,255,255,200),
  84. green = new Color(30,255,30,200);
  85.  
  86. //Status string//
  87. public String status = "Loading script";
  88.  
  89. //Do Not edit or script will fail//
  90. @Override
  91. protected int getMouseSpeed() {
  92. return random(7, 9);
  93. }
  94.  
  95. public boolean onStart(Map<String, String> args) {
  96. StartSpot = getMyPlayer().getLocation();
  97. if (args.get("Seed") != null && inventoryContains(LawRune)
  98. && inventoryContains(AirRune)) {
  99. Seed = true;
  100. }
  101. if (args.get("Spec") != null ) {
  102. Spec = true;
  103. }
  104. seed = 0;
  105. return true;
  106. }
  107.  
  108. public void onFinish() {
  109. Bot.getEventManager().removeListener(PaintListener.class, this);
  110. Bot.getEventManager().removeListener(ServerMessageListener.class, this);
  111. }
  112.  
  113. //Ruski <- i think
  114. @Override
  115. public RSInterfaceChild getInventoryInterface() {
  116. if (getInterface(Constants.INVENTORY_COM_X).isValid()) {
  117. return RSInterface.getChildInterface(Constants.INVENTORY_COM_X,
  118. Constants.INVENTORY_COM_Y);
  119. }
  120.  
  121. return RSInterface.getChildInterface(Constants.INVENTORY_X,
  122. Constants.INVENTORY_Y);
  123. }
  124.  
  125. //if Using Give Credits
  126. public boolean CheckSeed() {
  127. RSTile Ranarr = getGroundItemByID(5295);
  128. RSTile Water = getGroundItemByID(5321);
  129. RSTile Snape = getGroundItemByID(5300);
  130. RSTile Kwuarm = getGroundItemByID(5299);
  131. RSTile Strawb = getGroundItemByID(5323);
  132. RSTile Toothk = getGroundItemByID(985);
  133. RSTile Loopk = getGroundItemByID(987);
  134. RSTile Limp = getGroundItemByID(5100);
  135. RSTile Toadf = getGroundItemByID(5296);
  136. RSTile LongBone = getGroundItemByID(10976);
  137. RSTile CurvedBone = getGroundItemByID(10977);
  138. RSTile Torstol = getGroundItemByID(5304);
  139.  
  140. if (Seed) {
  141. if (Ranarr != null || Water != null || Snape != null
  142. || Kwuarm != null || Limp != null || Strawb != null
  143. || Toothk != null || Loopk != null || Limp != null
  144. || Toadf != null || LongBone != null || CurvedBone != null
  145. || Torstol != null) {
  146. return false;
  147. }
  148. }
  149. return true;
  150. }
  151.  
  152.  
  153. public boolean rightClickTile(RSTile tile, String action) {
  154. Point p = Calculations.tileToScreen(tile);
  155. clickMouse(p, false);
  156. wait(random(500, 800));
  157. return atMenu(action);
  158. }
  159.  
  160. @Override
  161. public int loop() {
  162. antiBan();
  163. checkForLvlUpMessage();
  164. if (distanceTo(StartSpot) > 2) {
  165. if (!walkTileMM(StartSpot)) {
  166. walkTo(StartSpot);
  167. }
  168. }
  169. //should work else checkForLvlMessage will activate as failsafe
  170. if (canContinue()){
  171. status = "Click Continue";
  172. clickContinue();
  173. }
  174. if (Spec) {
  175. doSpec();
  176. }
  177. if (Seed) {
  178. RSTile Ranarr = getGroundItemByID(RanarrID);
  179. RSTile Water = getGroundItemByID(WaterID);
  180. RSTile Snape = getGroundItemByID(SnapeID);
  181. RSTile Kwuarm = getGroundItemByID(KwuarmID);
  182. RSTile Limp = getGroundItemByID(LimpID);
  183. RSTile Strawb = getGroundItemByID(StrawbID);
  184. RSTile Toothk = getGroundItemByID(ToothkID);
  185. RSTile Loopk = getGroundItemByID(LoopkID);
  186. RSTile Toadf = getGroundItemByID(ToadfID);
  187. RSTile LongBone = getGroundItemByID(LongBoneID);
  188. RSTile CurvedBone = getGroundItemByID(CurvedBoneID);
  189. RSTile Torstol = getGroundItemByID(TorstolID);
  190.  
  191. if (Toadf != null) {
  192. status = "Tele-Grab";
  193. openTab(Constants.TAB_MAGIC);
  194. if (getCurrentTab() == Constants.TAB_MAGIC) {
  195. castSpell(Constants.SPELL_TELEKINETIC_GRAB);
  196. rightClickTile(Toadf, "Grab -> Toadflax");
  197. seed++;
  198. openTab(Constants.TAB_INVENTORY);
  199. wait(random(1400, 2200));
  200. }
  201. }
  202. if (Ranarr != null) {
  203. status = "Tele-Grab";
  204. openTab(Constants.TAB_MAGIC);
  205. if (getCurrentTab() == Constants.TAB_MAGIC) {
  206. castSpell(Constants.SPELL_TELEKINETIC_GRAB);
  207. rightClickTile(Ranarr, "Grab -> Ranarr");
  208. seed++;
  209. openTab(Constants.TAB_INVENTORY);
  210. wait(random(1400, 2200));
  211. }
  212. }
  213. if (Loopk != null) {
  214. status = "Tele-Grab";
  215. openTab(Constants.TAB_MAGIC);
  216. if (getCurrentTab() == Constants.TAB_MAGIC) {
  217. castSpell(Constants.SPELL_TELEKINETIC_GRAB);
  218. rightClickTile(Loopk, "Grab -> Loop");
  219. seed++;
  220. openTab(Constants.TAB_INVENTORY);
  221. wait(random(1400, 2200));
  222. }
  223. }
  224. if (Toothk != null) {
  225. status = "Tele-Grab";
  226. openTab(Constants.TAB_MAGIC);
  227. if (getCurrentTab() == Constants.TAB_MAGIC) {
  228. castSpell(Constants.SPELL_TELEKINETIC_GRAB);
  229. rightClickTile(Toothk, "Grab -> Tooth");
  230. seed++;
  231. openTab(Constants.TAB_INVENTORY);
  232. wait(random(1400, 2200));
  233. }
  234. }
  235. if (Strawb != null) {
  236. status = "Tele-Grab";
  237. openTab(Constants.TAB_MAGIC);
  238. if (getCurrentTab() == Constants.TAB_MAGIC) {
  239. castSpell(Constants.SPELL_TELEKINETIC_GRAB);
  240. rightClickTile(Strawb, "Grab -> Strawberry");
  241. seed++;
  242. openTab(Constants.TAB_INVENTORY);
  243. wait(random(1400, 2200));
  244. }
  245. }
  246. if (Water != null) {
  247. status = "Tele-Grab";
  248. openTab(Constants.TAB_MAGIC);
  249. if (getCurrentTab() == Constants.TAB_MAGIC) {
  250. castSpell(Constants.SPELL_TELEKINETIC_GRAB);
  251. rightClickTile(Water, "Grab -> Watermelon");
  252. seed++;
  253. openTab(Constants.TAB_INVENTORY);
  254. wait(random(1400, 2200));
  255. }
  256. }
  257. if (Snape != null) {
  258. status = "Tele-Grab";
  259. openTab(Constants.TAB_MAGIC);
  260. if (getCurrentTab() == Constants.TAB_MAGIC) {
  261. castSpell(Constants.SPELL_TELEKINETIC_GRAB);
  262. rightClickTile(Snape, "Grab -> Snapdragon");
  263. seed++;
  264. openTab(Constants.TAB_INVENTORY);
  265. wait(random(1400, 2200));
  266. }
  267. }
  268. if (Kwuarm != null) {
  269. status = "Tele-Grab";
  270. openTab(Constants.TAB_MAGIC);
  271. if (getCurrentTab() == Constants.TAB_MAGIC) {
  272. castSpell(Constants.SPELL_TELEKINETIC_GRAB);
  273. rightClickTile(Kwuarm, "Grab -> Kwuarm");
  274. seed++;
  275. openTab(Constants.TAB_INVENTORY);
  276. wait(random(1400, 2200));
  277. }
  278. }
  279. if (Limp != null) {
  280. status = "Tele-Grab";
  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. }
  289. }
  290. if (LongBone != null) {
  291. status = "Tele-Grab";
  292. openTab(Constants.TAB_MAGIC);
  293. if (getCurrentTab() == Constants.TAB_MAGIC) {
  294. castSpell(Constants.SPELL_TELEKINETIC_GRAB);
  295. rightClickTile(Kwuarm, "Grab -> Long");
  296. seed++;
  297. openTab(Constants.TAB_INVENTORY);
  298. wait(random(1400, 2200));
  299. }
  300. }
  301. if (CurvedBone != null) {
  302. status = "Tele-Grab";
  303. openTab(Constants.TAB_MAGIC);
  304. if (getCurrentTab() == Constants.TAB_MAGIC) {
  305. castSpell(Constants.SPELL_TELEKINETIC_GRAB);
  306. rightClickTile(Limp, "Grab -> Curved");
  307. seed++;
  308. openTab(Constants.TAB_INVENTORY);
  309. wait(random(1400, 2200));
  310. }
  311. }
  312. if (Torstol != null) {
  313. status = "Tele-Grab";
  314. openTab(Constants.TAB_MAGIC);
  315. if (getCurrentTab() == Constants.TAB_MAGIC) {
  316. castSpell(Constants.SPELL_TELEKINETIC_GRAB);
  317. rightClickTile(Limp, "Grab -> Torstol");
  318. seed++;
  319. openTab(Constants.TAB_INVENTORY);
  320. wait(random(1400, 2200));
  321. }
  322. }
  323. }
  324. if (CheckSeed() && getMyPlayer().getInteracting() == null
  325. && getNearestFreeNPCByID(Ogre) != null) {
  326. status = "click NPC";
  327. clickNPC(getNearestFreeNPCByID(Ogre), "Attack");
  328. }
  329. return 800;
  330. }
  331.  
  332. //needs to be updated since it causes mayor freeze/lagg
  333. public void serverMessageRecieved(ServerMessageEvent e) {
  334. String message = e.getMessage();
  335. if (message.contains("There is no ammo left in your quiver.")) {
  336. log("No Arrows!!");
  337. status = "Ending...";
  338. stopScript();
  339. }
  340. if (message.contains("That was your last one!")) {
  341. log("No knives!!");
  342. status = "Ending...";
  343. stopScript();
  344. }
  345. }
  346.  
  347. public boolean activateCondition() {
  348. if (getMyPlayer().isMoving()) {
  349. return random(1, walkSpeed) == 1;
  350. } else {
  351. return random(1, speed) == 1;
  352. }
  353. }
  354.  
  355. //If using Give Credits
  356. public boolean listContainsString(List<String> list, String string) {
  357. try {
  358. int a;
  359. for (a = list.size() - 1; a-- >= 0;) {
  360. if (list.get(a).contains(string)) {
  361. return true;
  362. }
  363. }
  364. } catch (Exception e) {
  365. }
  366. return false;
  367. }
  368.  
  369. //If Using Give Credits
  370. private boolean clickNPC(final RSNPC npc, final String action) {
  371. final RSTile tile = npc.getLocation();
  372. tile.randomizeTile(1, 1);
  373. try {
  374. final int hoverRand = random(8, 13);
  375. for (int i = 0; i < hoverRand; i++) {
  376. final Point screenLoc = npc.getScreenLocation();
  377. if (!pointOnScreen(screenLoc)) {
  378. setCameraRotation(getCameraAngle() + random(-35, 150));
  379. return true;
  380. }
  381.  
  382. moveMouse(screenLoc, 15, 15);
  383.  
  384. final List<String> menuItems = getMenuItems();
  385. if (menuItems.isEmpty() || menuItems.size() <= 1) {
  386. continue;
  387. }
  388. if (menuItems.get(0).toLowerCase().contains(
  389. npc.getName().toLowerCase())
  390. && getMyPlayer().getInteracting() == null) {
  391. clickMouse(true);
  392. return true;
  393. } else {
  394. for (int a = 1; a < menuItems.size(); a++) {
  395. if (menuItems.get(a).toLowerCase().contains(
  396. npc.getName().toLowerCase())
  397. && getMyPlayer().getInteracting() == null) {
  398. clickMouse(false);
  399. return atMenu(action);
  400. }
  401. }
  402. }
  403. }
  404.  
  405. } catch (final Exception e) {
  406. log.warning("ClickNPC error: " + e);
  407. return false;
  408. }
  409. return false;
  410. }
  411.  
  412. //If Using Give Credits
  413. public void antiBan(){
  414. antiban = random(0, 60);
  415. if(antiban == 12) {
  416. setCameraRotation(random(1,360));
  417. }
  418. if(antiban == 2) {
  419. moveMouseRandomly(20);
  420. }
  421. if(antiban == 17) {
  422. setCameraRotation(random(1, 100));
  423. }
  424. if(antiban == 6) {
  425. moveMouseRandomly(750);
  426. }
  427. if(antiban == 31) {
  428. setCameraRotation(random(1,176));
  429. moveMouseRandomly(750);
  430. }
  431. if(antiban == 38) {
  432. openTab(TAB_STATS);
  433. wait(random(100,200));
  434. }
  435. if(antiban == 42) {
  436. openTab(TAB_ATTACK);
  437. wait(random(100,200));
  438. }
  439. if(antiban == 21) {
  440. openTab(TAB_MAGIC);
  441. wait(random(100,200));
  442. }
  443. if(antiban == 14) {
  444. RSTile Bone = getGroundItemByID(532);
  445. if (Bone != null) {
  446. rightClickTile(Bone, "Cancel");
  447. }
  448. }
  449. }
  450.  
  451. public int getSpec() {
  452. return getSetting(300);
  453. }
  454.  
  455. public boolean specEnabled() {
  456. return (getSetting(301)) == 1;
  457. }
  458.  
  459. public void doSpec() {
  460. if (getSpec() == 550 && !specEnabled() ) {
  461. openTab(TAB_ATTACK);
  462. clickMouse(645 + random(0, 4), 425 + random(0, 4), true);
  463. } else if (getSpec() == 1000 && !specEnabled() ) {
  464. openTab(TAB_ATTACK);
  465. clickMouse(645 + random(0, 4), 425 + random(0, 4), true);
  466. }
  467. return;
  468. }
  469.  
  470.  
  471. //Credits to Epic_ tooken from Myr Seagull Killer
  472. public void onRepaint(Graphics g) {
  473. if (isLoggedIn()) {
  474.  
  475. int expgained = 0;
  476. int HPexpgained = 0;
  477.  
  478.  
  479. if ( startexp == 0) {
  480. startexp = skills.getCurrentSkillExp(STAT_DEFENSE);
  481. statIndex = STAT_DEFENSE;
  482. }
  483. expgained = skills.getCurrentSkillExp(STAT_DEFENSE) - startexp;
  484.  
  485.  
  486. if ( startexp == 0) {
  487. startexp = skills.getCurrentSkillExp(STAT_RANGE);
  488. statIndex = STAT_RANGE;
  489. }
  490. expgained = skills.getCurrentSkillExp(STAT_RANGE) - startexp;
  491.  
  492. if ( HPstartexp == 0) {
  493. HPstartexp = skills.getCurrentSkillExp(STAT_HITPOINTS);
  494. }
  495. HPexpgained = skills.getCurrentSkillExp(STAT_HITPOINTS) - HPstartexp;
  496.  
  497. long millis = System.currentTimeMillis() - startTime;
  498. long hours = millis / (1000 * 60 * 60);
  499. millis -= hours * (1000 * 60 * 60);
  500. long minutes = millis / (1000 * 60);
  501. millis -= minutes * (1000 * 60);
  502. long seconds = millis / 1000;
  503.  
  504.  
  505.  
  506. long totalSeconds = ((System.currentTimeMillis() - startTime) / 1000);
  507.  
  508. int EXPGained = skills.getCurrentSkillExp(statIndex) - startexp;
  509. long EXPPerHour;
  510. if (totalSeconds == 0) {
  511. EXPPerHour = 0;
  512. } else {
  513. EXPPerHour = (EXPGained * 3600) / totalSeconds;
  514. }
  515.  
  516. long secondsToLvl;
  517.  
  518. if (EXPPerHour == 0) {
  519. secondsToLvl = 0;
  520. } else {
  521. secondsToLvl = (skills.getXPToNextLevel(statIndex) * 3600) / EXPPerHour;
  522. }
  523. ;
  524. long hoursToLvl = secondsToLvl / (60 * 60);
  525. secondsToLvl -= hoursToLvl * (60 * 60);
  526. long minutesToLvl = secondsToLvl / (60);
  527. secondsToLvl -= minutesToLvl * (60);
  528.  
  529.  
  530.  
  531. Mouse m = Bot.getClient().getMouse();
  532. Point p = new Point(m.x,m.y);
  533.  
  534. if (isWithinBounds(p,350,350,70,20)) {
  535. paintSelection = 0;
  536. }
  537. if (isWithinBounds(p,420,350,70,20)) {
  538. paintSelection = 1;
  539. }
  540.  
  541. g.setColor(background);
  542. g.fillRoundRect(350,350,140,20,5,5);
  543. g.fillRoundRect(350,375,140,85,5,5);
  544.  
  545. g.setFont(new Font("sans serif", Font.PLAIN, 12));
  546. g.setColor(white);
  547. g.drawString("EXP", 375, 365);
  548. g.drawString("INFO", 440, 365);
  549. g.fillRect(420,350,1,20);
  550.  
  551.  
  552. g.setFont(new Font("sans serif", Font.PLAIN, 12));
  553. int y = 375;
  554. if (paintSelection == 0) {
  555. g.setColor(blue);
  556. g.drawString("Combat EXP: " + expgained, 355, y += 14);
  557. g.drawString("Hitpoints EXP: " + HPexpgained, 355, y += 14);
  558. g.drawString("EXP Per Hour: " + EXPPerHour, 355, y += 14);
  559. g.drawString("Level in: " + hoursToLvl + ":" + minutesToLvl + ":" + secondsToLvl, 355, y += 14);
  560.  
  561. g.setColor(white);
  562. g.drawString("" + skills.getPercentToNextLevel(statIndex)+"%", 355, y += 20);
  563. g.setColor(green);
  564. g.fillRoundRect(385, y -= 10, skills.getPercentToNextLevel(statIndex), 10, 5, 10);
  565. }
  566.  
  567. if (paintSelection == 1) {
  568. g.setColor(white);
  569. g.drawString("Ogre Cage Ranger", 355, y += 14);
  570. g.setColor(blue);
  571. g.drawString("Seeds: " + seed, 355, y += 14);
  572. g.drawString("Time Running: " + hours + ":" + minutes + ":" + seconds , 355, y += 14);
  573. g.drawString("Status: " + status, 355, y += 14);
  574. g.setColor(white);
  575. g.drawString("Created by Nobody", 355, y += 20);
  576. }
  577. }
  578. }
  579.  
  580. public boolean isWithinBounds(Point p, int x, int y, int w, int h) {
  581. if (p.x > x && p.x < x+w && p.y > y && p.y < y+h) {
  582. return true;
  583. } else {
  584. return false;
  585. }
  586. }
  587.  
  588. //credits to DDM
  589. public void checkForLvlUpMessage() {
  590. if(RSInterface.getInterface(INTERFACE_LEVELUP).isValid()) {
  591. wait(random(800, 2000)); //reaction time
  592. atInterface(INTERFACE_LEVELUP, 3);
  593. wait(random(2000, 4000));
  594. }
  595. }
  596. }
Add Comment
Please, Sign In to add comment