Welcome to TRiBot Forums

Register now to gain access to all of our features. Once registered and logged in, you will be able to contribute to this site by submitting your own content or replying to existing content. You'll be able to customize your profile, receive reputation points as a reward for submitting content, while also communicating with other members via your own private inbox, plus much more! This message will be removed once you have signed in.

IceKontroI

Returning Camera's Real Position [SOLVED]

5 posts in this topic

Anyone know how to get the RSTile that the camera is hovering directly over? I've tried using

Game.getCameraX();
Game.getCameraY();
Game.getCameraZ();

but these seem to be using a different coordinate grid than the one objects in-game do. When the player's RSTIle position was (3184, 3436, 0) [X, Y, Plane], the camera's position using the above functions was (8139, 5679, -1180) [X, Y, Z]. This doesn't seem to add up since the X and Y coordinates are so far apart. If anyone has any insight on how I could return the RSTile of the camera or even the distance between the camera and player it would be greatly appreciated.

EDIT: Thanks to Deluxes for providing the solution to this. A snippet to get the camera's RSTile position is below.

public static RSTile getCameraTile() {
	return new RSTile(Game.getCameraX() / 128 + Game.getBaseX(), Game.getCameraY() / 128 + Game.getBaseY());
}

 

Edited by IceKontroI

Share this post


Link to post
Share on other sites

Any reason for it? Camera position is based on world locations not tile locations.

 

You would take the Game.getCameraX/Y and divide by 128 then add the Game.getBaseX/Y to get the tile location. Of course its not going to be a whole number as the camera is not bound to tile locations.

Share this post


Link to post
Share on other sites
8 minutes ago, Deluxes said:

Any reason for it? Camera position is based on world locations not tile locations.

 

You would take the Game.getCameraX/Y and divide by 128 then add the Game.getBaseX/Y to get the tile location. Of course its not going to be a whole number as the camera is not bound to tile locations.

Damn you came through, that's actually the formula. I needed this to calculate the visible space for objects I want to click. For example if I want to click a tile without interacting with any NPCs that could be obscuring it, I'll need to find all the NPCs between the camera and the tile. Then I just click the area that is not shared between the tile's bounds and the bounds of all those NPCs. The same can be done with in-game objects to prevent your script from clicking an extremely distant tile through multiple buildings which is relatively unrealistic and most players would just click the minimap.

Share this post


Link to post
Share on other sites
1 minute ago, IceKontroI said:

Damn you came through, that's actually the formula. I needed this to calculate the visible space for objects I want to click. For example if I want to click a tile without interacting with any NPCs that could be obscuring it, I'll need to find all the NPCs between the camera and the tile. Then I just click the area that is not shared between the tile's bounds and the bounds of all those NPCs. The same can be done with in-game objects to prevent your script from clicking an extremely distant tile through multiple buildings which is relatively unrealistic and most players would just click the minimap.

Pretty sure USA posted a snippet of this awhile back on some random thread.

Share this post


Link to post
Share on other sites
Just now, Deluxes said:

Pretty sure USA posted a snippet of this awhile back on some random thread.

Is it this thread? Cause that snippet worked for all objects in the specified area and only returned whether or not an object had any visible points. My response post was a modified version of that which returned a polygon representing the visible points, but it still didn't take into consideration objects behind the player that were still in front of the camera. The camera's physical location was the final piece of the puzzle.

Share this post


Link to post
Share on other sites

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.