Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   onwall2 is supposed to be serverside, but doesn't work so well serverside.... (https://forums.graalonline.com/forums/showthread.php?t=59549)

EmpireOwnsYou 06-21-2005 02:38 PM

onwall2 is supposed to be serverside, but doesn't work so well serverside....
 
I wrote up some temp code for when I would make the TNT for my server for mining, and well its tnt only so the code is sort of important to make sure rocks dont end up on walls... and also so people can not spam tnt and block area's in. For some reason onwall2 tells me that every single tile is on a wall, no matter where it is... Maybe I scripted it wrong, or maybe theres something wrong with the command? I was hoping someone could tell me.

NPC Code:

if (created){
this.rocks=5;
putrox();
}

function putrox(){
for (i=0;i<10;i++){
this.randx=x+int(random(-10,10));
this.randy=y+int(random(-10,10));
if (!onwall2(this.randx,this.randy,32,32)){
putnpc2 this.randx,this.randy,{join minerock};
this.rocks--;
i=0;
}
if (this.rocks<1){
destroy;
}
}
}



If your going to attempt to insult me for no reason what-so-ever, just stay out of the thread now, I only want answers to my issue, not worthless spam from kaimetsu.

CheeToS2 06-21-2005 04:00 PM

Quote:

Originally Posted by EmpireOwnsYou
I wrote up some temp code for when I would make the TNT for my server for mining, and well its tnt only so the code is sort of important to make sure rocks dont end up on walls... and also so people can not spam tnt and block area's in. For some reason onwall2 tells me that every single tile is on a wall, no matter where it is... Maybe I scripted it wrong, or maybe theres something wrong with the command? I was hoping someone could tell me.

You could do a few things to improve this. First, onwall2 is measured in tiles, not pixels, so you are measuring a 32x32 tile area for one blocking tile >_<.

The second is minor: Put a semicolon after the join command. Remember, it's like you're creating an npc with the script being whatever is inside the brackets. You're creating an npc with one command, join, and it isn't properly terminated with a semicolon.

Also, it looks like you want to just create this.rocks rocks, but the way you are doing it seems a little cumbersome. Instead, you could try something like this:

NPC Code:
while (this.rocks > 0) {
if (not onwall){
//place rock
this.rocks--;
}
}



I wouldn't try it in a level with a ton of blocking tiles though (for your way or my way).

Admins 06-21-2005 05:00 PM

You should still have some loop variable for preventing endless loops in case everything is blocking


All times are GMT +2. The time now is 06:18 PM.

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