Botre Posted March 26, 2015 Posted March 26, 2015 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; } }
Czar Posted March 26, 2015 Posted March 26, 2015 (edited) looking good m9 edit; hope to see u with a blue name soon, it will match your profile pic too ;p Edited March 26, 2015 by Czar
Botre Posted March 26, 2015 Author Posted March 26, 2015 return true; sendMessage(getBrochachos(CoolestBrochachos.APAEC), "no"); edit; hope to see u with a blue name soon, it will match your profile pic too ;p Such coincidence 2
LeBron Posted March 26, 2015 Posted March 26, 2015 looking good m9 edit; hope to see u with a blue name soon, it will match your profile pic too ;p What's the difference between the two? Other than the color :P
Botre Posted March 26, 2015 Author Posted March 26, 2015 (edited) What's the difference between the two? Other than the color One looks good with my logo, the other not so much Edited March 26, 2015 by Botre
LeBron Posted March 26, 2015 Posted March 26, 2015 One looks good with my logo, the other not so much Silly How'd it go with your region problem?
AresScripts Posted March 26, 2015 Posted March 26, 2015 What's the difference between the two? Other than the color Social status
AresScripts Posted March 27, 2015 Posted March 27, 2015 notsureifsrs.png no i really am. As far as i know they dont get any benifits, but the rank is harder to get