-
Posts
70 -
Joined
-
Last visited
-
Feedback
100%
Posts posted by lare96
-
-
w....what are you doing?
im adding the JavaDocs so I can look at the documentation for certain types, fields, methods, etc. while I'm developing
Frankly, you don't even need that. The rest of us have been developing scripts for a long time now without it.
right, I'm aware that it's not needed but my initial point was that it's a pain in the ass. thanks anyway though
- 1
-
??? Anyone know why this is happening? Makes developing scripts a pain in the ass...
-
You should probably use some sort of event-node state system as it's much more modular, manageable, and it just looks better. Not trying to be a dick or anything, but especially for new scripters that aren't familiar with Java it's better to show them the best way of doing things so they learn and get comfortable with it from early on.
-
I just used a map with a forced key type of Enum<E> for O(1) get, put, and contains but this is really nice.
-
Cool beans, thanks for this.
-
Cool beans, thanks for this.
-
and this is how I want the osbot docs to be made.
A decent explanation of what the function actually does
Thx for your contribution!
Thanks man, I appreciate it.
-
Nice tutorial, but a few things.
This
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; }
Can just be this
LocalTime.ofSecondOfDay(TimeUnit.MILLISECONDS.toSeconds(duration)).toString();
And for the experience gained part, can you not just use the experience tracker...?
-
cool beans, thanks for this
-
Next time you say you get an "error" you should include the exception stack trace as well so we can help you pinpoint the exact location and cause of the problem very quickly.
-
/** * Returns an array of {@link org.osbot.rs07.api.map.Position} nodes that * are randomized within {@code radius}. The {@code path} will not be * modified, nor will it hold any references to the returned array. * * @param path * the path that will be randomized. * @param radius * the radius in which the path will be randomized. * @return the new randomized path. */ public static Position[] getRandomizedPath(Position[] path, int radius) { Position[] newPath = new Position[path.length]; int idx = 0; for (Position node : path) newPath[idx++] = node.translate(MethodProvider.random(radius), MethodProvider.random(radius)); return newPath; } /** * Returns an array of {@link org.osbot.rs07.api.map.Position} nodes that * are localized for the {@code node} point. This method is very useful for * when the script needs to cut out certain positions that aren't relevant; * for example, if the player starts a script when they are in the middle of * a path instead of the beginning or ending. Take for instance, this * pseudo-code. * * <pre> * Position[] path = { position1, position2, position3, position4, position5, position6, position7 }; * </pre> * * If {@code node} is closest to "position3" in distance, the returned array * will look like... * * <pre> * ... = { position3, position4, position5, position6, position7 }; * </pre> * * @param node * the node in which the path should be localized for. * @param path * the path that will be localized. * @return the new localized path. */ public static Position[] getLocalPath(Position node, Position[] path) { List<Position> newPath = new LinkedList<>(); int dist = -1; int index = -1; for (int i = 0; i < path.length; i++) { int newDist = node.distance(path[i]); if (dist == -1 || newDist < dist) { dist = newDist; index = i; } } IntStream.range(index, path.length).forEach(x -> newPath.add(path[x])); return newPath.toArray(new Position[newPath.size()]); }
Could come in handy for scripts that utilize walking, everything is explained in the documentation.
-
Write your own Java programs. I started with Runescape servers. You'll learn best through hands on experience.
-
I used to use Eclipse, the Switched to NetBeans because of better code format and UI and some other features.
Then somehow I switched to IntelliJ because of GitHub integration and some other great features.
IMO, I recommend Intellij, Community or Ultiamte, both are great, but Ultimate looks sexier lol.
UKF
You do know Eclipse has support for Git repositories right?
-
imo java is not suited as a scripting language at all. It could be so much easier to script for osbot if someone creates bindings for some proper scripting language, or create a new one, which can be embedded into java...
I agree, but you could always develop some sort of plugin system to add content to your script in a language that compiles into Java bytecode (JRuby, Scala, Xtend, Groovy, etc.)
-
I mean, while this is true to an extent, you really just need to know if statements and osbots api.
Being able to write good quality code that performs well and isn't a total clusterfuck works requires you to have knowledge in the four OOP pillars (Abstraction, Encapsulation, Inheritance, and Polymorphism) as well as being knowledgeable in both the Java and OSBot APIs. You even need to have some background on concurrency to understand how certain things work.
-
I use a personally OSBot Helper API that has an event-node state framework and some common utilities that are used in virtually every script. If Guava wasn't already bound together with the OSBot API I would've added that independently too.
I also use the WindowBuilder plugin for Eclipse to make my GUIs, although I should really start using JavaFX.
-
You should probably give the Java 8 documentation instead of the Java 7.
-
Well what you did there is too complicated, what you can do is this:
static Random r = new Random(); public static int rand (int mean, int stdDev){ return (int) (r.nextGaussian()*stdDev+mean); }
How is what I did complicated? I gave methods that support both inclusive and exclusive intervals.
-
Not all that great, since that while loop can potentially block forever...
private final Random random = new Random(); public int exclusive(int min, int max) { if (max <= min) { max = min + 1; } return random.nextInt((max - min)) + min; } public int exclusive(int range) { return exclusive(0, range); } public int inclusive(int min, int max) { if (max < min) { max = min + 1; } return exclusive((max - min) + 1) + min; } public int inclusive(int range) { return inclusive(0, range); }
-
If I remember correctly Kelper doesn't even have native support for Java 8... I don't really understand the issue, why not just use the latest version of Eclipse?
https://eclipse.org/downloads/packages/release/Luna/SR2
Click "Eclipse IDE for Java Developers" then on the right hand side it should show a bunch of downloads for your computer type, so just click the one that matches with your hardware.
EDIT: I just looked at the picture you presented more in depth, I had the same issue awhile back (although you should still download Eclipse Luna if you want Java 8 support...) the issue has do with your environment variables.
For me the solution was to go into (on Windows 8.1):System > Advanced system setting > Environment VariablesUnder 'System variables' in the 'Path' variable there was the following first:C:\ProgramData\Oracle\Java\javapath;I removed this and Eclipse worked again!This might happen if you have several versions of java in the same machine, to fix this i did the following:Checked current JAVA_HOME value, in Windows echo %JAVA_HOME%Accessed the route of javaw.exeReplaced the shortcuts pointing to java home location.Personally the second solution worked for me, my path to Java was wrong.
-
Ah i see the issue you are having. you can only do this if you make your own method.
how i would make my own method?
i would make a method which is called getNextPositionOnPath(Path path)
this should return the next position in the array which is walkable.
i would make a for loop which goes from path.length-1 to 0 to find which finds which position is closest to you and return it.
once you get the getNextPositionOnPath(Path path) assign it to a variable called nextPosition, make a new variable called newPosition= new Position(nextPosition.getX() + ***RANDOM NUMBER***, nextPosition.getY() + ***DIFFERENT RANDOM NUMBER***, nextPosition.getZ())
then make another method called walkPath which walks to the next position, once the distance < random number, getnextPosition and walk to it etc.
Some ugly pseudo-code, I wrote this in the reply box off top so I can't guarantee it'll work but it should give you some sort of idea on how to do what he suggested. Basically what the method does is take an array of positions, find the one closest to you and then reconstructs a randomized new path and returns it as a new array of positions. It does not modify the given array, and the returned array holds no references to the given one... because that obviously wouldn't work out too well.
public Position[] getRandomizedPath(Position[] path) { // local fields Position player = myPlayer().getPosition(); int index = 0; int dist = Integer.MAX_VALUE; // get index closest to player for(int i = 0; i < path.length; i++) { int amount = path[i].distance(player); if(amount < dist) { dist = amount; index = i; } } // filter positions and randomize them List<Position> list = new LinkedList<>(); for(int i = 0; i < path.length; i++) { if(i >= index) { list.add(new Position(path[i].getX() + MethodProvider.random(5), path[i].getY() + MethodProvider.random(5)); } } // return filtered and randomized positions return list.toArray(new Position[list.size()]); }
private static final Position[] PATH = { ... } public void ... () { ... localWalker.walk(getRandomizedPath(PATH)); ... }
-
Thank you, Daenerys Targaryen. It is my pleasure to serve under your wing.
Could also do something like this if you're using some sort of event-node state system.
private static final ImmutableList<Event> ANTIBAN = ImmutableList.of(new IdleEvent(), new AntibanEvent1(), new AntibanEvent2()); private static Event getRandomEvent() { return ANTIBAN.get((int) Math.random() * ANTIBAN.size()); }
-
A little off topic but just a tip: constants are static and final.
-
Could always use Streams introduced in Java 8 to make this a one liner.
public static int getMyTotalLevel(Script script) { return Arrays.stream(Skill.values()).mapToInt(script.getSkills()::getStatic).sum(); }
NMZ Flicker
in Minigames
Posted · Edited by lare96
Will flick "Rapid Heal", drink overloads when necessary and will drink 1-2 absorption sips after every overload sip. Make sure that you start the bot when you're inside the arena, you've guzzled your rock cakes and fully set up your character to be ready for combat (1HP, standing in corner, ready to flick). Sorry about the poor/messy quality but I whipped it up in 15 or so minutes, but I've been using it all day and it works perfectly. Enjoy!