Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.awt.Color;
- import java.awt.Font;
- import java.awt.Graphics;
- import java.awt.Graphics2D;
- import java.awt.Point;
- import java.awt.RenderingHints;
- import java.text.DecimalFormat;
- import org.rsbot.event.events.ServerMessageEvent;
- import org.rsbot.event.listeners.PaintListener;
- import org.rsbot.event.listeners.ServerMessageListener;
- import org.rsbot.script.Script;
- import org.rsbot.script.ScriptManifest;
- import org.rsbot.script.methods.Skills;
- import org.rsbot.script.util.Filter;
- import org.rsbot.script.wrappers.RSGroundItem;
- import org.rsbot.script.wrappers.RSItem;
- import org.rsbot.script.wrappers.RSNPC;
- import org.rsbot.script.wrappers.RSTile;
- @ScriptManifest (authors = {"Patrick"}, name = "Ghouls Virus whiper", description = "Whipes out the ghouls viruz!", version = 1.5)
- public class GhoulViruzWhiper extends Script implements PaintListener, ServerMessageListener {
- private long start, ttl;
- private int exp;
- private double eph;
- private DecimalFormat k = new DecimalFormat("#.#");
- private int[] lootID = {12158, 12163, 12160, 12159, 10266, 10264, 10265, 10263};
- private int[] skill = { 0, 1, 2, 3, 4, 6 }, startXP;
- private int[] potionID = {2436, 145, 149, 147, 2440, 159, 157, 161, 2442, 165, 163, 167};
- private static final int[] bones = {526, 532, 530, 528, 3183, 2859};
- private static final String[] skillNames = { "Attack", "Defence", "Strength", "Constitution", "Range", "Magic" };
- private static final Color[] skillColors = { new Color(145, 25, 25).brighter(), new Color(95, 115, 185), Color.GREEN.darker(), Color.WHITE.darker(), new Color(70, 95, 20).brighter(), new Color(95, 115, 230) };
- RSTile[] ghoulToBank = { new RSTile(3421, 3505), new RSTile(3431, 3497),
- new RSTile(3446, 3493), new RSTile(3458, 3483),
- new RSTile(3472, 3275), new RSTile(3002, 3289),
- new RSTile(3001, 3301), new RSTile(3005, 3312),
- new RSTile(3006, 3322), new RSTile(3007, 3336),
- new RSTile(3006, 3352), new RSTile(3012, 3355) };
- @Override
- public boolean onStart() {
- startXP = new int[6];
- for (int i = 0; i < skill.length; i++) {
- startXP[i] = skills.getCurrentExp(skill[i]);
- }
- start = System.currentTimeMillis();
- return true;
- }
- private void drinkPotion() {
- RSItem Potion = inventory.getItem(potionID);
- if (inventory.containsOneOf(potionID)) {
- Potion.doAction("Drink");
- }
- }
- @Override
- public int loop() {
- mouse.setSpeed(random(4, 7));
- if (!game.isLoggedIn()) {
- return 3000;
- }
- drinkPotion();
- if (!walking.isRunEnabled() && walking.getEnergy() > 60) {
- walking.setRun(true);
- return random(750, 1000);
- }
- if (players.getMyPlayer().getInteracting() != null) {
- if (combat.getLifePoints() < (skills.getRealLevel(3) * 10) / 2) {
- RSItem food = edible();
- if (food != null) {
- food.doAction("Eat ");
- } else {
- game.logout(true);
- log("Out of food...");
- return -1;
- }
- return random(900, 1100);
- }
- if (interfaces.canContinue()) {
- interfaces.clickContinue();
- }
- return random(400, 600);
- }
- RSGroundItem loot = pickup();
- if (loot != null) {
- if (players.getMyPlayer().isMoving()) {
- return random(400, 600);
- }
- if (inventory.isFull()) {
- if (inventory.getItem(bones) != null) {
- inventory.getItem(bones).doAction("Drop");
- return random(800, 1000);
- } else if (edible() != null) {
- edible().doAction("Eat");
- antiban();
- return random(800, 1000);
- }
- } else {
- if (!loot.isOnScreen()) {
- camera.turnToTile(loot.getLocation(), 15);
- if (!loot.isOnScreen()) {
- walking.walkTileMM(walking.getClosestTileOnMap(loot.getLocation()));
- return random(900, 1200);
- }
- }
- loot.doAction("Take " + loot.getItem().getName());
- antiban();
- return random(900, 1100);
- }
- }
- RSNPC ghoul = newNPC();
- if (ghoul == null || players.getMyPlayer().isMoving() && !ghoul.isOnScreen()) {
- return random(400, 600);
- }
- if (!ghoul.isOnScreen()) {
- turnTo(camera.getCharacterAngle(ghoul), ghoul);
- if (!ghoul.isOnScreen()) {
- walking.walkTileMM(walking.getClosestTileOnMap(ghoul.getLocation()));
- return random(900, 1200);
- }
- }
- ghoul.doAction("Attack "+ghoul.getName());
- antiban();
- return random(900, 1100);
- }
- @Override
- public void onRepaint(Graphics render) {
- int y = 365, z = 356, w = 196, x = 201;
- final Graphics2D g = (Graphics2D)render;
- long runTime = System.currentTimeMillis() - start;
- g.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
- g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
- Point m = mouse.getLocation();
- g.drawLine((int) m.getX() - 3, (int) m.getY(), (int) m.getX() + 3, (int) m.getY());
- g.drawLine((int) m.getX(), (int) m.getY() - 3, (int) m.getX(), (int) m.getY()+ 3);
- g.setFont(new Font("Comic Sans MS", Font.PLAIN, 10));
- g.setColor(Color.BLACK);
- g.drawRect(w, 345, 300, 11);
- g.setColor(new Color(0, 0, 0, 220));
- g.fillRect(w, 345, 300, 11);
- g.setColor(Color.WHITE);
- g.drawString("Ghouls Viruz Whiper- Run Time: "+format(runTime)+" - Version 1.5", x, 354);
- for (int i = 0; i < 6; i++, exp = 0, eph = 0, ttl = 0) {
- exp = (skills.getCurrentExp(skill[i]) - startXP[i]);
- if (exp > 0) {
- eph = (exp * 3600000D / (System.currentTimeMillis() - start));
- ttl = (long) ((skills.getExpToNextLevel(skill[i]) * 3600000D) / eph);
- g.setColor(Color.BLACK);
- g.drawRect(w, z, 300, 11);
- g.setColor(new Color(0, 0, 0, 220));
- g.fillRect(w, z, 300, 11);
- g.setColor(skillColors[i]);
- g.drawString(skillNames[i]+": "+k.format(exp / 1000D)+" K Earned - "+k.format(eph / 1000)
- +" K P/H - "+format(ttl)+" TTL", x, y);
- y += 11;
- z += 11;
- }
- }
- }
- private String format(long time) {
- if (time <= 0) {
- return "--:--:--";
- }
- final StringBuilder t = new StringBuilder();
- final long TotalSec = time / 1000;
- final long TotalMin = TotalSec / 60;
- final long TotalHour = TotalMin / 60;
- final int second = (int) TotalSec % 60;
- final int minute = (int) TotalMin % 60;
- final int hour = (int) TotalHour;
- if (hour < 10) {
- t.append("0");
- }
- t.append(hour);
- t.append(":");
- if (minute < 10) {
- t.append("0");
- }
- t.append(minute);
- t.append(":");
- if (second < 10) {
- t.append("0");
- }
- t.append(second);
- return t.toString();
- }
- private RSGroundItem pickup() {
- return groundItems.getNearest(new Filter<RSGroundItem>() {
- public boolean accept(RSGroundItem g) {
- if (lootID == null) {
- return false;
- }
- if (inventory.getCount() >= 27) {
- for (int b : bones) {
- if (g.getItem().getID() != b) {
- continue;
- }
- return false;
- }
- }
- for (int i : lootID) {
- if (g.getItem().getID() != i) {
- continue;
- }
- return true;
- }
- return false;
- }
- });
- }
- private RSNPC newNPC() {
- RSNPC interacting = interactingNPC();
- return interacting != null ? interacting : npcs.getNearest(new Filter<RSNPC>() {
- public boolean accept(RSNPC npc) {
- return npc.getName().contains("Ghoul") && npc.getHPPercent() > 0 && !npc.isInCombat();
- }
- });
- }
- private RSNPC interactingNPC() {
- return npcs.getNearest(new Filter<RSNPC>() {
- public boolean accept(RSNPC n) {
- return n.getInteracting() != null && n.getInteracting().equals(players.getMyPlayer());
- }
- });
- }
- private RSItem edible() {
- RSItem[] is = inventory.getItems();
- for (RSItem i : is) {
- if (i.getComponent().getActions() == null || i.getComponent().getActions()[0] == null) {
- continue;
- }
- if (i.getComponent().getActions()[0].contains("Eat")) {
- return i;
- }
- }
- return null;
- }
- public void antiban() {
- int b = random(0, 10);
- switch (b) {
- case 1:
- if (random(0, 10) == 5) {
- log("[Antiban] move mouse");
- mouse.moveSlightly();
- sleep(200, 600);
- mouse.moveRandomly(150, 600);
- }
- break;
- case 2:
- if (random(0, 13) == 2) {
- log("[Antiban] Turn screen");
- camera.setAngle(random(10, 100));
- sleep(400, 1200);
- }
- break;
- case 3:
- if (random(0, 24) == 6) {
- log("[Antiban] mouse off screen");
- mouse.moveOffScreen();
- sleep(random(600, random(1200, 2000)));
- }
- break;
- case 4:
- if (random(0, 18) == 3) {
- log("[antiban] Checking Xp.");
- game.openTab(1);
- skills.doHover(Skills.INTERFACE_ATTACK);
- sleep(random(100, 340));
- }
- case 5:
- if (random(0, 15) == 7) {
- log("[antiban] Checking Xp.");
- game.openTab(1);
- skills.doHover(skills.INTERFACE_DEFENSE);
- sleep(random(210, 340));
- }
- case 6:
- if (random(0, 15) == 7) {
- log("[antiban] Opening other tab");
- game.openTab(3);
- sleep(random(210, 340));
- }
- case 7:
- if (random(0, 15) == 7) {
- log("[antiban] Opening other tab");
- game.openTab(5);
- sleep(random(210, 340));
- }
- case 8:
- if (random(0, 15) == 7) {
- log("[antiban] Opening other tab");
- game.openTab(1);
- sleep(random(210, 340));
- }
- break;
- default:
- break;
- }
- }
- public void turnTo(int degrees, RSNPC n) {
- char left = 37;
- char right = 39;
- char whichDir = left;
- int start = camera.getAngle();
- if (start < 180) {
- start += 360;
- }
- if (degrees < 180) {
- degrees += 360;
- }
- if (degrees > start) {
- if (degrees - 180 < start) {
- whichDir = right;
- }
- } else if (start > degrees) {
- if (start - 180 >= degrees) {
- whichDir = right;
- }
- }
- degrees %= 360;
- keyboard.pressKey(whichDir);
- int timeWaited = 0;
- while (!n.isOnScreen() && camera.getAngle() > degrees + 10 || !n.isOnScreen() && camera.getAngle() < degrees - 10) {
- sleep(10);
- timeWaited += 10;
- if (timeWaited > 500) {
- int time = timeWaited - 500;
- if (time == 0) {
- keyboard.pressKey(whichDir);
- } else if (time % 40 == 0) {
- keyboard.pressKey(whichDir);
- }
- }
- }
- keyboard.releaseKey(whichDir);
- }
- @Override
- public void serverMessageRecieved(ServerMessageEvent e) {
- String serverString = e.getMessage();
- if (serverString.contains("just advanced a")) {
- env.saveScreenshot(true);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement