Jump to content

Alias

Members
  • Posts

    10
  • Joined

  • Last visited

  • Days Won

    4

Recent Profile Visitors

259 profile views

Alias's Achievements

Bronze Member

Bronze Member (1/10)

  1. where k=33, the answer is: (8,866,128,975,287,528)³ + (–8,778,405,442,862,239)³ + (–2,736,111,468,807,040)³ = 33.
  2. This is a simple class that can be used to convert String names into Item ID's or visa versa There are a few edge cases where there is more than one ID for the same item so that is a possibility if you're using this. import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.net.URL; import com.google.gson.JsonObject; import com.google.gson.JsonParser; public class ItemConverter { private final static String URL = "https://rsbuddy.com/exchange/summary.json"; private final JsonObject json; public ItemConverter() { this.json = new JsonParser().parse(getJson()).getAsJsonObject(); } public int getID(final String item) { for (String key : json.keySet()) { final JsonObject obj = json.get(key).getAsJsonObject(); if (obj.get("name").getAsString().equals(item)) { return obj.get("id").getAsInt(); } } return -1; } public String getName(final int itemId) { for (String key : json.keySet()) { final JsonObject obj = json.get(key).getAsJsonObject(); if (obj.get("id").getAsInt() == itemId) { return obj.get("name").getAsString(); } } return ""; } private String getJson() { try { final URL url = new URL(URL); final BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream())); String inputLine; String out = null; while ((inputLine = in.readLine()) != null) { out = inputLine; } in.close(); return out; } catch (IOException e) { e.printStackTrace(); } return null; } }
  3. edited to remove redundant walking code 🙂
  4. I wrote this fairly quickly and was a little bit lazy so no GUI to input your food or selected stall. Just edit the String for food - this is case sensitive (don't use cakes or bread as that clearly won't work on this). Also edit the stall you want to steal from if you wish. Should go right beside the stall and attempt to steal from it. import com.epicbot.api.shared.GameType; import com.epicbot.api.shared.entity.SceneObject; import com.epicbot.api.shared.model.Area; import com.epicbot.api.shared.model.Tile; import com.epicbot.api.shared.script.LoopScript; import com.epicbot.api.shared.script.ScriptManifest; import com.epicbot.api.shared.util.time.Time; @ScriptManifest(name = "AliasArdyStalls", gameType = GameType.OS) public class AliasArdyStallsThieving extends LoopScript { private final static String FOOD = "Lobster"; private final static Stalls STALL = Stalls.BAKER; private final static Area SAFE_AREA = new Area(2642, 3307, 2636, 3303);; private final static Area BANK_AREA = new Area(2655, 3287, 2649, 3280); @Override public boolean onStart(String... strings) { return true; } @Override protected int loop() { if (getAPIContext().skills().thieving().getCurrentLevel() < getRequiredLevel()) { stop("Player does not have required level for this stall..."); } else if (shouldBank()) { bank(); } else if (shouldEat()) { eat(); } else { steal(); } return 100; } private void steal() { if (!getAPIContext().localPlayer().getLocation().equals(getTileToStand())) { getAPIContext().walking().walkTo(getTileToStand(), 0); } else { final SceneObject stall = getStall(); if (stall != null) { final int emptySlots = getAPIContext().inventory().getCount(); if (stall.interact("Steal-from")) { Time.sleep(5_000, () -> getAPIContext().inventory().getCount() != emptySlots || getAPIContext().localPlayer().isInCombat()); } } } } private boolean shouldBank() { return getAPIContext().inventory().isFull() || !getAPIContext().inventory().contains(FOOD); } private void bank() { if (getAPIContext().calculations().distanceTo(BANK_AREA.getCentralTile()) > 5) { getAPIContext().walking().walkTo(BANK_AREA.getRandomTile()); } else if (!getAPIContext().bank().isOpen()) { if (getAPIContext().bank().open()) { Time.sleep(5_000, () -> getAPIContext().bank().isOpen()); } } else if (getAPIContext().inventory().isFull()) { if (getAPIContext().bank().depositAllExcept(FOOD)) { Time.sleep(5_000, () -> !getAPIContext().inventory().isFull()); } } else if (!getAPIContext().inventory().contains(FOOD)) { if (getAPIContext().bank().withdraw(5, FOOD)) { Time.sleep(5_000, () -> getAPIContext().inventory().getCount(FOOD) >= 5); } } } private boolean shouldEat() { return getAPIContext().skills().hitpoints().getRealLevel() < 7 || getAPIContext().localPlayer().getHealthPercent() < 50; } private void eat() { if (getAPIContext().inventory().getItem(FOOD).interact()) { Time.sleep(5_000, () -> !shouldEat()); } } private SceneObject getStall() { return getAPIContext().objects().query().nameContains(getStallName()).distance(5).results().nearest(); } private Tile getTileToStand() { return STALL.getTileToStand(); } private String getStallName() { return STALL.getName(); } private int getRequiredLevel() { return STALL.getRequiredLevel(); } } import com.epicbot.api.shared.model.Tile; public enum Stalls { BAKER("Baker's stall", new Tile(2655, 3313, 0), 5), FUR("Fur stall", new Tile(2662, 3296, 0), 35), GEM("Gem stall", new Tile(2668, 3305, 0), 75), SILK("Silk stall", new Tile(2661, 3315, 0), 20), SILVER("Silver stall", new Tile(2656, 3314, 0), 50), SPICE("Spice stall", new Tile(2657, 3297, 0), 65); Stalls(final String name, final Tile toStand, final int requiredLevel) { this.name = name; this.toStand = toStand; this.requiredLevel = requiredLevel; } private final String name; private final Tile toStand; private final int requiredLevel; public String getName() { return name; } public Tile getTileToStand() { return toStand; } public int getRequiredLevel() { return requiredLevel; } }
  5. @Ayylmao420 I feel like the boolean is a bit redundant as it is always returning true. There is nothing in the code that provides a false return so there's not really a point to check it with an if statement. This is what I do in my API public static void sleepUntil(final BooleanSupplier condition, final long timeout) { long start = System.currentTimeMillis(); while (!condition.getAsBoolean()) { if (System.currentTimeMillis() > start + timeout) { break; } } } And if you want to add a reset condition can just do this: public static void sleepUntil(final BooleanSupplier condition, final BooleanSupplier resetCondition, final long timeout) { long start = System.currentTimeMillis(); while (!condition.getAsBoolean()) { if (resetCondition.getAsBoolean()) { start = System.currentTimeMillis(); } else if (System.currentTimeMillis() > start + timeout) { break; } } } There is no need to pass the API context into the methods. The conditions are already provided and if the script ends the thread should be interrupted and everything will stop so you shouldn't be stuck in an infinite loop unless you ran this on a concurrent thread and didn't interrupt it onStop();
  6. public class TEST { public static void main(String[] args) throws InterruptedException { //create our something object that you need to get info from final Something something = new Something(); //create a thread and pass the runnable subclass though as a parameter //so the thread knows what it's job is final Thread thread = new Thread(something); //start the thread thread.start(); //synchronized block with the target of the thread we will be waiting on synchronized (thread) { System.out.println("Entering synchronized block"); //telling the main thread we are waiting on the other thread to complete thread.wait(); //providing our result from the something class System.out.println("Thread has been notified"); System.out.println("Calling the result from something..."); System.out.println("Got result: " + something.getResult()); } } } public class Something implements Runnable { private int result; @Override public void run() { // the synchronized block that will execute after wait() was called on this // object synchronized (this) { //just doing the math final int num = 5; final int multiplier = 5; result = num * multiplier; System.out.println("Did math, the answer is: " + result); // notify must be called to notify the main thread that this job is complete and // the other thread can proceed notify(); } } //grabbing the result of whatever info want from this class public int getResult() { return this.result; } } OUTPUT: Entering synchronized block Did math, the answer is: 25 Thread has been notified Calling the result from something... Got result: 25
  7. package cannonballer; import com.epicbot.api.shared.GameType; import com.epicbot.api.shared.entity.SceneObject; import com.epicbot.api.shared.model.Area; import com.epicbot.api.shared.script.LoopScript; import com.epicbot.api.shared.script.ScriptManifest; import com.epicbot.api.shared.util.time.Time; @ScriptManifest(name = "CB Smither", gameType = GameType.OS) public class AliasCannonballer extends LoopScript { private final static Area SMITH_AREA = new Area(3109, 3501, 3105, 3497); private final static Area EDGE_BANK = new Area(3098, 3499, 3092, 3493); private long animationTime = 0; @Override public boolean onStart(String... strings) { return true; } @Override protected int loop() { if (canSmith()) { smith(); } else { bank(); } return 100; } private boolean canSmith() { return getAPIContext().inventory().contains("Steel bar") && getAPIContext().inventory().contains("Ammo mould"); } private boolean smithInterfaceOpen() { return !getAPIContext().widgets().query().group(270).textContains("How many bars").results().isEmpty(); } private void smith() { SceneObject furnace = getAPIContext().objects().query().nameContains("Furnace").results().nearest(); if (furnace != null) { if (getAPIContext().calculations().distanceTo(furnace.getLocation()) > 5) { getAPIContext().walking().walkOnMap(SMITH_AREA.getCentralTile()); } else if (getAPIContext().localPlayer().isAnimating()) { this.animationTime = System.currentTimeMillis(); } else if (smithInterfaceOpen()) { getAPIContext().keyboard().sendText("1", false); Time.sleep(5_000, () -> getAPIContext().localPlayer().isAnimating()); } else if (System.currentTimeMillis() > animationTime + 3_000) { if (furnace.interact("Smelt")) { Time.sleep(5_000, this::smithInterfaceOpen); } } } } private void bank() { if (getAPIContext().calculations().distanceTo(EDGE_BANK.getCentralTile()) > 5) { getAPIContext().walking().walkTo(EDGE_BANK.getCentralTile()); } else if (!getAPIContext().bank().isOpen()) { if (getAPIContext().bank().open()) { Time.sleep(5_000, () -> getAPIContext().bank().isOpen(), 5_000); } } else if (!getAPIContext().inventory().contains("Ammo mould")) { withdrawItem(1, "Ammo mould"); } else if (!getAPIContext().inventory().contains("Steel bar")) { withdrawItem(27, "Steel bar"); } } private void withdrawItem(final int amount, final String item) { if (!getAPIContext().bank().contains(item)) { stop("No " + item + "...cannot run script."); } else if (getAPIContext().bank().withdraw(amount, item)) { Time.sleep(5_000, () -> getAPIContext().inventory().contains(item)); } } }
  8. Considering you don't have a Zulrah released I figured I'd help. public class RotationListener implements Runnable { public RotationListener(final AliasZulrah ctx) { this.ctx = ctx; }
  9. import com.epicbot.api.shared.GameType; import com.epicbot.api.shared.entity.SceneObject; import com.epicbot.api.shared.model.Area; import com.epicbot.api.shared.script.LoopScript; import com.epicbot.api.shared.script.ScriptManifest; import com.epicbot.api.shared.util.time.Time; @ScriptManifest(name = "Alias", gameType = GameType.OS) public class Main extends LoopScript { private final static Area OAK_AREA = new Area(3172, 3422, 3159, 3411); private final static Area BANK_AREA = new Area(3185, 3439, 3180, 3431); @Override public boolean onStart(String... strings) { return true; } @Override protected int loop() { if (getAPIContext().inventory().isFull()) { bank(); } else { chop(); } return 100; } private void bank() { if (!BANK_AREA.contains(getAPIContext().localPlayer().getLocation())) { getAPIContext().walking().walkTo(BANK_AREA.getCentralTile()); } else if (!getAPIContext().bank().isOpen()) { if (getAPIContext().bank().open()) { Time.sleep(5_000, () -> getAPIContext().bank().isOpen()); } } else if (getAPIContext().bank().depositAll("Oak logs")) { Time.sleep(5_000, () -> getAPIContext().inventory().isEmpty()); } } private void chop() { if (!OAK_AREA.contains(getAPIContext().localPlayer().getLocation())) { getAPIContext().walking().walkTo(OAK_AREA.getCentralTile()); } else if (!isChopping()) { final SceneObject tree = getAPIContext().objects().query().nameContains("Oak").results().nearest(); if (tree != null) { if (tree.interact()) { Time.sleep(5_000, () -> getAPIContext().localPlayer().isAnimating()); } } } } private boolean isChopping() { return getAPIContext().localPlayer().isAnimating() || getAPIContext().localPlayer().isMoving(); } }
×
×
  • Create New...