Graal Forums  

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

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 12-25-2003, 05:17 AM
ForgottenLegacy ForgottenLegacy is offline
-Backtoscripts-
Join Date: Aug 2003
Location: California
Posts: 289
ForgottenLegacy is on a distinguished road
Send a message via AIM to ForgottenLegacy
Talking 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];
}

Attached Images
 
__________________
"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
Reply With Quote
  #2  
Old 12-25-2003, 05:36 AM
tlf288 tlf288 is offline
Registered User
tlf288's Avatar
Join Date: Nov 2001
Location: new account: Trevor
Posts: 0
tlf288 is on a distinguished road
Send a message via AIM to tlf288 Send a message via Yahoo to tlf288
thats pretty cool. thank you and nice job.
__________________
new account: Trevor
Reply With Quote
  #3  
Old 12-25-2003, 06:00 AM
Dach Dach is offline
call me Chad, it's cooler
Dach's Avatar
Join Date: Aug 2002
Posts: 1,899
Dach is on a distinguished road
I wish Graal would paste correctly...
__________________
Scripting Documents:Old Script Documentation-Movement Tutorial
Reply With Quote
  #4  
Old 12-25-2003, 06:45 AM
DarkShadows_Legend DarkShadows_Legend is offline
Cult of the Winky
DarkShadows_Legend's Avatar
Join Date: Apr 2003
Location: Florida
Posts: 614
DarkShadows_Legend is on a distinguished road
Send a message via AIM to DarkShadows_Legend
You used to use the name TBD right? If so then you have improved a lot.
Nice script
__________________
- Criminal X

"I rather be hated for being myself, than be liked for being what you like best. I go above the influence, not under." - Me
Reply With Quote
  #5  
Old 12-25-2003, 07:45 AM
ForgottenLegacy ForgottenLegacy is offline
-Backtoscripts-
Join Date: Aug 2003
Location: California
Posts: 289
ForgottenLegacy is on a distinguished road
Send a message via AIM to ForgottenLegacy
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...
__________________
"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
Reply With Quote
  #6  
Old 12-27-2003, 04:44 AM
Riot Riot is offline
Delteria Management
Join Date: Nov 2003
Location: Seminole County, Florida
Posts: 280
Riot is on a distinguished road
Quote:
Originally posted by Dach
I wish Graal would paste correctly...
Paste into notepad first then copy again and it should work fine.
Reply With Quote
  #7  
Old 12-27-2003, 05:03 AM
Kigan Kigan is offline
Banned
Join Date: Dec 2003
Posts: 92
Kigan is on a distinguished road
Nice work, good to see people actually putting script examples online that are more elaborate than making something disipear when touched
Reply With Quote
  #8  
Old 12-28-2003, 10:32 PM
ForgottenLegacy ForgottenLegacy is offline
-Backtoscripts-
Join Date: Aug 2003
Location: California
Posts: 289
ForgottenLegacy is on a distinguished road
Send a message via AIM to ForgottenLegacy
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!
__________________
"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
Reply With Quote
  #9  
Old 12-28-2003, 10:35 PM
D1ce2 D1ce2 is offline
Registered User
Join Date: Dec 2003
Location: United Kingdom
Posts: 446
D1ce2 is on a distinguished road
Send a message via AIM to D1ce2 Send a message via Yahoo to D1ce2
I don't like have same scripts/gfx on the same server, shows lazyness from the people who have taken it x.x
__________________

The time is coming
Reply With Quote
  #10  
Old 12-29-2003, 01:57 AM
adam adam is offline
http://wiki.graal.us/
adam's Avatar
Join Date: Nov 2001
Posts: 2,247
adam has a spectacular aura aboutadam has a spectacular aura about
Send a message via AIM to adam
TBD?
Haha, nice to see you.
__________________
Rogue Shadow (TCN)(NAT)(Global Development Team)

For development help, contact the patrons of the #graaldt irc channel below, I am usually there.
Click Here to Join IRC Chat Now! -- irc.freenode.net Channel: #graaldt
Quote:
<Dustyshouri> no, RogueShadow is always talking about scripts lol
<Dustyshouri> in fact, he pretty much brought Graal back as a topic single-handedly
Reply With Quote
  #11  
Old 12-29-2003, 02:06 AM
Blue_Dragn Blue_Dragn is offline
Registered User
Join Date: Jul 2003
Posts: 302
Blue_Dragn is on a distinguished road
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.
__________________
No longer a Advertisement Goat
Reply With Quote
  #12  
Old 12-29-2003, 06:43 AM
ForgottenLegacy ForgottenLegacy is offline
-Backtoscripts-
Join Date: Aug 2003
Location: California
Posts: 289
ForgottenLegacy is on a distinguished road
Send a message via AIM to ForgottenLegacy
Quote:
Originally posted by adam
TBD?
Haha, nice to see you.
Nice to see you too.
__________________
"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
Reply With Quote
Reply


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 01:29 AM.


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