Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Christmas Present for all of Graal! (https://forums.graalonline.com/forums/showthread.php?t=49900)

ForgottenLegacy 12-25-2003 05:17 AM

Christmas Present for all of Graal!
 
1 Attachment(s)
:D
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];
}


tlf288 12-25-2003 05:36 AM

thats pretty cool. thank you and nice job.

Dach 12-25-2003 06:00 AM

I wish Graal would paste correctly...

DarkShadows_Legend 12-25-2003 06:45 AM

You used to use the name TBD right? If so then you have improved a lot.
Nice script :)

ForgottenLegacy 12-25-2003 07:45 AM

Quote:

Originally posted by DarkShadows_Legend
You used to use the name TBD right? If so then you have improved a lot.
Nice script :)


Yes, The Black Death, TBD, Sir Kohiri, and The Gothic Child are all me. I used the acconts Codeboy, sirkohiri, and my current one is ForgottenLegacy.

Besides, I have scripts that are better than that, but I only let certain servers have them. I don't want all of Graal to use what took me months to make... :whatever:

Riot 12-27-2003 04:44 AM

Quote:

Originally posted by Dach
I wish Graal would paste correctly...
Paste into notepad first then copy again and it should work fine.

Kigan 12-27-2003 05:03 AM

Nice work, good to see people actually putting script examples online that are more elaborate than making something disipear when touched :D

ForgottenLegacy 12-28-2003 10:32 PM

Thanks, it took me a week or two to figure out ways to fix all the bugs that that script had. Just please give me credit if you choose to use it on your server!

D1ce2 12-28-2003 10:35 PM

I don't like have same scripts/gfx on the same server, shows lazyness from the people who have taken it x.x

adam 12-29-2003 01:57 AM

TBD?
Haha, nice to see you.

Blue_Dragn 12-29-2003 02:06 AM

Isnt the name "lights out" Copywritten by the company that made the real game? I know this is not a big thing but Graphics people go ballistic when a copywritten style head is uploaded.

ForgottenLegacy 12-29-2003 06:43 AM

Quote:

Originally posted by adam
TBD?
Haha, nice to see you.

Nice to see you too.


All times are GMT +2. The time now is 11:41 PM.

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