Jump to content

Explv

Scripter II
  • Posts

    2314
  • Joined

  • Last visited

  • Days Won

    6
  • Feedback

    100%

Everything posted by Explv

  1. Explv

    Explv's Walker

    That's weird, I'll take a look at it, thank you
  2. Good job Except for the if if if if if .... You can easily avoid that if you just invert the condition like: if (!script.getTabs().getOpen().equals(Tab.LOGOUT)) { script.getTabs().open(Tab.LOGOUT); return false; }
  3. He was last seen 2014, so I'm not too worried about spam. Inb4 someone makes a new account called FunctionalInterface
  4. This thread is for the developers of the website to see, so don't worry about understanding it....
  5. Yeah... my uh... IDE is doing that...... The problem is, when you try to put the annotation @ Override (without the space) inside of code tags, and then submit your post / edit. @ Override is automatically replaced with that user's name. See this reply in the scripting help section: http://osbot.org/forum/topic/103825-cant-get-conditionalsleep-to-validate/?p=1159828 Note how the accepted solution by Khaleesi has a space between the @ and Override to prevent it from happening.
  6. So this problem is recent, @@OverRideCwalk's name appears instead of the Override annotation inside of the code tags. Consider this simple example: public class Example { @[member='OverRideCwalk'] // This should be @ Override (no space) public String toString() { return "His username messes this up"; } } People are currently working around this issue by putting a space between the @ and the annotation: public class Example { @ Override public String toString() { return "This works fine"; } }
  7. sigh perhaps you should read up on the Java Garbage Collector then. If you are really concerned about memory usage, then perhaps you should use a profiler to see how much memory, and where the memory is being used. It isn't really a concern though. It's just a Map containing a few objects..
  8. The source code is heavily obfuscated, so I wouldn't bother trying to read it. In terms of the getSlot() method, as the API does not specify anything else, it is safe to assume that it would return an index from 0 to the inventory size. Most methods that return some form of index would start at 0, and you know that the inventory has 28 slots. As a valid index would always be positive, -1 is typically used to indicate that a valid index could not be found, you will find this everywhere in programming. Regarding the ordering, you can't know for sure as it's not in the API, but most people would assume left to right in rows. If you don't know exactly how something works, just write a little test and you'll find out.
  9. This is something you could have easily figured out yourself by doing a small amount of testing. The definition of getSlot() looks like: public int getSlot(final Item item) { if(item == null) { return -1; } else { Item[] items = getInventory().getItems(); // returns an array of size 28 for(int i = 0; i < items.length; i++) { if(items[i] != null && items[i].equals(item)) { return i; } } return -1; } } As you can see, if the item is not found it returns -1. Otherwise it returns a value from 0 (inclusive) to 28 (exclusive). 0 is the top left slot, 27 is the bottom right slot. The index increments from left to right: 0 1 2 3 4 5 6 7 8 9 10 11 etc.
  10. Who gives a shit https://www.amazon.co.uk/Logitech-B100-Optical-Mouse-Black/dp/B00AZKNPZC/ref=sr_1_1?s=computers&ie=UTF8&qid=1469914709&sr=1-1&keywords=mouse
  11. In the future please use the code tags when posting code on OSBot. It's the button that looks like <>
  12. Perhaps something like this (Sorry can't be bothered to test it): import org.osbot.rs07.api.filter.NameFilter; import org.osbot.rs07.api.model.NPC; import org.osbot.rs07.script.Script; import org.osbot.rs07.script.ScriptManifest; import org.osbot.rs07.utility.ConditionalSleep; @ScriptManifest(name = "Cow Killer", info = "Kills Cows...", author = "Explv", version = 0.1, logo = "") public final class CowKiller extends Script { private NPC currentCow, nextCow; @Override public final int onLoop() throws InterruptedException { if(isAttackingCow()) { hoverNextNPC(); } else { currentCow = null; attackNPC(); } return random(150, 200); } private boolean isAttackingCow() { return currentCow != null && currentCow.exists() && currentCow.getHealthPercent() > 0 && myPlayer().isInteracting(currentCow); } private void hoverNextNPC() { nextCow = getClosestCow(); if(nextCow != null && !getMouse().isOnCursor(nextCow)) { nextCow.hover(); } } private void attackNPC() { currentCow = isAttackableTarget(nextCow) ? nextCow : getClosestCow(); if(currentCow != null && currentCow.interact("Attack")) { new ConditionalSleep(5000) { @Override public boolean condition() throws InterruptedException { return myPlayer().isInteracting(currentCow) || !isAttackableTarget(currentCow); } }.sleep(); } } private NPC getClosestCow() { return getNpcs().closest( new NameFilter<>("Cow", "Cow calf"), npc -> npc != currentCow && isAttackableTarget(npc) ); } private boolean isAttackableTarget(final NPC target) { return target != null && target.exists() && target.getHealthPercent() > 0 && !target.isUnderAttack(); } } Explanation: - If the we are under attack: - If we are hovering over another cow (nextCow variable) and that cow is attackable: - Set that cow as the cow to attack - Else find the closest attackable cow - Store the cow that we found in the global variable currentCow, to be used when hovering - If we have an attackable cow (!= null): - Use the interaction "Attack" on the cow - If the interaction was successful: - Sleep for 5 seconds, or until we are attacking the cow, or until the cow is no longer attackable. - If the player is not under attack: - Find the closest cow that is not the cow we are attacking (currentCow), and that is attackable - If a cow is found (!= null): - Store the cow in the global variable nextCow, to be used when attacking - If we are not already hovering over that cow: - Hover over the cow
  13. When you are under attack, find the next NPC which is not equal to the NPC you are attacking, that has health > 0 and is not under attack from another player, and then use hover() to hover over it.
  14. One simple method of doing it, would be to create an enum that stores the various Locations. For example: public enum Location { FALADOR(new Area(0, 0, 0, 0)), LUMBRIDGE(new Area(0, 0, 0, 0)); private final Area area; Location(final Area area) { this.area = area; } public final Area getArea() { return area; } @Override public final String toString() { return StringUtils.capitalize(name().toLowerCase()); } } Each value in the enum has an associated Area. This area can be used to walk to the chickens. Note, I also have overridden toString() here to return the name of the value in the enum in regular case, for example: VARROCK -> Varrock For the user to select a Location from the GUI, you can just use a JComboBox: JComboBox<Location> locationSelector = new JComboBox<>(Location.values()); Location selectedLocation = (Location) locationSelector.getSelectedItem(); You don't need to hardcode any paths because we now have web walking, so to walk to the chickens you can just do: getWalking().webWalk(chickenArea);
  15. I've fixed the issue and uploaded the new code to GitHub. I will upload a new .jar when I get home (I'll let you know when I have done it).
  16. Windows? I only tested on Linux unfortunately
  17. 100 nodes?!?! You're doing something very, very wrong..
  18. http://osbot.org/forum/topic/100554-explvs-osbot-manager/
  19. Nice tutorial, damn, that snippet though... phwoah
×
×
  • Create New...