Graal Forums  

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

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 12-17-2004, 02:15 AM
greenarrow greenarrow is offline
Registered User
Join Date: Oct 2004
Posts: 6
greenarrow is on a distinguished road
Need help with tile editor npc...

Since nobody else will help me I decided to consult the NPC Scripting board, please help me with this script...

NPC Code:

// NPC made by Samurai X
if (created) {
}
if (playerenters) {
hide;
}
if (compusdied) {
show;
}
if (playertouchsme) {
toweapons Terrain Alterator;
say2 Use this to save yourself!;
}
if(weaponfired && !this.on == 1){
initialise();
timeout = 0.1;
}

if(timeout){
freezeplayer 1;
setani idle,;
if(keydown(1) && (this.tileX - this.tileIncrease) >= 0) this.tileX -= this.tileIncrease;
else if(keydown(3) && (this.tileX + this.tileIncrease) <= (2048-this.setX)) this.tileX += this.tileIncrease;
else if(keydown(0) && (this.tileY - this.tileIncrease) >= 0) this.tileY -= this.tileIncrease;
else if(keydown(2) && (this.tileY + this.tileIncrease) <= (512-this.setY)) this.tileY += this.tileIncrease;
showtiles();
// setplayerprop #c,#v(this.getx),#v(this.gety)|#v(this.putx),#v(th is.puty);
timeout = 0.1;
}

if(leftmousebutton && this.on == 1){
if(mousescreenx in |this.screenx,this.screenx+this.setX|
&& mousescreeny in |this.screeny,this.screeny+this.setY|){
this.getx = int( int(mousescreenx) / 16) + int(this.tileX / this.tileIncrease);
this.gety = int( int(mousescreeny) / 16) + int(this.tileY / this.tileIncrease);
}else {

this.placex = int(mousex);
this.placey = int(mousey);

this.putx = int(this.getx % 16);
this.puty = (32 * int(this.getx / 16)) + this.gety;

this.newtile = this.putx + this.puty * 16;

tiles[this.placex,this.placey] = this.newtile;
updateboard this.placex,this.placey,16,16;

a = aindexof(this.placex,this.chBoard);
b = aindexof(this.placey,this.chBoard);
if(!b == a + 1){
this.change += 2;
setarray this.chBoard,this.change;
this.chBoard[this.change-2] = this.placex;
this.chBoard[this.change-1] = this.placey;
}

}
}

