Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Coordinate inaccuracy and confusion (https://forums.graalonline.com/forums/showthread.php?t=48327)

-Ramirez- 09-29-2003 05:46 AM

Coordinate inaccuracy and confusion
 
Ok, I've been rather reluctant to make any new threads on the forums, seeing as how most of them end up as "flame wars" or something else with a lot of insults, but nonetheless, I'm posting now.

First off, I've noticed that the gserver and NPC Server both don't send EXACT player/NPC coordinates. For example, an NPC could be on 30,40.599999, and the player would receive the coordinate 30,40.5. It truncates everything after the first digit following the decimal. This can cause problems with NPCs that need to be very accurate on their locations. Has anyone else noticed this happening?

Second... why do players/NPCs EVER end up on coordinates that aren't evenly divisible by 0.0625? That has eluded me for quite a while now. All coordinates should be evenly divisible by 0.0625, as that's 1 pixel in Graal coordinate terms. You can't exactly go smaller than a pixel...

I wanted to make sure I wasn't crazy before posting in the bugs section about this, that's why I posted it here. Feel free to move it, although it's not like you need my permission to do so. :P

Kaimetsu 09-29-2003 06:10 AM

Re: Coordinate inaccuracy and confusion
 
Quote:

Originally posted by -Ramirez-
Second... why do players/NPCs EVER end up on coordinates that aren't evenly divisible by 0.0625? That has eluded me for quite a while now. All coordinates should be evenly divisible by 0.0625, as that's 1 pixel in Graal coordinate terms. You can't exactly go smaller than a pixel...
There is a reason, though it may not be immediately obvious. I'll see if anybody can guess ^_^

-Ramirez- 09-29-2003 06:17 AM

Re: Re: Coordinate inaccuracy and confusion
 
Quote:

Originally posted by Kaimetsu
There is a reason, though it may not be immediately obvious. I'll see if anybody can guess ^_^
Does it have anything to do with Graal's internal movement system?

Loriel 09-29-2003 07:37 AM

I blame Stefan's scary way to calculate the movement that happens if you walk against an edge and thus get pushed to the side.

-Ramirez- 09-29-2003 08:20 AM

Quote:

Originally posted by Loriel
I blame Stefan's scary way to calculate the movement that happens if you walk against an edge and thus get pushed to the side.
That's what I first suspected, however, before posting, I put myself on integer coordinates, then pressed up enough to move a little bit. My coordinates were then a float value not divisible by 0.0625, so that just goes to show that Graal's internal movement system must also not increment/decrement your coordinates by a 0.0625 divisible amount.

adam 09-29-2003 04:48 PM

Bandwidth?

Loriel 09-29-2003 05:06 PM

Quote:

Originally posted by -Ramirez-

That's what I first suspected, however, before posting, I put myself on integer coordinates, then pressed up enough to move a little bit. My coordinates were then a float value not divisible by 0.0625, so that just goes to show that Graal's internal movement system must also not increment/decrement your coordinates by a 0.0625 divisible amount.

Mhm, do you have lizard shield? I am pretty sure that the default speed is 0.5 tiles/frame, but I dun know how the lizard shielded speed is calculated. :|
Also, on GK, the whole thing gets more messy with mudlib speeds and the like :\

GoZelda 09-29-2003 05:18 PM

It seemed to me that a lot of variables seemed to be saved as "integers" or whatever ^^
If you have a calculation, you can never go less then about 5 numbers behind the comma. 33,333...% for example, is, i believe,
33,33333%
What also questions me... is there a way to change values to integer values? It's possible for sure - when i calculated some stuff of the Magic points on GK, i noticed it was 4.2 instead of 4.2, so i guess it must be able to change values to integer values...

I think that Graal saves all x's and y's as integers or floats (?????) ... Wait, that doesn't makes sense, if you press F5, you see numbers like 38.8575040382... I guess that if Graal sends data to the player it becomes integers immediatly or something.

DustyPorViva 09-29-2003 05:26 PM

I'm going to take a wild guess and say when you move diagonally you move at speed squareroot 2...

For it not being divisible of .0625, it might not me, but it goes to the nearest pixel.

Go ahead Kai, say I'm wrong :)

GoZelda 09-29-2003 05:41 PM

Quote:

Originally posted by DustyPorViva
Go ahead Kai, say I'm wrong :)
Can i say it Kai? Can i say it? Pleaaaase? lol

-Ramirez- 09-29-2003 05:48 PM

Quote:

Originally posted by Loriel
Mhm, do you have lizard shield?
Yes.

Quote:

Originally posted by Loriel
I am pretty sure that the default speed is 0.5 tiles/frame, but I dun know how the lizard shielded speed is calculated. :|
0.5 is also what I've always determined it to be. I also always thought the Lizard shield was 0.6, but with the weird coordinates you end up on, that can't be right.

Quote:

Originally posted by GoZelda
What also questions me... is there a way to change values to integer values?
Of course, int().

Quote:

Originally posted by GoZelda
I think that Graal saves all x's and y's as integers or floats (?????) ... Wait, that doesn't makes sense, if you press F5, you see numbers like 38.8575040382... I guess that if Graal sends data to the player it becomes integers immediatly or something.
If it's not an integer or a float value, what could it possibly be? Of course it's going to be one of the two. No, the data isn't an integer, it's a decimal with 1 digit following the period, or at least that's what I've seen when testing this.

Quote:

Originally posted by DustyPorViva
I'm going to take a wild guess and say when you move diagonally you move at speed squareroot 2...
Even though this doesn't have a whole lot to do with what I posted, your diagonal speed is slightly higher than your normal speed. Without the Lizard shield, it's 0.7071068 (sqrt(0.5)), and around 0.8485583 (which I don't know of any calculation that equals this amount, or even relatively close) with it.

Quote:

Originally posted by GoZelda

Can i say it Kai? Can i say it? Pleaaaase? lol

Too late. ;)

GoZelda 09-29-2003 06:01 PM

Quote:

Originally posted by -Ramirez-
Even though this doesn't have a whole lot to do with what I posted, your diagonal speed is slightly higher than your normal speed. Without the Lizard shield, it's 0.7071068 (sqrt(0.5)), and around 0.8485583 (which I don't know of any calculation that equals this amount, or even relatively close) with it.

Mh, maybe this is because two keys are pressed?

DustyPorViva 09-29-2003 06:18 PM

If you press two keys you move diagonally, which is a slightly longer distance then horizontally or vertically, which could alter the coordinates from being naturally divisible by the speed you move.

-Ramirez- 09-29-2003 06:23 PM

Quote:

Originally posted by DustyPorViva
If you press two keys you move diagonally, which is a slightly longer distance then horizontally or vertically, which could alter the coordinates from being naturally divisible by the speed you move.
Oh... of course, sorry, I guess I was too set on thinking something else. However, what I mentioned about coordinate inaccuracy says that I only moved up, not diagonal, and my coordinates were still messed up.

Ningnong 09-29-2003 08:45 PM

Do you always walk the same speed, regardless of frames per second?

If so, then Graal uses a frame-rate independent movement system.

Meaning, the more frames/second you have the slower the co ordinates increment while you walk. Game engines record the time since the last frame.

eg, Y = Y + ( (0.6/1000) * timeElapsed )
1000 milliseconds in 1 second, so you divide 0.6 by 1000 .

y = increasing.


- I talk to Boco alot :)

Loriel 09-29-2003 11:19 PM

Quote:

Originally posted by Ningnong
Do you always walk the same speed, regardless of frames per second?
No. You walk 0.5 tiles per frame.

Ningnong 09-29-2003 11:36 PM

.... So that means no cookie for Ning :( ?

GoZelda 09-30-2003 05:20 PM

Quote:

Originally posted by Ningnong
.... So that means no cookie for Ning :( ?
Fetch boy! *throws dog cookie* thanks for helping me out with that script :)

Now Kai, what's the answer???

Kaimetsu 09-30-2003 06:08 PM

There are actually two, but I'm not sure if the second is applied to Graal.

The first is indeed related to movement. If x and y were locked to pixels then there'd be a limited range of movement speeds. I could move one pixel per frame, or two pixels per frame etc. To deviate from these, I'd need to code a system that keeps track of how far between pixels I am. Essentially I'd be replacing playerx with another variable, and thus negating the whole point of locking it in the first place.

The second is related to how the characters are drawn. If the game were antialiased then characters wouldn't be drawn at the nearest pixel, and thus non-pixel player coordinates would be valid.

GoZelda 09-30-2003 09:01 PM

How do you get to know all this stuff?

Ningnong 09-30-2003 09:54 PM

The cookie monster told him?

Probably experience, you tend to pick things up as you go along. Read forums associated with these type of things, you learn stuff...

Quote:

Originally Posted by GoZelda
thanks for helping me out with that script
Thank Boco, I don't know much C++. I started to learn it, then got side tracked. I'd say I could decode parts of it and point out syntax errors. Im going to learn C first, then C++.

GoZelda 09-30-2003 10:14 PM

Actually, i found it out myself XD
But you trying to help was great, too :)
By the way i finished it and it's even better and it's the pwn XD

Lance 09-30-2003 10:16 PM

Quote:

Originally posted by Ningnong
Im going to learn C first, then C++.
Out of curiosity - why? I could guess, but I'd rather hear your reasoning. :)

GoZelda 09-30-2003 10:19 PM

Quote:

Originally posted by Lance


Out of curiosity - why?

I think the same reason L'oreal does ;)

Ningnong 09-30-2003 10:20 PM

C++ is an extension of C. I am told that most C++ tutorials assume you know C.

Lance 09-30-2003 10:26 PM

Quote:

Originally posted by GoZelda

I think the same reason L'oreal does ;)

You have no idea what I'm talking about.

Quote:

Originally posted by Ningnong
C++ is an extension of C. I am told that most C++ tutorials assume you know C.
Incorrect, they do not assume you know C. C++ is its own language, though it did evolve from C (data abstraction and object-oriented programming features were added). You need not learn C to learn C++. You would probably be better off simply learning C++ than learning both C and C++. If you did decide that you must learn C to understand C++, then by extension, should you not also learn B, or even BCPL?

GoZelda 09-30-2003 10:34 PM

Quote:

Originally posted by Lance
[B]

You have no idea what I'm talking about.
K, we made first step to flame war.

Ningnong 09-30-2003 10:37 PM

I don't know, im only taking advice of someone who's been there and done stuff like this.

Anyway, isn't the new graal engine close too C?

As in:

If you could script in this new G script then, wouldn't working with C be an easy transition?

Lance 09-30-2003 10:49 PM

Quote:

Originally posted by GoZelda

K, we made first step to flame war.

No, you are simply posting replies without reading what you are replying to. I was talking to Ningnong about his decision to learn C before learning C++, and you said something about a reason Loriel does something. These are two quite different situations, but had you read my post, you would have understood.

Quote:

Originally posted by Ningnong
I don't know, im only taking advice of someone who's been there and done stuff like this.
I'm currently learning C++. While I learned some C several years ago, it really isn't something I'd be lost without - in fact, to be perfectly honest, I learned it at too young of an age, and have since forgotten; thus it really isn't a factor in my current learning. The only thing that'd really help you out in learning C++ is a basic understanding of programming concepts - possessing those will make your life much easier, as you'll understand why things work the way they do much better.

Quote:

Anyway, isn't the new graal engine close to C?

As in:

If you could script in this new G script then, wouldn't working with C be an easy transition?
But your goal is to learn C++ though, not to learn C. And, if you're attempting to compare, the new scripting engine is much closer to C++ than it is to C. However, hopefully you don't think by learning the new scripting that you'd be able to code in C++ easily (or, for that matter, C, or any other programming language).

GoZelda 09-30-2003 10:53 PM

Loriel's learning C. So is Ning. I guess they have the same reason for that.

End.

Anyway, you already learn the very very very basics with GScript; if, for, while and a bit of functions.

Ningnong 09-30-2003 10:57 PM

I didn't mean I wanted to learn C / C++ using the new graal engine, I was just saying, If I did learn C would I understand the new graal engine better (or vice versa), but you have answered my question.. (it was just another reason for learning C.)

Anyway, I'll most likley get the C++ books out ;)

Lance 09-30-2003 10:58 PM

Quote:

Originally posted by GoZelda
Loriel's learning C. So is Ning. I guess they have the same reason for that.

End.

Ah, I hadn't recalled reading that. However, don't assume they have the same reasoning ^_^.

Quote:

Anyway, you already learn the very very very basics with GScript; if, for, while and a bit of functions.
Well, those are basic concepts which can be applied to several languages. That goes along with my saying that if he understands the basic concepts, then it'll make learning C++ easier.

Quote:

Originally posted by Ningnong
I didn't mean I wanted to learn C / C++ using the new graal engine, I was just saying, If I did learn C would I understand the new graal engine better (or vice versa), but you have answered my question.. (it was just another reason for learning C.

Anyway, I'll most likley get the C++ books out ;)

Nifty. The one our class is learning from (I'm in a programming concepts/C++ class, and I must brag that I'm doing rather well ;)) is called: Programming and Problem-Solving with C++ (Third Edition) by Dale, Weems, and Headington. It gets the job done. :)

