Advertisement
Guest User

Oysto

a guest
Mar 15th, 2009
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.10 KB | None | 0 0
  1. import java.awt.*;
  2. import java.util.*;
  3. import java.awt.event.*;
  4. import javax.swing.*;
  5.  
  6. import com.speljohan.rsbot.bot.*;
  7. import com.speljohan.rsbot.event.events.*;
  8. import com.speljohan.rsbot.event.listeners.*;
  9. import com.speljohan.rsbot.script.*;
  10. import com.speljohan.rsbot.script.wrappers.*;
  11. import com.speljohan.rsbot.accessors.*;
  12.  
  13. public class TSoulWars extends Script implements ServerMessageListener {
  14.  
  15. int B_DeathX[] = new int[]{1823,1816,1816,1823};
  16. int B_DeathY[] = new int[]{3220,3220,3230,3230};
  17. Polygon B_Death = new Polygon(B_DeathX, B_DeathY, 4);
  18.  
  19. int OutX[] = new int[]{1886,1890,1894,1898,1904,1897,1899,1895,1880,1880,1880};
  20. int OutY[] = new int[]{3182,3181,3179,3180,3172,3166,3162,3157,3154,3161,3173};
  21. Polygon Out = new Polygon(OutX, OutY, 11);
  22.  
  23. int R_DeathX[] = new int[]{1953,1958,1959,1959,1958,1953,1952,1952};
  24. int R_DeathY[] = new int[]{3245,3245,3244,3236,3235,3235,3236,3244};
  25. Polygon R_Death = new Polygon(R_DeathX, R_DeathY, 8);
  26.  
  27. public int loop() {
  28.  
  29. if(RSInterface.getChildInterface(211, 3).getAbsoluteX() > 20) {
  30. atInterface(RSInterface.getChildInterface(211, 3));
  31. return random(1200, 1800);
  32. }
  33.  
  34. if(getMyPlayer().getAnimation() == 836) {
  35. return random(18000, 20000);
  36. }
  37.  
  38. if(RSInterface.getInterface(228).getChild(2).isValid()) {
  39. atInterface(RSInterface.getChildInterface(228, 2));
  40. return random(1200, 1800);
  41. }
  42.  
  43. switch(check()) {
  44. case 0: //outside of game
  45. RSObject Portal = getNearestObjectByID(42031); //portal
  46. if(Portal == null) {
  47. break;
  48. }
  49. if(!tileOnScreen(Portal.getLocation())) {
  50. walkTileMM(Portal.getLocation());
  51. waitWhileMoving();
  52. }
  53. atPortal(Portal.getLocation(), "Join");
  54. waitWhileMoving();
  55. return random(1600, 2100);
  56.  
  57. case 1: //blue start room
  58. if(tileOnScreen(new RSTile(1815, 3225))) {
  59. if(!atDoorTile(new RSTile(1815, 3225), "E", "Pass")) {
  60. turnCamera();
  61. }
  62. waitWhileMoving();
  63. return random(1200, 1800);
  64. } else {
  65. walkTileMM(randomizeTile(new RSTile(1815, 3225), 2, 2));
  66. waitWhileMoving();
  67. return random(1200, 1800);
  68. }
  69.  
  70. case 2: //red start room
  71. if(tileOnScreen(new RSTile(1959, 3239))) {
  72. if(!atDoorTile(new RSTile(1959, 3239), "W", "Pass")) {
  73. turnCamera();
  74. }
  75. waitWhileMoving();
  76. return random(1200, 1800);
  77. } else {
  78. walkTileMM(randomizeTile(new RSTile(1959, 3239), 2, 2));
  79. waitWhileMoving();
  80. return random(1200, 1800);
  81. }
  82.  
  83. case 3: // look down
  84. RSObject eastGrave = getNearestObjectByID(42013, 42016);
  85. if(eastGrave == null) {
  86. return random(100, 900);
  87. }
  88. if(tileOnScreen(eastGrave.getLocation())) {
  89. if(!atDoorTile(eastGrave.getLocation(), "N", "Pass")) {
  90. turnCamera();
  91. }
  92. waitWhileMoving();
  93. return random(1200, 1800);
  94. } else {
  95. walkTileMM(eastGrave.getLocation());
  96. waitWhileMoving();
  97. return random(1200, 1800);
  98. }
  99.  
  100. case 4: // look down
  101. RSObject westGrave = getNearestObjectByID(42014, 42017);
  102. if(westGrave == null) {
  103. return random(100, 900);
  104. }
  105. if(tileOnScreen(westGrave.getLocation())) {
  106. if(!atDoorTile(westGrave.getLocation(), "S", "Pass")) {
  107. turnCamera();
  108. }
  109. waitWhileMoving();
  110. return random(1200, 1800);
  111. } else {
  112. walkTileMM(westGrave.getLocation());
  113. waitWhileMoving();
  114. return random(1200, 1800);
  115. }
  116.  
  117. case 100: //OUT OF game antiban
  118. int x = random(0, 10);
  119. switch(x) {
  120. case 1:
  121. turnCamera();
  122. break;
  123. case 2:
  124. if(random(0, 3) == 1) {
  125. tab(true);
  126. } else {
  127. tab(false);
  128. }
  129. break;
  130. }
  131. return random(500, 1000);
  132.  
  133. case 101: //IN GAME antiban
  134. int a = random(0, 15);
  135. switch(a) {
  136. case 1:
  137. turnCamera();
  138. break;
  139. case 2:
  140. if(random(0, 3) == 1) {
  141. tab(true);
  142. } else {
  143. tab(false);
  144. }
  145. break;
  146. case 3:
  147. walkRandomTile();
  148. break;
  149. }
  150. return random(500, 1000);
  151. }
  152.  
  153. return random(400, 700);
  154. }
  155.  
  156. public int check() {
  157. if(isInPolygon(Out)) {
  158. return 0;
  159. } else if(!isInPolygon(Out) && distanceTo(new RSTile(1889, 3164)) < 30) {
  160. return 100;
  161. } else if(isInPolygon(B_Death)) {
  162. return 1;
  163. } else if(isInPolygon(R_Death)) {
  164. return 2;
  165. } else if(distanceTo(new RSTile(1933, 3245)) < 2) { //East grave
  166. return 3;
  167. } else if(distanceTo(new RSTile(1842, 3218)) < 2) { //West grave
  168. return 4;
  169. } else if(getMyPlayer().getInteracting() != null) {
  170. return 100;
  171. }
  172. return 101;
  173. }
  174.  
  175. public boolean isInPolygon(Polygon p) {
  176. return p.contains(getMyPlayer().getLocation().getX(), getMyPlayer().getLocation().getY());
  177. }
  178.  
  179. public boolean atPortal(RSTile tile, String action) {
  180. try {
  181. Point location = Calculations.tileToScreen(tile.getX(), tile.getY(), random(1.2, 1.5), random(1.2, 1.5), 0);
  182. if (location.x == -1 || location.y == -1) return false;
  183. moveMouse(location, 3, 3);
  184. if (getMenuItems().get(0).toLowerCase().contains(action.toLowerCase())) {
  185. clickMouse(true);
  186. return true;
  187. } else {
  188. clickMouse(false);
  189. return atMenu(action);
  190. }
  191. } catch (Exception e) {
  192. return false;
  193. }
  194. }
  195.  
  196. public void waitWhileMoving() {
  197. wait(random(500, 700));
  198. while(getMyPlayer().isMoving()) {
  199. wait(random(100, 300));
  200. }
  201. }
  202.  
  203. public boolean turnCamera() {
  204. try{
  205. setCameraAltitude(true);
  206. int newCamera = getCameraAngle()+random(0,270);
  207. if(newCamera >= 360)
  208. newCamera-=360;
  209. setCameraRotation(newCamera);
  210. }catch(Exception e) {
  211. return false;
  212. }
  213. return true;
  214. }
  215.  
  216. public void tab(boolean stupid) {
  217. int[] nonStupidTabs = {TAB_CLAN, TAB_FRIENDS, TAB_INVENTORY, TAB_MUSIC, TAB_OPTIONS, TAB_STATS};
  218. if(stupid) {
  219. int i = random(0, 14);
  220. if(getCurrentTab() != i) {
  221. openTab(i);
  222. }
  223. } else if(!stupid) {
  224. int i = random(0, nonStupidTabs.length - 1);
  225. if(getCurrentTab() != i) {
  226. openTab(i);
  227. }
  228. }
  229. }
  230.  
  231. public void walkRandomTile() {
  232. RSTile t = new RSTile(getMyPlayer().getLocation().getX() + random(-16, 16), getMyPlayer().getLocation().getY() + random(-16, 16));
  233. if(t.isValid() && canReach(t, false)) {
  234. walkTileMM(t);
  235. waitWhileMoving();
  236. }
  237. }
  238.  
  239. public boolean atDoorTile(RSTile loc, String direction, String action) {
  240. if (loc == null) return false;
  241. if (Bot.getClient().isMenuOpen()) {
  242. atMenu("Cancel");
  243. }
  244. Point t = null;
  245. if (direction.toLowerCase().startsWith("n")) {
  246. t = Calculations.tileToScreen(loc.getX(), loc.getY() + 1, .5, .1, 40);
  247. } else if (direction.toLowerCase().startsWith("s")) {
  248. t = Calculations.tileToScreen(loc.getX(), loc.getY(), .5, .1, 40);
  249. } else if (direction.toLowerCase().startsWith("w")) {
  250. t = Calculations.tileToScreen(loc.getX(), loc.getY(), .1, .5, 40);
  251. } else if (direction.toLowerCase().startsWith("e")) {
  252. t = Calculations.tileToScreen(loc.getX() + 1, loc.getY(), .1, .5, 40);
  253. }
  254. if (t == null) {
  255. return false;
  256. }
  257. clickMouse(t,3,3,false);
  258. return atMenu(action);
  259. }
  260.  
  261. public TSoulWars() {
  262. setParameter("author", "!@!@!");
  263. setParameter("version", 1.5);
  264. setParameter("name", "TSoulWars - Public");
  265. setParameter("category", "!@!@!/Combat");
  266. setParameter("description", disc());
  267. }
  268.  
  269. public String disc() {
  270. /*Used profisher's and changed it a little. */
  271. String html = "<html>";
  272. html += "<body>";
  273. html += "<center>";
  274. html += "<b><font size=\"6\" color=\"black\">" + getName() + " v" + getVersion() + "</font><br>";
  275. html += "<font size=\"5\" color=\"black\">By: !@!@!</b><br><br><br><br></font>";
  276. html += "<tr><td><center>";
  277. html += "</center></td></tr>";
  278. html += "</center></body>";
  279. html += "</html>";
  280.  
  281. return html;
  282. }
  283.  
  284. public boolean onStart(Map<String, String> args) {
  285. Bot.getEventManager().addListener(this);
  286. return true;
  287. }
  288.  
  289. public void onFinish() {
  290. Bot.getEventManager().removeListener(this);
  291. }
  292.  
  293. public void serverMessageRecieved(ServerMessageEvent e) {
  294. if(e.getMessage().contains("If you die,")) {
  295. wait(random(14000, 18000));
  296. }
  297. }
  298.  
  299. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement