| greenarrow |
12-17-2004 02:15 AM |
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?
|