Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import com.rsbuddy.event.events.MessageEvent;
- import com.rsbuddy.event.listeners.MessageListener;
- import com.rsbuddy.event.listeners.PaintListener;
- import com.rsbuddy.script.ActiveScript;
- import com.rsbuddy.script.Manifest;
- import com.rsbuddy.script.methods.*;
- import com.rsbuddy.script.util.Random;
- import com.rsbuddy.script.util.Timer;
- import com.rsbuddy.script.wrappers.Item;
- import org.rsbuddy.widgets.Bank;
- import org.rsbuddy.net.GeItem.*;
- import org.rsbuddy.tabs.Inventory;
- import java.awt.*;
- @Manifest(name = "EvilChocolate", version = 1.0, authors = "Eviltaco", description = "Crushes Chocolate Bars!")
- public class CrushingChampion extends ActiveScript implements PaintListener, MessageListener {
- boolean developerMode = true;
- int failed = 0;
- private String status;
- private long startTime;
- private int barsCrushed;
- private GrandExchange.Item geBar;
- private GrandExchange.Item geDust;
- private static final int crushAnimation = 364;
- private static final int knife = 946;
- private static final int chocolateBar = 1973;
- private static final int chocolateDust = 1975;
- private static final int parentID = 905;
- private static final int childID = 14;
- private int barPrice;
- private int dustPrice;
- private int totalProfit;
- private enum ScriptState {
- STARTUP, OPENING_BANK, DEPOSITING_EXTRA, WITHDRAWING_SCALES,
- CLOSING_BANK, USING_ITEMS, CLICKING_WIDGET, CRUSHING_SCALES,
- STOPPING_SCRIPT, UNKNOWN
- }
- private int random(int min, int max) {
- return Random.nextInt(min, max);
- }
- private void dLog(String log) {
- if (developerMode) {
- log(log);
- }
- }
- @Override
- public boolean onStart() {
- status = "Getting Chocolate Bar prices";
- geBar = GrandExchange.lookup(chocolateBar);
- barPrice = geBar.getGuidePrice();
- status = "Getting Chocolate Dust prices";
- geDust = GrandExchange.lookup(chocolateDust);
- dustPrice = geDust.getGuidePrice();
- totalProfit = dustPrice - barPrice;
- log("Assumed profit per crush: " + totalProfit);
- startTime = System.currentTimeMillis();
- return super.onStart();
- }
- public int profitPerHour() {
- return (int) ((totalProfit * barsCrushed) * 3600000D / (System.currentTimeMillis() - startTime));
- }
- public boolean inventoryContainsExtra() {
- return (Inventory.getCountExcept(knife, chocolateBar) > 1);
- }
- private boolean playerIsCrushing() {
- if (Players.getLocal().getAnimation() == crushAnimation) {
- return true;
- } else {
- return false;
- }
- }
- private boolean crushing() {
- Timer t = new Timer(random(700, 800));
- while (t.isRunning() && Inventory.contains(chocolateBar)) {
- antiBan();
- if (Players.getLocal().getAnimation() == crushAnimation &&
- Inventory.contains(chocolateBar)) {
- t.reset();
- continue;
- }
- sleep(500, 700);
- antiBan();
- if (Players.getLocal().getAnimation() == crushAnimation &&
- Inventory.contains(chocolateBar)) {
- t.reset();
- continue;
- } else {
- continue;
- }
- }
- return false;
- }
- private void antiBan() {
- int randomNumber = random(1, 2000);
- //log(randomNumber);
- if (randomNumber >= 0 && randomNumber <= 500) {
- return;
- } else if (randomNumber > 500 && randomNumber <= 502) {
- if (!status.contains("AB")) {
- status = status + "[AB]";
- }
- dLog(String.valueOf(randomNumber));
- Camera.setPitch(random(1, 101));
- Camera.setCompassAngle(random(1, 360));
- return;
- } else if (randomNumber > 503 && randomNumber <= 505) {
- if (!status.contains("AB")) {
- status = status + "[AB]";
- }
- dLog(String.valueOf(randomNumber));
- dLog(String.valueOf(Mouse.getLocation()));
- Mouse.moveSlightly();
- dLog(String.valueOf(Mouse.getLocation()));
- return;
- } else if (randomNumber == 999 && random(1, 5) == 2 &&
- random(1, 5) == 2) {
- if (!status.contains("AB")) {
- status = status + "[AB]";
- }
- dLog(String.valueOf(randomNumber));
- sleep(10000, 45000);
- return;
- }
- }
- private ScriptState getScriptState() {
- if (playerIsCrushing() && Inventory.contains(chocolateBar)) {
- return ScriptState.CRUSHING_SCALES;
- } else if (!Inventory.isFull()) {
- if (Bank.isOpen()) {
- if (Bank.getItem(chocolateBar).getStackSize() == 0 ) {
- return ScriptState.STOPPING_SCRIPT;
- }
- if (inventoryContainsExtra()) {
- return ScriptState.DEPOSITING_EXTRA;
- } else if (Inventory.contains(chocolateBar)) {
- return ScriptState.CLOSING_BANK;
- } else if (!Inventory.contains(chocolateBar)) {
- return ScriptState.WITHDRAWING_SCALES;
- }
- } else if (!Bank.isOpen()) {
- if (!Inventory.contains(chocolateBar)) {
- return ScriptState.OPENING_BANK;
- } else if (Inventory.contains(chocolateBar) &&
- !Widgets.getComponent(parentID, childID).isValid()) {
- return ScriptState.USING_ITEMS;
- } else if (Inventory.contains(chocolateBar) &&
- Widgets.getComponent(parentID, childID).isValid()) {
- return ScriptState.CLICKING_WIDGET;
- }
- }
- } else if (Inventory.isFull()) {
- if (Bank.isOpen()) {
- if (inventoryContainsExtra()) {
- return ScriptState.DEPOSITING_EXTRA;
- } else if (Inventory.contains(chocolateBar)) {
- return ScriptState.CLOSING_BANK;
- } else if (!Inventory.contains(chocolateBar)) {
- return ScriptState.WITHDRAWING_SCALES;
- }
- }
- if (!Bank.isOpen()) {
- if (!inventoryContainsExtra()) {
- if (Widgets.getComponent(parentID, childID).isValid() &&
- Widgets.getComponent(parentID, childID).isVisible()) {
- return ScriptState.CLICKING_WIDGET;
- } else if (!Widgets.getComponent(parentID, childID).isValid() ||
- !Widgets.getComponent(parentID, childID).isVisible()) {
- return ScriptState.USING_ITEMS;
- }
- } else if (inventoryContainsExtra()) {
- return ScriptState.OPENING_BANK;
- }
- }
- }
- return ScriptState.UNKNOWN;
- }
- public int loop() {
- switch (getScriptState()) {
- case STOPPING_SCRIPT:
- stop();
- return 0;
- case CRUSHING_SCALES:
- dLog("In CRUSHING_SCALES");
- status = "Crushing scales";
- while (crushing() && Inventory.contains(chocolateBar)) {
- antiBan();
- sleep(300, 500);
- }
- if (crushing()) {
- sleep(random(1000, 1500));
- }
- return 0;
- case USING_ITEMS:
- dLog("In USING_ITEMS");
- status = "Using Pestle with Scales";
- Item Knife = Inventory.getItem(knife);
- Item Bar = Inventory.getItem(chocolateBar);
- if (!Widgets.getComponent(parentID, childID).isValid() &&
- !Widgets.getComponent(parentID, childID).isVisible()) {
- if (Knife != null && Bar != null) {
- Inventory.useItem(Knife, Bar);
- }
- sleep(850, 950);
- }
- return 0;
- case CLICKING_WIDGET:
- dLog("In CLICKING_WIDGET");
- status = "Clicking 'Make All'";
- if (Widgets.getComponent(parentID, childID).isValid() &&
- Widgets.getComponent(parentID, childID).isVisible()) {
- Widgets.getComponent(parentID, childID).click();
- sleep(800, 1100);
- }
- return 0;
- case OPENING_BANK:
- status = "Opening bank";
- dLog("In OPENING_BANK");
- Bank.open();
- sleep(600, 800);
- while (Players.getLocal().isMoving()) {
- }
- return 0;
- case DEPOSITING_EXTRA:
- dLog("In DEPOSITING_EXTRA");
- status = "Depositing";
- if (inventoryContainsExtra() && Bank.isOpen()) {
- Bank.depositAllExcept(knife, chocolateBar);
- }
- return 0;
- case WITHDRAWING_SCALES:
- dLog("In WITHDRAWING_SCALES");
- status = "Withdrawing";
- if (Bank.isOpen()) {
- Bank.withdraw(chocolateBar, 0);
- }
- sleep(400, 600);
- return 0;
- case CLOSING_BANK:
- dLog("In CLOSING_BANK");
- status = "Closing bank";
- Bank.close();
- sleep(50, 80);
- return 0;
- default:
- failed++;
- if (failed >= 5) {
- log("Failed 5 times, stopping script");
- stop();
- }
- }
- return 0;
- }
- public void messageReceived(MessageEvent messageEvent) {
- if (messageEvent.getMessage().contains("You grind down the")) {
- barsCrushed++;
- }
- }
- //START: Code generated using Enfilade's Easel
- private final Color color1 = new Color(1, 1, 1, 110);
- private final Color color2 = new Color(0, 0, 0);
- private final Color color3 = new Color(1, 1, 1);
- private final BasicStroke stroke1 = new BasicStroke(1);
- private final Font font1 = new Font("Arial", 0, 11);
- public void onRepaint(Graphics g1) {
- Graphics2D g = (Graphics2D) g1;
- g.setColor(color1);
- g.fillRect(350, 248, 165, 90);
- g.setColor(color2);
- g.setStroke(stroke1);
- g.drawRect(350, 248, 165, 90); //61
- g.setFont(font1);
- g.setColor(color3);
- g.drawString("EvilChocolate [v1.0]", 354, 260);
- g.drawString("Bars Crushed: " + barsCrushed + "(" +
- (profitPerHour() / totalProfit) + "/hour)", 354, 295);
- g.drawString("Assumed Profit: " + (barsCrushed * totalProfit) + "(" +
- profitPerHour() + "/hour)", 354, 310);
- g.drawString("Status: " + status, 354, 325);
- g.drawString("Time Running: " + Timer.format(startTime - System.currentTimeMillis()), 354, 280);
- }
- //END: Code generated using Enfilade's Easel
- @Override
- public void onFinish() {
- Environment.saveScreenshot(true);
- super.onFinish();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement