Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   How to learn GS2 (https://forums.graalonline.com/forums/showthread.php?t=77116)

Arch_Angel 10-10-2007 09:21 PM

How to learn GS2
 
Hey, I came here for a little help. I've learned basically all Dev positions for Graal besides NAT. I came here in hope to find people who would be willing to find me a guide/tutorial on how to start GSCRIPT. I have the basic little Level scripts down, and can read/find things in scripts and maybe do small edits. But I need to learn what is what, and how the whole scripting concept works. So If anybody could be so kind to maybe find a guide/tutorial for me to start on that would help me get the basic knowledge to start scripting GS2. Also list some things that are good to do when trying to learn (such as what to first script, what to look at, compare scripts and edit/play (yes or no), or anything else) GS2. Any help is much appreciated! :p

Twinny 10-11-2007 12:45 AM

http://wiki.graal.net/index.php/Creation/Dev/GScript

The best source of information. Contains a few tutorials as well. You could also use http://resource.nukedstudios.com

xAndrewx 10-11-2007 12:48 AM

use the wiki for a reference. learn scripting from viewing how other people code.

the wiki with the images looks odd- looks out of place; other than that its good

Googi 10-11-2007 01:47 AM

If you have no knowledge of programming, first read a PHP tutorial (or tutorial for some other language, PHP just seems to "tutorialize" better than other languages). Then read a GS2 tutorial. The available GS2 tutorials aren't really good for people who know nothing about programming.

Admins 10-11-2007 02:01 AM

Could probably also update the old npcprogramming.doc to use GS2, it was using images and stuff.

xAndrewx 10-11-2007 02:05 AM

why not just refer to the wiki? It's all there.
If anything, post scripts on how you'd do things. [put a classic bomb on the overworld, shoot an arrow using the shoot command]
Get the people involved with fun things then move on to the boring things such as loops/arrays so that they can make pointless systems that'll never be used.

Admins 10-11-2007 02:13 AM

Hmmm will try to reorganize some stuff in the wiki, right now it's a little bit confusing to start scripting even if you already know programming. Also the function lists are not helping a lot, there should be some pages explaining the commands and also giving example scripts.

xAndrewx 10-11-2007 02:15 AM

hmm, would be good yes

Skylds wiki does that, but not much in detail. need more free lance coders to post things

Angel_Light 10-11-2007 03:48 AM

The code gallery is wonderful guys. ;]

Switch 10-11-2007 03:51 AM

Quote:

Originally Posted by xAndrewx (Post 1352224)
why not just refer to the wiki? It's all there.
If anything, post scripts on how you'd do things. [put a classic bomb on the overworld, shoot an arrow using the shoot command]
Get the people involved with fun things then move on to the boring things such as loops/arrays so that they can make pointless systems that'll never be used.

Right now the only thing I can think of that I don't know is how to use the shoot command and make projectiles do certain damage. That's all I can THINK of.

Angel_Light 10-11-2007 04:14 AM

PHP Code:

shootxyzanglezanglepowerganisgani params...); 

x,y and z - specify the starting position

angle - shoot angle (when looking from the top): east is 0,
north 3.14/2, west is 3.14, south 3.14*3/2)

zangle - the angle in vertical direction, 0 means the
projectile is shoot horizontal, 3.14/2 means straight to the
sun

