PDA

View Full Version : How to learn GS2


Arch_Angel
10-10-2007, 09:21 PM
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
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
shoot( x, y, z, angle, zangle, power, ganis, gani 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 :


function onKeyPressed( code, char)
{

if ( char == "d") {
setShootParams( this.x, this.y);

this.pangle = getangle( vecx( player.dir), vecy( player.y));
shoot( player.x, player.y, player.z, this.pangle, 0, 0, "idle", NULL);
}
}

function onActionProjectile2( lx, ly)
{

putExplosion( 1, lx, ly);
}

Zanzel
10-11-2007, 04:51 AM
I just learned from practice ^^

xAndrewx
10-11-2007, 09:43 AM
Example :
[PHP]
function onKeyPressed() {
if (params[1] == "d") {
setShootParams(1, this.x, this.y); //[1] being the unique ID to the projectile
shoot( player.x, player.y, player.z, getangle(vecx( player.dir), vecy( player.y)), 0, 0, "idle", null); //you only used the angle once, no need for the var
}
}

function onActionProjectile2(id, hitx, hity) {
//Upon adding the ID, you can do things like
switch(temp.id) {
case 1: this.dropExplosion(2, {temp.hitx, temp.hity}); break;
case 2:
for (temp.i = 0; temp.i < 10; temp.i++) {
this.dropExplosion(2, {random(temp.hitx - 5, temp.hitx + 5, random(temp.hity - 5, temp.hity + 5});
}
break;
}
}
//Could also make it dropExplosion(explosion type, bomb type, pos) [to support the other putexplosion]
function dropExplosion(type, pos) {
putexplosion(temp.type, temp.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
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
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
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
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
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
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!)

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