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 06-21-2005, 02:38 PM
EmpireOwnsYou EmpireOwnsYou is offline
Banned
Join Date: Mar 2005
Posts: 12
EmpireOwnsYou is on a distinguished road
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.
Reply With Quote
  #2  
Old 06-21-2005, 04:00 PM
CheeToS2 CheeToS2 is offline
That Guy
CheeToS2's Avatar
Join Date: Dec 2001
Location: Seattle, WA
Posts: 2,528
CheeToS2 will become famous soon enough
Send a message via AIM to CheeToS2
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).

Last edited by CheeToS2; 06-21-2005 at 04:11 PM..
Reply With Quote
  #3  
Old 06-21-2005, 05:00 PM
Admins Admins is offline
Graal Administration
Join Date: Jan 2000
Location: Admins
Posts: 11,693
Admins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud of
You should still have some loop variable for preventing endless loops in case everything is blocking
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 10:32 PM.


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