Guest User

Untitled

a guest
Jul 15th, 2018
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 49.07 KB | None | 0 0
  1. import org.rsbot.script.ScriptManifest;
  2. import org.rsbot.script.Script;
  3. import org.rsbot.script.Calculations;
  4. import org.rsbot.script.Constants;
  5. import org.rsbot.script.wrappers.*;
  6. import org.rsbot.event.listeners.PaintListener;
  7. import org.rsbot.event.listeners.ServerMessageListener;
  8. import org.rsbot.event.events.ServerMessageEvent;
  9. import org.rsbot.bot.input.Mouse;
  10. import org.rsbot.bot.Bot;
  11.  
  12. import java.awt.*;
  13. import java.util.Map;
  14. import java.util.ArrayList;
  15.  
  16. @ScriptManifest(authors = {"ByteCode"}, category = "Combat", name = "AIOSoulwars", version = 1.0, description =
  17. "<html><head>" +
  18. "<style type=\"text/css\"> body {background-color: #333333; color: #FFFFFF; padding: 5px; font-family: Arial; text-align: center;}" +
  19. "h1 {font-weight: bold; color: #FFFFFF; font-size: 14px; padding: 0px; margin: 0px; margin-top: 4px; }" +
  20. "h2 {color: #FF0000; padding: 0px; margin: 0px; margin-top: 1px; margin-bottom: 5px; font-weight: normal; font-size: 10px;}" +
  21. "td {font-weight: bold; width: 50%;}</style>" +
  22. "</head><body>" +
  23. "<div style=\"width: 100%, height: 80px; background-color: #111111; text-align: center; padding: 5px;\">" +
  24. "<h1>AIOSoulwars</h1>" +
  25. "<h2>ByteCode</h2></div><br />" +
  26. "Start next to the green portal. " +
  27. "Make sure that you are already using the combat style that you want to train." +
  28. "<br /><br /><br /><table style=\"border: 0px; width: 200px; margin: auto;\"><tr>" +
  29. "<td>Combat Style:</td><td><select name=\"fightType\">" +
  30. "<option>Attack</option>" +
  31. "<option>Strength</option>" +
  32. "<option>Defense</option>" +
  33. "<option>Range</option>" +
  34. "<option>Mage</option>" +
  35. "</select><tr><td>Play Style:</td>" +
  36. "<td><select name=\"playStyle\">" +
  37. "<option>Attack</option>" +
  38. "<option>Bandage</option>" +
  39. "<option>Suidicide</option>" +
  40. "</select><tr><td>Join team:</td><td><select name=\"joinTeam\">" +
  41. "<option>Red</option>" +
  42. "<option>Blue</option>" +
  43. "<option>Last won</option>" +
  44. "<option>Last lost</option>" +
  45. "<option>Clan chat</option>" +
  46. "</select></table>" +
  47. "</body></html>")
  48. public class AIOSoulwars extends Script implements PaintListener, ServerMessageListener {
  49.  
  50. public enum actions {
  51. CHOOSING_TEAM, JOINING_BLUE, JOINING_RED, WAITING_FOR_GAME, LEAVING_SPAWN, WALKING_TO_BANDAGES, GETTING_BANDAGES, USING_BANDAGES, WALKING_TO_OBELISK, ATTACKING_PLAYERS, DEAD_RUN, LEAVING_GRAVEYARD, INFRONT_OF_GRAVEYARD, ELIMINATE_SCRIPT
  52. }
  53.  
  54. int selectedTab = 0;
  55.  
  56. //Timer
  57. long startTime = System.currentTimeMillis();
  58. long thisTime = System.currentTimeMillis();
  59. long randomTime = System.currentTimeMillis() + random(0, 50000);
  60.  
  61. //Team
  62. String onTeam = "None";
  63.  
  64. //Games
  65. int won = 0;
  66. int tie = 0;
  67. int lost = 0;
  68. int zeals = 0;
  69. int kickedGames = 0;
  70. int playedGames = 0;
  71.  
  72. //Player position
  73. int playerX;
  74. int playerY;
  75. RSTile myLoc = getMyPlayer().getLocation();
  76.  
  77. //Join team
  78. String whatToJoin = "Nothing";
  79. String lastWon = "Dunno";
  80.  
  81. //In-game options
  82. String howToPlayInGame = "";
  83. boolean inGame = false;
  84. int cantAttack = 0;
  85. int lookingForNewTarget = 0;
  86. int bandageTimer = 0;
  87. int antiBanTimer = 0;
  88. int cantWalkTimer = 0;
  89.  
  90. //Action in game
  91. String actionName = "";
  92.  
  93. //Interfaces
  94. RSInterfaceChild continueInterface = getChildInterface(211, 3);
  95. RSInterfaceChild goInside = getChildInterface(228, 2);
  96.  
  97. //Clanchat
  98. int callBlue = 0;
  99. int callRed = 0;
  100. boolean canSpeak = true;
  101. String resetChat = "";
  102. String[] chat = new String[200];
  103. String[] chat2 = new String[200];
  104. String[] oldQ = {""};
  105. long talkTimer = System.currentTimeMillis() + random(10000, 15000);
  106.  
  107.  
  108. // Exp
  109. String fightType;
  110. int trainingSkill = STAT_ATTACK;
  111. int startXP;
  112. int startHPXP = skills.getCurrentSkillExp(STAT_HITPOINTS);
  113.  
  114. // Calls
  115. int blueCalls = 0;
  116. int redCalls = 0;
  117.  
  118. //RSAreas
  119. /*RSArea atBlueLobby = new RSArea(1870,3159,9,6);
  120. RSArea atRedLobby = new RSArea(1900,3157,9,8);
  121. RSArea atBlueSpawn = new RSArea(1816,3220,7,10);
  122. RSArea atRedSpawn = new RSArea(1952,3234,6,9);
  123. RSArea atBlueBandages = new RSArea(1790,3250,21,7);
  124. RSArea atRedBandages = new RSArea(1962,3207,9,5);
  125. RSArea atBlueGrave = new RSArea(1841,3217,2,2);
  126. RSArea atRedGrave = new RSArea(1932,3244,2,2);
  127. RSArea isAtObelisk = new RSArea(1881,3228,10,7);*/
  128.  
  129. //Walkpaths
  130. RSTile[] chestToBlueWaitingRoom = {new RSTile(1890, 3165), new RSTile(1882, 3162)};
  131. RSTile[] chestToRedWaitingRoom = {new RSTile(1890, 3165), new RSTile(1899, 3162)};
  132. RSTile[] blueBaseToBandages = {new RSTile(1808, 3234), new RSTile(1807, 3244), new RSTile(1808, 3255)};
  133. RSTile[] redBaseToBandages = {new RSTile(1959, 3239), new RSTile(1968, 3230), new RSTile(1969, 3217), new RSTile(1965, 3208)};
  134. RSTile[] blueBaseToObelisk = {new RSTile(1806, 3234), new RSTile(1811, 3248), new RSTile(1823, 3244), new RSTile(1832, 3238), new RSTile(1845, 3233), new RSTile(1858, 3233), new RSTile(1867, 3233), new RSTile(1877, 3233), new RSTile(1885, 3231)};
  135. RSTile[] redBaseToObelisk = {new RSTile(1967, 3234), new RSTile(1967, 3223), new RSTile(1963, 3216), new RSTile(1952, 3216), new RSTile(1941, 3223), new RSTile(1934, 3231), new RSTile(1927, 3233), new RSTile(1920, 3232), new RSTile(1912, 3231), new RSTile(1901, 3231), new RSTile(1887, 3230)};
  136.  
  137. public void serverMessageRecieved(ServerMessageEvent e) {
  138. String message = e.getMessage();
  139. if (message.contains("You receive 1 Zeal")) {
  140. zeals += 1;
  141. lost += 1;
  142. playedGames += 1;
  143. inGame = false;
  144. if (onTeam.equals("Blue")) {
  145. lastWon = "Red";
  146. log("Red won: last won: " + lastWon);
  147. } else if (onTeam.equals("Red")) {
  148. lastWon = "Blue";
  149. log("Blue won: last won: " + lastWon);
  150. }
  151. actionName = "Choosing Team";
  152. }
  153. if (message.contains("You receive 2 Zeal")) {
  154. zeals += 2;
  155. playedGames += 1;
  156. inGame = false;
  157. tie += 1;
  158. lastWon = "Dunno";
  159. actionName = "Choosing Team";
  160. }
  161. if (message.contains("You receive 3 Zeal")) {
  162. zeals += 3;
  163. won += 1;
  164. playedGames += 1;
  165. inGame = false;
  166. if (onTeam.equals("Blue")) {
  167. lastWon = "Blue";
  168. log("Blue won: last won: " + lastWon);
  169. } else if (onTeam.equals("Red")) {
  170. lastWon = "Red";
  171. log("Red won: last won: " + lastWon);
  172. }
  173. actionName = "Choosing Team";
  174. }
  175. if (message.contains("You are not allowed to talk in this clan channel")) {
  176. log("We cannot talk in this clanchat");
  177. canSpeak = false;
  178. }
  179. if (message.contains(("You receive 0 Zeal"))) {
  180. inGame = false;
  181. playedGames += 1;
  182. if (onTeam.equals("Blue")) {
  183. lastWon = "Red";
  184. log("Red won: last won: " + lastWon);
  185. } else if (onTeam.equals("Red")) {
  186. lastWon = "Blue";
  187. log("Blue won | last won: " + lastWon);
  188. }
  189. }
  190. }
  191.  
  192. public void onRepaint(Graphics g) {
  193.  
  194. int gainedTrainingSkillXP = skills.getCurrentSkillExp(trainingSkill) - startXP;
  195. int gainedHPXP = skills.getCurrentSkillExp(STAT_HITPOINTS) - startHPXP;
  196.  
  197. long millis = System.currentTimeMillis() - startTime;
  198. long hours = millis / (1000 * 60 * 60);
  199. millis -= hours * 1000 * 60 * 60;
  200. long minutes = millis / (1000 * 60);
  201. millis -= minutes * 1000 * 60;
  202. long seconds = millis / 1000;
  203.  
  204. selectedTab = getMouseTab();
  205.  
  206. //Tab box
  207. g.setColor(new Color(0, 0, 0, 90));
  208. g.fillRect(550, 205, 184, 30);
  209. g.fill3DRect(550, 234, 185, 233, true);
  210. g.setColor(Color.BLACK);
  211. g.drawRect(550, 205, 184, 30);
  212. g.drawLine(610, 205, 610, 235);
  213. g.drawLine(680, 205, 680, 235);
  214.  
  215. g.setColor(Color.LIGHT_GRAY);
  216. g.drawString("Game", 564, 225);
  217. g.drawString("Gained", 624, 225);
  218. g.drawString("Info", 695, 225);
  219.  
  220. g.setColor(Color.WHITE);
  221. switch (selectedTab) {
  222. case 0:
  223. g.drawString("Game", 564, 225);
  224. g.drawString("Games completed: " + playedGames, 560, 255);
  225. g.drawString("Games kicked: " + kickedGames, 560, 270);
  226. g.drawString("Won " + won + " games", 560, 300);
  227. g.drawString("Tied " + tie + " games", 560, 315);
  228. g.drawString("Lost " + lost + " games", 560, 330);
  229. if (zeals > 0) {
  230. g.drawString("Zeals/Game:" + (playedGames / zeals), 560, 360);
  231. } else {
  232. g.drawString("Zeals/Game: 0", 560, 360);
  233. }
  234. break;
  235. case 1:
  236. g.drawString("Gained", 624, 225);
  237. g.drawString("Gained " + zeals + " zeals", 560, 255);
  238. g.drawString(fightType + " XP gained: " + gainedTrainingSkillXP, 560, 270);
  239. g.drawString("Hitpoints XP gained : " + gainedHPXP, 560, 285);
  240. break;
  241. case 2:
  242. g.drawString("Info", 695, 225);
  243. g.drawString("Run time: " + hours + ":" + minutes + ":" + seconds, 560, 255);
  244. g.drawString("State: " + actionName, 560, 270);
  245. g.drawString("Blue calls: " + callBlue, 560, 300);
  246. g.drawString("Red calls: " + callRed, 560, 315);
  247. g.drawString("Ultimate Soulwars", 560, 435);
  248. g.drawString("By Zenzie", 560, 450);
  249. break;
  250. }
  251. }
  252.  
  253. private int getMouseTab() {
  254. final Mouse mouse = Bot.getClient().getMouse();
  255. if (mouse.x > 550 && mouse.x < 610 && mouse.y > 205 && mouse.y < 230) {
  256. selectedTab = 0;
  257. }
  258. if (mouse.x > 610 && mouse.x < 680 && mouse.y > 205 && mouse.y < 230) {
  259. selectedTab = 1;
  260. }
  261. if (mouse.x > 680 && mouse.x < 735 && mouse.y > 205 && mouse.y < 230) {
  262. selectedTab = 2;
  263. }
  264. return selectedTab;
  265. }
  266.  
  267. @Override
  268. public boolean onStart(final Map<String, String> args) {
  269. howToPlayInGame = args.get("playStyle");
  270. whatToJoin = args.get("joinTeam");
  271. fightType = args.get("fightType");
  272. actionName = "Choosing team";
  273. intializeFightType();
  274. return true;
  275. }
  276.  
  277. public actions getAction() {
  278.  
  279. if (actionName.contains("Choosing") && onTeam.contains("one") && !inGame) {
  280. return actions.CHOOSING_TEAM;
  281. }
  282. if (actionName.contains("Joining") && !atRedLobby() && !atBlueLobby()
  283. && !inGame) {
  284. if (actionName.equals("Joining blue team")) {
  285. return actions.JOINING_BLUE;
  286. }
  287. if (actionName.equals("Joining red team")) {
  288. return actions.JOINING_RED;
  289. }
  290. }
  291. if (atRedLobby() || atBlueLobby()) {
  292. return actions.WAITING_FOR_GAME;
  293. }
  294. if (atBlueSpawn() || atRedSpawn()) {
  295. return actions.LEAVING_SPAWN;
  296. }
  297. if (!atBlueSpawn() && !atRedSpawn() && !atBlueBandages() && !atRedBandages() && inGame
  298. && howToPlayInGame.equals("Bandage")) {
  299. return actions.WALKING_TO_BANDAGES;
  300. }
  301. if (atBlueBandages() || atRedBandages() && inGame && howToPlayInGame.equals("Bandage")) {
  302. if (inventoryContains(14640)) {
  303. return actions.USING_BANDAGES;
  304. } else {
  305. return actions.GETTING_BANDAGES;
  306. }
  307. }
  308. if (!atBlueSpawn() && !atRedSpawn() && !atRedGrave() && !atBlueGrave() && inGame
  309. && howToPlayInGame.equals("Attack") && !isAtObelisk()) {
  310. return actions.WALKING_TO_OBELISK;
  311. }
  312. if (isAtObelisk() && howToPlayInGame.equals("Attack")) {
  313. return actions.ATTACKING_PLAYERS;
  314. }
  315. if (!atBlueSpawn() && !atRedSpawn() && !atRedGrave() && !atBlueGrave() && inGame
  316. && howToPlayInGame.equals("Suidicide")) {
  317. return actions.DEAD_RUN;
  318. }
  319. if (atRedGrave() || atBlueGrave()) {
  320. return actions.LEAVING_GRAVEYARD;
  321. }
  322. if (infrontOfRedGraveyard() || infrontOfBlueGraveyard()) {
  323. return actions.INFRONT_OF_GRAVEYARD;
  324. }
  325.  
  326. return actions.ELIMINATE_SCRIPT;
  327. }
  328.  
  329. public int loop() {
  330.  
  331. actions act = getAction();
  332.  
  333. if (!isRunning() && getEnergy() >= random(45, 60)) {
  334. setRun(true);
  335. }
  336.  
  337. if (RSInterface.getChildInterface(243, 4).isValid() &&
  338. RSInterface.getChildInterface(243, 4).containsText("You were removed from the game due")) {
  339. inGame = false;
  340. kickedGames += 1;
  341. actionName = "Choosing Team";
  342. }
  343.  
  344. clickContinue();
  345.  
  346. if (inGame) {
  347. String time = RSInterface.getInterface(836).getChild(27).getText();
  348. if (time.equals("2 mins") || time.equals(" 1 min") || time.equals("3 mins")) {
  349. if (whatToJoin.equals("Clan chat")) {
  350. countCall();
  351. }
  352. }
  353. if (!getMyPlayer().isMoving()) {
  354. cantWalkTimer++;
  355. if (cantWalkTimer >= 10) {
  356. if (getNearestNPCByID(8600) != null && distanceTo(getNearestNPCByID(8600).getLocation()) <= 1) {
  357. attackNPC(getNearestNPCByID(8600));
  358. cantWalkTimer = 0;
  359. }
  360. }
  361. }
  362. if (thisTime > randomTime) {
  363. antiBan(1, 6);
  364. randomTime = System.currentTimeMillis() + random(0, 50000);
  365. }
  366. }
  367.  
  368. switch (act) {
  369.  
  370. case CHOOSING_TEAM:
  371. if (whatToJoin.equals("Red")) {
  372. actionName = "Joining red team";
  373. } else if (whatToJoin.equals("Blue")) {
  374. actionName = "Joining blue team";
  375. } else if (whatToJoin.equals("Last won")) {
  376. if (lastWon.equals("Blue")) {
  377. actionName = "Joining blue team";
  378. } else if (lastWon.equals("Red")) {
  379. actionName = "Joining red team";
  380. } else if (lastWon.equals("Dunno")) {
  381. actionName = "Joining blue team";
  382. }
  383. } else if (whatToJoin.equals("Last lost")) {
  384. if (lastWon.equals("Blue")) {
  385. actionName = "Joining red team";
  386. } else if (lastWon.equals("Red")) {
  387. actionName = "Joining blue team";
  388. } else if (lastWon.equals("Dunno")) {
  389. actionName = "Joining blue team";
  390. }
  391. } else if (whatToJoin.equals("Clan chat")) {
  392. countCall();
  393. }
  394. break;
  395.  
  396. case JOINING_BLUE:
  397. onTeam = "Blue";
  398. continueWalk(chestToBlueWaitingRoom);
  399. RSTile blueBarrier = new RSTile(1879, 3162);
  400. setCameraAltitude(false);
  401. if (blueBarrier != null) {
  402. if (distanceTo(blueBarrier) <= 2) {
  403. if (getCameraAngle() >= 260 && getCameraAngle() <= 280) {
  404. if (!getMyPlayer().isMoving())
  405. setCameraAltitude(random(0, 40));
  406. if (onTile(blueBarrier, "Blue barrier"))
  407. wait(random(200, 500));
  408. if (waitTime() > 0) {
  409. wait(random(20000, 40000));
  410. int doAnti = random(1, 3);
  411. if (doAnti == 1) {
  412. antiBan(0, 6);
  413. }
  414. }
  415. while (atInterface(RSInterface.getInterface(211).getChild(3)) || atInterface(RSInterface.getInterface(228).getChild(2))) {
  416. if (atInterface(RSInterface.getInterface(211).getChild(3))) {
  417. wait(random(800, 1000));
  418. clickMouse(190 + random(0, 140), 445 + random(0, 15), true);
  419. }
  420. if (atInterface(RSInterface.getInterface(228).getChild(2))) {
  421. clickMouse(220 + random(0, 80), 395 + random(0, 15), true);
  422. wait(random(800, 1000));
  423. }
  424. wait(random(800, 1000));
  425. }
  426. } else {
  427. setCameraRotation(random(260, 280));
  428. }
  429. } else {
  430. walkTile(randomizeTile(new RSTile(1880, 3162), 2, 2));
  431. }
  432. }
  433. break;
  434.  
  435. case JOINING_RED:
  436. onTeam = "Red";
  437. continueWalk(chestToRedWaitingRoom);
  438. RSTile redBarrier = new RSTile(1899, 3162);
  439. setCameraAltitude(false);
  440. if (redBarrier != null) {
  441. if (distanceTo(redBarrier) <= 2) {
  442. if (getCameraAngle() >= 260 && getCameraAngle() <= 280) {
  443. if (!getMyPlayer().isMoving())
  444. setCameraAltitude(random(0, 40));
  445. if (onTile(redBarrier, "Red barrier")) {
  446. wait(random(200, 500));
  447. if (waitTime() > 0) {
  448. wait(random(20000, 40000));
  449. int doAnti = random(1, 3);
  450. if (doAnti == 1) {
  451. antiBan(0, 6);
  452. }
  453. }
  454. }
  455. if (atInterface(RSInterface.getInterface(211).getChild(3))) {
  456. clickMouse(190 + random(0, 140), 445 + random(0, 15), true);
  457. wait(random(1500, 1800));
  458. }
  459. wait(random(800, 1000));
  460. if (atInterface(RSInterface.getInterface(228).getChild(2))) {
  461. clickMouse(220 + random(0, 80), 395 + random(0, 15), true);
  462. wait(random(1200, 1500));
  463. }
  464. wait(random(1500, 1800));
  465. } else {
  466. setCameraRotation(random(260, 280));
  467. }
  468. } else {
  469. walkTile(randomizeTile(new RSTile(1899, 3162), 2, 2));
  470. }
  471. }
  472. break;
  473.  
  474. case WAITING_FOR_GAME:
  475. actionName = "Waiting for game";
  476. if (actionName.equals("Waiting for game")) {
  477. int shouldWalk = random(1, 30);
  478. if (shouldWalk == 2) {
  479. if (onTeam.equals("Blue")) {
  480. int blueX = random(1870, 1879);
  481. int blueY = random(3159, 3165);
  482. walkTile(new RSTile(blueX, blueY));
  483. }
  484. if (onTeam.equals("Red")) {
  485. int redX = random(1900, 1909);
  486. int redY = random(3157, 3165);
  487. walkTile(new RSTile(redX, redY));
  488. }
  489. }
  490. wait(random(1666, 5000));
  491. antiBanTimer += 1;
  492. if (antiBanTimer >= 4) {
  493. antiBan(0, 6);
  494. antiBanTimer = 0;
  495. }
  496. }
  497. break;
  498.  
  499. case LEAVING_SPAWN:
  500. actionName = "Leaving spawn";
  501. setCameraAltitude(false);
  502. if (!inGame) {
  503. inGame = true;
  504. }
  505. if (onTeam.equals("Blue")) {
  506. RSTile blueStartBarrier = new RSTile(1815, 3225);
  507. if (blueStartBarrier != null) {
  508. if (distanceTo(new RSTile(1816, 3225)) < 2) {
  509. if (getCameraAngle() >= 65 && getCameraAngle() <= 95) {
  510. if (!getMyPlayer().isMoving()) {
  511. if (onTile(blueStartBarrier, "Blue barrier")) {
  512. wait(random(500, 750));
  513. }
  514. }
  515. } else {
  516. setCameraRotation(random(65, 95));
  517. }
  518. } else {
  519. walkTile(randomizeTile(new RSTile(1816, 3225), 2, 2));
  520. }
  521. }
  522. } else if (onTeam.equals("Red")) {
  523. RSTile redStartBarrier = new RSTile(1959, 3239);
  524. if (redStartBarrier != null) {
  525. if (distanceTo(new RSTile(1959, 3239)) < 2) {
  526. if (getCameraAngle() >= 260 && getCameraAngle() <= 280) {
  527. if (!getMyPlayer().isMoving()) {
  528. if (onTile(redStartBarrier, "Red barrier")) {
  529. wait(random(500, 750));
  530. }
  531. }
  532. } else {
  533. setCameraRotation(random(260, 280));
  534. }
  535. } else {
  536. walkTile(randomizeTile(new RSTile(1959, 3239), 2, 2));
  537. }
  538. }
  539. } else if (atRedLobby()) {
  540. onTeam = "Red";
  541. } else if (atBlueLobby()) {
  542. onTeam = "Blue";
  543. }
  544. break;
  545.  
  546. case WALKING_TO_BANDAGES:
  547. actionName = "Walking to bandages";
  548. if (onTeam.equals("Blue")) {
  549. continueWalk(blueBaseToBandages);
  550. }
  551. if (onTeam.equals("Red")) {
  552. continueWalk(redBaseToBandages);
  553. }
  554. break;
  555.  
  556. case GETTING_BANDAGES:
  557. actionName = "Getting bandages";
  558. if (onTeam.equals("Blue")) {
  559. setCameraRotation(random(320, 390));
  560. RSTile bandageTableBlue = new RSTile(1810, 3254);
  561. if (bandageTableBlue != null) {
  562. if (distanceTo(bandageTableBlue) < 3 && !getMyPlayer().isMoving()) {
  563. wait(random(1000, 1500));
  564. onTile(bandageTableBlue, "Take-x");
  565. wait(random(1500, 3000));
  566. if (RSInterface.getInterface(752).getChild(4).isValid() && RSInterface.getInterface(752).getChild(4).containsText("How many bandages would")
  567. && !getMyPlayer().isInCombat()) {
  568. sendText(Integer.toString(random(28, 100)), true);
  569. wait(random(600, 950));
  570. }
  571. } else if (!getMyPlayer().isMoving()) {
  572. walkTile(randomizeTile(new RSTile(1810, 3254), 2, 2));
  573. wait(random(3000, 5000));
  574. }
  575. }
  576. } else {
  577. setCameraRotation(random(130, 200));
  578. RSTile bandageTableRed = new RSTile(1963, 3207);
  579. if (bandageTableRed != null) {
  580. if (distanceTo(bandageTableRed) < 3 && !getMyPlayer().isMoving()) {
  581. wait(random(1000, 1500));
  582. onTile(bandageTableRed, "Take-x");
  583. wait(random(1500, 3000));
  584. if (RSInterface.getInterface(752).getChild(4).isValid() && RSInterface.getInterface(752).getChild(4).containsText("How many bandages would")
  585. && !getMyPlayer().isInCombat()) {
  586. sendText(Integer.toString(random(28, 100)), true);
  587. wait(random(600, 950));
  588. }
  589. } else if (!getMyPlayer().isMoving()) {
  590. walkTile(randomizeTile(new RSTile(1963, 3207), 2, 2));
  591. wait(random(3000, 5000));
  592. }
  593. }
  594. }
  595. break;
  596.  
  597. case USING_BANDAGES:
  598. useBandagesOnOtherPlayer();
  599. break;
  600.  
  601. case WALKING_TO_OBELISK:
  602. actionName = "Walking to obelisk";
  603. log("Camera angle: " + getCameraAngle());
  604. if (onTeam.equals("Blue")) {
  605. if(getCameraAngle() >= 310 && getCameraAngle() <= 228) {
  606. setCameraRotation(random(229,309));
  607. }
  608. if(Bot.getClient().getCamPosZ() < 80) {
  609. setCameraAltitude(random(80.00,100.00));
  610. }
  611. continueWalk(blueBaseToObelisk);
  612. }
  613. if (onTeam.equals("Red")) {
  614. if(getCameraAngle() >= 139 && getCameraAngle() <= 49) {
  615. setCameraRotation(random(49,139));
  616. }
  617. if(Bot.getClient().getCamPosZ() < 80) {
  618. setCameraAltitude(random(80.00,100.00));
  619. }
  620. continueWalk(redBaseToObelisk);
  621. }
  622. break;
  623.  
  624. case ATTACKING_PLAYERS:
  625. if(!getMyPlayer().isMoving() && !getMyPlayer().isInCombat()) {
  626. actionName = "Finding target";
  627. getAttackAblePlayer();
  628. }
  629. break;
  630.  
  631. case LEAVING_GRAVEYARD:
  632. actionName = "Leaving graveyard";
  633. wait(random(15000,17000));
  634. setCameraAltitude(false);
  635. if (actionName.equals("Leaving graveyard")) {
  636. if (atBlueGrave()) {
  637. setCameraRotation(random(140, 210));
  638. RSTile blueGraveyardBarrier = new RSTile(1842, 3219);
  639. if (blueGraveyardBarrier != null) {
  640. if (onTile(blueGraveyardBarrier, "barrier")) {
  641. }
  642. }
  643. }
  644. }
  645. if (atRedGrave()) {
  646. setCameraRotation(random(310, 390));
  647. RSTile redGraveyardBarrier = new RSTile(1933, 3244);
  648. if (redGraveyardBarrier != null) {
  649. onTile(redGraveyardBarrier, "barrier");
  650. }
  651. }
  652. break;
  653.  
  654. case INFRONT_OF_GRAVEYARD:
  655. if (infrontOfBlueGraveyard()) { //Just out of graveyard **FOR BLUE TEAM**
  656. if (howToPlayInGame.equals("Attack") && onTeam.equals("Blue")) {
  657. actionName = "Walking to obelisk";
  658. }
  659. if (howToPlayInGame.equals("Attack") && onTeam.equals("Red")) {
  660. actionName = "Suidicide";
  661. }
  662. }
  663. if (infrontOfRedGraveyard()) { //Just out of graveyard **FOR RED TEAM**
  664. if (howToPlayInGame.equals("Attack") && onTeam.equals("Blue")) {
  665. actionName = "Suidicide";
  666. }
  667. if (howToPlayInGame.equals("Attack") && onTeam.equals("Red")) {
  668. actionName = "Walking to obelisk";
  669. }
  670. }
  671. break;
  672. case DEAD_RUN:
  673. if (!getMyPlayer().isMoving() || distanceTo(getDestination()) <= random(5, 8)
  674. && !getMyPlayer().isInCombat()) {
  675. if (onTeam.equals("Blue")) {
  676. setCameraAltitude(true);
  677. continueWalk(blueBaseToObelisk);
  678. } else {
  679. setCameraAltitude(true);
  680. continueWalk(redBaseToObelisk);
  681. }
  682. }
  683. break;
  684.  
  685. case ELIMINATE_SCRIPT:
  686. break;
  687. }
  688. return random(500, 900);
  689. }
  690.  
  691. public void continueWalk(final RSTile[] path) {
  692. if (!getMyPlayer().isMoving() || distanceTo(getDestination()) < random(4, 6)) {
  693. walkPathMM(randomizePath(path, 2, 2), 16);
  694. }
  695. }
  696.  
  697. public boolean onTile(RSTile tile, String action) {
  698. try {
  699. Point location = Calculations.tileToScreen(tile);
  700. if (location.x == -1 || location.y == -1)
  701. return false;
  702. moveMouse(location, 3, 3);
  703. if (actionName.contains("Joining") || atBlueSpawn() || atRedSpawn()) {
  704. moveMouse(Bot.getInputManager().getX(), Bot.getInputManager().getY() + random(-25, -30));
  705. }
  706. wait(random(500, 1000));
  707. if (getMenuItems().get(0).toLowerCase().contains(
  708. action.toLowerCase())) {
  709. clickMouse(true);
  710. wait(random(1000, 2000));
  711. } else {
  712. clickMouse(false);
  713. if (!atMenu(action))
  714. return false;
  715. }
  716. wait(random(500, 1000));
  717. while (true) {
  718. if (!getMyPlayer().isMoving())
  719. break;
  720. wait(random(500, 1000));
  721. }
  722. return true;
  723. } catch (Exception e) {
  724. return false;
  725. }
  726. }
  727.  
  728. private int antiBan(int minC, int maxC) {
  729.  
  730. final int randomAction = random(minC, maxC);
  731. switch (randomAction) {
  732. case 0:
  733. if (getCurrentTab() != Constants.TAB_INVENTORY) {
  734. openTab(Constants.TAB_INVENTORY);
  735. wait(random(310, 610));
  736. final Point invPoint = new Point(random(558, 723), random(215,
  737. 440));
  738. moveMouse(invPoint);
  739. return random(510, 2300);
  740. } else {
  741. final int random = random(0, 10);
  742. final Point rndPoint = new Point(random(558, 723), random(215,
  743. 440));
  744. if (random == 0) {
  745. if (getCurrentTab() != Constants.TAB_STATS) {
  746. openTab(Constants.TAB_STATS);
  747. wait(random(310, 610));
  748. }
  749. moveMouse(rndPoint);
  750. return random(200, 2300);
  751. } else if (random >= 1 && random <= 6) {
  752. final int randomTab = random(0, 13);
  753. if (randomTab != getCurrentTab()) {
  754. openTab(random(0, 13));
  755. wait(random(310, 610));
  756. }
  757. moveMouse(rndPoint);
  758. return random(300, 1600);
  759. } else {
  760. final int randomTab = random(0, 13);
  761. if (randomTab != getCurrentTab()) {
  762. openTab(random(0, 13));
  763. return random(310, 2000);
  764. }
  765. }
  766. }
  767. case 1:
  768. Point randomMouse;
  769. final int rndMovement = random(1, 5);
  770. for (int a = 0; a < rndMovement; a++) {
  771. randomMouse = new Point(random(15, 730), random(15, 465));
  772. moveMouse(randomMouse);
  773. wait(random(50, 800));
  774. }
  775. return random(130, 810);
  776. case 2:
  777. final int currentAngle = getCameraAngle();
  778. switch (random(0, 1)) {
  779. case 0:
  780. setCameraRotation(currentAngle + random(0, 650));
  781. return random(710, 1700);
  782. case 1:
  783. setCameraRotation(currentAngle - random(0, 650));
  784. return random(710, 1700);
  785. }
  786. case 3:
  787. final int currentAlt = Bot.getClient().getCamPosZ();
  788. final int random = random(0, 10);
  789. if (random <= 7) {
  790. setCameraAltitude(currentAlt - random(0, 100));
  791. return random(410, 2130);
  792. } else {
  793. setCameraAltitude(currentAlt + random(0, 100));
  794. return random(410, 2130);
  795. }
  796. case 4:
  797. final int currentAngle2 = getCameraAngle();
  798. Bot.getClient().getCamPosZ();
  799. switch (random(0, 1)) {
  800. case 0:
  801. setCameraRotation(currentAngle2 + random(0, 650));
  802. setCameraAltitude(random(80, 100));
  803. return random(410, 2130);
  804. case 1:
  805. setCameraRotation(currentAngle2 - random(0, 650));
  806. setCameraAltitude(random(40, 80));
  807. return random(410, 2130);
  808. }
  809. case 5:
  810. return random(310, 2400);
  811.  
  812. case 6:
  813. final int currentAlt2 = Bot.getClient().getCamPosZ();
  814. final int random2 = random(0, 2);
  815. if (random2 <= 2) {
  816. setCameraAltitude(currentAlt2 - random(-100, +100));
  817. return random(410, 2130);
  818. } else {
  819. setCameraAltitude(currentAlt2 + random(-100, +100));
  820. return random(410, 2130);
  821. }
  822. }
  823. return random(100, 200);
  824. }
  825.  
  826. public boolean clickInventoryItem(int itemID, String option) {
  827. if (getCurrentTab() != TAB_INVENTORY) {
  828. openTab(TAB_INVENTORY);
  829. }
  830. int[] items = getInventoryArray();
  831. java.util.List<Integer> possible = new ArrayList<Integer>();
  832. for (int i = 0; i < items.length; i++) {
  833. if (items[i] == itemID) {
  834. possible.add(i);
  835. }
  836. }
  837. if (possible.size() == 0) {
  838. return false;
  839. }
  840. int idx = possible.get(random(0, possible.size()));
  841. Point t = getInventoryItemPoint(idx);
  842. moveMouse(t, 5, 5);
  843. long waitTime = System.currentTimeMillis() + random(50, 250);
  844. boolean found = false;
  845. while (!found && System.currentTimeMillis() < waitTime) {
  846. wait(15);
  847. if (itemID != 14640) {
  848. if ((getMenuItems()).get(0).toLowerCase().contains(
  849. option.toLowerCase())) {
  850. found = true;
  851. }
  852. } else {
  853. if ((getMenuItems()).get(0).toLowerCase().equals(
  854. option.toLowerCase())) {
  855. found = true;
  856. }
  857. }
  858. }
  859. if (found) {
  860. clickMouse(true);
  861. wait(random(150, 250));
  862. return true;
  863. }
  864. clickMouse(false);
  865. wait(random(150, 250));
  866. return atMenu(option);
  867. }
  868.  
  869. public int waitTime() {
  870. if (RSInterface.getChildInterface(211, 1).isValid() &&
  871. RSInterface.getChildInterface(211, 1).containsText("You left a game of Soul Wars early")) {
  872. String getLine = RSInterface.getChildInterface(211, 1).getText();
  873. String subLine = getLine.substring(getLine.indexOf("wait ") + 5,
  874. getLine.indexOf(" minutes"));
  875. return Integer.parseInt(subLine);
  876. }
  877. return 0;
  878. }
  879.  
  880. /**
  881. * Makes sure we aren't mass clicking the tile
  882. * when we use walkTileMM
  883. *
  884. * @param walkTo tile to walk
  885. */
  886. public void walkTile(RSTile walkTo) {
  887. RSTile dest = getDestination();
  888. if (walkTo != dest && !getMyPlayer().isMoving()) {
  889. if (tileOnScreen(walkTo)) {
  890. final Point tile = tileToMinimap(walkTo);
  891. clickMouse(tile, true);
  892. } else {
  893. walkTileMM(walkTo);
  894. }
  895. }
  896. }
  897.  
  898. public boolean useBandagesOnOtherPlayer() {
  899. RSPlayer player = null;
  900. int[] validPlayers = Bot.getClient().getRSPlayerIndexArray();
  901. ArrayList<String> cantBandage = new ArrayList<String>();
  902. org.rsbot.accessors.RSPlayer[] players = Bot.getClient().getRSPlayerArray();
  903.  
  904. for (int element : validPlayers) {
  905. wait(random(1660, 5000));
  906. bandageTimer += 1;
  907. if (players[element] == null) {
  908. continue;
  909. }
  910.  
  911. player = new RSPlayer(players[element]);
  912. try {
  913. RSTile targetLoc = player.getLocation();
  914. String name = player.getName();
  915. Point checkPlayer = Calculations.tileToScreen(targetLoc);
  916. if (distanceTo(targetLoc) > 10) {
  917. continue;
  918. }
  919. if (!pointOnScreen(checkPlayer)) {
  920. cantBandage.add(name);
  921. continue;
  922. }
  923. if (!inGame || actionName.equals("Choosing team")) {
  924. break;
  925. }
  926. if (!inventoryContains(14640) || atBlueSpawn()
  927. || atRedSpawn()) {
  928. break;
  929. }
  930. if (onTeam.equals("Blue")) {
  931. RSObject bandageTableBlue = findObject(42023);
  932. if (bandageTableBlue != null) {
  933. if (distanceTo(bandageTableBlue.getLocation()) >= 8) {
  934. walkTile((bandageTableBlue.getLocation()));
  935. }
  936. }
  937. } else {
  938. RSObject bandageTableRed = findObject(42024);
  939. if (bandageTableRed != null) {
  940. if (distanceTo(bandageTableRed.getLocation()) >= 8) {
  941. walkTile(bandageTableRed.getLocation());
  942. }
  943. }
  944. }
  945. if (inventoryContains(14640) && bandageTimer >= 3 && !cantBandage.contains(name)) {
  946. bandageTimer = 0;
  947. clickInventoryItem(14640, "use");
  948. wait(random(700, 900));
  949. actionName = "Bandaging " + name;
  950. moveMouse(checkPlayer, 2, 2);
  951. wait(random(500, 750));
  952. clickMouse(false);
  953. atMenu("use bandages -> " + name);
  954. }
  955. return true;
  956. } catch (Exception ignored) {
  957. }
  958. }
  959. return player != null;
  960. }
  961.  
  962. public boolean getAttackAblePlayer() {
  963. RSPlayer player;
  964. ArrayList<String> canAttack = new ArrayList<String>();
  965. int[] validPlayers = Bot.getClient().getRSPlayerIndexArray();
  966. org.rsbot.accessors.RSPlayer[] players = Bot.getClient().getRSPlayerArray();
  967.  
  968. for (int element : validPlayers) {
  969. player = new RSPlayer(players[element]);
  970. if (players[element] == null) {
  971. continue;
  972. }
  973. String name = player.getName();
  974. RSTile targetLocation = player.getLocation();
  975. Point targetLoc = Calculations.tileToScreen(targetLocation);
  976. if (!pointOnScreen(targetLoc)) {
  977. continue;
  978. }
  979. if (!actionName.contains("Attack")) {
  980. moveMouse(targetLoc, 2, 2);
  981. wait(random(100, 300));
  982. if (getMenuIndex("Attack") == 0) {
  983. canAttack.add(name);
  984. wait(random(100, 300));
  985. if (lookingForNewTarget > 3 && canAttack.contains(name)) {
  986. clickMouse(true);
  987. actionName = "Attacking " + name;
  988. }
  989. }
  990. }
  991. if (cantAttack > 20) {
  992. cantAttack = 0;
  993. actionName = "Suidicide";
  994. }
  995. if (!getMyPlayer().isInCombat() && getMyPlayer().getAnimation() == -1) {
  996. actionName = "Not in combat";
  997. lookingForNewTarget += 1;
  998. wait(random(200, 400));
  999. } else {
  1000. lookingForNewTarget = 0;
  1001. actionName = "Under Attack";
  1002. wait(random(400, 800));
  1003. }
  1004. if (atRedGrave() || atBlueGrave()) {
  1005. actionName = "Leaving graveyard";
  1006. break;
  1007. }
  1008. if (!isAtObelisk() || !inGame || getMyPlayer().isMoving()) {
  1009. break;
  1010. }
  1011. }
  1012. return true;
  1013. }
  1014.  
  1015. private boolean attackNPC(final RSNPC npc) {
  1016. final RSTile tile = npc.getLocation();
  1017. tile.randomizeTile(1, 1);
  1018. try {
  1019. final int hoverRand = random(8, 13);
  1020. for (int i = 0; i < hoverRand; i++) {
  1021. if (distanceTo(tile) <= 1) {
  1022. return false;
  1023. }
  1024. final Point screenLoc = npc.getScreenLocation();
  1025. if (!pointOnScreen(screenLoc)) {
  1026. setCameraRotation(getCameraAngle() + random(-35, 150));
  1027. return true;
  1028. }
  1029.  
  1030. moveMouse(screenLoc, 15, 15);
  1031.  
  1032. final java.util.List<String> menuItems = getMenuItems();
  1033. if (menuItems.isEmpty() || menuItems.size() <= 1) {
  1034. continue;
  1035. }
  1036. if (menuItems.get(0).toLowerCase().contains(
  1037. npc.getName().toLowerCase())
  1038. && getMyPlayer().getInteracting() == null) {
  1039. clickMouse(true);
  1040. return true;
  1041. } else {
  1042. for (int a = 1; a < menuItems.size(); a++) {
  1043. if (menuItems.get(a).toLowerCase().contains(
  1044. npc.getName().toLowerCase())
  1045. && getMyPlayer().getInteracting() == null) {
  1046. clickMouse(false);
  1047. return atMenu("Attack");
  1048. }
  1049. }
  1050. }
  1051. }
  1052. } catch (final Exception e) {
  1053. log.warning("attackNPC(RSNPC) error: " + e);
  1054. return false;
  1055. }
  1056. return false;
  1057. }
  1058.  
  1059.  
  1060. public String getClanChatMessage(int iface, int child) {
  1061. return RSInterface.getInterface(iface).getChild(child).getText();
  1062. }
  1063.  
  1064. public void countCall() {
  1065. chat = readCall(true);
  1066. chat2 = readCall(false);
  1067. if (chat[0] == null || resetChat.equalsIgnoreCase(chat2[0])) {
  1068. return;
  1069. }
  1070. if (oldQ[0].equalsIgnoreCase(chat2[0])) {
  1071. return;
  1072. }
  1073. if (parseInComingData(chat[0])) {
  1074. oldQ[0] = chat2[0];
  1075. }
  1076. }
  1077.  
  1078. public String[] readCall(boolean stripMessages) {
  1079. String[] messageArchive = new String[100];
  1080. int slotIndex = 0;
  1081. String clanChatName = RSInterface.getChildInterface(589, 0).getText();
  1082.  
  1083. if (!clanChatName.contains("Not in chat")) {
  1084. for (int i = 155; i >= 56; i--)
  1085. if (getClanChatMessage(137, i).contains("<col=0000ff>") && getClanChatMessage(137, i).contains(clanChatName)) {
  1086. if (stripMessages) {
  1087. log(clanChatName);
  1088. messageArchive[slotIndex] = getClanChatMessage(137, i).substring(getClanChatMessage(137, i).indexOf("<col=0000ff>") + 12);
  1089. slotIndex++;
  1090. } else {
  1091. messageArchive[slotIndex] = getClanChatMessage(137, i).substring(getClanChatMessage(137, i).indexOf("<col=0000ff>") + 12);
  1092. slotIndex++;
  1093. }
  1094. }
  1095. int antiban = random(0, 55);
  1096. if (antiban == 30 && !inGame) {
  1097. antiBan(1, 6);
  1098. }
  1099. } else {
  1100. log("Not in clan chat !");
  1101. stopAllScripts();
  1102. }
  1103. return messageArchive;
  1104. }
  1105.  
  1106. public boolean parseInComingData(String text) {
  1107. String lower = text.toLowerCase();
  1108. if (lower.contains("blue") || lower.contains("b l u e")) {
  1109. callBlue += 1;
  1110. return true;
  1111. } else if (lower.contains("red") || lower.contains("r e d")) {
  1112. callRed += 1;
  1113. return true;
  1114. }
  1115. return false;
  1116. }
  1117.  
  1118. public void intializeFightType() {
  1119. if (fightType.equals("Range")) {
  1120. trainingSkill = Constants.STAT_RANGE;
  1121. } else if (fightType.equals("Mage")) {
  1122. trainingSkill = Constants.STAT_MAGIC;
  1123. } else if (fightType.equals("Strength")) {
  1124. trainingSkill = Constants.STAT_STRENGTH;
  1125. } else if (fightType.equals("Attack")) {
  1126. trainingSkill = Constants.STAT_ATTACK;
  1127. } else if (fightType.equals("Defense")) {
  1128. trainingSkill = Constants.STAT_DEFENSE;
  1129. }
  1130. startXP = skills.getCurrentSkillExp(trainingSkill);
  1131. }
  1132.  
  1133. public boolean infrontOfRedGraveyard() {
  1134. int x = getMyPlayer().getLocation().getX();
  1135. int y = getMyPlayer().getLocation().getY();
  1136. return x == 1933 && y == 3243;
  1137. }
  1138.  
  1139. public boolean infrontOfBlueGraveyard() {
  1140. int x = getMyPlayer().getLocation().getX();
  1141. int y = getMyPlayer().getLocation().getY();
  1142. return x == 1842 && y == 3220;
  1143. }
  1144.  
  1145. public boolean atBlueLobby() {
  1146. int x = getMyPlayer().getLocation().getX();
  1147. int y = getMyPlayer().getLocation().getY();
  1148. return x >= 1870 && x <= 1879 && y >= 3159 && y <= 3165;
  1149. }
  1150.  
  1151. public boolean atRedLobby() {
  1152. int x = getMyPlayer().getLocation().getX();
  1153. int y = getMyPlayer().getLocation().getY();
  1154. return x >= 1900 && x <= 1909 && y >= 3157 && y <= 3165;
  1155. }
  1156.  
  1157. public boolean atBlueSpawn() {
  1158. int x = getMyPlayer().getLocation().getX();
  1159. int y = getMyPlayer().getLocation().getY();
  1160. return x >= 1816 && x <= 1823 && y >= 3220 && y <= 3230;
  1161. }
  1162.  
  1163. public boolean atRedSpawn() {
  1164. int x = getMyPlayer().getLocation().getX();
  1165. int y = getMyPlayer().getLocation().getY();
  1166. return x >= 1952 && x <= 1958 && y >= 3234 && y <= 3243;
  1167. }
  1168.  
  1169. public boolean atBlueBandages() {
  1170. int x = getMyPlayer().getLocation().getX();
  1171. int y = getMyPlayer().getLocation().getY();
  1172. return x >= 1790 && x <= 1811 && y >= 3250 && y <= 3257;
  1173. }
  1174.  
  1175. public boolean atRedBandages() {
  1176. int x = getMyPlayer().getLocation().getX();
  1177. int y = getMyPlayer().getLocation().getY();
  1178. return x >= 1962 && x <= 1973 && y >= 3207 && y <= 3212;
  1179. }
  1180.  
  1181. public boolean atBlueGrave() {
  1182. int x = getMyPlayer().getLocation().getX();
  1183. int y = getMyPlayer().getLocation().getY();
  1184. return x >= 1841 && x <= 1843 && y >= 3217 && y <= 3219;
  1185. }
  1186.  
  1187. public boolean atRedGrave() {
  1188. int x = getMyPlayer().getLocation().getX();
  1189. int y = getMyPlayer().getLocation().getY();
  1190. return x >= 1932 && x <= 1934 && y >= 3244 && y <= 3246;
  1191. }
  1192.  
  1193. public boolean isAtObelisk() {
  1194. int x = getMyPlayer().getLocation().getX();
  1195. int y = getMyPlayer().getLocation().getY();
  1196. return x >= 1879 && x <= 1894 && y >= 3226 && y <= 3239;
  1197. }
  1198.  
  1199. }
Add Comment
Please, Sign In to add comment