Guest User

Untitled

a guest
Jul 22nd, 2018
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 13.64 KB | None | 0 0
  1. //---------------------------------------------Imports---------------------------------------------\\
  2. import java.awt.Color;
  3. import java.awt.Font;
  4. import java.awt.Graphics;
  5. import java.awt.Rectangle;
  6. import java.util.ArrayList;
  7. import java.util.Map;
  8.  
  9. import org.rsbot.bot.Bot;
  10. import org.rsbot.event.events.ServerMessageEvent;
  11. import org.rsbot.event.listeners.PaintListener;
  12. import org.rsbot.event.listeners.ServerMessageListener;
  13. import org.rsbot.script.Constants;
  14. import org.rsbot.script.Script;
  15. import org.rsbot.script.ScriptManifest;
  16. import org.rsbot.script.Skills;
  17. import org.rsbot.script.wrappers.RSInterfaceComponent;
  18. import org.rsbot.script.wrappers.RSNPC;
  19.  
  20. //---------------------------------------------Manifest---------------------------------------------\\
  21. @ScriptManifest(authors = { "Ubuntu4life" }, category = "Combat", name = "ImNotAFK", version = 2.0, description =
  22. "Keeps your ass logged in. Note that this is just an AFK script. A Bandits version is coming soon!" +
  23. " Version 2.0")
  24. //---------------------------------------------ChangeLog---------------------------------------------\\
  25. //[12-30-2009]; Version 2 release
  26. //[2-18-2010]; Quick cleanup and finetuning
  27. //---------------------------------------------Class---------------------------------------------\\
  28. public class ImNotAFK extends Script implements PaintListener, ServerMessageListener {
  29.  
  30. //---------------------------------------------Ints and stuff---------------------------------------------\\
  31. long lastNPC = 0;
  32. public int startExp[] = null;
  33. protected int getMouseSpeed() {return random(10, 12);}
  34. public boolean paint = true;
  35. long start;
  36. public double getVersion() {return 2.0;}
  37.  
  38. //---------------------------------------------FoodID's---------------------------------------------\\
  39. //Credits to FoulFighter\\
  40. final int[] FoodID = {1895, 1893, 1891, 4293, 2142, 291, 2140, 3228, 9980,
  41. 7223, 6297, 6293, 6295, 6299, 7521, 9988, 7228, 2878, 7568, 2343,
  42. 1861, 13433, 315, 325, 319, 3144, 347, 355, 333, 339, 351, 329,
  43. 3381, 361, 10136, 5003, 379, 365, 373, 7946, 385, 397, 391, 3369,
  44. 3371, 3373, 2309, 2325, 2333, 2327, 2331, 2323, 2335, 7178, 7180,
  45. 7188, 7190, 7198, 7200, 7208, 7210, 7218, 7220, 2003, 2011, 2289,
  46. 2291, 2293, 2295, 2297, 2299, 2301, 2303, 1891, 1893, 1895, 1897,
  47. 1899, 1901, 7072, 7062, 7078, 7064, 7084, 7082, 7066, 7068, 1942,
  48. 6701, 6703, 7054, 6705, 7056, 7060, 2130, 1985, 1993, 1989, 1978,
  49. 5763, 5765, 1913, 5747, 1905, 5739, 1909, 5743, 1907, 1911, 5745,
  50. 2955, 5749, 5751, 5753, 5755, 5757, 5759, 5761, 2084, 2034, 2048,
  51. 2036, 2217, 2213, 2205, 2209, 2054, 2040, 2080, 2277, 2225, 2255,
  52. 2221, 2253, 2219, 2281, 2227, 2223, 2191, 2233, 2092, 2032, 2074,
  53. 2030, 2281, 2235, 2064, 2028, 2187, 2185, 2229, 6883, 1971, 4608,
  54. 1883, 1885, 15272};
  55.  
  56. //---------------------------------------------Boolean's---------------------------------------------\\
  57. public boolean doInventoryItem(int[] ids, String action) {
  58. ArrayList<RSInterfaceComponent> possible = new ArrayList<RSInterfaceComponent>();
  59. for (RSInterfaceComponent com : getInventoryInterface().getComponents()) {
  60. for (int i : ids) {
  61. if (i == com.getComponentID())
  62. possible.add(com);
  63. }
  64. }
  65. if (possible.size() == 0)
  66. return false;
  67. RSInterfaceComponent winner = possible.get(random(0,
  68. possible.size() - 1));
  69. Rectangle loc = winner.getArea();
  70. moveMouse(loc);
  71. String top = getMenuItems().get(0).toLowerCase();
  72. if (isItemSelected()) {
  73. moveMouse(random(0, 492), random(340, 450));
  74. clickMouse(true);
  75. wait(random(300, 600));
  76. }
  77. if (top.contains(action.toLowerCase())) {
  78. clickMouse(true);
  79. return true;}
  80. else if (menuContains(action)) {
  81. wait(random(400, 700));
  82. return atMenu(action);
  83. }
  84. return false;
  85. }
  86.  
  87. public boolean menuContains(String item) {
  88. try {
  89. for (String s : getMenuItems()) {
  90. if (s.toLowerCase().contains(item.toLowerCase()))
  91. return true;
  92. }
  93. } catch (Exception e) {
  94. return menuContains(item);
  95. }
  96. return false;
  97. }
  98.  
  99. public boolean isItemSelected() {
  100. for (RSInterfaceComponent com : getInventoryInterface().getComponents()) {
  101. if (com.getBorderThickness() == 2)
  102. return true;
  103. }
  104. return false;
  105. }
  106.  
  107. public boolean onStart(Map<String, String> s) {
  108. start = System.currentTimeMillis();
  109. wait(random(100, 500));
  110. startExp = new int[20];
  111. for (int i = 0; i < 20; i++) {
  112. startExp[i] = skills.getCurrentSkillExp(i);
  113. }
  114. return true;
  115. }
  116.  
  117. //---------------------------------------------Void's---------------------------------------------\\
  118. //Mouse stabilizer\\
  119. public void moveMouse(Rectangle r) {
  120. int x = (r.x + 1) + random(0, r.width - 1);
  121. int y = (r.y + 1) + random(0, r.height - 1);
  122. moveMouse(x, y);
  123. }
  124.  
  125. //Extra backup if RSBot fails to click continue when lvled credits to FoulFighter\\
  126. public void serverMessageRecieved(ServerMessageEvent arg0) {
  127. String serverString = arg0.getMessage();
  128. if (serverString.contains("You've just") || serverString.contains("Congratulations")) {
  129. log("You just advanced a level, attempting to click continue!");
  130. wait(random(1500, 2500));
  131. if (canContinue())
  132. clickContinue();
  133. }
  134. }
  135. //---------------------------------------------Public's---------------------------------------------\\
  136. //searches NPC's credits to BPestControlV2\\
  137. public RSNPC getNPCOnScreen(){
  138. final int[] validNpcs = Bot.getClient().getRSNPCIndexArray();
  139. final org.rsbot.accessors.RSNPC[] npcs = Bot.getClient()
  140. .getRSNPCArray();
  141. final ArrayList<RSNPC> p = new ArrayList<RSNPC>();
  142. for (final int element : validNpcs) {
  143. if (npcs[element] == null) {
  144. continue;
  145. }
  146. final RSNPC player = new RSNPC(npcs[element]);
  147. try {
  148. if (!tileOnScreen(player.getLocation())) {
  149. continue;
  150. }
  151. p.add(player);
  152. } catch (final Exception ignored) {
  153. }
  154. }
  155. if (p.size() == 0) {
  156. return null;
  157. } else if (p.size() == 1) {
  158. return p.get(0);
  159. }
  160. return p.get(random(0, p.size() - 1));
  161. }
  162.  
  163. public String SkillToString(int skill) {
  164. return Skills.statsArray[skill];
  165. }
  166.  
  167. //---------------------------------------------Paint---------------------------------------------\\
  168. //Lovely Paint Credits to FoulFighter\\
  169. public void onRepaint(Graphics g) {
  170. if (paint) {
  171. int x = 0;
  172. int y = 0;
  173. long millis = System.currentTimeMillis() - start;
  174. final long hours = millis / (1000 * 60 * 60);
  175. millis -= hours * 1000 * 60 * 60;
  176. final long minutes = millis / (1000 * 60);
  177. millis -= minutes * 1000 * 60;
  178. final long seconds = millis / 1000;
  179. paintBar(g, x, y, "ImNotAFK is running for : " + hours + ":" + minutes
  180. + ":" + seconds);
  181. String ver = Double.toString(getVersion());
  182. g.drawString("Version " + ver, 436, y + 13);
  183. y += 15;
  184. for (int i = 0; i < 7; i++) {
  185. if (startExp != null
  186. && (skills.getCurrentSkillExp(i) - startExp[i]) > 0) {
  187. paintSkillBar(g, x, y, i, startExp[i]);
  188. y += 15;
  189. }
  190. }
  191. if (startExp != null && (skills.getCurrentSkillExp(18) - startExp[18] > 0)) {
  192. paintSkillBar(g, x, y, 18, startExp[18]);
  193. y += 15;
  194. }
  195. }
  196. }
  197. public void paintSkillBar(Graphics g, int x, int y, int skill, int start) {
  198. if (paint) {
  199. g.setFont(new Font("Century Gothic", Font.PLAIN, 13));
  200. int gained = (skills.getCurrentSkillExp(skill) - start);
  201. String s = SkillToString(skill) + " Exp Gained: " + gained;
  202. String firstLetter = s.substring(0, 1); // Get first letter
  203. String remainder = s.substring(1); // Get remainder of word.
  204. String capitalized = firstLetter.toUpperCase() + remainder;
  205. String exp = Integer.toString(skills.getXPToNextLevel(skill));
  206. g.setColor(new Color(255, 0, 0, 90));
  207. g.fillRoundRect(416, y + 3, 100, 9, 10, 10);
  208. g.setColor(Color.BLACK);
  209. g.drawRoundRect(416, y + 3, 100, 9, 10, 10);
  210. g.setColor(new Color(0, 255, 0, 255));
  211. g.fillRoundRect(416, y + 3, skills.getPercentToNextLevel(skill), 9, 10, 10);
  212. g.setColor(Color.BLACK);
  213. g.drawRoundRect(416, y + 3, skills.getPercentToNextLevel(skill), 9, 10, 10);
  214. g.setColor(new Color(0, 200, 255));
  215. paintBar(g, x, y, capitalized);
  216. g.drawString("Exp To Level: " + exp, 240, y + 13);
  217. }
  218. }
  219. public void paintBar(Graphics g, int x, int y, String s) {
  220. g.setFont(new Font("Century Gothic", Font.PLAIN, 13));
  221. int width = 516;
  222. int height = (int) g.getFontMetrics().getStringBounds(s, g).getHeight();
  223. g.setColor(Color.BLACK);
  224. g.drawRect(0, y, width, height);
  225.  
  226. g.setColor(new Color(0, 0, 0, 90));
  227. g.fillRect(0, y, width, height);
  228.  
  229. g.setColor(new Color(255, 255, 255));
  230. g.drawString(s, x + 7, y + height - 2);
  231. }
  232.  
  233. //---------------------------------------------AntiBan---------------------------------------------\\
  234. public int antiban() {
  235. int i = random(0, 37);
  236. if (i == 3 || i == 12 || i == 24 || i == 8)
  237. {
  238. log("moving camera way 1");
  239. char dir = 37;
  240. if (random(0, 3) == 2)
  241. dir = 39;
  242. Bot.getInputManager().pressKey(dir);
  243. wait(random(500, 1200));
  244. Bot.getInputManager().releaseKey(dir);
  245. wait(random(3000, 7000));
  246. return random(100, 500);
  247. }
  248. else if (i == 9 || i == 25 || i == 34 || i == 15)
  249. {
  250. log("Moving Camera way 2");
  251. setCameraRotation(random(45,75));
  252. setCameraAltitude(random(25, 45));
  253. wait(random(5000, 10000));
  254. return random(100, 500);
  255. }
  256. else if (i == 2 || i == 29 || i == 37 || i == 20)
  257. {
  258. log("Moving mouse out of game");
  259. moveMouse(random(765, 770), random(30, 450));
  260. wait(random(25000, 45000));
  261. return random(50, 400);
  262. }
  263. else if (i == 1 || i == 4 || i == 35 || i == 8 || i == 17 || i == 21|| i ==
  264. 27|| i == 29|| i == 31|| i == 33 || i == 23 || i == 26)
  265. {
  266. log("Moving mouse way 1");
  267. moveMouse(random(57, 714), random(40, 440));
  268. wait(random(500, 15000));
  269. return random(50, 400);
  270. }
  271. else if (i == 22 || i == 18)
  272. {
  273. log("Checking HitPoints XP");
  274. openTab(Constants.TAB_STATS);
  275. moveMouse(random(613, 654), random(232, 254));
  276. wait(random(1495, 2003));
  277. openTab(Constants.TAB_INVENTORY);
  278. wait(random(30000, 45000));
  279. return random(500, 1000);
  280. }
  281. else if (i == 3 || i == 32 || i == 6)
  282. {
  283. log("Checking Defence XP");
  284. openTab(Constants.TAB_STATS);
  285. moveMouse(random(561, 596), random(302, 318));
  286. wait(random(1495, 2003));
  287. openTab(Constants.TAB_INVENTORY);
  288. moveMouse(random(50, 450), random(50, 300));
  289. wait(random(30000, 45000));
  290. return random(0, 500);
  291. }
  292. else if (i == 23)
  293. {
  294. log("Checking Friends");
  295. openTab(Constants.TAB_FRIENDS);
  296. moveMouse(random(571, 616), random(239, 406));
  297. wait(random(1095, 1403));
  298. openTab(Constants.TAB_INVENTORY);
  299. moveMouse(random(577, 703), random(227, 445));
  300. wait(random(25000, 45000));
  301. return random(0, 500);
  302. }
  303. else if (i == 16)
  304. {
  305. log("Checking Attack style");
  306. openTab(Constants.TAB_ATTACK);
  307. wait(random(595, 1003));
  308. openTab(Constants.TAB_INVENTORY);
  309. moveMouse(random(50, 450), random(50, 300));
  310. wait(random(22000, 35000));
  311. return random(500, 1000);
  312. }
  313. else if (i == 32 || i == 19 || i == 7|| i == 13)
  314. {
  315. log("Right clicking NPC");
  316. RSNPC npc = getNPCOnScreen();
  317. if (npc != null) {
  318. clickMouse(npc.getScreenLocation(), false);
  319. while(isMenuOpen()){
  320. wait(random(550, 1030));}
  321. moveMouse(random(50, 450), random(50, 300));
  322. return random(2000, 5000);}
  323. }
  324. else if (i == 14)
  325. {
  326. log("Checking Stats");
  327. openTab(Constants.TAB_STATS);
  328. wait(random(11495, 15003));
  329. openTab(Constants.TAB_INVENTORY);
  330. moveMouse(random(50, 450), random(50, 300));
  331. return random(500, 1000);
  332. }
  333. return i;
  334. }
  335.  
  336. //---------------------------------------------Loop---------------------------------------------\\
  337. public int loop() {
  338. if (!isLoggedIn()) {
  339. return random(200, 700);
  340. }
  341. //Credits to FoulFighter\\
  342. if (skills.getCurrentSkillLevel(STAT_HITPOINTS) <= random(skills.getRealSkillLevel
  343. (STAT_HITPOINTS) / 2, skills.getRealSkillLevel(STAT_HITPOINTS) / 1.5)) {
  344. log("Needed to eat.");
  345. if (getInventoryCount(FoodID) != 0) {
  346. if (getCurrentTab() != TAB_INVENTORY)
  347. openTab(TAB_INVENTORY);
  348. wait(random(400, 500));
  349. doInventoryItem(FoodID, "Eat");
  350. if (waitForAnim(829) != -1) {
  351. while (getMyPlayer().getAnimation() != -1)
  352. wait(random(300, 600));
  353. if (waitToMove(750)) {
  354. while (getMyPlayer().isMoving()) {
  355. wait(random(20,30));
  356. }
  357. }
  358. }
  359. }
  360. } else {
  361. return antiban();
  362. }
  363. return random(100, 300);
  364. }
  365. }
  366. //End\\
Add Comment
Please, Sign In to add comment