Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Save files as CodeSpaceLawCrafter.java
- import java.awt.*;
- import java.util.Map;
- import org.rsbot.bot.Bot;
- import org.rsbot.event.listeners.PaintListener;
- import org.rsbot.script.Script;
- import org.rsbot.script.ScriptManifest;
- import org.rsbot.script.Skills;
- import org.rsbot.script.wrappers.RSInterface;
- import org.rsbot.script.wrappers.RSNPC;
- import org.rsbot.script.wrappers.RSTile;
- @ScriptManifest(authors = { "CodeSpace" }, category = "Runecraft", name = "CodeSpaces's FREE Law Crafter", version = 1.0,
- description = "<html><body style='font-family: Arial; padding: 0px; background-color: #FFFFFF;'>"
- + "<div style=\"background-color: #99CCFF; width: 100%; height: 34px; border: 3px coral solid;\">"
- + "<h1 style=\"font-size: 13px; color: #FFFFFF;\"><center>CodeSpaces's FREE Law Crafter"
- + "<br /><small>Version 1.0</small></center></h1></div>"
- + "<br /><center>Start at Draynor Bank.</center>"
- + "<br /> <b>Requirements:</b> <ul><li>Ability to travel to Entrana.</li><li>54 Runecrafting</li></ul> "
- + "<br /><small><center>Note: You must be wearing a Law tiara before you start the script. Its important that pure essence is viewable when the bank opens.</center>")
- public class CodeSpaceLawCrafter extends Script implements PaintListener {
- private final ScriptManifest properties = getClass().getAnnotation(ScriptManifest.class);
- // VARIABLES
- private int startLvl;
- private int startXP;
- private int failCount = 0;
- private int bankBooth = 2213;
- private int runEnergy = random(50, 80);
- private boolean gotSkillLvl = false;
- private boolean tiaraCheck = false;
- private final long startTime = System.currentTimeMillis();
- // ITEM ID'S
- private int pureEssence = 7936;
- private int lawRune = 563;
- private int lawTiara = 5545;
- // NPC'S
- private int monksID[] = {657, 2728, 2729, 658, 2730, 2731};
- // OBJECT ID'S
- private int gangPlank[] = {2415, 2413};
- private int lawRuins = 2459;
- private int lawPortal = 2472;
- private int lawAltar = 2485;
- // PATHS
- private RSTile bankToBoatPath[] = {new RSTile(3093, 3243), new RSTile(3085, 3248),
- new RSTile(3081, 3254), new RSTile(3079, 3265),
- new RSTile(3073, 3273), new RSTile(3066, 3275),
- new RSTile(3060, 3267), new RSTile(3057, 3260),
- new RSTile(3054, 3251), new RSTile(3043, 3245),
- new RSTile(3042, 3237), new RSTile(3048, 3235)};
- private RSTile boatToRuinsPath[] = {new RSTile(2834, 3335), new RSTile(2842, 3335),
- new RSTile(2852, 3337), new RSTile(2859, 3342),
- new RSTile(2859, 3350), new RSTile(2858, 3357),
- new RSTile(2857, 3366), new RSTile(2858, 3378)};
- private RSTile portalToAltarPath[] = {new RSTile(2464, 4818), new RSTile(2464, 4829)};
- // GAME STATES
- private final int WALKTOBOAT = 1;
- private final int RIDEBOAT = 2;
- private final int WALKTORUINS = 3;
- private final int ENTERRUINS = 4;
- private final int WALKTOALTAR = 5;
- private final int CRAFTRUNES = 6;
- private final int LEAVEALTAR = 7;
- private final int WALKFROMRUINS = 8;
- private final int WALKTOBANK = 9;
- private final int BANK = 10;
- private int ACTION = WALKTOBANK;
- public void onRepaint(Graphics g) {
- if(getCurrentTab() != TAB_INVENTORY) {
- return;
- }
- final int percentTilNext = skills.getPercentToNextLevel(Skills.getStatIndex("runecrafting"));
- final int fillBar = (int) (1.65 * (double) percentTilNext);
- final int gainedXP = (int) (skills.getCurrentSkillExp(Skills.getStatIndex("runecrafting")) - startXP);
- final int perHourXP = (int) ((gainedXP) * 3600000D / (System.currentTimeMillis() - startTime));
- final int lawsCrafted = (int) (gainedXP / 9.5);
- final int lawsPerHour = (int) ((lawsCrafted) * 3600000D / (System.currentTimeMillis() - startTime));
- final long runTime = System.currentTimeMillis() - startTime;
- final int seconds = (int) ((runTime / 1000) % 60);
- final int minutes = (int) ((runTime / 1000) / 60) % 60;
- final int hours = (int) (((runTime / 1000) / 60) / 60) % 60;
- final StringBuilder botTime = new StringBuilder();
- if (hours < 10) { botTime.append('0'); }
- botTime.append(hours);
- botTime.append(':');
- if (minutes < 10) { botTime.append('0'); }
- botTime.append(minutes);
- botTime.append(':');
- if (seconds < 10) { botTime.append('0'); }
- botTime.append(seconds);
- try {
- g.setColor(new Color(70, 130, 180, 200));
- g.fillRoundRect(555, 210, 175, 250, 10, 10);
- g.setColor(Color.white);
- int[] coords = new int[] {225, 235, 255, 270, 285, 300, 315, 330, 345, 360, 375, 390, 405, 420, 440};
- g.setFont(new Font("Calibri", Font.PLAIN, 12));
- g.drawString("CodeSpace's", 570, coords[1]);
- g.setFont(new Font("Calibri", Font.BOLD, 18));
- g.drawString("FREE", 640, coords[1]);
- g.setFont(new Font("Calibri", Font.BOLD, 23));
- g.drawString("Law Crafter", 590, coords[2]);
- g.setFont(new Font("Calibri", Font.PLAIN, 10));
- g.drawString("Version: " + properties.version(), 618, coords[3]);
- g.setFont(new Font("Calibri", Font.PLAIN, 12));
- g.drawString("___________________________", 561, 280);
- g.drawString("Time running: " + botTime, 580 ,coords[5]);
- g.drawString("Current Lvl: " + skills.getCurrentSkillLevel(Skills.getStatIndex("runecrafting")), 570, coords[7]);
- g.drawString("Lvls Gained: " + (skills.getCurrentSkillLevel(Skills.getStatIndex("runecrafting")) - startLvl), 570, coords[8]);
- g.drawString("Laws Crafted: " + Integer.toString(lawsCrafted) + "", 570, coords[9]);
- g.drawString("Laws/Hour: " + Integer.toString(lawsPerHour) + "", 570, coords[10]);
- g.drawString("XP Gained: " + Integer.toString(gainedXP) + "", 570, coords[12]);
- g.drawString("XP/Hour: " + Integer.toString(perHourXP) + "", 570, coords[13]);
- g.setColor(new Color(255, 255, 255, 255));
- g.fillRect(559, 441 - 13, 167, 15);
- g.setColor(new Color(0, 0, 0, 175));
- g.fillRect(560, coords[14] - 11, 165, 13);
- g.setColor(new Color(70, 130, 180, 200));
- g.fillRect(560, coords[14] - 11, fillBar, 13);
- g.setColor(Color.WHITE);
- g.drawString(percentTilNext + "%", 565, coords[14]);
- } catch (NullPointerException e) {
- e.printStackTrace();
- }
- }
- public boolean onStart( Map<String,String> args ) {
- return true;
- }
- public int loop() {
- try {
- if(isLoggedIn() && !gotSkillLvl) {
- startLvl = skills.getCurrentSkillLevel(Skills.getStatIndex("runecrafting"));
- startXP = skills.getCurrentSkillExp(Skills.getStatIndex("runecrafting"));
- gotSkillLvl = true;
- return random(50,150);
- }
- } catch (Exception e) { }
- try {
- if(isLoggedIn() && !tiaraCheck) {
- if (equipmentContainsOneOf(lawTiara)) {
- tiaraCheck = true;
- return random(50,150);
- } else {
- log("You need to have a law tiara equipped!");
- wait(10000);
- return random(50,150);
- }
- }
- } catch (Exception e) { }
- try {
- if (energyCheck()) {
- setRun(true);
- wait(random(750,1000));
- return random(50, 150);
- }
- } catch (Exception e) { }
- try {
- runScript();
- antiBan();
- } catch (Exception e) { }
- return random(50,150);
- }
- private void runScript() {
- if (ACTION == WALKTOBOAT) {
- if (distanceTo(getDestination()) < random(5, 7)) {
- if (walkMeTo((bankToBoatPath),false)) {
- ACTION = RIDEBOAT;
- }
- }
- return;
- }
- if (ACTION == RIDEBOAT) {
- if (getInterface(210).getChild(1).getText().contains("The ship arrives") && getInterface(210).getChild(2).getText().contains("to continue")) {
- while (getNearestObjectByID(gangPlank) != null) {
- atObject(getNearestObjectByID(gangPlank), "Gangplank");
- wait(random(1500,2000));
- }
- if (!needsBank()) {
- ACTION = WALKTORUINS;
- return;
- }
- if (needsBank()) {
- ACTION = WALKTOBANK;
- return;
- }
- return;
- }
- final RSNPC monk = getNearestFreeNPCByID(monksID);
- atNPC(monk, "Take-boat");
- wait(random(1500,1700));
- while (getInterface(64).getChild(4).getText().contains("Yes, ok") && getInterface(64).getChild(5).getText().contains("to continue")) {
- atInterface(64, 5);
- wait(random(750,1000));
- }
- while (getInterface(241).getChild(4).getText().contains("Very well.") && getInterface(241).getChild(5).getText().contains("to continue")) {
- atInterface(241, 5);
- wait(random(750,1000));
- }
- while (getInterface(210).getChild(1).getText().contains("The monk") && getInterface(210).getChild(2).getText().contains("to continue")) {
- atInterface(210, 2);
- wait(random(750,1000));
- }
- while (getInterface(241).getChild(4).getText().contains("All is satisfactory.") && getInterface(241).getChild(5).getText().contains("to continue")) {
- atInterface(241, 5);
- wait(random(750,1000));
- }
- while (getInterface(299).getChild(25).getText().contains("You sail to")) {
- wait(random(1000,1500));
- }
- while (getInterface(243).getChild(4).getText().contains("I see you are")) {
- log("ATTENTION: Script terminating due to users incoherence.");
- wait(random(750,1000));
- stopScript();
- }
- return;
- }
- if (ACTION == WALKTORUINS) {
- if (distanceTo(getDestination()) < random(5, 7)) {
- if (walkMeTo((boatToRuinsPath),false)) {
- ACTION = ENTERRUINS;
- }
- }
- return;
- }
- if (ACTION == ENTERRUINS) {
- if (getMyPlayer().getLocation().getY() >= 4812) {
- ACTION = WALKTOALTAR;
- return;
- }
- atObject(getNearestObjectByID(lawRuins), "Mysterious ruins");
- wait(random(1000,1500));
- return;
- }
- if (ACTION == WALKTOALTAR) {
- if (distanceTo(getDestination()) < random(5, 7)) {
- if (walkMeTo((portalToAltarPath),false)) {
- ACTION = CRAFTRUNES;
- }
- }
- return;
- }
- if (ACTION == CRAFTRUNES) {
- if (getInventoryCount(pureEssence) == 0) {
- ACTION = LEAVEALTAR;
- return;
- }
- atObject(getNearestObjectByID(lawAltar), "Altar");
- wait(random(1500,2000));
- return;
- }
- if (ACTION == LEAVEALTAR) {
- if (getMyPlayer().getLocation().getY() <= 3390) {
- ACTION = WALKFROMRUINS;
- return;
- }
- if (distanceTo(getDestination()) < random(5, 7)) {
- if (walkMeTo((portalToAltarPath),true)) {
- atObject(getNearestObjectByID(lawPortal), "Portal");
- wait(random(1000,1500));
- }
- }
- return;
- }
- if (ACTION == WALKFROMRUINS) {
- if (distanceTo(getDestination()) < random(5, 7)) {
- if (walkMeTo((boatToRuinsPath),true)) {
- ACTION = RIDEBOAT;
- }
- }
- return;
- }
- if (ACTION == WALKTOBANK) {
- if (distanceTo(getDestination()) < random(5, 7)) {
- if (walkMeTo((bankToBoatPath),true)) {
- ACTION = BANK;
- }
- }
- return;
- }
- if (ACTION == BANK) {
- if(getInventoryCount(pureEssence) > 0 && getInventoryCount(lawRune) <= 0)
- {
- bank.close();
- wait(random(150,300));
- ACTION = WALKTOBOAT;
- failCount = 0;
- return;
- }
- if (bank.getInterface().isValid()) {
- if (getInventoryCount() != 0)
- bank.depositAll();
- wait(random(750,1000));
- if (bank.atItem(pureEssence, "Withdraw-All")) {
- wait(random(750,1000));
- failCount = 0;
- return;
- } else {
- failCount++;
- if (failCount >= 5)
- stopScript();
- else
- return;
- }
- return;
- } else {
- wait(random(1000, 2000));
- if (!bank.isOpen()) {
- if (getNearestObjectByID(bankBooth) != null) {
- atObject(getNearestObjectByID(bankBooth), "uickly");
- wait(random(500, 1000));
- return;
- }
- }
- }
- }
- }
- private int onEnergyCheck() {
- return Integer.parseInt(RSInterface.getChildInterface(750, 5).getText());
- }
- private boolean energyCheck() {
- try {
- if (onEnergyCheck() >= runEnergy && !isRunning()) {
- runEnergy = random(35, 65);
- return true;
- } else {
- return false;
- }
- } catch (Exception e) {
- return false;
- }
- }
- private boolean walkMeTo(RSTile[] tilearr, boolean backwards){
- int i;
- int arrl = tilearr.length - 1;
- if(!backwards){
- for(i=0;i <= arrl;){
- if(distanceTo(tilearr[i]) <= 4){
- i++;
- if(i > arrl){
- return true;
- }
- }
- if(distanceTo(getDestination()) <= 4 || !getMyPlayer().isMoving()){
- walkTileMM(tilearr[i]);
- }
- }
- if(distanceTo(tilearr[arrl]) <= 4){
- return true;
- }
- }else{
- for(i= arrl;i >= 0;){
- if(distanceTo(tilearr[0]) <= 4){
- return true;
- }
- if(distanceTo(tilearr[i]) <= 4){
- i--;
- if(i < 0){
- return true;
- }
- }
- if(distanceTo(getDestination()) <= 4 || !getMyPlayer().isMoving()){
- walkTileMM(tilearr[i]);
- }
- }
- }
- return false;
- }
- public boolean needsBank() {
- if (getInventoryCount(pureEssence) == 0) {
- return true;
- }
- else {
- return false;
- }
- }
- private int antiBan() {
- int random = random(1, 24);
- switch (random) {
- case 1:
- if (random(1, 4) == 2)
- {
- moveMouseRandomly(300);
- }
- return random(100, 500);
- case 2:
- if (getCurrentTab() != TAB_INVENTORY) {
- openTab(TAB_INVENTORY);
- }
- return random(100, 500);
- case 3:
- if (random(1, 40) == 30)
- {
- if (getMyPlayer().isMoving()) {
- return random(750, 1000);
- }
- if (getCurrentTab() != TAB_STATS) {
- openTab(TAB_STATS);
- }
- moveMouse(560, 420, 40, 20);
- wait(random(3000, 6000));
- return random(100, 200);
- }
- case 4:
- if (random(1, 30) == 5) {
- int angle = getCameraAngle() + random(-90, 90);
- if (angle < 0) {
- angle = 0;
- }
- if (angle > 359) {
- angle = 0;
- }
- setCameraRotation(angle);
- return random(500, 750);
- }
- }
- return 500;
- }
- public void onFinish() {
- Bot.getEventManager().removeListener( PaintListener.class, this );
- }
- }
Add Comment
Please, Sign In to add comment