Kirito 5 Share Posted December 4, 2016 Title says it all also my cought counter is broke.... package PowerFisher; import org.dreambot.api.script.AbstractScript; import org.dreambot.api.methods.Calculations; import org.dreambot.api.methods.interactive.NPCs; import org.dreambot.api.methods.map.Area; import org.dreambot.api.methods.map.Tile; import org.dreambot.api.methods.skills.Skill; import org.dreambot.api.script.Category; import org.dreambot.api.script.ScriptManifest; import org.dreambot.api.script.listener.PaintListener; import org.dreambot.api.utilities.Timer; import org.dreambot.api.wrappers.interactive.GameObject; import org.dreambot.api.wrappers.interactive.NPC; 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; @ScriptManifest(author = "Kirito", name = "Simple Power Fisher", version = 0.01, description = "Simply Fishes in Lumbridge Swamp.", category = Category.FISHING) public class PowerFisher extends AbstractScript implements PaintListener { private long startTime = System.currentTimeMillis(); private int cought = 0; public State State; public void onStart() { //getCamera().rotateToPitch(383); getCamera().mouseRotateTo(Calculations.random(1,383), Calculations.random(1,383)); getSkillTracker().start(Skill.FISHING); startTime = System.currentTimeMillis(); //Area myArea = new Area(new Tile(3281, 3370), new Tile(3290, 3370), new Tile(3290, 3361), new Tile(3282, 3361)); //myArea.contains(getLocalPlayer()); } private enum State { WELCOME, FISH, DROP, NO_STATE, ROTATE }; private State getState() { NPC spot = getNpcs().closest("Fishing spot"); if (spot != null && spot.isOnScreen() && !getInventory().isFull() && getInventory().contains(item -> item != null && item.getName() != null && item.getName().contains("net"))) { { return State.FISH; } } else if (getInventory().isFull()) { return State.DROP; } return State.NO_STATE; } private String stateParser() { if (State == State.FISH) { return "FISHING"; } else if (State == State.DROP) { return "Dropping"; } else if (State == State.NO_STATE) { return "No idea"; } else return "Waiting"; } public void onExit() { } //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, 14); private final Image img1 = getImage("http://i63.tinypic.com/346qbe1.png"); public void onRepaint(Graphics g1) { Graphics2D g = (Graphics2D)g1; g.drawImage(img1, 4, -1, null); g.setFont(font1); g.setColor(color1); g.drawString("Simple Power Fisher V0.01", 546, 461); } //END: Code generated using Enfilade's Easel @Override public int onLoop() { NPC spot = getNpcs().closest("Fishing spot"); State = getState(); switch(State){ case FISH: fish(spot); break; case ROTATE: rotate(); break; case DROP: drop(); break; case NO_STATE: break; } return 100; } private double progressBar() { return ((double) (getSkills().getExperience(Skill.FISHING) - getSkills().getExperienceForLevel(getSkills().getRealLevel(Skill.FISHING))) / (getSkills().getExperienceForLevel(getSkills().getRealLevel(Skill.FISHING) + 1) - getSkills().getExperienceForLevel(getSkills().getRealLevel(Skill.FISHING)))) * 100; } @Override public void onPaint(Graphics g) { g.setColor(new Color(48, 48, 48, 180)); //g.fillRect(5, 240, 370, 99); g.setFont(new Font(Font.MONOSPACED, Font.ROMAN_BASELINE, 14)); g.setColor(Color.BLUE); //g.drawString("Simple Power FISHper V0.01 -", 10, 260); g.drawString("Runtime: " + Timer.formatTime(System.currentTimeMillis() - startTime), 10, 260); g.drawString("Exp/hr: " + getSkillTracker().getGainedExperiencePerHour(Skill.FISHING) , 10, 280); g.drawString("Exp gained: " + getSkillTracker().getGainedExperience(Skill.FISHING), 10, 300); g.drawString("Levels gained: " + getSkillTracker().getGainedLevels(Skill.FISHING) , 220, 320); // g.drawRect(10, 310, 100, 15); g.fillRect(10, 310, (int) progressBar(), 15); g.drawString("Fish Cought: " + cought, 220, 300); g.drawString("State: " + stateParser(), 220, 280); g.drawImage(img1, -5, -1, null); g.setFont(font1); g.setColor(color1); g.drawString("Simple Power Fisher V0.01", 546, 461); } public void fish(NPC spot) { int fID = 317; if (getInventory().contains(i -> i.getName().contains("net")) && !getInventory().isFull()) { if (getLocalPlayer().distance(spot) >3) { getWalking().walk(spot); sleepUntil(() ->!getLocalPlayer().isMoving(), 300); }else if (!getLocalPlayer().isAnimating() && !getLocalPlayer().isMoving() && spot.exists() && spot.isOnScreen()) { //&& myORE != null int fCount = getInventory().count(438); spot.interact("Net"); if(getLocalPlayer().isAnimating()) { sleepUntil(() -> getInventory().count(fID) > fCount, Calculations.random(10000, 15000)); cought++; } }else getCamera().rotateToEntity(getGameObjects().closest("spot")); //}else getCamera().mouseRotateTo(Calculations.random(1,383), Calculations.random(1,383)); }else if (getInventory().isFull()) { State = State.DROP; } } // } private void rotate() { getCamera().mouseRotateTo(Calculations.random(1,383), Calculations.random(1,383)); State = State.FISH; } private void drop() { if (getInventory().isFull()) { //getInventory().dropAll("ore"); log("Status: Dropping all Ores"); getInventory().dropAllExcept(f -> f != null &&f.getName().contains("net")); }else if (getInventory().isFull()) { State = State.FISH; } } } Link to comment Share on other sites More sharing options...
Mohammed 21 Share Posted December 4, 2016 If it is fishing it is animation ~50% of the time, use interacting entity instead. Link to comment Share on other sites More sharing options...
Kirito 5 Author Share Posted December 4, 2016 If it is fishing it is animation ~50% of the time, use interacting entity instead. !getLocalPlayer().isAnimating() into !getLocalPlayer().interacting(spot)? Link to comment Share on other sites More sharing options...
Soldtodie 76 Share Posted December 4, 2016 !getLocalPlayer().isAnimating() into !getLocalPlayer().interacting(spot)? It should be .isInteracting(spot) Because a fishing spot is like a npc. Link to comment Share on other sites More sharing options...
Kirito 5 Author Share Posted December 4, 2016 It should be .isInteracting(spot) Because a fishing spot is like a npc. thats fixed Link to comment Share on other sites More sharing options...
Nuclear Nezz 2040 Share Posted December 4, 2016 your caught counter checks if it's animating right after it interacts with the fishing spot, you don't get a fish by clicking the spot, you get it periodically throughout the animations after fishing. You should probably add something either in onMessage or an inventory tracker. Link to comment Share on other sites More sharing options...
Kirito 5 Author Share Posted December 4, 2016 your caught counter checks if it's animating right after it interacts with the fishing spot, you don't get a fish by clicking the spot, you get it periodically throughout the animations after fishing. You should probably add something either in onMessage or an inventory tracker. what about placing the cought counter straight behind the cast method? @ ok thats fixed but now the cought/ph is fucked up -.- it keeps saying [2147483647]....... Link to comment Share on other sites More sharing options...
Mohammed 21 Share Posted December 4, 2016 !getLocalPlayer().isAnimating() into !getLocalPlayer().interacting(spot)? When your fishing it isnt anymating 100% of the time you got up periodically, then it isnt animating for a small time. So you should check if you're interacting with the fishingspot. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.