Jump to content

lare96

Members
  • Posts

    70
  • Joined

  • Last visited

  • Feedback

    100%

Everything posted by lare96

  1. lare96

    NMZ Flicker

    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! (Shitty XP because this is while I was debugging the script.) import com.google.common.base.Stopwatch; import org.osbot.rs07.api.ui.PrayerButton; import org.osbot.rs07.api.ui.Skill; import org.osbot.rs07.script.Script; import org.osbot.rs07.script.ScriptManifest; import java.awt.Color; import java.awt.Font; import java.awt.Graphics2D; import java.time.LocalTime; import java.util.concurrent.TimeUnit; /** * @author lare96 <http://github.org/lare96> */ @ScriptManifest(logo = "", name = "NmzFlicker", author = "lare96", version = 1.0, info = "Will flick HP and pot overloads/absorbs.") public final class NmzFlicker extends Script { private final Stopwatch watch = Stopwatch.createStarted(); private String status = "Idle..."; private int sipAbsortption = 0; @Override public void onStart() { experienceTracker.start(Skill.ATTACK); experienceTracker.start(Skill.DEFENCE); experienceTracker.start(Skill.STRENGTH); } @Override public int onLoop() throws InterruptedException { if (!combat.isAutoRetaliateOn() && !prayer.isActivated(PrayerButton.RAPID_HEAL)) { status = "Turning on auto-retaliate..."; combat.toggleAutoRetaliate(true); return random(1000, 1500); } if (skills.getDynamic(Skill.HITPOINTS) == 51 && !prayer .isActivated(PrayerButton.RAPID_HEAL) && sipAbsortption == 0) { status = "Drinking Overload potion..."; for (int i = 1; i < 5; i++) { if (inventory.contains("Overload (" + i + ")")) { inventory.interact("Drink", "Overload (" + i + ")"); break; } } sipAbsortption = random(1, 2); return random(1000, 1500); } if (sipAbsortption > 0 && !prayer.isActivated(PrayerButton.RAPID_HEAL)) { status = "Drinking Absorption potion..."; for (int i = 1; i < 5; i++) { if (inventory.contains("Absorption (" + i + ")")) { inventory.interact("Drink", "Absorption (" + i + ")"); break; } } sipAbsortption--; return random(1000, 1500); } if (prayer.isActivated(PrayerButton.RAPID_HEAL)) { status = "Flicking \"Rapid Heal\" off..."; prayer.set(PrayerButton.RAPID_HEAL, false); } else { status = "Flicking \"Rapid Heal\" on..."; prayer.set(PrayerButton.RAPID_HEAL, true); return random(50, 100); } return random(3000, 15_000); } @Override public void onPaint(Graphics2D g) { g.setColor(Color.WHITE); g.setFont(new Font("Myriad Pro", Font.BOLD, 16)); g.drawString("NmzFlicker [By Lare96]", 7, 225); g.setFont(new Font("Myriad Pro", Font.PLAIN, 14)); g.drawString("Time Running: " + LocalTime.ofSecondOfDay(watch.elapsed(TimeUnit.SECONDS)).toString(), 7, 245); g.drawString("Status: " + status, 7, 260); g.drawString("Attack XP: " + experienceTracker.getGainedXP(Skill.ATTACK) + " (" + experienceTracker .getGainedXPPerHour(Skill.ATTACK) + ")", 7, 275); g.drawString("Strength XP: " + experienceTracker.getGainedXP(Skill.STRENGTH) + " (" + experienceTracker .getGainedXPPerHour(Skill.STRENGTH) + ")", 7, 290); g.drawString("Defence XP: " + experienceTracker.getGainedXP(Skill.DEFENCE) + " (" + experienceTracker .getGainedXPPerHour(Skill.DEFENCE) + ")", 7, 305); } }
  2. im adding the JavaDocs so I can look at the documentation for certain types, fields, methods, etc. while I'm developing 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
  3. ??? Anyone know why this is happening? Makes developing scripts a pain in the ass...
  4. 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.
  5. 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.
  6. 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...?
  7. cool beans, thanks for this
  8. 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.
  9. /** * 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.
  10. Write your own Java programs. I started with Runescape servers. You'll learn best through hands on experience.
  11. You do know Eclipse has support for Git repositories right?
  12. 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.)
  13. 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.
  14. 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.
  15. You should probably give the Java 8 documentation instead of the Java 7.
  16. lare96

    Better random()

    How is what I did complicated? I gave methods that support both inclusive and exclusive intervals.
  17. lare96

    Better random()

    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); }
  18. 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. http://stackoverflow.com/questions/11461607/cant-start-eclipse-java-was-started-but-returned-exit-code-13 Personally the second solution worked for me, my path to Java was wrong.
  19. 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)); ... }
  20. 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()); }
  21. A little off topic but just a tip: constants are static and final.
  22. 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(); }
×
×
  • Create New...