Jump to content

lare96

Members
  • Posts

    70
  • Joined

  • Last visited

  • Feedback

    100%

Posts posted by lare96

  1. 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.)
     
    xFVKrHP.png
    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);
        }
    }
    
    • Like 3
  2. 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

     

    • Like 1
  3. 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.

  4. 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...?

  5.     /**
         * 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.

  6. 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?

  7. 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.)

  8. 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.

  9. 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.

     

     

  10.  

    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.

  11. 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);
        } 
  12. 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 Variables
    Under '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.exe
    Replaced the shortcuts pointing to java home location.

     

    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.

  13. 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));    
    
        ...
    }
    
  14. 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());
    }
    
  15. 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...