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
Malorian
xXziroXx's Avatar
Join Date: May 2004
Posts: 5,289
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
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. 
__________________
Follow my work on social media post-Graal:Updated august 2025.
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
Malorian
xXziroXx's Avatar
Join Date: May 2004
Posts: 5,289
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
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!");

__________________
Follow my work on social media post-Graal:Updated august 2025.
Reply With Quote
  #16  
Old 04-11-2009, 01:23 PM
[email protected] sid.gottlieb@googlemail.com is offline
Banned
Join Date: Mar 2008
Posts: 861
sid.gottlieb@googlemail.com will become famous soon enough
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.
The GS2 way, have you read the wiki? (http://wiki.graal.net/index.php/Creation)
HTML Code:
player.say2("Stuff in here");
Reply With Quote
  #17  
Old 04-11-2009, 01:40 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
HTML Code:
player.say2("Stuff in here");
So I need player.say2? Or just say2 like Ziro posted?
__________________
*Don't let the door hit you on the way out.*
Reply With Quote
  #18  
Old 04-11-2009, 01:51 PM
Inverness Inverness is offline
Incubator
Inverness's Avatar
Join Date: Aug 2004
Location: Houston, Texas
Posts: 3,613
Inverness is a jewel in the roughInverness is a jewel in the rough
Quote:
Originally Posted by Raelyn View Post
So I need player.say2? Or just say2 like Ziro posted?
Just say2.

After looking at the wiki it doesn't show that say2 is part of the player object, it is a global function.
__________________
Reply With Quote
  #19  
Old 04-11-2009, 01:53 PM
[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 serverside too... I'm using it as we speak
HTML Code:
function onActionDisplayStats() {
  temp.i = "#i(classic_bowlingpin_2.png)";
  temp.txt = "\n         " @ i SPC "Lane" SPC this.alleynum SPC "Scores" SPC i @ "\n\n";
  
  temp.players = this.onGetList();
  for (temp.p: temp.players) {
    temp.p = findPlayer(p);
    if (p.level.name != this.level.name) continue;
    
    temp.score = this.("score_" @ p.account); 
    temp.txt @= "#i(" @ p.headimg @ ", 0, 64, 32, 32)" SPC p.nick.substring(0, 25) @ "\n";
    
    temp.c = temp.score.tokenize();
    for (temp.i: temp.c) {
      temp.ind = c.index(i);
      
      temp.txt @= " " @ i @ ",";
      if (ind == 5) temp.txt @= "\n";
    }
    temp.txt = txt.substring(0, txt.length() - 1) @ "\n";
  }
  player.say2(temp.txt);
}
Reply With Quote
  #20  
Old 04-11-2009, 02:46 PM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Indeed, I am fairly certain it can be used serverside.
__________________
Reply With Quote
  #21  
Old 04-23-2009, 11: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 #8

If I am going to be replacing the default tileset, how would I apply it online? Not really sure how to use addtiledef online.

The tiles has to be in levels\images\ also, right?
__________________
*Don't let the door hit you on the way out.*
Reply With Quote
  #22  
Old 04-23-2009, 12:21 PM
TSAdmin TSAdmin is offline
Forum Moderator
TSAdmin's Avatar
Join Date: Aug 2006
Location: Australia
Posts: 1,980
TSAdmin has much to be proud ofTSAdmin has much to be proud ofTSAdmin has much to be proud ofTSAdmin has much to be proud ofTSAdmin has much to be proud ofTSAdmin has much to be proud of
Quote:
Originally Posted by Raelyn View Post
If I am going to be replacing the default tileset, how would I apply it online? Not really sure how to use addtiledef online.

The tiles has to be in levels\images\ also, right?
If I'm not mistaken about your request, you want to make it a Weapon-NPC that adds to people as they log in. Within the Weapon-NPC, the following lines would be necessary to achieve the same output as if you were doing it offline in the Level Editor:

PHP Code:
//#CLIENTSIDE
function onCreated() {
  
removeTileDefs("");

  
addTileDef("tileImageFile.ext""prefix"type);

Yes, "tileImageFile.ext" must be in a valid image directory as defined in your Folder Options, generally in the folder you specified, or any custom sub-folder.
__________________
TSAdmin (Forum Moderator)
Welcome to the Official GraalOnline Forums! Where sharing an opinion may be seen as a declaration of war!
------------------------
· User Agreement · Code of Conduct · Forum Rules ·
· Graal Support · Administrative Contacts ·
Reply With Quote
  #23  
Old 04-23-2009, 09:50 PM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Adding a bit to what TSA said, you can also do stuff like

PHP Code:
addtiledef("tileset.png""server_"1);
addtiledef("cavetileset.png""servercave_"1); // or...
addtiledef("cavetileset.png""server_cave-"1); 
for adding custom tiles for certain levels, rather than putting it in the actual level.
__________________
Reply With Quote
  #24  
Old 04-24-2009, 12:04 AM
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 cbk1994 View Post
Adding a bit to what TSA said, you can also do stuff like

PHP Code:
addtiledef("tileset.png""server_"1);
addtiledef("cavetileset.png""servercave_"1); // or...
addtiledef("cavetileset.png""server_cave-"1); 
for adding custom tiles for certain levels, rather than putting it in the actual level.
Would I put this in a weapon and add to all players? Or would I put this in a global script, like NPC server?
__________________
*Don't let the door hit you on the way out.*
Reply With Quote
  #25  
Old 04-24-2009, 12:31 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 #9

When adding gmaps online, if I am going to be placing additional gmaps, such as a 2 level gmap to make a larger room, etc, do I have to add a loadmap function for that? Or does the server automatically detect all the new gmaps?
__________________
*Don't let the door hit you on the way out.*
Reply With Quote
  #26  
Old 04-24-2009, 12:34 AM
Tigairius Tigairius is offline
The Cat
Tigairius's Avatar
Join Date: Jan 2007
Location: Missouri, USA
Posts: 4,240
Tigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant future
You need to use gmaps= in server options. It will automatically load the gmap if it is in that list. After you add it, type "/updatelevel whatever.gmap" in RC.

If the NPC-Server has rights to the gmap, you can also use the scripting function:
PHP Code:
addgmap(str) - adds dynamicly a gmap to the options and loads it 
__________________


“Shoot for the moon. Even if you miss, you'll land among the stars.”
Reply With Quote
  #27  
Old 04-24-2009, 01:10 AM
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 Tigairius View Post
You need to use gmaps= in server options. It will automatically load the gmap if it is in that list. After you add it, type "/updatelevel whatever.gmap" in RC.

If the NPC-Server has rights to the gmap, you can also use the scripting function:
PHP Code:
addgmap(str) - adds dynamicly a gmap to the options and loads it 
Would that be:


PHP Code:
gmaps=aetherforge_main.gmap
or

PHP Code:
gmaps=aetherfoge_main
?
__________________
*Don't let the door hit you on the way out.*
Reply With Quote
  #28  
Old 04-24-2009, 01:17 AM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Quote:
Originally Posted by Raelyn View Post
Would that be:


PHP Code:
gmaps=aetherforge_main.gmap
or

PHP Code:
gmaps=aetherfoge_main
?
The second one.
__________________
Reply With Quote
  #29  
Old 04-24-2009, 01:31 AM
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 cbk1994 View Post
The second one.
Alright, thanks.
__________________
*Don't let the door hit you on the way out.*
Reply With Quote
  #30  
Old 04-24-2009, 01:55 AM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Quote:
Originally Posted by Raelyn View Post
Would I put this in a weapon and add to all players? Or would I put this in a global script, like NPC server?
[sorry, didn't see this earlier]

It has to be in a weapon that all players have; addtiledef only works clientside. TSA provided a code example that you can pretty much copy and paste in.
__________________
Reply With Quote
  #31  
Old 04-27-2009, 02:51 AM
Raelyn Raelyn is offline
the Professional.
Raelyn's Avatar
Join Date: Sep 2003
Location: Zormite
Posts: 964
Raelyn will become famous soon enough
I've been doing a lot of work offline with GS1 since I haven't had a stable internet connection for the past week, and I am trying to do something like:

PHP Code:
if (keydown(C)){
   
ShowCharPane();

And it's not working.

I have tried keydown, keydown2, and keypressed in as many ways as I could imagine, and none of them worked. The only thing I could get is (keypressed) to respond, but it responds on EVERY key and when I try to specify with #k, #K etc, it doesn't work. I even tried stuff like:

PHP Code:
if (keypressed)
   if (
strequals(#K,C)){
      
ShowCharPane();
   }

I am not really sure if there is just some strange graal wierdness going on with assigning custom keys.. It doesn't seem like it should be THIS hard...

ALSO;

I have an NPC with setshape 1,32,32; and I would like to somehow make the script read it's x,y in the CENTER of the NPC, not the top left corner, but I am not sure the easiest way how. I tried something like:

this.npcx = x+1;

and then using the new vars for the movement like:

x = this.npcx += .03;

While this SEEMS to make sense to me, it doesn't work, which is causing silly graphical errors with my onwall detection, so the mob is being blocked by the tree, it's image is being drawn on top of the tree, mmm, I could just show the image at x,y -1, but it would have to be looped in everytime, which seems like a silly thing to do since we are already moving the whole NPC too?

Very confused.
__________________
*Don't let the door hit you on the way out.*
Reply With Quote
  #32  
Old 04-27-2009, 03:19 AM
Tigairius Tigairius is offline
The Cat
Tigairius's Avatar
Join Date: Jan 2007
Location: Missouri, USA
Posts: 4,240
Tigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant future
Well, in GS1, for the keypressed thing, use :
PHP Code:
if (keypressed) {
   if (
strequals(#p(1),C)){
      
ShowCharPane();
   }

You could also do:
PHP Code:
if (keydown2(keycode(c), true)) { 
Like in a timeout or in the keypressed event.

to replicate these in gs2, do:

PHP Code:
function onKeyPressed(codekey) {
  switch (
key) {
    case 
"C":
      
ShowCharPane();
    break;
  }

or
PHP Code:
if (keydown2(getKeyCode("C"), true)) { 
As far as finding the center of the npc, you will always have to add the offset of +1 if the width/height is 32
__________________


“Shoot for the moon. Even if you miss, you'll land among the stars.”
Reply With Quote
  #33  
Old 04-27-2009, 03:38 AM
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 Tigairius View Post
Well, in GS1, for the keypressed thing, use :
PHP Code:
if (keypressed) {
   if (
strequals(#p(1),C)){
      
ShowCharPane();
   }

You could also do:
PHP Code:
if (keydown2(keycode(c), true)) { 
Like in a timeout or in the keypressed event.

to replicate these in gs2, do:

PHP Code:
function onKeyPressed(codekey) {
  switch (
key) {
    case 
"C":
      
ShowCharPane();
    break;
  }

or
PHP Code:
if (keydown2(getKeyCode("C"), true)) { 
As far as finding the center of the npc, you will always have to add the offset of +1 if the width/height is 32
Adding the offset as in showing the NPC -1? Or adding +1 to all movements and detections?
__________________
*Don't let the door hit you on the way out.*
Reply With Quote
  #34  
Old 04-27-2009, 03:39 AM
Tigairius Tigairius is offline
The Cat
Tigairius's Avatar
Join Date: Jan 2007
Location: Missouri, USA
Posts: 4,240
Tigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant future
Quote:
Originally Posted by Raelyn View Post
adding +1 to all movements and detections?
this
__________________


“Shoot for the moon. Even if you miss, you'll land among the stars.”
Reply With Quote
  #35  
Old 04-27-2009, 04:51 AM
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 Tigairius View Post
this
Thanks, and thanks also for the keypressed help, must do more testing now!
__________________
*Don't let the door hit you on the way out.*
Reply With Quote
  #36  
Old 04-29-2009, 02:17 AM
Raelyn Raelyn is offline
the Professional.
Raelyn's Avatar
Join Date: Sep 2003
Location: Zormite
Posts: 964
Raelyn will become famous soon enough
Ok, I've wrote 2 scripts while I did not have internet access, but now I have it back and I am going to try and get them to work on my server, but I wanted to post here first and get critique on the scripting itself (to better improve my noob self) and advice on the best way to upload it to work, like not sure how the various parts will be read by the server, since offline it all works in 2 weapons.

They are both still works in progress, so any pointers/changes/improvements would be appreciated!

Anyway, have a look, this first one is a basic baddy:

PHP Code:
//scripted(poorly) by Raelyn


if (created){
  
timeout .05;
  
setshape 1,32,32;
  
NpcStats();
}

if (
wa**** || waspelt){
  
NpcWa****();
  if (
this.cur_hp =< 0){
    
NpcDeath();
  }
}

if (
timeout){
  
NpcChase();
  
message #v(this.cur_hp)/#v(this.max_hp);
  
timeout .05;
}

if ((
x+1) > playerx && (x-1) < playerx && (y+1) > playery && (y-1) < playery){
  
hitplayer ,0,x,y;
}

function 
NpcDeath(){
  
clientr.cur_exp += 10;
  
message dead!;
  
destroy;
}

function 
NpcWa****(){
  
this.cur_hp -= 1;
  
message #v(this.cur_hp)/#v(this.max_hp);
  
timeout .5;
}

function 
NpcStats(){
  
this.cur_hp 5;
  
this.max_hp 5;
}


// NPC chases the player until wall
function NpcChase(){
  if (
playerx>x){
    
+= .3;
    if (
onwall(x+1,y+1)){
      
-= .3;
    }

  }
  else
    
-= .3;
  if (
onwall(x+1,y+1)){
    
x+= .3;
  }
  if (
playery>y){
    
y+= .3;
    if (
onwall(x+1,y+1)){
      
y-= .3;
    }
  }
  else
    
y-= .3;
  if (
onwall(x+1,y+1)){
    
y+= .3;
  }

And this one is the whole player system I have thus far..

PHP Code:
//scripted(poorly) by Raelyn

// index key
//
// 0411  - help interface
// 0412  - help interface
// 0001 - level up
// 0002 - exp display
// 205  - hud head
// 202  - hud background
// 200  - hud current hp
// 2001 - hud hp /
// 2002 - hud max hp
// 201  - hud current mp
// 2011 - hud mp /
// 2012 - hud max mp


// initialize the stuff
if (created){
  
SetStats();
  
UpdateGui();
  
ThisLevel();
  
removetiledefs;
  
addtiledef2 raelyn_tiles_sand.png,scripting,0,0;
  
addtiledef2 raelyn_tiles_sand-trailmark.png,scripting,0,32;
  
addtiledef2 raelyn_tiles_sand-footprint.png,scripting,0,48;
  
timeout .05;
}

if (
playerhurt){
  
clientr.cur_hp clientr.cur_hp 1;
  
UpdateGui();
}

if (
clientr.cur_hp 1){
  
message Dead!;
}

if (
keypressed){
  if (
strequals(#p(1),C)){
    
message woot;
  }
}

if (
timeout){
  
UpdateGui();
  
timeout .05;
}


// chat commands
if (playerchats){
  if (
strequals(#c,/setstats)){
    
SetStats();
  }
  if (
strequals(#c,/help)){
    
Help();
  }
  if (
strequals(#c,/updategui)){
    
UpdateGui();
  }
  if (
strequals(#c,/levelup)){
    
LevelUp();
    
UpdateGui();
  }
  if (
strequals(#c,/sethead)){
    
sethead head25.png;
    
UpdateGui();
  }

}

// stuff for this level
function ThisLevel(){
  
showimg 2022,raelyn_desert_trailmarker.png,35,24;
  
changeimgvis 2022,1;
}

// in-game help
function Help(){
  
showtext 0411,400,400,tempus sans itc,,The available commands are:;
  
changeimgvis 0411,4;
  
sleep 2;
  
showtext 0411,,,,,;
  
showtext 0412,400,400,tempus sans itc,,/help, /setstats, /updategui, /sethead, /levelup;
  
changeimgvis 0412,4;
  
sleep 2;
  
showtext 0412,,,,,;
}

// leveling up the player
function LevelUp(){
  
clientr.max_exp += clientr.max_exp 1;
  
clientr.str += clientr.str 100 *10;
  
clientr.end += clientr.end 100 *10;
  
clientr.dex += clientr.dex 100 *10;
  
clientr.int += clientr.int 100 *10;
  
clientr.max_hp clientr.end 2;
  
clientr.cur_hp clientr.max_hp;
  
clientr.max_mp clientr.int;
  
clientr.cur_mp clientr.max_mp;
  
showtext 0001,playerx,playery-2,tempus sans itc,,Level up!;
  
UpdateGui();
  
sleep 2;
  
showtext 0001,,,,,;
}

// setting up newb stats
function SetStats(){
  
clientr.cur_exp 0;
  
clientr.max_exp 10;
  
clientr.str 10;
  
clientr.end 10;
  
clientr.dex 10;
  
clientr.int 10;
  
clientr.max_hp clientr.end 2;
  
clientr.cur_hp clientr.max_hp;
  
clientr.max_mp clientr.int;
  
clientr.cur_mp clientr.max_mp;
}


// refreshing the interface
function UpdateGui(){
  
disableselectweapons;
  
disablemap;
  
showstats 1024;

  if (
clientr.cur_exp => clientr.max_exp){
    
LevelUp();

  }

  
showtext 0002,100,100,tempus sans itc,,Exp#v(clientr.cur_exp) / #v(clientr.max_exp);
  
changeimgvis 00025;

  
showimg 205,#3,12,12;
  
changeimgpart 205,0,62,32,32;
  
changeimgvis 205,6;
  
showimg 202,raelyn_hud.png,10,10;
  
changeimgpart 202,0,0,140,36;
  
changeimgvis 202,5;

  if (
clientr.cur_hp == clientr.max_hp){
    
showimg 206,raelyn_hud.png,46,12;
    
changeimgpart 206,0,36,100,16;
    
changeimgvis 206,6;
  } else {
    
showimg 206,raelyn_hud.png,46,12;
    
changeimgpart 206,0,36,(clientr.cur_hp 100) / clientr.max_hp,16;
    
changeimgvis 206,6;
  }
  
showimg 207,raelyn_hud.png,46,29;
  
changeimgpart 207,0,36,100,16;
  
changeimgvis 207,6;

  
showtext 200,50,11,tempus sans itc,,#v(int(clientr.cur_hp));
  
showtext 2001,90,11,tempus sans itc,,/;
  
showtext 2002,100,11,tempus sans itc,,#v(int(clientr.max_hp));
  
changeimgvis 200,7;
  
changeimgzoom 200,.75;
  
changeimgvis 2001,7;
  
changeimgzoom 2001,.75;
  
changeimgvis 2002,7;
  
changeimgzoom 2002,.75;

  
showtext 201,50,28,tempus sans itc,,#v(int(clientr.cur_mp));
  
showtext 2011,90,28,tempus sans itc,,/;
  
showtext 2012,100,28,tempus sans itc,,#v(int(clientr.max_mp));
  
changeimgvis 201,7;
  
changeimgzoom 201,.75;
  
changeimgvis 2011,7;
  
changeimgzoom 2011,.75;
  
changeimgvis 2012,7;
  
changeimgzoom 2012,.75;

Be gentle, please.
__________________
*Don't let the door hit you on the way out.*
Reply With Quote
  #37  
Old 04-29-2009, 02:48 AM
Novice Novice is offline
Developer
Join Date: Dec 2008
Posts: 90
Novice is an unknown quantity at this point
Send a message via MSN to Novice
Quote:
Originally Posted by Raelyn View Post
post
Why GS1? GS2 can easily be used instead.
Reply With Quote
  #38  
Old 04-29-2009, 02:55 AM
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 Novice View Post
Why GS1? GS2 can easily be used instead.
Because I don't know GS2 yet, and because I am silly?
__________________
*Don't let the door hit you on the way out.*
Reply With Quote
  #39  
Old 04-29-2009, 03:08 AM
Novice Novice is offline
Developer
Join Date: Dec 2008
Posts: 90
Novice is an unknown quantity at this point
Send a message via MSN to Novice
Quote:
Originally Posted by Raelyn View Post
Because I don't know GS2 yet, and because I am silly?
You silly goose.
Reply With Quote
  #40  
Old 04-29-2009, 03:10 AM
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 Novice View Post
You silly goose.
So what do you think of my silly scripts? :o
__________________
*Don't let the door hit you on the way out.*
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 03:23 AM.


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