![]() |
Gmap warp on a custom map script
Hi i have a custom map script on my playerworld and am trying to do the warping for it..
it works but i cant figure out how to get the gmap coords from the screencoords of the map.. The map image is 420x420 The gmap is 15 x 15 levels.. Im not good at math so im having some problems here.. :( mapxy is the coordinates of the map image on the screen.. How is the math done? to convert the mousescreen coordinates on the map to gmap coordinates.. so if i click the bottem right corner i will warp to the bottem right corner, which is 957x957.. this is a part of the script NPC Code: |
Instead of *6.5 you want *(960/420) to scale it to the gmap..
(The map is actually 960 tiles big not 957) That can be simplified to *(16/7).... ...however i think you have some logical errors... firstly... mapxy[] is where the map is positioned on the screen? Or where you are saving the cordinates to? You seem to be using it for both x_x. Also you seem to use to totally new variables when passing to the triggeraction... Try... NPC Code: Now mapxy[] is the position of the map on the screen and tempxy[] is where we temporarily store the values when calculating them. If there somthing glaringly wrong in what I posted, then blame lack of sleep :\ |
It doesnt seem to work, it might have been something I did wrong but Ive been working on it for about 10 minutes, still doesnt work properly..
Maybe i should give some more information ;) mapxy = {screenwidth / 2 - 210, screenheight / 2 - 210}; The map is shown in the middle , it is 420x420. Im trying to make it so if i click 0,0 on the map screen i will be warped to 0,0 but if i click the very bottem right corner i will be warped to 957x957, or the very bottem corner mapxy is where the map is shown on the screen im trying to get the new player coordinates from the screen position on mapxy to gmap position,so instead of 420x420 it would be 957x957 am i confusing? im sorta confusing myself :( |
nobody knows? comon :(
|
NPC Code: |
Oh yeah silly me forgot the brackets round the subtraction x_x
|
For security reasons, instead of triggeractioning a warp, you should just do like
setplayerprop #c,warpto #v(xcoord) #v(ycoord); or something. |
It works now, thanks a lot :)
|
Having another problem, since Im not good with math.
Here it is, can anyone help? Im trying to show where the player is on the custom map.. the custom map position is on the screen at x(screenwidth / 2 - 210) y(screenheight / 2 - 210) the map image is shown there, the map image is 420x420 I cant figure the math out same map size as I used for the warping up there.... but it needs to show up using something like this. showimg 201,@@@Me,this.x+playerx/420,this.y+playery/420; changeimgvis 201,4; any math experts out there that can help? |
Quote:
We have three numbers, a b c and d (makes more sense for b and c to be vectors and a be a position on b and we are looking for the corresponding position, d, on b, but I doubt you have that kind of math knowledge :/ ) where 0<=a<=b and 0<=d<=c and we want to find d so that a/b = d/c. We work out the expression; a/b = d/c (a/b)*c = d d = (a/b)*c assuming that this.x and this.y are the map x and y; we know 420 is the width and height of map image, and 960 is the width and height of the actual map in tiles, therefore using the above expression, a is playerx or y, b = 960, c = 420 and d is the x or y of the position on the map image. You can do the rest, if you can't I will personally beat you with a stick :rolleyes: |
Thanks for helping out, and not being an ******* about it because you have more math skills then me, not all of us have good education, some people just dont understand things the way others do..Everyones different and unique in their own way.
|
| All times are GMT +2. The time now is 03:34 PM. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.