Strange_Fk Posted September 18, 2015 Share Posted September 18, 2015 I decided to make a Yew cutter at edgeville since there are no free ones and my fresh account woodcutter and fire maker has gotten me the sufficient levels to cut Yews. I stripped the old script of the contents which left a template some people might want to use, along with a notes on paint in case some people don't know what to do to change paint. Some of the methods used to check the paint were made when i first started learning javascript, that being said I know there are better methods but since they work I have been too lazy to simplify them... import org.osbot.rs07.Bot; import org.osbot.rs07.api.model.*; import org.osbot.rs07.event.*; import org.osbot.rs07.event.Event; import org.osbot.rs07.input.mouse.MiniMapTileDestination; import org.osbot.rs07.input.mouse.awt.BotMouseEvent; import org.osbot.rs07.script.Script; import org.osbot.rs07.script.ScriptManifest; import org.osbot.rs07.api.map.Position; import org.osbot.rs07.api.ui.Skill; import java.awt.*; import org.osbot.rs07.api.map.Area; import java.awt.Font; import java.awt.event.MouseEvent; import java.io.File; import java.io.IOException; import java.net.URI; import java.nio.file.*; import java.util.Iterator; import java.util.concurrent.TimeUnit; import static org.osbot.rs07.api.ui.Skill.WOODCUTTING; @ScriptManifest(author = "Strange's Simple Script's", info = "Chops Yews in Edgeville", name = "Yew Chopper", version = .2, logo = "") public class YewChopper extends Script { /////////////////////////PAINT VARIABLES//////////////////////////// public int startExp; public int paintCheck; public int expFor; public int expTil; public int startExp2; public int currentExp; public int expGained; public int currentLvl; public int nextLvl; public int sharksCaught; public int fontSize; public int center; public int mouseX; public int mouseY; public int fmEXPStart; public int fmEXPCurrent; public int fmEXPGained; private long timeBegan; private long timeRan; public void onStart() { timeBegan = System.currentTimeMillis(); currentLvl = getSkills().getDynamic(WOODCUTTING); nextLvl = currentLvl + 1; expFor = skills.getSkills().getExperienceForLevel(nextLvl); expTil = skills.experienceToLevel(WOODCUTTING); fmEXPStart = skills.getSkills().getExperience(Skill.FIREMAKING); startExp2 = expFor - expTil; startExp = skills.getSkills().getExperience(WOODCUTTING); expGained = currentExp - startExp; paintCheck = startExp - startExp2; if (startExp != startExp2 || expGained > 0) { return; } this.log("Strange's Yew Chopper has started"); } public int onLoop() throws InterruptedException { State current = this.getState(); //this.log(current.toString()); switch (current) { } return (random(211, 761)); } public void forLoop1() throws InterruptedException { } public void forLoop2() throws InterruptedException { } public void forLoop3() throws InterruptedException { } public void forLoop4() throws InterruptedException { } public void forLoop5() throws InterruptedException { } public void forLoop6() throws InterruptedException { } public void forLoop7() throws InterruptedException { } public void onPaint(Graphics2D g) { Graphics2D gr = g; fmEXPCurrent = skills.getExperience(Skill.FIREMAKING); fmEXPGained = fmEXPCurrent - fmEXPStart; currentExp = skills.getExperience(Skill.WOODCUTTING); expGained = currentExp - startExp; sharksCaught = expGained / 15; timeRan = System.currentTimeMillis() - this.timeBegan; fontSize = 26; center = (fontSize/3); mouseX = getMouse().getPosition().x - center; mouseY = getMouse().getPosition().y + center; Font crossHair2 = new Font("SANS_SERIF", Font.BOLD, fontSize); //////////////////////MOUSE CROSSHAIR OUTLINE COLOR///////////////////////// g.setColor(Color.BLACK); //////////////////////////////////////////////////////////////////////////// g.setFont(crossHair2); g.drawString("+", mouseX, mouseY); Font crossHair = new Font("SANS_SERIF", Font.PLAIN, fontSize); //////////////////////MOUSE CROSSHAIR MAIN FILL COLOR/////////////////////// g.setColor(Color.MAGENTA); //////////////////////////////////////////////////////////////////////////// g.setFont(crossHair); g.drawString("+", mouseX, mouseY); Font normal = new Font("SANS_SERIF", Font.BOLD, 14); Font italic = new Font("SANS_SERIF", Font.ITALIC, 12); g.setColor(Color.WHITE); g.setFont(normal); /////////////////PAINT TEXT CONTENTS FOLLOWED BY THEIR POSITION///////////// g.drawString("Strange's Account Starter", 8, 30); g.drawString("Time Elapsed: " + ft(timeRan), 8, 45); g.drawString("Woodcutting Exp Gained: " + expGained, 8, 60); g.drawString("Firemaking Exp Gained " + fmEXPGained, 8, 75); g.setFont(italic); g.drawString(this.getState().toString(), 8, 90); } 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) { res = (hours + ":" + minutes + ":" + seconds); } else { res = (days + ":" + hours + ":" + minutes + ":" + seconds); } return res; } public void onExit() { this.log("Script ended! Please notify of any bugs you may come across, I will try my best to fix as soon as possible."); this.log("Total EXP Gained: " + expGained); this.log("Yews Chopped " + sharksCaught); } public State getState() { return State.IDLE; } public enum State { IDLE } } The paint has exp gained, and a mouse crosshair Quote Link to comment Share on other sites More sharing options...
Bobrocket Posted September 18, 2015 Share Posted September 18, 2015 The paint code itself looks alright, the rest is a bit messy. A few tips: Learn some proper variable notation. I would personally recommend hungarian notation, as this will become more useful in larger programs. public int xVal = 0; public int intXCoordinate = 0; Which one of those is easier to read? Hungarian notation simply implies that you write your data type in lower case at the start, and then you give the variable a meaningful name. With modern IDEs the need for hungarian notation doesn't apply so much, but it's still useful and easy to read. On top of this note, rename your variables as it is very confusing to read. As far as paints are concerned, I would recommend trying something such as my PaintLib. It easily allows the manipulation of paint components in an OOP manner, and is also fairly easy to read in the long run. Good to see people learning though, good job! 1 Quote Link to comment Share on other sites More sharing options...
fixthissite Posted September 18, 2015 Share Posted September 18, 2015 (edited) The paint code itself looks alright, the rest is a bit messy. A few tips: Learn some proper variable notation. I would personally recommend hungarian notation, as this will become more useful in larger programs. public int xVal = 0;public int intXCoordinate = 0;Which one of those is easier to read? Hungarian notation simply implies that you write your data type in lower case at the start, and then you give the variable a meaningful name. With modern IDEs the need for hungarian notation doesn't apply so much, but it's still useful and easy to read.On top of this note, rename your variables as it is very confusing to read. As far as paints are concerned, I would recommend trying something such as my PaintLib. It easily allows the manipulation of paint components in an OOP manner, and is also fairly easy to read in the long run. Good to see people learning though, good job! http://stackoverflow.com/questions/111933/why-shouldnt-i-use-hungarian-notationCompilers handle semantic analysis. No need to mix type semantics it into your code. It could hurt during refactoring. If you're going to use hungarian notation, use it the right way (apps hungarian https://en.wikipedia.org/wiki/Hungarian_notation#Systems_vs._Apps_Hungarian) Edited September 18, 2015 by fixthissite 2 Quote Link to comment Share on other sites More sharing options...
Bobrocket Posted September 18, 2015 Share Posted September 18, 2015 http://stackoverflow.com/questions/111933/why-shouldnt-i-use-hungarian-notation Compilers handle semantic analysis. No need to mix type semantics it into your code. It could hurt during refactoring. There's no need, but personally I think it looks cleaner. I am of course biased since I'm using Pascal at college and the IDE I'm using actually requires a DOS emulator. It's always good to get into some good conventions, and obviously now that you can view types in an IDE by hovering over the variable it has more or less become redundant. Notation overall is just up to preference, after all. Quote Link to comment Share on other sites More sharing options...
Strange_Fk Posted September 19, 2015 Author Share Posted September 19, 2015 fixthissite is an OG at java ahahaha much love man. Yeah honestly most of the pain was a basic setup I had from a long time ago. I've been too lazy to try cleaning it up, but my java script has gotten a lot better in the scripts I've made (that I haven't released on forums). Hoping my yew cutter works out ahaha, need money for bond. Just got done running it for 15 hours with 1 hr breaks every 3 hrs of botting. It works better than any other yew woodcutting bots that I watched while running it. Hopefully no ban though, but we'll see! Just checked out your thieve script BobRocket, looks dope af. Props to you too man, thanks for the input from both of y'all Quote Link to comment Share on other sites More sharing options...
FrostBug Posted September 22, 2015 Share Posted September 22, 2015 You could clean it up a bit by using the ExperienceTracker class already implemented for you It contains methods such as getElapsed, getGainedXP, getGainedXPPerHour, getTimeToLevel, getGainedLevels etc. 1 Quote Link to comment Share on other sites More sharing options...
Strange_Fk Posted September 22, 2015 Author Share Posted September 22, 2015 Wow please tell me that was added sometime in the last month or so to the api ahahahah. Otherwise i'm going to feel prettttty stupid Quote Link to comment Share on other sites More sharing options...