|
-Backtoscripts-
|
Join Date: Aug 2003
Location: California
Posts: 289
|
|
Christmas Present for all of Graal!
Here's one of my best scripts, you can use it on any server you want, just be sure to give me some credit, either in a comment inside the weapon script or a sign near the NPC. This is a Lights Out! type game, and it is very fun. Took me a good while to write the script and arrays, but it is a good script. Please do not change the style. Also, feel free to add more levels, you just need to change a few numbers. Scrounge around and you will be able to figour out how the game works.
NPC Code:
// NPC made by TGC aka Sertoh KaIren
//#CLIENTSIDE
if (playertouchsme) {
disabledefmovement;
playersprite=0;
this.mode=1;
this.level=1;
init();
this.defloc={(screenwidth/2)-(16*3),(screenheight/2)-(16*3)};
timeout=.05;
}
if (timeout) {
if (this.mode==1) {
freezeplayer .15;
showtext 200,this.defloc[0],this.defloc[1],,c,Welcome to Lights Out!;
showtext 201,this.defloc[0],this.defloc[1]+16,,c,Press S to play;
showtext 202,this.defloc[0],this.defloc[1]+32,,c,Press A to quit;
changeimgvis 200,5;
changeimgvis 201,5;
changeimgvis 202,5;
if (keydown(5)) this.mode=2;
if (keydown(6)) this.mode=0;
} else if (this.mode==2) {
showtext 250,this.defloc[0]-23,this.defloc[1],,ur,Press D to learn how to play;
showtext 251,this.defloc[0]-23,this.defloc[1]+16,,ur,Press S to restart this level;
showtext 252,this.defloc[0]-23,this.defloc[1]+32,,ur,Press A to quit playing;
showtext 253,this.defloc[0]+106,this.defloc[1],,,Level: #v(this.level);
showtext 254,this.defloc[0]+106,this.defloc[1]+16,,,Clicks: #v(this.numclicks);
for (a=250;a<260;a++) {
changeimgvis a,6;
changeimgzoom a,.9;
}
showpoly 261,{
this.defloc[0]-22.5,this.defloc[1]-22.5,
this.defloc[0]+105.5,this.defloc[1]-22.5,
this.defloc[0]+105.5,this.defloc[1]+105.5,
this.defloc[0]-22.5,this.defloc[1]+105.5;
};
changeimgvis 261,4;
changeimgcolors 261,0,0,0,1;
if (keydown(4)) say2 How to play!
#b#b#bThe object of the game is to
#bturn off every light on the
#bdisplay. Once you click on a
#blight, it will either turn on
#b(if it was off), or turn off
#b(if it was on).
#bThe light above, below, left, and
#bright of the light you clicked
#bwill also change.
#bSee if you can beat all 15 levels!;
if (keydown(5)) init();
if (keydown(6)) this.mode=0;
freezeplayer .15;
findindex();
showimgs();
checkwinner();
} else if (this.mode==0) {
hideimgs 200,299;
enabledefmovement;
}
timeout=.05;
}
if (mousedown) {
if (this.mode==2) {
freezeplayer .15;
findindex();
if (leftmousebutton) {
if (mousescreenx in |this.defloc[0],this.defloc[0]+(6*16)|) {
if (mousescreeny in |this.defloc[1],this.defloc[1]+(6*16)|) {
this.numclicks++;
this.lvl[this.index[0]+0]=(this.lvl[this.index[0]+0]+1)%2;
if (aindexof(this.index[0],this.limit1)>=0) this.lvl[this.index[0]+1]=(this.lvl[this.index[0]+1]+1)%2;
if (aindexof(this.index[0],this.limit2)>=0) this.lvl[this.index[0]-1]=(this.lvl[this.index[0]-1]+1)%2;
if (this.index[0]<20) this.lvl[this.index[0]+5]=(this.lvl[this.index[0]+5]+1)%2;
if (this.index[0]>4) this.lvl[this.index[0]-5]=(this.lvl[this.index[0]-5]+1)%2;
}
}
}
showimgs();
checkwinner();
if (this.winner==true) {
if (this.level<=15) {
say2 You won!#bYou are now on level #v(this.level+1) of 15!;
this.level++;
hideimgs 200,249;
init();
} else {
say2 You beat the game!;
enabledefmovement;
this.mode=0;
}
}
}
}
function init() {
this.numclicks=0;
if (this.level==1)
this.lvl={0,0,0,0,0,0,0,1,0,0,0,1,1,1,0,0,0,1,0,0, 0,0,0,0,0};
if (this.level==2)
this.lvl={1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,0, 1,0,1,0,1};
if (this.level==3)
this.lvl={1,0,0,0,1,0,1,1,1,0,0,1,1,1,0,0,1,1,1,0, 1,0,0,0,1};
if (this.level==4)
this.lvl={1,0,1,0,1,0,0,1,0,0,1,1,0,1,1,0,0,1,0,0, 1,0,1,0,1};
if (this.level==5)
this.lvl={1,1,1,1,1,1,1,0,1,1,1,0,1,0,1,1,1,0,1,1, 1,1,1,1,1};
if (this.level==6)
this.lvl={0,1,1,1,0,1,0,0,0,1,1,0,1,0,1,1,0,0,0,1, 0,1,1,1,0};
if (this.level==7)
this.lvl={1,0,1,0,1,0,0,0,0,0,1,0,1,0,1,0,0,0,0,0, 1,0,1,0,1};
if (this.level==8)
this.lvl={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0, 0,0,0,0,0};
if (this.level==9)
this.lvl={0,1,1,1,1,0,1,0,0,0,0,1,1,1,0,0,1,0,0,0, 0,1,0,0,0};
if (this.level==10)
this.lvl={1,0,0,0,1,1,1,0,0,1,1,0,0,0,1,1,0,1,0,1, 0,1,0,0,1};
if (this.level==11)
this.lvl={0,0,0,0,0,0,1,0,0,1,0,0,0,1,0,0,0,1,0,0, 0,0,0,1,0};
if (this.level==12)
this.lvl={0,1,0,1,0,0,1,0,0,0,1,0,1,0,1,1,0,0,1,1, 1,0,0,0,1};
if (this.level==13)
this.lvl={0,0,0,1,1,1,1,1,0,0,0,0,0,0,0,0,1,0,0,0, 1,1,1,1,1};
if (this.level==14)
this.lvl={0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,1,0, 0,0,0,0,0};
if (this.level==15)
this.lvl={0,0,1,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0,1,0, 1,1,0,1,1};
setarray this.index,2;
this.limit1 = {
0, 1, 2, 3,
5, 6, 7, 8,
10,11,12,13,
15,16,17,18,
20,21,22,23
};
this.limit2 = {
1, 2, 3, 4,
6, 7, 8, 9,
11,12,13,14,
16,17,18,19,
21,22,23,24
};
}
function checkwinner() {
this.winner=false;
if (aindexof(1,this.lvl)<0) this.winner=true;
}
function showimgs() {
this.index[1]=-1;
for (a=0;a<5;a++) {
for (b=0;b<5;b++) {
this.index[1]++;
showimg this.index[1]+200,tgc_lightbulb.gif,this.defloc[0]+(b*16),this.defloc[1]+(a*16);
changeimgpart this.index[1]+200,16*this.lvl[this.index[1]],0,16,16;
changeimgvis this.index[1]+200,5;
}
}
}
function findindex() {
this.loc = {
abs(int((mousescreenx-this.defloc[0])/16)),
abs(int((mousescreeny-this.defloc[1])/16))
};
this.index[0]=this.loc[1]*5+this.loc[0];
}
|
__________________
"The higher you fly, the harder it is to breathe."
[Kaidenn] Maybe I will somehow take control of Lance's body when he isn't looking, have him log onto Kingdoms, update one script, and leave.
[Kaidenn] And leave him exactly where I found him, unchanged and completely unnaware of what just took place the last two minutes.
[GrowlZ] Lance: You might want to lock your bedroom door tonight
|
|