PDA

View Full Version : Some help with weather system


coreys
01-26-2008, 11:08 PM
Well, I released the code to my weather system just a little while ago, but I need to change the way it works. I'm changing it to use classes for the weather effects, but for some reason it doesn't do anything.

Here's the class:

//#CLIENTSIDE
function onCreated() {
with (findImg(201)) {
// Emitter attributes
layer = 2;
x = player.x; y = player.y;
emitter.delaymin = 0.1;
emitter.delaymax = 0.3;
emitter.nrofparticles = 5;
emitter.emissionoffset = {-12, -15, 50};
emitter.checkbelowterrain = true;

// Basic particle attributes
emitter.particle.lifetime = 20;
emitter.particle.zoom = 2;
emitter.particle.image = "abjorn_particle_rain.gif";
emitter.particle.rotation = -degtorad(10);

// Movement
emitter.particle.zangle = -1;
emitter.particle.speed = 15;
emitter.particle.alpha = 1;
emitter.particle.mode = 0;

emitter.addglobalmodifier("impulse", 0.2, 0.2, "zangle", "multiply", 0.95, 0.95);
emitter.addlocalmodifier("impulse", 0, 20, "zoom", "add", -1.5, .2);
emitter.addlocalmodifier("once", 0, 0, "angle", "replace", degtorad(260), degtorad(230));
emitter.addlocalmodifier("once", 0, 0, "x", "add", -64, 64);
emitter.addlocalmodifier("once", 0, 0, "y", "add", -10, 0);
emitter.addlocalmodifier("once", 0, 0, "zoom", "replace", 0.6, 1.2);
emitter.addlocalmodifier("range", 0, 10, "speed", "add", 1, 3);
emitter.addglobalmodifier("range", 0.1, 25, "angle", "add", -degtorad(45), degtorad(45));
}
this.timer = 0;
this.lifetime = 0;
setTimer(0.1);
}
function onTimeOut() {
temp.i = findImg(201);
temp.i.x = player.x; temp.i.y = player.y;
if (this.timer < .5)
this.timer += .1;
else {
if (this.lifetime < 800) {
if (temp.i.emitter.nrofparticles < 150)
temp.i.emitter.nrofparticles++;
this.timer = 0;
}
}
if (this.lifetime < 800)
this.lifetime += .1;
else {
if (temp.i.emitter.nrofparticles > 0)
temp.i.emitter.nrofparticles--;
}
hideimg(202);
if (temp.i.emitter.nrofparticles > 75) {
temp.chance = int(random(0, 500));
if (temp.chance > 495) {
showpoly(202, {0,0,screenwidth,0,screenwidth,screenheight,0,scre enheight});
changeimgvis(202,4);
changeimgcolors(202,1,1,1,.1);
}
}
setTimer(0.1);
}
If I do something like set the players chat in the timeout loop or in onCreated() that will work, but nothing else seems to, I can't figure it out.