Everything posted by Explv
-
Hover Function
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
-
Hover Function
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.
-
Basic Scripting, Classes, and Good Code
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);
-
Explv's OSBot Manager
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).
-
Explv's OSBot Manager
Windows? I only tested on Linux unfortunately
-
With A Node Framework...
100 nodes?!?! You're doing something very, very wrong..
- My second csgo edit
-
How To Use OSBot's new CLI (Command Line Interface)
http://osbot.org/forum/topic/100554-explvs-osbot-manager/
-
How To Use OSBot's new CLI (Command Line Interface)
Nice tutorial, damn, that snippet though... phwoah
-
Explv's AIO [13 skill AIO in 1 script]
I have pushed a fix for this, it will be available next time the SDN updates. I will update the change log on this thread when it is available.
-
Explv's AIO [13 skill AIO in 1 script]
Thanks, I'll check it out This has been fixed, will be available next SDN update (I will update the change log when it is available)
-
Explv's OSBot Manager
Yes, my apologies. I have been very busy at work, and also have a lot on my plate @OSBot. I will do my best to get this finished and released over the next few days
-
Explv's AIO [13 skill AIO in 1 script]
What skill did you setup to go to after tut island?
-
Explv's OSBot Manager
It's pretty much finished, I will try and release if over the next few days, been super busy at work. It will be free, open source, and the link will be provided on this thread.
-
Explv's AIO [13 skill AIO in 1 script]
Yep, I'll fix it ASAP, been very busy at work lately. Sorry for the delay
-
Pokemon GO - Be careful [android]
Not from the app store, from random websites.
-
Pokemon GO - Be careful [android]
You could just wait until it comes out in the store for your region. It's just a shitty pokemon game after all
-
Pokemon GO - Be careful [android]
If you got the official version of Pokemon GO from the app store, it will not have malware. However, if you are downloading dodgy .apks from random sites, then rip you.
-
GE Data (get price etc. by item name) no external libraries required
Peng ting innit
-
GE Data (get price etc. by item name) no external libraries required
I've updated it. Should be a bit more memory efficient now. Still some improvements that could be made but I cba
-
GE Data (get price etc. by item name) no external libraries required
Yeah I will be improving this further, I just wrote this up quickly to get things started
-
GE Data (get price etc. by item name) no external libraries required
Here is a simple class I have written to retrieve grand exchange information for specified osrs items, using the json file hosted by rsbuddy at: https://rsbuddy.com/exchange/summary.json Note the retrieval of this data should only be done once at the start of your script, and you should store the map for use later rather than re-calling the method. You may also get better performance using a JSON library. RSExchange.java import java.io.BufferedReader; import java.io.InputStreamReader; import java.net.URL; import java.net.URLConnection; import java.util.HashMap; import java.util.Map; import java.util.Optional; import java.util.regex.Matcher; import java.util.regex.Pattern; public final class RSExchange { private final String ITEMS_JSON; public RSExchange() { ITEMS_JSON = getItemsJson().orElse(""); } private Optional<String> getItemsJson() { try { URL url = new URL("https://rsbuddy.com/exchange/summary.json"); URLConnection con = url.openConnection(); con.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36"); con.setUseCaches(true); BufferedReader br = new BufferedReader(new InputStreamReader(con.getInputStream())); String json = br.readLine(); br.close(); return Optional.of(json); } catch (Exception e) { e.printStackTrace(); } return Optional.empty(); } public final Optional<ExchangeItem> getExchangeItem(final String itemName) { return getItemID(ITEMS_JSON, itemName).map(id -> new ExchangeItem(itemName, id)); } public final Map<String, ExchangeItem> getExchangeItems(final String... itemNames) { Map<String, ExchangeItem> exchangeItems = new HashMap<>(); for (final String itemName : itemNames) { getItemID(ITEMS_JSON, itemName).ifPresent(id -> exchangeItems.put(itemName, new ExchangeItem(itemName, id))); } return exchangeItems; } private Optional<Integer> getItemID(final String json, final String itemName) { return getItemFromJson(json, itemName).flatMap(this::getItemIDFromItemJson); } private Optional<String> getItemFromJson(final String json, final String itemName) { Matcher matcher = Pattern.compile("(\\{[^}]*\"name\"\\s*:\\s*\"" + Pattern.quote(itemName) + "\"[^}]*})").matcher(json); return matcher.find() ? Optional.of(matcher.group(1)) : Optional.empty(); } private Optional<Integer> getItemIDFromItemJson(final String json) { Matcher matcher = Pattern.compile("\"id\"\\s*:\\s*(\\d*)").matcher(json); return matcher.find() ? Optional.of(Integer.parseInt(matcher.group(1))) : Optional.empty(); } } ExchangeItem.java import java.io.BufferedReader; import java.io.InputStreamReader; import java.net.URL; import java.net.URLConnection; import java.util.Optional; import java.util.regex.Matcher; import java.util.regex.Pattern; public final class ExchangeItem { private final String name; private final int id; private int overallAverage = -1; private int buyAverage = -1; private int sellAverage = -1; private int buyingQuantity; private int sellingQuantity; public ExchangeItem(final String name, final int id) { this.name = name; this.id = id; updateRSBuddyValues(); } public final String getName() { return name; } public final int getId() { return id; } public final int getBuyAverage() { return buyAverage; } public final int getSellAverage() { return sellAverage; } public final int getBuyingQuantity() { return buyingQuantity; } public final int getSellingQuantity() { return sellingQuantity; } public void updateRSBuddyValues() { try { URL url = new URL("http://api.rsbuddy.com/grandExchange?a=guidePrice&i=" + id); URLConnection con = url.openConnection(); con.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36"); con.setUseCaches(true); BufferedReader br = new BufferedReader(new InputStreamReader(con.getInputStream())); String json = br.readLine(); br.close(); getItemValue("overall", json).ifPresent(overallAverage -> this.overallAverage = overallAverage); getItemValue("buying", json).ifPresent(sellAverage -> this.sellAverage = sellAverage); getItemValue("selling", json).ifPresent(buyAverage -> this.buyAverage = buyAverage); getItemValue("buyingQuantity", json).ifPresent(buyQuantity -> this.buyingQuantity = buyQuantity); getItemValue("sellingQuantity", json).ifPresent(sellingQuantity -> this.sellingQuantity = sellingQuantity); } catch (Exception e) { e.printStackTrace(); } } private Optional<Integer> getItemValue(final String key, final String json) { Matcher overallAvgMatcher = Pattern.compile("\"" + key + "\"\\s*:\\s*(\\d*)").matcher(json); if (overallAvgMatcher.find()) { return Optional.of(Integer.parseInt(overallAvgMatcher.group(1))); } return Optional.empty(); } public final String toString() { return String.format("Name: %s, ID: %d, Overall AVG: %d gp, Buying AVG: %d gp, Selling AVG: %d gp, Buying Quantity: %d, Selling Quantity:%d", name, id, overallAverage, buyAverage, sellAverage, buyingQuantity, sellingQuantity); } } Usage: final RSExchange rsExchange = new RSExchange(); rsExchange.getExchangeItem("Yew logs").ifPresent(System.out::println); This would print out Name: Yew logs, ID: 1515, Overall AVG: 355 gp, Buying AVG: 355 gp, Selling AVG: 354 gp, Buying Quantity: 90576, Selling Quantity :71726
-
Java Tutorial Series
I learned a lot, thanks!
-
Simple onLoop() script :)
Looking good bawss, nice work. Just a few things you might want to clean up: Firstly, if(getInventory().contains(i -> !i.getName().equals("Cosmic rune") && !i.getName().equals("Sapphire ring"))) Can be replaced with: if(!getInventory().onlyContains("Cosmic rune", "Sapphire ring")) Secondly, I don't think you need to open the magic tab before casting a spell, it will already do that for you. Also when enchanting you don't need to check: if (getMagic().canCast(Spells.NormalSpells.LVL_1_ENCHANT)) Because you already know you have the required runes. Instead, in onStart() you should check if the player has a magic level >= the required, and stop the script if they don't with a useful message: if(getSkills().getStatic(Skill.MAGIC) < Spells.NormalSpells.LVL_1_ENCHANT.getRequiredLevel()) { log("You do not have a magic level high enough to use this script!"); stop(); } In onStart you also may want to check the player is in a P2P world, as enchanting is members only (I think). If they are not in P2P attempt to hop worlds, if it fails, again log a useful message and stop the script: if(!getWorlds().isMembersWorld()) { log("You need to be logged into a members world to use this script."); log("Attempting to hop worlds"); if(!getWorlds().hopToP2PWorld()) { log("Failed to hop to P2P world"); stop(); } } You also haven't made any checks anywhere for if the player has water runes / a staff of water, and no banking to retrieve them.
-
Explv's Tutorial Island [Free] [Random Characters]
I'll check it out this weekend / earlier if I have time. Thanks