Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   Future Improvements (https://forums.graalonline.com/forums/forumdisplay.php?f=10)
-   -   NPC Include (https://forums.graalonline.com/forums/showthread.php?t=32990)

iniquitus 07-06-2002 04:21 AM

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 :)

Python523 07-06-2002 10:12 AM

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;

Torankusu 07-06-2002 10:13 AM

Re: Re: NPC Include
 
Quote:

Originally posted by Python523

serverside -
join classname;

wonderful!

;)

Falcor 07-06-2002 06:51 PM

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

jeff335 07-06-2002 09:29 PM

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.

Admins 07-07-2002 07:26 AM

"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).

Dark-Dragoon 07-07-2002 08:02 AM

When stefan explains stuff like that it makes me feel very stupid...

Python523 07-07-2002 08:17 AM

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


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

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