Guest User

Untitled

a guest
Jul 18th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.53 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 = 2.0, 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. }
  193. }
  194. if (Ranarr != null) {
  195. openTab(Constants.TAB_MAGIC);
  196. if (getCurrentTab() == Constants.TAB_MAGIC) {
  197. castSpell(Constants.SPELL_TELEKINETIC_GRAB);
  198. rightClickTile(Ranarr, "Grab -> Ranarr");
  199. seed++;
  200. openTab(Constants.TAB_INVENTORY);
  201. wait(random(1400, 2200));
  202. }
  203. }
  204. if (Loopk != null) {
  205. openTab(Constants.TAB_MAGIC);
  206. if (getCurrentTab() == Constants.TAB_MAGIC) {
  207. castSpell(Constants.SPELL_TELEKINETIC_GRAB);
  208. rightClickTile(Loopk, "Grab -> Loop");
  209. seed++;
  210. openTab(Constants.TAB_INVENTORY);
  211. wait(random(1400, 2200));
  212. }
  213. }
  214. if (Toothk != null) {
  215. openTab(Constants.TAB_MAGIC);
  216. if (getCurrentTab() == Constants.TAB_MAGIC) {
  217. castSpell(Constants.SPELL_TELEKINETIC_GRAB);
  218. rightClickTile(Toothk, "Grab -> Tooth");
  219. seed++;
  220. openTab(Constants.TAB_INVENTORY);
  221. wait(random(1400, 2200));
  222. }
  223. }
  224. if (Strawb != null) {
  225. openTab(Constants.TAB_MAGIC);
  226. if (getCurrentTab() == Constants.TAB_MAGIC) {
  227. castSpell(Constants.SPELL_TELEKINETIC_GRAB);
  228. rightClickTile(Strawb, "Grab -> Strawberry");
  229. seed++;
  230. openTab(Constants.TAB_INVENTORY);
  231. wait(random(1400, 2200));
  232. }
  233. }
  234. if (Water != null) {
  235. openTab(Constants.TAB_MAGIC);
  236. if (getCurrentTab() == Constants.TAB_MAGIC) {
  237. castSpell(Constants.SPELL_TELEKINETIC_GRAB);
  238. rightClickTile(Water, "Grab -> Watermelon");
  239. seed++;
  240. openTab(Constants.TAB_INVENTORY);
  241. wait(random(1400, 2200));
  242. }
  243. }
  244. if (Snape != null) {
  245. openTab(Constants.TAB_MAGIC);
  246. if (getCurrentTab() == Constants.TAB_MAGIC) {
  247. castSpell(Constants.SPELL_TELEKINETIC_GRAB);
  248. rightClickTile(Snape, "Grab -> Snapdragon");
  249. seed++;
  250. openTab(Constants.TAB_INVENTORY);
  251. wait(random(1400, 2200));
  252. }
  253. }
  254. if (Kwuarm != null) {
  255. openTab(Constants.TAB_MAGIC);
  256. if (getCurrentTab() == Constants.TAB_MAGIC) {
  257. castSpell(Constants.SPELL_TELEKINETIC_GRAB);
  258. rightClickTile(Kwuarm, "Grab -> Kwuarm");
  259. seed++;
  260. openTab(Constants.TAB_INVENTORY);
  261. wait(random(1400, 2200));
  262. }
  263. }
  264. if (Limp != null) {
  265. openTab(Constants.TAB_MAGIC);
  266. if (getCurrentTab() == Constants.TAB_MAGIC) {
  267. castSpell(Constants.SPELL_TELEKINETIC_GRAB);
  268. rightClickTile(Limp, "Grab -> Limp");
  269. seed++;
  270. openTab(Constants.TAB_INVENTORY);
  271. wait(random(1400, 2200));
  272. }
  273. }
  274. }
  275. if (CheckSeed() && getMyPlayer().getInteracting() == null
  276. && getNearestFreeNPCByID(MONSTER) != null) {
  277. clickNPC(getNearestFreeNPCByID(MONSTER), "Attack");
  278. }/* else {
  279. if (npc.getInteracting() != null
  280. && !npc.isInteractingWithLocalPlayer()
  281. && getMyPlayer().getInteracting() == null)
  282. atNPC(getNearestNPCByID(MONSTER), "Attack");
  283. }*/
  284. return 800;
  285. }
  286.  
  287. public void serverMessageRecieved(ServerMessageEvent e) {
  288. String message = e.getMessage();
  289. if (message.contains("There is no ammo left in your quiver.")) {
  290. log("No Arrows!!");
  291. stopScript();
  292. }
  293. if (message.contains("That was your last one!")) {
  294. log("No knives!!");
  295. stopScript();
  296. }
  297. }
  298.  
  299. public boolean activateCondition() {
  300. if (getMyPlayer().isMoving()) {
  301. return random(1, walkSpeed) == 1;
  302. } else {
  303. return random(1, speed) == 1;
  304. }
  305. }
  306.  
  307. public boolean someNPC(RSNPC npc, String action) {
  308. try {
  309. int a;
  310. StringBuffer npcCommandBuf = new StringBuffer();
  311. npcCommandBuf.append(action);
  312. npcCommandBuf.append(" ");
  313. npcCommandBuf.append(npc.getName());
  314. String npcCommand = npcCommandBuf.toString();
  315. for (a = 10; a-- >= 0;) {
  316. if (npc.getInteracting() != null
  317. && !npc.isInteractingWithLocalPlayer()) {
  318. return false;
  319. }
  320. List<String> menuItems = getMenuItems();
  321. if (menuItems.size() > 1) {
  322. if (listContainsString(menuItems, npcCommand)) {
  323. if (menuItems.get(0).contains(npcCommand)) {
  324. clickMouse(true);
  325. return true;
  326. } else {
  327. clickMouse(false);
  328. wait(random(230, 520));
  329. return atMenu(npcCommand);
  330. }
  331. }
  332. }
  333. Point screenLoc = npc.getScreenLocation();
  334. if (!pointOnScreen(screenLoc)) {
  335. return false;
  336. }
  337. Point randomP = new Point(random(screenLoc.x - 15,
  338. screenLoc.x + 15), random(screenLoc.y - 15,
  339. screenLoc.y + 15));
  340. if (randomP.x >= 0 && randomP.y >= 0) {
  341. moveMouse(randomP);
  342. }
  343. }
  344. return false;
  345. } catch (Exception e) {
  346. System.out.print("clickNPC(RSNPC, String) error: " + e);
  347. return false;
  348. }
  349. }
  350.  
  351. public boolean listContainsString(List<String> list, String string) {
  352. try {
  353. int a;
  354. for (a = list.size() - 1; a-- >= 0;) {
  355. if (list.get(a).contains(string)) {
  356. return true;
  357. }
  358. }
  359. } catch (Exception e) {
  360. }
  361. return false;
  362. }
  363.  
  364. public void onRepaint(Graphics g) {
  365. runTime = System.currentTimeMillis( ) - startTime;
  366. seconds = runTime / 1000;
  367. if ( seconds >= 60 ) {
  368. minutes = seconds / 60;
  369. seconds -= (minutes * 60);
  370. }
  371. if ( minutes >= 60 ) {
  372. hours = minutes / 60;
  373. minutes -= (hours * 60);
  374. }
  375.  
  376. expGained = skills.getCurrentSkillExp(STAT_RANGE) - startXp;
  377. g.setColor( new Color(0, 0, 0, 50) );
  378. g.fillRoundRect(3, 180, 155, 130, 5, 5);
  379.  
  380. levelsGained = skills.getCurrentSkillLevel(STAT_RANGE) - startLevel;
  381.  
  382. g.setColor( Color.WHITE );
  383. g.drawString("Ogre Cage Ranger V 2.0", 12, 216);
  384. g.drawString("Run time: " + hours + ":" + minutes + ":" + seconds, 12, 232);
  385. g.drawString("Seeds Collected: " + seed + " seeds.", 12, 248);
  386. g.drawString("XP Gained: " + expGained, 12, 264);
  387. g.drawString("Levels Gained: " + levelsGained, 12, 280);
  388. g.drawString("Percent to next level: " + skills.getPercentToNextLevel(STAT_RANGE), 12, 296);
  389. }
  390.  
  391. public boolean isRanging() {
  392. final int id = getMyPlayer().getAnimation();
  393. return id == 426 || id == 4230 || id == 1074;
  394. }
  395.  
  396. private boolean clickNPC(final RSNPC npc, final String action) {
  397. final RSTile tile = npc.getLocation();
  398. tile.randomizeTile(1, 1);
  399. try {
  400. final int hoverRand = random(8, 13);
  401. for (int i = 0; i < hoverRand; i++) {
  402. final Point screenLoc = npc.getScreenLocation();
  403. if (!pointOnScreen(screenLoc)) {
  404. setCameraRotation(getCameraAngle() + random(-35, 150));
  405. return true;
  406. }
  407.  
  408. moveMouse(screenLoc, 15, 15);
  409.  
  410. final List<String> menuItems = getMenuItems();
  411. if (menuItems.isEmpty() || menuItems.size() <= 1) {
  412. continue;
  413. }
  414. if (menuItems.get(0).toLowerCase().contains(
  415. npc.getName().toLowerCase())
  416. && getMyPlayer().getInteracting() == null) {
  417. clickMouse(true);
  418. return true;
  419. } else {
  420. for (int a = 1; a < menuItems.size(); a++) {
  421. if (menuItems.get(a).toLowerCase().contains(
  422. npc.getName().toLowerCase())
  423. && getMyPlayer().getInteracting() == null) {
  424. clickMouse(false);
  425. return atMenu(action);
  426. }
  427. }
  428. }
  429. }
  430.  
  431. } catch (final Exception e) {
  432. log.warning("ATTACKNPC(RSNPC, String) error: " + e);
  433. return false;
  434. }
  435. return false;
  436. }
  437. }
Add Comment
Please, Sign In to add comment