Graal Forums  

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

 
 
Thread Tools Search this Thread Rate Thread Display Modes
  #1  
Old 05-19-2001, 05:03 AM
Admins Admins is offline
Graal Administration
Join Date: Jan 2000
Location: Admins
Posts: 11,693
Admins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud of
Converting NPCs

A lot of servers have the npcserver now.
Some tips for converting scripts to work with
the npcserver:

- client-side scripts:

By default all code is running on the npcserver. But some stuff must be done client-side because the commands just don't exist on the npcserver, because they are just graphical or are playing sound effects. This means you need to change the scripts for lights, then it will look like this:

NPC Code:

if (created)
dontblock;

//#CLIENTSIDE

if (playerenters) {
setcoloreffect 1,0,0,0.99;
setzoomeffect 2;
drawaslight;
}



- playertouchsme:

The server doesn't load images or ganis to exactly detect if a player touchs an npc. To let the server know how big (in pixels) an npc is you can use the setshape command:

NPC Code:

if (created)
setshape 1,32,32;
if (playertouchsme)
playerrupees++;



This script would give the player one gralat when he touchs the npcs. 32x32 would be the size of a door (2x2 tiles since each tile is 16x16). The first parameter (1) is for specifying what kind of shape the npc has, currently only 1 (for tectangle) is supported.

- old commands:

Some people still use script commands that are not supported anymore. While Graal.exe still supports them (for compatibility), the npcserver ignores such commands. This is mainly 'playersays(text)', which can be replaced with 'playerchats && strequals(#c,text)'. Also 'setlevel' doesn't work, use the better command 'setlevel2' instead

- timeouts:

The minimum timeout for the npcserver is 0.1, while it is 0.05 secs in Graal.exe. The reason is that because of lag a more precise timeout wouldn't make sense, and it saves CPU time.
  #2  
Old 05-19-2001, 10:05 AM
Guest
Posts: n/a
cool...
  #3  
Old 05-19-2001, 12:02 PM
G_yoshi G_yoshi is offline
Forbidden
G_yoshi's Avatar
Join Date: Mar 2001
Posts: 7,206
G_yoshi will become famous soon enough
Send a message via AIM to G_yoshi
lol......that means i have to go back and fix all the npcs i will be using.....oh well......
__________________
  #4  
Old 05-19-2001, 12:53 PM
MoonAngel MoonAngel is offline
Banned
MoonAngel's Avatar
Join Date: Mar 2001
Location: QUÉBEC!
Posts: 1,443
MoonAngel is on a distinguished road
Send a message via ICQ to MoonAngel Send a message via AIM to MoonAngel
i have a question, when doing a setshape, if you touch it, will it automatically work or do you still need to push a key to make sure you're touching it?

like in those gravity rooms, lets say an npc will lay a pack of darts, with playertouchsme, dropping on the npc doesnt do a thing, will setshape remove that sort of a glitch?

i hope this example was clear enough, i dont really know how to describe it
  #5  
Old 05-19-2001, 09:17 PM
Admins Admins is offline
Graal Administration
Join Date: Jan 2000
Location: Admins
Posts: 11,693
Admins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud of
? what do you mean?
  #6  
Old 05-19-2001, 09:30 PM
MoonAngel MoonAngel is offline
Banned
MoonAngel's Avatar
Join Date: Mar 2001
Location: QUÉBEC!
Posts: 1,443
MoonAngel is on a distinguished road
Send a message via ICQ to MoonAngel Send a message via AIM to MoonAngel
erm.. from what i can see the playertouchsme command doesnt check for x and y it checks to see if the player is going on the npc with the arrow keys, so if you move the player with an npc it wont do the playertouchsme unless you try to move with the arrows. I was wondering if setshape checks to see if part of the 3x3 tiles of the player is on the npc or if we still need to walk on that npc with the arrows. i know its hard to understand but its also hard to explain
  #7  
Old 05-19-2001, 09:34 PM
Admins Admins is offline
Graal Administration
Join Date: Jan 2000
Location: Admins
Posts: 11,693
Admins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud of
Normally the server checks for playertouchsme
each time the player moves; but the player
must touch the npc with his front (depending on
the direction)
  #8  
