Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Gravity.... (https://forums.graalonline.com/forums/showthread.php?t=52198)

greeno 04-10-2004 01:44 AM

Gravity....
 
Hello, I am making a gravity room for my guild house and I was wondering why my script makes people go through objects.... basically I have it make the playery subtract one every .05 seconds, and if the up arrow is pushed, then they go up, but for some reason it makes them go through tiles... I remember doing this with an older version of graal and it worked fine. Did stefan/unixmad change that in a later release?

And I would like to know if anyone can help me
this is my code....

// NPC made by Stipo Swift -Leader- (Turtles)
if (created) {
falling = true;
}

while (falling==true)
{
playery = playery + 1;
sleep .05;
if (keydown(A))
{
playery = playery - 2;
if (playery > 60)
{
playery = playery - 2;
}
}
}

any suggestions? :confused:

Riot 04-10-2004 01:47 AM

erm, keydown(A)?

Also you need to do onwall checks to stop it from going on walls.

Please look into another way of doing this.

greeno 04-10-2004 01:51 AM

well thats why I am here, to find out other ways of doing it, I'm not a professional :P

Dach 04-10-2004 02:42 AM

Re: Gravity....
 
Quote:

Originally posted by greeno
I have it make the playery subtract one every .05

but for some reason it makes them go through tiles...

think about that for a second, you're script moves the player regardless if there is a blocking tile there or not :\

and keydown needs a number argument, its in the commands.rtf (the list on the left in the offline script editor)

greeno 04-10-2004 04:35 AM

ok, thank you, like I said i'm new to this.

and I was wondering if you could get an NPC to say a variable...
like the playerx and playery variables... I've been looking through the list and so far I have nothing....

Dach 04-10-2004 05:49 AM

use #v(variablehere) in the message, those parseing things are at the end, their not incredibly straight forward so you just have to experiment with them more to figure them out

greeno 04-10-2004 05:51 AM

ok, thanks... one more question for tonight, will
if (onwall(playerx,playery)) work for this situation?

ZeroTrack 04-10-2004 07:25 AM

you need to detect if the player has hit a wall or come to an object that is set to block the player using onwall command, also use if(keydown2(keycode(a),false)) or if(keydown(5)) if ya wanna be nubish about it :)

Dach 04-10-2004 07:42 AM

the position (playerx,playery) is at the top lefthand corner of the player, use playerx+1.5,playery+2 it's not exact (playery+1.96875 is right) but there is hardly a difference so it doesn't matter

onwall is a function

ack, I just noticed, don't use a while loop for that, use a timeout

Ningnong 04-10-2004 10:23 AM

timeout would also fix that delay you've got with the sleep. Also, get into the habbit of using this:

NPC Code:

playery -= 2;
playery += 1;



etc, it looks alot neater :]

TB3 04-10-2004 11:15 AM

I would like to see the gravity script from g2k1 and how it was done it worked rather smoothly than most I have seen :).
I made one but its a little buggy going up

-Ramirez- 04-10-2004 06:43 PM

Quote:

Originally posted by Dach
(playery+1.96875 is right)
...yeah, if pixels are capable of being divided by two. A pixel is 0.0625 tiles, not 0.03125 tiles.

Dach 04-10-2004 09:00 PM

1 Attachment(s)
Quote:

Originally posted by -Ramirez-

...yeah, if pixels are capable of being divided by two. A pixel is 0.0625 tiles, not 0.03125 tiles.

Aren't odd numbers wonderous? :grin:

try it out before jumping to conclusions next time, say something in this level, one of the npcs calculates the middle of the player

-Ramirez- 04-10-2004 09:19 PM

Quote:

Originally posted by Dach
try it out before jumping to conclusions next time, say something in this level, one of the npcs calculates the middle of the player
There's nothing to try out. :grin:

It's simply not possible to get more accurate than a pixel. If you use something like that in any onwall check or whatever, Graal is going to round it some way or another.

Dach 04-10-2004 09:42 PM

Quote:

Originally posted by -Ramirez-

There's nothing to try out. :grin:

It's simply not possible to get more accurate than a pixel. If you use something like that in any onwall check or whatever, Graal is going to round it some way or another.

Look, lets say you have an odd number, 3. You need to find the middle of that number, so you do 3/2 which is 1.5, correct? Guess what, an odd number of pixels is going to do the same thing.