power - the shoot power which is used to shoot the projectile;
if it's 0 then the projectile is shoot like an old arrow
(doesn't fall down, moves 20 tiles each second)

gani - the animation that is used for the projectile; the
animation can be multidirectional, the engine automatically
selects the best direction for the flying direction; the
animation can have 1 step (not animated) or 7 steps, then the
engine is automatically choosing the good animation step for
the projectile flying angle - when its raising then step 1 is
taken, when flying horizontal it is step 4, when it is short before
the impact then the engine displays step 7

When the projectile is landing or hitting an object then some actions
are triggered. With the command 'setshootparams <params>;' you can set
the parameters that the called scripts get, call 'setshootparams' before
shooting the projectile.

Client-side events:

* actionprojectile2:
is triggered when a projectile lands on the player/npc,
in params[0], params[1] etc. you have the parameters set with the
command setshootparams()

Server-side events:
* actionprojectile:
is triggered when a client has used the 'shoot' command to shoot a
projectile and the projectile is landed; in params[0] and params[1] you have
the x and y position of the impact in case you want to place an explosion
or similar things on the ground (the control-npc is automatically warped
to the level where the impact happened); params[2], params[3] etc. contain the
params set with 'setshootparams()' (before shooting the projectile)

* actionsprojectile:
is triggered when a server-side script has shot a projectile and the projectile
is landed; in params[0] and params[1] you have the x and y position of the impact
(the control-npc is automatically warped to the level where the impact
happened); params[2], params[3] etc. contain the params set with 'setshootparams()'
(before shooting the projectile)

Projectiles are easy to use and don't take a lot of bandwidth because only
the shooting of the projectile needs to be sent, the movement is calculated on
the different computers. The projectile is flying like a heavy object thrown
through the air: the horizontal movement speed keeps the same (moves
horzspeed=cos(zangle)*speed tiles all 0.05 seconds), the vertical speed is
initialized as vertspeed=sin(zangle)*speed and is decreased by 0.1 all 0.05 seconds;
then the new position (calculated all 0.05 seconds) is
newx = x + cos(angle)*horzspeed, newy = y - sin(angle)*horzspeed,
newz = z + vertspeed

Example :

PHP Code:

function onKeyPressedcodechar
{

  if ( 
char == "d") {
    
setShootParamsthis.xthis.y);
 
    
this.pangle getanglevecxplayer.dir), vecyplayer.y));
    
shootplayer.xplayer.yplayer.zthis.pangle00"idle"NULL);
  }
}

function 
onActionProjectile2lxly
{

  
putExplosion1lxly);



Zanzel 10-11-2007 04:51 AM

I just learned from practice ^^

xAndrewx 10-11-2007 09:43 AM

Quote:

Originally Posted by Angel_Light (Post 1352299)
[PHP]Example :
PHP Code:

function onKeyPressed() {
  if (
params[1] == "d") {
    
setShootParams(1this.xthis.y); //[1] being the unique ID to the projectile
    
shootplayer.xplayer.yplayer.zgetangle(vecxplayer.dir), vecyplayer.y)), 00"idle"null); //you only used the angle once, no need for the var
  
}
}

