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 08-12-2001, 08:14 AM
Bhala Bhala is offline
Disgruntled Monkey
Bhala's Avatar
Join Date: Mar 2001
Posts: 779
Bhala is on a distinguished road
Ok now why wont this work?

Why wont this work?

NPC Code:
if (playerenters) {
drawunderplayer;
dontblock;
timereverywhere;
timeout = .5;
}
if (timeout){
this.dir = random( 1, 5 );
if (this.dir=1 && !onwall(x+1,y)){y-=1;}
if (this.dir=2 && !onwall(x+.5,y+2)){y+=1;}
if (this.dir=3 && !onwall(x,y)){y-=1;}
if (this.dir=4 && !onwall(x,y)){y-=1;}
timeout = .5;
}

Reply With Quote
  #2  
Old 08-12-2001, 08:20 AM
Xaviar Xaviar is offline
Registered User
Join Date: Aug 2001
Location: Fairyland
Posts: 463
Xaviar is on a distinguished road
Send a message via ICQ to Xaviar Send a message via AIM to Xaviar
Re: Ok now why wont this work?

Quote:
Originally posted by Bhala


this.dir = random( 1, 5 );

should be

this.dir = int(random(1,5));
__________________
One by one, the penguins steal my sanity.

*cookie for Xaviar* --Originally posted by Tyhm

--Xaviar

A m e r i c a
Reply With Quote
  #3  
Old 08-12-2001, 08:23 AM
LiquidIce00 LiquidIce00 is offline
RadioActive Monkeeh
LiquidIce00's Avatar
Join Date: Apr 2001
Location: dirty south
Posts: 2,112
LiquidIce00 is on a distinguished road
Send a message via ICQ to LiquidIce00 Send a message via AIM to LiquidIce00 Send a message via Yahoo to LiquidIce00
ur onwall is messy tho
__________________
LiquidIce *Owner* (UnholyNation)
-UN Website
http://www.unholynation.com
-UN Forum
http://forums.unholynation.com
-
-the thinker
-

-
onwall2 for nonp2p (i suck at onwall)
Reply With Quote
  #4  
Old 08-12-2001, 08:28 AM
Bhala Bhala is offline
Disgruntled Monkey
Bhala's Avatar
Join Date: Mar 2001
Posts: 779
Bhala is on a distinguished road
yea I know about the onwall stuff but I know why that wasnt making it work


thx
Reply With Quote
  #5  
Old 08-12-2001, 03:24 PM
Falcor Falcor is offline
Darth Cucumber
Falcor's Avatar
Join Date: Mar 2001
Location: At School
Posts: 2,874
Falcor is on a distinguished road
Send a message via ICQ to Falcor Send a message via AIM to Falcor Send a message via MSN to Falcor Send a message via Yahoo to Falcor
dir = (dir+int(random(1,4)))%4;

Thats nice a neat =D
__________________

subliminal message: 1+1=3
Reply With Quote
  #6  
Old 08-13-2001, 08:35 AM
Jerom Jerom is offline
Banned
Jerom's Avatar
Join Date: Mar 2001
Location: In a Trash Can
Posts: 3,708
Jerom is on a distinguished road
Send a message via AIM to Jerom
Re: Ok now why wont this work?

Quote:
Originally posted by Bhala
Why wont this work?

NPC Code:
if (playerenters) {
drawunderplayer;
dontblock;
timereverywhere;
timeout = .5;
}
if (timeout){
this.dir = random( 1, 5 );
if (this.dir=1 && !onwall(x+1,y)){y-=1;}
if (this.dir=2 && !onwall(x+.5,y+2)){y+=1;}
if (this.dir=3 && !onwall(x,y)){y-=1;}
if (this.dir=4 && !onwall(x,y)){y-=1;}
timeout = .5;
}

When you do random things, doesn't it also do decimals and not just whole numbers?
Reply With Quote
  #7  
Old 08-13-2001, 09:32 AM
kyle0654 kyle0654 is offline
-. .`
kyle0654's Avatar
Join Date: Mar 2001
Posts: 1,000
kyle0654 will become famous soon enough
Re: Re: Ok now why wont this work?

Quote:
Originally posted by Jerom

When you do random things, doesn't it also do decimals and not just whole numbers?
yep.

Also, the parts where you check stuff like this.dir=3 should be this.dir==3. Quick guide to where to use == as opposed to =:

if = is found inside:
if ()
while ()
or the second part of for ()
then use ==

otherwise, use =
Reply With Quote
  #8  
Old 08-13-2001, 07:04 PM
ownerofbabylon ownerofbabylon is offline
Lord Helmut
ownerofbabylon's Avatar
Join Date: Jun 2001
Location: Gainesville FL
Posts: 1,763
ownerofbabylon is on a distinguished road
Send a message via ICQ to ownerofbabylon Send a message via AIM to ownerofbabylon
Quote:
Originally posted by Kaimetsu


And inefficient...
LOL great to have you back Kai
__________________


Warrior of Light

WWW.BABYLONSERVER.COM
Reply With Quote
  #9  
Old 08-14-2001, 03:32 AM
Jerom Jerom is offline
Banned
Jerom's Avatar
Join Date: Mar 2001
Location: In a Trash Can
Posts: 3,708
Jerom is on a distinguished road
Send a message via AIM to Jerom
Re: Re: Re: Ok now why wont this work?

Quote:
Originally posted by kyle0654

yep.

Also, the parts where you check stuff like this.dir=3 should be this.dir==3. Quick guide to where to use == as opposed to =:

if = is found inside:
if ()
while ()
or the second part of for ()
then use ==

otherwise, use =
But I remember trying to make a baddie, and it would change directions according to what ranges of a number a certain variable was in. I had used the same method before, but it didn't work in my baddie for some reason. I guess I'll have to look over it again.
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 12:42 AM.


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