It's not like i'm proposing the use of such numbers, I did say to use 2. Granted I didn't notice that the number was in the middle of a pixel untill you said something, but it's not like I'm wrong.

-Ramirez- 04-10-2004 10:17 PM

Quote:

Originally posted by Dach
Look, lets say you have an odd number, 3. You need to find the middle of that number, so you do 3/2 which is 1.5, correct? Guess what, an odd number of pixels is going to do the same thing.
That's irresponsible. You should realize that when you do the calculation and use the appropriate calculations to make it an exact pixel coordinate rather than half. Well, on Graal, that's no big deal to leave it that way, as it's going to use the right coordinate for you regardless, but it's just bad to get in the habit of being lazy.

Quote:

Granted I didn't notice that the number was in the middle of a pixel untill you said something, but it's not like I'm wrong.
I never said you were wrong about anything. I was pointing out the fact that you were saying the middle of the player is a half-pixel coordinate.

greeno 04-10-2004 11:05 PM

Quote:

Originally posted by Dach
the position (playerx,playery) is at the top lefthand corner of the player, use playerx+1.5,playery+2 it's not exact (playery+1.96875 is right) but there is hardly a difference so it doesn't matter

onwall is a function

ack, I just noticed, don't use a while loop for that, use a timeout


okay... i'm looking that up in the npc scripting help that comes with graal.... so far i'm understanding it.

Dach 04-11-2004 08:11 AM

Quote:

Originally posted by -Ramirez-

That's irresponsible. You should realize that when you do the calculation and use the appropriate calculations to make it an exact pixel coordinate rather than half. Well, on Graal, that's no big deal to leave it that way, as it's going to use the right coordinate for you regardless, but it's just bad to get in the habit of being lazy.


I never said you were wrong about anything. I was pointing out the fact that you were saying the middle of the player is a half-pixel coordinate.

The players' onwall block is located 16 pixels (1 tile) down, and is 31 (an odd number) pixels deep. This information shows that the middle of the player is, in fact, 30.5 pixels (1.96875 tiles) down from playery. I have no idea what you are trying to argue with me about, since I thought I made it blatantly obvious I don't use that number. actually it appears you are spreading your platform, switching from argueing against the possibility that the middle could be a half pixel, and against using such a calculation in script, tut tut tut

-Ramirez- 04-11-2004 07:32 PM

Quote:

This information shows that the middle of the player is, in fact, 30.5 pixels (1.96875 tiles) down from playery. I have no idea what you are trying to argue with me about, since I thought I made it blatantly obvious I don't use that number.
I'm not arguing with you about anything. Everyone on the forums is obsessed with considering everything an argument, aren't they? Anyway, using a half coordinate in a calculation of any kind is going to produce an end result with a half-pixel coordinate anyway without further calculation to round it, so what ARE you talking about? If you don't use it directly in any calculations, what the hell is the point in knowing it? Well, if you were to double it, that would even it out, but um... if you did that, why divide it to begin with?

Quote:

actually it appears you are spreading your platform, switching from argueing against the possibility that the middle could be a half pixel, and against using such a calculation in script, tut tut tut
*doesn't consider this an argument, but whatever*

greeno 04-12-2004 04:30 PM

Goodbye thread.... :(

myth-simba 11-27-2004 12:59 AM

Quote:

Originally Posted by greeno
Hello, I am making a gravity room for my guild house and I was wondering why my script makes people go through objects.... basically I have it make the playery subtract one every .05 seconds, and if the up arrow is pushed, then they go up, but for some reason it makes them go through tiles... I remember doing this with an older version of graal and it worked fine. Did stefan/unixmad change that in a later release?

And I would like to know if anyone can help me
this is my code....

// NPC made by Stipo Swift -Leader- (Turtles)
if (created) {
falling = true;
}

while (falling==true)
{
playery = playery + 1;
sleep .05;
if (keydown(A))
{
playery = playery - 2;
if (playery > 60)
{
playery = playery - 2;
}
}
}

any suggestions? :confused:

have you got the gravity script with you? i may be able to help you solve it. i experiment with stuff like that. i made the tiles not be able to walk through once. could u tell me script i may be able to help.

Kaimetsu 11-27-2004 01:01 AM

Dude, don't post in threads that are more than a couple of weeks old.

VeX_RaT_Boy 11-27-2004 01:52 AM

I just felt for making a gravity script now...

EDIT: Maybe I should rather call it side-viewed graal?


All times are GMT +2. The time now is 02:37 AM.

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