Graal Forums  

Go Back   Graal Forums > Development Forums > Future Improvements
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 07-06-2002, 04:21 AM
iniquitus iniquitus is offline
Oldbie
Join Date: Dec 2001
Location: Maine
Posts: 606
iniquitus is on a distinguished road
Send a message via AIM to iniquitus
NPC Include

A way to include files into NPC's, e.g:

you have your system.txt organised into time.txt, daynight.txt, map.txt, message.txt, and music.txt, your system.txt, which would be the actual NPC would be something like:

if (created) {

toweapons -system-;

include time.txt;
include daynight.txt;
include map.txt;
include message.txt;
include music.txt;

}

If this is alredy possible, let me know, I just think it would be nice for organisational purpouses, also, a file extention for npc scripts would be good too, like .npc or maybe .gs (graal script, not to be confused with ghost script)

maybe a way to compile npc's too, .gsc (graal script compiled) and .gss (graal script source) maybe not... i dont think it's needed, unless it would add speed and reduce server load. (less lag)

what about .gss (graal server script) i like that one. sounds alot beter than "non playing charector" or whatever it is

Urizen
__________________
What am I still doing here?
Reply With Quote
  #2  
Old 07-06-2002, 10:12 AM
Python523 Python523 is offline
Banned
Join Date: Aug 2001
Location: Illinois
Posts: 3,498
Python523 is on a distinguished road
Re: NPC Include

Quote:
Originally posted by iniquitus
A way to include files into NPC's, e.g:

you have your system.txt organised into time.txt, daynight.txt, map.txt, message.txt, and music.txt, your system.txt, which would be the actual NPC would be something like:

if (created) {

toweapons -system-;

include time.txt;
include daynight.txt;
include map.txt;
include message.txt;
include music.txt;

}

If this is alredy possible, let me know, I just think it would be nice for organisational purpouses, also, a file extention for npc scripts would be good too, like .npc or maybe .gs (graal script, not to be confused with ghost script)

maybe a way to compile npc's too, .gsc (graal script compiled) and .gss (graal script source) maybe not... i dont think it's needed, unless it would add speed and reduce server load. (less lag)

what about .gss (graal server script) i like that one. sounds alot beter than "non playing charector" or whatever it is

Urizen
serverside -
join classname;
Reply With Quote
  #3  
Old 07-06-2002, 10:13 AM
Torankusu Torankusu is offline
Elite Member
Torankusu's Avatar
Join Date: Jun 2001
Posts: 10,065
Torankusu is a jewel in the roughTorankusu is a jewel in the rough
Re: Re: NPC Include

Quote:
Originally posted by Python523

serverside -
join classname;
wonderful!

__________________
Quote:
Originally posted by Spark910
Think befreo you type.

Last edited by Torankusu; 07-06-2002 at 10:58 AM..
Reply With Quote
  #4  
Old 07-06-2002, 06:51 PM
Falcor Falcor is offline
Darth Cucumber
Falcor's Avatar
Join Date: Mar 2001
Location: At School
Posts: 2,874
Falcor is on a distinguished road
Send a message via ICQ to Falcor Send a message via AIM to Falcor Send a message via MSN to Falcor Send a message via Yahoo to Falcor
Im pretty sure join works clientside too, as it works in weapons now. Also, classes arent txt files saved on the server, use RC to edit/make them
__________________

subliminal message: 1+1=3
Reply With Quote
  #5  
Old 07-06-2002, 09:29 PM
jeff335 jeff335 is offline
Registered User
Join Date: Oct 2001
Posts: 605
jeff335 is on a distinguished road
Yes, NPC isn't always the appropriate thing. I wouldn't call a bomb kit or a serverside database-holding "NPC" a character of any sort.
__________________

Quote:
Some people like standing around talking to idiots in the real world, and some don't. Neither choice is inherently better than the other.

-Kaimetsu
Reply With Quote
  #6  
Old 07-07-2002, 07:26 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
"join" is a server-side command. Part of the scripting docu that I am working on :

Script classes

On the npcserver (server-side scripting) you can use the script classes system to organize code better and reuse code easily. The classes are saved in separate text files, e.g. class 'gralats' is saved in scripts/gralats.txt.

To join a class you must add the statement 'join <classname>;' to your script. That command works similar to the C/C++ command 'include', but is dynamic. It attaches the class script to the script of the npc, when executed it is handled like on big script. So you can put often used functions in class files and then all npcs that need the functions join the class.

Script class example:
An npc joins the class 'messagedisplays':
NPC Code:

if (created) {
setstring this.message,hello!;
}
join messagedisplays;


The class script 'messagedisplays' displays a message:
NPC Code:

if (playerenters) {
message #s(this.message);
}


That will result in a new virtual script for the npc:
NPC Code:

if (created) {
setstring this.message,hello!;
}
if (playerenters) {
message #s(this.message);
}



You can also join classes from inside classes, the scripting engine automatically prevents recursive joining. One important thing to know is that local variables (i,j, etc.) are only valid for the current script, so when you want to pass parameters to functions in joined classes by assigning values to temporary variables then you must use this.variables because normal variables cannot be accessed from the function.

When script classes contain functions then you can overwrite them in the npc script, the scripting engine chooses the right function script at runtime. The function implementation that is found first will be used. an example for this:
An npc joins the class 'messagedisplays':
NPC Code:

if (created) {
displaymessage();
}
function displaymessage() {
message Hello!;
}
join messagedisplays;


The class script displays 'Hi!':
NPC Code:

function displaymessage() {
message Hi!;
}


The resulting virtual script of the npc:
NPC Code:

if (created) {
displaymessage();
}
function displaymessage() {
message Hello!;
}
function displaymessage() {
message Hi!;
}


The npc will display 'Hello!' because the function displaymessage() of the npc is appearing before the displaymessage() of the joined class.

The script of classes is only kept one time in the memory, all npcs joining the class only hold pointers to the script class. That means using script classes is saving resources and makes it easy to update the script because whenever the script of the class is changed then automatically all npcs that have joined the class will use the new script.

With the remotecontrol.exe administrators with 'npccontrol' right have access to the class scripts. In the class script window you see the currently classes loaded in the npcserver. To 'add' a new class you must first add an npc using the class, removing a class file from the list is currently not supported (only disappears after restarting the npcserver).
Reply With Quote
  #7  
Old 07-07-2002, 08:02 AM
Dark-Dragoon Dark-Dragoon is offline
Registered User
Dark-Dragoon's Avatar
Join Date: May 2002
Posts: 886
Dark-Dragoon is on a distinguished road
When stefan explains stuff like that it makes me feel very stupid...
__________________
R.I.P. 1999-2004 Graalian Year
The World Renown Nobody, Guy.
Reply With Quote
  #8  
Old 07-07-2002, 08:17 AM
Python523 Python523 is offline
Banned
Join Date: Aug 2001
Location: Illinois
Posts: 3,498
Python523 is on a distinguished road
Quote:
Originally posted by Dark-Dragoon
When stefan explains stuff like that it makes me feel very stupid...
you should've heard him explaining how encryption (#E) worked on delteria, everyone but me and one other nat didnt understand a word
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 01:42 AM.


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