Old 05-19-2001, 09:38 PM
MoonAngel MoonAngel is offline
Banned
MoonAngel's Avatar
Join Date: Mar 2001
Location: QUÉBEC!
Posts: 1,443
MoonAngel is on a distinguished road
Send a message via ICQ to MoonAngel Send a message via AIM to MoonAngel
hmm so ill still have to use

e.g: if(int(playery)<=y+10)

to check if the player is actually touching the npc without moving
  #9  
Old 06-06-2001, 06:54 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
Lmao you do confuse

I think i know what you mean saying that if (playersx<x+2.5&&playersx>x-.5&&playery<y+3.5&&playery>y-.5) { using this to detect if the npcs actualy is touching an area where the player is located correct? }
__________________

To the sun of your age, I arise
  #10  
Old 06-06-2001, 06:57 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
Well if thats what ur askin noperz the setshape will not detect that it will only detect if the player is moving and facing most of the time so sometimes its better to make ur own detection script heheh this one here will work in a timeout loop if its client side if u want to use it that is if i did it correctly not sure it will pick up i think around a 32*48 object i wasnt paying attention to what i was typing
__________________

To the sun of your age, I arise
  #11  
Old 06-06-2001, 07:00 AM
MoonAngel MoonAngel is offline
Banned
MoonAngel's Avatar
Join Date: Mar 2001
Location: QUÉBEC!
Posts: 1,443
MoonAngel is on a distinguished road
Send a message via ICQ to MoonAngel Send a message via AIM to MoonAngel
Bah, the only reason im confusing is because i can't think right in english, i wouldnt be confusing if i would be typing in french but then almost no one would understand ; )


anyways, i solved my problem
  #12  
Old 06-06-2001, 08:13 AM
T-Squad T-Squad is offline
Banned
T-Squad's Avatar
Join Date: Mar 2001
Location: United States of America
Posts: 1,733
T-Squad is on a distinguished road
stefan, lets say you have the script (this is a simplified version to show a point)

timeout = 0.1;
if (timeout) {
timeout = 0.1;
setstring server.blah,#v(this.x);
}
//#CLIENSIDE
timeout = 0.05;
if (timeout) {
timeout = 0.05;
if (keydown(6)) {
this.x = 5;
}
}

in a nutshell, i need server.blah to = this.x....
but for some reason it doesnt work..also keydown doesnt work server side, so i must make it client side....
  #13  
Old 06-06-2001, 08:41 AM
kyle0654 kyle0654 is offline
-. .`
kyle0654's Avatar
Join Date: Mar 2001
Posts: 1,000
kyle0654 will become famous soon enough
Soul Blade, I'd like to be able to do the same thing...but it isn't possible. Use the save[index] variables...there's 10 of them, and they work (at least I'm sure you can set them server-side and send to client-side)
  #14  
Old 06-06-2001, 09:57 AM
T-Squad T-Squad is offline
Banned
T-Squad's Avatar
Join Date: Mar 2001
Location: United States of America
Posts: 1,733
T-Squad is on a distinguished road
thnx kyle...i was having a hard time figuring that out, i guess i can stop now....ive never heard of save[index] stuff...can you please explain?
  #15  
Old 06-06-2001, 07:43 PM
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
Wowow

Ok save[i] vars are variables used in npc of course but they can be easily called and checked by other npcs as well as they are called by npcs[i].save[i] to check values its what is used in the blue rocks on faheria D/l the beachside4 where i added the new compatible ones and look at the script it will help better than it can be explained =P
__________________

To the sun of your age, I arise
  #16  
Old 06-11-2001, 12:15 AM
Admins Admins is offline
Graal Administration
Join Date: Jan 2000
Location: Admins
Posts: 11,693
Admins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud of
Yes save[0..9] are variables good especially on
client-side where you don't have with()

Those variables are also sent to the client,
I have used them in the railtracks npcs to
tell the player what kind of railroad track the
npc is.

When changed on client-side its not sent back
to the npcserver though (because the npc is protected
against modifications by the clients)
 


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:20 PM.


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