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 javax.tools.DiagnosticCollector;
- import javax.tools.*;
- import org.rsbot.event.events.MessageEvent;
- import org.rsbot.script.Script;
- import org.rsbot.event.listeners.MessageListener;
- import org.rsbot.event.listeners.PaintListener;
- import org.rsbot.script.ScriptManifest;
- import org.rsbot.script.methods.*;
- import org.rsbot.script.util.Filter;
- import org.rsbot.script.util.Timer;
- import org.rsbot.script.wrappers.*;
- import org.rsbot.Configuration;
- import org.rsbot.util.io.HttpClient;
- /**
- * Change log:
- * v2.70: MOAR CODE OPTIMIZATIONS!!111, Screenshot sender
- * v2.60: Added Garbage Collector, loot above X value, improved GE checker, code optimization, fixed prayer potions, fix for 2.6.23
- * v2.53: Fixed AutoUpdater
- * v2.52: Fixed LootLoop Error for like the gazillionth time >.<
- * v2.51: Fixed LootLoop Error.... again!
- * v2.50: Room Generation, fixed paint
- * 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 = "TFighterEE", authors = "!@!@! And Zalgo2462", keywords = {"combat", "money", "universal", "fighter", "!@!@!", "Zalgo2462"}, version = 2.70,
- description = "TFighter by !@!@! with additions by Zalgo2462", website = "http://www.powerbot.org/community/topic/444458-tfighteree-the-original-tfighter-but-with-enhancements-approved-by/")
- public class TFighterEE extends Script implements PaintListener, MouseListener, MessageListener {
- private final String branch = "Stable";
- private final static ScriptManifest mani = TFighterEE.class.getAnnotation(ScriptManifest.class);
- private final Util u = new Util();
- private RSTile startTile;
- private long nextAntiban = 0;
- private int badFoodCount = 0;
- private int startTime = 0;
- private int mouseSpeedMin = 4, mouseSpeedMax = 7;
- private boolean startScript;
- 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;
- private Timer gcTimer;
- public boolean onStart() {
- if (!game.isLoggedIn()) {
- log("Start logged in.");
- return false;
- }
- u.vChecker.start();
- u.paint.showPaint = true;
- u.paint.showMain = true;
- 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 = getMyPlayer().getLocation();
- if(u.bank.bankingEnabled) {
- if(startTile.getZ() == 0){
- RSTile bankTile = web.getNearestBank();
- if(bankTile.getX() == 3382 && bankTile.getY() == 3270) {
- bankTile = new RSTile(3269, 3167);
- }
- webToBank = web.getWeb(startTile, bankTile);
- webToStart = web.getWeb(bankTile, startTile);
- } else {
- log("Banking only works on ground level.");
- u.bank.bankingEnabled = false;
- }
- }
- if(u.rooms.instantiateGenerator())
- u.rooms.generator.start();
- 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));
- System.gc();
- gcTimer = new Timer(1000 * 60 * 5);
- return true;
- }
- public void onFinish() {
- sendScreenShot();
- if(u.rooms.generator != null) {
- if(u.rooms.generator.isAlive()) {
- u.rooms.generator.safeStop();
- }
- }
- }
- @Override
- public int loop() {
- if (!gcTimer.isRunning()) {
- System.gc();
- gcTimer.reset();
- }
- 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.Tab.EQUIPMENT);
- equipment.getItem(Equipment.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.getTab() != Game.Tab.INVENTORY) {
- game.openTab(Game.Tab.INVENTORY);
- return random(700, 1500);
- }
- //banking
- if (u.bank.bankingEnabled) {
- if (u.bank.shouldWalkHome) {
- if(calc.distanceTo(startTile) > 5) {
- if(webToStart != null) {
- webToStart.step();
- sleep(random(1500, 2000));
- if(!players.getMyPlayer().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(calc.distanceTo(web.getNearestBank()) > 5 ) {
- if(webToBank != null) {
- webToBank.step();
- sleep(random(1500, 2000));
- if(!players.getMyPlayer().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.getCurrentLevel(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.");
- stopScript();
- }
- }
- return random(1200, 1600);
- }
- //potions and prayer
- u.pot.usePotions();
- if(u.pot.getPotions().get("PRAYER").length != 0 && !prayer.isQuickPrayerOn() && u.pot.setQuickPrayer) {
- prayer.setQuickPrayer(true);
- }
- //arrow equipping
- if(u.npcs.weapon != null && u.npcs.ammo != null) {
- if(u.npcs.weapon.toLowerCase().contains("bow")) {
- for(RSItem 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 {
- private RSNPC interacting;
- public int loop() {
- if( u.npcs.useSpecial() && !combat.isSpecialEnabled() && !interacting.isDead()) {
- sleep(random(500, 1000));
- combat.setSpecialAttack(true);
- }
- if(u.loot.onlyTakeLootFromKilled) {
- if(!u.npcs.tilesFoughtOn.contains(interacting.getLocation())
- && !interacting.isMoving()) {
- u.npcs.tilesFoughtOn.add(interacting.getLocation());
- }
- }
- antiban();
- return random(50, 200);
- }
- public boolean activate() {
- return u.npcs.isInCombat() && (interacting = u.npcs.getInteracting()) != null;
- }
- }
- private class AttackLoop implements LoopAction {
- public int loop() {
- RSNPC inter = u.npcs.getInteracting();
- RSNPC n = inter != null ? inter : u.npcs.getNPC();
- if (n != null) {
- if(random(0, 4) == 3 )
- camera.turnTo(n);
- 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 (calc.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 (!calc.tileOnScreen(startTile) ? walking.walkTileMM(startTile) : tiles.interact(startTile, "Walk")) {
- waitWhileMoving();
- return random(200, 500);
- }
- return random(80, 120);
- }
- public boolean activate() {
- return useSafespot && calc.distanceTo(startTile) > 0;
- }
- }
- private class LootLoop implements LoopAction {
- private RSGroundItem 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(RSItem 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() {
- RSItem bone = inventory.getItem(BONE_IDS);
- if(bone != null) {
- if(bone.getID() != -1) {
- int n = inventory.getCount(true);
- bone.doClick(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 {
- private int BUNYIP_POUCH = 12029;
- public int loop() {
- inventory.getItem(BUNYIP_POUCH).interact("Summon");
- return random(3000, 5000);
- }
- public boolean activate() {
- return !summoning.isFamiliarSummoned() && inventory.contains(BUNYIP_POUCH) && summoning.getSummoningPoints() > 0;
- }
- }
- private void waitWhileMoving() {
- long start = System.currentTimeMillis();
- while (System.currentTimeMillis() - start < 1500 && !getMyPlayer().isMoving()) {
- sleep(random(50, 200));
- }
- while (getMyPlayer().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 && getMyPlayer().getAnimation() == -1
- && (System.currentTimeMillis() - timer < 1000 || getMyPlayer().getInteracting() != null))
- sleep(random(50, 100));
- }
- private void sendScreenShot(){
- try {
- int time = (int)System.currentTimeMillis() - startTime;
- if(time > 5 * 60 * 1000) {
- log("Sending Proggie. Please Wait.");
- BufferedImage image = getProggie();
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- ImageIO.write(image, "png", baos);
- byte[] byteArray = baos.toByteArray();
- String base64 = new sun.misc.BASE64Encoder().encode(byteArray);
- String imageData = URLEncoder.encode("image", "UTF-8") + "=" + URLEncoder.encode(base64 , "UTF-8");
- imageData += "&" + URLEncoder.encode("time", "UTF-8") + "=" + time;
- URL server = new URL("http://tfighter.pcriot.com/sc.php");
- URLConnection conn = server.openConnection();
- conn.setRequestProperty("User-Agent", "TFighter");
- conn.setDoOutput(true);
- OutputStreamWriter wr = new OutputStreamWriter(conn.getOutputStream());
- wr.write(imageData);
- wr.flush();
- BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));
- String line;
- while((line = rd.readLine()) != null) {
- log(line);
- }
- }
- } catch (Exception e) {
- log("Failure: " + e.getMessage());
- }
- }
- 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, 14);
- if(decision < 5) {
- keyThread.start();
- sleep(random(0, 600));
- mouseThread.start();
- } else if (decision < 11) {
- mouseThread.start();
- sleep(random(0, 600));
- keyThread.start();
- } else if (decision == 13) {
- Game.Tab tab = game.getTab();
- game.openTab(Game.Tab.STATS);
- long timer = System.currentTimeMillis();
- while(tab == game.getTab() && System.currentTimeMillis() - timer < 1000) {
- sleep(random(50, 90));
- }
- int decision2 = random (1, 4);
- if(decision2 == 1)
- skills.doHover(1);
- else if (decision2 == 2)
- skills.doHover(4);
- else if (decision2 == 3)
- skills.doHover(22);
- sleep(random(1500, 2000));
- }
- 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
- RSComponent 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) {
- u.tiles.drawBadTiles(g, Color.RED);
- g.setColor(Color.WHITE);
- g.setFont(u.paint.KellyAnnGothic.deriveFont(Font.PLAIN, 18));
- g.drawImage(u.paint.ribbon, xx, yy - 325, null);
- g.drawString("TFighterEE", xx + 25, 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);
- 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("TFighter Enhanced Edition (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.getPercentToNextLevel(Skills.ATTACK) * 80) / 100);
- if(attackHeight != 0)
- g.fillRect(x + 44, y + (93 - attackHeight), 25, attackHeight);
- int strengthHeight = Math.round((skills.getPercentToNextLevel(Skills.STRENGTH) * 80) / 100);
- if(strengthHeight != 0)
- g.fillRect(x + 109, y + (93 - strengthHeight), 25, strengthHeight);
- int defenseHeight = Math.round((skills.getPercentToNextLevel(Skills.DEFENSE) * 80) / 100);
- if(defenseHeight != 0)
- g.fillRect(x + 174, y + (93 - defenseHeight), 25, defenseHeight);
- int rangedHeight = Math.round((skills.getPercentToNextLevel(Skills.RANGE) * 80) / 100);
- if(rangedHeight != 0)
- g.fillRect(x + 238, y + (93 - rangedHeight), 25, rangedHeight);
- int prayerHeight = Math.round((skills.getPercentToNextLevel(Skills.PRAYER) * 80) / 100);
- if(prayerHeight != 0)
- g.fillRect(x + 304, y + (93 - prayerHeight), 25, prayerHeight);
- int magicHeight = Math.round((skills.getPercentToNextLevel(Skills.MAGIC) * 80) / 100);
- if(magicHeight != 0)
- g.fillRect(x + 370, y + (93 - magicHeight), 25, magicHeight);
- int constitutionHeight = Math.round((skills.getPercentToNextLevel(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.getRealLevel(Skills.ATTACK) + "", x + 20, y + 40);
- g.drawString(skills.getRealLevel(Skills.STRENGTH) + "", x + 85, y + 40);
- g.drawString(skills.getRealLevel(Skills.DEFENSE) + "", x + 150, y + 40);
- g.drawString(skills.getRealLevel(Skills.RANGE) + "", x + 215, y + 40);
- g.drawString(skills.getRealLevel(Skills.PRAYER) + "", x + 280, y + 40);
- g.drawString(skills.getRealLevel(Skills.MAGIC) + "", x + 345, y + 40);
- g.drawString(skills.getRealLevel(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.getExpToNextLevel(Skills.ATTACK)), x + 10, y + 93 + g.getFontMetrics().getMaxAscent());
- g.drawString(numberPostfixer(skills.getExpToNextLevel(Skills.STRENGTH)), x + 110, y + 93 + g.getFontMetrics().getMaxAscent());
- g.drawString(numberPostfixer(skills.getExpToNextLevel(Skills.DEFENSE)), x + 175, y + 93 + g.getFontMetrics().getMaxAscent());
- g.drawString(numberPostfixer(skills.getExpToNextLevel(Skills.RANGE)), x + 238, y + 93 + g.getFontMetrics().getMaxAscent());
- g.drawString(numberPostfixer(skills.getExpToNextLevel(Skills.PRAYER)), x + 305, y + 93 + g.getFontMetrics().getMaxAscent());
- g.drawString(numberPostfixer(skills.getExpToNextLevel(Skills.MAGIC)), x + 370, y + 93 + g.getFontMetrics().getMaxAscent());
- g.drawString(numberPostfixer(skills.getExpToNextLevel(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()) {
- int price;
- if(u.paint.prices.containsKey(entry.getKey())) {
- price = u.paint.prices.get(entry.getKey());
- }
- else {
- price = u.loot.getPrice(entry.getKey());
- u.paint.prices.put(entry.getKey(), price);
- }
- g.drawString(entry.getKey() + " x" + entry.getValue() + " = " + (
- price * entry.getValue()) + " Coins", x + 50, y += g.getFontMetrics().getMaxAscent());
- totalProfit += (price * 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("TFighter Enhanced Edition (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);
- }
- public BufferedImage getProggie() {
- final NumberFormat nf = NumberFormat.getIntegerInstance();
- int runTime = (int) System.currentTimeMillis() - startTime;
- RSComponent inter = interfaces.get(137).getComponent(0);
- BufferedImage image = new BufferedImage(inter.getWidth(), inter.getHeight(), BufferedImage.TYPE_INT_RGB);
- Graphics g = image.createGraphics();
- ((Graphics2D) g).setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
- int x = 0;
- int y = 0;
- 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("TFighter Enhanced Edition (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());
- }
- return image;
- }
- 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.getID() == MessageEvent.MESSAGE_SERVER) {
- 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(RSItem 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 final RoomGeneration rooms = new RoomGeneration();
- }
- private class NPCs {
- private int[] npcIDs = new int[0];
- private String[] npcNames = new String[0];
- private String weapon = "";
- private boolean hasSpecialWeapon = false;
- public String ammo = "";
- public String ring = "";
- private int maxRadius = 10;
- RSNPC lastClickedNPC = null;
- private ArrayList<RSTile> tilesFoughtOn = new ArrayList<RSTile>();
- 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.getSpecialBarEnergy() >= amountUsage[i];
- }
- }
- }
- }
- return false;
- }
- /**
- * Checks if we are in combat.
- *
- * @return True if we are in combat.
- */
- private boolean isInCombat() {
- return getMyPlayer().getInteracting() instanceof RSNPC;
- }
- /**
- * 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(RSNPC 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 || !calc.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);
- 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)) {
- lastClickedNPC = npc;
- return 0;
- }
- }
- }
- } else {
- if(!useSafespot) {
- walking.walkTileMM(closerTile(npc.getLocation(), 1), 2, 2);
- sleep(random(1500, 2000));
- return 1;
- } else {
- int angle = camera.getCharacterAngle(npc);
- if (calc.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 RSModel to check.
- * @return True if any point on the model is on screen.
- */
- private boolean isPartiallyOnScreen(RSModel m) {
- return getPointOnScreen(m, true) != null;
- }
- /**
- * Gets a point on a model that is on screen.
- *
- * @param m The RSModel 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(RSModel m, boolean first) {
- if (m == null)
- return null;
- ArrayList<Point> list = new ArrayList<Point>();
- try {
- Polygon[] tris = m.getTriangles();
- for (Polygon p : tris) {
- for (int j = 0; j < p.xpoints.length; j++) {
- Point pt = new Point(p.xpoints[j], p.ypoints[j]);
- if (calc.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 RSModel.
- *
- * @param m The RSModel to test.
- * @return The rough central point.
- */
- private Point getCentralPoint(RSModel 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(!calc.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 RSTile closerTile(RSTile t, int dist) {
- RSTile loc = getMyPlayer().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 RSTile(newX, newY);
- }
- /**
- * Returns the nearest NPC.
- *
- * @return The nearest NPC that matches the filter.
- */
- private RSNPC getNPC() {
- RSNPC 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 RSNPC getInteracting() {
- RSNPC npc = null;
- int dist = 20;
- for (RSNPC n : npcs.getAll()) {
- if (!isOurNPC(n))
- continue;
- RSCharacter inter = n.getInteracting();
- if (inter != null && inter instanceof RSPlayer && inter.equals(getMyPlayer()) && calc.distanceTo(n) < dist) {
- dist = calc.distanceTo(n);
- npc = n;
- }
- }
- return npc;
- }
- private boolean isOurNPC(RSNPC 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(RSNPC t) {
- if(t.isDead()) {
- RSGroundItem[] GIs = groundItems.getAllAt(t.getLocation());
- long start = System.currentTimeMillis();
- while(t.isDead() && GIs.length == groundItems.getAllAt(t.getLocation()).length
- && System.currentTimeMillis() - start < 5000) {
- sleep(random(20, 70));
- }
- }
- }
- private boolean weaponContains(String... tests) {
- for(String test : tests) {
- if(weapon.toLowerCase().contains(test))
- return true;
- }
- return false;
- }
- /**
- * The filter we use!
- */
- private final Filter<RSNPC> npcFilter = new Filter<RSNPC>() {
- public boolean accept(RSNPC t) {
- return (isOurNPC(t) && t.isValid() && (!onlyInRadius || calc.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<RSNPC> npcOnScreenFilter = new Filter<RSNPC>() {
- public boolean accept(RSNPC 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 RSItem 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() {
- RSItem i = inventory.getItem(B2P_TAB_ID);
- if (i != null)
- i.doClick(true);
- }
- /**
- * Casts B2B.
- */
- private void castB2b() {
- game.openTab(Game.Tab.MAGIC);
- magic.castSpell(Magic.SPELL_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 RSItem of food, or null if none was found.
- */
- private RSItem getFood() {
- for (RSItem 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() {
- RSItem 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.getRealLevel(Skills.CONSTITUTION) * 10)) * 100));
- } catch (Exception e) {
- return 100;
- }
- }
- }
- private class Loot {
- private int[] lootIDs = new int[0];
- private String[] lootNames = new String[0];
- private Map<String, Integer> lootTaken = new HashMap<String, Integer>();
- public boolean lootAbove = false;
- public int lootAboveX = 10000;
- public boolean onlyTakeLootFromKilled = false;
- /**
- * Gets the nearest loot, based on the filter
- *
- * @return The nearest item to loot, or null if none.
- */
- private RSGroundItem 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(RSGroundItem 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 = calc.tileToScreen(item.getLocation(), random(0.48, 0.52), random(0.48, 0.52), 0);
- if (!calc.pointOnScreen(p))
- continue;
- mouse.move(p, 3, 3);
- if (menu.contains(action)) {
- if (menu.getItems()[0].contains(action)) {
- mouse.click(true);
- return 0;
- } else {
- mouse.click(false);
- sleep(random(100, 200));
- if (menu.click(action)) {
- return 0;
- }
- }
- }
- }
- } else {
- walking.walkTileMM(walking.getClosestTileOnMap(item.getLocation()));
- sleep(random(1500, 2000));
- 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;
- }
- public int getPrice(String itemName) {
- try {
- if(itemName.toLowerCase().contains("coin"))
- return 1;
- itemName = itemName.replace(' ', '+');
- URL url = new URL("http://rscript.org/lookup.php?type=ge&search=" + itemName);
- BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream()));
- String inputLine;
- int price = 0;
- while ((inputLine = in.readLine()) != null) {
- if (inputLine.contains(itemName.replace('+', '_'))) {
- String words[] = inputLine.split(" ");
- price = Integer.parseInt(words[4]);
- }
- }
- in.close();
- return price;
- } catch (Exception e) {
- return -1;
- }
- }
- private final Filter<RSGroundItem> lootFilter = new Filter<RSGroundItem>() {
- public boolean accept(RSGroundItem t) {
- //Skip if we can't hold it
- RSItem 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 && calc.distanceBetween(t.getLocation(), startTile) > u.npcs.maxRadius
- || calc.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(lootAbove) {
- int price;
- if(u.paint.prices.containsKey(name)) {
- price = u.paint.prices.get(name);
- } else {
- price = getPrice(name);
- log(name + ": " + price);
- u.paint.prices.put(name, price);
- }
- if(t.getItem().getStackSize() > 1) {
- price *= t.getItem().getStackSize();
- }
- if(price >= lootAboveX)
- good = true;
- }
- if(good && u.tiles.groundItemIsOnBadTile(t)) {
- good = false;
- }
- if(good && onlyTakeLootFromKilled) {
- if(!u.npcs.tilesFoughtOn.isEmpty()) {
- for(RSTile tileFoughtOn : u.npcs.tilesFoughtOn) {
- if(t.getLocation().getX() == tileFoughtOn.getX() && t.getLocation().getY() == tileFoughtOn.getY()) {
- good = true;
- break;
- } 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},
- PRAYER_POTIONS = new int[] {2434, 139, 141, 143, 11465, 11467},
- RANGE_POTIONS = new int[] {2444, 169, 171, 173, 11509, 11511, 13524, 13525, 15326, 15327},
- ENERGY_POTIONS = new int[] {3008, 3010, 3012, 3014, 3016, 3018, 3020, 3022, 11453, 11455, 11481, 11483},
- COMBAT_POTIONS = new int[] {9739, 9741, 9743, 9745, 11445, 11447},
- ATTACK_POTIONS = new int[] {2428, 121, 123, 125, 2436, 145, 147, 149, 11429, 11431,
- 11429, 11431, 11429, 11431, 11469, 11471, 15308 , 15309, 15310, 15311},
- STRENGTH_POTIONS = new int[] {113, 115, 117, 119, 2440, 157, 159, 161, 11443, 11441,
- 11485, 11487, 15312, 15313, 15314, 15315},
- DEFENSE_POTIONS = new int[] {2432, 133, 135, 137, 2442, 163, 165, 167, 11457, 11459,
- 11497, 11499, 15316, 15317, 15318, 15319},
- ANTIPOISON = new int[] {2446, 175, 177, 179, 2448, 181, 183, 185, 5952, 5954,
- 5956, 5958, 5943, 5945, 5947, 5949, 11433, 11435, 11501, 11503},
- ZAMORAK_POTIONS = new int[] {2450, 189, 191, 193, 11521, 11523},
- SARADOMIN_POTIONS = new int[] {6685, 6687, 6689, 6691},
- OVERLOAD_POTIONS = new int[] {15332, 15333, 15334, 15335};
- private final int VIAL = 229;
- private boolean setQuickPrayer = true;
- private HashMap<String, RSItem[]> getPotions() {
- HashMap<String, RSItem[]> potions = new HashMap<String, RSItem[]>();
- potions.put("MAGIC", inventory.getItems(MAGIC_POTIONS));
- potions.put("PRAYER", inventory.getItems(PRAYER_POTIONS));
- potions.put("RANGE", inventory.getItems(RANGE_POTIONS));
- potions.put("ENERGY", inventory.getItems(ENERGY_POTIONS));
- potions.put("COMBAT", inventory.getItems(COMBAT_POTIONS));
- potions.put("ATTACK", inventory.getItems(ATTACK_POTIONS));
- potions.put("STRENGTH", inventory.getItems(STRENGTH_POTIONS));
- potions.put("DEFENSE", inventory.getItems(DEFENSE_POTIONS));
- potions.put("ANTIPOISON", inventory.getItems(ANTIPOISON));
- potions.put("ZAMORAK", inventory.getItems(ZAMORAK_POTIONS));
- potions.put("SARADOMIN", inventory.getItems(SARADOMIN_POTIONS));
- potions.put("OVERLOAD", inventory.getItems(OVERLOAD_POTIONS));
- return potions;
- }
- public void usePotions() {
- HashMap<String, RSItem[]> potions = u.pot.getPotions();
- if(inventory.getItems(VIAL).length != 0) {
- for( RSItem 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].doClick(true);
- }
- else if(potions.get("OVERLOAD").length != 0) {
- potions.get("OVERLOAD")[0].doClick(true);
- }
- }
- if(shouldUsePrayerPot() && potions.get("PRAYER").length != 0 && setQuickPrayer) {
- int current = prayer.getPrayerLeft();
- if(potions.get("PRAYER")[0].doClick(true)) {
- long time = System.currentTimeMillis();
- while(prayer.getPrayerLeft() == 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].doClick(true);
- }
- else if(potions.get("OVERLOAD").length != 0) {
- potions.get("OVERLOAD")[0].doClick(true);
- }
- }
- if(walking.getEnergy() < random(40, 70) && potions.get("ENERGY").length != 0) {
- potions.get("ENERGY")[0].doClick(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].doClick(true);
- }
- else if(potions.get("STRENGTH").length != 0) {
- potions.get("STRENGTH")[0].doClick(true);
- }
- else if(potions.get("ZAMORAK").length != 0) {
- potions.get("ZAMORAK")[0].doClick(true);
- }
- else if(potions.get("OVERLOAD").length != 0) {
- potions.get("OVERLOAD")[0].doClick(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].doClick(true);
- }
- else if(potions.get("SARADOMIN").length != 0) {
- potions.get("SARADOMIN")[0].doClick(true);
- }
- else if(potions.get("OVERLOAD").length != 0) {
- potions.get("OVERLOAD")[0].doClick(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].doClick(true);
- }
- else if(potions.get("ATTACK").length != 0) {
- potions.get("ATTACK")[0].doClick(true);
- }
- else if(potions.get("ZAMORAK").length != 0) {
- potions.get("ZAMORAK")[0].doClick(true);
- }
- else if(potions.get("OVERLOAD").length != 0) {
- potions.get("OVERLOAD")[0].doClick(true);
- }
- }
- if(combat.isPoisoned() && potions.get("ANTIPOISON").length != 0) {
- potions.get("ANTIPOISON")[0].doClick(true);
- }
- }
- private boolean statIsBoosted(int Skill) {
- return skills.getCurrentLevel(Skill) != skills.getRealLevel(Skill);
- }
- private boolean shouldUsePrayerPot() {
- return skills.getRealLevel(Skills.PRAYER) - (prayer.getPrayerLeft() / 10) > (70 + Math.floor(skills.getRealLevel(Skills.PRAYER) * 2.5));
- }
- }
- private class Alchemy {
- private int[] alchIDs = new int[0];
- private String[] alchNames = new String[0];
- private final int NATURE_RUNE = 561;
- private final int FIRE_RUNE = 554;
- private final int COINS= 995;
- public boolean canAlch() {
- if(inventory.getCount(true, NATURE_RUNE) >= 1 && (inventory.getCount(true, FIRE_RUNE) >= 5 || u.npcs.weaponContains("fire", "steam", "lava"))
- && (inventory.getCount(COINS) > 0 ||
- inventory.getCount() <= 27) && skills.getCurrentLevel(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.getCurrentLevel(Skills.MAGIC) >= 21) {
- return true;
- }
- return false;
- }
- public boolean hasAlchItems() {
- if(alchNames.length > 0 || alchIDs.length > 0)
- {
- for( RSItem 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;
- }
- public void alch(RSComponent i) {
- if (i != null) {
- if(inventory.getCount(true, NATURE_RUNE) >= 1 && (inventory.getCount(true, FIRE_RUNE) >= 5 ||
- u.npcs.weaponContains("fire", "lava", "steam")) && skills.getCurrentLevel(Skills.MAGIC) >= 55) {
- if(game.getTab() != Game.Tab.MAGIC) {
- game.openTab(Game.Tab.MAGIC);
- }
- magic.castSpell(Magic.SPELL_HIGH_LEVEL_ALCHEMY);
- }
- else if(inventory.getCount(true, NATURE_RUNE) >= 1 && (inventory.getCount(true, FIRE_RUNE) >= 5 ||
- u.npcs.weaponContains("fire", "lava", "steam")) && skills.getCurrentLevel(Skills.MAGIC) >= 21) {
- if(game.getTab() != Game.Tab.MAGIC) {
- game.openTab(Game.Tab.MAGIC);
- }
- magic.castSpell(Magic.SPELL_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;
- boolean useAdvancedPaint = true;
- HashMap<String, Integer> prices = new HashMap<String, Integer>();
- private Paint() {
- try {
- ribbon = ImageIO.read(new URL("http://scripters.powerbot.org/files/349221/Paint/pentagon_tag.png"));
- stableRug = ImageIO.read(new URL("http://scripters.powerbot.org/files/349221/Paint/rug.png"));
- skillsRug = ImageIO.read(new URL("http://scripters.powerbot.org/files/349221/Paint/rug1.png"));
- URL fontURL = new URL("http://scripters.powerbot.org/files/349221/Paint/kellyag.ttf");
- URLConnection fontDownload = fontURL.openConnection();
- KellyAnnGothic = Font.createFont(Font.TRUETYPE_FONT, fontDownload.getInputStream());
- } 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 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.
- */
- public 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.getCurrentExp(skill));
- startLevelsMap.put(skill, skills.getRealLevel(skill));
- }
- }
- /**
- * Returns the amount of exp gained in the specified skill.
- *
- * @param skill The skill see Skills.*
- * @return the EXP Gained
- */
- public int getExpGainedIn(int skill) {
- if (startExpMap.get(skill) == null)
- return -1;
- return skills.getCurrentExp(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)
- public int getLevelsGainedIn(int skill) {
- return skills.getRealLevel(skill) - startLevelsMap.get(skill);
- }
- /**
- * Returns a map of skill names and exp gained.
- *
- * @return A map of exp gains and skill names.
- */
- public 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 {
- private final Object[] options = {"Yes.", "No."};
- private final File javaFile = new File(Configuration.Paths.getScriptsSourcesDirectory() + File.separator
- + "TFighterEE.java");
- private boolean autoDownloaded = false;
- 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()) {
- SwingUtilities.invokeAndWait(new Runnable() {
- public void run() {
- int answer = JOptionPane.showOptionDialog(null, "A new version of TFighterEE (" + 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 + "/TFighterEE.java";
- log("Downloading: " + sourceURL);
- if(javaFile.exists()) {
- javaFile.delete();
- }
- try {
- HttpClient.download(new URL(sourceURL), javaFile);
- if(javaFile.exists()) {
- autoDownloaded = true;
- }
- } catch (Exception e) {
- if(javaFile.exists()) {
- javaFile.delete();
- }
- JOptionPane.showMessageDialog(null, "Could not download script");
- }
- }
- if(autoDownloaded) {
- answer = JOptionPane.showOptionDialog(null, "Download Completed!\r\nWould you like to compile now?",
- "Download Successful!", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, options[0]);
- if(answer == 0) {
- deleteRunningFiles();
- compileNewVersion(javaFile.getPath());
- }
- zui.dispose();
- stopScript();
- }
- }
- });
- }
- } 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 boolean deleteRunningFiles() {
- for(File file : getRunningFiles()) {
- file.delete();
- }
- return getRunningFiles().length == 0;
- }
- private File[] getRunningFiles() {
- File directory = new File(Configuration.Paths.getScriptsSourcesDirectory());
- ArrayList<File> files = new ArrayList<File>();
- for(File file : directory.listFiles()) {
- if(file.getName().contains("TFighterEE") && !file.getName().equals("TFighterEE.java"))
- files.add(file);
- }
- return files.toArray(new File[files.size()]);
- }
- private boolean compileNewVersion(String path) {
- boolean success = false;
- try {
- if(new File(path).exists()) {
- JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
- DiagnosticCollector<JavaFileObject> diagnostics = new DiagnosticCollector<JavaFileObject>();
- StandardJavaFileManager fileManager = compiler.getStandardFileManager(diagnostics, null, null);
- Iterable<? extends JavaFileObject> compilationUnits = fileManager
- .getJavaFileObjectsFromStrings(Arrays.asList(path));
- JavaCompiler.CompilationTask task = compiler.getTask(null, fileManager, diagnostics, null,
- null, compilationUnits);
- success = task.call();
- fileManager.close();
- }
- } catch (Exception ignored) {}
- return success;
- }
- }
- 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;
- public 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++;
- }
- return !(iii == 1 && containsBones && !u.bank.depositBones);
- }
- }
- return false;
- }
- public void withdraw() {
- if(inventory.getCount(false) < 28 && !u.eat.haveFood() && u.eat.foodOfChoice != null) {
- RSItem bankItem = bank.getItem(u.eat.foodOfChoice.getID());
- if (bankItem == null || bankItem.getID() == -1) {
- log(Color.RED, "Banking Error!");
- stopScript();
- }
- assert bankItem != null;
- RSComponent bankItemComponent = bankItem.getComponent();
- if (bankItemComponent == null) {
- log(Color.RED, "Banking Error!");
- stopScript();
- }
- 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]).doClick()) {
- sleep(random(800, 1300));
- }
- t++;
- }
- if (!interfaces.scrollTo(bankItemComponent, (Bank.INTERFACE_BANK << 16) + Bank.INTERFACE_BANK_SCROLLBAR)) {
- log(Color.RED, "Banking Error!");
- stopScript();
- }
- boolean withdrew = false;
- for(int iii = 0; iii < 10; iii++) {
- bankItemComponent.doClick(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!");
- stopScript();
- }
- needBankForFood = false;
- }
- }
- public void deposit() {
- Set<Map.Entry<String, Integer>> entries = u.loot.getLootTaken().entrySet();
- RSItem[] items = inventory.getItems();
- ArrayList<Integer> alreadyDeposited = new ArrayList<Integer>();
- for(Map.Entry<String, Integer> entry : entries) {
- for(RSItem 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;
- RSComponent 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!");
- stopScript();
- }
- 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!");
- stopScript();
- }
- }
- }
- }
- }
- }
- }
- }
- @SuppressWarnings({"SynchronizeOnNonFinalField"})
- private class Tiles {
- List<RSTile> badTiles = Collections.synchronizedList(new ArrayList<RSTile>());
- @SuppressWarnings({"BooleanMethodIsAlwaysInverted"})
- public boolean NPCIsOnBadTile(RSNPC t) {
- synchronized (badTiles) {
- for(RSTile badTile : badTiles) {
- if(t.getLocation().getX() == badTile.getX() &&
- t.getLocation().getY() == badTile.getY() ) {
- return true;
- }
- }
- }
- return false;
- }
- @SuppressWarnings({"BooleanMethodIsAlwaysInverted"})
- public boolean groundItemIsOnBadTile(RSGroundItem t) {
- synchronized (badTiles) {
- for(RSTile badTile : badTiles) {
- if(t.getLocation().getX() == badTile.getX() &&
- t.getLocation().getY() == badTile.getY() ) {
- return true;
- }
- }
- }
- return false;
- }
- public void addBadRoom(Room room) {
- badTiles.addAll(Arrays.asList(room.getTiles()));
- }
- public void clearBadTiles() {
- badTiles.clear();
- }
- public RSTile deriveTile(RSTile tile, int xDeviation, int yDeviation) {
- return new RSTile(tile.getX() + xDeviation, tile.getY() + yDeviation, tile.getZ());
- }
- public void drawBadTiles(final Graphics render, final Color color) {
- synchronized (badTiles) {
- for(RSTile tile : badTiles) {
- drawTile(render, color, tile, 0);
- }
- }
- }
- public void drawTile(final Graphics render, final Color color, final RSTile tile, final int tileHeight) {
- if (calc.tileOnMap(tile)) {
- final Point p = calc.tileToMinimap(tile);
- render.setColor(color);
- render.drawLine(p.x, p.y, p.x, p.y);
- if (calc.tileOnScreen(tile)) {
- Point localPoint1 = calc.tileToScreen(tile, 0.0D, 0.0D, tileHeight);
- Point localPoint2 = calc.tileToScreen(tile, 1.0D, 0.0D, tileHeight);
- Point localPoint3 = calc.tileToScreen(tile, 0.0D, 1.0D, tileHeight);
- Point localPoint4 = calc.tileToScreen(tile, 1.0D, 1.0D, tileHeight);
- if (calc.pointOnScreen(localPoint1) && calc.pointOnScreen(localPoint2) &&
- calc.pointOnScreen(localPoint3) && calc.pointOnScreen(localPoint4)) {
- final Polygon localPolygon = new Polygon();
- localPolygon.addPoint(localPoint1.x, localPoint1.y);
- localPolygon.addPoint(localPoint2.x, localPoint2.y);
- localPolygon.addPoint(localPoint4.x, localPoint4.y);
- localPolygon.addPoint(localPoint3.x, localPoint3.y);
- render.drawPolygon(localPolygon);
- render.setColor(new Color(color.getRed(), color.getGreen(), color.getBlue(), 50));
- render.fillPolygon(localPolygon);
- }
- }
- }
- }
- }
- private class RoomGeneration {
- public Generator generator = null;
- public boolean disableChecker = false;
- private class Generator extends Thread {
- boolean ranged;
- volatile boolean stop;
- public Generator(boolean ranged){
- this.ranged = ranged;
- }
- public void run() {
- while(!stop) {
- ArrayList<Room> rooms = generateRooms(ranged, 50);
- u.tiles.clearBadTiles();
- for(Room room : rooms) {
- if(!room.contains(players.getMyPlayer().getLocation()))
- u.tiles.addBadRoom(room);
- }
- try {sleep(1000); } catch(Exception ignored) {}
- }
- }
- public void safeStop() {
- this.stop = true;
- }
- }
- public boolean instantiateGenerator() {
- if(!disableChecker) {
- generator = new Generator(u.npcs.weaponContains("dart", "knife", "thrownaxe", "bow"));
- return true;
- }
- return false;
- }
- private ArrayList<Flag> getFlagsAtTile(RSTile tile) {
- try {
- ArrayList<Flag> flagsArrayList = new ArrayList<Flag>();
- RSTile offset = walking.getCollisionOffset(game.getPlane());
- int[][] flags = walking.getCollisionFlags(game.getPlane());
- int tileFlag = flags[tile.getX() - (game.getBaseX() + offset.getX())][tile.getY() - (game.getBaseY() + offset.getY())];
- for(Flag flag : Flag.values()) {
- if((flag.getFlag() & tileFlag) != 0) {
- flagsArrayList.add(flag);
- }
- }
- return flagsArrayList;
- } catch(ArrayIndexOutOfBoundsException e) {
- sleep(2000);
- return getFlagsAtTile(tile);
- }
- }
- private RSTile[] getLocalArea(int length) {
- return new RSArea(u.tiles.deriveTile(players.getMyPlayer().getLocation(), -(length / 2),-(length / 2)),
- u.tiles.deriveTile(players.getMyPlayer().getLocation(), (length / 2),(length / 2))).getTileArray();
- }
- private ArrayList<Room> generateRooms(boolean ranged, int deviations) {
- //BFS SEARCH
- ArrayList<RSTile> unchecked = new ArrayList<RSTile>();
- unchecked.addAll(Arrays.asList(getLocalArea(deviations)));
- if(unchecked.size() != 0) {
- ArrayList<Room> rooms = new ArrayList<Room>();
- while(!unchecked.isEmpty()){
- if(getFlagsAtTile(unchecked.get(0)).contains(ranged ? Flag.OBJECT_BLOCK : Flag.OBJECT_TILE) ||
- getFlagsAtTile(unchecked.get(0)).contains(Flag.DECORATION_BLOCK) ||
- getFlagsAtTile(unchecked.get(0)).contains(Flag.LIMITER)) {
- unchecked.remove(0);
- continue;
- }
- ArrayList<RSTile> areaTiles = new ArrayList<RSTile>();
- Queue<RSTile> queue = new LinkedList<RSTile>();
- areaTiles.add(unchecked.get(0));
- queue.add(unchecked.get(0));
- unchecked.remove(0);
- while(!queue.isEmpty()) {
- RSTile t = queue.remove();
- RSTile child;
- while((child = getUncheckedChild(t, unchecked, ranged)) != null) {
- areaTiles.add(child);
- queue.add(child);
- unchecked.remove(child);
- }
- }
- rooms.add(new Room(areaTiles.toArray(new RSTile[areaTiles.size()])));
- }
- return rooms;
- }
- return null;
- }
- private RSTile getUncheckedChild(RSTile parent, ArrayList<RSTile> unchecked, boolean ranged) {
- RSTile north = u.tiles.deriveTile(parent, 0, 1);
- RSTile east = u.tiles.deriveTile(parent, 1, 0);
- RSTile south = u.tiles.deriveTile(parent, 0, -1);
- RSTile west = u.tiles.deriveTile(parent, -1, 0);
- ArrayList<Flag> parentFlags = getFlagsAtTile(parent);
- if(unchecked.contains(north) && !parentFlags.contains(ranged ? Flag.WALL_BLOCK_NORTH : Flag.WALL_NORTH)) {
- ArrayList<Flag> childFlags = getFlagsAtTile(north);
- if(!childFlags.contains(ranged ? Flag.OBJECT_BLOCK : Flag.OBJECT_TILE) && !childFlags.contains(Flag.DECORATION_BLOCK)
- && !childFlags.contains(ranged ? null : Flag.MAP_BLOCK))
- return north;
- }
- if(unchecked.contains(east) && !parentFlags.contains(ranged ? Flag.WALL_BLOCK_EAST : Flag.WALL_EAST)) {
- ArrayList<Flag> childFlags = getFlagsAtTile(east);
- if(!childFlags.contains(ranged ? Flag.OBJECT_BLOCK : Flag.OBJECT_TILE) && !childFlags.contains(Flag.DECORATION_BLOCK)
- && !childFlags.contains(ranged ? null : Flag.MAP_BLOCK))
- return east;
- }
- if(unchecked.contains(south) && !parentFlags.contains(ranged ? Flag.WALL_BLOCK_SOUTH : Flag.WALL_SOUTH)) {
- ArrayList<Flag> childFlags = getFlagsAtTile(south);
- if(!childFlags.contains(ranged ? Flag.OBJECT_BLOCK : Flag.OBJECT_TILE) && !childFlags.contains(Flag.DECORATION_BLOCK)
- && !childFlags.contains(ranged ? null : Flag.MAP_BLOCK))
- return south;
- }
- if(unchecked.contains(west) && !parentFlags.contains(ranged ? Flag.WALL_BLOCK_WEST : Flag.WALL_WEST)) {
- ArrayList<Flag> childFlags = getFlagsAtTile(west);
- if(!childFlags.contains(ranged ? Flag.OBJECT_BLOCK : Flag.OBJECT_TILE) && !childFlags.contains(Flag.DECORATION_BLOCK)
- && !childFlags.contains(ranged ? null : Flag.MAP_BLOCK))
- return west;
- }
- return null;
- }
- }
- private class Room {
- private RSTile[] tiles;
- public Room(RSTile[] tiles) {
- this.tiles = tiles;
- }
- public boolean contains(RSTile tile) {
- for(RSTile toCheck : tiles) {
- if(toCheck.equals(tile))
- return true;
- }
- return false;
- }
- public RSTile[] getTiles() {
- return tiles;
- }
- }
- @SuppressWarnings({"UnusedDeclaration"})
- private enum Flag {
- WALL_NORTHWEST(0x1),
- WALL_NORTH(0x2),
- WALL_NORTHEAST(0x4),
- WALL_EAST(0x8),
- WALL_SOUTHEAST(0x10),
- WALL_SOUTH(0x20),
- WALL_SOUTHWEST(0x40),
- WALL_WEST(0x80),
- OBJECT_TILE(0x100),
- WALL_BLOCK_NORTHWEST(0x200),
- WALL_BLOCK_NORTH(0x400),
- WALL_BLOCK_NORTHEAST(0x800),
- WALL_BLOCK_EAST(0x1000),
- WALL_BLOCK_SOUTHEAST(0x2000),
- WALL_BLOCK_SOUTH(0x4000),
- WALL_BLOCK_SOUTHWEST(0x8000),
- WALL_BLOCK_WEST(0x10000),
- OBJECT_BLOCK(0x20000),
- DECORATION_BLOCK(0x40000),
- MAP_BLOCK(0x200000),
- WALL_ALLOW_RANGE_NORTHWEST(0x400000),
- WALL_ALLOW_RANGE_NORTH(0x800000),
- WALL_ALLOW_RANGE_NORTHEAST(0x1000000),
- WALL_ALLOW_RANGE_EAST(0x2000000),
- WALL_ALLOW_RANGE_SOUTHEAST(0x4000000),
- WALL_ALLOW_RANGE_SOUTH(0x8000000),
- WALL_ALLOW_RANGE_SOUTHWEST(0x10000000),
- WALL_ALLOW_RANGE_WEST(0x20000000),
- OBJECT_ALLOW_RANGE(0x40000000),
- LIMITER(0x1280100),
- NULL(0);
- private int flag;
- Flag(int flag){
- this.flag = flag;
- }
- public int getFlag() {
- return this.flag;
- }
- public String toString() {
- return this.name();
- }
- }
- @SuppressWarnings({"serial", "ResultOfMethodCallIgnored"})
- private class ZUI extends JFrame {
- private final File file = new File(Configuration.Paths.getScriptCacheDirectory() + File.separator + "TFighter.txt");
- private JCheckBox useMulti, useRadius, disableChecker, useSafe, useCentral, disableSpecials, lootAbove, prioritizeLoot, onlyLoot, useBones,
- useOldPaint, depositLoot, depositBones, withdrawFood, enableBanking;
- private JTextField npcBox, lootBox, lootAboveBox, alchBox, mouseSpeedBox, 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("TFighter Enhanced Edition");
- 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 (Deprecated)");
- 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");
- lootAboveBox = new JTextField("1000");
- lootAbove = new JCheckBox("Loot everything above: ");
- 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);
- lootAboveBox.setMaximumSize(new Dimension(Integer.MAX_VALUE, lootAboveBox.getPreferredSize().height));
- lootAboveBox.setColumns(10);
- if (props.getProperty("lootBox") != null) {
- lootBox.setText(props.getProperty("lootBox"));
- }
- if(props.getProperty("lootAbove") != null) {
- if(props.get("lootAbove").equals("true"))
- lootAbove.setSelected(true);
- }
- if (props.getProperty("lootAboveBox") != null) {
- lootAboveBox.setText(props.getProperty("lootAboveBox"));
- }
- 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);
- JPanel lootAbovePanel = new JPanel();
- lootAbovePanel.add(lootAbove);
- lootAbovePanel.add(lootAboveBox);
- loot.add(new JLabel(" "));
- lootAbovePanel.setMaximumSize(new Dimension(Integer.MAX_VALUE, lootAbovePanel.getPreferredSize().height));
- lootAbovePanel.setAlignmentX(JPanel.CENTER_ALIGNMENT);
- loot.add(lootAbovePanel);
- 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");
- disableChecker = new JCheckBox("Turn off room generation");
- 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);
- disableChecker.setAlignmentX(JCheckBox.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));
- alchBox.setMaximumSize(new Dimension(Integer.MAX_VALUE, alchBox.getPreferredSize().height));
- mouseSpeedBox.setColumns(25);
- alchBox.setColumns(25);
- if (props.getProperty("mouseSpeed") != null) {
- mouseSpeedBox.setText(props.getProperty("mouseSpeed"));
- }
- if(props.getProperty("disableChecker") != null ) {
- if(props.get("disableChecker").equals("true"))
- disableChecker.setSelected(true);
- }
- if(props.getProperty("useSimplePaint") != null ) {
- if(props.get("useSimplePaint").equals("true"))
- useOldPaint.setSelected(true);
- }
- 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(alchLabel);
- misc.add(alchBox);
- misc.add(new JLabel(" "));
- misc.add(disableChecker);
- 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("TFighter 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("lootAbove", Boolean.toString(lootAbove.isSelected()));
- p.put("lootAboveBox", lootAboveBox.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("disableChecker", Boolean.toString(disableChecker.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());
- 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();
- u.rooms.disableChecker = disableChecker.isSelected();
- useSafespot = useSafe.isSelected();
- useCentralClicking = useCentral.isSelected();
- buryBones = useBones.isSelected();
- u.loot.onlyTakeLootFromKilled = onlyLoot.isSelected();
- u.loot.lootAbove = lootAbove.isSelected();
- u.loot.lootAboveX = Integer.parseInt(lootAboveBox.getText());
- u.paint.useAdvancedPaint = !useOldPaint.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]);
- TFighterEE.this.prioritizeLoot = prioritizeLoot.isSelected();
- if (onlyInRadius) {
- u.rooms.disableChecker = true;
- 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];
- game.openTab(Game.Tab.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.Tab.EQUIPMENT);
- //Credit: The Powerbot Scripters Team
- if(equipment.getItem(Equipment.WEAPON) != null && !disableSpecials.isSelected()){
- u.npcs.weapon = equipment.getItem(Equipment.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.AMMO) != null) {
- u.npcs.ammo = equipment.getItem(Equipment.AMMO).getName();
- }
- if(equipment.getItem(Equipment.RING) != null) {
- u.npcs.ring = equipment.getItem(Equipment.RING).getName();
- }
- 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) {
- RSComponent inter = interfaces.get(137).getComponent(0);
- int x = inter.getLocation().x;
- int y = inter.getLocation().y;
- if (inter.getArea().contains(e.getPoint())) {
- u.paint.showPaint = !u.paint.showPaint;
- }
- //Probably should move this sometime to prevent instantiating new polygons
- 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) {}
- }
Add Comment
Please, Sign In to add comment