Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.awt.*;
- //import java.awt.Point;
- //import java.util.ArrayList;
- import java.util.Map;
- import org.rsbot.event.events.ServerMessageEvent;
- import org.rsbot.event.listeners.PaintListener;
- import org.rsbot.event.listeners.ServerMessageListener;
- import org.rsbot.script.Script;
- import org.rsbot.script.ScriptManifest;
- import org.rsbot.script.wrappers.RSInterface;
- import org.rsbot.script.wrappers.RSObject;
- import org.rsbot.script.wrappers.RSTile;
- import org.rsbot.script.wrappers.RSItem;
- import org.rsbot.script.methods.Skills;
- import org.rsbot.script.methods.Camera;
- import org.rsbot.script.methods.Bank;
- import org.rsbot.script.methods.Store;
- @ScriptManifest(authors = {"Fagerheim"}, name = "fGrSmither", version = 1.36,
- description = ("smiths stuff"))
- public class fGrSmither extends Script implements PaintListener, ServerMessageListener {
- private final int bronze = 2349;
- private final int iron = 2351;
- private final int steel = 2353;
- private final int mith = 2359;
- private final int addy = 2361;
- private final int rune = 2363;
- public boolean awbest;
- public int anvil = 2783;
- public int bar;
- public int bars2 = 0;
- public int hammer;
- public int chooseIdle = 0;
- public int needed = 1;
- public int toScroll = 0;
- public int energy = random(11, 90);
- public int smithIdle = 0;
- public int level = 0;
- public int startingExp = 0;
- public float secExp = 0;
- public float minuteExp = 0;
- public float hourExp = 0;
- public int gainedExp = 0;
- public int avgPerHour = 0;
- public int antall;
- public int oldExp = 0;
- public long lastAvgCheck = 0;
- public String make = "Scimitar";
- public String bars;
- public int xpbar = 25;
- public int fixedmouse = 5;
- public int[] tokeep = { 2347, 2349, 2351, 2353, 2359, 2361, 2363, 14112 };
- public int startingLevel;
- int smithx = 0;
- int smithy = 0;
- int smithx2 = 0;
- int smithy2 = 0;
- long startTime = 0;
- long runTime = 0, seconds = 0, minutes = 0, hours = 0;
- public RSTile boothTile = new RSTile(3186, 3437);
- public RSTile smithTile = new RSTile(3187, 3424);
- public void antiBan() {
- if (random(1, 12) == 1) {
- camera.setAngle(random(1, 359));
- }
- if (shouldRun()) {
- walking.setRun(true);
- }
- if (random(1, 11) == 1) {
- final int x = (int) mouse.getLocation().getX();
- final int y = (int) mouse.getLocation().getY();
- mouse.move(x + random(-100, 100), y + random(-50, 50));
- }
- if (random(1, 60) == 1) {
- game.openTab(game.TAB_STATS);
- mouse.move(random(678, 731), random(240, 261));
- sleep(random(731, 2313));
- game.openTab(game.TAB_INVENTORY);
- }
- }
- private boolean bank() {
- if (bank.isOpen()) {
- if (bank.depositAllExcept(tokeep)) {
- sleep(random(200, 300));
- }
- if (inventory.getCount(hammer) != 1) {
- bank.withdraw(hammer, 1);
- sleep(random(200, 300));
- }
- if (!(bank.getCount(bar) + inventory.getCount(bar) < needed)) {
- bank.withdraw(bar, 0);
- sleep(random(200, 300));
- if (random(1, 6) == 1) {
- bank.close();
- }
- } else {
- while (bank.isOpen()) {
- bank.close();
- }
- log("No Hammer or out of Bars. Terminating.");
- stopScript();
- }
- } else {
- openBank();
- }
- return false;
- }
- public boolean choosesmith() {
- if (make.equals("Dagger") || make.equals("Medium Helm")
- || make.equals("Studs") || make.equals("Dart Tip")
- || make.equals("Sword") || make.equals("Wire")
- || make.equals("Lantern") || make.equals("Grapple Tip")
- || make.equals("Mace") || make.equals("Hatchet")
- || make.equals("Arrow tips") || make.equals("Crossbow Limb")
- || make.equals("Crossbow Bolt") || make.equals("Nails")
- || make.equals("Throwing Knife")) {
- needed = 1;
- }
- if (make.equals("Claws") || make.equals("Longsword")
- || make.equals("Scimitar") || make.equals("Square Shield")
- || make.equals("Full Helm")) {
- needed = 2;
- }
- if (make.equals("Warhammer") || make.equals("Battleaxe")) {
- needed = 3;
- }
- if (make.equals("2-handed Sword") || make.equals("Kiteshield")
- || make.equals("Platelegs") || make.equals("Plateskirt")
- || make.equals("Chainbody")) {
- needed = 3;
- toScroll = 1;
- }
- if (make.equals("Platebody")) {
- needed = 5;
- toScroll = 1;
- }
- if (make.equals("Dagger") || make.equals("Iron Spit")
- || make.equals("Wire") || make.equals("Crossbow Bolt")
- || make.equals("Studs") || make.equals("Longsword")
- || make.equals("Lantern") || make.equals("Chainbody")
- || make.equals("Plateskirt")) {
- smithx = 117;
- smithx2 = 119;
- }
- if (make.equals("Dagger") || make.equals("Hatchet")
- || make.equals("Mace") || make.equals("Medium Helm")) {
- smithy = 67;
- smithy2 = 92;
- }
- if (make.equals("Hatchet") || make.equals("Grapple Tip")
- || make.equals("Sword") || make.equals("Arrow tips")
- || make.equals("Throwing Knife") || make.equals("Kiteshield")
- || make.equals("Platelegs")) {
- smithx = 133;
- smithx2 = 236;
- }
- if (make.equals("Crossbow Bolt") || make.equals("Sword")
- || make.equals("Nails") || make.equals("Dart Tip")) {
- smithy = 119;
- smithy2 = 144;
- }
- if (make.equals("Mace") || make.equals("Scimitar")
- || make.equals("Full Helm") || make.equals("Warhammer")
- || make.equals("Platebody") || make.equals("Dart Tip")) {
- smithx = 251;
- smithx2 = 353;
- }
- if (make.equals("Studs") || make.equals("Wire")
- || make.equals("Iron Spit") || make.equals("Arrow tips")
- || make.equals("Scimitar") || make.equals("Crossbow Limb")) {
- smithy = 171;
- smithy2 = 196;
- }
- if (make.equals("Medium Helm") || make.equals("Nails")
- || make.equals("Crossbow Limb") || make.equals("Square Shield")
- || make.equals("2-handed Sword") || make.equals("Battleaxe")) {
- smithx = 381;
- smithx2 = 483;
- }
- if (make.equals("Longsword") || make.equals("Throwing Knife")
- || make.equals("Full Helm") || make.equals("Square Shield")) {
- smithy = 223;
- smithy2 = 248;
- }
- if (make.equals("Lantern") || make.equals("Grapple Tip")
- || make.equals("Warhammer") || make.equals("Battleaxe")
- || make.equals("Crossbow Limb")) {
- smithy = 275;
- smithy2 = 300;
- }
- if (make.equals("Chainbody") || make.equals("Kiteshield")
- || make.equals("2-handed Sword")) {
- smithy = 216;
- smithy2 = 241;
- }
- if (make.equals("Plateskirt") || make.equals("Platelegs")
- || make.equals("Platebody")) {
- smithy = 268;
- smithy2 = 293;
- }
- return true;
- }
- public boolean needToWalk() {
- if (inventory.getCount(bar) < needed && calc.distanceTo(boothTile) > 5
- || inventory.getCount(hammer) != 1 && calc.distanceTo(boothTile) > 5) {
- smithIdle = 0;
- return true;
- }
- return false;
- }
- public int loop() {
- if (interfaces.get(740).getComponent(0).isValid()) {
- chooseIdle = 0;
- sleep(random(300, 600));
- interfaces.get(740).getComponent(3).doAction("continue");
- level = skills.getCurrentLevel(Skills.SMITHING);
- }
- if (chooseIdle != 1) {
- choosesmith();
- chooseIdle = 1;
- }
- antiBan();
- while (getMyPlayer().isMoving()) {
- return random(500, 1500);
- }
- if (needToWalk()) {
- RSTile rboothTile = new RSTile(random(3187, 3188), random(3436, 3438));
- walking.walkTo(rboothTile);
- return random(285, 321);
- }
- if (inventory.getCount(hammer) == 1 && inventory.getCount(bar) >= needed
- && calc.distanceTo(smithTile) > 5) {
- RSTile rsmithTile = new RSTile(random(3186, 3189), random(3421, 3426));
- walking.walkTo(rsmithTile);
- return random(236, 1026);
- }
- if (inventory.getCount(bar) <= needed && calc.distanceTo(boothTile) < 5
- || inventory.getCount(hammer) != 1 && calc.distanceTo(boothTile) < 5) {
- bank();
- return random(562, 1074);
- }
- if (inventory.getCount(hammer) == 1 && inventory.getCount(bar) >= needed
- && calc.distanceTo(smithTile) < 5) {
- smith();
- return random(546, 2023);
- }
- return random(262, 314);
- }
- public void onFinish() {
- log("Thanks for useing fGrSmither!");
- }
- @Override
- public void onRepaint(Graphics g1) {
- Graphics2D g = (Graphics2D)g1;
- final Color BG = new Color(0, 0, 0, 200);
- final Color RED = new Color(255, 0, 0, 255);
- final Color WHITE = new Color(255, 255, 255, 255);
- if ((minutes > 0 || hours > 0 || seconds > 0) && gainedExp > 0) {
- secExp = (float) gainedExp
- / (float) (seconds + minutes * 60 + hours * 60 * 60);
- }
- minuteExp = secExp * 60;
- hourExp = minuteExp * 60;
- if (System.currentTimeMillis() - lastAvgCheck >= 500) {
- lastAvgCheck = System.currentTimeMillis();
- avgPerHour = gainedExp - oldExp;
- oldExp = gainedExp;
- }
- if (startTime == 0) {
- startTime = System.currentTimeMillis();
- }
- runTime = System.currentTimeMillis() - startTime;
- seconds = runTime / 1000;
- if (seconds >= 60) {
- minutes = seconds / 60;
- seconds -= minutes * 60;
- }
- if (minutes >= 60) {
- hours = minutes / 60;
- minutes -= hours * 60;
- }
- if (bars2 == 1 || bars2 == 3 || bars2 == 5) {
- antall = skills.getExpToNextLevel(Skills.SMITHING) / xpbar
- / needed * 2 + 2;
- }
- if (bars2 == 2 || bars2 == 4 || bars2 == 6) {
- antall = skills.getExpToNextLevel(Skills.SMITHING) / xpbar
- / needed * +1;
- }
- gainedExp = skills.getCurrentExp(Skills.SMITHING)
- - startingExp;
- g.setColor(BG);
- g.fill3DRect(305, 180, 205, 150, true);
- g.setColor(RED);
- g.drawString("fGrSmither v 1.36", 360, 195);
- g.setColor(WHITE);
- g.drawString("Running for: " + hours + ":" + minutes + ":" + seconds,
- 310, 210);
- g.drawString("Making: " + bars + " " + make + "'s", 310, 225);
- g.drawString("Currently Level: " + level, 310, 240);
- g.drawString(skills.getPercentToNextLevel(Skills.SMITHING)
- + "% to level " + (level + 1), 310, 255);
- g
- .drawString(
- "Gained "
- + (skills.getCurrentLevel(Skills.SMITHING) - startingLevel)
- + " levels", 310, 270);
- g.drawString("Gained " + gainedExp + " Exp", 310, 285);
- g.drawString("Average Exp per hour: " + (int) hourExp, 310, 300);
- g.drawString(
- (int) antall + " " + make + "s until level " + (level + 1),
- 310, 315);
- }
- public boolean onStart() {
- startingLevel = skills.getCurrentLevel(Skills.SMITHING);
- level = startingLevel;
- startingExp = skills.getCurrentExp(Skills.SMITHING);
- //final String hammers = args.get("hammer").trim();
- //if (hammers.equals("Normal Hammer")) {
- hammer = 2347;
- //}
- //if (hammers.equals("SC Hammer")) {
- // hammer = 14112;
- //}
- //bars = args.get("bar");
- bars = "Adamantite";
- if (bars.equals("Bronze")) {
- bar = bronze;
- bars2 = 1;
- xpbar = 25;
- }
- if (bars.equals("Iron")) {
- bar = iron;
- bars2 = 2;
- xpbar = 25;
- }
- if (bars.equals("Steel")) {
- bar = steel;
- bars2 = 3;
- xpbar = 75;
- }
- if (bars.equals("Mithril")) {
- bar = mith;
- bars2 = 4;
- xpbar = 50;
- }
- if (bars.equals("Adamantite")) {
- bar = addy;
- bars2 = 5;
- xpbar = 125;
- }
- if (bars.equals("Runite")) {
- bar = rune;
- bars2 = 6;
- xpbar = 75;
- }
- //final String mspeed = args.get("fmousespeed").trim();
- fixedmouse = 8;
- return true;
- }
- @Override
- public void serverMessageRecieved(ServerMessageEvent e) {
- }
- public boolean openBank() {
- final RSObject bankbooth = objects.getNearest(11402);
- if (bankbooth == null) {
- return false;
- }
- if (!calc.tileOnScreen(bankbooth.getLocation())) {
- camera.turnToTile(bankbooth.getLocation(), 15);
- }
- return bankbooth.doAction("Use-quickly");
- }
- public boolean shouldRun() {
- if (walking.getEnergy() > energy + random(-10, 10)) {
- return true;
- }
- return false;
- }
- public int smith() {
- sleep(random(200, 350));
- if (smithIdle != 1) {
- while(interfaces.get(300).isValid() == false) {
- inventory.getItem(bar).doAction("Use");
- sleep(random(300, 600));
- final RSObject anvill = objects.getNearest(anvil);
- anvill.doAction("Use " + bars + " bar -> Anvil");
- sleep(random(2500, 3000));
- }
- camera.setAngle(random(1, 359));
- if (interfaces.get(300).isValid()) {
- if (toScroll == 1) {
- mouse.click(random(492, 504), random(250, 300), true);
- toScroll = 0;
- }
- while(interfaces.get(300).isValid()) {
- mouse.click(random(smithx, smithx2), random(smithy, smithy2),false);
- menu.doAction("All");
- sleep(random(2500, 3000));
- }
- smithIdle = 1;
- }
- }
- return random(50, 100);
- }
- public boolean topTextContains(final String s) {
- for (int a = 0; a < 10; a++) {
- if (menu.getItems()[0].toLowerCase().toLowerCase().contains(
- s.toLowerCase())) {
- return true;
- }
- }
- return false;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement