Tasemu Posted May 16, 2017 Share Posted May 16, 2017 (edited) Hey guys, here is my first script for OSBot. The first of hopefully many more. I have open sourced it and you can find the script and the link to Github online. Please feel free to post any comments and constructive criticism of my script right here and don't be shy as I hope to get a few new techniques out of this share to improve my future scripts. If you wanna say thanks for the script then that would also make me pretty happy haha. Welp enjoy ^^ Credits to so many awesome people on this forum. If you have posted on one of my threads, or if I have used a method you shared then please post below and i'll credit you for sure! Progress reports coming soon... running it now. Github: https://github.com/Tasemu/osbot_descrete_gulls (fork me baby) package descrete_gulls; import org.osbot.rs07.api.map.Area; import org.osbot.rs07.api.model.NPC; import org.osbot.rs07.api.ui.Skill; import org.osbot.rs07.api.util.GraphicUtilities; import org.osbot.rs07.script.Script; import org.osbot.rs07.script.ScriptManifest; import org.osbot.rs07.utility.ConditionalSleep; import java.awt.*; import java.util.EnumSet; @ScriptManifest(author = "Tasemu", info = "Kill seagulls at Port Sarim", name = "Descrete Gulls", version = 1.1, logo = "") public class main extends Script { private Area docks = new Area( new int[][]{ { 3026, 3241 }, { 3030, 3241 }, { 3030, 3238 }, { 3047, 3238 }, { 3047, 3234 }, { 3030, 3234 }, { 3030, 3211 }, { 3026, 3211 }, { 3026, 3216 }, { 3018, 3216 }, { 3018, 3220 }, { 3026, 3220 } } ); private NPC target; private enum State { WAIT, WALK, ATTACK }; private EnumSet<Skill> skillToTrain = EnumSet.of(Skill.ATTACK, Skill.STRENGTH, Skill.DEFENCE, Skill.HITPOINTS); private long startTime; private int gullsKilled = 0; @Override public void onStart() { log("Welcome to Descrete Gulls."); log("version: " + getVersion()); startTime = System.currentTimeMillis(); for (Skill skill : skillToTrain) { getExperienceTracker().start(skill); } } private State getState() { NPC gull = getNpcs().closest("Seagull"); if (target != null && myPlayer().isInteracting(target)) return State.WAIT; if (!docks.contains(myPlayer())) return State.WALK; if ( gull != null && !gull.isUnderAttack() && !gull.isHitBarVisible() ) return State.ATTACK; return State.WAIT; } @Override public int onLoop() throws InterruptedException { switch (getState()) { case ATTACK: target = getNpcs().closest("Seagull"); if (target != null) { if (target.interact("Attack")) { new ConditionalSleep(random(3000, 5000)) { @Override public boolean condition() throws InterruptedException { return target != null && target.getHealthPercent() > 0; } }.sleep(); } } break; case WALK: getWalking().webWalk(docks); break; case WAIT: if (target != null && target.getHealthPercent() == 0) { this.gullsKilled++; this.target = null; } if (this.getDialogues().isPendingContinuation()) { this.getDialogues().clickContinue(); } sleep(random(500, 700)); break; } return random(200, 300); } @Override public void onExit() { log("Bye!"); } @Override public void onPaint(Graphics2D g) { final long runTime = System.currentTimeMillis() - startTime; drawMouse(g); g.setColor(Color.WHITE); g.drawString("Descrete Gulls Public v" + this.getVersion(), 10, 40); g.drawString("Status: " + getState().toString().toLowerCase() + "ing", 10, 55); g.drawString("Time running: " + formatTime(runTime), 10, 70); g.drawString("Gulls Wasted: " + this.gullsKilled, 10, 85); int trainingPaintMargin = 0; for (Skill skill : skillToTrain) { if (getExperienceTracker().getGainedXP(skill) > 0) { g.drawString(skill.toString().toLowerCase() + " xp: " + getExperienceTracker().getGainedXP(skill), 10, 100 + trainingPaintMargin); trainingPaintMargin += 15; } } if (target != null && target.exists()) { g.setColor(Color.RED); GraphicUtilities.drawWireframe(getBot(), g, target); } } public final String formatTime(final long ms){ long s = ms / 1000, m = s / 60, h = m / 60; s %= 60; m %= 60; h %= 24; return String.format("%02d:%02d:%02d", h, m, s); } private void drawMouse(Graphics graphics) { ((Graphics2D) graphics).setRenderingHints( new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON)); Point pointer = mouse.getPosition(); Graphics2D spinG = (Graphics2D) graphics.create(); Graphics2D spinGRev = (Graphics2D) graphics.create(); spinG.setColor(new Color(255, 255, 255)); spinGRev.setColor(Color.cyan); spinG.rotate(System.currentTimeMillis() % 2000d / 2000d * (360d) * 2 * Math.PI / 180.0, pointer.x, pointer.y); spinGRev.rotate(System.currentTimeMillis() % 2000d / 2000d * (-360d) * 2 * Math.PI / 180.0, pointer.x, pointer.y); final int outerSize = 20; final int innerSize = 12; spinG.setStroke(new BasicStroke(1.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND)); spinGRev.setStroke(new BasicStroke(1.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND)); spinG.drawArc(pointer.x - (outerSize / 2), pointer.y - (outerSize / 2), outerSize, outerSize, 100, 75); spinG.drawArc(pointer.x - (outerSize / 2), pointer.y - (outerSize / 2), outerSize, outerSize, -100, 75); spinGRev.drawArc(pointer.x - (innerSize / 2), pointer.y - (innerSize / 2), innerSize, innerSize, 100, 75); spinGRev.drawArc(pointer.x - (innerSize / 2), pointer.y - (innerSize / 2), innerSize, innerSize, -100, 75); } } Edited May 16, 2017 by Tasemu 2 Quote Link to comment Share on other sites More sharing options...
Phaibooty Posted May 16, 2017 Share Posted May 16, 2017 Grats on your release! Quote Link to comment Share on other sites More sharing options...
TrapMan Posted May 16, 2017 Share Posted May 16, 2017 Congratulations on your release. Quote Link to comment Share on other sites More sharing options...
FaxeKondi Posted May 16, 2017 Share Posted May 16, 2017 GJ! Quote Link to comment Share on other sites More sharing options...
Nym Posted May 16, 2017 Share Posted May 16, 2017 Nice! Quote Link to comment Share on other sites More sharing options...
Tyelr Posted May 17, 2017 Share Posted May 17, 2017 Looks nice and neat to me Quote Link to comment Share on other sites More sharing options...
Prolax Posted May 17, 2017 Share Posted May 17, 2017 Instead of states you could just use methods. I'll test it today. Quote Link to comment Share on other sites More sharing options...
Tasemu Posted May 17, 2017 Author Share Posted May 17, 2017 2 hours ago, Prolax said: Instead of states you could just use methods. I'll test it today. Sweet, how do you mean man? just have each method check if it should be running itself? Is that similar to a task based script or do you mean something else? ^^ Quote Link to comment Share on other sites More sharing options...
Prolax Posted May 17, 2017 Share Posted May 17, 2017 7 hours ago, Tasemu said: Sweet, how do you mean man? just have each method check if it should be running itself? Is that similar to a task based script or do you mean something else? ^^ For example in your onLoop, you just call the method attackNpc(), no need for states. But that's just how I prefer it. if (gull != null && !gull.isUnderAttack() && !gull.isHitBarVisible()) attackNpc(); } I tried the script, the attacking of the next seagull could be a bit faster. Very nice for your first script though. Quote Link to comment Share on other sites More sharing options...
spectre007 Posted May 22, 2017 Share Posted May 22, 2017 hey can you help me how to add. which file do i need to move to my local script olfder? Quote Link to comment Share on other sites More sharing options...
Tasemu Posted May 23, 2017 Author Share Posted May 23, 2017 I haven't included a .jar file as I assumed the SDN is already inundated with basic combat scripts. You can easily compile this yourself with eclipse. Would you like me to upload the jar? 1 Quote Link to comment Share on other sites More sharing options...
Prolax Posted May 23, 2017 Share Posted May 23, 2017 17 hours ago, spectre007 said: hey can you help me how to add. which file do i need to move to my local script olfder? As said, compile it to a jar using eclipse or intelliJ. Quote Link to comment Share on other sites More sharing options...
Volta Posted May 23, 2017 Share Posted May 23, 2017 I love seagulls! Quote Link to comment Share on other sites More sharing options...
jerritwijksma Posted May 23, 2017 Share Posted May 23, 2017 How do i make this one work? I don't know how to run it. Quote Link to comment Share on other sites More sharing options...
spectre007 Posted May 28, 2017 Share Posted May 28, 2017 On 2017-5-23 at 10:15 AM, Tasemu said: I haven't included a .jar file as I assumed the SDN is already inundated with basic combat scripts. You can easily compile this yourself with eclipse. Would you like me to upload the jar? please upload the jar much easier for everyone Quote Link to comment Share on other sites More sharing options...