January 20, 20179 yr Untested but it seems like it could work /** * * @param position to check if it is within the region * @param player the current position of the player (myPosition()) * @return true if the position is within the region with respect to our players position */ public boolean isReachable(Position position, Position player) { int HOW_BIG_IS_REGION = 20;//idk how big a region is Position insidePos = new Position(position); int distance = insidePos.distance(player); //If the distance from the region is less than our current position, it is reachable return distance < HOW_BIG_IS_REGION; } Just noticed there's already a function for this: map.canReach(position); Edited January 20, 20179 yr by Hayase
January 20, 20179 yr not sure why you want to do it but something like this is probably the most efficient, performance-wise private boolean isLoaded(Position pos) { return pos.getX() > getMap().getBaseX() && pos.getX() < (getMap().getBaseX() + 104) && pos.getY() > getMap().getBaseY() && pos.getY() < getMap().getBaseY() + 104; } Regions are 104x104 EDIT: Didn't test above method, btw Edited January 20, 20179 yr by FrostBug
January 20, 20179 yr Author not sure why you want to do it but something like this is probably the most efficient, performance-wise private boolean isLoaded(Position pos) { return pos.getX() > getMap().getBaseX() && pos.getX() < (getMap().getBaseX() + 104) && pos.getY() > getMap().getBaseY() && pos.getY() < getMap().getBaseY() + 104; } Regions are 104x104 EDIT: Didn't test above method, btw Should works, thanks EDIT; For custom walker. Edited January 20, 20179 yr by Ayylmao420
Create an account or sign in to comment