Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.awt.*;
- import java.awt.event.ActionEvent;
- import java.awt.event.ActionListener;
- import java.awt.event.MouseEvent;
- import java.awt.event.MouseListener;
- import java.awt.image.BufferedImage;
- import java.io.*;
- import java.text.DecimalFormat;
- import java.text.NumberFormat;
- import java.util.*;
- import java.net.*;
- import java.util.List;
- import javax.imageio.ImageIO;
- import javax.swing.*;
- import org.rsbot.bot.event.events.MessageEvent;
- import org.rsbot.script.Script;
- import org.rsbot.script.internal.event.MessageListener;
- import org.rsbot.script.internal.event.PaintListener;
- import org.rsbot.script.ScriptManifest;
- import org.rsbot.script.methods.*;
- import org.rsbot.script.methods.Menu;
- import org.rsbot.script.methods.tabs.*;
- import org.rsbot.script.methods.ui.Camera;
- import org.rsbot.script.methods.ui.Interfaces;
- import org.rsbot.script.methods.ui.Magic;
- import org.rsbot.script.util.Filter;
- import org.rsbot.script.wrappers.*;
- import org.rsbot.Configuration;
- import org.rsbot.script.wrappers.Character;
- import org.rsbot.util.io.HttpClient;
- /**
- * Change log:
- * v1.01: API updates
- * v1.00: FIRST RENATUS SCRIPT BOO YA!
- *
- * RENATUS CONVERSION!!!!!!!!!!!!!!
- *
- * v2.30: Arrow Equipping, Explorers Ring, Expanded anti ban, bunyip summoning, pbot DDoS protection
- * v2.20: New GUI, added amount of food to withdraw, fixed prayer pot double clicking, fixed? stats panel freezing for some
- * v2.10: Fixed InCombatloop NPE, added staffs to alching
- * v2.02: Finally fixed prayer pots.... hopefully, rewrote bonesLoop, bug fixes
- * v2.01: Fixed LootLoop Error.
- * v2.00: Milestone release:
- * Added:
- * -new autoupdater
- * -changed new paint
- * -multithreading
- * -disable specs
- * -fixed? prayer pots
- * -automatic banking (Experimental)
- * -Secondary Loot Method
- * -Bad Tile Checking
- * -Code optimization
- * v1.80: Stable: Fixed click to continue issue, Added autoupdater, Added new paint
- * v1.75: Unstable: Added autoupdater, new paint, may freeze a bit, looking to improve with multithreading next version.
- * v1.70: Stable: Fixed GUI, Added: B2B, alching, prayer pot support, and special attacks codings. (Please tell me if you have any issues with this.)
- * v1.66: Unstable: Removed "can reach" checking, improved Prayer pot support, added Special Attacks Codings
- * v1.65: Unstable: Added: B2B, alching, and item/npc "can reach" checking.
- * v1.61: Made SDN compatible.
- * v1.60: Stable: Potions and ssh scattering added.
- * v1.55: Unstable: Potions and ash scattering added.
- * v1.50: Project branched by Zalgo2462. Bone burial added.
- * v1.02: Includes click here to continue hotfix.
- * v1.01: Prioritize looting over combat. Safespotting + looting is now possible. Implemented new LoopAction structure internally.
- * v1.00: Milestone release.
- * Added:
- * -Safespot ability
- * -Central clicking
- * -Clicking continue
- * -Antiban - performs camera + mouse at same time! (sometimes)
- * -Declared stable
- * v0.96: Hopefully finally fixed food
- * v0.95: Small error, caused null pointer
- * v0.94: Fixed eating.
- * v0.93: Hide paint by clicking it.
- * v0.92: Loot support, mainly. Many small changes.
- * v0.91: Oops, forgot to add mouse speed settings!
- * v0.9: Initial release
- */
- @ScriptManifest(name = "RFighter", authors = "!@!@! And Zalgo2462", keywords = {"universal", "fighter", "!@!@!", "Zalgo2462"}, version = 1.02,
- description = "RFighter by Zalgo2462: Original by !@!@!", website = "http://www.powerbot.org/community/topic/444458-tfighteree-the-original-tfighter-but-with-enhancements-approved-by/")
- public class RFighter extends Script implements PaintListener, MouseListener, MessageListener {
- private final String branch = "Renatus";
- private final static ScriptManifest mani = RFighter.class.getAnnotation(ScriptManifest.class);
- private final Util u = new Util();
- private Tile startTile;
- private long nextAntiban = 0;
- private int badFoodCount = 0;
- private int startTime = 0;
- private int mouseSpeedMin = 4, mouseSpeedMax = 7;
- private boolean startScript;
- private boolean autoDownloaded = false;
- private boolean onlyInRadius = false;
- private boolean utilizeMultiwayCombat = false;
- private boolean useSafespot = false;
- private boolean useCentralClicking = true;
- private boolean prioritizeLoot = false;
- private boolean buryBones = false;
- private ZUI zui = new ZUI();
- private List<LoopAction> loopActions = new LinkedList<LoopAction>();
- // private RSWeb webToBank;
- //
- // private RSWeb webToStart;
- public boolean onRun() {
- if (!Game.isLoggedIn()) {
- log("Start logged in.");
- return false;
- }
- u.vChecker.start();
- u.paint.showPaint = true;
- u.paint.showMain = true;
- if (SwingUtilities.isEventDispatchThread()) {
- zui.setResizable(false);
- zui.setVisible(true);
- } else {
- try {
- SwingUtilities.invokeAndWait(new Runnable() {
- public void run() {
- zui.setResizable(false);
- zui.setVisible(true);
- }
- });
- } catch (Exception ignored) { }
- }
- startScript = false;
- while (!startScript) {
- if (!zui.isVisible())
- return false;
- sleep(100);
- }
- u.sw.poll();
- startTime = (int) System.currentTimeMillis();
- startTile = Players.getLocal().getLocation();
- // if(u.bank.bankingEnabled) {
- // if(startTile.getZ() == 0){
- // Tile bankTile = web.getNearestBank();
- // if(bankTile.getX() == 3382 && bankTile.getY() == 3270) {
- // bankTile = new Tile(3269, 3167);
- // }
- // webToBank = web.getWeb(startTile, bankTile);
- // webToStart = web.getWeb(bankTile, startTile);
- // } else {
- // log("Banking only works on ground level.");
- // u.bank.bankingEnabled = false;
- // }
- // }
- Game.openTab(Game.Tabs.INVENTORY);
- // u.eat.foodOfChoice = u.eat.getFood();
- //
- // if(u.eat.foodOfChoice == null && u.bank.withdrawFood) {
- // log("You do not have any food in your inventory! Food withdrawal banking will not be used!");
- // log("If you want to use food withdrawal banking, start the script with the food you use in your inventory.");
- // }
- Game.openTab(Game.Tabs.EQUIPMENT);
- //Credit: The Powerbot Scripters Team
- if(Equipment.getItem(Equipment.Slot.WEAPON) != null && !u.npcs.disableSpecials){
- u.npcs.weapon = Equipment.getItem(Equipment.Slot.WEAPON).getName();
- if(u.npcs.weapon.contains(">")) {
- u.npcs.weapon = u.npcs.weapon.substring(u.npcs.weapon.indexOf(">") + 1);
- }
- String[] specialWeaponsArray = new String[] {"Rune thrownaxe", "Rod of ivandis", "Dragon Dagger",
- "Dragon dagger (p)", "Dragon dagger (p+)", "Dragon dagger (p++)", "Dragon Mace", "Dragon Spear",
- "Dragon longsword", "Rune claws", "Dragon Halberd", "Magic Longbow", "Magic Composite Bow",
- "Dragon Claws", "Abyssal Whip", "Granite Maul", "Darklight", "Barrelchest Anchor",
- "Armadyl Godsword", "Magic Shortbow", "Dragon Scimitar", "Dragon 2H Sword", "Zamorak Godsword",
- "Korasi's sword", "Dorgeshuun Crossbow", "Bone Dagger", "Bone Dagger (p+)", "Bone Dagger (p++)",
- "Brine Sabre", "Bandos Godsword", "Dragon Battleaxe", "Dragon Hatchet", "Seercull Bow",
- "Excalibur", "Enhanced excalibur", "Ancient Mace", "Saradomin sword"};
- for(String weapon : specialWeaponsArray ) {
- if (weapon.equalsIgnoreCase(u.npcs.weapon)) {
- u.npcs.hasSpecialWeapon = true;
- }
- }
- }
- if(Equipment.getItem(Equipment.Slot.AMMO) != null) {
- u.npcs.ammo = Equipment.getItem(Equipment.Slot.AMMO).getName();
- }
- if(Equipment.getItem(Equipment.Slot.RING) != null) {
- u.npcs.ring = Equipment.getItem(Equipment.Slot.RING).getName();
- }
- LoopAction[] actions;
- if(prioritizeLoot) {
- actions = new LoopAction[] {new SummoningLoop(), new AlchLoop(), (buryBones ? new BonesLoop() : null), new LootLoop(),
- (useSafespot ? new SafespotLoop() : null), new InCombatLoop(), new AttackLoop() };
- }
- else {
- actions = new LoopAction[] { (useSafespot ? new SafespotLoop() : null), new InCombatLoop(), new SummoningLoop(), new AlchLoop(),
- (buryBones ? new BonesLoop() : null), new LootLoop(), new AttackLoop() };
- }
- loopActions.addAll(Arrays.asList(actions));
- return true;
- }
- // public void onStop() {
- // if(u.paint.priceGetter != null) {
- // if(u.paint.priceGetter.isAlive()) {
- // u.paint.priceGetter.safeStop();
- // }
- // }
- // }
- @Override
- public int loop() {
- if (random(0, 3) == 0 || Mouse.getSpeed() < mouseSpeedMin || Mouse.getSpeed() > mouseSpeedMax) {
- Mouse.setSpeed(random(mouseSpeedMin, mouseSpeedMax));
- }
- if (Camera.getPitch() < 90) {
- Camera.setPitch(true);
- return random(50, 100);
- }
- if (!Walking.isRunEnabled() && Walking.getEnergy() > random(60, 90)) {
- Walking.setRun(true);
- return random(1200, 1600);
- } else if(u.npcs.ring.contains("Explorer's Ring") && u.npcs.rechargeAvailable) {
- Game.openTab(Game.Tabs.EQUIPMENT);
- Equipment.getItem(Equipment.Slot.RING).interact("Run-replenish");
- long millis = System.currentTimeMillis();
- int run = Walking.getEnergy();
- while(System.currentTimeMillis() - millis < 5000 && run == Walking.getEnergy()) {
- sleep(random (50, 70));
- }
- if(Interfaces.getComponent(211, 1) != null &&
- Interfaces.getComponent(211, 1).getText().contains("Your ring appears")) {
- u.npcs.rechargeAvailable = false;
- }
- }
- if (Interfaces.canContinue()) {
- Interfaces.clickContinue();
- return random(1200, 1600);
- }
- if (Game.getCurrentTab() != Game.Tabs.INVENTORY) {
- Game.openTab(Game.Tabs.INVENTORY);
- return random(700, 1500);
- }
- //banking
- // if (u.bank.bankingEnabled) {
- // if (u.bank.shouldWalkHome) {
- // if(Calculations.distanceTo(startTile) > 5) {
- // if(webToStart != null) {
- // webToStart.step();
- // sleep(random(1500, 2000));
- // if(!Players.getLocal().isMoving()) {
- // Walking.walkTileOnScreen(webToStart.getEnd());
- // sleep(random(500, 1000));
- // webToStart.update();
- // }
- // } else {
- // log("Web is null");
- // }
- // } else {
- // u.bank.shouldWalkHome = false;
- // }
- // return (random(500, 750));
- // }
- //
- // if (u.bank.isInBank && u.bank.needsBank()) {
- // while(!Bank.isOpen()) {
- // Bank.open();
- // sleep(random(2000, 3000));
- // }
- // if(u.bank.depositLoot) {
- // u.bank.deposit();
- // }
- // if(u.bank.withdrawFood && u.eat.foodOfChoice != null) {
- // u.bank.withdraw();
- // }
- // u.bank.shouldWalkHome = true;
- // u.bank.isInBank = false;
- // return (random(500, 750));
- // }
- //
- // if (u.bank.needsBank()) {
- // if(Calculations.distanceTo(web.getNearestBank()) > 5 ) {
- // if(webToBank != null) {
- // webToBank.step();
- // sleep(random(1500, 2000));
- // if(!Players.getLocal().isMoving()) {
- // Walking.walkTileOnScreen(webToBank.getEnd());
- // sleep(random(500, 1000));
- // webToBank.update();
- // }
- // } else {
- // log("Web is null");
- // }
- // } else {
- // u.bank.isInBank = true;
- // }
- // return (random(500, 750));
- // }
- // }
- //eating
- if (u.eat.needEat()) {
- if (u.eat.haveFood()) {
- badFoodCount = 0;
- u.eat.eatFood();
- } else if (u.eat.haveB2pTab() && u.eat.haveBones()) {
- u.eat.breakB2pTab();
- return random(2600, 3000);
- } else if (u.eat.haveB2bRunes() && u.eat.haveBones() && Skills.getLevel(Skills.MAGIC) >= 15) {
- u.eat.castB2b();
- return random(2600, 3000);
- // } else if (u.bank.bankingEnabled && u.bank.withdrawFood){
- // u.bank.needBankforFood = true;
- } else {
- badFoodCount++;
- if (badFoodCount > 5) {
- log("You ran out of food! Stopping.");
- container.stop();
- }
- }
- return random(1200, 1600);
- }
- //potions and prayer
- u.pot.usePotions();
- if(u.pot.getPotions().get("PRAYER").length != 0 && !Prayer.isQuickPrayersActive() && u.pot.setQuickPrayer) {
- Prayer.toggleQuickPrayers(true);
- }
- //arrow equipping
- if(u.npcs.weapon != null && u.npcs.ammo != null) {
- if(u.npcs.weapon.toLowerCase().contains("bow")) {
- for(Item item : Inventory.getItems()) {
- if(item != null) {
- if(item.getID() != -1 && item.getName().equals(u.npcs.ammo)) {
- int n = Inventory.getCount(true);
- if(item.interact("Wield")) {
- waitForInvChange(n, 3000);
- }
- }
- }
- }
- }
- }
- if(u.loot.onlyTakeLootFromKilled && u.npcs.lastClickedNPC != null) {
- u.npcs.sleepWhileNpcIsDying(u.npcs.lastClickedNPC);
- }
- for(LoopAction a : loopActions)
- if(a != null && a.activate())
- return a.loop();
- return random(50, 200);
- }
- private interface LoopAction {
- public int loop();
- public boolean activate();
- }
- private class InCombatLoop implements LoopAction {
- public int loop() {
- if(u.npcs.getInteracting() != null) {
- if( u.npcs.useSpecial() && !Combat.isSpecialEnabled() && !u.npcs.getInteracting().isDead()) {
- sleep(random(500, 1000));
- Combat.setSpecial(true);
- }
- if(u.loot.onlyTakeLootFromKilled) {
- if(u.npcs.getInteracting() != null){
- if(!u.npcs.tilesFoughtOn.contains(u.npcs.getInteracting().getLocation())
- && !u.npcs.getInteracting().isMoving()) {
- u.npcs.tilesFoughtOn.add(u.npcs.getInteracting().getLocation());
- }
- }
- }
- }
- antiban();
- return random(50, 200);
- }
- public boolean activate() {
- return u.npcs.isInCombat();
- }
- }
- private class AttackLoop implements LoopAction {
- public int loop() {
- NPC inter = u.npcs.getInteracting();
- NPC n = inter != null ? inter : u.npcs.getNPC();
- if (n != null) {
- int result = u.npcs.clickNPC(n, "Attack " + n.getName());
- if (result == 0) {
- if(!useSafespot) {
- waitWhileMoving();
- } else {
- waitForAnim();
- }
- return random(300, 500);
- } else if (result == 1) {
- waitWhileMoving();
- return random(0, 200);
- }
- } else {
- if (Calculations.distanceTo(startTile) > 5) {
- Walking.walkTileMM(Walking.getClosestTileOnMap(startTile));
- waitWhileMoving();
- } else {
- antiban();
- }
- }
- return random(50, 200);
- }
- public boolean activate() {
- return !u.npcs.isInCombat();
- }
- }
- private class SafespotLoop implements LoopAction {
- public int loop() {
- if (!startTile.isOnScreen()) {
- Walking.walkTileMM(startTile);
- } else {
- startTile.interact("Walk");
- }
- waitWhileMoving();
- return random(200, 500);
- }
- public boolean activate() {
- return useSafespot && Calculations.distanceTo(startTile) > 0;
- }
- }
- private class LootLoop implements LoopAction {
- private GroundItem loot = null;
- public int loop() {
- int origCount = Inventory.getCount(true);
- String name = loot.getItem().getName();
- int count = loot.getItem().getStackSize();
- int result = u.loot.takeItem(loot);
- if (result == 0) {
- waitWhileMoving();
- if (waitForInvChange(origCount)) {
- u.loot.addItem(name, count);
- if(u.loot.onlyTakeLootFromKilled && u.npcs.tilesFoughtOn.contains(loot.getLocation())) {
- u.npcs.tilesFoughtOn.remove(loot.getLocation());
- }
- }
- } else if (result == 1) {
- waitWhileMoving();
- }
- return random(50, 200);
- }
- public boolean activate() {
- return (loot = u.loot.getLoot()) != null;
- }
- }
- private class AlchLoop implements LoopAction {
- public int loop() {
- for(Item i : Inventory.getItems()) {
- for ( String s : u.alch.alchNames) {
- if ( i.getID() != -1 && i.getName().toLowerCase().contains(s)) {
- u.alch.alch(i.getComponent());
- return random(2500, 3000);
- }
- }
- for ( int n : u.alch.alchIDs) {
- if( n == i.getID()) {
- u.alch.alch(i.getComponent());
- return random(2500, 3000);
- }
- }
- }
- return random(50, 200);
- }
- public boolean activate() {
- return u.alch.canAlch() && u.alch.hasAlchItems();
- }
- }
- private class BonesLoop implements LoopAction {
- private final int[] BONE_IDS = new int[] { 526, 528, 530, 532, 534, 536, 2859, 3123, 3125, 3183, 6182 , 20268, 20266, 20264};
- public int loop() {
- Item bone = Inventory.getItem(BONE_IDS);
- if(bone != null) {
- if(bone.getID() != -1) {
- int n = Inventory.getCount(true);
- bone.click(true);
- waitForInvChange(n);
- }
- }
- return random(50, 200);
- }
- public boolean activate() {
- return Inventory.getCount(BONE_IDS) != 0;
- }
- }
- //TODO: Add support for other familiars
- private class SummoningLoop implements LoopAction {
- public int loop() {
- Inventory.getItem(12029).interact("Summon");
- return random(3000, 5000);
- }
- public boolean activate() {
- return !Summoning.isFamiliarSummoned() && Inventory.contains(12029) && Summoning.getPoints() > 0;
- }
- }
- private void waitWhileMoving() {
- long start = System.currentTimeMillis();
- while (System.currentTimeMillis() - start < 1500 && !Players.getLocal().isMoving()) {
- sleep(random(50, 200));
- }
- while (Players.getLocal().isMoving()) {
- sleep(random(20, 50));
- }
- }
- /**
- * Waits until the inventory count changes
- * @param origCount the original count of rsitems inventory.getCount(true)
- * @return True when inventory has changed
- */
- private boolean waitForInvChange(int origCount) {
- long start = System.currentTimeMillis();
- while (Inventory.getCount(true) == origCount && System.currentTimeMillis() - start < 2000) {
- sleep(random(20, 70));
- }
- return Inventory.getCount(true) != origCount;
- }
- private boolean waitForInvChange(int origCount, int bound) {
- long start = System.currentTimeMillis();
- while (Inventory.getCount(true) == origCount && System.currentTimeMillis() - start < bound) {
- sleep(random(20, 70));
- }
- return Inventory.getCount(true) != origCount;
- }
- /**
- * Used in safe spotting. Waits for an animation.
- */
- private void waitForAnim() {
- long timer = System.currentTimeMillis();
- while(System.currentTimeMillis() - timer < 2500 && Players.getLocal().getAnimation() == -1
- && (System.currentTimeMillis() - timer < 1000 || Players.getLocal().getInteracting() != null))
- sleep(random(50, 100));
- }
- private void antiban() {
- if (System.currentTimeMillis() > nextAntiban) {
- nextAntiban = System.currentTimeMillis() + random(2000, 30000);
- } else {
- return;
- }
- Thread mouseThread = new Thread() {
- public void run() {
- switch(random(0, 5)) {
- case 0:
- Mouse.moveOffScreen();
- break;
- case 1:
- Mouse.move(random(0, Game.getWidth()), random(0, Game.getHeight()));
- break;
- case 2:
- Mouse.move(random(0, Game.getWidth()), random(0, Game.getHeight()));
- break;
- }
- }
- };
- Thread keyThread = new Thread() {
- public void run() {
- switch(random(0, 4)) {
- case 0:
- Camera.setAngle(Camera.getAngle() + random(-100, 100));
- break;
- case 1:
- Camera.setAngle(Camera.getAngle() + random(-100, 100));
- break;
- case 2:
- Camera.setAngle(Camera.getAngle() + random(-100, 100));
- break;
- }
- }
- };
- int decision = random(1, 6);
- if(decision < 3) {
- keyThread.start();
- sleep(random(0, 600));
- mouseThread.start();
- } else if (decision < 5) {
- mouseThread.start();
- sleep(random(0, 600));
- keyThread.start();
- } else if (decision == 6) {
- Game.Tabs tab = Game.getCurrentTab();
- Game.openTab(Game.Tabs.STATS);
- while(tab == Game.getCurrentTab()) {
- sleep(random(50, 90));
- }
- int decision2 = random (1, 4);
- if(decision2 == 1)
- Skills.hover(1);
- else if (decision2 == 2)
- Skills.hover(4);
- else if (decision2 == 3)
- Skills.hover(22);
- }
- while(keyThread.isAlive() || mouseThread.isAlive())
- sleep(random(30, 100));
- }
- public void onRepaint(Graphics g) {
- if (u.paint.showPaint) {
- final NumberFormat nf = NumberFormat.getIntegerInstance();
- ((Graphics2D) g).setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
- //Variables
- InterfaceComponent inter = Interfaces.get(137).getComponent(0);
- int xx = inter.getLocation().x;
- int yy = inter.getLocation().y;
- int runTime = (int) System.currentTimeMillis() - startTime;
- if(u.paint.useAdvancedPaint) {
- g.setColor(Color.WHITE);
- g.setFont(u.paint.KellyAnnGothic.deriveFont(Font.BOLD, 18));
- g.drawImage(u.paint.ribbon, xx, yy - 325, null);
- g.drawString("RFighter", xx + 35, yy - 290);
- g.drawImage(u.paint.ribbon, xx, yy - 225, null);
- g.drawString("Stats", xx + 55, yy - 190);
- g.drawImage(u.paint.ribbon, xx, yy - 125, null);
- g.drawString("Loot", xx + 55, yy - 90);
- ArrayList<Tile> alreadyDrawn = new ArrayList<Tile>();
- //Credit: Parnassian for paint method
- for(Tile tile : u.tiles.badTiles) {
- if(!alreadyDrawn.contains(tile)) {
- Point p = tile.toMinimap();
- if (p != null && p.x > 0 && p.x < Game.getWidth() && p.y > 0
- && p.y < Game.getHeight()) {
- g.setColor(Color.CYAN);
- g.drawRect(p.x - 2, p.y - 2, 4, 4);
- g.fillRect(p.x - 2, p.y - 2, 4, 4);
- alreadyDrawn.add(tile);
- }
- }
- }
- if(u.paint.showMain) {
- int x = inter.getLocation().x;
- int y = inter.getLocation().y;
- g.drawImage(u.paint.stableRug, x, y, inter.getWidth(), inter.getHeight(), null);
- g.setColor(Color.WHITE);
- g.setFont(new Font("Arial", Font.PLAIN, 16));
- g.drawString("Renatus Fighter (v" + mani.version() + ")", x + 15, y += g.getFontMetrics().getMaxAscent() + 10);
- g.setFont(new Font("Arial", Font.PLAIN, 14));
- g.drawString("By !@!@! & Zalgo2462", x + 15, y += g.getFontMetrics().getMaxAscent() + 5);
- g.setFont(new Font("Arial", Font.PLAIN, 12));
- g.drawString("Run time: " + millisToTime(runTime), x + 25, y += g.getFontMetrics().getMaxAscent() + 5);
- //Exp gains
- g.setFont(new Font("Arial", Font.BOLD, 12));
- g.drawString("Experience gained:", x + 25, y += g.getFontMetrics().getMaxAscent() + 10);
- g.setFont(new Font("Arial", Font.PLAIN, 11));
- int skillLayoutNumber = 0;
- final int skillYStart = y + g.getFontMetrics().getMaxAscent();
- for (Map.Entry<String, Integer> entry : u.sw.getExpGainedMap().entrySet()) {
- skillLayoutNumber++;
- double expPerSec = entry.getValue() / (double) (runTime / 1000);
- int expPerHour = (int) Math.round(expPerSec * 3600);
- if((skillLayoutNumber < 4) || (skillLayoutNumber > 4)) {
- g.drawString(entry.getKey() + ": " + nf.format(entry.getValue()) +
- " (p/hr: " + nf.format(expPerHour) + ")", x + 25, y += g.getFontMetrics().getMaxAscent());
- }
- else if(skillLayoutNumber == 4) {
- g.drawString(entry.getKey() + ": " + nf.format(entry.getValue()) +
- " (p/hr: " + nf.format(expPerHour) + ")", x + 175, skillYStart);
- }
- }
- y = inter.getLocation().y;
- g.setFont(new Font("Arial", Font.BOLD, 12));
- g.drawString("Loot taken:", x + 280, y += g.getFontMetrics().getMaxAscent() + 15);
- g.setFont(new Font("Arial", Font.PLAIN, 11));
- Map<String, Integer> loot = u.loot.getLootTaken();
- for (Map.Entry<String, Integer> entry : loot.entrySet()) {
- g.drawString(entry.getKey() + " x" + entry.getValue(), x + 285, y += g.getFontMetrics().getMaxAscent());
- }
- }
- else if (u.paint.showSkills) {
- int x = inter.getLocation().x;
- int y = inter.getLocation().y;
- g.drawImage(u.paint.skillsRug, x, y, inter.getWidth(), inter.getHeight(), null);
- g.setColor(new Color(0, 203, 0));
- int attackHeight = Math.round(Skills.getPercentToLevel(Skills.ATTACK) * 80 / 100);
- if(attackHeight != 0)
- g.fillRect(x + 44, y + (93 - attackHeight), 25, attackHeight);
- int strengthHeight = Math.round(Skills.getPercentToLevel(Skills.STRENGTH) * 80 / 100);
- if(strengthHeight != 0)
- g.fillRect(x + 109, y + (93 - strengthHeight), 25, strengthHeight);
- int defenseHeight = Math.round(Skills.getPercentToLevel(Skills.DEFENSE) * 80 / 100);
- if(defenseHeight != 0)
- g.fillRect(x + 174, y + (93 - defenseHeight), 25, defenseHeight);
- int rangedHeight = Math.round(Skills.getPercentToLevel(Skills.RANGE) * 80 / 100);
- if(rangedHeight != 0)
- g.fillRect(x + 238, y + (93 - rangedHeight), 25, rangedHeight);
- int prayerHeight = Math.round(Skills.getPercentToLevel(Skills.PRAYER) * 80 / 100);
- if(prayerHeight != 0)
- g.fillRect(x + 304, y + (93 - prayerHeight), 25, prayerHeight);
- int magicHeight = Math.round(Skills.getPercentToLevel(Skills.MAGIC) * 80 / 100);
- if(magicHeight != 0)
- g.fillRect(x + 370, y + (93 - magicHeight), 25, magicHeight);
- int constitutionHeight = Math.round(Skills.getPercentToLevel(Skills.CONSTITUTION) * 80 / 100);
- if(constitutionHeight != 0)
- g.fillRect(x + 434, y + (93 - constitutionHeight), 25, constitutionHeight);
- g.setColor(Color.WHITE);
- g.setFont(new Font("Arial", Font.PLAIN, 18));
- g.drawString(Skills.getAbsoluteLevel(Skills.ATTACK) + "", x + 20, y + 40);
- g.drawString(Skills.getAbsoluteLevel(Skills.STRENGTH) + "", x + 85, y + 40);
- g.drawString(Skills.getAbsoluteLevel(Skills.DEFENSE) + "", x + 150, y + 40);
- g.drawString(Skills.getAbsoluteLevel(Skills.RANGE) + "", x + 215, y + 40);
- g.drawString(Skills.getAbsoluteLevel(Skills.PRAYER) + "", x + 280, y + 40);
- g.drawString(Skills.getAbsoluteLevel(Skills.MAGIC) + "", x + 345, y + 40);
- g.drawString(Skills.getAbsoluteLevel(Skills.CONSTITUTION) + "", x + 410, y + 40);
- g.setColor(Color.GREEN);
- g.drawString("+" + u.sw.getLevelsGainedIn(Skills.ATTACK) + "", x + 20, y + 60);
- g.drawString("+" + u.sw.getLevelsGainedIn(Skills.STRENGTH) + "", x + 85, y + 60);
- g.drawString("+" + u.sw.getLevelsGainedIn(Skills.DEFENSE) + "", x + 150, y + 60);
- g.drawString("+" + u.sw.getLevelsGainedIn(Skills.RANGE) + "", x + 215, y + 60);
- g.drawString("+" + u.sw.getLevelsGainedIn(Skills.PRAYER) + "", x + 280, y + 60);
- g.drawString("+" + u.sw.getLevelsGainedIn(Skills.MAGIC) + "", x + 345, y + 60);
- g.drawString("+" + u.sw.getLevelsGainedIn(Skills.CONSTITUTION) + "", x + 410, y + 60);
- g.setColor(Color.WHITE);
- g.setFont(new Font("Arial", Font.PLAIN, 11));
- g.drawString("TNL: " + numberPostfixer(Skills.getExperienceToLevel(Skills.ATTACK)), x + 10, y + 93 + g.getFontMetrics().getMaxAscent());
- g.drawString(numberPostfixer(Skills.getExperienceToLevel(Skills.STRENGTH)), x + 110, y + 93 + g.getFontMetrics().getMaxAscent());
- g.drawString(numberPostfixer(Skills.getExperienceToLevel(Skills.DEFENSE)), x + 175, y + 93 + g.getFontMetrics().getMaxAscent());
- g.drawString(numberPostfixer(Skills.getExperienceToLevel(Skills.RANGE)), x + 238, y + 93 + g.getFontMetrics().getMaxAscent());
- g.drawString(numberPostfixer(Skills.getExperienceToLevel(Skills.PRAYER)), x + 305, y + 93 + g.getFontMetrics().getMaxAscent());
- g.drawString(numberPostfixer(Skills.getExperienceToLevel(Skills.MAGIC)), x + 370, y + 93 + g.getFontMetrics().getMaxAscent());
- g.drawString(numberPostfixer(Skills.getExperienceToLevel(Skills.CONSTITUTION)), x + 435, y + 93 + g.getFontMetrics().getMaxAscent());
- int lowerStringY = y + 93 + g.getFontMetrics().getMaxAscent();
- g.drawString("P/Hr: " + numberPostfixer(u.paint.getExpPerHour(Skills.ATTACK)),
- x + 10, lowerStringY + g.getFontMetrics().getMaxAscent());
- g.drawString(numberPostfixer(u.paint.getExpPerHour(Skills.STRENGTH)),
- x + 110, lowerStringY + g.getFontMetrics().getMaxAscent());
- g.drawString(numberPostfixer(u.paint.getExpPerHour(Skills.DEFENSE)) ,
- x + 175, lowerStringY + g.getFontMetrics().getMaxAscent());
- g.drawString(numberPostfixer(u.paint.getExpPerHour(Skills.RANGE)),
- x + 238, lowerStringY + g.getFontMetrics().getMaxAscent());
- g.drawString(numberPostfixer(u.paint.getExpPerHour(Skills.PRAYER)),
- x + 305, lowerStringY + g.getFontMetrics().getMaxAscent());
- g.drawString(numberPostfixer(u.paint.getExpPerHour(Skills.MAGIC)),
- x + 370, lowerStringY + g.getFontMetrics().getMaxAscent());
- g.drawString(numberPostfixer(u.paint.getExpPerHour(Skills.CONSTITUTION)),
- x + 435, lowerStringY + g.getFontMetrics().getMaxAscent());
- }
- else if (u.paint.showLoot) {
- int x = inter.getLocation().x;
- int y = inter.getLocation().y;
- g.drawImage(u.paint.stableRug, x, y, inter.getWidth(), inter.getHeight(), null);
- g.setColor(Color.WHITE);
- g.setFont(new Font("Arial", Font.BOLD, 14));
- g.drawString("Loot taken:", x + 50 , y += g.getFontMetrics().getMaxAscent() + 15);
- y += 5;
- g.setFont(new Font("Arial", Font.PLAIN, 12));
- Map<String, Integer> loot = u.loot.getLootTaken();
- int totalProfit = 0;
- for (Map.Entry<String, Integer> entry : loot.entrySet()) {
- g.drawString(entry.getKey() + " x" + entry.getValue() /** + " = " + (
- u.paint.priceGetter.prices.containsKey(entry.getKey()) ?
- nf.format(u.paint.priceGetter.prices.get(entry.getKey()) * entry.getValue()) + " Coins":
- "Fetching Price")**/, x + 50, y += g.getFontMetrics().getMaxAscent());
- // if(u.paint.priceGetter.prices.containsKey(entry.getKey())) {
- // totalProfit += (u.paint.priceGetter.prices.get(entry.getKey()) * entry.getValue());
- // }
- }
- // y = inter.getLocation().y;
- // g.setFont(new Font("Arial", Font.PLAIN, 24));
- // g.drawString("PROFIT???", x + 300, y += g.getFontMetrics().getMaxAscent() + 15);
- // g.drawString(nf.format(totalProfit) + " COINS", x + 300, y += g.getFontMetrics().getMaxAscent() + 15);
- }
- }
- else{
- int x = inter.getLocation().x;
- int y = inter.getLocation().y;
- // Background
- g.setColor(new Color(198, 226, 255));
- g.fillRect(x, y, inter.getWidth() + 5, inter.getHeight() + 5);
- //Simple things
- g.setColor(Color.BLACK);
- g.setFont(new Font("Arial", Font.PLAIN, 16));
- g.drawString("Renatus Fighter (v" + mani.version() + ")", x + 10, y += g.getFontMetrics().getMaxAscent() + 10);
- g.setFont(new Font("Arial", Font.PLAIN, 14));
- g.drawString("By !@!@! & Zalgo2462", x + 10, y += g.getFontMetrics().getMaxAscent() + 5);
- g.setFont(new Font("Arial", Font.PLAIN, 12));
- g.drawString("Run time: " + millisToTime(runTime), x + 20, y += g.getFontMetrics().getMaxAscent() + 5);
- //Exp gains
- g.setFont(new Font("Arial", Font.BOLD, 12));
- g.drawString("Experience gained:", x + 20, y += g.getFontMetrics().getMaxAscent() + 15);
- g.setFont(new Font("Arial", Font.PLAIN, 11));
- int skillLayoutNumber = 0;
- final int skillYStart = y + g.getFontMetrics().getMaxAscent();
- for (Map.Entry<String, Integer> entry : u.sw.getExpGainedMap().entrySet()) {
- skillLayoutNumber++;
- double expPerSec = entry.getValue() / (double) (runTime / 1000);
- int expPerHour = (int) Math.round(expPerSec * 3600);
- if((skillLayoutNumber < 5) || (skillLayoutNumber > 5)) {
- g.drawString(entry.getKey() + ": " + nf.format(entry.getValue()) +
- " (p/hr: " + nf.format(expPerHour) + ")", x + 25, y += g.getFontMetrics().getMaxAscent());
- }
- else if(skillLayoutNumber == 5) {
- g.drawString(entry.getKey() + ": " + nf.format(entry.getValue()) +
- " (p/hr: " + nf.format(expPerHour) + ")", x + 175, skillYStart);
- }
- }
- //Loot
- y = inter.getLocation().y;
- g.setFont(new Font("Arial", Font.BOLD, 12));
- g.drawString("Loot taken:", x + 280, y += g.getFontMetrics().getMaxAscent() + 15);
- g.setFont(new Font("Arial", Font.PLAIN, 11));
- Map<String, Integer> loot = u.loot.getLootTaken();
- for (Map.Entry<String, Integer> entry : loot.entrySet()) {
- g.drawString(entry.getKey() + " x" + entry.getValue(), x + 285, y += g.getFontMetrics().getMaxAscent());
- }
- }
- }
- drawMouse(g);
- }
- private void drawMouse(Graphics g) {
- int x = Mouse.getLocation().x, y = Mouse.getLocation().y;
- g.setColor(System.currentTimeMillis() - Mouse.getPressTime() < 300 ? Color.CYAN : Color.RED);
- g.fillOval(x - 6, y - 6, 12, 12);
- g.setColor(Color.ORANGE);
- g.fillOval(x - 3, y - 3, 6, 6);
- g.drawLine(x - 10, y - 10, x + 10, y + 10);
- g.drawLine(x - 10, y + 10, x + 10, y - 10);
- }
- public void messageReceived(MessageEvent e) {
- if(e.getMessage().equals("You can't reach that.")) {
- if(u.loot.itemWasClickedLast && u.loot.lastClickedItem != null) {
- u.tiles.addBadTile(u.loot.lastClickedItem.getLocation());
- } else if(u.npcs.npcWasClickedLast && u.npcs.lastClickedNPC != null) {
- u.tiles.addBadTile(u.npcs.lastClickedNPC.getLocation());
- }
- } else if(e.getMessage().equals("You don't have any quick prayers selected.")) {
- u.pot.setQuickPrayer = false;
- log("You must set your quick prayers to use prayer potions.");
- } else if(e.getMessage().equals("There is no ammo in your quiver.")) {
- boolean weaponIsCBow = u.npcs.weapon.toLowerCase().contains("crossbow");
- for(Item item : Inventory.getItems()) {
- if(item != null && item.getID() != -1) {
- if(weaponIsCBow && item.getName().toLowerCase().contains("bolt") ||
- !weaponIsCBow && item.getName().toLowerCase().contains("arrow")) {
- if(item.interact("Wield")) {
- u.npcs.ammo = item.getName();
- }
- }
- }
- }
- }
- }
- private String millisToTime(int millis) {
- int hours = millis / (60 * 1000 * 60);
- int minutes = (millis - (hours * 60 * 1000 * 60)) / (60 * 1000);
- int seconds = (millis - (hours * 60 * 1000 * 60) - (minutes * 60 * 1000)) / 1000;
- return (hours >= 10 ? hours + ":" : "0" + hours + ":")
- + (minutes >= 10 ? minutes + ":" : "0" + minutes + ":")
- + (seconds >= 10 ? seconds : "0" + seconds);
- }
- private String numberPostfixer(int number) {
- if(number >= 1000) {
- DecimalFormat twoDForm = new DecimalFormat("#.##");
- double temp = number / 1000.0;
- return Double.valueOf(twoDForm.format(temp)) + "K";
- }
- return "" + number;
- }
- private class Util {
- private final Npcs npcs = new Npcs();
- private final Eating eat = new Eating();
- private final Loot loot = new Loot();
- private final Potion pot = new Potion();
- private final Alchemy alch = new Alchemy();
- private final Paint paint = new Paint();
- private final SkillWatcher sw = new SkillWatcher();
- private final VersionChecker vChecker = new VersionChecker();
- // private final Banking bank = new Banking();
- private final Tiles tiles = new Tiles();
- }
- private class Npcs {
- private int[] npcIDs = new int[0];
- private String[] npcNames = new String[0];
- private String weapon = "";
- private boolean hasSpecialWeapon = false;
- private boolean disableSpecials = false;
- public String ammo = "";
- public String ring = "";
- private int maxRadius = 10;
- NPC lastClickedNPC = null;
- boolean npcWasClickedLast = false;
- private ArrayList<Tile> tilesFoughtOn = new ArrayList<Tile>();
- public boolean rechargeAvailable = true;
- public boolean useSpecial() {
- if(hasSpecialWeapon) {
- int[] amountUsage = {10, 25, 33, 35, 45, 50, 55, 60, 80, 85, 100};
- String[][] weapons = {
- {"Rune thrownaxe", "Rod of ivandis"},
- {"Dragon Dagger", "Dragon dagger (p)", "Dragon dagger (p+)",
- "Dragon dagger (p++)", "Dragon Mace", "Dragon Spear",
- "Dragon longsword", "Rune claws"},
- {"Dragon Halberd"},
- {"Magic Longbow"},
- {"Magic Composite Bow"},
- {"Dragon Claws", "Abyssal Whip", "Granite Maul", "Darklight",
- "Barrelchest Anchor", "Armadyl Godsword"},
- {"Magic Shortbow"},
- {"Dragon Scimitar", "Dragon 2H Sword", "Zamorak Godsword",
- "Korasi's sword"},
- {"Dorgeshuun Crossbow", "Bone Dagger", "Bone Dagger (p+)",
- "Bone Dagger (p++)"},
- {"Brine Sabre"},
- {"Bandos Godsword", "Dragon Battleaxe", "Dragon Hatchet",
- "Seercull Bow", "Excalibur", "Enhanced excalibur",
- "Ancient Mace", "Saradomin sword"}};
- for (int i = 0; i < weapons.length; i++) {
- for (int j = 0; j < weapons[i].length; j++) {
- if (weapons[i][j].equalsIgnoreCase(weapon)) {
- return Combat.getSpecialEnergy() >= amountUsage[i];
- }
- }
- }
- }
- return false;
- }
- /**
- * Checks if we are in combat.
- *
- * @return True if we are in combat.
- */
- private boolean isInCombat() {
- return Players.getLocal().getInteracting() instanceof NPC;
- }
- /**
- * Clicks an NPC based on its model.
- *
- * @param npc The NPC to click.
- * @param action The action to perform.
- * @return 0 if the NPC was clicked, 1 if we walked to it, or -1 if nothing happened.
- */
- private int clickNPC(NPC npc, String action) {
- for (int i = 0; i < 10; i++) {
- if (isPartiallyOnScreen(npc.getModel())) {
- Point p = useCentralClicking ? getCentralPoint(npc.getModel()) : getPointOnScreen(npc.getModel(), false);
- if (p == null || !Calculations.pointOnScreen(p)) {
- continue;
- }
- Mouse.move(p, useCentralClicking ? 3 : 0, useCentralClicking ? 3 : 0);
- String[] items = Menu.getItems();
- if (items.length > 0 && items[0].contains(action)) {
- Mouse.click(true);
- u.loot.itemWasClickedLast = false;
- npcWasClickedLast = true;
- lastClickedNPC = npc;
- return 0;
- } else if (Menu.contains(action)) {
- Mouse.click(false);
- sleep(random(100, 200));
- for (int x = 0; x < 4; x++) {
- if (!Menu.contains(action)) {
- break;
- }
- if (Menu.click(action)) {
- u.loot.itemWasClickedLast = false;
- npcWasClickedLast = true;
- lastClickedNPC = npc;
- return 0;
- }
- }
- }
- } else {
- if(!useSafespot) {
- Walking.walkTileMM(closerTile(npc.getLocation(), 1), 2, 2);
- sleep(random(1500, 2000));
- if(!Players.getLocal().isMoving()){
- u.tiles.addBadTile(npc.getLocation());
- return -1;
- }
- return 1;
- } else {
- int angle = Camera.getCharacterAngle(npc);
- if (Calculations.distanceTo(npc) < 10 && Math.abs(angle - Camera.getAngle()) > 20) {
- Camera.setAngle(angle + random(-20, 20));
- }
- }
- }
- }
- return -1;
- }
- /**
- * Checks if a model is partially on screen.
- *
- * @param m The GameModel to check.
- * @return True if any point on the model is on screen.
- */
- private boolean isPartiallyOnScreen(GameModel m) {
- return getPointOnScreen(m, true) != null;
- }
- /**
- * Gets a point on a model that is on screen.
- *
- * @param m The GameModel to test.
- * @param first If true, it will return the first point that it finds on screen.
- * @return A random point on screen of an object.
- */
- private Point getPointOnScreen(GameModel m, boolean first) {
- if (m == null)
- return null;
- ArrayList<Point> list = new ArrayList<Point>();
- try {
- Polygon[] tris = m.getTriangles();
- for (int i = 0; i < tris.length; i++) {
- Polygon p = tris[i];
- for (int j = 0; j < p.xpoints.length; j++) {
- Point pt = new Point(p.xpoints[j], p.ypoints[j]);
- if (Calculations.pointOnScreen(pt)) {
- if (first)
- return pt;
- list.add(pt);
- }
- }
- }
- } catch (Exception ignored) {
- }
- return list.size() > 0 ? list.get(random(0, list.size())) : null;
- }
- /**
- * Generates a rough central point. Performs the calculation
- * by first generating a rough point, and then finding the point
- * closest to the rough point that is actually on the GameModel.
- *
- * @param m The GameModel to test.
- * @return The rough central point.
- */
- private Point getCentralPoint(GameModel m) {
- if(m == null)
- return null;
- try {
- /* Add X and Y of all points, to get a rough central point */
- int x = 0, y = 0, total = 0;
- for(Polygon poly : m.getTriangles()) {
- for(int i = 0; i < poly.npoints; i++) {
- x += poly.xpoints[i];
- y += poly.ypoints[i];
- total++;
- }
- }
- Point central = new Point(x / total, y / total);
- /* Find a real point on the NPC that is closest to the central point */
- Point curCentral = null;
- double dist = 20000;
- for(Polygon poly : m.getTriangles()) {
- for(int i = 0; i < poly.npoints; i++) {
- Point p = new Point(poly.xpoints[i], poly.ypoints[i]);
- if(!Calculations.pointOnScreen(p))
- continue;
- double dist2 = distanceBetween(central, p);
- if(curCentral == null || dist2 < dist) {
- curCentral = p;
- dist = dist2;
- }
- }
- }
- return curCentral;
- } catch (Exception ignored) {}
- return null;
- }
- /**
- * Calculates the distance between two points.
- *
- * @param p1 The first point.
- * @param p2 The second point.
- * @return The distance between the two points, using the distance formula.
- */
- private double distanceBetween(Point p1, Point p2) {
- return Math.sqrt(((p1.x - p2.x) * (p1.x - p2.x)) + ((p1.y - p2.y) * (p1.y - p2.y)));
- }
- /**
- * Gets a closer tile to us within dist.
- *
- * @param t The tile to start with.
- * @param dist The max dist.
- * @return A closer tile.
- */
- private Tile closerTile(Tile t, int dist) {
- Tile loc = Players.getLocal().getLocation();
- int newX = t.getX(), newY = t.getY();
- for (int i = 1; i < dist; i++) {
- newX = t.getX() != loc.getX() ? (t.getX() < loc.getX() ? newX-- : newX++) : newX;
- newY = t.getY() != loc.getY() ? (t.getY() < loc.getY() ? newY-- : newY++) : newY;
- }
- return new Tile(newX, newY);
- }
- /**
- * Returns the nearest NPC.
- *
- * @return The nearest NPC that matches the filter.
- */
- private NPC getNPC() {
- NPC onScreen = NPCs.getNearest(npcOnScreenFilter);
- if(onScreen != null)
- return onScreen;
- return NPCs.getNearest(npcFilter);
- }
- /**
- * Returns the interacting NPC that matches our description, if any.
- *
- * @return The closest interacting NPC that matches the filter.
- */
- private NPC getInteracting() {
- NPC npc = null;
- int dist = 20;
- for (NPC n : NPCs.getLoaded()) {
- if (!isOurNPC(n))
- continue;
- Character inter = n.getInteracting();
- if (inter != null && inter instanceof Player && inter.equals(Players.getLocal()) && Calculations.distanceTo(n) < dist) {
- dist = Calculations.distanceTo(n);
- npc = n;
- }
- }
- return npc;
- }
- private boolean isOurNPC(NPC t) {
- int id = t.getID();
- String name = t.getName();
- boolean good = false;
- for (int i : npcIDs) {
- if (id == i)
- good = true;
- }
- for (String s : npcNames) {
- if (name.toLowerCase().contains(s.toLowerCase()))
- good = true;
- }
- return good;
- }
- private void sleepWhileNpcIsDying(NPC t) {
- if(u.npcs.lastClickedNPC.isDead()) {
- GroundItem[] GIs = GroundItems.getLoadedAt(t.getLocation());
- long start = System.currentTimeMillis();
- while(u.npcs.lastClickedNPC.isDead() && GIs.length == GroundItems.getLoadedAt(t.getLocation()).length
- && System.currentTimeMillis() - start < 5000) {
- sleep(random(20, 70));
- }
- }
- }
- /**
- * The filter we use!
- */
- private final Filter<NPC> npcFilter = new Filter<NPC>() {
- public boolean accept(NPC t) {
- return (isOurNPC(t) && t.verify() && (!onlyInRadius || Calculations.distanceBetween(t.getLocation(), startTile) < maxRadius)
- && (utilizeMultiwayCombat || !t.isInCombat() && t.getInteracting() == null) && t.getHPPercent() != 0
- && !u.tiles.NPCisOnBadTile(t));
- }
- };
- /**
- * Will only return an on screen NPC. Based on npcFilter.
- */
- private final Filter<NPC> npcOnScreenFilter = new Filter<NPC>() {
- public boolean accept(NPC n) {
- return npcFilter.accept(n) && getPointOnScreen(n.getModel(), true) != null;
- }
- };
- }
- private class Eating {
- private final int[] B2P_TAB_ID = new int[]{8015};
- // --Commented out by Inspection (7/20/11 2:14 PM):private final int[] B2B_TAB_ID = new int[]{8014};
- private final int[] NATURE_RUNE = new int[]{561};
- private final int[] EARTH_RUNE = new int[]{557};
- private final int[] WATER_RUNE = new int[]{555};
- private final int[] MUD_RUNE = new int[]{4698};
- private final int[] BONES_ID = new int[]{526, 532, 530, 528, 3183, 2859};
- private int toEatAtPercent = getRandomEatPercent();
- //private Item foodOfChoice;
- /**
- * Returns a random integer of when to eat.
- * @return A random integer of the percent to eat at.
- */
- private int getRandomEatPercent() {
- return random(45, 60);
- }
- /**
- * Checks if we have at least one B2P tab.
- *
- * @return True if we have a tab.
- */
- private boolean haveB2pTab() {
- return Inventory.getCount(B2P_TAB_ID) > 0;
- }
- /**
- * Checks if we have enough runes for B2B.
- * @return True if we have enough runes.
- */
- private boolean haveB2bRunes() {
- if(Inventory.getCount(true, NATURE_RUNE) > 2) {
- if(Inventory.getCount(true, MUD_RUNE) >= 1 || (Inventory.getCount(true, EARTH_RUNE) >= 1 && Inventory.getCount(true, WATER_RUNE) >= 1)) {
- return true;
- }
- }
- return false;
- }
- /**
- * Breaks a B2P tab.
- */
- private void breakB2pTab() {
- Item i = Inventory.getItem(B2P_TAB_ID);
- if (i != null)
- i.click(true);
- }
- /**
- * Casts B2B.
- */
- private void castB2b() {
- Game.openTab(Game.Tabs.MAGIC);
- Magic.castSpell(Magic.Modern.BONES_TO_BANANAS);
- }
- /**
- * Checks if the Inventory contains bones, for B2P.
- *
- * @return True if we have bones.
- */
- private boolean haveBones() {
- return Inventory.getCount(BONES_ID) > 0;
- }
- /**
- * Checks if we have food.
- *
- * @return True if we have food.
- */
- private boolean haveFood() {
- return getFood() != null;
- }
- /**
- * Finds food based on Inventory actions.
- *
- * @return The Item of food, or null if none was found.
- */
- private Item getFood() {
- for (Item i : Inventory.getItems()) {
- if (i == null || i.getID() == -1)
- continue;
- if (i.getComponent().getActions() == null || i.getComponent().getActions()[0] == null)
- continue;
- if (i.getComponent().getActions()[0].contains("Eat"))
- return i;
- }
- return null;
- }
- /**
- * Attempts to eat food.
- *
- * @return True if we ate.
- */
- private boolean eatFood() {
- Item i = getFood();
- for (int j = 0; j < 3; j++) {
- if (i == null)
- break;
- if (i.interact("Eat")) {
- return true;
- }
- }
- return false;
- }
- /**
- * Checks whether you need to eat or not.
- *
- * @return True if we need to eat.
- */
- private boolean needEat() {
- if(getHPPercent() <= toEatAtPercent) {
- toEatAtPercent = getRandomEatPercent();
- return true;
- }
- return false;
- }
- /**
- * Returns an integer representing the current health percentage.
- * @return The current health percentage.
- */
- public int getHPPercent() {
- try {
- return ((int) ((Integer.parseInt(Interfaces.get(748).getComponent(8).getText().trim()) / (double)(Skills.getAbsoluteLevel(Skills.CONSTITUTION) * 10)) * 100));
- } catch (Exception e) {
- return 100;
- }
- }
- }
- private class Loot {
- private int[] lootIDs = new int[0];
- private String[] lootNames = new String[0];
- GroundItem lastClickedItem = null;
- boolean itemWasClickedLast = false;
- private Map<String, Integer> lootTaken = new HashMap<String, Integer>();
- boolean onlyTakeLootFromKilled = false;
- /**
- * Gets the nearest loot, based on the filter
- *
- * @return The nearest item to loot, or null if none.
- */
- private GroundItem getLoot() {
- return GroundItems.getNearest(lootFilter);
- }
- /**
- * Attempts to take an item.
- *
- * @param item The item to take.
- * @return -1 if error, 0 if taken, 1 if walked
- */
- private int takeItem(GroundItem item) {
- if (item == null)
- return -1;
- String action = "Take " + item.getItem().getName();
- if (item.isOnScreen()) {
- for (int i = 0; i < 5; i++) {
- if (Menu.isOpen())
- Mouse.moveRandomly(300, 500);
- Point p = item.getLocation().toScreen(random(0.48, 0.52), random(0.48, 0.52), 0);
- if (!Calculations.pointOnScreen(p))
- continue;
- Mouse.move(p, 3, 3);
- if (Menu.contains(action)) {
- if (Menu.getItems()[0].contains(action)) {
- Mouse.click(true);
- itemWasClickedLast = true;
- u.npcs.npcWasClickedLast = false;
- lastClickedItem = item;
- return 0;
- } else {
- Mouse.click(false);
- sleep(random(100, 200));
- if (Menu.click(action)) {
- itemWasClickedLast = true;
- u.npcs.npcWasClickedLast = false;
- lastClickedItem = item;
- return 0;
- }
- }
- }
- }
- } else {
- Walking.walkTileMM(Walking.getClosestTileOnMap(item.getLocation()));
- sleep(random(1500, 2000));
- if(!Players.getLocal().isMoving()) {
- u.tiles.addBadTile(item.getLocation());
- return -1;
- }
- return 1;
- }
- return -1;
- }
- private void addItem(String name, int count) {
- if (lootTaken.get(name) != null) {
- int newCount = count + lootTaken.get(name);
- lootTaken.remove(name);
- lootTaken.put(name, newCount);
- } else {
- lootTaken.put(name, count);
- }
- }
- private Map<String, Integer> getLootTaken() {
- HashMap<String, Integer> m = new HashMap<String, Integer>();
- m.putAll(lootTaken);
- return m;
- }
- private final Filter<GroundItem> lootFilter = new Filter<GroundItem>() {
- public boolean accept(GroundItem t) {
- //Skip if we can't hold it
- Item i;
- if (Inventory.isFull() && ((i = Inventory.getItem(t.getItem().getID())) == null || i.getStackSize() <= 1)) {
- return false;
- }
- //Skip if its out of radius or far away
- if (onlyInRadius && Calculations.distanceBetween(t.getLocation(), startTile) > u.npcs.maxRadius
- || Calculations.distanceTo(t.getLocation()) > 25) {
- return false;
- }
- //Check ID/name
- boolean good = false;
- int id = t.getItem().getID();
- for (int iD : lootIDs) {
- if (iD == id)
- good = true;
- }
- String name = t.getItem().getName();
- for (String s : lootNames) {
- if (name != null && name.toLowerCase().contains(s.toLowerCase()))
- good = true;
- }
- if(good){
- for(Tile badTile : u.tiles.badTiles) {
- if(t.getLocation().getX() == badTile.getX() && t.getLocation().getY() == badTile.getY() ) {
- good = false;
- break;
- }
- }
- }
- if(good && onlyTakeLootFromKilled) {
- if(!u.npcs.tilesFoughtOn.isEmpty()) {
- for(Tile tileFoughtOn : u.npcs.tilesFoughtOn) {
- if(t.getLocation().getX() == tileFoughtOn.getX() && t.getLocation().getY() == tileFoughtOn.getY()) {
- return true;
- } else {
- good = false;
- }
- }
- } else {
- good = false;
- }
- }
- return good;
- }
- };
- }
- private class Potion {
- private final int[] MAGIC_POTIONS = new int[] {3040, 3042, 3044, 3046, 11513, 11515, 13520, 13521, 13522, 13523};
- private final int[] PRAYER_POTIONS = new int[] {2434, 139, 141, 143, 11465, 11467};
- private final int[] RANGE_POTIONS = new int[] {2444, 169, 171, 173, 11509, 11511, 13524, 13525, 15326, 15327};
- private final int[] ENERGY_POTIONS = new int[] {3008, 3010, 3012, 3014, 3016, 3018, 3020, 3022, 11453, 11455,
- 11481, 11483};
- private final int[] COMBAT_POTIONS = new int[] {9739, 9741, 9743, 9745, 11445, 11447};
- private final int[] ATTACK_POTIONS = new int[] {2428, 121, 123, 125, 2436, 145, 147, 149, 11429, 11431,
- 11429, 11431, 11429, 11431, 11469, 11471, 15308 , 15309, 15310, 15311};
- private final int[] STRENGTH_POTIONS = new int[] {113, 115, 117, 119, 2440, 157, 159, 161, 11443, 11441,
- 11485, 11487, 15312, 15313, 15314, 15315};
- private final int[] DEFENSE_POTIONS = new int[] {2432, 133, 135, 137, 2442, 163, 165, 167, 11457, 11459,
- 11497, 11499, 15316, 15317, 15318, 15319};
- private final int[] ANTIPOISON = new int[] {2446, 175, 177, 179, 2448, 181, 183, 185, 5952, 5954,
- 5956, 5958, 5943, 5945, 5947, 5949, 11433, 11435, 11501, 11503};
- private final int[] ZAMORAK_POTIONS = new int[] {2450, 189, 191, 193, 11521, 11523};
- private final int[] SARADOMIN_POTIONS = new int[] {6685, 6687, 6689, 6691};
- private final int[] OVERLOAD_POTIONS = new int[] {15332, 15333, 15334, 15335};
- private final int[] VIAL = new int[] {229};
- private boolean setQuickPrayer = true;
- private HashMap<String, Item[]> getPotions() {
- HashMap<String, Item[]> potions = new HashMap<String, Item[]>();
- potions.put("MAGIC", getRealItems(MAGIC_POTIONS));
- potions.put("PRAYER", getRealItems(PRAYER_POTIONS));
- potions.put("RANGE", getRealItems(RANGE_POTIONS));
- potions.put("ENERGY", getRealItems(ENERGY_POTIONS));
- potions.put("COMBAT", getRealItems(COMBAT_POTIONS));
- potions.put("ATTACK", getRealItems(ATTACK_POTIONS));
- potions.put("STRENGTH", getRealItems(STRENGTH_POTIONS));
- potions.put("DEFENSE", getRealItems(DEFENSE_POTIONS));
- potions.put("ANTIPOISON", getRealItems(ANTIPOISON));
- potions.put("ZAMORAK", getRealItems(ZAMORAK_POTIONS));
- potions.put("SARADOMIN", getRealItems(SARADOMIN_POTIONS));
- potions.put("OVERLOAD", getRealItems(OVERLOAD_POTIONS));
- return potions;
- }
- public void usePotions() {
- HashMap<String, Item[]> potions = u.pot.getPotions();
- if(Inventory.getItems(VIAL).length != 0) {
- for( Item i : Inventory.getItems(VIAL)) {
- int n = Inventory.getCount(true);
- i.interact("Drop Vial");
- waitForInvChange(n);
- }
- }
- if(!(u.pot.statIsBoosted(Skills.MAGIC)) && (potions.get("MAGIC").length != 0 || potions.get("OVERLOAD").length != 0)) {
- if(potions.get("MAGIC").length != 0) {
- potions.get("MAGIC")[0].click(true);
- }
- else if(potions.get("OVERLOAD").length != 0) {
- potions.get("OVERLOAD")[0].click(true);
- }
- }
- if(shouldUsePrayerPot() && potions.get("PRAYER").length != 0 && setQuickPrayer) {
- int current = Prayer.getRemainingPoints();
- if(potions.get("PRAYER")[0].click(true)) {
- long time = System.currentTimeMillis();
- while(Prayer.getRemainingPoints() == current && System.currentTimeMillis() - time < 10000) {
- sleep(random(200, 500));
- }
- }
- }
- if(!(u.pot.statIsBoosted(Skills.RANGE)) && (potions.get("RANGE").length != 0 || potions.get("OVERLOAD").length != 0)) {
- if(potions.get("RANGE").length != 0) {
- potions.get("RANGE")[0].click(true);
- }
- else if(potions.get("OVERLOAD").length != 0) {
- potions.get("OVERLOAD")[0].click(true);
- }
- }
- if(Walking.getEnergy() < random(40, 70) && potions.get("ENERGY").length != 0) {
- potions.get("ENERGY")[0].click(true);
- }
- if(!(u.pot.statIsBoosted(Skills.STRENGTH)) && (potions.get("STRENGTH").length != 0 || potions.get("COMBAT").length != 0 || potions.get("ZAMORAK").length != 0 || potions.get("OVERLOAD").length != 0)) {
- if(potions.get("COMBAT").length != 0) {
- potions.get("COMBAT")[0].click(true);
- }
- else if(potions.get("STRENGTH").length != 0) {
- potions.get("STRENGTH")[0].click(true);
- }
- else if(potions.get("ZAMORAK").length != 0) {
- potions.get("ZAMORAK")[0].click(true);
- }
- else if(potions.get("OVERLOAD").length != 0) {
- potions.get("OVERLOAD")[0].click(true);
- }
- }
- if(!(u.pot.statIsBoosted(Skills.DEFENSE)) && (potions.get("DEFENSE").length != 0 || potions.get("SARADOMIN").length != 0 || potions.get("OVERLOAD").length != 0)) {
- if(potions.get("DEFENSE").length != 0) {
- potions.get("DEFENSE")[0].click(true);
- }
- else if(potions.get("SARADOMIN").length != 0) {
- potions.get("SARADOMIN")[0].click(true);
- }
- else if(potions.get("OVERLOAD").length != 0) {
- potions.get("OVERLOAD")[0].click(true);
- }
- }
- if(!(u.pot.statIsBoosted(Skills.ATTACK)) && (potions.get("ATTACK").length != 0 || potions.get("COMBAT").length != 0 || potions.get("ZAMORAK").length != 0 || potions.get("OVERLOAD").length != 0)) {
- if(potions.get("COMBAT").length != 0) {
- potions.get("COMBAT")[0].click(true);
- }
- else if(potions.get("ATTACK").length != 0) {
- potions.get("ATTACK")[0].click(true);
- }
- else if(potions.get("ZAMORAK").length != 0) {
- potions.get("ZAMORAK")[0].click(true);
- }
- else if(potions.get("OVERLOAD").length != 0) {
- potions.get("OVERLOAD")[0].click(true);
- }
- }
- if(isPoisoned() && potions.get("ANTIPOISON").length != 0) {
- potions.get("ANTIPOISON")[0].click(true);
- }
- }
- private boolean isPoisoned() {
- return Settings.get(102) > 0 || Interfaces.getComponent(748, 4).getTextureID() == 1801;
- }
- private boolean statIsBoosted(int Skill) {
- return Skills.getLevel(Skill) != Skills.getAbsoluteLevel(Skill);
- }
- private boolean shouldUsePrayerPot() {
- return (Skills.getAbsoluteLevel(Skills.PRAYER) - Prayer.getRemainingPoints()) > (7+Math.floor(Skills.getAbsoluteLevel(Skills.PRAYER)/4));
- }
- public Item[] getRealItems(int[] ids) {
- Item[] raw = Inventory.getItems(ids);
- ArrayList<Item> refined = new ArrayList<Item>();
- for(Item item : raw) {
- if(item != null) {
- if(item.getID() != -1) {
- refined.add(item);
- }
- }
- }
- return refined.toArray(new Item[refined.size()]);
- }
- }
- private class Alchemy {
- private int[] alchIDs = new int[0];
- private String[] alchNames = new String[0];
- private final int[] NATURE_RUNE = new int[]{561};
- private final int[] FIRE_RUNE = new int[]{554};
- private final int[] COINS= new int[]{995};
- private boolean canAlch() {
- if(Inventory.getCount(true, NATURE_RUNE) >= 1 && (Inventory.getCount(true, FIRE_RUNE) >= 5 ||
- u.npcs.weapon.toLowerCase().contains("fire") || u.npcs.weapon.toLowerCase().contains("steam")
- || u.npcs.weapon.toLowerCase().contains("lava")) && (Inventory.getCount(COINS) > 0 ||
- Inventory.getCount() <= 27) && Skills.getLevel(Skills.MAGIC) >= 55) {
- return true;
- }
- else if(Inventory.getCount(true, NATURE_RUNE) >= 1 && Inventory.getCount(true, FIRE_RUNE) >= 3 && (Inventory.getCount(COINS) > 0 || Inventory.getCount() <= 27) && Skills.getLevel(Skills.MAGIC) >= 21) {
- return true;
- }
- return false;
- }
- private boolean hasAlchItems() {
- if(alchNames.length > 0 || alchIDs.length > 0)
- {
- for( Item i : Inventory.getItems()) {
- for ( String s : u.alch.alchNames) {
- if (i.getComponent() != null && i.getID() != -1 && i.getName().toLowerCase().contains(s)) {
- return true;
- }
- }
- for ( int n : u.alch.alchIDs) {
- if( n == i.getID()) {
- return true;
- }
- }
- }
- }
- return false;
- }
- private void alch(InterfaceComponent i) {
- if (i != null) {
- if(Inventory.getCount(true, NATURE_RUNE) >= 1 && (Inventory.getCount(true, FIRE_RUNE) >= 5 ||
- u.npcs.weapon.toLowerCase().contains("fire") || u.npcs.weapon.toLowerCase().contains("steam") ||
- u.npcs.weapon.toLowerCase().contains("lava")) && Skills.getLevel(Skills.MAGIC) >= 55) {
- if(Game.getCurrentTab() != Game.Tabs.MAGIC) {
- Game.openTab(Game.Tabs.MAGIC);
- }
- Magic.castSpell(Magic.Modern.HIGH_LEVEL_ALCHEMY);
- }
- else if(Inventory.getCount(true, NATURE_RUNE) >= 1 && (Inventory.getCount(true, FIRE_RUNE) >= 5 ||
- u.npcs.weapon.toLowerCase().contains("fire") || u.npcs.weapon.toLowerCase().contains("steam") ||
- u.npcs.weapon.toLowerCase().contains("lava")) && Skills.getLevel(Skills.MAGIC) >= 21) {
- if(Game.getCurrentTab() != Game.Tabs.MAGIC) {
- Game.openTab(Game.Tabs.MAGIC);
- }
- Magic.castSpell(Magic.Modern.LOW_LEVEL_ALCHEMY);
- }
- sleep(random(150, 500));
- i.interact("Cast");
- }
- }
- }
- private class Paint {
- BufferedImage ribbon = null;
- BufferedImage stableRug = null;
- BufferedImage skillsRug = null;
- Font KellyAnnGothic = null;
- boolean showPaint = false;
- boolean showMain = false;
- boolean showSkills = false;
- boolean showLoot = false;
- // public ExchangePriceGetter priceGetter;
- boolean useAdvancedPaint = true;
- private Paint() {
- try {
- ribbon = ImageIO.read(new URL("http://scripters.powerbot.org/585097/Paint/pentagon_tag.png"));
- stableRug = ImageIO.read(new URL("http://scripters.powerbot.org/585097/Paint/rug.png"));
- skillsRug = ImageIO.read(new URL("http://scripters.powerbot.org/585097/Paint/rug1.png"));
- URL fontURL = new URL("http://scripters.powerbot.org/585097/Paint/kellyag.ttf");
- URLConnection fontDownload = fontURL.openConnection();
- KellyAnnGothic = Font.createFont(Font.TRUETYPE_FONT, fontDownload.getInputStream());
- // priceGetter = new ExchangePriceGetter();
- // priceGetter.start();
- } catch (Exception e){
- useAdvancedPaint = false;
- }
- }
- public int getExpPerHour(int Skill) {
- double entry = u.sw.getExpGainedIn(Skill);
- int runTime = (int) System.currentTimeMillis() - startTime;
- double expPerSec = entry / (runTime / 1000);
- return((int) Math.round(expPerSec * 3600));
- }
- // private class ExchangePriceGetter extends Thread {
- // HashMap<String, Integer> prices = new HashMap<String, Integer>();
- // boolean stopThread = false;
- //
- // public ExchangePriceGetter() {
- // setDaemon(true);
- // setPriority(2);
- // }
- //
- // public void safeStop() {
- // stopThread = true;
- // }
- //
- // public void run() {
- // Map<String, Integer> lootTaken;
- // while(!stopThread){
- // if(u != null) {
- // lootTaken = u.loot.getLootTaken();
- // for(Map.Entry<String, Integer> lootEntry: lootTaken.entrySet()) {
- // if(!prices.containsKey(lootEntry.getKey())) {
- // if(lootEntry.getKey().equals("Coins")) {
- // prices.put("Coins", 1);
- // }
- // GrandExchange.GEItem item = grandExchange.lookup(lootEntry.getKey());
- // if(item != null) {
- // prices.put(item.getName(), item.getGuidePrice());
- // }
- // }
- // }
- // }
- // try{ sleep(5000); } catch (Exception ignored) {}
- // }
- // }
- // }
- }
- private class SkillWatcher {
- private HashMap<Integer, Integer> startExpMap = new HashMap<Integer, Integer>();
- private final int[] SKILLS_TO_WATCH = new int[]{Skills.SLAYER, Skills.CONSTITUTION, Skills.ATTACK, Skills.STRENGTH, Skills.DEFENSE, Skills.RANGE, Skills.MAGIC, Skills.PRAYER};
- private HashMap<Integer, Integer> startLevelsMap = new HashMap<Integer, Integer>();
- /**
- * Basically sets start exp for all Skills we are watching.
- */
- private void poll() {
- for (int skill : SKILLS_TO_WATCH) {
- if (startExpMap.containsKey(skill)) {
- startExpMap.remove(skill);
- }
- if (startLevelsMap.containsKey(skill)) {
- startLevelsMap.remove(skill);
- }
- startExpMap.put(skill, Skills.getExperience(skill));
- startLevelsMap.put(skill, Skills.getAbsoluteLevel(skill));
- }
- }
- /**
- * Returns the amount of exp gained in the specified skill.
- *
- * @param skill The skill see Skills.*
- * @return the EXP Gained
- */
- private int getExpGainedIn(int skill) {
- if (startExpMap.get(skill) == null)
- return -1;
- return Skills.getExperience(skill) - startExpMap.get(skill);
- }
- // --Commented out by Inspection START (7/24/11 10:18 PM):
- // private int getExpStart(int skill) {
- // if (startExpMap.get(skill) == null)
- // return -1;
- // return startExpMap.get(skill);
- // }
- // --Commented out by Inspection STOP (7/24/11 10:18 PM)
- private int getLevelsGainedIn(int skill) {
- return Skills.getAbsoluteLevel(skill) - startLevelsMap.get(skill);
- }
- /**
- * Returns a map of skill names and exp gained.
- *
- * @return A map of exp gains and skill names.
- */
- private Map<String, Integer> getExpGainedMap() {
- Map<String, Integer> map = new HashMap<String, Integer>();
- for (int i : SKILLS_TO_WATCH) {
- int gained = getExpGainedIn(i);
- if (gained != 0)
- map.put(Skills.SKILL_NAMES[i], gained);
- }
- return map;
- }
- }
- @SuppressWarnings({"ResultOfMethodCallIgnored"})
- private class VersionChecker extends Thread {
- public void run() {
- try {
- Properties versionInfo = new Properties();
- URL url = new URL("http://scripters.powerbot.org/files/349221/" + branch + "/Version.txt");
- URLConnection conn = url.openConnection();
- conn.setConnectTimeout(10 * 1000);
- conn.setReadTimeout(10 * 1000);
- versionInfo.load( new BufferedReader(new InputStreamReader(conn.getInputStream())));
- if(Double.parseDouble(versionInfo.getProperty(branch + "Version")) > mani.version()) {
- if (SwingUtilities.isEventDispatchThread()) {
- Object[] options = {"Yes.", "No."};
- int answer = JOptionPane.showOptionDialog(null, "A new version of RFighter (" + branch + ") is available. \r\n" +
- "Would you like to download it?", "New Version Available!", JOptionPane.YES_NO_OPTION,
- JOptionPane.QUESTION_MESSAGE, null, options, options[0]);
- if(answer == 0) {
- String sourceURL = "http://scripters.powerbot.org/files/349221/" + branch + "/RFighter.java";
- log("Downloading: " + sourceURL);
- final File classFile = new File(Configuration.Paths.getScriptsSourcesDirectory() + File.separator
- + "RFighter.java");
- try {
- HttpClient.download(new URL(sourceURL), classFile);
- } catch (Exception e) {
- classFile.delete();
- JOptionPane.showMessageDialog(null, "Could not download script");
- }
- if(classFile.exists()) {
- JOptionPane.showMessageDialog(null, "Please Recompile Scripts!");
- }
- zui.dispose();
- container.stop();
- }
- } else {
- SwingUtilities.invokeAndWait(new Runnable() {
- public void run() {
- Object[] options = {"Yes.", "No."};
- int answer = JOptionPane.showOptionDialog(null, "A new version of RFighter (" + branch + ") is available. \r\n" +
- "Would you like to download it?", "New Version Available!", JOptionPane.YES_NO_OPTION,
- JOptionPane.QUESTION_MESSAGE, null, options, options[0]);
- if(answer == 0) {
- String sourceURL = "http://scripters.powerbot.org/files/349221/" + branch + "/RFighter.java";
- log("Downloading: " + sourceURL);
- final File classFile = new File(Configuration.Paths.getScriptsSourcesDirectory() + File.separator
- + "RFighter.java");
- if(classFile.exists()) {
- classFile.delete();
- }
- try {
- HttpClient.download(new URL(sourceURL), classFile);
- } catch (Exception e) {
- if(classFile.exists()) {
- classFile.delete();
- }
- JOptionPane.showMessageDialog(null, "Could not download script");
- }
- if(classFile.exists()) {
- JOptionPane.showMessageDialog(null, "Please Recompile Scripts!");
- autoDownloaded = true;
- }
- }
- }
- });
- if(autoDownloaded) {
- zui.dispose();
- container.stop();
- }
- }
- }
- } catch (SocketTimeoutException stw) {
- log("Powerbot is currently being DDoS'd!");
- u.paint.useAdvancedPaint = false;
- } catch (Exception e) {
- log(e.getMessage());
- u.paint.useAdvancedPaint = false;
- }
- }
- }
- // private class Banking {
- //
- // boolean bankingEnabled = false;
- // boolean depositLoot = false;
- // boolean depositBones = false;
- // boolean withdrawFood = false;
- //
- // boolean needBankforFood = false;
- // int minimumFood = 5;
- // int maximumFood = 7;
- //
- // boolean shouldWalkHome = false;
- // boolean isInBank = false;
- //
- //
- // private boolean needsBank() {
- // if(bankingEnabled) {
- // if(depositLoot && Inventory.getCount(false) == 28 && !u.loot.getLootTaken().isEmpty() || needBankforFood) {
- // if (needBankforFood && !u.eat.haveFood()) {
- // return true;
- // }
- // int iii = 0;
- // boolean containsBones = false;
- // for(Map.Entry<String, Integer> entry : u.loot.getLootTaken().entrySet()) {
- // if(entry.getKey().contains("Bones")) {
- // containsBones = true;
- // }
- // iii++;
- // }
- //
- // if(iii == 1 && containsBones && !u.bank.depositBones) {
- // return false;
- // }
- // return true;
- // }
- // }
- // return false;
- // }
- //
- // private void withdraw() {
- // if(Inventory.getCount(false) < 28 && !u.eat.haveFood() && u.eat.foodOfChoice != null) {
- // Item bankItem = Bank.getItem(u.eat.foodOfChoice.getID());
- // if (bankItem == null || bankItem.getID() == -1) {
- // log(Color.RED, "Banking Error!");
- // container.stop();
- // }
- // assert bankItem != null;
- // InterfaceComponent bankItemComponent = bankItem.getComponent();
- // if (bankItemComponent == null) {
- // log(Color.RED, "Banking Error!");
- // container.stop();
- // }
- // int t = 0;
- // assert bankItemComponent != null;
- // while (bankItemComponent.getRelativeX() == 0 && Bank.getCurrentTab() != 0 && t < 5) {
- // if (Interfaces.getComponent(Bank.INTERFACE_BANK, Bank.INTERFACE_BANK_TAB[0]).click()) {
- // sleep(random(800, 1300));
- // }
- // t++;
- // }
- // if (!Interfaces.scrollTo(bankItemComponent, (Bank.INTERFACE_BANK << 16) + Bank.INTERFACE_BANK_SCROLLBAR)) {
- // log(Color.RED, "Banking Error!");
- // container.stop();
- // }
- // boolean withdrew = false;
- // for(int iii = 0; iii < 10; iii++) {
- // bankItemComponent.click(false);
- // if(Menu.isOpen()) {
- // int origCount = Inventory.getCount(true);
- // bankItemComponent.interact("Withdraw-X");
- // sleep(1000);
- // Keyboard.sendText(String.valueOf(random(minimumFood, maximumFood)), true);
- // if(waitForInvChange(origCount, 5000)) {
- // withdrew = true;
- // break;
- // } else {
- // Keyboard.sendText("", true);
- // }
- // }
- // }
- // if(!withdrew) {
- // log(Color.RED, "Banking Error!");
- // container.stop();
- // }
- // needBankforFood = false;
- // }
- // }
- //
- // private void deposit() {
- // Set<Map.Entry<String, Integer>> entries = u.loot.getLootTaken().entrySet();
- // Item[] items = Inventory.getItems();
- // ArrayList<Integer> alreadyDeposited = new ArrayList<Integer>();
- // for(Map.Entry<String, Integer> entry : entries) {
- // for(Item item : items) {
- // if(item != null && item.getID() != -1 && !alreadyDeposited.contains(item.getID())) {
- // if (item.getName().equals(entry.getKey())) {
- // if(!item.getName().contains("Bones") || (item.getName().contains("Bones") && u.bank.depositBones)) {
- // int origCount = Inventory.getCount(true);
- // int itemCount = Inventory.getCount(true, item.getID());
- // boolean deposited = false;
- //
- // InterfaceComponent freeSpace, freeItems, memSpace, memItems;
- //
- // freeSpace = Interfaces.getComponent(762, 29);
- // freeItems = Interfaces.getComponent(762, 30);
- //
- // memSpace = Interfaces.getComponent(762, 31);
- // memItems = Interfaces.getComponent(762, 32);
- //
- // if(freeSpace.getText().equals(freeItems.getText())
- // || memSpace.getText().equals(memItems.getText())) {
- // log(Color.RED, "You Ran Out Of Bank Space! Stopping Script!");
- // container.stop();
- // }
- //
- // for(int iii = 0; iii < 10; iii++) {
- // item.interact(itemCount > 1 ? "Deposit-All" : "Deposit");
- // if(waitForInvChange(origCount, 5000)) {
- // deposited = true;
- // break;
- // }
- // }
- //
- // if(deposited) {
- // alreadyDeposited.add(item.getID());
- // } else {
- // log(Color.RED, "Banking Error!");
- // container.stop();
- // }
- // }
- // }
- // }
- // }
- // }
- // }
- //
- // }
- private class Tiles {
- ArrayList<Tile> badTiles = new ArrayList<Tile>();
- int threshold = 5;
- public void addBadTile(Tile tile) {
- addBadTile(tile, threshold);
- }
- public void addBadTile(Tile tile, int thres) {
- if(thres > -1) {
- if (badTiles.size() > 0) {
- ArrayList<Tile> tilesWithinRadius = new ArrayList<Tile>();
- for(Tile badTile : badTiles) {
- if(Calculations.distanceBetween(badTile, tile) < thres) {
- tilesWithinRadius.add(badTile);
- }
- }
- if (tilesWithinRadius.size() > 1){
- tilesWithinRadius.add(tile);
- Area temp = new Area(tilesWithinRadius.toArray(new Tile[tilesWithinRadius.size()]));
- Tile[] areaTiles = temp.getTileArray();
- for(Tile tileToAdd : areaTiles) {
- if(!badTiles.contains(tileToAdd)) {
- badTiles.add(tileToAdd);
- }
- }
- if(!badTiles.contains(tile)) {
- badTiles.add(tile);
- }
- } else {
- if(!badTiles.contains(tile)) {
- badTiles.add(tile);
- }
- }
- } else {
- badTiles.add(tile);
- }
- }
- }
- @SuppressWarnings({"BooleanMethodIsAlwaysInverted"})
- private boolean NPCisOnBadTile(NPC t) {
- for(Tile badTile: badTiles) {
- if(t.getLocation().getX() == badTile.getX() &&
- t.getLocation().getY() == badTile.getY() ) {
- return true;
- }
- }
- return false;
- }
- }
- @SuppressWarnings({"serial", "ResultOfMethodCallIgnored"})
- private class ZUI extends JFrame {
- private final File file = new File(Configuration.Paths.getStorageDirectory() + File.separator + "RFighter.txt");
- private JCheckBox useMulti, useRadius, useSafe, useCentral, disableSpecials, prioritizeLoot, onlyLoot, useBones,
- useOldPaint/**, depositLoot, depositBones, withdrawFood, enableBanking**/;
- private JTextField npcBox, lootBox, alchBox, mouseSpeedBox, thresholdBox/**, foodBox**/;
- private JButton start;
- private ZUI() {
- init();
- pack();
- }
- private void init() {
- Properties props = loadProperties();
- JPanel north = new JPanel(new FlowLayout());
- north.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
- {
- JLabel title = new JLabel("Renatus Fighter");
- title.setFont(new Font("Arial", Font.PLAIN, 24));
- north.add(title);
- }
- add(north, BorderLayout.NORTH);
- JPanel center = new JPanel();
- center.setLayout(new BoxLayout(center, BoxLayout.PAGE_AXIS));
- center.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
- {
- JPanel combat = new JPanel();
- combat.setLayout(new BoxLayout(combat, BoxLayout.PAGE_AXIS));
- combat.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
- {
- JLabel title = new JLabel("Combat");
- JLabel npcLabel = new JLabel("Enter the names/ ids of the monsters to fight");
- npcBox = new JTextField("barbarian,278,dragon");
- useMulti = new JCheckBox("Attack monsters that are fighting others");
- useRadius = new JCheckBox("Stay within a radius (Applies to loot too.)");
- useSafe = new JCheckBox("Use a safespot");
- useCentral = new JCheckBox("Use central point on NPC");
- disableSpecials = new JCheckBox("Disable special attacks");
- title.setAlignmentX(JLabel.CENTER_ALIGNMENT);
- npcLabel.setAlignmentX(JLabel.CENTER_ALIGNMENT);
- npcBox.setAlignmentX(JTextField.CENTER_ALIGNMENT);
- useMulti.setAlignmentX(JCheckBox.CENTER_ALIGNMENT);
- useRadius.setAlignmentX(JCheckBox.CENTER_ALIGNMENT);
- useSafe.setAlignmentX(JCheckBox.CENTER_ALIGNMENT);
- useCentral.setAlignmentX(JCheckBox.CENTER_ALIGNMENT);
- disableSpecials.setAlignmentX(JCheckBox.CENTER_ALIGNMENT);
- npcBox.setMaximumSize(new Dimension(Integer.MAX_VALUE, npcBox.getPreferredSize().height));
- npcBox.setColumns(25);
- if (props.getProperty("npcBox") != null) {
- npcBox.setText(props.getProperty("npcBox"));
- }
- if (props.getProperty("useMulti") != null) {
- if (props.getProperty("useMulti").equals("true"))
- useMulti.setSelected(true);
- }
- if (props.getProperty("useRadius") != null) {
- if (props.getProperty("useRadius").equals("true"))
- useRadius.setSelected(true);
- }
- if(props.getProperty("useSafe") != null) {
- if(props.getProperty("useSafe").equals("true"))
- useSafe.setSelected(true);
- }
- if(props.getProperty("useCentral") != null) {
- if(props.getProperty("useCentral").equals("true"))
- useCentral.setSelected(true);
- }
- if(props.getProperty("disableSpecials") != null) {
- if(props.get("disableSpecials").equals("true"))
- disableSpecials.setSelected(true);
- }
- combat.add(title);
- combat.add(new JLabel(" "));
- combat.add(npcLabel);
- combat.add(npcBox);
- combat.add(new JLabel(" "));
- combat.add(useMulti);
- combat.add(useRadius);
- combat.add(useSafe);
- combat.add(useCentral);
- combat.add(disableSpecials);
- combat.add(Box.createVerticalGlue());
- combat.add(Box.createRigidArea(new Dimension(1,1)));
- }
- JPanel loot = new JPanel();
- loot.setLayout(new BoxLayout(loot, BoxLayout.PAGE_AXIS));
- loot.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
- {
- JLabel title = new JLabel("Loot");
- JLabel lootLabel = new JLabel("Enter the names/ ids of the loot to pick up");
- lootBox = new JTextField("arrow,rune");
- prioritizeLoot = new JCheckBox("Loot while fighting");
- onlyLoot = new JCheckBox("Only loot from monsters you kill");
- title.setAlignmentX(JLabel.CENTER_ALIGNMENT);
- lootLabel.setAlignmentX(JLabel.CENTER_ALIGNMENT);
- lootBox.setAlignmentX(JTextField.CENTER_ALIGNMENT);
- prioritizeLoot.setAlignmentX(JCheckBox.CENTER_ALIGNMENT);
- onlyLoot.setAlignmentX(JCheckBox.CENTER_ALIGNMENT);
- lootBox.setMaximumSize(new Dimension(Integer.MAX_VALUE, lootBox.getPreferredSize().height));
- lootBox.setColumns(25);
- if (props.getProperty("lootBox") != null) {
- lootBox.setText(props.getProperty("lootBox"));
- }
- if(props.getProperty("onlyLoot") != null) {
- if(props.get("onlyLoot").equals("true"))
- onlyLoot.setSelected(true);
- }
- if(props.getProperty("prioritizeLoot") != null) {
- if(props.get("prioritizeLoot").equals("true"))
- prioritizeLoot.setSelected(true);
- }
- loot.add(title);
- loot.add(new JLabel(" "));
- loot.add(lootLabel);
- loot.add(lootBox);
- loot.add(new JLabel(" "));
- loot.add(prioritizeLoot);
- loot.add(onlyLoot);
- loot.add(Box.createVerticalGlue());
- loot.add(Box.createRigidArea(new Dimension(1,1)));
- }
- // JPanel bank = new JPanel();
- // bank.setLayout(new BoxLayout(bank, BoxLayout.PAGE_AXIS));
- // bank.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
- // {
- // JLabel title = new JLabel("Bank");
- // JLabel bankLabel1 = new JLabel("WARNING: EXPERIMENTAL");
- // JLabel bankLabel2 = new JLabel("ONLY WORKS ON GROUND LEVEL");
- //
- // enableBanking = new JCheckBox("Enable banking");
- // depositLoot = new JCheckBox("Deposit Loot");
- // depositBones = new JCheckBox("Deposit Bones");
- // withdrawFood = new JCheckBox("Withdraw Food");
- // foodBox = new JTextField("5,7");
- //
- // title.setAlignmentX(JLabel.CENTER_ALIGNMENT);
- // bankLabel1.setAlignmentX(JLabel.CENTER_ALIGNMENT);
- // bankLabel2.setAlignmentX(JLabel.CENTER_ALIGNMENT);
- // enableBanking.setAlignmentX(JCheckBox.CENTER_ALIGNMENT);
- // depositLoot.setAlignmentX(JCheckBox.CENTER_ALIGNMENT);
- // depositBones.setAlignmentX(JCheckBox.CENTER_ALIGNMENT);
- // withdrawFood.setAlignmentX(JCheckBox.CENTER_ALIGNMENT);
- // foodBox.setAlignmentX(JTextField.CENTER_ALIGNMENT);
- //
- // foodBox.setMaximumSize(new Dimension(Integer.MAX_VALUE, foodBox.getPreferredSize().height));
- // foodBox.setColumns(25);
- //
- // enableBanking.addActionListener(disableAllBankingOptions);
- // depositLoot.addActionListener(disableDepositBones);
- // withdrawFood.addActionListener(disableFoodBox);
- //
- // if (props.getProperty("depositLoot") != null) {
- // if (props.getProperty("depositLoot").equals("true"))
- // depositLoot.setSelected(true);
- // }
- //
- // if (props.getProperty("depositBones") != null) {
- // if (props.getProperty("depositBones").equals("true"))
- // depositBones.setSelected(true);
- // }
- //
- // if (props.getProperty("withdrawFood") != null) {
- // if (props.getProperty("withdrawFood").equals("true")) {
- // withdrawFood.setSelected(true);
- // foodBox.setEnabled(true);
- // } else {
- // foodBox.setEnabled(false);
- // }
- // }
- //
- // if (props.getProperty("enableBanking") != null) {
- // if (props.getProperty("enableBanking").equals("true")) {
- // enableBanking.setSelected(true);
- // } else {
- // depositLoot.setSelected(false);
- // depositBones.setSelected(false);
- // withdrawFood.setSelected(false);
- // depositLoot.setEnabled(false);
- // depositBones.setEnabled(false);
- // withdrawFood.setEnabled(false);
- // foodBox.setEnabled(false);
- // }
- // } else {
- // depositLoot.setSelected(false);
- // depositBones.setSelected(false);
- // withdrawFood.setSelected(false);
- // depositLoot.setEnabled(false);
- // depositBones.setEnabled(false);
- // withdrawFood.setEnabled(false);
- // foodBox.setEnabled(false);
- // }
- //
- // bank.add(title);
- // bank.add(new JLabel(" "));
- // bank.add(bankLabel1);
- // bank.add(bankLabel2);
- // bank.add(new JLabel(" "));
- // bank.add(enableBanking);
- // bank.add(new JLabel(" "));
- // bank.add(depositLoot);
- // bank.add(depositBones);
- // bank.add(new JLabel(" "));
- // bank.add(withdrawFood);
- // bank.add(foodBox);
- // bank.add(Box.createVerticalGlue());
- // bank.add(Box.createRigidArea(new Dimension(1,1)));
- // }
- JPanel misc = new JPanel();
- misc.setLayout(new BoxLayout(misc, BoxLayout.PAGE_AXIS));
- misc.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
- {
- JLabel miscLabel = new JLabel("Miscellaneous Settings");
- JLabel mouseLabel = new JLabel("Mouse Speed: Lower = Faster");
- mouseSpeedBox = new JTextField("4,7");
- JLabel thresholdLabel = new JLabel("Threshold for bad tile checking: -1 to turn off");
- thresholdBox = new JTextField("5");
- JLabel alchLabel = new JLabel("Enter the ids/ names of items to alch");
- alchBox = new JTextField("");
- useBones = new JCheckBox("Bury the bones you loot");
- useOldPaint = new JCheckBox("Use simple paint");
- miscLabel.setAlignmentX(JLabel.CENTER_ALIGNMENT);
- mouseLabel.setAlignmentX(JLabel.CENTER_ALIGNMENT);
- mouseSpeedBox.setAlignmentX(JTextField.CENTER_ALIGNMENT);
- thresholdLabel.setAlignmentX(JLabel.CENTER_ALIGNMENT);
- thresholdBox.setAlignmentX(JLabel.CENTER_ALIGNMENT);
- alchLabel.setAlignmentX(JLabel.CENTER_ALIGNMENT);
- alchBox.setAlignmentX(JLabel.CENTER_ALIGNMENT);
- useBones.setAlignmentX(JCheckBox.CENTER_ALIGNMENT);
- useOldPaint.setAlignmentX(JCheckBox.CENTER_ALIGNMENT);
- mouseSpeedBox.setMaximumSize(new Dimension(Integer.MAX_VALUE, mouseSpeedBox.getPreferredSize().height));
- thresholdBox.setMaximumSize(new Dimension(Integer.MAX_VALUE, thresholdBox.getPreferredSize().height));
- alchBox.setMaximumSize(new Dimension(Integer.MAX_VALUE, alchBox.getPreferredSize().height));
- mouseSpeedBox.setColumns(25);
- thresholdBox.setColumns(25);
- alchBox.setColumns(25);
- if (props.getProperty("mouseSpeed") != null) {
- mouseSpeedBox.setText(props.getProperty("mouseSpeed"));
- }
- if(props.getProperty("useSimplePaint") != null ) {
- if(props.get("useSimplePaint").equals("true"))
- useOldPaint.setSelected(true);
- }
- if (props.getProperty("thresholdBox") != null) {
- thresholdBox.setText(props.getProperty("thresholdBox"));
- }
- if (props.getProperty("alchBox") != null) {
- alchBox.setText(props.getProperty("alchBox"));
- }
- if(props.getProperty("useBones") != null) {
- if(props.get("useBones").equals("true"))
- useBones.setSelected(true);
- }
- if(!u.paint.useAdvancedPaint) {
- useOldPaint.setSelected(true);
- useOldPaint.setEnabled(false);
- }
- misc.add(miscLabel);
- misc.add(new JLabel(" "));
- misc.add(mouseLabel);
- misc.add(mouseSpeedBox);
- misc.add(new JLabel(" "));
- misc.add(thresholdLabel);
- misc.add(thresholdBox);
- misc.add(new JLabel(" "));
- misc.add(alchLabel);
- misc.add(alchBox);
- misc.add(new JLabel(" "));
- misc.add(useBones);
- if(!u.paint.useAdvancedPaint) {
- JLabel ddosLabel1 = new JLabel("Powerbot is currently being DDoS'd");
- JLabel ddosLabel2 = new JLabel("Due to this fact, only simple paint");
- JLabel ddosLabel3 = new JLabel("is available.");
- ddosLabel1.setAlignmentX(JLabel.CENTER_ALIGNMENT);
- ddosLabel2.setAlignmentX(JLabel.CENTER_ALIGNMENT);
- ddosLabel3.setAlignmentX(JLabel.CENTER_ALIGNMENT);
- misc.add(new JLabel(" "));
- misc.add(ddosLabel1);
- misc.add(ddosLabel2);
- misc.add(ddosLabel3);
- }
- misc.add(useOldPaint);
- }
- JTabbedPane tabbedPane = new JTabbedPane();
- tabbedPane.addTab("Combat", combat);
- tabbedPane.addTab("Loot", loot);
- // tabbedPane.addTab("Bank", bank);
- tabbedPane.addTab("Misc.", misc);
- center.add(tabbedPane);
- }
- add(center, BorderLayout.CENTER);
- JPanel south = new JPanel(new FlowLayout());
- south.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
- {
- start = new JButton("Start script!");
- start.setAlignmentX(JButton.CENTER_ALIGNMENT);
- start.addActionListener(onStart);
- south.add(start);
- }
- add(south, BorderLayout.SOUTH);
- setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
- setTitle("RFighter GUI");
- }
- private Properties loadProperties() {
- try {
- if (!file.exists())
- file.createNewFile();
- Properties p = new Properties();
- p.load(new FileInputStream(file));
- return p;
- } catch (Exception e) {
- e.printStackTrace();
- }
- return null;
- }
- private void saveProperties() {
- Properties p = new Properties();
- p.put("mouseSpeed", mouseSpeedBox.getText());
- p.put("npcBox", npcBox.getText());
- p.put("lootBox", lootBox.getText());
- p.put("alchBox", alchBox.getText());
- p.put("useMulti", Boolean.toString(useMulti.isSelected()));
- p.put("useRadius", Boolean.toString(useRadius.isSelected()));
- p.put("useSafe", Boolean.toString(useSafe.isSelected()));
- p.put("useCentral", Boolean.toString(useCentral.isSelected()));
- p.put("useBones", Boolean.toString(useBones.isSelected()));
- p.put("disableSpecials", Boolean.toString(disableSpecials.isSelected()));
- p.put("onlyLoot", Boolean.toString(onlyLoot.isSelected()));
- p.put("prioritizeLoot", Boolean.toString(prioritizeLoot.isSelected()));
- p.put("useSimplePaint", Boolean.toString(useOldPaint.isSelected()));
- // p.put("enableBanking", Boolean.toString(enableBanking.isSelected()));
- // p.put("depositLoot", Boolean.toString(depositLoot.isSelected()));
- // p.put("depositBones", Boolean.toString(depositBones.isSelected()));
- // p.put("withdrawFood", Boolean.toString(withdrawFood.isSelected()));
- // p.put("foodBox", foodBox.getText());
- p.put("thresholdBox", thresholdBox.getText());
- try {
- p.store(new FileOutputStream(file), "");
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- private ActionListener onStart = new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- saveProperties();
- startScript = true;
- mouseSpeedMin = Integer.parseInt(mouseSpeedBox.getText().split(",")[0]);
- mouseSpeedMax = Integer.parseInt(mouseSpeedBox.getText().split(",")[1]);
- utilizeMultiwayCombat = useMulti.isSelected();
- onlyInRadius = useRadius.isSelected();
- useSafespot = useSafe.isSelected();
- useCentralClicking = useCentral.isSelected();
- buryBones = useBones.isSelected();
- u.loot.onlyTakeLootFromKilled = onlyLoot.isSelected();
- u.tiles.threshold = Integer.parseInt(thresholdBox.getText());
- u.paint.useAdvancedPaint = !useOldPaint.isSelected();
- u.npcs.disableSpecials = disableSpecials.isSelected();
- // u.bank.bankingEnabled = enableBanking.isSelected();
- // u.bank.depositLoot = depositLoot.isSelected();
- // u.bank.depositBones = depositBones.isSelected();
- // u.bank.withdrawFood = withdrawFood.isSelected();
- // u.bank.minimumFood = Integer.parseInt(foodBox.getText().split(",")[0]);
- // u.bank.maximumFood = Integer.parseInt(foodBox.getText().split(",")[1]);
- RFighter.this.prioritizeLoot = prioritizeLoot.isSelected();
- if (onlyInRadius) {
- u.npcs.maxRadius = Integer.parseInt(JOptionPane.showInputDialog("Enter the max radius. Example: 10"));
- }
- String[] ids = npcBox.getText().split(",");
- ArrayList<Integer> idList = new ArrayList<Integer>();
- ArrayList<String> nameList = new ArrayList<String>();
- for (String id3 : ids) {
- if (id3 != null && !id3.equals("")) {
- try {
- int id = Integer.parseInt(id3);
- idList.add(id);
- } catch (Exception e1) {
- nameList.add(id3);
- }
- }
- }
- u.npcs.npcIDs = idList.size() > 0 ? toIntArray(idList.toArray(new Integer[idList.size()])) : new int[0];
- u.npcs.npcNames = nameList.size() > 0 ? nameList.toArray(new String[nameList.size()]) : new String[0];
- ids = lootBox.getText().split(",");
- idList = new ArrayList<Integer>();
- nameList = new ArrayList<String>();
- for (String id2 : ids) {
- if (id2 != null && !id2.equals("")) {
- try {
- int id = Integer.parseInt(id2);
- idList.add(id);
- } catch (Exception e1) {
- nameList.add(id2);
- }
- }
- }
- u.loot.lootIDs = idList.size() > 0 ? toIntArray(idList.toArray(new Integer[idList.size()])) : new int[0];
- u.loot.lootNames = nameList.size() > 0 ? nameList.toArray(new String[nameList.size()]) : new String[0];
- ids = alchBox.getText().split(",");
- idList = new ArrayList<Integer>();
- nameList = new ArrayList<String>();
- for (String id1 : ids) {
- if (id1 != null && !id1.equals("")) {
- try {
- int id = Integer.parseInt(id1);
- idList.add(id);
- } catch (Exception e1) {
- nameList.add(id1.toLowerCase());
- }
- }
- }
- u.alch.alchIDs = idList.size() > 0 ? toIntArray(idList.toArray(new Integer[idList.size()])) : new int[0];
- u.alch.alchNames = nameList.size() > 0 ? nameList.toArray(new String[nameList.size()]) : new String[0];
- dispose();
- }
- };
- // private ActionListener disableAllBankingOptions = new ActionListener() {
- // public void actionPerformed(ActionEvent e) {
- // AbstractButton abstractButton = (AbstractButton) e.getSource();
- // boolean selected = abstractButton.getModel().isSelected();
- //
- // if(selected) {
- //
- // withdrawFood.setEnabled(selected);
- // depositLoot.setEnabled(selected);
- // } else {
- // withdrawFood.setSelected(selected);
- // depositLoot.setSelected(selected);
- // depositBones.setSelected(selected);
- // withdrawFood.setEnabled(selected);
- // depositLoot.setEnabled(selected);
- // depositBones.setEnabled(selected);
- // foodBox.setEnabled(selected);
- // }
- // }
- // };
- // private ActionListener disableDepositBones = new ActionListener() {
- // public void actionPerformed(ActionEvent e) {
- // AbstractButton abstractButton = (AbstractButton) e.getSource();
- // boolean selected = abstractButton.getModel().isSelected();
- // depositBones.setEnabled(selected);
- // }
- // };
- //
- // private ActionListener disableFoodBox = new ActionListener() {
- // public void actionPerformed(ActionEvent e) {
- // AbstractButton abstractButton = (AbstractButton) e.getSource();
- // boolean selected = abstractButton.getModel().isSelected();
- // foodBox.setEnabled(selected);
- // }
- // };
- private int[] toIntArray(Integer[] ints) {
- int[] done = new int[ints.length];
- for (int i = 0; i < done.length; i++) {
- done[i] = ints[i];
- }
- return done;
- }
- }
- public void mouseClicked(MouseEvent e) {
- InterfaceComponent inter = Interfaces.get(137).getComponent(0);
- int x = inter.getLocation().x;
- int y = inter.getLocation().y;
- if (inter.contains(e.getPoint())) {
- u.paint.showPaint = !u.paint.showPaint;
- }
- Polygon mainRibbonPoly =
- new Polygon(
- new int[] {x, x, x + 80, x + 160, x + 160},
- new int[] {y - 325, y - 325 + 52, y - 325 + 97, y - 325 + 52, y - 325},
- 5);
- Polygon skillsRibbonPoly =
- new Polygon(
- new int[] {x, x, x + 80, x + 160, x + 160},
- new int[] {y - 225, y - 225 + 52, y - 225 + 97, y - 225 + 52, y - 225},
- 5);
- Polygon lootRibbonPoly =
- new Polygon(
- new int[] {x, x, x + 80, x + 160, x + 160},
- new int[] {y - 125, y - 125 + 52, y - 125 + 97, y - 125 + 52, y - 125},
- 5);
- if(mainRibbonPoly.contains(e.getPoint())) {
- u.paint.showMain = true;
- u.paint.showSkills = false;
- u.paint.showLoot = false;
- }
- if(skillsRibbonPoly.contains(e.getPoint())) {
- u.paint.showMain = false;
- u.paint.showSkills = true;
- u.paint.showLoot = false;
- }
- if(lootRibbonPoly.contains(e.getPoint())) {
- u.paint.showMain = false;
- u.paint.showSkills = false;
- u.paint.showLoot = true;
- }
- }
- public void mousePressed(MouseEvent e) {}
- public void mouseReleased(MouseEvent e) {}
- public void mouseEntered(MouseEvent e) {}
- public void mouseExited(MouseEvent e) {}
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement