Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //---------------------------------------------Imports---------------------------------------------\\
- import java.awt.Color;
- import java.awt.Font;
- import java.awt.Graphics;
- import java.awt.Rectangle;
- import java.util.ArrayList;
- import java.util.Map;
- import org.rsbot.bot.Bot;
- import org.rsbot.event.events.ServerMessageEvent;
- import org.rsbot.event.listeners.PaintListener;
- import org.rsbot.event.listeners.ServerMessageListener;
- import org.rsbot.script.Constants;
- import org.rsbot.script.Script;
- import org.rsbot.script.ScriptManifest;
- import org.rsbot.script.Skills;
- import org.rsbot.script.wrappers.RSInterfaceComponent;
- import org.rsbot.script.wrappers.RSNPC;
- //---------------------------------------------Manifest---------------------------------------------\\
- @ScriptManifest(authors = { "Ubuntu4life" }, category = "Combat", name = "ImNotAFK", version = 2.0, description =
- "Keeps your ass logged in. Note that this is just an AFK script. A Bandits version is coming soon!" +
- " Version 2.0")
- //---------------------------------------------ChangeLog---------------------------------------------\\
- //[12-30-2009]; Version 2 release
- //[2-18-2010]; Quick cleanup and finetuning
- //---------------------------------------------Class---------------------------------------------\\
- public class ImNotAFK extends Script implements PaintListener, ServerMessageListener {
- //---------------------------------------------Ints and stuff---------------------------------------------\\
- long lastNPC = 0;
- public int startExp[] = null;
- protected int getMouseSpeed() {return random(10, 12);}
- public boolean paint = true;
- long start;
- public double getVersion() {return 2.0;}
- //---------------------------------------------FoodID's---------------------------------------------\\
- //Credits to FoulFighter\\
- final int[] FoodID = {1895, 1893, 1891, 4293, 2142, 291, 2140, 3228, 9980,
- 7223, 6297, 6293, 6295, 6299, 7521, 9988, 7228, 2878, 7568, 2343,
- 1861, 13433, 315, 325, 319, 3144, 347, 355, 333, 339, 351, 329,
- 3381, 361, 10136, 5003, 379, 365, 373, 7946, 385, 397, 391, 3369,
- 3371, 3373, 2309, 2325, 2333, 2327, 2331, 2323, 2335, 7178, 7180,
- 7188, 7190, 7198, 7200, 7208, 7210, 7218, 7220, 2003, 2011, 2289,
- 2291, 2293, 2295, 2297, 2299, 2301, 2303, 1891, 1893, 1895, 1897,
- 1899, 1901, 7072, 7062, 7078, 7064, 7084, 7082, 7066, 7068, 1942,
- 6701, 6703, 7054, 6705, 7056, 7060, 2130, 1985, 1993, 1989, 1978,
- 5763, 5765, 1913, 5747, 1905, 5739, 1909, 5743, 1907, 1911, 5745,
- 2955, 5749, 5751, 5753, 5755, 5757, 5759, 5761, 2084, 2034, 2048,
- 2036, 2217, 2213, 2205, 2209, 2054, 2040, 2080, 2277, 2225, 2255,
- 2221, 2253, 2219, 2281, 2227, 2223, 2191, 2233, 2092, 2032, 2074,
- 2030, 2281, 2235, 2064, 2028, 2187, 2185, 2229, 6883, 1971, 4608,
- 1883, 1885, 15272};
- //---------------------------------------------Boolean's---------------------------------------------\\
- public boolean doInventoryItem(int[] ids, String action) {
- ArrayList<RSInterfaceComponent> possible = new ArrayList<RSInterfaceComponent>();
- for (RSInterfaceComponent com : getInventoryInterface().getComponents()) {
- for (int i : ids) {
- if (i == com.getComponentID())
- possible.add(com);
- }
- }
- if (possible.size() == 0)
- return false;
- RSInterfaceComponent winner = possible.get(random(0,
- possible.size() - 1));
- Rectangle loc = winner.getArea();
- moveMouse(loc);
- String top = getMenuItems().get(0).toLowerCase();
- if (isItemSelected()) {
- moveMouse(random(0, 492), random(340, 450));
- clickMouse(true);
- wait(random(300, 600));
- }
- if (top.contains(action.toLowerCase())) {
- clickMouse(true);
- return true;}
- else if (menuContains(action)) {
- wait(random(400, 700));
- return atMenu(action);
- }
- return false;
- }
- public boolean menuContains(String item) {
- try {
- for (String s : getMenuItems()) {
- if (s.toLowerCase().contains(item.toLowerCase()))
- return true;
- }
- } catch (Exception e) {
- return menuContains(item);
- }
- return false;
- }
- public boolean isItemSelected() {
- for (RSInterfaceComponent com : getInventoryInterface().getComponents()) {
- if (com.getBorderThickness() == 2)
- return true;
- }
- return false;
- }
- public boolean onStart(Map<String, String> s) {
- start = System.currentTimeMillis();
- wait(random(100, 500));
- startExp = new int[20];
- for (int i = 0; i < 20; i++) {
- startExp[i] = skills.getCurrentSkillExp(i);
- }
- return true;
- }
- //---------------------------------------------Void's---------------------------------------------\\
- //Mouse stabilizer\\
- public void moveMouse(Rectangle r) {
- int x = (r.x + 1) + random(0, r.width - 1);
- int y = (r.y + 1) + random(0, r.height - 1);
- moveMouse(x, y);
- }
- //Extra backup if RSBot fails to click continue when lvled credits to FoulFighter\\
- public void serverMessageRecieved(ServerMessageEvent arg0) {
- String serverString = arg0.getMessage();
- if (serverString.contains("You've just") || serverString.contains("Congratulations")) {
- log("You just advanced a level, attempting to click continue!");
- wait(random(1500, 2500));
- if (canContinue())
- clickContinue();
- }
- }
- //---------------------------------------------Public's---------------------------------------------\\
- //searches NPC's credits to BPestControlV2\\
- public RSNPC getNPCOnScreen(){
- final int[] validNpcs = Bot.getClient().getRSNPCIndexArray();
- final org.rsbot.accessors.RSNPC[] npcs = Bot.getClient()
- .getRSNPCArray();
- final ArrayList<RSNPC> p = new ArrayList<RSNPC>();
- for (final int element : validNpcs) {
- if (npcs[element] == null) {
- continue;
- }
- final RSNPC player = new RSNPC(npcs[element]);
- try {
- if (!tileOnScreen(player.getLocation())) {
- continue;
- }
- p.add(player);
- } catch (final Exception ignored) {
- }
- }
- if (p.size() == 0) {
- return null;
- } else if (p.size() == 1) {
- return p.get(0);
- }
- return p.get(random(0, p.size() - 1));
- }
- public String SkillToString(int skill) {
- return Skills.statsArray[skill];
- }
- //---------------------------------------------Paint---------------------------------------------\\
- //Lovely Paint Credits to FoulFighter\\
- public void onRepaint(Graphics g) {
- if (paint) {
- int x = 0;
- int y = 0;
- long millis = System.currentTimeMillis() - start;
- final long hours = millis / (1000 * 60 * 60);
- millis -= hours * 1000 * 60 * 60;
- final long minutes = millis / (1000 * 60);
- millis -= minutes * 1000 * 60;
- final long seconds = millis / 1000;
- paintBar(g, x, y, "ImNotAFK is running for : " + hours + ":" + minutes
- + ":" + seconds);
- String ver = Double.toString(getVersion());
- g.drawString("Version " + ver, 436, y + 13);
- y += 15;
- for (int i = 0; i < 7; i++) {
- if (startExp != null
- && (skills.getCurrentSkillExp(i) - startExp[i]) > 0) {
- paintSkillBar(g, x, y, i, startExp[i]);
- y += 15;
- }
- }
- if (startExp != null && (skills.getCurrentSkillExp(18) - startExp[18] > 0)) {
- paintSkillBar(g, x, y, 18, startExp[18]);
- y += 15;
- }
- }
- }
- public void paintSkillBar(Graphics g, int x, int y, int skill, int start) {
- if (paint) {
- g.setFont(new Font("Century Gothic", Font.PLAIN, 13));
- int gained = (skills.getCurrentSkillExp(skill) - start);
- String s = SkillToString(skill) + " Exp Gained: " + gained;
- String firstLetter = s.substring(0, 1); // Get first letter
- String remainder = s.substring(1); // Get remainder of word.
- String capitalized = firstLetter.toUpperCase() + remainder;
- String exp = Integer.toString(skills.getXPToNextLevel(skill));
- g.setColor(new Color(255, 0, 0, 90));
- g.fillRoundRect(416, y + 3, 100, 9, 10, 10);
- g.setColor(Color.BLACK);
- g.drawRoundRect(416, y + 3, 100, 9, 10, 10);
- g.setColor(new Color(0, 255, 0, 255));
- g.fillRoundRect(416, y + 3, skills.getPercentToNextLevel(skill), 9, 10, 10);
- g.setColor(Color.BLACK);
- g.drawRoundRect(416, y + 3, skills.getPercentToNextLevel(skill), 9, 10, 10);
- g.setColor(new Color(0, 200, 255));
- paintBar(g, x, y, capitalized);
- g.drawString("Exp To Level: " + exp, 240, y + 13);
- }
- }
- public void paintBar(Graphics g, int x, int y, String s) {
- g.setFont(new Font("Century Gothic", Font.PLAIN, 13));
- int width = 516;
- int height = (int) g.getFontMetrics().getStringBounds(s, g).getHeight();
- g.setColor(Color.BLACK);
- g.drawRect(0, y, width, height);
- g.setColor(new Color(0, 0, 0, 90));
- g.fillRect(0, y, width, height);
- g.setColor(new Color(255, 255, 255));
- g.drawString(s, x + 7, y + height - 2);
- }
- //---------------------------------------------AntiBan---------------------------------------------\\
- public int antiban() {
- int i = random(0, 37);
- if (i == 3 || i == 12 || i == 24 || i == 8)
- {
- log("moving camera way 1");
- char dir = 37;
- if (random(0, 3) == 2)
- dir = 39;
- Bot.getInputManager().pressKey(dir);
- wait(random(500, 1200));
- Bot.getInputManager().releaseKey(dir);
- wait(random(3000, 7000));
- return random(100, 500);
- }
- else if (i == 9 || i == 25 || i == 34 || i == 15)
- {
- log("Moving Camera way 2");
- setCameraRotation(random(45,75));
- setCameraAltitude(random(25, 45));
- wait(random(5000, 10000));
- return random(100, 500);
- }
- else if (i == 2 || i == 29 || i == 37 || i == 20)
- {
- log("Moving mouse out of game");
- moveMouse(random(765, 770), random(30, 450));
- wait(random(25000, 45000));
- return random(50, 400);
- }
- else if (i == 1 || i == 4 || i == 35 || i == 8 || i == 17 || i == 21|| i ==
- 27|| i == 29|| i == 31|| i == 33 || i == 23 || i == 26)
- {
- log("Moving mouse way 1");
- moveMouse(random(57, 714), random(40, 440));
- wait(random(500, 15000));
- return random(50, 400);
- }
- else if (i == 22 || i == 18)
- {
- log("Checking HitPoints XP");
- openTab(Constants.TAB_STATS);
- moveMouse(random(613, 654), random(232, 254));
- wait(random(1495, 2003));
- openTab(Constants.TAB_INVENTORY);
- wait(random(30000, 45000));
- return random(500, 1000);
- }
- else if (i == 3 || i == 32 || i == 6)
- {
- log("Checking Defence XP");
- openTab(Constants.TAB_STATS);
- moveMouse(random(561, 596), random(302, 318));
- wait(random(1495, 2003));
- openTab(Constants.TAB_INVENTORY);
- moveMouse(random(50, 450), random(50, 300));
- wait(random(30000, 45000));
- return random(0, 500);
- }
- else if (i == 23)
- {
- log("Checking Friends");
- openTab(Constants.TAB_FRIENDS);
- moveMouse(random(571, 616), random(239, 406));
- wait(random(1095, 1403));
- openTab(Constants.TAB_INVENTORY);
- moveMouse(random(577, 703), random(227, 445));
- wait(random(25000, 45000));
- return random(0, 500);
- }
- else if (i == 16)
- {
- log("Checking Attack style");
- openTab(Constants.TAB_ATTACK);
- wait(random(595, 1003));
- openTab(Constants.TAB_INVENTORY);
- moveMouse(random(50, 450), random(50, 300));
- wait(random(22000, 35000));
- return random(500, 1000);
- }
- else if (i == 32 || i == 19 || i == 7|| i == 13)
- {
- log("Right clicking NPC");
- RSNPC npc = getNPCOnScreen();
- if (npc != null) {
- clickMouse(npc.getScreenLocation(), false);
- while(isMenuOpen()){
- wait(random(550, 1030));}
- moveMouse(random(50, 450), random(50, 300));
- return random(2000, 5000);}
- }
- else if (i == 14)
- {
- log("Checking Stats");
- openTab(Constants.TAB_STATS);
- wait(random(11495, 15003));
- openTab(Constants.TAB_INVENTORY);
- moveMouse(random(50, 450), random(50, 300));
- return random(500, 1000);
- }
- return i;
- }
- //---------------------------------------------Loop---------------------------------------------\\
- public int loop() {
- if (!isLoggedIn()) {
- return random(200, 700);
- }
- //Credits to FoulFighter\\
- if (skills.getCurrentSkillLevel(STAT_HITPOINTS) <= random(skills.getRealSkillLevel
- (STAT_HITPOINTS) / 2, skills.getRealSkillLevel(STAT_HITPOINTS) / 1.5)) {
- log("Needed to eat.");
- if (getInventoryCount(FoodID) != 0) {
- if (getCurrentTab() != TAB_INVENTORY)
- openTab(TAB_INVENTORY);
- wait(random(400, 500));
- doInventoryItem(FoodID, "Eat");
- if (waitForAnim(829) != -1) {
- while (getMyPlayer().getAnimation() != -1)
- wait(random(300, 600));
- if (waitToMove(750)) {
- while (getMyPlayer().isMoving()) {
- wait(random(20,30));
- }
- }
- }
- }
- } else {
- return antiban();
- }
- return random(100, 300);
- }
- }
- //End\\
Add Comment
Please, Sign In to add comment