Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Converting old scripts to NPCs sripts? (https://forums.graalonline.com/forums/showthread.php?t=58085)

JkWhoSaysNi 03-15-2005 05:01 PM

Converting old scripts to NPCs sripts?
 
I'm trying to convert the default walk in a rectangle NPC script to work on an NPC server but i dont know where to begin :p

What do I need to change to get it to work on an NPCs? Are there any tutorials on this anywhere?

I found out i can add clientside at the top to make it clientside, but doesnt this mean every client could potentially see different things? I'm implementing random in the script so that it isnt always a the same sized rectangle. Will random calculate differently on each client?

If so, how can i make it run server side so all the clients see the same?

Thanks.

Lance 03-15-2005 06:04 PM

You'll probably want to make the NPC serverside if you want all players seeing the same thing, and for making the NPC move you'll want to use the serverside move command.

JkWhoSaysNi 03-15-2005 06:19 PM

Thanks. But which is the server side move command? ;)

Gman4pwnu 03-15-2005 08:44 PM

the command is called move.

JkWhoSaysNi 03-16-2005 02:14 AM

Thankyou. I saw that but it looked more complicated than what i had and diddnt want to spend all the time converting the script only to find out it diddnt work server side.

I'm having some problems with it though. Specifically, chaining two together.
After figuring out that it was acting like vectors rather than taking the co-ords as map positions i tried this:
NPC Code:

move 20,0,3,;
timeout = 3;
if (timeout) move 0,20,3,;




I expected this to move the npc across 20 over a duration of 3 seconds, then down 20 over a duration of three seconds.

However, what it does is move the npc across 20 over 3 seconds, then jump it another 20 (approx) without any time in between, then move down 20 over 3 seconds.

Can anyone explain what i'm doing wrong here? I'm using timeout to count down the three seconds that the npc is moving for because i couldnt see a better way. Is there a way of waiting until the last command is finished before executing the next one?

Also, is there any way to give functions arguements? I tried the c++ way (function myFunction(myarg) {}) but it gave me a syntax error.

Kaimetsu 03-16-2005 02:46 AM

Quote:

Originally Posted by JkWhoSaysNi
Can anyone explain what i'm doing wrong here?

You're not following KSI-GS.

JkWhoSaysNi 03-16-2005 03:01 AM

Ok... thanks.

I've changed it to this:

NPC Code:
if (created) {
move 20,0,3,;
timeout = 3;
if (timeout) move 0,20,3,;
}



Now it halts after the first move command.

Polo 03-16-2005 03:04 AM

if (timeout) is an event...
if (created) is also an event...

The two can not and should not be stacked inside each other.

JkWhoSaysNi 03-16-2005 03:06 AM

Ok.... So how can i make it wait three seconds before executing the next move statement?

Edit: I just found the sleep command :P

It still doesnt work though. This is my script:
NPC Code:

if (created) {
move 20,0,3,;
sleep 3;
move 0,20,3,;
}
//#CLIENTSIDE
//some stuff controlling how the npc looks



With this, the NPC is never even shown. It might be being moved, but i cant see it. :frown:

Kaimetsu 03-16-2005 03:21 AM

Quote:

Originally Posted by JkWhoSaysNi
Ok.... So how can i make it wait three seconds before executing the next move statement?

Read move's documention in the relevant newfeatures.txt.

BlueDevil 03-16-2005 03:54 AM

don't you put + or - signs in front of the numbers to tell it which way to go?

Evil_Trunks 03-16-2005 04:10 AM

Quote:

Originally Posted by BlueDevil
don't you put + or - signs in front of the numbers to tell it which way to go?

a number without a + or - sign is considered to be positive

JkWhoSaysNi 03-16-2005 03:51 PM

Ok, I read up on the move command and newfeatures.txt says this should work:

NPC Code:
if (created) {

move 20,0,3,;

sleep 3;

move 0,20,3,;

}

//#CLIENTSIDE

//some stuff controlling how the npc look



Except it doesnt even show the NPC when the sleep command is in there.

What's wrong with this? It's the same as the example.

Kaimetsu 03-16-2005 06:02 PM

Quote:

Originally Posted by JkWhoSaysNi
it doesnt even show the NPC

showcharacter.

JkWhoSaysNi 03-16-2005 06:13 PM

Thanks. I had that in the clientside section. Surely all the visuals should be handled by the client though? I assumed the actions would be serverside and the way it looked would be handled clientside. However, its starting to make sense to me now :D If the npc is server side, the server controls whether the npc is visible and how it looks.

Thanks. Now i think i understand gscript a bit better.


All times are GMT +2. The time now is 01:33 PM.

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