This is a read only copy without any forum functionality of the old Modcraft forum.
If there is anything that you would like to have removed, message me on Discord via Kaev#5208.
Big thanks to Alastor for making this copy!

Menu

Author Topic: [C++] Get server coords with cursor from map  (Read 2618 times)

dm666

  • Registred Member
  • BLP Convertor
  • *****
  • Posts: 7
    • View Profile
[C++] Get server coords with cursor from map
« on: March 06, 2016, 09:36:52 am »
Hi all. How to i can get coords with cursor?
For example:
I move cursor to Goldshire and want to get server coords.
Help with algorithm pls. What i must load, rendering etc?
Sry for my bad english.
« Last Edit: January 01, 1970, 01:00:00 am by Admin »

schlumpf

  • Administrator
  • Creator of Worlds
  • *****
  • Posts: 2967
    • View Profile
Re: [C++] Get server coords with cursor from map
« Reply #1 on: March 06, 2016, 10:35:28 am »
There is no API to do that ingame. You will need to read the data from WorldMap*.dbc and make them available in lua. Then, determine which map you are on (not sure if there is an API for that or if you'll have Tomas that yourself as well), and determine the coordinates by simple maths (position of cursor in percentage mapped to the rect spanned by the DB. Convert the position from map to server coordinates.
« Last Edit: January 01, 1970, 01:00:00 am by Admin »

dm666

  • Registred Member
  • BLP Convertor
  • *****
  • Posts: 7
    • View Profile
Re: [C++] Get server coords with cursor from map
« Reply #2 on: March 06, 2016, 11:28:49 am »
Thanks for ur answer.
I want to choose location and get coords of the cursor position. Then convert their to server coords(yet it's not necessary).
I want to do something like this
Code: [Select]

statusbarInfo << "tile: " << std::floor(gWorld->camera.x / TILESIZE) << " " << std::floor(gWorld->camera.z / TILESIZE)
<< "; coordinates: client (x: " << gWorld->camera.x << ", y: " << gWorld->camera.z << ", z: " << gWorld->camera.y
<< "), server (x: " << (ZEROPOINT - gWorld->camera.z) << ", y:" << (ZEROPOINT - gWorld->camera.x) << ", z:" << (gWorld->camera.y) << ")";


But how i can get camera x, y, z? I must load adt file? Or dbc file?
« Last Edit: January 01, 1970, 01:00:00 am by Admin »

schlumpf

  • Administrator
  • Creator of Worlds
  • *****
  • Posts: 2967
    • View Profile
Re: [C++] Get server coords with cursor from map
« Reply #3 on: March 06, 2016, 11:43:26 am »
Quote from: "schlumpf"
You will need to read the data from WorldMap*.dbc
« Last Edit: January 01, 1970, 01:00:00 am by Admin »

Amaroth

  • Contributors
  • Creator of Worlds
  • *****
  • Posts: 1219
    • View Profile
    • Amaroth's Tools
Re: [C++] Get server coords with cursor from map
« Reply #4 on: March 06, 2016, 07:24:28 pm »
WorldMapArea.dbc sets coords of borders of maps. Check DBCs documentation for more info. Combination of these coords and coords of mouse cursor should be good enough for getting coords of place, where mouse hovers over.
« Last Edit: January 01, 1970, 01:00:00 am by Admin »
English YT tutorial channel. Check it out if you preffer videos over walls of text.:
https://www.youtube.com/AmarothEng

Want to support me for my releases and/or tutorials? You can send donation via Paypal to:
jantoms@seznam.cz