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.ABCUtil;
- import org.tribot.api2007.Banking;
- import org.tribot.api2007.Equipment;
- import org.tribot.api2007.Game;
- 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.Skills.SKILLS;
- import org.tribot.api2007.Inventory;
- import org.tribot.api2007.types.RSItem;
- import org.tribot.api2007.types.RSItemDefinition;
- 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 int essId = 7936;
- private long lastAction = System.currentTimeMillis();
- 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);
- @Override
- public void run() {
- General.useAntiBanCompliance(true);
- Walking.setWalkingTimeout(500);
- while(alive){
- if(needToBank()){
- bank();
- } else {
- travelAndCraft();
- }
- abc.performTimedActions(SKILLS.RUNECRAFTING);
- setRunOn();
- sleep(10,50);
- }
- }
- private void setRunOn(){
- if(Game.getRunEnergy() >= abc.INT_TRACKER.NEXT_RUN_AT.next()){
- Options.setRunOn(true);
- abc.INT_TRACKER.NEXT_RUN_AT.reset();
- }
- }
- private void bank(){
- if(!Banking.isBankScreenOpen()){
- if(isLastCharge()){
- Equipment.remove(SLOTS.RING);
- } else if (Inventory.getCount(rodIds) == 0){
- RSObject[] bankChest = Objects.getAt(chestPosition);
- if(bankChest.length > 0){
- openBank(bankChest[0]);
- }
- } else if(Inventory.getCount(rodIds) > 0 && !Equipment.isEquipped(rodIds)){
- equipRod();
- }
- } else if(Banking.isBankScreenOpen()){
- if(Inventory.getAll().length > 0){
- Banking.depositAll();
- } else if(!Equipment.isEquipped(rodIds)){
- withDraw(rodIds, 1, "ring of dueling");
- Banking.close();
- } else {
- withDraw(new int[] {essId}, 0, "pure ess");
- }
- }
- }
- private boolean openBank(RSObject bankChest){
- if(bankChest.isClickable()){
- Banking.openBank();
- } else if(!Player.isMoving()){
- if(Walking.blindWalkTo(new RSTile(chestPosition.getX() + General.random(-1, 1), chestPosition.getY() + General.random(-1, 1)))){
- sleep(600,1000);
- }
- }
- return false;
- }
- private void equipRod(){
- RSItem[] rod = Inventory.find(rodIds);
- if(rod.length > 0){
- if(rod[0].click("Wear")){
- abc.waitNewOrSwitchDelay(System.currentTimeMillis(), false);
- }
- }
- }
- private void travelAndCraft(){
- if(Inventory.getCount(essId) > 0){
- if(getLocation().equals(POSITION.CWARS) || getLocation().equals(POSITION.LOST)){
- if(Banking.isBankScreenOpen()){
- Banking.close();
- } else {
- rodTele("Duel Arena");
- }
- } else if (getLocation().equals(POSITION.ARENA)){
- if(toRuins()){
- enterRuins();
- }
- } else if (getLocation().equals(POSITION.ALTAR)){
- if(Player.getPosition().distanceTo(altarPosition) > 2 && !Player.isMoving()){
- Walking.blindWalkTo(altarPosition);
- } else {
- craft();
- }
- }
- } else if(Inventory.getCount(essId) == 0 && !getLocation().equals(POSITION.CWARS)){
- rodTele("Castle Wars");
- }
- }
- private void craft(){
- RSObject[] altar = Objects.getAt(altarPosition);
- if(Inventory.getCount(essId) > 0 && altar.length > 0){
- altar[0].click("Craft");
- abc.waitNewOrSwitchDelay(System.currentTimeMillis(), false);
- }
- }
- private boolean enterRuins(){
- RSObject[] ruins = Objects.getAt(ruinsPosition);
- if(ruins.length > 0){
- if(ruins[0].isClickable()){
- ruins[0].click("Enter");
- abc.waitNewOrSwitchDelay(System.currentTimeMillis(), false);
- }
- }
- return false;
- }
- private boolean toRuins(){
- if(Player.getPosition().distanceTo(ruinsPosition) > 3 && !Player.isMoving()){
- sleep(100);
- if(getLocation().equals(POSITION.ARENA)){
- if(!Walking.clickTileMM(new RSTile(ruinsPosition.getX() + General.random(-1, 1), ruinsPosition.getY() + General.random(-1, 1)), 1)){
- Walking.clickTileMM(new RSTile(3308 + General.random(-1, 1), 3247 + General.random(-1, 1)), 1);
- sleep(50,260);
- }
- }
- } else if(Player.getPosition().distanceTo(ruinsPosition) <= 3){
- return true;
- }
- return false;
- }
- private void withDraw(int itemID[], int amount, String itemName){
- if(bankIsLoaded()){
- RSItem[] item = Banking.find(itemID);
- if(item.length > 0){
- Banking.withdraw(amount, itemID);
- long t =System.currentTimeMillis();
- while(Inventory.getCount(itemID) == 0 && Timing.timeFromMark(t) < 2000){
- sleep(10,200);
- }
- } else {
- stopScript("Out of " + itemName);
- }
- }
- }
- private void stopScript(String message){
- println(message);
- Banking.close();
- Login.logout();
- alive = false;
- }
- private boolean bankIsLoaded(){
- if(Banking.isBankScreenOpen()){
- if(Banking.getAll().length > 0){
- return true;
- }
- }
- return false;
- }
- private void rodTele(String location){
- RSItem[] rod = Equipment.find(SLOTS.RING);
- if(rod.length > 0 && Game.getGameState() == 30 && Player.getAnimation() != 714){
- rod[0].click(location);
- RSTile startpos = Player.getPosition();
- long t = System.currentTimeMillis();
- while(Player.getPosition().equals(startpos) && Timing.timeFromMark(t) < 5000){
- sleep(10,150);
- }
- while(Game.getGameState() == 25 && Timing.timeFromMark(t) < 20000){
- sleep(10,50);
- }
- }
- }
- private boolean needToBank(){
- if(Inventory.getCount(essId) == 0 && getLocation().equals(POSITION.CWARS)){
- return true;
- }
- return false;
- }
- private boolean isLastCharge(){
- RSItem[] ring = Equipment.find(SLOTS.RING);
- if(ring.length > 0){
- RSItemDefinition def = ring[0].getDefinition();
- if(def != null){
- return def.getName().contains("1");
- }
- }
- return false;
- }
- private POSITION getLocation(){
- if(Player.getPosition().distanceTo(chestPosition) < 20){
- return POSITION.CWARS;
- } else if(Player.getPosition().distanceTo(altarPosition) < 20){
- return POSITION.ALTAR;
- } else if(Player.getPosition().distanceTo(duelArenaPosition) < 40){
- return POSITION.ARENA;
- }
- return POSITION.LOST;
- }
- //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