Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- *
- * @author Dew - FuserScripts.cz.cc
- * @author Deww1 - Powerbot.org
- */
- import java.awt.Color;
- import org.rsbot.event.events.MessageEvent;
- import org.rsbot.script.*;
- import org.rsbot.script.wrappers.*;
- @ScriptManifest(authors = {"Dew"}, keywords = {"Skeleton"}, name = "FuserWarriorsGuild", description = "Warriors Guild Script Brought to you by: FuserScripts", version = 0.00, website = "http://fuserscripts.cz.cc")
- public class FuserWarriorsGuild extends Script {
- //variables
- // <editor-fold defaultstate="collapsed" desc="General Variables">
- /**
- * Room IDS:<br/>
- * bank - going to bank<br />
- * catapult - doing catapult<br/>
- * animated - doing animated armour<br/>
- * barrel - doing Jimmy's Challenge<br/>
- * dummy - doing dummy attack<br/>
- * shotput - doing Shot Put<br/>
- * cyclops - fight for defender<br/>
- * null - doing nothing..?
- */
- public String getRoom = "null";
- // </editor-fold>
- // <editor-fold defaultstate="collapsed" desc="Banking Variables/Setters">
- public final int bankBooth = 2213; //the ID of the Banking Booth
- public final int bankNpc = 4296; //the ID of the Banking NPC
- /**
- * 0 - 361(tuna)<br/>
- * 1 - 373(swordfish<br/>
- * 2 - 7946(Monkfish)<br/>
- */
- public int[] foodIds = {361, 373, 7946};
- public int foodID = foodIds[1]; //the food ID to use
- public int withdrawAmount = 1; //amount to withdraw
- public boolean useFood = false; //true if using food
- public boolean usePots = false; //true if using pots
- public boolean banked = false;
- // </editor-fold>
- // <editor-fold defaultstate="collapsed" desc="Special Settings">
- public boolean useDh = false; //true if using Dharok's
- public boolean useGuth = false; //true if using Guthan's
- // </editor-fold>
- // <editor-fold defaultstate="collapsed" desc="Points at Start Setter">
- public int startInBarrel = 0;
- public int startInStrength = 0;
- public int startInAnimation = 0;
- public int startInCatapult = 0;
- public int startInDummy = 0;
- // </editor-fold>
- // <editor-fold defaultstate="collapsed" desc="Points to Go Setters">
- public int pointsInBarrel = 0; //how many points to go to while doing Jimmy's Challenge
- public int pointsInStrength = 0; //how many points to go to while doing Shot Put
- public int pointsInAnimation = 0; //how many points to go to while doing Animated Armour
- public int pointsInCatapult = 0; //how many points to go to while doing Catapult Defense
- public int pointsInDummy = 0; //how many points to go to while doing Dummy Attack
- // </editor-fold>
- // <editor-fold defaultstate="collapsed" desc="gained Points Setter">
- public int gainedInBarrel = 0;
- public int gainedInStrength = 0;
- public int gainedInAnimation = 0;
- public int gainedInCatapult = 0;
- public int gainedInDummy = 0;
- // </editor-fold>
- // <editor-fold defaultstate="collapsed" desc="Current Points Setters">
- public int curInBarrel = 0; //current amount of points in Jimmy's Challenge
- public int curInStrength = 0; //current amount of points in Shot Put
- public int curInAnimation = 0; //current amount of points in Animated Armour
- public int curInCatapult = 0; //current amount of points in Catapult Defense
- public int curInDummy = 0; //current amount of points in Dummy Attack
- // </editor-fold>
- // <editor-fold defaultstate="collapsed" desc="Points Interface Setters">
- public final int POINTS_INTER = 1057;
- public final int POINTS_BARREL = 13;
- public final int POINTS_STRENGTH = 16;
- public final int POINTS_ANIMATION = 19;
- public final int POINTS_CATAPULT = 22;
- public final int POINTS_DUMMY = 25;
- // </editor-fold>
- // <editor-fold defaultstate="collapsed" desc="Catapult Room">
- // <editor-fold defaultstate="collapsed" desc="Catapult Room Variables">
- private int cata_curObj = 0; //the current catapult id
- public boolean cata_clicked = false;
- //needed ids
- public final int CSHEILD = 8856; //ID of the catapult Shield
- // </editor-fold>
- // <editor-fold defaultstate="collapsed" desc="Catapult Object Setters">
- public final int C_REG = 15616; //Catapult Regular id
- //usable ids
- public final int C_STAB = 15617; //Catapult Spike id
- public final int C_MAGIC = 15618; //Catapult magic id
- public final int C_BLUNT = 15619; //Catapult blunt id
- public final int C_SLASH = 15620; //Catapult slash id
- // </editor-fold>
- // <editor-fold defaultstate="collapsed" desc="Catapult Interface Setters">
- public final int C_INTER = 411; //main catapult room interface
- //components
- public final int C_SLASH_Com = 2; //slash component
- public final int C_BLUNT_Com = 1; //blunt component
- public final int C_Stab_Com = 0; //slash component
- public final int C_MAGIC_Com = 3; //magic component
- // </editor-fold>
- // </editor-fold>
- // <editor-fold defaultstate="collapsed" desc="areas">
- // <editor-fold defaultstate="collapsed" desc="in guild">
- private boolean inGuild() {//checks if I'm in the Guild or not
- RSArea area1 = new RSArea(new RSTile(2837, 3526), new RSTile(2875, 3553));
- return area1.contains(getMyPlayer().getLocation());
- }
- // </editor-fold>
- // <editor-fold defaultstate="collapsed" desc="in bank">
- private boolean inBank() {//checks if I'm in the bank or not
- RSArea area1 = new RSArea(new RSTile(2841, 3532, 0), new RSTile(2848, 3541, 0));
- return game.getPlane() == 0 && area1.contains(getMyPlayer().getLocation().getX(), getMyPlayer().getLocation().getY());
- }
- // </editor-fold>
- // <editor-fold defaultstate="collapsed" desc="in barrel">
- private boolean inBarrel() {//checks if I'm in the Jimmy area or not
- RSArea area1 = new RSArea(new RSTile(2861, 3532, 1), new RSTile(2876, 3539, 1));
- return game.getPlane() == 1 && area1.contains(getMyPlayer().getLocation().getX(), getMyPlayer().getLocation().getY());
- }
- // </editor-fold>
- // <editor-fold defaultstate="collapsed" desc="in strength">
- private boolean inStrength() {//checks if I'm in the Shot Put area or not
- RSArea area1 = new RSArea(new RSTile(2858, 3540, 1), new RSTile(2876, 3552, 1));
- return game.getPlane() == 1 && area1.contains(getMyPlayer().getLocation().getX(), getMyPlayer().getLocation().getY());
- }
- // </editor-fold>
- // <editor-fold defaultstate="collapsed" desc="in animation">
- private boolean inAnimation() {//checks if I'm in the Animation area or not
- RSArea area1 = new RSArea(new RSTile(2849, 3530, 0), new RSTile(2861, 3541, 0));
- return game.getPlane() == 0 && area1.contains(getMyPlayer().getLocation().getX(), getMyPlayer().getLocation().getY());
- }
- // </editor-fold>
- // <editor-fold defaultstate="collapsed" desc="in catapult">
- private boolean inCatapult() {//checks if I'm in the Catapult area or not
- RSArea area1 = new RSArea(new RSTile(2837, 3538), new RSTile(2847, 3545, 1));
- return game.getPlane() == 1 && area1.contains(getMyPlayer().getLocation().getX(), getMyPlayer().getLocation().getY());
- }
- // </editor-fold>
- // <editor-fold defaultstate="collapsed" desc="in dummy">
- private boolean inDummy() {//checks if I'm in the dummy area or not
- RSArea area1 = new RSArea(new RSTile(2854, 3544, 0), new RSTile(2861, 3551, 0));
- return game.getPlane() == 0 && area1.contains(getMyPlayer().getLocation().getX(), getMyPlayer().getLocation().getY());
- }
- // </editor-fold>
- // </editor-fold>
- private RSTile cata_doTile = new RSTile(2842, 3541);
- private RSTile cata_runTile = new RSTile(2842, 3540);
- private boolean onCataTile = false;
- public boolean cataShieldEquip = false;
- //methods
- // <editor-fold defaultstate="collapsed" desc="animated armour setters">
- /**
- * 0 - Bronze
- * 1 - Iron
- * 2 - Steel
- * 3 - Black
- * 4 - Mithril
- * 5 - Adamantite
- * 6 - Rune
- */
- public int[] animtedArmourType = {0, 1, 2, 3, 4, 5, 6};
- public int armourHelm; //helm id
- public int armourBody; //body id
- public int armourLegs; //legs id
- // </editor-fold>
- // <editor-fold defaultstate="collapsed" desc="Point Getters">
- /**
- * Type 0 - Barrel<br/>
- * Type 1 - Str<br/>
- * Type 2 - Anim<br/>
- * Type 3 - Cata<br/>
- * Type 4 - Dumm
- * @param type what to get the current points from
- * @return the current amount of points in type
- */
- public int getCurPoints(int type) {
- int points = 0;
- RSInterface main = interfaces.get(this.POINTS_INTER);
- RSComponent barrel = main.getComponent(this.POINTS_BARREL);
- RSComponent str = main.getComponent(this.POINTS_STRENGTH);
- RSComponent anim = main.getComponent(this.POINTS_ANIMATION);
- RSComponent cata = main.getComponent(this.POINTS_CATAPULT);
- RSComponent dumm = main.getComponent(this.POINTS_DUMMY);
- if (main != null && main.isValid()) {
- if (barrel != null && barrel.isValid()
- && str != null && str.isValid()
- && anim != null && anim.isValid()
- && cata != null && cata.isValid()
- && dumm != null && dumm.isValid()) {
- switch (type) {
- case 0:
- points = Integer.parseInt(barrel.getText());
- break;
- case 1:
- points = Integer.parseInt(str.getText());
- break;
- case 2:
- points = Integer.parseInt(anim.getText());
- break;
- case 3:
- points = Integer.parseInt(cata.getText());
- break;
- case 4:
- points = Integer.parseInt(dumm.getText());
- break;
- default:
- log.warning("Error getting current points!");
- stopScript();
- }
- }
- }
- return points;
- }
- public void getAllPoints() {
- this.getCurPoints(0);
- this.getCurPoints(1);
- this.getCurPoints(2);
- this.getCurPoints(3);
- this.getCurPoints(4);
- }
- /**
- * Sets the current Points
- * @return true if current points were set
- */
- public boolean setCurPoints() {
- curInBarrel = this.getCurPoints(0);
- curInStrength = this.getCurPoints(1);
- curInAnimation = this.getCurPoints(2);
- curInCatapult = this.getCurPoints(3);
- curInDummy = this.getCurPoints(4);
- if (curInBarrel == this.getCurPoints(0) &&
- curInStrength == this.getCurPoints(1) &&
- curInAnimation == this.getCurPoints(2) &&
- curInCatapult == this.getCurPoints(3) &&
- curInDummy == this.getCurPoints(4)) {
- return true;
- }
- return false;
- }
- public int getDiff(int type) {
- int difference = 0;
- switch(type) {
- case 0:
- difference = this.getCurPoints(type)- this.startInBarrel;
- break;
- case 1:
- difference = this.getCurPoints(type) - this.startInStrength;
- break;
- case 2:
- difference = this.getCurPoints(type)- this.startInAnimation;
- break;
- case 3:
- difference = this.getCurPoints(type) - this.startInCatapult;
- break;
- case 4:
- difference = this.getCurPoints(type) - this.startInDummy;
- break;
- default:
- log(Color.RED, "[ERROR]GetDiff: Bad Type");
- }
- return difference;
- }
- // </editor-fold>
- // <editor-fold defaultstate="collapsed" desc="All Banking Stuff">
- /**
- * this will check if bank is open, if not, it will open bank
- * @return true if the bank is open
- */
- public boolean openBank() {
- RSObject booth = objects.getNearest(this.bankBooth);
- RSNPC banker = npcs.getNearest(this.bankNpc);
- if (!bank.open()) {
- int rand = random(1, 2);
- switch (rand) {
- case 1:
- if (booth != null && booth.isOnScreen()) {
- booth.interact("Use-quickly");
- sleep(1000, 2500);
- }
- break;
- case 2:
- if (banker != null && banker.isOnScreen()) {
- banker.interact("Bank");
- sleep(1000, 2500);
- }
- break;
- }
- }
- return bank.open();
- }
- /**
- * this will check if the bank is open. if it is, it will check if foodID is available,<br/>
- * and if there is a greater or equal to amount to withdraw.<br/>
- * if there is, it will withdraw the foodID's withdrawAmount
- * @return true if inventory contains foodID
- */
- public boolean withdrawFood(int item, int amount) {
- if (openBank()) {
- if (bank.getItem(item) != null && bank.getItem(item).getStackSize() >= amount) {
- bank.withdraw(item, amount);
- sleep(2000, 4000);
- }
- }
- return inventory.contains(item);
- }
- /**
- * checks if the bank is open<br/>
- * then checks if has withdrawn food.<br/>
- * if it has, it will close bank.
- */
- public void closeBank(int item, int amount) {
- if (openBank()) {
- if (withdrawFood(item, amount)) {
- bank.close();
- }
- }
- }
- public void doBank(int item, int amount) {
- int rand = random(1, random(2, 10));
- if (inBank()) {
- openBank();
- withdrawFood(item, amount);
- if (rand != 1) {
- banked = true;
- } else {
- closeBank(item, amount);
- banked = true;
- }
- }
- }
- // </editor-fold>
- /**
- *
- * @param item the item to equipped
- * @param action the action to preform on the item
- * @return true if equipement contains one of the item
- */
- public boolean isEquipped(int item, String action) {
- if (inventory.contains(item)) {
- inventory.getItem(item).interact(action);
- return true;
- }
- return equipment.containsOneOf(item);
- }
- // <editor-fold defaultstate="collapsed" desc="Catapult Methods">
- public int catapultCurValue() {
- RSObject reg = objects.getNearest(this.C_REG);
- RSObject stab = objects.getNearest(this.C_STAB);
- RSObject mage = objects.getNearest(this.C_MAGIC);
- RSObject blunt = objects.getNearest(this.C_BLUNT);
- RSObject slash = objects.getNearest(this.C_SLASH);
- if (getRoom.equals("catapult")) {
- if (inCatapult()) {
- if (reg != null) {
- cata_curObj = this.C_REG;
- } else if (stab != null) {
- cata_curObj = this.C_STAB;
- } else if (mage != null) {
- cata_curObj = this.C_MAGIC;
- } else if (blunt != null) {
- cata_curObj = this.C_BLUNT;
- } else if (slash != null) {
- cata_curObj = this.C_SLASH;
- }
- }
- }
- // log("ID: "+cata_curObj);
- return cata_curObj;
- }
- public int catapultSetShield(int incoming) {
- RSInterface main = interfaces.get(this.C_INTER);
- RSComponent stab = main.getComponent(this.C_Stab_Com);
- RSComponent blunt = main.getComponent(this.C_BLUNT_Com);
- RSComponent slash = main.getComponent(this.C_SLASH_Com);
- RSComponent mage = main.getComponent(this.C_MAGIC_Com);
- if (getRoom.equals("catapult")) {
- int rand = random(1, 15);
- int rand2 = random(1, 4);
- int misclick = 0;
- switch (rand2) {
- case 1:
- misclick = stab.getID();
- break;
- case 2:
- misclick = blunt.getID();
- break;
- case 3:
- misclick = slash.getID();
- break;
- case 4:
- misclick = mage.getID();
- break;
- default:
- log("[ERROR]misclick antiban: bad rand2 pick");
- }
- if (inCatapult()) {
- if (main != null && main.isValid()) {
- if (stab != null && stab.isValid()
- && blunt != null && blunt.isValid()
- && slash != null && slash.isValid()
- && mage != null && mage.isValid()) {
- if (incoming == this.C_REG) {
- cata_clicked = false;
- } else if (incoming == this.C_STAB) {
- if (rand > 1 && rand < 15) {
- if (!cata_clicked) {
- stab.doClick();
- }
- sleep(500, 1500);
- cata_clicked = true;
- } else if (rand == 15) {
- main.getComponent(misclick).doClick();
- log("Miss!");
- } else {
- stab.doHover();
- }
- } else if (incoming == this.C_BLUNT) {
- if (rand > 1 && rand < 15) {
- if (!cata_clicked) {
- blunt.doClick();
- }
- sleep(500, 1500);
- cata_clicked = true;
- } else if (rand == 15) {
- main.getComponent(misclick).doClick();
- log("Miss!");
- } else {
- blunt.doHover();
- }
- } else if (incoming == this.C_SLASH) {
- if (rand > 1 && rand < 15) {
- if (!cata_clicked) {
- slash.doClick();
- }
- sleep(500, 1500);
- cata_clicked = true;
- } else if (rand == 15) {
- main.getComponent(misclick).doClick();
- log("Miss!");
- } else {
- slash.doHover();
- }
- } else if (incoming == this.C_MAGIC) {
- if (rand > 1 && rand < 15) {
- if (!cata_clicked) {
- mage.doClick();
- }
- sleep(500, 1500);
- cata_clicked = true;
- } else if (rand == 15) {
- main.getComponent(misclick).doClick();
- log("Miss!");
- } else {
- mage.doHover();
- }
- } else {
- log(Color.RED, "[catapult]ERROR: Bad catpult ID");
- walking.walkTileOnScreen(this.cata_runTile);
- log("[FAILSAFE]Running away, and Taking a break....");
- sleep(5000, 8000);
- onCataTile = false;
- }
- }
- }
- }
- }
- return 0;
- }
- // </editor-fold>
- // <editor-fold defaultstate="collapsed" desc="onStart">
- @Override
- public boolean onStart() {
- this.startInBarrel = this.getCurPoints(0);
- this.startInStrength = this.getCurPoints(1);
- this.startInAnimation = this.getCurPoints(2);
- this.startInCatapult = this.getCurPoints(3);
- this.startInDummy = this.getCurPoints(4);
- // log(""+this.startInBarrel);
- // log(""+this.startInAnimation);
- // log(""+this.startInCatapult);
- // log(""+this.startInDummy);
- // log(""+this.startInStrength);
- // log(""+this.getDiff(0));
- // log(""+this.getDiff(1));
- // log(""+this.getDiff(2));
- // log(""+this.getDiff(3));
- // log(""+this.getDiff(4));
- getRoom = "catapult";
- return true;
- }// </editor-fold>
- public int loop() {
- this.getAllPoints();
- if (getRoom.equalsIgnoreCase("bank")) {
- //TODO add bank
- } else if (getRoom.equalsIgnoreCase("catapult")) {
- if (this.cataShieldEquip) {//is equiped
- if (onCataTile) {
- this.catapultCurValue();
- this.catapultSetShield(this.cata_curObj);
- int oldDiff = this.getDiff(3);
- //searched - place // on next line.
- log(""+this.getDiff(3));
- } else {
- RSObject cata_doObj = objects.getNearest(15640);
- if (cata_doObj != null) {
- walking.walkTileMM(cata_doObj.getLocation());
- onCataTile = true;
- }
- }
- } else {//not equiped
- this.isEquipped(this.CSHEILD, "Wield");
- if (this.isEquipped(this.CSHEILD, "Wield")) {
- this.cataShieldEquip = true;
- }
- }
- } else if (getRoom.equalsIgnoreCase("shotput")) {
- //TODO add shotput
- } else if (getRoom.equalsIgnoreCase("barrel")) {
- //TODO add barrel
- } else if (getRoom.equalsIgnoreCase("animated")) {
- //TODO add animated
- } else if (getRoom.equalsIgnoreCase("dummy")) {
- //TODO add dummy
- } else if (getRoom.equalsIgnoreCase("cyclops")) {
- //TODO add cyclops fighting
- } else {
- log(Color.RED, "[ERROR]GetRoom: Bad area String - Stopping Script!");
- return -1;
- }
- return random(400, 1000);
- }
- // <editor-fold defaultstate="collapsed" desc="onFinish">
- @Override
- public void onFinish() {
- }// </editor-fold>
- public void messageReceived(MessageEvent e) {
- String m = e.getMessage().toLowerCase();
- if (m.contains("successfully defend") || m.contains("fail defending")) {
- cata_clicked = false;
- }
- }
- // <editor-fold defaultstate="collapsed" desc="Get Points Test">
- // getAllPoints();
- // sleep(1000);
- // setCurPoints();
- // log(""+curInBarrel);
- // log(""+curInStrength);
- // log(""+curInAnimation);
- // log(""+curInCatapult);
- // log(""+curInDummy);
- // </editor-fold>
- // <editor-fold defaultstate="collapsed" desc="banking test">
- // log("in Bank? "+inBank());
- // if (!inventory.contains(foodID) && !banked) {
- // doBank();
- // } else {
- // return -1;
- // }
- // </editor-fold>
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement