Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Rain (https://forums.graalonline.com/forums/showthread.php?t=5864)

SkooL 06-26-2001 03:17 PM

Rain
 
I am trying to script rain. Here is what I used for one drop:
NPC Code:
if (created) {
setbackpal dusk7.png;
putnpc rainimage.gif,rain.txt,this.x = (random(0,64)),this.y = (random(0,64));
timeout=0.05;
}
if (timeout) {
putnpc rainimage.gif,rain.txt,this.x = (random(0,64)),this.y = (random(0,64));
timeout=0.05;
}



In rain.txt I have:
NPC Code:
if (created) {
sleep 0.05;
destroy;
}



I paste the NPC a couple times and the NPC is always on the coordinate (1,1). How can I fix this?

entravial 06-26-2001 04:06 PM

NO NO NO NO!!!!!


if (created) {
setbackpal dusk7.png;
timeout=0.05;
}
if (timeout) {
this.x = (random(0,64));
this.y = (random(0,64));
putnpc rainimage.gif,rain.txt,this.x,this.y;
timeout=0.05;
}

SkooL 06-26-2001 04:21 PM

Ok, it works, but lags to hell. Does anyone have a different way of doing it?

grim_squeaker_x 06-26-2001 04:59 PM

Hmm...
NPC Code:
if (created) {
this.maxdrops=30;
setarray this.rainloc,this.maxdrops*2;
setarray this.rainstep,this.maxdrops;
setarray this.raintime,this.maxdrops;
for (this.i=0;this.i<this.maxdrops;this.i++) this.raintime=random(0,2);
}
if (playerenters||timeout) {
if (IsRaining) {
setbackpal dusk7.png;
for (this.i=0;this.i<this.maxdrops;this.i++) {
if (this.rainstep[this.i]==4) {
this.raintime[this.i]=random(0,2);
this.rainstep[this.i]=0;
}
if (this.raintime[this.i]<=0) {
if (this.rainstep[this.i]==0) {
this.rainloc[this.i*2]=random(0,64);
this.rainloc[this.i*2+1]=random(0,64);
this.rainstep[this.i]=1;
}
showimg this.i,splash#v(this.rainstep).gif,this.rainloc[this.i*2],this.rainloc[this.i*2+1];
changeimgvis this.i,0;
this.rainstop[this.i++];
}
else this.raintime[this.i]-=0.05;
}
}
timeout=0.05;
timereverywhere;
}

And now I want both of you to swear never to use putnpc again, thanks.

SkooL 06-26-2001 05:21 PM

Thanks, but it doesn't work =\
I set the flag IsRaining and went into the level, the backpal sets, but there isn't any rain =\

entravial 06-26-2001 06:53 PM

*AlphaFlame*
Hrmm... I just usually use something like this for rain... (it's 8 a.m., I've been up for 15+ hours, I'll give a better script later :P, so shuddup :P)

if (israin){
timeout=.05;
this.dripy=(how many drops you want at any 1 time);
}
if (timeout){
for (this.i=0;this.i<this.dripy;this.i++) {
showimg this.i,(the rain gif),random(0,64),random(0,64);
}
if (this.i=this.dripy) this.i=0;
}



grim_squeaker_x 06-26-2001 07:13 PM

Quote:

Originally posted by SkooL
Thanks, but it doesn't work =\
I set the flag IsRaining and went into the level, the backpal sets, but there isn't any rain =\

I probably made a mistake, that often happens when I post scripts which I haven't tested and just typed in here.

grim_squeaker_x 06-27-2001 02:31 PM

Quote:

Originally posted by Kaimetsu
Must... use... indexes>200...
I know, this was in the case of it being an NPC in the level.

Marco2002 06-27-2001 02:54 PM

perhaps he just doesn't have the images splash1-x.gif

entravial 06-27-2001 02:59 PM

no i told him how to make it random and he put it in the wrong place

grim_squeaker_x 06-27-2001 06:09 PM

Quote:

Originally posted by Kaimetsu


Still... >200... and timereverywhere.

And I forgot to mention that it was because I didn't script it in Graal, I always make such stupid mistakes when I do that.


All times are GMT +2. The time now is 07:25 AM.

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