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 12-06-2001, 06:44 AM
ShockwaveISTHEBEST ShockwaveISTHEBEST is offline
Registered User
Join Date: Nov 2001
Location: never never land
Posts: 208
ShockwaveISTHEBEST is on a distinguished road
Send a message via AIM to ShockwaveISTHEBEST Send a message via Yahoo to ShockwaveISTHEBEST
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
Reply With Quote
  #2  
Old 12-06-2001, 08:26 AM
Poogle Poogle is offline
Registered User
Poogle's Avatar
Join Date: Jun 2001
Posts: 2,471
Poogle is on a distinguished road
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;}
Reply With Quote
  #3  
Old 12-06-2001, 08:29 AM
BruceLee2000 BruceLee2000 is offline
TONYMONTANA
BruceLee2000's Avatar
Join Date: Mar 2001
Location: T E X A S
Posts: 1,514
BruceLee2000 will become famous soon enough
merlin:

i made a short thing when i used to play graal, lemme find it...
__________________
-T O N Y



much thanks to XDaKreepX for the sig
Reply With Quote
  #4  
Old 12-06-2001, 08:31 AM
BruceLee2000 BruceLee2000 is offline
TONYMONTANA
BruceLee2000's Avatar
Join Date: Mar 2001
Location: T E X A S
Posts: 1,514
BruceLee2000 will become famous soon enough
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.
__________________
-T O N Y



much thanks to XDaKreepX for the sig
Reply With Quote
  #5  
Old 12-06-2001, 09:39 AM
Aknts Aknts is offline
Level Designer
Aknts's Avatar
Join Date: Apr 2001
Location: USofA
Posts: 3,340
Aknts will become famous soon enough
Send a message via AIM to Aknts
...
Reply With Quote
  #6  
Old 12-06-2001, 01:00 PM
Saga2001 Saga2001 is offline
Wishing he had 3 feet
Join Date: Aug 2001
Location: Basement
Posts: 1,565
Saga2001 is on a distinguished road
Send a message via ICQ to Saga2001 Send a message via AIM to Saga2001 Send a message via Yahoo to Saga2001
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.
__________________

!Wan ( 11:27:55 AM):
can i c ur scripts please?
Zorg (RC): If I hear NPC Server call Ne0, Past Austin or Brent sexy one more time im disconnecting it
Reply With Quote
  #7  
Old 12-06-2001, 01:10 PM
Saga2001 Saga2001 is offline
Wishing he had 3 feet
Join Date: Aug 2001
Location: Basement
Posts: 1,565
Saga2001 is on a distinguished road
Send a message via ICQ to Saga2001 Send a message via AIM to Saga2001 Send a message via Yahoo to Saga2001
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.;
}

__________________

!Wan ( 11:27:55 AM):
can i c ur scripts please?
Zorg (RC): If I hear NPC Server call Ne0, Past Austin or Brent sexy one more time im disconnecting it

Last edited by Saga2001; 12-07-2001 at 12:43 AM..
Reply With Quote
  #8  
Old 12-08-2001, 10:03 AM
ShockwaveISTHEBEST ShockwaveISTHEBEST is offline
Registered User
Join Date: Nov 2001
Location: never never land
Posts: 208
ShockwaveISTHEBEST is on a distinguished road
Send a message via AIM to ShockwaveISTHEBEST Send a message via Yahoo to ShockwaveISTHEBEST
Im still lost in trigger action I got the rest down pat
Reply With Quote
  #9  
Old 12-09-2001, 03:50 AM
TDO2000 TDO2000 is offline
Registered User
TDO2000's Avatar
Join Date: Jul 2001
Location: Germany
Posts: 655
TDO2000 is on a distinguished road
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...
__________________
No Webhost at the moment
Reply With Quote
  #10  
Old 12-09-2001, 09:05 AM
ShockwaveISTHEBEST ShockwaveISTHEBEST is offline
Registered User
Join Date: Nov 2001
Location: never never land
Posts: 208
ShockwaveISTHEBEST is on a distinguished road
Send a message via AIM to ShockwaveISTHEBEST Send a message via Yahoo to ShockwaveISTHEBEST
Thanks, also where did you get that pic from you sig. Its cool.
__________________
[img]http://rick.*******ers.net/ss/users/jerrytyrrell64/Shockwave%20Sig%2003.jpg[/img]
Reply With Quote
  #11  
Old 12-09-2001, 12:03 PM
Saga2001 Saga2001 is offline
Wishing he had 3 feet
Join Date: Aug 2001
Location: Basement
Posts: 1,565
Saga2001 is on a distinguished road
Send a message via ICQ to Saga2001 Send a message via AIM to Saga2001 Send a message via Yahoo to Saga2001
very nice!
__________________

!Wan ( 11:27:55 AM):
can i c ur scripts please?
Zorg (RC): If I hear NPC Server call Ne0, Past Austin or Brent sexy one more time im disconnecting it
Reply With Quote
  #12  
Old 12-10-2001, 12:12 AM
TDO2000 TDO2000 is offline
Registered User
TDO2000's Avatar
Join Date: Jul 2001
Location: Germany
Posts: 655
TDO2000 is on a distinguished road
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 =)
__________________
No Webhost at the moment
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:14 PM.


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