Jump to content

piscenian

Members
  • Posts

    3
  • Joined

  • Last visited

  • Feedback

    100%

Profile Information

  • Gender
    Male

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

piscenian's Achievements

Newbie

Newbie (1/10)

0

Reputation

  1. Thankyou, that was the main reason i posted the source, i want some feed back, suggestions etc. The ony reason i didnt do mutipe classes is i havent looked into how to call them from another class, if that is even a thing (the L key on my keyboard works like 30% of the time so if you see some words missing the L...thats why.
  2. So I've only been coding / scripting in java for about a weeks time as of 12/29/2018 and i have been working on a WoodCutter / Fetcher. There are still some "issues" Shields are causing me some grief i just need to address them. I am sure im scripting some things in an odd manner but as of this post, the script....mostly works. I've tested the @Trees, @anytreeType- @Longbow / Shortbow / ArrowShafts / Crossbow Stock- @Banking / Anybank- a good bit and it seems to work just fine. Please feel free to provide feed back, i am new and welcome it. Known issues: Fletching Shields isn't fluid enough but mosty works, add in log chop counter, improve upon every function... Features include: Wood cutting > Fetching @ full inventory >Bank/Drop Sitting in bank >Withdraw > Fetch > Deposit Fletches: Arrow Shafts Headless Arrows Arrows Shortbow (u) Longbow (u) Crossbow stock Shield Trees: Tree Oak Willow Maple Yew Magic Hardcoded in banks: Lumbridge Upper Draynor Varrockl E / W Faador E / W Seer's Village / Camelot EdgeVille Catherby Ardougne N / S CODE UPDATED 12/30/2018 9AM cst import java.awt.Color; import java.awt.Graphics2D; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.Component; import java.awt.FlowLayout; import java.awt.Font; import java.awt.GraphicsEnvironment; import java.util.Objects; import java.util.List; import java.util.function.BooleanSupplier; import javax.swing.*; import javax.swing.ImageIcon; import javax.swing.JComboBox; import javax.swing.JFrame; import javax.swing.DefaultComboBoxModel; import javax.swing.JLabel; import javax.swing.JList; import javax.swing.ListCellRenderer; import com.sun.javafx.image.BytePixelSetter; import org.osbot.rs07.api.Skills; import org.osbot.rs07.api.ui.Skill; import org.osbot.rs07.api.map.Area; import org.osbot.rs07.api.map.Position; import org.osbot.rs07.api.map.constants.Banks; import org.osbot.rs07.api.model.NPC; import org.osbot.rs07.api.ui.Message; import org.osbot.rs07.api.ui.Skill; import org.osbot.rs07.script.Script; import org.osbot.rs07.script.ScriptManifest; import java.util.Comparator; import org.osbot.rs07.utility.ConditionalSleep; import org.osbot.rs07.api.ui.RS2Widget; import org.osbot.rs07.api.model.RS2Object; import static org.osbot.rs07.api.map.constants.Banks.FALADOR_WEST; import static org.osbot.rs07.api.map.constants.Banks.VARROCK_WEST; @ScriptManifest(name = "AlphaFletcher", author = "Jared", version = 1.0, info = "", logo = "") public class AlphaFletcher extends Script { private JPanel AlphaFletcher; private JTextField textField; public Boolean finishedGUI = false; int wY, wZ, StartingLocationX, StartingLocationY, Craftcount = 0, Runtimer = 0; String Location, LogType, Product, Tree, Banking, Logs, Metal, ProductCheck, Doing, State, subcom, ShouldBe, CurrentState, FoodName; Area WalkThisWay, StartingPos; Long Logcount, startTime; int amnt = 0; String Items = ""; RS2Object trees; public void JFrame() { JFrame AlphaFletcher; AlphaFletcher = new JFrame(); AlphaFletcher.setTitle("AlphaFletcher"); AlphaFletcher.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); AlphaFletcher.setBounds(100, 100, 400, 250); AlphaFletcher.getContentPane(); AlphaFletcher.setLayout(null); JComboBox comboBox_Location = new JComboBox(); comboBox_Location.setModel(new DefaultComboBoxModel(new String[]{"- Location -", "Bank", "Trees"})); comboBox_Location.setBounds(200, 11, 150, 20); AlphaFletcher.add(comboBox_Location); JComboBox comboBox_Product = new JComboBox(); comboBox_Product.setModel(new DefaultComboBoxModel(new String[]{"- Product -"})); comboBox_Product.setBounds(200, 41, 150, 20); AlphaFletcher.add(comboBox_Product); JComboBox comboBox_Bank = new JComboBox(); comboBox_Bank.setModel(new DefaultComboBoxModel(new String[]{"- Bank -"})); comboBox_Bank.setBounds(200, 71, 150, 20); AlphaFletcher.add(comboBox_Bank); JComboBox comboBox_Wood = new JComboBox(); comboBox_Wood.setModel(new DefaultComboBoxModel(new String[]{"- Wood -"})); comboBox_Wood.setBounds(200, 101, 150, 20); AlphaFletcher.add(comboBox_Wood); JComboBox comboBox_Metal = new JComboBox(); comboBox_Metal.setModel(new DefaultComboBoxModel(new String[]{"- Metal -"})); comboBox_Metal.setBounds(200, 131, 150, 20); AlphaFletcher.add(comboBox_Metal); JButton btnNewButton = new JButton("Start"); btnNewButton.setBounds(200, 161, 100, 23); AlphaFletcher.getContentPane().add(btnNewButton); AlphaFletcher.setVisible(true); comboBox_Location.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { Location = comboBox_Location.getSelectedItem().toString(); switch (Location){ case "Bank": comboBox_Metal.setModel(new DefaultComboBoxModel(new String[]{"- Metal -", "Bronze", "Iron", "Steel", "Adamant", "Rune"})); comboBox_Bank.setModel(new DefaultComboBoxModel(new String[]{"- Bank -", "Lumbridge", "Draynor", "Varrock_East", "Varrock_West", "Falador_East", "Seers' Village", "Falador_West", "EdgeVille", "Catherby", "Ardougne_N", "Ardougne_S"})); comboBox_Product.setModel(new DefaultComboBoxModel(new String[]{"- Product -", "Arrow Shaft", "Headless arrow", "Arrow", "Bolt", "Dart", "shortbow", "longbow", "Crossbow stock", "Shield"})); comboBox_Wood.setModel(new DefaultComboBoxModel(new String[]{"- Wood -", "Logs", "Oak logs", "Willow logs", "Maple logs", "Yew logs", "Magioc logs"})); AlphaFletcher.setVisible(true); break; case "Trees": comboBox_Metal.setModel(new DefaultComboBoxModel(new String[]{"- Metal -", "Bronze", "Iron", "Steel", "Adamant", "Rune"})); comboBox_Bank.setModel(new DefaultComboBoxModel(new String[]{"- Bank -", "Drop", "Lumbridge", "Draynor", "Varrock_East", "Varrock_West", "Falador_East", "Falador_West","Seers' Village", "EdgeVille", "Catherby", "Ardougne_N", "Ardougne_S"})); comboBox_Product.setModel(new DefaultComboBoxModel(new String[]{"- Product -","Headless arrow", "Arrow Shaft", "Arrow", "shortbow", "longbow", "Crossbow stock", "Shield"})); comboBox_Wood.setModel(new DefaultComboBoxModel(new String[]{"- Wood -", "Logs", "Oak logs", "Willow logs", "Maple logs", "Yew logs", "Magioc logs"})); AlphaFletcher.setVisible(true); break; } } }); comboBox_Product.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { Product = comboBox_Product.getSelectedItem().toString(); switch(Product) { case "Arrow": case "Bolt" : case "Dart": comboBox_Metal.setModel(new DefaultComboBoxModel(new String[]{"- Metal -", "Bronze", "Iron", "Steel", "Adamant", "Rune"})); break; default: comboBox_Metal.setModel(new DefaultComboBoxModel(new String[]{"- Ignore -", "Bronze", "Iron", "Steel", "Adamant", "Rune"})); } } }); btnNewButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { AlphaFletcher.setVisible(false); AlphaFletcher.dispose(); ProductCheck = Product; LogType = comboBox_Wood.getSelectedItem().toString(); Banking = comboBox_Bank.getSelectedItem().toString(); Product = comboBox_Product.getSelectedItem().toString(); Metal = comboBox_Metal.getSelectedItem().toString(); switch(Product){ case "shortbow": subcom = "shortbow (u)"; break; case "longbow": subcom = "longbow (u)"; break; case "Crossbow stock": subcom = "stock"; break; case "Shield": subcom = "shield"; break; } switch(LogType){ case "Logs": ProductCheck = Product; Tree = "Tree"; break; case "Oak logs": ProductCheck = "Oak " + subcom; Tree = "Oak"; break; case "Willow logs": ProductCheck = "Willow " + subcom; Tree = "Willow"; break; case "Maple logs": ProductCheck = "Maple " + subcom; Tree = "Maple Tree"; break; case "Yew logs": ProductCheck = "Yew " + subcom; Tree = "Yew"; break; case "Magic logs": ProductCheck = "Magic " + subcom; Tree = "Magic tree"; break; } finishedGUI = true; } }); } @Override public void onStart() { //Code here will execute before the loop is started State = "Starting Script..."; startTime = System.currentTimeMillis(); StartingPos = myPlayer().getArea(4); this.getExperienceTracker().start(Skill.WOODCUTTING); this.getExperienceTracker().start(Skill.FLETCHING); JFrame(); } @Override public void onExit() { } public void WalkToBank(String BankName) throws InterruptedException { switch(Banking){ case "Lumbridge": if(!Banks.LUMBRIDGE_UPPER.contains(myPosition())) { State = "Walking to " + Banking; getWalking().webWalk(Banks.LUMBRIDGE_UPPER); } break; case "Draynor": getWalking().webWalk(Banks.DRAYNOR); break; case "Varrock_East": getWalking().webWalk(Banks.VARROCK_EAST); break; case "Varrock_West": getWalking().webWalk(VARROCK_WEST); break; case "Falador_East": getWalking().webWalk(Banks.FALADOR_EAST); break; case "Falador_West": getWalking().webWalk(FALADOR_WEST); break; case "EdgeVille": getWalking().webWalk(Banks.EDGEVILLE); break; case "Catherby": getWalking().webWalk(Banks.CATHERBY); break; case "Ardougne_N": getWalking().webWalk(Banks.ARDOUGNE_NORTH); break; case "Ardougne_S": getWalking().webWalk(Banks.ARDOUGNE_SOUTH); break; case "Seers' Village": getWalking().webWalk(Banks.CAMELOT); break; } } public int withdrawlcheck() { return (getInventory().getItem(Items).getAmount()); } public void Fletching() throws InterruptedException { Logs = LogType; if (getInventory().getAmount(Logs) >= 1 && (Product != "Shield") || (getInventory().getAmount(Logs) >= 2 && (Product == "Shield"))) { State = "Fletching"; inventory.interact("Use", "Knife"); inventory.interact("Use", LogType); sleep(random(1000, 2000)); switch (LogType) { case "Logs": switch (Product) { case "shortbow": widgets.get(270, 16, 38).interact(); break; case "longbow": widgets.get(270, 17, 38).interact(); break; case "Crossbow stock": widgets.get(270, 18, 38).interact(); break; case "Shield": widgets.get(270, 19, 38).interact(); break; } default: switch (Product) { case "shortbow": widgets.get(270, 15, 38).interact(); break; case "longbow": widgets.get(270, 16, 38).interact(); break; case "Crossbow stock": widgets.get(270, 17, 38).interact(); break; case "Shield": widgets.get(270, 18, 38).interact(); break; } } sleep(random(1500, 2500)); while (myPlayer().isAnimating()) { inventory.deselectItem(); sleep(random(1000, 1500)); } } } public void Chop() throws InterruptedException { RS2Object trees = objects.closest(Tree); if (trees != null) { State = "Chopping"; while (myPlayer().isAnimating() || (myPlayer().isMoving() && (!(getInventory().getEmptySlotCount() <= 1)))) { sleep(random(300, 700)); } trees.interact("Chop down"); sleep(random(1500, 2500)); while (myPlayer().isMoving()) { sleep(random(300, 700)); } } } public void WhatToDoWhenFull() throws InterruptedException { if (!getInventory().contains("log") && (!inventory.isFull())) { Chop(); } if (!getInventory().contains(Product) && inventory.isFull()) { Fletching(); } if (getInventory().inventory.getAmount(LogType)>= (28 - (getInventory().getItem(item -> (!item.nameContains(LogType)))).getAmount()) && (Product != "Shield")){ Fletching(); } if (getInventory().inventory.getAmount(LogType)>=2 && (Product == "Shield")){ Fletching(); } if (getInventory().inventory.getAmount(LogType)<=1 && (Product == "Shield")){ State = "Banking"; WalkToBank(Banking); getBank().open(); getBank().depositAllExcept("Knife", "Bronze axe", "Iron axe", "Steel axe", "Mithril axe", "Adamant axe", "Rune axe", "Dragon axe", "3rd age axe", "Infernal axe"); getWalking().webWalk(StartingPos); Task(); } if (getInventory().inventory.getAmount(ProductCheck) >= 24 && (Banking != "Drop") && (getInventory().inventory.isFull())) { State = "Banking"; WalkToBank(Banking); getBank().open(); getBank().depositAllExcept("Knife", "Bronze axe", "Iron axe", "Steel axe", "Mithril axe", "Adamant axe", "Rune axe", "Dragon axe", "3rd age axe", "Infernal axe"); getWalking().webWalk(StartingPos); Task(); } } public boolean fullinvwithlogs() { return (getInventory().getEmptySlotCount()==0) && (getInventory().getAmount(item -> item.nameContains(" logs")) > 0); } public boolean CheckAxe() { return (getInventory().getItem(item -> item.nameContains(" axe")).getAmount() > 0); } public boolean theplacetobe() { return (grabstartingspot().contains(myPosition())); } public Area grabstartingspot() { return myPlayer().getArea(15); } public boolean isanimated() { return myPlayer().isAnimating(); } public void Task() throws InterruptedException { inventory.deselectItem(); State = "Tasker"; switch (Product) { case "Headless arrow": switch (Location) { case "Bank": WalkToBank(Banking); if (inventory.getAmount("Feather") <= 0 || (inventory.getAmount("Arrow shaft") <= 0)) { BankForHeadlessArrow(); } if (inventory.getAmount("Feather") >= 0 || (inventory.getAmount("Arrow shaft") >= 0)) { State = "Attaching Feathers"; inventory.interact("Use", "Arrow shaft"); inventory.interact("Use", "Feather"); sleep((random(800,1300))); int tempnum = Craftcount; widgets.get(270, 14, 38).interact(); //sleep(random(9500,11000)); while (Craftcount != (tempnum + 150)){ sleep(500); } } case "Trees": RS2Object trees = objects.closest(Tree); if (trees != null && (!getInventory().isFull())) { State = "Chopping1"; while (myPlayer().isAnimating() || (myPlayer().isMoving() && (!(getInventory().getEmptySlotCount() <= 1)))) { sleep(random(300, 700)); } trees.interact("Chop down"); sleep(random(678, 1243)); while (myPlayer().isMoving() || (myPlayer().isAnimating())) { sleep(random(300, 700)); } } if (inventory.isFull() && (getInventory().getAmount("Arrow shaft") >= 1)) { State = "Fetching"; inventory.interact("Use", "Logs"); inventory.interact("Use", "Feather"); sleep(random(800, 1600)); widgets.get(270, 14, 38).interact(); sleep(random(800, 1256)); while (myPlayer().isAnimating()) { sleep(random(300, 700)); } } } break; case "Arrow Shaft": switch (Location) { case "Bank": WalkToBank(Banking); getBank().open(); getBank().depositAllExcept("Knife"); if (!getInventory().contains("Knife")) { getBank().withdraw("Knife", 1); } getBank().withdrawAll(LogType); getBank().close(); case "Trees": if (!getInventory().contains("Knife") && (Banking.equals("Drop"))) { JOptionPane.showMessageDialog(null, "You need to go grab a Knife", "InfoBox: " + "Missing Tools", JOptionPane.INFORMATION_MESSAGE); WalkToBank(Banking); getBank().open(); getBank().withdraw("Knife", 1); } if (!getInventory().contains("Knife") && (!Banking.equals("Drop"))) { WalkToBank(Banking); getBank().open(); getBank().withdraw("Knife", 1); getWalking().webWalk(StartingPos); } trees = objects.closest(Tree); if (trees != null) { State = "Chopping2"; while (myPlayer().isAnimating() || (myPlayer().isMoving() && (!(getInventory().getEmptySlotCount() <= 1)))) { sleep(random(300, 700)); } trees.interact("Chop down"); sleep(random(678, 1243)); while (myPlayer().isMoving()) { sleep(random(300, 700)); } } if (getInventory().isFull()) { State = "full Inv"; Logs = LogType; if (getInventory().getAmount(Logs) >= 1) { State = "Fletching"; inventory.interact("Use", "Knife"); inventory.interact("Use", LogType); sleep(random(1000, 2000)); widgets.get(270, 14, 38).interact(); sleep(random(900, 2000)); while (myPlayer().isAnimating()) { sleep(random(300, 700)); } } break; } } case "shortbow": case "longbow": case "Crossbow stock": case "Shield": switch (Location) { case "Bank": WalkToBank(Banking); getBank().open(); getBank().depositAllExcept("Knife"); if (!getInventory().contains("Knife")) { getBank().withdraw("Knife", 1); } getBank().withdrawAll(LogType); getBank().close(); WhatToDoWhenFull(); case "Trees": trees = objects.closest(Tree); if (trees != null && (!getInventory().inventory.isFull())) { State = "Chopping"; //impment some status checking and if fetching and logs to fetch...keep fetching instead of chopping while (myPlayer().isAnimating() || (myPlayer().isMoving() && (!(getInventory().getEmptySlotCount() <= 2)))) { sleep(random(500, 900)); } trees.interact("Chop down"); sleep(random(678, 1243)); if (myPlayer().isMoving()) { sleep(random(300, 700)); } } if (getInventory().inventory.getEmptySlotCount() <=0) { State = "Deciding on Full inv"; WhatToDoWhenFull(); } } if (getInventory().inventory.getAmount(ProductCheck) >= 1 && (Banking == "Drop")) { Dropping(); Task(); } if (getInventory().inventory.getAmount(ProductCheck) >= 24 && (Banking != "Drop") && (getInventory().inventory.isFull())) { WalkToBank(Banking); getBank().open(); getBank().depositAllExcept("Knife", "Bronze axe", "Iron axe", "Steel axe", "Mithril axe", "Adamant axe", "Rune axe", "Dragon axe", "3rd age axe", "Infernal axe"); getWalking().webWalk(StartingPos); Task(); } } } public void Dropping() throws InterruptedException { State = "Dropping"; inventory.dropAll(ProductCheck); Task(); } public void BankForHeadlessArrow() throws InterruptedException { State = "Banking Items"; getBank().open(); getBank().depositAll(); getBank().withdrawAll("Arrow shaft"); getBank().withdrawAll("Feather"); getBank().close(); } @Override public int onLoop() throws InterruptedException { if (finishedGUI == true) { Task(); } return 75; } @Override public void onMessage(Message message) throws java.lang.InterruptedException { String msg = message.getMessage().toLowerCase(); if (msg.contains("i can't reach that!")) { //RunForrestRun(); } if (msg.contains("you get some " + LogType.toLowerCase() + ".")) { Logcount++; } if (msg.contains("you carefully cut the wood into a " + Product.toLowerCase() + ".")) { Craftcount++; } if (msg.contains("you carefully cut the wood into 15 arrow shafts.")) { Craftcount++; } if (msg.contains("you carefully cut the wood into 30 arrow shafts.")) { Craftcount++; } if (msg.contains("you carefully cut the wood into 45 arrow shafts.")) { Craftcount++; } if (msg.contains("you carefully cut the wood into 60 arrow shafts.")) { Craftcount++; } if (msg.contains("you attach feathers to 15 arrow shafts.")) { Craftcount = Craftcount + 15; } if (msg.contains("you require 2 logs to do that.")) { if (getInventory().getAmount(ProductCheck) >= 1 && (Banking == "Drop")) { Dropping(); Task(); } if (getInventory().getAmount(ProductCheck) >= 24 && (Banking != "Drop") && (inventory.isFull())) { WalkToBank(Banking); getBank().open(); getBank().depositAllExcept("Knife", "Bronze axe", "Iron axe", "Steel axe", "Mithril axe", "Adamant axe", "Rune axe", "Dragon axe", "3rd age axe", "Infernal axe"); getWalking().webWalk(StartingPos); Task(); } } } @Override public void onPaint(Graphics2D g) { g.setColor (Color.gray); g.fill3DRect (2, 20, 230, 100, true); g.setColor(Color.white); g.drawString("AlphaFletcher by Jared", 5, 35); g.drawString("State: " + State, 5, 50); g.drawString("Making: " + ProductCheck, 5, 65); g.drawString("Action: " + Doing, 5, 80); g.drawString("Logs Chopped: " + Logcount, 5, 95); g.drawString("Logs Fletched: " + Craftcount, 5, 110); g.drawString("Runtime: " + this.formatTime(System.currentTimeMillis() - this.startTime), 10, 315); g.drawString("TTL Woodcutting: " + this.formatTime(this.getExperienceTracker().getTimeToLevel(Skill.WOODCUTTING)), 10, 330); g.drawString("TTL Fletching: " + this.formatTime(this.getExperienceTracker().getTimeToLevel(Skill.FLETCHING)), 290, 330); } private String formatTime(long time) { long s = time / 1000L; long m = s / 60L; long h = m / 60L; s %= 60L; m %= 60L; h %= 24L; return String.format("%02d:%02d:%02d", h, m, s); } }
×
×
  • Create New...