Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   A few script commands I need help with. (https://forums.graalonline.com/forums/showthread.php?t=18389)

ShockwaveISTHEBEST 12-06-2001 06:44 AM

A few script commands I need help with.
 
Could you possibly give me some sample scripts or just one for each that are fairly short and easy to understand for using in one of them Strequals, in another Tokenize,in another Tokenize2,and last but not definatly not least could I have a lot of help on Trigger Actions, cause I find if very hard to understand.

Thanks for everything

Poogle 12-06-2001 08:26 AM

Re: A few script commands I need help with.
 
Quote:

Originally posted by ShockwaveISTHEBEST
Could you possibly give me some sample scripts or just one for each that are fairly short and easy to understand for using in one of them Strequals, in another Tokenize,in another Tokenize2,and last but not definatly not least could I have a lot of help on Trigger Actions, cause I find if very hard to understand.

Thanks for everything

if (strequals(#c, Kill me)) {hurt 11111111;}

BruceLee2000 12-06-2001 08:29 AM

merlin:

i made a short thing when i used to play graal, lemme find it...

BruceLee2000 12-06-2001 08:31 AM

here...


//Basic
Well theres two main if (action)'s which when you open the npc edit window
they are already there, those are,
if (playerenters) {
and
if (playertouchsme) {
now, those two commands are very important to most scripts, so knowing
that much lets move on.
/Adding an response to an action
Well, the basic layout for action/response would be
if (action) {response;}
Now, let's replace the action with a real action,
if (playertouchsme) {
now we got that far, let's replace the response with a real response
if (playertouchsme) {hide; //hides the npc
sleep1; //the npc sleeps for one second
show; //the npc shows again
} //ends the reponse
Now, after the if (action) we have a { to start the response and a }
to end the response, and a ";" at the end of each part of the response
eg:/ if (playertouchsme) {actions here;}
eg:/ hide;
Great, now we got the basics down lets move on to a little more advanced
scripting.
//NPCWs (none playable charcter weapons)
NPCWs we've all used them at one point be it bomb or GP boots,
NPCWs are all of those things you see when you press the "D" button.
//Making NPCws
NPCws are fairly simple, the structure of the npcw itself is ususualy
two commands
-toweapons
-weaponfired
now to incorperate that into what we know it would be something like this
if (playertouchsme) {toweapons Test NPC;} //adds the weapons "Test NPC to your weapons list
if (weaponfired) {say2 Weapontest;} //here is where you add the actions for what will happen if you fire them weapon aka press the "D" button.
That's the basic layout of an NPCW which can ofcourse be altered with more
advanced commands.
//Timeouts
Timeouts are a very key part in NPC scripting, they are often used
to loop commands, for example
if (playerenters) {timeout=.5;} //that tells the npc that it waits .5 seconds
if (timeout) {lay2 goldrupee,playerx+1,playery; //that would be the command that would happen after a timeout and if another timeout is added after it will loop (see below)
timeout=.5;} //adding another timeout so it stays looped and constantly does the if (timeout) action
//Functions
functions are a slightly more advanced type of scripting to keep things from having to be written out more then once
for example
if (playerenters) test(); //tells the npc that when a player enters it performs the function "test"

function test() {playerx=30; //tells the npc what the function for test() is.
playery=30;}

//Strings
Strings are a very important part of scripting needed for a lot of things.
an example of a string would be
if (washit) {setstring server.igothit,#v(strtofloat(#s(server.igothit))+1 );}
which is basicly keeping track of how many times you got hit, that string
adds +1 to the string server.igothit, you can also use local strings
like client.igothit instead.
So that string in the flags box would look like server.igothit=#oftimesyougothit.
To display a string that would be changing you would make an npc like this
if (playerenters) {timeout=.5;} //starting of the loop (see timeout)
if (timeout) {message I was hit #s(server.iwashit) times;} //the #s is saying that it will display the string and the (server.iwashit) is telling it which string to display
so you would see something like I was hit 3 times.

Aknts 12-06-2001 09:39 AM

...

Saga2001 12-06-2001 01:00 PM

ok...
 
NPC Code:

// assume the player says "you are a carrot, *flinch*"
if (playerchats) {
tokenize #c;
/*
this cuts up the line "you are a carrot, *flinch*" into a new string at every space and comma. so it is:
#t(0) = you
#t(1) = are
#t(2) = a
#t(3) = carrot
#t(4) = *flinch*
meaning no only does it break at every space and comma it also cuts them.
*/

// Now strequals()
if (strequals(Owner,#a)&&strequals(#a,Owner)) {
/*
since it is making sure the two strings equal each other the two strings are interchangible.
*/
if (strequals(#t(0),you)&&strequals(#t(1),are)&&streq uals(#t(2),a)&&strequals(#t(3),carrot)) {
showimg 201,@Yesh i am,20,120;
changeimgvis 201,4;
}
}
}



hope this helped, e-mail me: [email protected] if u have ne further questions.

Saga2001 12-06-2001 01:10 PM

Triggeraction
 
NPC Code:

/*
i am pretty new to triggeraction.

the syntax is:
triggeraction x,y,actionname,params;
description:
x - duh
y - duh
action - the actual name of the action to be triggered.
params - this is an open syntax i guess u could call it cause what you can do it say:
triggeraction x,y,action,#a,#c,#e(0,-1,#L);
see you can send lots of params, unless using npc server to transfer server actions than all you need to do it
triggeraction 0,0,action,;
cause all parameters are most likely accessable by the npc, however if using npc server than with the first triggeraction example:
#p(0) = #a;
#p(1) = #c;
#p(2) = #e(0,-1,#L);
which can be accessed by the database npc or the NPCW and that way you can get the data you need. we'll pretend you are not using npc server.
*/
if (playerchats&&strequals(triggeraction,#c)) {
triggeraction playerx+1.5,playery+2,Graalet,;
/*
This triggers the action Graalet at playerx+1.5 & playery+2. You add 1.5 & 2 because you are triggering an action on the npc, since this item is a weapon, then we want to trigger the action, where the npcw actually is. So just remember 1.5 & 2.
*/
}
if (actionGraalet) {
lay2 goldrupee,playerx+.75,playery+3;
/*
Notice, that Graalet has a capital G actons are CASE-SENENSITIVE! rememeber that. The action will be triggered and a gold graalet will be dropped. There you go.
*/
}
if (playertouchsme) {
toweapons Graalet Drop;
say2
Say "triggeraction" to#bdrop a gold graalet.;
}


ShockwaveISTHEBEST 12-08-2001 10:03 AM

Im still lost in trigger action I got the rest down pat

TDO2000 12-09-2001 03:50 AM

hmmm triggeractions okeeee

1. we start with a short description
Triggeraction is used to use code in another Players weapon or an NPC when it's at the position u trigger at... it's normally easier to use then callnpc or callweapon and pretty nice for interactions between players

2. example:
the player has a weapon with following code in it:
if(actionspin){
freezeplayer 1;
setani spin,;
}

there is an NPC in the level with following ode in it:
if(playerenters){
triggeraction playerx+1.5,playery+2,spin,;
}

what it does:
when the player enters the level and he has a weapon with the first code in it, the player will do a spin move

how?:
oke when the player enters there is a triggeration with the name "spin" on the playerx and playery (there are 1.5 and 2 added because this will be the middle of the player and the triggeraction will work better)
there are no parameters with it thats why there is nothing behind the last ,
so if the weapon gets an action with the name
spin (there is alwas the word action before the command so gscript knows that is something it has to do when there is an triggeraction) the player will do this spin-move

now another example like the copnet on NM

there is a weapon for 2 players both must have these weapon if the script should work

the script:
if(playertouchsme){
toweapons Net;
}
//The part while using the weapon
if(weaponfired){
setani jaxe,;
triggeraction playerx+1.5+vecx(playerdir)*2,playery+2+vecy(playe rdir)*2,catch,;
}

//if u are catched
if(actioncatch){
setani dead,;
freezeplayer 3;
}


so what it does:
when u fire the weapon it will set the players ani to jaxe then trigger in front of the player (at this place u don't need to know how to use vecx and vecy here u just have to know that the x and y of the triggeraction are in front of the player).
The triggername is catch...
if there is another player in front of the one using the net-weapon his weapon will get the name of the triggeraction so he is "triggered"... so the part
if(actioncatch){
setani dead,;
freezeplayer 3;
}
will be run...
his ani is set to dead and he can't move for 3 seconds....

now something like the hat-giving-NPC

both players have a weapon like this:
the first player wears a hat with the name "hat1.png"
codepart:
if(playertouchsme){
toweapons Gievhat;
}
//Giving the hat
if(weaponfired){
setani jaxe,;
triggeraction playerx+1.5+vecx(playerdir)*2,playery+2+vecy(playe rdir)*2,givehat,#P(1);
}

//Getting the hat
if(actiongivehat){
setplayerprop #P(1),#p(0);
}

what happens:
if the first player wears a hat and uses the weapon in front of another player this other player will wear the hat too.

how?:
when the player fires his hatgiving weapon it will trigger in front of this player with the with the name "givehat" and the parameter #P(1) (Hat of the player)

if there is another player in front of the player using the weapon he is triggered with the triggeractionname givehat
then the code in if(actiongivehat){ runs.
and the player gets the hat...
setplayerprop #P(1),#p(0);

so how to use parameters
if u trigger a player u can giveout paramters with the triggeraction:
triggeraction playerx+1.5+vecx(playerdir)*2,playery+2+vecy(playe rdir)*2,givehat,#P(1);

here it is #P(1) thats the hat of the player

these action can be read with
#p(number)

for the first paramter the number is 0 for the 2. one its 1 for the 3. its 2 etc.

so u can give many things to the triggered player...
for example:

if(playertouchsme){
toweapons Gievhat;
}
//Giving the hat
if(weaponfired){
setani jaxe,;
triggeraction playerx+1.5+vecx(playerdir)*2,playery+2+vecy(playe rdir)*2,givehat,#P(1),#n;
}

//Getting the hat
if(actiongivehat){
setplayerprop #P(1),#p(0);
setplayerprop #c,Thanx for the hat #p(1);
}

here the triggered player will get the hat of the first player then he will say
Thanx for the hat <here the nickname of the hat giver>

so triggeraction is usefull for interactions...
I hope this helped...

ShockwaveISTHEBEST 12-09-2001 09:05 AM

Thanks, also where did you get that pic from you sig. Its cool.

Saga2001 12-09-2001 12:03 PM

very nice! :D

TDO2000 12-10-2001 12:12 AM

Quote:

Originally posted by ShockwaveISTHEBEST
Thanks, also where did you get that pic from you sig. Its cool.
The Person is a charakter from Ragna*rok (why is this word censored doesn't Stefan like concurence? ;D) the background was made by a friend... I just put them together =)


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

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