Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Today's Posts

 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 12-22-2003, 05:07 AM
Termina_Owner Termina_Owner is offline
Registered User
Join Date: Oct 2003
Posts: 175
Termina_Owner is on a distinguished road
Talking Classes...

Erm... To think of it, classes are things that could be added to almost most NPCs... I've been scripting for a couple of years (6 to be exact), and well, I just wanted to show some nifty tricks to shorten scripts down (I rather an 100 line script then an 800 one)..

Weapon Key Touches:

When firing a weapon put:
setarray this.keydown,10;
for (i=0;i<10;i++)
this.keydown[i] = (i == 4) ? 1 : 0;

Then, in the timeout loop, put keys();
then, outside everything, put:

function keys(){
for (i=0;i<10;i++)
this.keydown[i] = keydown(i) ? this.keydown[i] + 1 : 0;
}

That's for recording how much time you have a key down (The i == 4 thing is to avoid D being pressed twice in the same second, and thus to close the weapon selction or whatnot, you must release and press it again).

Here's another trick...

setstring commands,heal,die,unstick me;

command = lindexof(#c,commands);
if (command == 0) playerhearts = playerfullhearts;
if (command == 1) playerhearts = 0;
if (command == 2) warpto localstartarea.nw,30,30;

Simple tricks like that reduce the ammount of lines, or at least the ammount of space taken (repeatedly using strequals(#c,...)). And it is much more reliable if you want to make some more dimensional commands along those lines...

setstring commands,buy,add,remove,withdraw,deposit;
tokenize #c;
command = lindexof(#t(0),commands);
if (command < 1){ // User Commands
so-so;
} else { // Admin Commands
so-so;
}

That would be pretty useful if you want to make some player-oriented shops, or at least something of the kind.

Well.. These are two parts that I find useful right now... I'll tell you more later (I just came back from a party)
Reply With Quote
 


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 08:04 PM.


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