Flamezzz Posted August 6, 2015 Share Posted August 6, 2015 (edited) Returns POH location found in config 738. My cons is quite low so I've only tested this for rimmington/taverly/pollniveach, unless they do some weird shit it should work for other locations as well.Note: positions for brimhaven/yanille are missing atm. public class POH { private static final int POH_CONFIG = 738; public static POHLocation getLocation(MethodProvider api) { int c = api.configs.get(POH_CONFIG) & 0x7; // clear other bits return POHLocation.values()[c]; } public enum POHLocation { None(0x0, new Position(0,0,0)), RIMMINGTON(0x1, new Position(2953,3224,0)), TAVERLY(0x2, new Position(2893,3465,0)), POLLNIVEACH(0x3, new Position(3340,3003,0)), RELLEKKA(0x4, new Position(2670,3631,0)), BRIMHAVEN(0x5, new Position(0,0,0)), YANILLE(0x6, new Position(0,0,0)); public final int mask; public final Position position; POHLocation(int mask, Position position) { this.mask = mask; this.position = position; } } } Edited August 6, 2015 by Flamezzz 3 Quote Link to comment Share on other sites More sharing options...
Botre Posted August 6, 2015 Share Posted August 6, 2015 Captain Config 3 Quote Link to comment Share on other sites More sharing options...
Bobrocket Posted August 6, 2015 Share Posted August 6, 2015 Stupid question here, why do you use the bitwise AND in the script? Is it so you can limit the values between 0 and 6? Quote Link to comment Share on other sites More sharing options...
liverare Posted August 6, 2015 Share Posted August 6, 2015 (edited) Sorry but I just had to clean this code up: package com.liverare.better.utility.data; 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.MethodProvider; public enum HouseLocation implements Filter<RS2Object> { NONE("None", 0, 0), RIMMINGTON("Rimmington", 2953, 3224), TAVERLY("Taverly", 2893, 3465), POLLNIVEACH("Pollniveach", 3340, 3003), RELLEKKA("Rellekka", 2670, 3631), BRIMHAVEN("Brimhaven", 0, 0), // TODO Data required YANILLE("Yanille", 0, 0), // TODO Data required ; /* * Static global variables */ public static final String PORTAL_NAME = "Portal"; public static final Integer CONFIG_ID = 738; /* * Local field variables */ private final String name; private final Position position; HouseLocation(String name, Integer x, Integer y) { this.name = name; this.position = new Position(x, y, 0); } /* * Overriden methods */ @Override public String toString() { return name + " [" + position.toString() + "]"; } @Override public boolean match(RS2Object object) { return object.getPosition().equals(position) && object.getName().equals(PORTAL_NAME); } /* * Getters/setters */ public Position getPosition() { return position; } /* * Static methods */ public static HouseLocation getCurrent(MethodProvider methodProvider) { final Integer index = (methodProvider.configs.get(CONFIG_ID) & 0x7); return values()[index]; } } Example of usage: RS2Object housePortalEntrance = getObjects().closest( HouseLocation.getCurrent(this)); Edited August 6, 2015 by liverare 1 Quote Link to comment Share on other sites More sharing options...
Botre Posted August 6, 2015 Share Posted August 6, 2015 (edited) Sorry but I just had to clean this code up: public enum HouseLocation { NONE(0, 0), RIMMINGTON(2953, 3224), TAVERLY(2893, 3465), POLLNIVEACH(3340, 3003), RELLEKKA(2670, 3631), BRIMHAVEN(0, 0), // TODO Data required YANILLE(0, 0), // TODO Data required ; private static final int CONFIG_ID = 738; public final Position position; HouseLocation(Integer x, Integer y) { this.position = new Position(x, y, 0); } public Position getLocation() { return position; } /* * Static methods */ public static HouseLocation getCurrent(MethodProvider methodProvider) { final Integer index = (api.configs.get(CONFIG_ID) & 0x7); return values()[index]; } } Nice find though. It may be very useful in some scripts, especially gilded altar (own house) scripts. If you wanted, you could implement an Filter<RS2Object> onto the enum, implement the required filter methods and then use the Enumerator record itself to filter for the house portal RS2Object. The Filter interface? ew. Edited August 6, 2015 by Botre Quote Link to comment Share on other sites More sharing options...
liverare Posted August 6, 2015 Share Posted August 6, 2015 The Filter interface? ew. For enum records, I use Filter. For records that need a tad more filtering, I use Lambda. Quote Link to comment Share on other sites More sharing options...
Botre Posted August 6, 2015 Share Posted August 6, 2015 For enum records, I use Filter. For records that need a tad more filtering, I use Lambda. You can use lambdas with the Filter class. Filter<RS2Object> lambda = o -> o != null && o.exists(); Filtering a Stream with a Predicate is more efficient than using a Filter on a List, hence the ew. Lambdas are just a matter of reducing verbosity :p Also, why are you boxing the ints ? Oo Quote Link to comment Share on other sites More sharing options...
Flamezzz Posted August 6, 2015 Author Share Posted August 6, 2015 Stupid question here, why do you use the bitwise AND in the script? Is it so you can limit the values between 0 and 6? Ye there were some other bits set in config 738, but as liverare posted the enum values should of course be indexed and not iterated as I did. 1 Quote Link to comment Share on other sites More sharing options...
liverare Posted August 6, 2015 Share Posted August 6, 2015 You can use lambdas with the Filter class. Filter<RS2Object> lambda = o -> o != null && o.exists(); Filtering a Stream with a Predicate is more efficient than using a Filter on a List, hence the ew. Lambdas are just a matter of reducing verbosity Also, why are you boxing the ints ? Oo As for efficiency, we're not talking about a great deal of loss there. It's not like you're gonna need to constantly iterate for the RS2Object like 100 times a second. It's just each time you encounter the zone containing the portal. It's not much of a loss in my eyes. I've (almost) made a full habit of switching from primitives to their Object counterparts, save for the booleans, in order to future proof the programme encase Java remove primitives altogether. There's a bit of controversy surrounding this with people making the case for primitives to be kept. Quote Link to comment Share on other sites More sharing options...
Botre Posted August 6, 2015 Share Posted August 6, 2015 I've (almost) made a full habit of switching from primitives to their Object counterparts, save for the booleans, in order to future proof the programme encase Java remove primitives altogether. There's a bit of controversy surrounding this with people making the case for primitives to be kept. Java won't ever remove primitives. Objects waste space, primitives don't, easy as that x) But at this level it probably doesn't matter. 1 Quote Link to comment Share on other sites More sharing options...
fixthissite Posted August 7, 2015 Share Posted August 7, 2015 (edited) As for efficiency, we're not talking about a great deal of loss there. It's not like you're gonna need to constantly iterate for the RS2Object like 100 times a second. It's just each time you encounter the zone containing the portal. It's not much of a loss in my eyes. I've (almost) made a full habit of switching from primitives to their Object counterparts, save for the booleans, in order to future proof the programme encase Java remove primitives altogether. There's a bit of controversy surrounding this with people making the case for primitives to be kept. Java would never remove primitives. Even with Java 9's value type, which lowers the footprint of object creation, they will not be removed. It would break too much code. Java won't ever remove primitives. Objects waste space, primitives don't, easy as that x) But at this level it probably doesn't matter. Check this out Edited August 7, 2015 by fixthissite 1 Quote Link to comment Share on other sites More sharing options...