Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package main;
- import java.awt.BasicStroke;
- import java.awt.Color;
- import java.awt.Font;
- import java.awt.Graphics;
- import java.awt.Graphics2D;
- import java.awt.Stroke;
- import org.dreambot.api.methods.Calculations;
- import org.dreambot.api.methods.MethodProvider;
- import org.dreambot.api.methods.bank.BankLocation;
- import org.dreambot.api.methods.map.Area;
- import org.dreambot.api.methods.map.Tile;
- import org.dreambot.api.script.AbstractScript;
- import org.dreambot.api.script.Category;
- import org.dreambot.api.script.ScriptManifest;
- import org.dreambot.api.utilities.Timer;
- import org.dreambot.api.utilities.impl.Condition;
- import org.dreambot.api.wrappers.interactive.Player;
- import org.dreambot.api.wrappers.items.Item;
- import data.Settings;
- @ScriptManifest(author = "Franjey", category = Category.FIREMAKING, name = "Franjey's Log Burner", version = 0.1, description = "Trains Firemaking")
- public class LogBurner extends AbstractScript{
- /////////////////////////////////////////////////////////////////////////////////////////////////
- ////////////***
- ////////////***Variable Declarations
- /////////////////////////////////////////////////////////////////////////////////////////////////
- private final Color color1 = new Color(51, 51, 51, 147);
- private final Color color2 = new Color(0, 233, 165);
- private final Color color3 = new Color(255, 255, 255);
- private final BasicStroke stroke1 = new BasicStroke(5);
- private final Font font1 = new Font("Century Gothic", 0, 13);
- private final Font font2 = new Font("Century Gothic", 0, 13);
- private final Font font3 = new Font("Century Gothic", 0, 13);
- private Timer t = new Timer();
- private LogBurner script;
- private Area rangeArea;
- private Tile burnTile = new Tile(3227, 3159, 0);
- int tinderbox;
- Player myPlayer = getPlayers().myPlayer();
- public void setBurnTile(Tile tile) {
- this.burnTile = tile;
- }
- /////////////////////////////////////////////////////////////////////////////////////////////////
- ////////////***
- ////////////***Enum Declarations
- /////////////////////////////////////////////////////////////////////////////////////////////////
- private State state;
- private enum State{
- WALK_TO_BANK, WALK_TO_BURNAREA, BANK, BURN
- }
- private State getState(){
- if(getInventory().onlyContains("Tinderbox")){
- if(BankLocation.AL_KHARID.getArea(3).contains(getLocalPlayer())) {
- return State.BANK;
- }
- else
- return State.WALK_TO_BANK;
- }
- else {
- if(rangeArea.contains(getLocalPlayer())){
- return State.BURN;
- }
- else
- return State.WALK_TO_BURNAREA;
- }
- }
- /////////////////////////////////////////////////////////////////////////////////////////////////
- ////////////***
- ////////////***onStart()
- /////////////////////////////////////////////////////////////////////////////////////////////////
- @Override
- public void onStart(){
- log("Welcome to the script");
- }
- /////////////////////////////////////////////////////////////////////////////////////////////////
- ////////////***
- ////////////***onExit()
- /////////////////////////////////////////////////////////////////////////////////////////////////
- public void onExit() {
- log("Ending script");
- }
- /////////////////////////////////////////////////////////////////////////////////////////////////
- ////////////***
- ////////////***Main Processing - onLoop()
- /////////////////////////////////////////////////////////////////////////////////////////////////
- @Override
- public int onLoop() {
- getDialogues().clickContinue();
- if(!getWalking().isRunEnabled() && getWalking().getRunEnergy() > (int)Calculations.random(30,50)){
- getWalking().toggleRun();
- }
- state = getState();
- switch(state){
- case WALK_TO_BURNAREA:
- if(getBank().isOpen()) {
- getBank().close();
- }
- if (script.getWalking().walk(Settings.rangeArea.getRandomTile())) {
- MethodProvider.sleepWhile(() -> script.getLocalPlayer().isMoving(), (int)Calculations.gRandom(600, 200));
- }
- break;
- case BURN:
- Item tinderbox = getInventory().getItem("Tinderbox");
- Item logs = getInventory().getItem("Logs");
- if(tinderbox != null && logs != null){
- getWalking().walk(burnTile);
- getInventory().interactWithItem("Tinderbox", "Use");
- getInventory().interactWithItem("Logs", "Use");
- log("Burning logs");
- MethodProvider.sleepUntil(new Condition() {
- @Override
- public boolean verify() {
- return getInventory().getItem("Tinderbox").useOn("Logs");
- }
- }, 7000);
- }
- break;
- case BANK:
- if(getBank().isOpen()){
- getBank().withdrawAll("Logs");
- }
- else{
- getBank().openBank(BankLocation.AL_KHARID.getBankType());
- sleepUntil(new Condition(){
- public boolean verify(){
- return getBank().isOpen();
- }
- },1200);
- }
- break;
- case WALK_TO_BANK:
- if(rangeArea.contains(getLocalPlayer())){
- getWalking().walk(BankLocation.AL_KHARID.getCenter());
- //getWalking().walkTilePath(druidsToBank, Calculations.random(20,30));
- }
- break;
- }
- return Calculations.random(200,300);
- }
- public void onPaint(Graphics g1) {
- if(t == null){
- t = new Timer(0);
- }
- Graphics2D g = (Graphics2D)g1;
- Stroke stroke = g.getStroke();
- g.setColor(color1);
- g.fillRect(3, 4, 199, 159);
- g.setColor(color2);
- g.setStroke(stroke1);
- g.drawRect(3, 4, 225, 233);
- g.setFont(font1);
- g.setColor(color3);
- g.drawString(getManifest().name(), 8, 225); //Will list the name of the script
- g.setFont(font2);
- g.drawString("v" + getManifest().version(), 165, 225); //Will list the version number
- g.setFont(font3);
- g.setStroke(stroke);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement