Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 02-17-2005, 09:04 AM
SSS SSS is offline
Owner of Sceleris
Join Date: Jan 2005
Posts: 14
SSS is on a distinguished road
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:

if (mousescreenx in | mapxy[0], mapxy[0] + 420 | &&
mousescreeny in | mapxy[1], mapxy[1] + 420 | ) {
this.mapxy = {mousescreenx-mapxy[0]*6.5,mousescreeny-mapxy[1]*6.5}; //here is where i get the gmap coords from the screencoords
//but the math is wrong

if (keydown2(17, true)) {
triggeraction 0, 0, serverside, -Map, warp, #v(this.mapx),#v(this.mapy);

}
}

Reply With Quote
  #2  
Old 02-17-2005, 10:10 AM
Polo Polo is offline
Classic Systems Admin
Join Date: Sep 2002
Location: Vancouver, Canada
Posts: 735
Polo is on a distinguished road
Send a message via AIM to Polo
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 . Also you seem to use to totally new variables when passing to the triggeraction...

Try...

NPC Code:

if (mousescreenx in | mapxy[0], mapxy[0] + 420 | && mousescreeny in | mapxy[1], mapxy[1] + 420 | ) {
if (keydown2(17, true)) {
this.tempxy = {mousescreenx-mapxy[0]*(16/7),mousescreeny-mapxy[1]*(16/7)};
triggeraction 0, 0, serverside, -Map, warp, #v(this.tempxy[0]),#v(this.tempxy[1]);
}
}



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
__________________
Be good little players, or Master Storm will ban you!



Proof that the staff are crazy..
*Ghost Pirate: I'm a little teacup short and stubbe here is my raygun here is my butt
DragonX: Jumping jack rabbits Batman! Our eggo waffles have been stolen! To the batmobile Robin!
X-Mann (RC): I have a head ache
Reply With Quote
  #3  
Old 02-17-2005, 11:16 AM
SSS SSS is offline
Owner of Sceleris
Join Date: Jan 2005
Posts: 14
SSS is on a distinguished road
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
Reply With Quote
  #4  
Old 02-18-2005, 08:09 AM
SSS SSS is offline
Owner of Sceleris
Join Date: Jan 2005
Posts: 14
SSS is on a distinguished road
nobody knows? comon
Reply With Quote
  #5  
Old 02-18-2005, 08:38 AM
Tolnaftate2004 Tolnaftate2004 is offline
penguin.
Join Date: Jul 2004
Location: Berkeley, CA
Posts: 534
Tolnaftate2004 is a jewel in the roughTolnaftate2004 is a jewel in the rough
Send a message via AIM to Tolnaftate2004
NPC Code:

if (mousescreenx in | mapxy[0], mapxy[0] + 420 | && mousescreeny in | mapxy[1], mapxy[1] + 420 | ) {
if (keydown2(17, true)) {
this.tempxy = {(mousescreenx-mapxy[0])*(16/7),(mousescreeny-mapxy[1])*(16/7)};
triggeraction 0, 0, serverside, -Map, warp, #v(this.tempxy[0]),#v(this.tempxy[1]);
}
}

Reply With Quote
  #6  
Old 02-18-2005, 11:47 AM
Polo Polo is offline
Classic Systems Admin
Join Date: Sep 2002
Location: Vancouver, Canada
Posts: 735
Polo is on a distinguished road
Send a message via AIM to Polo
Oh yeah silly me forgot the brackets round the subtraction
__________________
Be good little players, or Master Storm will ban you!



Proof that the staff are crazy..
*Ghost Pirate: I'm a little teacup short and stubbe here is my raygun here is my butt
DragonX: Jumping jack rabbits Batman! Our eggo waffles have been stolen! To the batmobile Robin!
X-Mann (RC): I have a head ache
Reply With Quote
  #7  
Old 02-19-2005, 03:11 AM
ApothiX ApothiX is offline
Okiesmokie
Join Date: May 2004
Posts: 1,447
ApothiX is on a distinguished road
For security reasons, instead of triggeractioning a warp, you should just do like
setplayerprop #c,warpto #v(xcoord) #v(ycoord); or something.
__________________


[06:24:19] * Parts: Skyld (i=silent@unaffiliated/skyld) ("Perhaps Okiesmokie did not realise that I like the boys. ")
Reply With Quote
  #8  
Old 02-19-2005, 08:54 AM
SSS SSS is offline
Owner of Sceleris
Join Date: Jan 2005
Posts: 14
SSS is on a distinguished road
It works now, thanks a lot
Reply With Quote
  #9  
Old 02-21-2005, 07:54 AM
SSS SSS is offline
Owner of Sceleris
Join Date: Jan 2005
Posts: 14
SSS is on a distinguished road
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?
Reply With Quote
  #10  
Old 02-21-2005, 09:43 PM
Dach Dach is offline
call me Chad, it's cooler
Dach's Avatar
Join Date: Aug 2002
Posts: 1,899
Dach is on a distinguished road
Quote:
Originally Posted by SSS
Having another problem, since Im not good with math.
[...]
showimg 201,@@@Me,this.x+playerx/420,this.y+playery/420;
changeimgvis 201,4;
Math lesson
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
__________________
Scripting Documents:Old Script Documentation-Movement Tutorial
Reply With Quote
  #11  
Old 02-24-2005, 07:55 AM
SSS SSS is offline
Owner of Sceleris
Join Date: Jan 2005
Posts: 14
SSS is on a distinguished road
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.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 05:59 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.