Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package scripts.gfirecrafter;
- import java.awt.Color;
- import java.awt.Font;
- import java.awt.Graphics;
- import java.awt.Graphics2D;
- import java.awt.Image;
- import java.io.IOException;
- import java.net.URL;
- import javax.imageio.ImageIO;
- import org.tribot.api.General;
- import org.tribot.api.Timing;
- import org.tribot.api.util.abc.ABCUtil;
- import org.tribot.api2007.Banking;
- import org.tribot.api2007.Equipment;
- import org.tribot.api2007.Game;
- import org.tribot.api2007.Interfaces;
- import org.tribot.api2007.Login;
- import org.tribot.api2007.Objects;
- import org.tribot.api2007.Options;
- import org.tribot.api2007.Player;
- import org.tribot.api2007.Skills;
- import org.tribot.api2007.Walking;
- import org.tribot.api2007.Equipment.SLOTS;
- import org.tribot.api2007.Login.STATE;
- import org.tribot.api2007.Skills.SKILLS;
- import org.tribot.api2007.Inventory;
- import org.tribot.api2007.types.RSInterface;
- import org.tribot.api2007.types.RSItem;
- import org.tribot.api2007.types.RSObject;
- import org.tribot.api2007.types.RSTile;
- import org.tribot.script.Script;
- import org.tribot.script.ScriptManifest;
- import org.tribot.script.interfaces.Painting;
- @ScriptManifest(authors = { "Genka" }, category = "Runecrafting", name = "GFireCrafter")
- public class Main extends Script implements Painting{
- private ABCUtil abc = new ABCUtil();
- private boolean alive = true;
- private int[] rodIds = new int[] {2552, 2554, 2556, 2558, 2560, 2562, 2564};
- private RSTile chestPosition = new RSTile(2444, 3083);
- private RSTile duelArenaPosition = new RSTile(3316, 3236);
- private RSTile altarPosition = new RSTile(2584, 4837);
- private RSTile ruinsPosition = new RSTile(3312, 3254);
- private int startXp = Skills.getXP(SKILLS.RUNECRAFTING);
- private int nextRun = abc.generateRunActivation();
- @Override
- public void run() {
- Walking.setWalkingTimeout(500);
- while(alive){
- if(needToBank()){
- bank();
- } else {
- traverse();
- setRunOn();
- doTimedActions();
- }
- sleep(10,50);
- }
- }
- private void setRunOn(){
- if(Game.getRunEnergy() >= nextRun){
- Options.setRunOn(true);
- nextRun = abc.generateRunActivation();
- }
- }
- private void bank(){
- if(!Banking.isBankScreenOpen()){
- checkROD();
- } else if(Banking.isBankScreenOpen()){
- if(Inventory.getAll().length > 0){
- Banking.depositAll();
- }
- if(!Equipment.isEquipped(rodIds)){
- Banking.withdraw(1, rodIds);
- long t = System.currentTimeMillis();
- while(Inventory.find(rodIds).length == 0 && Timing.timeFromMark(t) < 2000){
- sleep(10, 250);
- }
- Banking.close();
- } else {
- withdrawEss();
- }
- }
- }
- private void withdrawEss() {
- RSItem[] ess = Banking.find("Rune essence", "Pure essence");
- if(ess.length == 0 && isBankItemsLoaded()){
- killScript();
- } else {
- Banking.withdraw(0, "Rune essence", "Pure essence");
- long t = System.currentTimeMillis();
- while(Inventory.find("Rune essence", "Pure essence").length == 0 && Timing.timeFromMark(t) < 1000){
- sleep(10,250);
- }
- }
- }
- private void killScript() {
- println("Out of essence");
- long t = System.currentTimeMillis();
- while(Login.getLoginState() == STATE.INGAME && Timing.timeFromMark(t) < 20000){
- sleep(100,500);
- Banking.close();
- Login.logout();
- }
- if(Login.getLoginState() == STATE.LOGINSCREEN){
- alive = false;
- }
- }
- //Thanks Erickho123 for the snippet
- private boolean isBankItemsLoaded() {
- return getCurrentBankSpace() == Banking.getAll().length;
- }
- //Thanks Erickho123 for the snippet
- private int getCurrentBankSpace() {
- RSInterface amount = Interfaces.get(12,5);
- if(amount != null) {
- String text = amount.getText();
- if(text != null) {
- try {
- int parse = Integer.parseInt(text);
- if(parse > 0)
- return parse;
- } catch(NumberFormatException e) {
- return -1;
- }
- }
- }
- return -1;
- }
- private void checkROD() {
- if(isLastCharge()){
- Equipment.remove(SLOTS.RING);
- } else if (Inventory.find(rodIds).length == 0){
- RSObject[] bankChest = Objects.getAt(chestPosition);
- if(bankChest.length > 0){
- if(bankChest[0].isClickable()){
- Banking.openBank();
- } else if(!Player.isMoving() && Game.getDestination() == null){
- Walking.blindWalkTo(new RSTile(chestPosition.getX() + General.random(-1, 1), chestPosition.getY() + General.random(-1, 1)));
- sleep(50,100);
- }
- }
- } else if(Inventory.find(rodIds).length > 0 && !Equipment.isEquipped(rodIds)){
- RSItem[] rod = Inventory.find(rodIds);
- if(rod.length > 0){
- rod[0].click("Wear");
- sleep(50, 100);
- }
- }
- }
- private void traverse(){
- if(Inventory.find("Rune essence", "Pure essence").length > 0){
- if(getLocation() == "Castle Wars" || getLocation() == "Lost"){
- if(Banking.isBankScreenOpen()){
- Banking.close();
- }
- rodTele("Duel Arena");
- } else if (getLocation() == "Duel Arena"){
- moveToRuins();
- } else if (getLocation() == "Fire Altar"){
- craftRunes();
- }
- } else if(Inventory.find("Rune essence", "Pure essence").length == 0 && getLocation() != "Castle Wars"){
- rodTele("Castle Wars");
- }
- }
- private void moveToRuins() {
- if(Player.getPosition().distanceTo(ruinsPosition) > 3 && !Player.isMoving()){
- sleep(100);
- if(getLocation() == "Duel Arena"){
- if(Player.getPosition().distanceTo(ruinsPosition) > 2 && Game.getDestination() == null){
- Walking.blindWalkTo(ruinsPosition);
- sleep(50,260);
- }
- }
- } else {
- RSObject[] ruins = Objects.getAt(ruinsPosition);
- if(ruins.length > 0){
- if(ruins[0].isClickable()){
- if(ruins[0].click("Enter")){
- long t = System.currentTimeMillis();
- while(Player.getPosition().distanceTo(altarPosition) > 50 && Timing.timeFromMark(t) < 5000) {
- sleep(10, 500);
- }
- }
- }
- }
- }
- }
- private void craftRunes() {
- RSTile dest = Game.getDestination();
- if(Player.getPosition().distanceTo(altarPosition) > 2 && (!Player.isMoving() || (dest != null && dest.distanceTo(altarPosition) > 2))){
- Walking.blindWalkTo(altarPosition);
- } else {
- RSObject[] altar = Objects.getAt(altarPosition);
- if(Inventory.find("Rune essence", "Pure essence").length > 0 && altar.length > 0){
- if(altar[0].click("Craft")) {
- sleep(600);
- long t = System.currentTimeMillis();
- while(Player.getAnimation() != -1 && Timing.timeFromMark(t) < 2000) {
- sleep(10, 500);
- }
- }
- }
- }
- }
- private void rodTele(String location){
- RSItem[] rod = Equipment.find(SLOTS.RING);
- if(rod.length > 0 && Game.getGameState() == 30 && Player.getAnimation() != 714){
- if(rod[0].click(location)) {
- long t = System.currentTimeMillis();
- while(getLocation() != location && Timing.timeFromMark(t) < 5000){
- sleep(10,150);
- }
- while(Game.getGameState() == 25 && Timing.timeFromMark(t) < 20000){
- sleep(10,50);
- }
- }
- }
- }
- private boolean needToBank(){
- return Inventory.find("Rune essence", "Pure essence").length == 0 && getLocation().equals("Castle Wars");
- }
- private boolean isLastCharge(){
- RSItem[] ring = Equipment.find(SLOTS.RING);
- if(ring.length > 0){
- return ring[0].getID() == 2566;
- }
- return false;
- }
- private String getLocation(){
- if(Player.getPosition().distanceTo(chestPosition) < 20){
- return "Castle Wars";
- } else if(Player.getPosition().distanceTo(altarPosition) < 20){
- return "Fire Altar";
- } else if(Player.getPosition().distanceTo(duelArenaPosition) < 40){
- return "Duel Arena";
- }
- return "Lost";
- }
- private void doTimedActions() {
- if (abc.shouldCheckTabs()) {
- abc.checkTabs();
- }
- if (abc.shouldCheckXP()) {
- abc.checkXP();
- }
- if (abc.shouldExamineEntity()) {
- abc.examineEntity();
- }
- if (abc.shouldMoveMouse()) {
- abc.moveMouse();
- }
- if (abc.shouldPickupMouse()) {
- abc.pickupMouse();
- }
- if (abc.shouldRightClick()) {
- abc.rightClick();
- }
- if (abc.shouldRotateCamera()) {
- abc.rotateCamera();
- }
- if (abc.shouldLeaveGame()) {
- abc.leaveGame();
- }
- }
- //START: Code generated using Enfilade's Easel
- private Image getImage(String url) {
- try {
- return ImageIO.read(new URL(url));
- } catch(IOException e) {
- return null;
- }
- }
- private final Color color1 = new Color(255, 255, 255);
- private final Font font1 = new Font("Arial", 0, 10);
- private final Image img1 = getImage("http://i.imgur.com/NVV4Xv1.png");
- public void onPaint(Graphics g1) {
- double multiplier = getRunningTime() / 3600000.0D;
- int xpPerHour = (int) ((Skills.getXP(SKILLS.RUNECRAFTING) - startXp) / multiplier);
- Graphics2D g = (Graphics2D)g1;
- g.drawImage(img1, 277, 345, null);
- g.setFont(font1);
- g.setColor(color1);
- g.drawString("Runtime: " + Timing.msToString(getRunningTime()), 366, 409);
- g.drawString("RC level: " + Skills.getActualLevel(SKILLS.RUNECRAFTING), 366, 421);
- g.drawString("XP: " + (Skills.getXP(SKILLS.RUNECRAFTING) - startXp) + " (" + xpPerHour + ")", 366, 433);
- }
- //END: Code generated using Enfilade's Easel
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement