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-11-2009, 10:18 AM
Raelyn Raelyn is offline
the Professional.
Raelyn's Avatar
Join Date: Sep 2003
Location: Zormite
Posts: 964
Raelyn will become famous soon enough
Raelyn's Big Book of Scripting Questions.

Ok, because I am a newbie to GS2 scripting (and was never that good at GS1 either admittedly) and am genuinely trying to learn it, I know I am going to have a million questions, and I am already seeing myself making alot of threads, so rather than do that, I am going to compile all my questions into this thread, which should also make for a neat little resource for other new scripters. (I hope.)

Thank you all who have answered my questions so far, and thanks in advance to anyone else who does. I'm really glad to have a community of knowledgeable people to turn to.

Ok, just for the purpose of converging all my questions here, for my own reference if for no other reason, I am going to add the questions and answers that I already asked!
__________________
*Don't let the door hit you on the way out.*
Reply With Quote
  #2  
Old 04-11-2009, 10:18 AM
Raelyn Raelyn is offline
the Professional.
Raelyn's Avatar
Join Date: Sep 2003
Location: Zormite
Posts: 964
Raelyn will become famous soon enough
Question #1

Question #1:
"Ok, I have a weapon NPC on the server that has alot of chat commands etc, but currently I have to add it to people for them to have it, what is the easiest method to have the NPC server check and add it to anyone who doesn't have it when they log on?"

Answer #1:
Quote:
Originally Posted by Tigairius View Post
-Click on your NPCs button (the button on the far left of your NPC-Control).
-Right click Control-NPC and edit the script.
-If the script is blank, add this:
PHP Code:
function onActionPlayerOnline() {
  
player.addWeapon("weapon name");

-If the script is not blank, just add player.addWeapon("weapon name"); in your actionplayeronline function.
__________________
*Don't let the door hit you on the way out.*

Last edited by Raelyn; 04-11-2009 at 12:48 PM.. Reason: Neatness.
Reply With Quote
  #3  
Old 04-11-2009, 10:22 AM
Raelyn Raelyn is offline
the Professional.
Raelyn's Avatar
Join Date: Sep 2003
Location: Zormite
Posts: 964
Raelyn will become famous soon enough
Question #2

Question #2:
What is the GS2 equivalent of the lay and lay2 commands?

Answer #2:
Quote:
Originally Posted by Tigairius View Post
"lay", "lay2", and "shoot" commands are all deprecated commands that were only left for compatibility and are not actually recommended to use.

An example of laying a green rupee could be replicated (depending on your 'gralats' class) with something as simple as:
PHP Code:
with (putnpc2(xy"join gralats;")) {
  
this.type 1// 0 = green, 1 = blue, 2 = red, 3 = gold

Other commands, like shootarrow() can be replicated using a shoot() command.

PHP Code:
//#CLIENTSIDE
function onWeaponFired() {
  
// TServerLevel.shoot(x,y,z,angle,zangle,strength,ani,aniparams)
  
shoot(player.1.5 vecx(player.dir), player.vecy(player.dir), player.zgetangle(vecx(player.dir), vecy(player.dir)), NULLNULL"arrow"NULL);

You would have to make a gani called 'arrow' with an arrow facing all four directions, of course. It's my recommendation that you don't use any of those older commands, and re-script most of that kind of stuff.
__________________
*Don't let the door hit you on the way out.*

Last edited by Raelyn; 04-11-2009 at 12:49 PM.. Reason: Neatness
Reply With Quote
  #4  
Old 04-11-2009, 10:25 AM
Raelyn Raelyn is offline
the Professional.
Raelyn's Avatar
Join Date: Sep 2003
Location: Zormite
Posts: 964
Raelyn will become famous soon enough
Question #3

Question #3:
I have a script for setani in GS1, how would I setani in GS2?

Answer #3:
Quote:
Originally Posted by Tigairius View Post
Simple animation changes are:
PHP Code:
setCharAni("idle"NULL); // This will set the NPC's ani to idle, replace "NULL" with an additional PARAM1 if necessary.

setAni("idle"NULL); // This will set the player's ani to idle, replace "NULL" with an additional PARAM1 if necessary.

replaceAni("walk""newwalk"); // Replaces 'walk' with 'newwalk'. 
The top two commands for ganis work both clientside and serverside.
__________________
*Don't let the door hit you on the way out.*

Last edited by Raelyn; 04-11-2009 at 12:49 PM.. Reason: Neatness
Reply With Quote
  #5  
Old 04-11-2009, 10:29 AM
Raelyn Raelyn is offline
the Professional.
Raelyn's Avatar
Join Date: Sep 2003
Location: Zormite
Posts: 964
Raelyn will become famous soon enough
Question #4

Question #4:
Where can I get the commands.rtf for GS2? I only have the GS1 commands...

Answer #4:
Quote:
Originally Posted by Stefan View Post
commands.rtf -> ./Graal.exe -listscriptfunctions

The /scripthelp command shows all functions and built-in variables, although there are some which don't have a description yet. Also the events are not displayed right now although they have been added to -listscriptfunctions in the recent months.

Update: added description of server-side object events to /scripthelp to the next npcserver release.
__________________
*Don't let the door hit you on the way out.*

Last edited by Raelyn; 04-11-2009 at 12:50 PM.. Reason: Neatness
Reply With Quote
  #6  
Old 04-11-2009, 10:33 AM
Raelyn Raelyn is offline
the Professional.
Raelyn's Avatar
Join Date: Sep 2003
Location: Zormite
Posts: 964
Raelyn will become famous soon enough
Question #5

Question #5:
I have seen on my friend's server some of his weapons have '-' in front of them such as '-System' and '-Admin'. What is the significance of the '-' in front of the weapon name, if any?

Answer #5:
Quote:
Originally Posted by Schetti
the answer to your 5# question:
- weapons arent in inventory

-System/Summon, isnt in your inventory, its an invisible weapon.
EVERY weapo starts iht and - doesnt shine up in your inventory, thats the use if it
__________________
*Don't let the door hit you on the way out.*

Last edited by Raelyn; 04-11-2009 at 10:55 AM.. Reason: Answered.
Reply With Quote
  #7  
Old 04-11-2009, 10:50 AM
[email protected] sid.gottlieb@googlemail.com is offline
Banned
Join Date: Mar 2008
Posts: 861
sid.gottlieb@googlemail.com will become famous soon enough
It's better to organize, however if you're using the default Graal inventory, adding the '-' in front of the weapon name won't show that weapon in the inventory.
Reply With Quote
  #8  
Old 04-11-2009, 12:46 PM
Raelyn Raelyn is offline
the Professional.
Raelyn's Avatar
Join Date: Sep 2003
Location: Zormite
Posts: 964
Raelyn will become famous soon enough
Question #6

Question #6

Schetti suggested naming for instance staff boots as '-System/Boots' however when I tried this, the RC produced an error.

Quote:
Raelyn prob: No write rights for WEAPONS/-System/Boots
I made a seperate weapon called '-StaffBoots' which worked fine. What causes this?

Answer #6
Quote:
Originally Posted by xXziroXx View Post
The / token is considered as a separator of sorts, and you have to add rights to whatever is behind it.


PHP Code:
rw WEAPONS/*
rw WEAPONS/*/
*
rw WEAPONS/*/*/*         <---- Doubt you'll need to go this far. 
__________________
*Don't let the door hit you on the way out.*

Last edited by Raelyn; 04-11-2009 at 01:02 PM.. Reason: Neatness
Reply With Quote
  #9  
Old 04-11-2009, 12:46 PM
Raelyn Raelyn is offline
the Professional.
Raelyn's Avatar
Join Date: Sep 2003
Location: Zormite
Posts: 964
Raelyn will become famous soon enough
Quote:
Originally Posted by [email protected] View Post
It's better to organize, however if you're using the default Graal inventory, adding the '-' in front of the weapon name won't show that weapon in the inventory.
Thanks.
__________________
*Don't let the door hit you on the way out.*
Reply With Quote
  #10  
Old 04-11-2009, 12:49 PM
Crow Crow is offline
ǝɔɐɹq ʎןɹnɔ
Crow's Avatar
Join Date: Dec 2006
Location: Germany
Posts: 5,153
Crow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond repute
Quote:
Originally Posted by Raelyn View Post
Question #6

Schetti suggested naming for instance staff boots as '-System/Boots' however when I tried this, the RC produced an error.



I made a seperate weapon called '-StaffBoots' which worked fine. What causes this?
I suppose you only have "rw WEAPONS/*" in your folder rights. Slashs are counted as a new folder, which means you also need to give "rw WEAPONS/*/*".
__________________
Reply With Quote
  #11  
Old 04-11-2009, 12:51 PM
Raelyn Raelyn is offline
the Professional.
Raelyn's Avatar
Join Date: Sep 2003
Location: Zormite
Posts: 964
Raelyn will become famous soon enough
Quote:
Originally Posted by Crow View Post
I suppose you only have "rw WEAPONS/*" in your folder rights. Slashs are counted as a new folder, which means you also need to give "rw WEAPONS/*/*".

Uh, seems to me like if you have access to a folder, you would have access to all sub-folders by default, no?
__________________
*Don't let the door hit you on the way out.*
Reply With Quote
  #12  
Old 04-11-2009, 12:57 PM
xXziroXx xXziroXx is offline
Master of Puppets
xXziroXx's Avatar
Join Date: May 2004
Location: Sweden
Posts: 5,288
xXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant future
Send a message via AIM to xXziroXx Send a message via MSN to xXziroXx
Quote:
Originally Posted by Raelyn View Post
Uh, seems to me like if you have access to a folder, you would have access to all sub-folders by default, no?
The / token is considered as a separator of sorts, and you have to add rights to whatever is behind it.


PHP Code:
rw WEAPONS/*
rw WEAPONS/*/
*
rw WEAPONS/*/*/*         <---- Doubt you'll need to go this far. 
__________________

"A delayed game is eventually good, but a rushed game is forever bad." - Shigeru Miyamoto
Reply With Quote
  #13  
Old 04-11-2009, 12:58 PM
Raelyn Raelyn is offline
the Professional.
Raelyn's Avatar
Join Date: Sep 2003
Location: Zormite
Posts: 964
Raelyn will become famous soon enough
Question #7
I have several NPCs with the following script.

PHP Code:
if (created) {
  
setshape 1,32,16;
}

if (
playertouchsme){
  
say2 Says_stuff_here;

What is the GS2 equivalent for the say2 command? And is there something wrong about the functionality of this script (bad formatting aside)? Because I have 4 of them on the gmap, and two work, and two don't. All identical, the only difference is the sign text.
__________________
*Don't let the door hit you on the way out.*
Reply With Quote
  #14  
Old 04-11-2009, 01:01 PM
Raelyn Raelyn is offline
the Professional.
Raelyn's Avatar
Join Date: Sep 2003
Location: Zormite
Posts: 964
Raelyn will become famous soon enough
Quote:
Originally Posted by xXziroXx View Post
The / token is considered as a separator of sorts, and you have to add rights to whatever is behind it.


PHP Code:
rw WEAPONS/*
rw WEAPONS/*/
*
rw WEAPONS/*/*/*         <---- Doubt you'll need to go this far. 
Roger that, thanks Ziro.
__________________
*Don't let the door hit you on the way out.*
Reply With Quote
  #15  
Old 04-11-2009, 01:23 PM
xXziroXx xXziroXx is offline
Master of Puppets
xXziroXx's Avatar
Join Date: May 2004
Location: Sweden
Posts: 5,288
xXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant future
Send a message via AIM to xXziroXx Send a message via MSN to xXziroXx
Quote:
Originally Posted by Raelyn View Post
Question #7
I have several NPCs with the following script.

PHP Code:
if (created) {
  
setshape 1,32,16;
}

if (
playertouchsme){
  
say2 Says_stuff_here;

What is the GS2 equivalent for the say2 command? And is there something wrong about the functionality of this script (bad formatting aside)? Because I have 4 of them on the gmap, and two work, and two don't. All identical, the only difference is the sign text.
say2 is a clientsided command, and thus can't be used on serverside.

PHP Code:
//#CLIENTSIDE
function onPlayerTouchsMe()
{
  
say2("Insert your fancy stuff here!");

__________________

"A delayed game is eventually good, but a rushed game is forever bad." - Shigeru Miyamoto
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:00 PM.


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