Scripter 3 Posted April 2, 2016 Share Posted April 2, 2016 (edited) Our Enum for our altar modes Credits: Isolate - for status snippet, Explv - for JOptionPane snippet, and Valkyr - for being my boy toy. import org.osbot.rs07.api.map.Area; import org.osbot.rs07.api.map.Position; public enum Altars { AIR_ALTAR("Rune essence", "Air rune", new Position(2986, 3294,0), new Position(3013, 3356, 0), new Area(2839, 4840, 2849, 4827), new Area(3009, 3358, 3021, 3353), new Area(2970, 3379, 3022, 3275)), MIND_ALTAR("Rune essence", "Mind rune", new Position(2980, 3513, 0), new Position(2945, 3370, 0), new Area(2771, 4852, 2798, 4823), new Area(2940, 3375, 2952, 3358), new Area(2922, 3525, 3037, 3308)), WATER_ALTAR("Rune essence", "Water rune", new Position(3183, 3166, 0), new Position(3094, 3244, 0), new Area(2706, 4842, 2730, 4828), new Area(3088, 3246, 3097, 3240), new Area(3058, 3278, 3280, 3119)), EARTH_ALTAR("Rune essence", "Earth rune", new Position(3305, 3472, 0), new Position(3253, 3421, 0), new Area(2644, 4851, 2663, 4824), new Area(3248, 3427, 3259, 3414), new Area(3225, 3406, 3318, 3500)), FIRE_ALTAR("Rune essence", "Fire rune", new Position(3312, 3253, 0), new Position(3382, 3270, 0), new Area(2572, 4852, 2596, 4827), new Area(3375, 3275, 3388, 3266), new Area(3267, 3302, 3412, 3154)), BODY_ALTAR("Rune essence", "Body rune", new Position(3055, 3447, 0), new Position(3093, 3490, 0), new Area(2511, 4847, 2529, 4829), new Area(3090, 3499, 3098, 3488), new Area(3039, 3521, 3127, 3408)), COSMIC_ALTAR("Pure essence", "Cosmic rune", new Position(2408, 4379, 0), new Position(2386, 4458, 0), new Area(2119, 4856, 2164, 4811), new Area(2382, 4461, 2390, 4453), new Area(2382, 4461, 2424, 4369)), //CHAOS_ALTAR("Pure essence", "Chaos rune", new Position(3062, 3590, 0), new Position(3094, 3497, 0), new Area(), new Area(3090, 3499, 3098, 3488), new Area(3114, 3455, 2959, 3621)), ASTRAL_ALTAR("Pure essence", "Astral rune", new Position(2156, 3865, 0), new Position(2100, 3918, 0), new Area(2150, 3871, 2164, 3859), new Area(2097, 3921, 2104, 3917), new Area(2094, 3924, 2170, 3845)) ; private String essence, crafted; private Position ruinsPos, bankPos; private Area altarZone, bankZone, pathingZone; Altars(String essence, String craftedRune, Position ruinsPos, Position bankPos, Area altarZone, Area bankZone, Area pathingZone) { this.essence = essence; this.crafted = craftedRune; this.ruinsPos = ruinsPos; this.bankPos = bankPos; this.altarZone = altarZone; this.bankZone = bankZone; this.pathingZone = pathingZone; } public String getEssence() { return essence; } public String getCrafted() { return crafted; } public Position getRuinsPos() { return ruinsPos; } public Position getBankPos() { return bankPos; } public Area getAltarZone() { return altarZone; } public Area getBankZone() { return bankZone; } public Area getPathingZone() { return pathingZone; } } You can edit and expand it as you like Main @ScriptManifest(name = "Runecrafter", author = "Scripter 3", version = 1.0, info = "Supports walking atm", logo = "") public class RC extends Script{ // define variables private String essence, crafted; private Position ruinsPos, bankPos; private Area altarZone, bankZone, pathingZone; private Altars altars; public static String getStatus, lastLoggedStatus; private long startTime; private int runesMade; } onStart @Override public void onStart() throws InterruptedException { startTime = System.currentTimeMillis(); //start the timer getExperienceTracker().startAll(); /start the experience tracker. can just do start(Skill skill); runesMade = 0; //refresh our rune counter altars = (Altars) JOptionPane.showInputDialog(null, "Select a mode:", "Runecrafter", JOptionPane.INFORMATION_MESSAGE, null, Altars.values(), Altars.values()[0] ); //JOptionPane that throws our enum into it to select a 'Mode' loadMode(altars); //load our mode. } onLoop @Override public int onLoop() throws InterruptedException { /*Handle level-up*/ if (getDialogues().isPendingContinuation()) { //if pending con -> click con getDialogues().clickContinue(); new ConditionalSleep(2000, 600) { //sleep @Override public boolean condition() throws InterruptedException { return !getDialogues().isPendingContinuation(); } }.sleep(); } /*Handle bank depositbox missclick */ if (getDepositBox().isOpen()){ //if its open -> close -> sleep getDepositBox().close(); new ConditionalSleep(2000, 900) { @Override public boolean condition() throws InterruptedException { return !getDepositBox().isOpen(); } }.sleep(); } /*Handle running*/ if (getSettings().getRunEnergy() >= random(15, 35) && !getSettings().isRunning()){ getSettings().setRunning(true); new ConditionalSleep(2000, 700) { @Override public boolean condition() throws InterruptedException { return getSettings().isRunning(); } }.sleep(); } //if not running -> randomize between 15,25 energy -> turn it on -> sleep /*Handle banking*/ if (bankZone.contains(myPosition()) && !getInventory().contains(essence)){ //pretty explanatory if (!getBank().isOpen()){ getStatus = "Opening bank"; getBank().open(); new ConditionalSleep(2000, 767) { @Override public boolean condition() throws InterruptedException { return getBank().isOpen(); } }.sleep(); } else { if (getInventory().contains(crafted)){ getStatus = "Depositing"; getBank().depositAll(); sleep(600); } else { getStatus = "Withdrawing"; getBank().withdrawAll(essence); sleep(600); if (random(0, 7) < 2) getBank().close(); } } } /*Handle walking w/ essence*/ if (pathingZone.contains(myPosition()) && getInventory().contains(essence)){ if (ruinsPos.distance(myPosition()) <= 10){ RS2Object ruins = getObjects().closest(obj -> obj.hasAction("Enter") && obj.getName().equals("Mysterious ruins")); if (ruins != null && ruins.interact("Enter")){ getStatus = "Entering ruins"; new ConditionalSleep(5000, 676) { @Override public boolean condition() throws InterruptedException { return altarZone.contains(myPosition()); } }.sleep(); } } else { getStatus = "Walking to ruins"; WebWalkEvent toRuins = new WebWalkEvent(INodeRouteFinder.createAdvanced(), ruinsPos); execute(toRuins); } } /*Handle walking w/o essence*/ if (pathingZone.contains(myPosition()) && getInventory().contains(crafted)){ getStatus = "Walking to bank"; WebWalkEvent toRuins = new WebWalkEvent(INodeRouteFinder.createAdvanced(), bankPos); execute(toRuins); } /*Craft runes in altar area || leave altar area*/ if (altarZone.contains(myPosition())){ if (getInventory().contains(essence)){ RS2Object altar = getObjects().closest("Altar"); if (altar != null && altar.interact("Craft-rune")){ getStatus = "Crafting runes"; new ConditionalSleep(4000, 912) { @Override public boolean condition() throws InterruptedException { return getInventory().contains(crafted); } }.sleep(); runesMade += getInventory().getAmount(crafted); } } else if (getInventory().contains(crafted)){ RS2Object portal = getObjects().closest("Portal"); if (portal != null && portal.interact("Use")){ getStatus = "Exiting area"; new ConditionalSleep(3500, 684) { @Override public boolean condition() throws InterruptedException { return pathingZone.contains(myPosition()); } }.sleep(); } } } return 600; } onPaint @Override public void onPaint(Graphics2D gfx) { long timeRan = System.currentTimeMillis() - this.startTime; gfx.setColor(Color.PINK); gfx.drawString("Mode: " + altars, 20, 20); gfx.drawString("Status: " + printStatus(), 20, 40); gfx.drawString("Time: " + Time.format(timeRan), 20, 60); gfx.drawString("Experience: " + getExperienceTracker().getGainedXP(Skill.RUNECRAFTING) + " (" + getExperienceTracker().getGainedXPPerHour(Skill.RUNECRAFTING) + ")", 20, 80); gfx.drawString("Time Till Level: " + Time.format(getExperienceTracker().getTimeToLevel(Skill.RUNECRAFTING)), 20, 100); gfx.drawString("Gained level(s): +" + getExperienceTracker().getGainedLevels(Skill.RUNECRAFTING), 20, 120); gfx.drawString("Runes crafted: " + runesMade, 20, 140); } methods /** * Methods * @param mode */ public void loadMode(Altars mode) { this.essence = mode.getEssence(); this.crafted = mode.getCrafted(); this.ruinsPos = mode.getRuinsPos(); this.bankPos = mode.getBankPos(); this.altarZone = mode.getAltarZone(); this.bankZone = mode.getBankZone(); this.pathingZone = mode.getPathingZone(); } private String printStatus(){ if(!Objects.equals(lastLoggedStatus, getStatus)){ log("Current Status: " + getStatus); lastLoggedStatus = getStatus; } return lastLoggedStatus; } Quick copy pasta import com.ajck.runecrafting.util.Altars; import com.ajck.runecrafting.util.Time; import org.osbot.rs07.api.map.Area; import org.osbot.rs07.api.map.Position; import org.osbot.rs07.api.model.RS2Object; import org.osbot.rs07.api.ui.Skill; import org.osbot.rs07.api.webwalk.INodeRouteFinder; import org.osbot.rs07.event.WebWalkEvent; import org.osbot.rs07.script.Script; import org.osbot.rs07.script.ScriptManifest; import org.osbot.rs07.utility.ConditionalSleep; import javax.swing.*; import java.awt.*; import java.util.Objects; @ScriptManifest(name = "Runecrafter", author = "Scripter 3", version = 1.0, info = "Supports walking atm", logo = "") public class RC extends Script{ private String essence, crafted; private Position ruinsPos, bankPos; private Area altarZone, bankZone, pathingZone; private Altars altars; public static String getStatus, lastLoggedStatus; private long startTime; private int runesMade; @Override public void onStart() throws InterruptedException { startTime = System.currentTimeMillis(); getExperienceTracker().startAll(); runesMade = 0; altars = (Altars) JOptionPane.showInputDialog(null, "Select a mode:", "Runecrafter", JOptionPane.INFORMATION_MESSAGE, null, Altars.values(), Altars.values()[0] ); loadMode(altars); } @Override public int onLoop() throws InterruptedException { /*Handle level-up*/ if (getDialogues().isPendingContinuation()) { getDialogues().clickContinue(); new ConditionalSleep(2000, 600) { @Override public boolean condition() throws InterruptedException { return !getDialogues().isPendingContinuation(); } }.sleep(); } /*Handle bank depositbox missclick */ if (getDepositBox().isOpen()){ getDepositBox().close(); new ConditionalSleep(2000, 900) { @Override public boolean condition() throws InterruptedException { return !getDepositBox().isOpen(); } }.sleep(); } /*Handle running*/ if (getSettings().getRunEnergy() >= random(15, 35) && !getSettings().isRunning()){ getSettings().setRunning(true); new ConditionalSleep(2000, 700) { @Override public boolean condition() throws InterruptedException { return getSettings().isRunning(); } }.sleep(); } /*Handle banking*/ if (bankZone.contains(myPosition()) && !getInventory().contains(essence)){ if (!getBank().isOpen()){ getStatus = "Opening bank"; getBank().open(); new ConditionalSleep(2000, 767) { @Override public boolean condition() throws InterruptedException { return getBank().isOpen(); } }.sleep(); } else { if (getInventory().contains(crafted)){ getStatus = "Depositing"; getBank().depositAll(); sleep(600); } else { getStatus = "Withdrawing"; getBank().withdrawAll(essence); sleep(600); if (random(0, 7) < 2) getBank().close(); } } } /*Handle walking w/ essence*/ if (pathingZone.contains(myPosition()) && getInventory().contains(essence)){ if (ruinsPos.distance(myPosition()) <= 10){ RS2Object ruins = getObjects().closest(obj -> obj.hasAction("Enter") && obj.getName().equals("Mysterious ruins")); if (ruins != null && ruins.interact("Enter")){ getStatus = "Entering ruins"; new ConditionalSleep(5000, 676) { @Override public boolean condition() throws InterruptedException { return altarZone.contains(myPosition()); } }.sleep(); } } else { getStatus = "Walking to ruins"; WebWalkEvent toRuins = new WebWalkEvent(INodeRouteFinder.createAdvanced(), ruinsPos); execute(toRuins); } } /*Handle walking w/o essence*/ if (pathingZone.contains(myPosition()) && getInventory().contains(crafted)){ getStatus = "Walking to bank"; WebWalkEvent toRuins = new WebWalkEvent(INodeRouteFinder.createAdvanced(), bankPos); execute(toRuins); } /*Craft runes in altar area || leave altar area*/ if (altarZone.contains(myPosition())){ if (getInventory().contains(essence)){ RS2Object altar = getObjects().closest("Altar"); if (altar != null && altar.interact("Craft-rune")){ getStatus = "Crafting runes"; new ConditionalSleep(4000, 912) { @Override public boolean condition() throws InterruptedException { return getInventory().contains(crafted); } }.sleep(); runesMade += getInventory().getAmount(crafted); } } else if (getInventory().contains(crafted)){ RS2Object portal = getObjects().closest("Portal"); if (portal != null && portal.interact("Use")){ getStatus = "Exiting area"; new ConditionalSleep(3500, 684) { @Override public boolean condition() throws InterruptedException { return pathingZone.contains(myPosition()); } }.sleep(); } } } return 600; } @Override public void onPaint(Graphics2D gfx) { long timeRan = System.currentTimeMillis() - this.startTime; gfx.setColor(Color.PINK); gfx.drawString("Mode: " + altars, 20, 20); gfx.drawString("Status: " + printStatus(), 20, 40); gfx.drawString("Time: " + Time.format(timeRan), 20, 60); gfx.drawString("Experience: " + getExperienceTracker().getGainedXP(Skill.RUNECRAFTING) + " (" + getExperienceTracker().getGainedXPPerHour(Skill.RUNECRAFTING) + ")", 20, 80); gfx.drawString("Time Till Level: " + Time.format(getExperienceTracker().getTimeToLevel(Skill.RUNECRAFTING)), 20, 100); gfx.drawString("Gained level(s): +" + getExperienceTracker().getGainedLevels(Skill.RUNECRAFTING), 20, 120); gfx.drawString("Runes crafted: " + runesMade, 20, 140); } /** * Methods * @param mode */ public void loadMode(Altars mode) { this.essence = mode.getEssence(); this.crafted = mode.getCrafted(); this.ruinsPos = mode.getRuinsPos(); this.bankPos = mode.getBankPos(); this.altarZone = mode.getAltarZone(); this.bankZone = mode.getBankZone(); this.pathingZone = mode.getPathingZone(); } private String printStatus(){ if(!Objects.equals(lastLoggedStatus, getStatus)){ log("Current Status: " + getStatus); lastLoggedStatus = getStatus; } return lastLoggedStatus; } } If something can be changed please let everyone know EDIT: forgot a few classes public class Time { public static String format(long time) { StringBuilder t = new StringBuilder(); long total_secs = time / 1000L; long total_mins = total_secs / 60L; long total_hrs = total_mins / 60L; long total_days = total_hrs / 24L; int secs = (int)total_secs % 60; int mins = (int)total_mins % 60; int hrs = (int)total_hrs % 24; int days = (int)total_days; if (days > 0) { if (days < 10) { t.append("0"); } t.append(days); t.append(":"); } if (hrs < 10) { t.append("0"); } t.append(hrs); t.append(":"); if (mins < 10) { t.append("0"); } t.append(mins); t.append(":"); if (secs < 10) { t.append("0"); } t.append(secs); return t.toString(); } } public class Timer { //Extra private final long start; private final long period; private long end; public Timer(long period) { this.period = period; this.start = System.currentTimeMillis(); this.end = (this.start + period); } public long getElapsed() { return System.currentTimeMillis() - this.start; } public long getRemaining() { if (isRunning()) { return this.end - System.currentTimeMillis(); } return 0L; } public boolean isRunning() { return System.currentTimeMillis() < this.end; } public void reset() { this.end = (System.currentTimeMillis() + this.period); } public long setEndIn(long ms) { this.end = (System.currentTimeMillis() + ms); return this.end; } public String toElapsedString() { return Time.format(getElapsed()); } public String toRemainingString() { return Time.format(getRemaining()); } } Edited April 3, 2016 by Scripter 3 Quote Link to comment Share on other sites More sharing options...
Khaleesi Posted April 3, 2016 Share Posted April 3, 2016 You should change rune essence to pure essence... Rune essence is more expensive Looks good on first sight! Goodluck with adding pouch support! Khaleesi 1 Quote Link to comment Share on other sites More sharing options...
Scripter 3 Posted April 3, 2016 Author Share Posted April 3, 2016 You should change rune essence to pure essence... Rune essence is more expensive Looks good on first sight! Goodluck with adding pouch support! Khaleesi True. I'll let those who use this to edit it themselves 1 Quote Link to comment Share on other sites More sharing options...
Mydog80 Posted April 7, 2016 Share Posted April 7, 2016 incredible work Quote Link to comment Share on other sites More sharing options...
King Ramon Posted May 19, 2016 Share Posted May 19, 2016 I don't know much, but just reading the code this looks awfully complete. Is it? Honestly confused since its under Snippets. Quote Link to comment Share on other sites More sharing options...