|
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) |