
12-06-2001, 08:31 AM
|
|
TONYMONTANA
|
 |
Join Date: Mar 2001
Location: T E X A S
Posts: 1,514
|
|
|
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
|
|
|
|