October 16, 201411 yr Hello everyone! I have just completed my first script ever!!! I'm really happy, because I've always wanted to make a bot. Anyway, this script is fairly simple, but it's aesthetically pleasing. It has a nice paint (my opinion) and power-fishes shrimp/anchovies. It will run anywhere as long as you have a small net in your inventory. The script has really bad anti-ban at the moment, so I will be updating that soon. Please enjoy the script, and GIVE FEEDBACK! I really want to learn, and feedback is the best way to learn. Please tear my code to shreds if you want to, it just helps me learn. Thanks! (The script has been updated, and the file has not been. The only change was in the timer, no big deal) Thank you to: Pug, ESPECIALLY Apaec, Divinity, igetbanned -Computor .jar file (and file scan) https://mega.co.nz/#!MsdEUBgR!url1xPQVslKHkHLyFRayGg0OX6oIBlXlTVCVI4NPehY https://www.virustotal.com/en/file/ff16d4c146470a9175d8ad31e46dd86b0154f3311d56c5a60d426b7f29917792/analysis/1413455531/ Code: import org.osbot.rs07.api.model.NPC; import org.osbot.rs07.script.Script; import org.osbot.rs07.script.ScriptManifest; import org.osbot.rs07.api.ui.Message; import org.osbot.rs07.api.ui.Message.MessageType; import org.osbot.rs07.api.ui.Skill; import org.osbot.rs07.api.ui.Tab; import java.text.DecimalFormat; import java.util.concurrent.TimeUnit; import java.awt.*; import java.io.IOException; import java.net.URL; import java.awt.Font; import javax.imageio.ImageIO; @ScriptManifest(author = "Computor", info = "My first script. Has bugs still. Anti-ban sucks. " + "Start \nnear ANY shrimp location, have a small fishing net in \nyour inventory", name = "Simple Power-Shrimper", version = 1.0, logo = "") public class shrimpPowerFisher extends Script { private static final int[] FISHING_ID = {1528 , 1525}; //declarations for the paint (used in math) private static final int xpPerShrimp = 10; private static final int xpPerAnchovie = 40; private int shrimpCaught = 0; private int xpGained = 0; private int xpPerHour; private int totalXpPerHour; private long timeBegan; private long timeRan; private String logInfo; @Override public void onStart() { log("Simple power-fisher for anchovies and shrimps. Run anywhere."); timeBegan = System.currentTimeMillis(); logInfo = "None"; } private enum State { FISH, DROP }; private State getState() { if (inventory.isFull()){ logInfo = "Dropping."; //changes status on paint return State.DROP; } return State.FISH; } @Override public int onLoop() throws InterruptedException { switch (getState()) { case FISH: if (!myPlayer().isAnimating()) { NPC Fishing_spot = npcs.closest(FISHING_ID); if(Fishing_spot != null) { if (!inventory.isFull()) { Fishing_spot.interact("Net"); logInfo = "Casting net."; sleep(random(800,1200)); antiban(); } } } break; case DROP: inventory.dropAllExcept(303); break; } logInfo = "Fishing."; //changes status on paint return random(0, 50); } @Override public void onMessage(Message m) { if (m.getType() == MessageType.GAME) { String c = m.getMessage().toLowerCase(); //not sure if this helped anything, didn't test taking this out. try { if (c.contains("you catch some shrimps.") || c.contains("You catch some shrimps.")) { shrimpCaught++; //stuff for paint xpGained += xpPerShrimp;} //stuff for paint else if (c.contains("you catch some anchovies.") || c.contains("You catch some anchovies.")){ shrimpCaught++; xpGained += xpPerAnchovie; } } catch (Exception e) { //not sure if I need the catch, it works fine. e.printStackTrace(); } } } private void antiban() throws InterruptedException { if(myPlayer().isAnimating()) { //shitty anti-ban, needs updating. logInfo = "Antiban."; //changes status on paint getTabs().open(Tab.SKILLS); sleep(100 + random(300, 700)); getSkills().hoverSkill(Skill.FISHING); sleep(100 + random(3000, 4000)); getTabs().open(Tab.INVENTORY); sleep(100 + random(500, 700)); getMouse().moveRandomly(); } } // PAINT VARIABLE DECLARATIONS private final Image bg = getImage("http://s14.postimg.org/wvkn4w3cx/Untitled_3.png"); private Image getImage(String url) { try { return ImageIO.read(new URL(url)); } catch (IOException e) {} return null; } @Override public void onExit() { log("End of fishing script."); //logs in console, not paint } @Override public void onPaint(Graphics2D g) { Font SansSerif = new Font ("SansSerif", Font.BOLD, 16); timeRan = System.currentTimeMillis() - this.timeBegan; DecimalFormat df = new DecimalFormat("#"); Graphics2D gr = g; g.drawImage(bg, 2, 277, null); g.setFont (SansSerif); //changes font type to SansSerif g.setColor(Color.BLACK); //changes font color to black g.drawString(ft(timeRan), 111, 465); g.setFont (SansSerif); //possibly don't need this again? haven't tested. g.setColor(Color.BLACK); g.drawString("" + df.format(xpGained) , 274, 424); g.setFont (SansSerif); g.setColor(Color.BLACK); g.drawString("" + df.format(shrimpCaught) , 111, 424); xpPerHour = (int)(xpGained / ((System.currentTimeMillis() - timeBegan) / 3600000.0D)); totalXpPerHour = xpPerHour; g.drawString("" + df.format(totalXpPerHour) + "/hr", 274, 379); g.drawString(logInfo, 111, 379); } // FORMAT TIME METHOD (code used from Apaec, thank you Apaec.) private String ft(long duration) { String res = ""; long days = TimeUnit.MILLISECONDS.toDays(duration); long hours = TimeUnit.MILLISECONDS.toHours(duration) - TimeUnit.DAYS.toHours(TimeUnit.MILLISECONDS.toDays(duration)); long minutes = TimeUnit.MILLISECONDS.toMinutes(duration) - TimeUnit.HOURS.toMinutes(TimeUnit.MILLISECONDS.toHours(duration)); long seconds = TimeUnit.MILLISECONDS.toSeconds(duration) - TimeUnit.MINUTES.toSeconds(TimeUnit.MILLISECONDS.toMinutes(duration)); if (days == 0) { if (minutes < 10){ res = (hours + ":0" + minutes + ":" + seconds); if (seconds < 10){ res = (hours + ":0" + minutes + ":0" + seconds); } } else res = (hours + ":" + minutes + ":" + seconds); } else { res = (days + ":" + hours + ":" + minutes + ":" + seconds); } return res; } } Screenshot (short runtime I know, just wanted to upload a screenshot): Edited October 17, 201411 yr by computor
October 17, 201411 yr Awesome job man. I just needed one too. Problem is...it's not working in Draynor Village. I ran it...it does nothing but stand there. I don't know why a lot of my scripts aren't working.
October 17, 201411 yr Author Hmmm, I'll test it out tomorrow, give me a few hours. Make sure when you run it that you are right next to the fishing spots, it won't walk to them from the bank. Edited October 17, 201411 yr by computor
November 30, 201411 yr Thanks, using this right now. EDIT: make this bank instead of dropping at al Kalarhid and this would be baws. Edited December 1, 201411 yr by Kenn