Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package scripts.autoAlcherPro;
- import java.awt.Graphics;
- import java.awt.Rectangle;
- import org.tribot.api.Clicking;
- import org.tribot.api.General;
- import org.tribot.api.Timing;
- import org.tribot.api2007.Skills;
- import org.tribot.api2007.Skills.SKILLS;
- import org.tribot.api.types.generic.Condition;
- import org.tribot.api2007.Game;
- import org.tribot.api2007.GameTab;
- import org.tribot.api2007.Magic;
- import org.tribot.api2007.Player;
- import org.tribot.api2007.GameTab.TABS;
- import org.tribot.api2007.Inventory;
- import org.tribot.api2007.WebWalking;
- import org.tribot.api2007.types.RSArea;
- import org.tribot.api2007.types.RSTile;
- import org.tribot.script.Script;
- import org.tribot.script.ScriptManifest;
- import org.tribot.script.interfaces.Painting;
- @ScriptManifest(authors = { "JoeDezzy" }, category = "Magic", name = "AIO Walking Alcher")
- public class AutoAlcher extends Script implements Painting {
- public static boolean running = true; //main loop boolean
- public boolean canWalk = false; //user wants to walk or not
- public boolean GUI_COMPLETE = false;
- public String ITEM_NAME; //item to alch
- public int walkTimeMin; //minimum amount of time to walk before alching
- public int walkTimeMax; //maximum time
- private long nextWalkTime; //next valid walking time
- private BotState state;
- private RSTile queuedCity; //city the bot is currently walking to
- private AntiBan aban;
- public AutoAlcher(){}
- enum BotState {
- CLICK_ALCH,
- CLICK_ITEM,
- OPEN_MAGEBOOK,
- KILL,
- NULL,
- WALK
- }
- @Override
- public void run() {
- new GUI();
- while (!GUI_COMPLETE) sleep(200);
- aban = new AntiBan();
- println("Welcome to JoeDezzy's walking autoAlcher!");
- while(running) {
- state = getState();
- aban.start();
- switch(state) {
- case WALK:
- if (successfulWalk())
- nextWalkTime = System.currentTimeMillis()
- + (General.random(walkTimeMin, walkTimeMax) * 1000);
- break;
- case CLICK_ALCH:
- clickAlch();
- break;
- case OPEN_MAGEBOOK:
- GameTab.open(TABS.MAGIC);
- break;
- case CLICK_ITEM:
- clickItem();
- break;
- case KILL:
- running = false;
- case NULL:
- sleep(300);
- }
- sleep(400, 900);
- }
- }
- private void setQuedCity() {
- //*
- /* Sets a city to walk to if not
- * already walking to a certain city.
- * Using a static variable because the walker times
- * out to alch in-between walking.
- */
- RSArea VARROCK_AREA = new RSArea(new RSTile(3179, 3449, 0), new RSTile(3282, 3382, 0));
- RSArea FALADOR_AREA = new RSArea(new RSTile(2943, 3389, 0), new RSTile(3039, 3327, 0));
- RSArea LUMBRIDGE_AREA = new RSArea(new RSTile(3200, 3244, 0), new RSTile(3264, 3197, 0));
- if (VARROCK_AREA.contains(Player.getPosition())) {
- println("Queded falador as next destination");
- queuedCity = new RSTile(3004, 3358, 0);
- }
- else if (FALADOR_AREA.contains(Player.getPosition())) {
- println("Queded lumbridge as next destination");
- queuedCity = new RSTile(3248, 3234, 0);
- }
- else if (LUMBRIDGE_AREA.contains(Player.getPosition())) {
- println("Queded varrock as next destination");
- queuedCity = new RSTile(3207, 3425, 0);
- }
- }
- private boolean successfulWalk() {
- final long walkKill = System.currentTimeMillis() + General.random(5000, 15000);
- setQuedCity();
- return WebWalking.walkTo(queuedCity, new Condition() {
- @Override
- public boolean active() {
- return System.currentTimeMillis() > walkKill;
- }
- }, 400);
- }
- private void clickItem() {
- if (Clicking.click(Inventory.find(ITEM_NAME))) {
- Timing.waitCondition(new Condition(){
- @Override
- public boolean active() {
- return GameTab.getOpen().equals(TABS.MAGIC);
- }
- }, General.random(1200, 2200));
- }
- }
- private void clickAlch() {
- if (Magic.selectSpell(Skills.getActualLevel(SKILLS.MAGIC) < 55 ? "Low Level Alchemy" : "High Level Alchemy")) {
- Timing.waitCondition(new Condition(){
- @Override
- public boolean active() {
- return GameTab.getOpen().equals(TABS.INVENTORY);
- }
- }, General.random(1800, 2300));
- }
- }
- private BotState getState() {
- if (canWalk && Player.getRSPlayer().getAnimation() <= -1 && System.currentTimeMillis() > nextWalkTime) {
- //canWalk is if the user wants to walk
- return BotState.WALK;
- }
- else if (Inventory.find(ITEM_NAME).length <= 0 || Inventory.find("Nature rune").length <= 0) {
- //out of items
- return BotState.KILL;
- }
- else if (!GameTab.getOpen().equals(TABS.MAGIC) && !Game.getUptext().contains("Cast")) {
- return BotState.OPEN_MAGEBOOK;
- }
- else if (GameTab.getOpen().equals(TABS.MAGIC) && !Magic.isSpellSelected()) {
- return BotState.CLICK_ALCH;
- }
- else if (GameTab.getOpen().equals(TABS.INVENTORY) && Game.getUptext().contains("Cast")) {
- return BotState.CLICK_ITEM;
- }
- return BotState.NULL;
- }
- private long xpPerHour = 0;
- private long timeRunning = 0;
- private int alchsPerHour = 0;
- private int startXp = 0;
- private long startTime = 0;
- @Override
- public void onPaint(Graphics g) {
- xpPerHour = (Skills.getXP(SKILLS.MAGIC) - startXp) / (timeRunning * 1000);
- timeRunning = System.currentTimeMillis() - startTime;
- int seconds = (int) (timeRunning / 1000) % 60 ;
- int minutes = (int) ((timeRunning / (1000*60)) % 60);
- int hours = (int) ((timeRunning / (1000*60*60)) % 24);
- Rectangle r = new Rectangle(300, 300);
- g.draw3DRect(50, 50, 200, 100, true);
- g.drawString("Time ran: " + (hours < 10 ? "0" : "") + hours
- + ":" + (minutes < 10 ? "0" : "") + minutes
- + ":" + (seconds < 10 ? "0" : "") + seconds,
- r.x + 20, r.y - 20);
- g.drawString("Alchs p/h: " + alchsPerHour, r.x + 20, r.y - 40);
- g.drawString("Xp p/h: " + xpPerHour, r.x + 20, r.y - 60);
- }
- public void sendValues(boolean walking, int min, int max, String item) {
- this.canWalk = walking;
- this.walkTimeMin = min;
- this.walkTimeMax = max;
- this.ITEM_NAME = item;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement