Hi Everyone, Jonathis here again. I am still whiling away on my Monster and Me 2.5 Client rebuild project. Looking for some help on the TQ Coordinate system, as I am not getting expected results. I have confirmed MaM uses the same coordinate system as Conquer Online, and read through a number of posts regarding the calculations, including the extremely useful post found here by unknownone:
The map dimensions are the following:
pixels: 3840 x 2400
tiles: 135 x 135 (according to the map file)
tile size is the standard 64 x 32
So here's my problem... Mouse Coordinate to Map Coordinate works nearly perfectly utilizing unknownone's algorithm:
Code:
int tempX = mouseX - (mouseX % tileWidth);
int tempY = mouseY - (mouseY % tileHeight);
int coordX = tempX / tileWidth + tempY / tileHeight;
int coordY = tempY / tileHeight + (map->width - tempX) / tileWidth;
//Array replicating 'Rainbow Tile'
int posX = mouseX - tempX;
int posY = mouseY - tempY;
if (tileZone[posX][posY] == TileZone::TOPLEFT) coordX--;
else if (tileZone[posX][posY] == TileZone::TOPRIGHT) coordY--;
else if (tileZone[posX][posY] == TileZone::BOTTOMLEFT) coordY++;
else if (tileZone[posX][posY] == TileZone::BOTTOMRIGHT) coordX++;
I cross referenced the given coordinates in quite some detail with the coordinate system in game, with the only hiccup being the x coordinate was always 1 off. I can fix that by adding 1 to it, though I'm not completely sure why it is off given the above. Once I add the 1 offset, I get exact matches to the ingame coordinates.
Now comes the problem. I try to do the reverse, and apply the Map Coordinate to Screen Point algorithm, and get very odd results. Below is the implemented algorithm.
With this, I get a seemingly accurate x position, as can be seen by how the bounding rectangle bounds a tile that is in alignment with my mouse position. I am not completely sure it is right though, because the 0,60 calcs look iffy. The Y axis is definitely wrong though.
Instead of starting in the middle, I figure take a simple example
The top left corner of the map is the coordinate 0,60. If I plug in the above I get the following results:
x = (0-60) * 32 + 1920 = 0
y = (0 + 60 - (135 - 1)) * 32 + 1200 = -49 * 32 + 1200 = -1168
Given the first tile origin is the very top left corner for the map, I would expect the tile and bounding rectangle to only be a quarter visible. Thus expected x and y should be -32,-16. Definitely not right! If I subtract an extra 1 from the x coordinate, I get the expected x values (which is obviously because I had to add 1 earlier). Still, the Y coordinate is really puzzling me.
If anyone has any suggestions, I'd much appreciate it. Thanks
If I input my values, I still don't get the right results. Assuming posOrigin is 0,0 for the top left corner, thus no current offset to the map, using the same 0,60 coordinate:
iWorldX = 64 * (0-60) / 2 = -1920
iWorldY = 32 * (0+60) / 2 = 960
If I input my values, I still don't get the right results. Assuming posOrigin is 0,0 for the top left corner, thus no current offset to the map, using the same 0,60 coordinate:
iWorldX = 64 * (0-60) / 2 = -1920
iWorldY = 32 * (0+60) / 2 = 960
This code is not yours, it was stolen via a RAT on my computer years ago.
Figured that was a little too smart for him to come up with. Nothing against him, just not his skillset. Had me surprised for a minute, but it makes sense now.
Wish I saw this before I started digging in the client to find what the calcs were in memory. Just came on to post my final findings with the chunks of code. After implementing the below, I am getting accurate results for all the maps.
First we have an amalgam of spirited's code, where the m_posOrigin x/y has the following formula
I have fully tested both aspects of these, and cross examined (without objection) the coordinates and real points to the ones in the live game client, and it all matches up. I am a bit puzzled as to why my coord>point is different than spirited's and what Angelius references. Perhaps further operations are done to the given x,y at a later point and I am just consolidating them here? Well, I'm not going to dwell on it too much.
COnquer coordinate in cartesian coordinate ? 02/07/2011 - CO2 Programming - 5 Replies i m working on my minimap in pro4never proxy, i cleaning map from coquer site and put in picture box
now i want to locate my char in this minimap likes in game :) but the coordinate in game are different view of classic cartesian coordinate :)
some1 had module to trasform Conquer coordinate in cartesian coordinate ?
or explain me why cood traslation in math not work :// :handsdown:
i m working on this sistem