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 04-10-2004, 01:44 AM
greeno greeno is offline
Registered User
Join Date: Oct 2001
Location: U.S.A.
Posts: 116
greeno is on a distinguished road
Send a message via AIM to greeno
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?
__________________
-Stipo Swift-
"My Cat likes string cheese"
Reply With Quote
  #2  
Old 04-10-2004, 01:47 AM
Riot Riot is offline
Delteria Management
Join Date: Nov 2003
Location: Seminole County, Florida
Posts: 280
Riot is on a distinguished road
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.
Reply With Quote
  #3  
Old 04-10-2004, 01:51 AM
greeno greeno is offline
Registered User
Join Date: Oct 2001
Location: U.S.A.
Posts: 116
greeno is on a distinguished road
Send a message via AIM to greeno
well thats why I am here, to find out other ways of doing it, I'm not a professional :P
__________________
-Stipo Swift-
"My Cat likes string cheese"
Reply With Quote
  #4  
Old 04-10-2004, 02:42 AM
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
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)
__________________
Scripting Documents:Old Script Documentation-Movement Tutorial
Reply With Quote
  #5  
Old 04-10-2004, 04:35 AM
greeno greeno is offline
Registered User
Join Date: Oct 2001
Location: U.S.A.
Posts: 116
greeno is on a distinguished road
Send a message via AIM to greeno
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....
__________________
-Stipo Swift-
"My Cat likes string cheese"

Last edited by greeno; 04-10-2004 at 05:25 AM..
Reply With Quote
  #6  
Old 04-10-2004, 05:49 AM
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
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
__________________
Scripting Documents:Old Script Documentation-Movement Tutorial
Reply With Quote
  #7  
Old 04-10-2004, 05:51 AM
greeno greeno is offline
Registered User
Join Date: Oct 2001
Location: U.S.A.
Posts: 116
greeno is on a distinguished road
Send a message via AIM to greeno
ok, thanks... one more question for tonight, will
if (onwall(playerx,playery)) work for this situation?
__________________
-Stipo Swift-
"My Cat likes string cheese"
Reply With Quote
  #8  
Old 04-10-2004, 07:25 AM
ZeroTrack ZeroTrack is offline
G2K1 Developer
ZeroTrack's Avatar
Join Date: Apr 2004
Location: LongIsland, NY
Posts: 402
ZeroTrack is on a distinguished road
Send a message via AIM to ZeroTrack
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
Reply With Quote
  #9  
Old 04-10-2004, 07:42 AM
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
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
__________________
Scripting Documents:Old Script Documentation-Movement Tutorial
Reply With Quote
  #10  
Old 04-10-2004, 10:23 AM
Ningnong Ningnong is offline
Registered User
Ningnong's Avatar
Join Date: Nov 2002
Location: < -- way
Posts: 262
Ningnong is on a distinguished road
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 :]
__________________
Former Global Scripting Team Member


Reply With Quote
  #11  
Old 04-10-2004, 11:15 AM
TB3 TB3 is offline
Registered User
TB3's Avatar
Join Date: May 2001
Location: US of A State of VA
Posts: 658
TB3 is on a distinguished road
Send a message via Yahoo to TB3
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
__________________

To the sun of your age, I arise
Reply With Quote
  #12  
Old 04-10-2004, 06:43 PM
-Ramirez- -Ramirez- is offline
Registered User
Join Date: Jun 2002
Location: USA, Ohio
Posts: 729
-Ramirez- has a spectacular aura about
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.
__________________
Kat
Reply With Quote
  #13  
Old 04-10-2004, 09:00 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 -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
Attached Files
File Type: nw playerblock_test.nw (10.1 KB, 184 views)
__________________
Scripting Documents:Old Script Documentation-Movement Tutorial

Last edited by Dach; 04-10-2004 at 09:37 PM..
Reply With Quote
  #14  
Old 04-10-2004, 09:19 PM
-Ramirez- -Ramirez- is offline
Registered User
Join Date: Jun 2002
Location: USA, Ohio
Posts: 729
-Ramirez- has a spectacular aura about
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.
__________________
Kat
Reply With Quote
  #15  
Old 04-10-2004, 09:42 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 -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.
__________________
Scripting Documents:Old Script Documentation-Movement Tutorial
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 09:40 PM.


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