if(playerchats && strequals(#c,/reset)){
// reset board to original tiles
for(p = 0; p < arraylen(this.chBoard); p += 2{
tiles[this.chBoard[p],this.chBoard[p+1]] = this.boardOrigin[this.chBoard[p]+this.chBoard[p+1]*64];
updateboard this.chBoard[p],this.chBoard[p+1],16,16;
}
setarray this.chBoard,0;
}


// --FUNCTIONS--

function initialise(){ // main
this.on = 1;
setarray this.boardOrigin,64 * 64; // old board vars
for(iy = 0; iy < 64; iy ++)
for(ix = 0; ix < 64; ix ++)
this.boardOrigin[ix+iy*64] = tiles[ix,iy]; // for resetting
this.blockWidth = 8; // the amount of tiles to show from left to right
this.blockHeight = 10; // the amount of tiles to show from top to bottom
this.tileIncrease = 16; // increase by 16 pixels
this.screenx = 1;
this.screeny = 1;
}

function showtiles(){
this.setX = this.blockWidth * this.tileIncrease;
this.setY = this.blockHeight * this.tileIncrease;
showimg 200,pics1.png,this.screenx,this.screeny;
changeimgpart 200,this.tileX,this.tileY,this.setX,this.setY;
changeimgvis 200,10;
}



I need to know, once I fire the weapon I can edit tiles and everything but I cant figure out how to turn it off and go back to playing, can you people read the script and tell me how, or add to the script to make it work and tell me how to work it?

Last edited by Loriel; 12-17-2004 at 09:20 PM..
Reply With Quote
  #2  
Old 12-17-2004, 02:34 AM
Slash-P2P Slash-P2P is offline
Banned
Join Date: May 2004
Location: Burning Blade
Posts: 941
Slash-P2P is on a distinguished road
Quote:
Originally Posted by greenarrow
Since nobody else will help me I decided to consult the NPC Scripting board, please help me with this script...
I need to know, once I fire the weapon I can edit tiles and everything but I cant figure out how to turn it off and go back to playing, can you people read the script and tell me how, or add to the script to make it work and tell me how to work it?
As of now, it looks like theres no way to turn it off besides reconnecting. Also, you shouldn't post full scripts.
Reply With Quote
  #3  
Old 12-17-2004, 02:41 AM
Kaimetsu Kaimetsu is offline
Script Monkey
Kaimetsu's Avatar
Join Date: May 2001
Posts: 18,222
Kaimetsu will become famous soon enough
Quote:
Originally Posted by Slash-P2P
Also, you shouldn't post full scripts.
You're right, but possibly for the wrong reasons. There is a certain degree of confusion over some of the rules, you see. Posting complete scripts is only forbidden when they are being given as prepackaged solutions to a person's problem. The forum exists with the objective of helping scripters to help themselves, after all.

However, 'greenarrow' did make an error of judgement, in that he posted the whole thing instead of isolating the part that was giving him problems. It could be that this is what you were talking about, but I wanted to cover both possibilities just in case.
__________________
Reply With Quote
  #4  
Old 12-17-2004, 02:51 AM
zokemon zokemon is offline
That one guy...
zokemon's Avatar
Join Date: Mar 2001
Location: Sonoma County, California
Posts: 2,925
zokemon is a jewel in the roughzokemon is a jewel in the rough
Send a message via ICQ to zokemon Send a message via AIM to zokemon Send a message via MSN to zokemon Send a message via Yahoo to zokemon
Use code or php tags.
__________________
Do it with a DON!
Reply With Quote
  #5  
Old 12-17-2004, 03:03 AM
greenarrow greenarrow is offline
Registered User
Join Date: Oct 2004
Posts: 6
greenarrow is on a distinguished road
uh

Now can you 3 try ANSWERING the question?
Reply With Quote
  #6  
Old 12-17-2004, 03:09 AM
Kaimetsu Kaimetsu is offline
Script Monkey
Kaimetsu's Avatar
Join Date: May 2001
Posts: 18,222
Kaimetsu will become famous soon enough
Personally, I ain't gonna help you until you conform to KSI-GS and put the script in a legible, non-bloated form.
__________________
Reply With Quote
  #7  
Old 12-17-2004, 03:16 AM
greenarrow greenarrow is offline
Registered User
Join Date: Oct 2004
Posts: 6
greenarrow is on a distinguished road
omg

Omg, how can I tell you what part of the code is bothering me IF I DONT KNOW WHICH PART IS THE PROBLEM, i dont know what button to press to turn the npc off, all i asked is for someone to tell me which button does it
Reply With Quote
  #8  
Old 12-17-2004, 03:21 AM
Kaimetsu Kaimetsu is offline
Script Monkey
Kaimetsu's Avatar
Join Date: May 2001
Posts: 18,222
Kaimetsu will become famous soon enough
So you didn't even write this code? You're just asking us how it works? Why don't you ask the author?
__________________
Reply With Quote
  #9  
Old 12-17-2004, 04:55 AM
Lance Lance is offline
dark overlord
Lance's Avatar
Join Date: Sep 2003
Location: Space Jam Mountain
Posts: 5,072
Lance is on a distinguished road
The code does not seem to provide a method to turn it off.

That said, the code is horrible, by the way, and its author would do well to read KSI-GS.
Reply With Quote
  #10  
Old 12-17-2004, 06:20 AM
Slash-P2P Slash-P2P is offline
Banned
Join Date: May 2004
Location: Burning Blade
Posts: 941
Slash-P2P is on a distinguished road
NPC Code:
if(weaponfired && !this.on == 1){
initialise();
timeout = 0.1;
}


That is the on/off function, but its only scripted to go on.
You can use an algorithim for making a 1 and 0 toggle for the this.on variable with something such as:
this.on = abs(this.on-1);
Plug that in there. Make sure initialise() only happens if this.on is '1'. If this.on is '0', make an end function such as end() that unsets everything that happening (one thing in that function could be hideimg 200)
Reply With Quote
  #11  
Old 12-17-2004, 07:14 AM
Lance Lance is offline
dark overlord
Lance's Avatar
Join Date: Sep 2003
Location: Space Jam Mountain
Posts: 5,072
Lance is on a distinguished road
Quote:
Originally Posted by Slash-P2P
NPC Code:
this.on = abs(this.on-1);

That's unnecessarily complicated - try this:

NPC Code:
this.on = 1 - this.on;

Reply With Quote
  #12  
Old 12-17-2004, 01:45 PM
Skyld Skyld is offline
Script-fu
Skyld's Avatar
Join Date: Jan 2002
Location: United Kingdom
Posts: 3,914
Skyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud of
Send a message via AIM to Skyld
NPC Code:
if (created) {
}


Eep.
__________________
Skyld
Reply With Quote
  #13  
Old 12-17-2004, 03:11 PM
calum calum is offline
Registered User
Join Date: Nov 2003
Location: Scotland
Posts: 182
calum is on a distinguished road
After looking at your script I want to vomit profusely! Ever heard of KSI-GS?
__________________
Reply With Quote
  #14  
Old 12-17-2004, 08:56 PM
zokemon zokemon is offline
That one guy...
zokemon's Avatar
Join Date: Mar 2001
Location: Sonoma County, California
Posts: 2,925
zokemon is a jewel in the roughzokemon is a jewel in the rough
Send a message via ICQ to zokemon Send a message via AIM to zokemon Send a message via MSN to zokemon Send a message via Yahoo to zokemon
Quote:
Originally Posted by Skyld
NPC Code:
if (created) {
}


Eep.
The whole script is an "Eep."
__________________
Do it with a DON!
Reply With Quote
  #15  
Old 12-17-2004, 11:07 PM
protagonist protagonist is offline
Banned
protagonist's Avatar
Join Date: May 2003
Location: CAW
Posts: 5,586
protagonist is on a distinguished road
Send a message via AIM to protagonist Send a message via MSN to protagonist
The code, gents, is like me. I don't turn off.
Reply With Quote
  #16  
Old 12-22-2004, 12:03 AM
Gman4pwnu Gman4pwnu is offline
Banned
Join Date: Jan 2004
Posts: 434
Gman4pwnu is on a distinguished road
Send a message via AIM to Gman4pwnu
I made one if anyone wants it pm me, ill see if i can find it.
Reply With Quote
  #17  
Old 12-28-2004, 05:03 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
I made that earlier this year and posted it on graal.net. I don't use the name Samurai X, either. Only Criminal X and PrinceDark.
http://graal.net/snippet/detail.php?type=snippet&id=25

I am very messy too when scripting, sorry.

Oh yeah, stealing scripts and putting your name on it is .... bad.
__________________
- 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
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 05:57 AM.


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