Ningnong 09-30-2003 11:03 PM

Quote:

Originally Posted by Lance
Well, those are basic concepts which can be applied to several languages. That goes along with my saying that if he understands the basic concepts, then it'll make learning C++ easier.
Yea, corse I understand the basic concepts. It's like when I started php, I was reading a tutorial and it mentioned variable assignment (ways I am familiar with), if (condition) etc... I was like, ah ha, this is my cup of tea :D!

-Also, is there a way I can access that book via a website or something, I also need to find a good online tutorial, I hate ones that blab on and talk about irrelevant things, and kind of branch off....one thing leads to another and you get lost..."hey how come were talking about the evolution of the earth now?"

GoZelda 10-01-2003 02:46 PM

Quote:

Originally posted by Lance

Well, those are basic concepts which can be applied to several languages.

Yeah i know :) I learned how to use a for loop by reading a Java tutorial.


Quote:


Nifty. The one our class is learning from (I'm in a programming concepts/C++ class, and I must brag that I'm doing rather well ;)) is called: Programming and Problem-Solving with C++ (Third Edition) by Dale, Weems, and Headington. It gets the job done. :)

I'm looking for a good C++ book ^^ Is it hard english (Like Kai uses)?

Oh and Ning, try
http://www.cprogramming.com
and
http://cotweb3.mccneb.edu/Computercl...Resources.html

(note: above URL might be invalid because copy&paste is dope - svchost.exe closed itself x.x)

Loriel 10-01-2003 07:07 PM

I think someone said that I do plan to first learn C, and then learn C++. This is incorrect, I have no intentions to learn C++.
Almost all C++ tutorials I have seen do not assume that you already know C. Actually, most of them start with things that are almost done the same way in both C and C++. This gets more confusing as simple C code often is valid C++ code too.
The new scripting engine is probably going to be closer to C++ than C, which is not at all object oriented.

If you want to learn C++, I do not think you should start with C. Actually, if you want to start with either C or C++, you should rethink your plans :)
ESR explains that very well, in my opinion, and although this article itself is probably not what you want, the section I point at should be useful.


All times are GMT +2. The time now is 07:59 PM.

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