Jump to content

Botre

Members
  • Posts

    5883
  • Joined

  • Last visited

  • Days Won

    18
  • Feedback

    100%

Everything posted by Botre

  1. Botre

    My TreeFilter

    sendMessage(getBrochachos(CoolestBrochachos.APAEC), "no"); Such coincidence
  2. Botre

    My TreeFilter

    I wrote this after realizing that calling @getMap().canReach(...) is really expensive. package org.bjornkrols.events; import java.util.HashMap; import java.util.Map; import org.bjornkrols.script.BotreMethodProvider; import org.osbot.rs07.api.filter.Filter; import org.osbot.rs07.api.map.Position; import org.osbot.rs07.api.model.RS2Object; import org.osbot.rs07.script.Script; /** * @author Bjorn Krols (Botre) * @version 0.2 * @since March 26, 2015 */ public class TreeFilter implements Filter<RS2Object> { /** * The script instance. */ private final Script script; /** * The tree's name. */ private String name; /** * The chop radius's center. */ private Position chopCenter; /** * The chop radius. */ private int chopRadius; /** * <Position, reachable && in range> */ private Map<Position, Boolean> validityMap; public TreeFilter(final Script script) { this.script = script; validityMap = new HashMap<Position, Boolean>(); } @Override public boolean match(RS2Object o) { if (!BotreMethodProvider.isValid(o)) return false; if (!o.hasAction("Chop down")) return false; if (!o.getName().equals(name)) return false; Position p = o.getPosition(); if (validityMap.containsKey(p)) return validityMap.get(p); validityMap.put(p, chopCenter.distance(o) < chopRadius && script.getMap().canReach(o)); return validityMap.get(p); } public String getName() { return name; } public void setName(String name) { this.name = name; } public Position getChopCenter() { return chopCenter; } public void setChopCenter(Position chopCenter) { this.chopCenter = chopCenter; } public int getChopRadius() { return chopRadius; } public void setChopRadius(int chopRadius) { this.chopRadius = chopRadius; } }
  3. Nope. The last method could work but you'd have to check every 300 milliseconds. The first one just doesn't work. I just want an id/config/hash method.
  4. You could probably do it via getClippingPanes() but f that. getTiles() is super confusing. Each region should return a proper identifier / hash imo..
  5. getRegion() always returns the same hash and equals always returns true.
  6. Botre

    Anne4Red

    *Approved by Anne*
  7. A quick example of a ConditionalLoop class. The API one is great and I suggest you use that one, this is more for learning purposes. package org.bjornkrols.conditional; import org.bjornkrols.imported.MilliTimer; /** * @author Bjorn Krols (Botre) * @version 0.1 * @since March 26, 2015 */ public abstract class ConditionalLoop extends Thread { /** * This loop's timer (millisecond precision). */ private MilliTimer timer; /** * The maximum (exclusive) time of looping, in milliseconds, after which the loop will be broken. */ private int timeout; public ConditionalLoop(final int timeout) { setDaemon(true); setTimeout(timeout); } /** * A no-argument constructor with a default timeout of 10 seconds. */ public ConditionalLoop() { this(10000); } @Override public void run() { preLoop(); while (condition()) { if (timer.getElapsedMilliSeconds() > timeout) { onTimeout(); break; } try { Thread.sleep(onLoop()); } catch (InterruptedException e) { e.printStackTrace(); } } postLoop(); } /** * @return Whether to continue to loop. */ public abstract boolean condition(); /** * Executes before the loop starts. */ public void preLoop() { timer = new MilliTimer(); }; /** * The actual loop. * * @return The time to sleep for, in milliseconds, after each iteration. */ public abstract int onLoop(); /** * Executes after the loop. */ public void postLoop() { }; /** * Executes when the loop has timed out. */ public void onTimeout() { } /** * Sets the timeout (in milliseconds). * * @param milliseconds The time out (in milliseconds). */ public void setTimeout(int milliseconds) { timeout = milliseconds; } }
  8. Botre

    #1000

    Congratulations young javawan.
  9. This is for Alek right ? :x
  10. PS: almost 100 days online :x PPS: 4-digit likes :x PPPS: SDN rank :x PPPPS: no
  11. Not really feeling like giving out my work for free, especially if it could hurt a fellow scripter's sales. I suggest you stick with chopping and dropping then ^^
  12. Seems fire considering the firemaking script on the sdn is also 4.99 ^^ edit: *fair (badum tsss)
  13. I have this ready PS: if you were willing to pay for this at all, howmuch do you think you would be willing to pay ?
  14. People seem to have forgotten the "once or twice / week updates" days. Times are good tbh. People seem to have forgotten the "once or twice / week updates" days. Times are good tbh.
  15. Knowledge has value :^|
×
×
  • Create New...