Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Some Optimization for You All... (https://forums.graalonline.com/forums/showthread.php?t=25506)

Saga2001 03-12-2002 07:28 AM

Some Optimization for You All...
 
Talk about optimization:
This is a beginning. ;)
NPC Code:

// I could really care less if anyone uses this, because it will be 2 player in about a week.
if (created || initialized) {
disabledefmovement;
this.vars = {1,1,int(random(0,360)),32,32,this.vars[3]-5,this.vars[4]-5,this.vars[3]-10,this.vars[4]-10,this.vars[5],this.vars[6],.75,.5,this.vars[3],this.vars[6],0};
setarray this.keys,11;
timeout=.05;
}
if (timeout) {
for (i=0;i<11;i++;) this.keys[i] = (keydown(i) ? 1 : 0);
this.ix = (cos(this.vars[2]/57.3)*this.vars[11])-(cos(this.vars[2]/57.3));
this.iy = (sin(this.vars[2]/57.3)*this.vars[11])-(sin(this.vars[2]/57.3));
this.vars = {(this.vars[9]>=this.vars[3]&&this.vars[10] in |this.vars[14]-.75,this.vars[14]+.25| ? 0 : (this.vars[9]<=this.vars[7] ? 1 : this.vars[0])),(this.vars[10]>=this.vars[4] ? 0 : (this.vars[10]<=this.vars[8] ? 1 : this.vars[1])),this.vars[2],this.vars[3],this.vars[4],this.vars[5],this.vars[6],this.vars[7],this.vars[8],this.vars[9]+(this.vars[0]==1 ? abs(this.ix) : -abs(this.ix)),this.vars[10]+(this.vars[1]==1 ? abs(this.iy) : -abs(this.iy)),this.vars[11],this.vars[12],this.vars[13],this.vars[14]+(this.keys[2]==1&&this.vars[14]<this.vars[4] ? this.vars[12] : (this.keys[0]==1&&this.vars[14]>this.vars[8] ? -this.vars[12] : 0)),(this.vars[9]>this.vars[3]+.25&&!(this.vars[10] in |this.vars[14]-.75,this.vars[14]+.25|) ? 1 : 0),this.vars[16]+(this.vars[9]>=this.vars[3]&&this.vars[10] in |this.vars[14]-.75,this.vars[14]+.25| ? 1 : 0)};
if (this.vars[15]==1) say2 You Lost!;
showimg 1,@.,this.vars[9],this.vars[10];
showimg 2,@|,this.vars[13],this.vars[14]; changeimgzoom 2,.5;
showimg 3,@#v(this.vars[16]),25,100; changeimgvis 3,4; changeimgzoom 3,.5;
timeout=(this.vars[15]==0 ? .05 : 0);
}


Aknts 03-12-2002 08:24 AM

??????

Goboom 03-12-2002 08:45 AM

it freezes sometimes...:-\

Aknts 03-12-2002 08:49 AM

I don't get it...As soon as I play the level it says you lose

Saga2001 03-12-2002 09:01 AM

Quote:

Originally posted by Aknts
I don't get it...As soon as I play the level it says you lose
yeah set the player x and y to 32, probably should have mentioned that. Its the placement of the script...sorry...lol

Goboom 03-12-2002 09:07 AM

ya you got to move quick

Saga2001 03-13-2002 12:41 AM

Quote:

Originally posted by Kaimetsu
Small code size doesn't necessarily mean good code. Bear that in mind.
True, however this is not only small code, but optimization, and it works well. I don't know weather you like it at all, but in my opinion its pretty good, and thats just the start. ;). I was actually posting to get some thoughts on it...any opinions?

Spanko 03-13-2002 01:39 AM

Evil, evil, where are the line breaks? AAHHHH!

Faheria_GP2 03-13-2002 07:20 AM

writing cryptic code makes you look smarter :p

BARGAD 03-13-2002 07:33 AM

Quote:

Originally posted by Faheria_GP2
writing cryptic code makes you look smarter :p
Specially to newbies like me who have no idea what this script does, and no clue what most of the commands does neither :)

Maths and such makes me confused O.o!

Goboom 03-13-2002 08:24 AM

Quote:

Originally posted by Faheria_GP2
writing cryptic code makes you look smarter :p
your funny:p

haunter 03-13-2002 09:30 AM

0.o
 
... I don't get it, it doesn't do anything...

Saga2001 03-14-2002 01:22 PM

Well, you live you learn, right. I know in this version, it has no line bvreaks, but the one i have here has line breaks all over, the point is I want it to be cryptic. Its point was to have fun to see how short I could get it and make it still work, it really does improve your scripting ability.


All times are GMT +2. The time now is 12:17 PM.

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