Jump to content

Region positions


Recommended Posts

Posted (edited)

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 by Hayase
Posted (edited)

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 by FrostBug
  • Like 2
Posted (edited)

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 boge.png

 

EDIT; For custom walker.

Edited by Ayylmao420

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...