Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.awt.Color;
- import java.awt.Font;
- import java.awt.FontMetrics;
- import java.awt.Graphics;
- import java.awt.Graphics2D;
- import java.awt.Point;
- import java.awt.RenderingHints;
- import java.awt.event.KeyEvent;
- import java.util.ArrayList;
- import java.util.List;
- 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.RSInterface;
- import org.rsbot.script.wrappers.RSItemTile;
- import org.rsbot.script.wrappers.RSNPC;
- import org.rsbot.script.wrappers.RSPlayer;
- import org.rsbot.script.wrappers.RSTile;
- @ScriptManifest(authors = { "Nobody" }, category = "Combat", name = "Ogre Ranger", version = 1.5, description = "<html><head><style type=\"text/css\"> hr {color: white} p {margin-left: 20px} body {margin: 5px; font-family: Arial}</style></head><body><center><b><font size=\"4\" color=\"red\">Ogre Ranger v1.5</font></b><br /><b><font size=\"4\" color=\"red\">By Nobody</font></b><br /><table border=\"0\"><tr><td colspan=\"2\"><center><font size=\"3\"><b>Say Tnx</b></font></center></td></tr><tr><td colspan=\"2\"></td></tr><tr><td></table></center></body></html>")
- public class OgreCageRanger extends Script implements PaintListener,
- ServerMessageListener {
- public int currenttab;
- public int GambleInt;
- public int checkTime, checkTime1 = random(240000, 480000);
- public int speed = 150;
- public int walkSpeed = 200;
- public long lastCheck = -1, lastcheck1 = -1, lastCheck2,
- lastCheck3 = System.currentTimeMillis();
- public Point mousePos;
- private final Color backgroundBottom = new Color(72, 62, 51, 160),
- text = new Color(180, 150, 90, 160),
- black = new Color(0, 0, 0, 160);
- private final int DEFENSIVE_STYLE = 2, DAMAGE_CUTOFF = 3000;
- private Font defaultFont;
- private long lastXPChange;
- private int lastXP, lastMode;
- private double totalDamage;
- public long startTime = System.currentTimeMillis();
- int startxp = skills.getCurrentSkillExp(Skills.getStatIndex("range"));
- int startlvl = skills.getCurrentSkillLevel(Skills.getStatIndex("range"));
- public RSTile orgespot = new RSTile(2527, 3372);
- int seed = 0;
- public boolean activateCondition() {
- if (getMyPlayer().isMoving()) {
- return random(1, walkSpeed) == 1;
- } else {
- return random(1, speed) == 1;
- }
- }
- public int antiban() {
- setRun(true);
- if (!bank.getInterface().isValid()) {
- if (System.currentTimeMillis() - lastCheck2 >= checkTime) {
- lastCheck2 = System.currentTimeMillis();
- checkTime = random(300000, 600000);
- turnCamera();
- wait(random(300, 500));
- mousePos = getMouseLocation();
- currenttab = getCurrentTab();
- openTab(random(0, 13));
- wait(random(300, 500));
- turnCamera();
- wait(random(300, 500));
- openTab(currenttab);
- wait(random(300, 500));
- moveMouse(mousePos, 7, 7);
- wait(random(100, 200));
- }
- GambleInt = random(1, 9);
- switch (GambleInt) {
- case 1: // Camera Rotation
- turnCamera();
- return -1;
- case 2: // Move mouse & come back to original mouse location &
- // Camera Rotation
- final int xA = random(0, 750);
- final int yA = random(0, 500);
- mousePos = getMouseLocation();
- moveMouse(xA, yA);
- wait(random(300, 500));
- moveMouse(mousePos, 7, 7);
- wait(random(100, 200));
- turnCamera();
- return -1;
- case 3: // Inventory Tab Selection & Camera Rotation
- if (getCurrentTab() != Constants.TAB_INVENTORY) {
- currenttab = getCurrentTab();
- openTab(Constants.TAB_INVENTORY);
- wait(random(300, 500));
- turnCamera();
- }
- return -1;
- case 4: // Player right click
- mousePos = getMouseLocation();
- final RSPlayer p = getNearestPlayerByLevel(1, 130);
- if (p != null && p.isValid()) {
- moveMouse(p.getScreenLocation(), 5, 5);
- wait(random(300, 500));
- clickMouse(false);
- wait(random(1000, 1500));
- moveMouse(mousePos, 7, 7);
- }
- return -1;
- case 5: // Camera Rotation & Move mouse & come back to original
- // mouse location
- turnCamera();
- wait(random(300, 500));
- final int xB = random(0, 750);
- final int yB = random(0, 500);
- mousePos = getMouseLocation();
- moveMouse(xB, yB);
- wait(random(300, 500));
- moveMouse(mousePos, 7, 7);
- return -1;
- case 6: // Camera Rotation
- turnCamera();
- return -1;
- case 7: // Open different tab and go back to original tab
- mousePos = getMouseLocation();
- currenttab = getCurrentTab();
- openTab(random(0, 13));
- wait(random(300, 500));
- openTab(currenttab);
- wait(random(300, 500));
- moveMouse(mousePos, 7, 7);
- return -1;
- case 8: // Move mouse && come back to original mouse location
- mousePos = getMouseLocation();
- moveMouse(random(0, 450), random(0, 450));
- wait(random(300, 500));
- moveMouse(mousePos, 7, 7);
- return -1;
- }
- }
- return -1;
- }
- public void checkXP() {
- final int curXP = skills.getCurrentSkillExp(Constants.STAT_RANGE);
- if (lastXP != curXP || isRanging()) {
- if (System.currentTimeMillis() - lastXPChange > DAMAGE_CUTOFF) {
- totalDamage = 0;
- System.currentTimeMillis();
- }
- totalDamage += (curXP - lastXP) / getDenominator();
- lastXP = curXP;
- lastXPChange = System.currentTimeMillis();
- }
- }
- private boolean clickNPC(final RSNPC npc, final String action) {
- try {
- int a;
- final StringBuffer npcCommandBuf = new StringBuffer();
- npcCommandBuf.append(action);
- npcCommandBuf.append(" ");
- npcCommandBuf.append(npc.getName());
- final String npcCommand = npcCommandBuf.toString();
- for (a = 10; a-- >= 0;) {
- if (npc.getInteracting() != null
- && !npc.isInteractingWithLocalPlayer()) {
- return false;
- }
- final List<String> menuItems = getMenuItems();
- if (menuItems.size() > 1) {
- if (listContainsString(menuItems, npcCommand)) {
- if (menuItems.get(0).contains(npcCommand)) {
- clickMouse(true);
- return true;
- } else {
- clickMouse(false);
- wait(random(230, 520));
- return atMenu(npcCommand);
- }
- }
- }
- final Point screenLoc = npc.getScreenLocation();
- if (!pointOnScreen(screenLoc)) {
- return false;
- }
- final Point randomP = new Point(random(screenLoc.x - 15,
- screenLoc.x + 15), random(screenLoc.y - 15,
- screenLoc.y + 15));
- if (randomP.x >= 0 && randomP.y >= 0) {
- moveMouse(randomP);
- }
- }
- return false;
- } catch (final Exception e) {
- System.out.print("clickNPC(RSNPC, String) error: " + e);
- return false;
- }
- }
- public String convertToShorthand(final int number) {
- if (number >= 10000000) {
- return number / 1000000 + "M";
- }
- if (number >= 10000) {
- return number / 1000 + "K";
- }
- return number + "";
- }
- public void drawStringWithShadow(final String text, final int x,
- final int y, final Graphics g) {
- final Color bef = g.getColor();
- g.setColor(black);
- g.drawString(text, x + 1, y + 1);
- g.setColor(bef);
- g.drawString(text, x, y);
- }
- private double getDenominator() {
- return lastMode == DEFENSIVE_STYLE ? 2.0 : 4.0;
- }
- public ArrayList<RSItemTile> getGroundItemsByID(final int... ids) {
- final ArrayList<RSItemTile> itemsList = new ArrayList<RSItemTile>();
- final int pX = getMyPlayer().getLocation().getX();
- final int pY = getMyPlayer().getLocation().getY();
- final int minX = pX - 35;
- final int minY = pY - 35;
- final int maxX = pX + 35;
- final int maxY = pY + 35;
- for (int x = minX; x <= maxX; x++) {
- for (int y = minY; y <= maxY; y++) {
- final RSItemTile[] items = getGroundItemsAt(x, y);
- for (final RSItemTile item : items) {
- final int iId = item.getItem().getID();
- for (final int id : ids) {
- if (iId == id) {
- itemsList.add(item);
- }
- }
- }
- }
- }
- return itemsList;
- }
- @Override
- protected int getMouseSpeed() {
- return random(5, 7);
- }
- /*
- * public void antiban() { setRun(true); getEat(); zomgtele(); }
- */
- public boolean isRanging() {
- final int id = getMyPlayer().getAnimation();
- return id == 426 || id == 4230 || id == 1074;
- }
- private boolean listContainsString(final List<String> list,
- final String string) {
- try {
- int a;
- for (a = list.size() - 1; a-- >= 0;) {
- if (list.get(a).contains(string)) {
- return true;
- }
- }
- } catch (final Exception e) {
- }
- return false;
- }
- @Override
- public int loop() {
- if (distanceTo(orgespot) > 5) {
- if (distanceTo(orgespot) > 10) {
- log("lost, ending script");
- return -1;
- }
- walkTileMM(orgespot);
- return random(500, 1500);
- }
- checkForLevelUpMessage();
- if (getMyPlayer().getInteracting() == null) {
- final RSNPC ogre = getNearestFreeNPCByID(2801);
- if (ogre != null) {
- clickNPC(ogre, "Attack");
- return random(500, 1500);
- }
- } else {
- final RSTile ranarr = getGroundItemByID(5295);
- if (ranarr != null) {
- openTab(Constants.TAB_MAGIC);
- atInterface(192, 20);
- atTile(ranarr, "Grab -> Ranarr");
- wait(random(2000, 2500));
- seed++;
- }
- }
- {
- final RSTile ranarr = getGroundItemByID(5300);
- if (ranarr != null) {
- openTab(Constants.TAB_MAGIC);
- atInterface(192, 20);
- atTile(ranarr, "Grab -> Snapdragon");
- wait(random(2000, 2500));
- seed++;
- }
- }
- {
- final RSTile water = getGroundItemByID(5321);
- if (water != null) {
- openTab(Constants.TAB_MAGIC);
- atInterface(192, 20);
- atTile(water, "Grab -> Watermelon");
- wait(random(2000, 2500));
- seed++;
- }
- }
- {
- antiban();
- }
- return random(500, 1500);
- }
- @Override
- public void onFinish() {
- Bot.getEventManager().removeListener(PaintListener.class, this);
- Bot.getEventManager().removeListener(ServerMessageListener.class, this);
- }
- public void onRepaint(final Graphics render) {
- long millis = System.currentTimeMillis() - startTime;
- final int XPChange = skills.getCurrentSkillExp(Skills
- .getStatIndex("range"))
- - startxp;
- 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;
- float expPerSec = 0;
- if ((minutes > 0 || hours > 0 || seconds > 0) && XPChange > 0) {
- expPerSec = (float) XPChange
- / (float) (seconds + minutes * 60 + hours * 60 * 60);
- }
- final float expPerMin = expPerSec * 60;
- final float expPerHour = expPerMin * 60;
- final Graphics2D g = (Graphics2D) render;
- g.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
- RenderingHints.VALUE_ANTIALIAS_ON);
- if (defaultFont == null) {
- defaultFont = g.getFont();
- }
- g.setColor(backgroundBottom);
- g.fillRect(4, 318, 511, 20);
- g.setColor(black);
- g.drawRect(4, 317, 511, 21);
- g.setColor(new Color(180, 119, 22, 160));
- g.setFont(new Font(defaultFont.getName(), defaultFont.getStyle(), 10));
- g
- .fillRect(
- 36,
- 323,
- (int) (skills
- .getPercentToNextLevel(Constants.STAT_RANGE) / 100.0 * 123),
- 11);
- g.setColor(black);
- g.drawRect(35, 322, 125, 12);
- final FontMetrics fontMetrics = g.getFontMetrics(g.getFont());
- final String percentText = skills
- .getPercentToNextLevel(Constants.STAT_RANGE)
- + "%";
- g.drawString(skills.getXPToNextLevel(Constants.STAT_RANGE) + "",
- 36 + (125 - (int) fontMetrics.getStringBounds(percentText, g)
- .getWidth()) / 2, 332);
- if (styleChanged()) {
- totalDamage = 0;
- }
- checkXP();
- if (System.currentTimeMillis() - lastXPChange < DAMAGE_CUTOFF) {
- System.currentTimeMillis();
- }
- g.setColor(text);
- drawStringWithShadow(percentText, 30 - (int) fontMetrics
- .getStringBounds(percentText, g).getWidth(), 331, g);
- drawStringWithShadow("Time: " + hours + ":" + minutes + ":" + seconds,
- 165, 331, g);
- drawStringWithShadow("Gained: " + XPChange + " Xp", 245, 331, g);
- drawStringWithShadow("Xp Per Hour: " + (int) expPerHour, 340, 331, g);
- drawStringWithShadow("Seeds:" + seed, 450, 331, g);
- g.setColor(new Color(255, 255, 255, 25));
- g.fillRect(5, 318, 510, 10);
- }
- public boolean onStart() {
- skills.getCurrentSkillExp(Skills.getStatIndex("range"));
- skills.getCurrentSkillLevel(Skills.getStatIndex("range"));
- defaultFont = null;
- lastXP = skills.getCurrentSkillExp(Constants.STAT_RANGE);
- lastXPChange = System.currentTimeMillis() - DAMAGE_CUTOFF;
- lastMode = getSetting(Constants.SETTING_COMBAT_STYLE);
- totalDamage = 0;
- return true;
- }
- public void serverMessageRecieved(final ServerMessageEvent e) {
- final String mes = e.getMessage();
- if (mes.contains("There is no ammo left in your quiver.")) {
- logout();
- stopScript();
- }
- if (mes.contains("That was your last one!")) {
- log("Out of knives! Stopping script!");
- logout();
- stopScript();
- }
- }
- private boolean styleChanged() {
- if (lastMode != getSetting(Constants.SETTING_COMBAT_STYLE)) {
- lastMode = getSetting(Constants.SETTING_COMBAT_STYLE);
- return true;
- }
- return false;
- }
- public void turnCamera() {
- final char[] LR = new char[] { KeyEvent.VK_LEFT, KeyEvent.VK_RIGHT };
- final char[] UD = new char[] { KeyEvent.VK_DOWN, KeyEvent.VK_UP };
- final char[] LRUD = new char[] { KeyEvent.VK_LEFT, KeyEvent.VK_RIGHT,
- KeyEvent.VK_UP, KeyEvent.VK_UP };
- final int random2 = random(0, 2);
- final int random1 = random(0, 2);
- final int random4 = random(0, 4);
- if (random(0, 3) == 0) {
- Bot.getInputManager().pressKey(LR[random1]);
- try {
- Thread.sleep(random(100, 400));
- } catch (final Exception e) {
- }
- Bot.getInputManager().pressKey(UD[random2]);
- try {
- Thread.sleep(random(300, 600));
- } catch (final Exception e) {
- }
- Bot.getInputManager().releaseKey(UD[random2]);
- try {
- Thread.sleep(random(100, 400));
- } catch (final Exception e) {
- }
- Bot.getInputManager().releaseKey(LR[random1]);
- } else {
- Bot.getInputManager().pressKey(LRUD[random4]);
- if (random4 > 1) {
- try {
- Thread.sleep(random(300, 600));
- } catch (final Exception e) {
- }
- } else {
- try {
- Thread.sleep(random(500, 900));
- } catch (final Exception e) {
- }
- }
- Bot.getInputManager().releaseKey(LRUD[random4]);
- }
- }
- public void checkForLevelUpMessage() {
- if (RSInterface.getInterface(INTERFACE_LEVELUP).isValid()) {
- wait(random(800, 2000));
- atInterface(INTERFACE_LEVELUP, 3);
- wait(random(1000, 2000));
- }
- }
- public boolean activateCondition1() {
- long timeSinceClick = Bot.getClient().getMouse().getMousePressTime();
- if ( timeSinceClick > System.currentTimeMillis() - 600) {
- Point d = getMouseLocation();
- moveMouse(d.x - 9, d.y - 9, 18, 18);
- }
- return false;
- }
- }
Add Comment
Please, Sign In to add comment