function 
onActionProjectile2(idhitxhity) {
  
//Upon adding the ID, you can do things like
  
switch(temp.id) {
    case 
1this.dropExplosion(2, {temp.hitxtemp.hity}); break;
    case 
2
      for (
temp.0temp.10temp.i++) {
        
this.dropExplosion(2, {random(temp.hitx 5temp.hitx 5random(temp.hity 5temp.hity 5});
      }
    break;
  }
}
  
//Could also make it dropExplosion(explosion type, bomb type, pos) [to support the other putexplosion]
function dropExplosion(typepos) {
  
putexplosion(temp.typetemp.pos[0], temp.pos[1]);



edit

Admins 10-11-2007 11:07 AM

And you can change "gravity" before shooting

zokemon 10-11-2007 12:35 PM

Quote:

Originally Posted by Stefan (Post 1352230)
Hmmm will try to reorganize some stuff in the wiki, right now it's a little bit confusing to start scripting even if you already know programming. Also the function lists are not helping a lot, there should be some pages explaining the commands and also giving example scripts.

I would be doing that but I don't really know where to start. I'll probably just start helping on documenting the 3D stuff for now since it's new and not to overwhelming.

Angel_Light 10-11-2007 01:41 PM

Quote:

Originally Posted by Stefan (Post 1352339)
And you can change "gravity" before shooting

correct. gravity = 0 means normal, gravity = -1 means objects are lighter and possess anti-gravity. gravity = 1 means objects are heavier as if they where on a bigger planet

foxboi 10-11-2007 02:11 PM

I say we make the Graal Editor GS2 enabled. *if it isn't already.

DustyPorViva 10-11-2007 02:36 PM

Quote:

Originally Posted by Angel_Light (Post 1352349)
correct. gravity = 0 means normal, gravity = -1 means objects are lighter and possess anti-gravity. gravity = 1 means objects are heavier as if they where on a bigger planet

Well I don't think you have to tell Stefan that :P
Though, actually, I believe gravity is a modifier. Which means 1=normal x 1, 0=normal x 0, and 1.5=normal x 1.5, and so on. So 0 would mean no gravity, 1 would mean default, and 2 would mean gravity is twice as strong. Not sure about this though.

zokemon 10-11-2007 03:04 PM

Quote:

Originally Posted by DustyPorViva (Post 1352353)
Well I don't think you have to tell Stefan that :P
Though, actually, I believe gravity is a modifier. Which means 1=normal x 1, 0=normal x 0, and 1.5=normal x 1.5, and so on. So 0 would mean no gravity, 1 would mean default, and 2 would mean gravity is twice as strong. Not sure about this though.

This is correct but gravity is also global meaning it effects all projectiles.

Kyranki 10-12-2007 12:40 AM

Quote:

Originally Posted by foxboi (Post 1352350)
I say we make the Graal Editor GS2 enabled. *if it isn't already.

There's no longer even a point to respond to this statement.

pooper200000 10-12-2007 02:33 AM

Hehe. You should make a tutorial so easy even the mentally challenged and stupid can remember and learn from it. Yes I am challenging you to make something so even I could learn the basics and Stan will tell you it is arduous task. ^^ Right stan? XD

BonzaiXxXSRStudios 10-12-2007 04:50 AM

I just learned the basics of scripting GS2 today. Though, ya just cant fit in with the rest of the crowd with just the basics..believe me i tried and yet i still felt foolish. =( Uhh, but if your still intrested, find twinny and check out his signature links for GS2 basics.

xXziroXx 10-12-2007 03:23 PM

I'm one of few who's completely self taught, except for a few minor things like Skyld teaching me basics of GS2 (I was late with that, used to go with 'GS1 ftw').

Arch_Angel 10-12-2007 05:28 PM

Well thank you all for some of the links you've left and some ideas to try to learn GS2. I will try my best to start picking it up. :)

xAndrewx 10-12-2007 06:41 PM

Quote:

Originally Posted by BonzaiXxXSRStudios (Post 1352487)
I just learned the basics of scripting GS2 today. Though, ya just cant fit in with the rest of the crowd with just the basics..believe me i tried and yet i still felt foolish. =( Uhh, but if your still intrested, find twinny and check out his signature links for GS2 basics.

why be bothered on how other people view you? you get better from learning. my view on scripting is that everyone on Graal that scripts won't be as equally good as Novo.

BonzaiXxXSRStudios 10-12-2007 11:12 PM

Does anyone have a link after twinny's basic tutorial i could follow? Ive recently been looking at people's recent problems in the GS2 portion of the NPC topic trying to see if i can figure it out and i cant just quite yet. (I hate to bring this back up but it would really nice if you could somehow possibly practice on editor or something. I cant get on my playerworld because of my college gaming network restrictions, unfortantely. !pissed!)

Quote:

Originally Posted by xAndrewx (Post 1352539)
why be bothered on how other people view you? you get better from learning. my view on scripting is that everyone on Graal that scripts won't be as equally good as Novo.

True, everyone has their own scripting methods so noone will really be on same level, but sometimes, i wouldnt mind being on the same level as Stefan one day.:D


All times are GMT +2. The time now is 06:48 AM.

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