|
Registered User
|
 |
Join Date: Apr 2006
Posts: 755
|
|
I tried simplifying it to see if I could get it to work. I changed it to use this.currentWeather instead of serverr.weather, so I could easily change the weather with the number keys.
I also put hideimg(255) on top of every weather function to make sure the emitters don't inherit attributes from each other, and I removed deprecated lines like
if (serverr.weather != "wind") hideimgs(255, 256);
Seems to work for me except for the lightning.
PHP Code:
//#CLIENTSIDE
function onCreated()
{
setTimer(0.05);
}
function onKeyPressed(keyCode, keyChar, scanCode)
{
switch (keyChar) {
case "1": this.currentWeather = "rain"; break;
case "2": this.currentWeather = "wind"; break;
case "3": this.currentWeather = "fog"; break;
case "4": this.currentWeather = "storm"; break;
case "5": this.currentWeather = "calm"; break;
}
echo("Changed weather to " @ this.currentWeather);
}
function Rain() {
hideimg(255);
with (findimg(255)) {
alpha = 0;
layer = 5;
//play("rain.wav");
this.shootAngle2 = pi * 1.5;
emitter.checkbelowterrain = true;
this.shootAngle = this.shootAngle2 + this.angle;
emitter.autorotation = false;
emitter.attachposition = false; // If the image's x and y move, would the entire emitter, every single particle at once, move along with the image? If true, every sprite moves when the image movies. If false, then only the point of origin, where the particles are created, move when the image is moved.
emitter.delaymin = 0; // This is the minimum delay between emissions.
emitter.delaymax = 0; // This is the maximum delay between emissions, both of these are in seconds.
emitter.emissionoffset = {0, -40, 0}; // In format of "{float, float, float}", it's the offset from the x, y, and z that an emission will show. It's the delta variables for the location, basically.
emitter.firstinfront = 1; // Should the first emitted particle be in front of every other particle?
emitter.nrofparticles = 10; // The number of particles to be released at the same exact time when the emitter emits. For example, set this to two, and you'll have two particles released every time instead of the default 1.
emitter.maxparticles = 80; // The maximum number of particles that can exist at one time. If this limit is reached, the script will wait until one of the particles runs out before emitting another one.
emitter.particle.lifetime = 1; // How long, in seconds, the emitter lasts.
emitter.particle.image = "sh_particle_rain.png"; // The imagename of the emitter
emitter.particle.mode = 0; // Either 0, 1, or 2, the same as changeimgmode. 0 = add, 1 = trans, 2 = subtract. Use this for a blacklight effect if you wish.
emitter.particle.alpha = .8; // Between 0 and 1, the alpha colour for transparancy
emitter.particle.zoom = 1; // The zoom effect of the particle
emitter.particle.red = 1;
emitter.particle.green = 1;
emitter.particle.blue = 1; // These three are between 0 and 1, and they're the colours of the individual particles
emitter.particle.zangle = 0; // Between 0 and pi*2, it's the upward angle of the particles. Remember zangle from the shoot() function? Same basic idea.
emitter.particle.angle = this.shootAngle; // Again, between 0 and pi*2, it's the angle that the particle should flow.
emitter.particle.speed = 1000; // I'm not sure if this is measured in Tiles per second or what, but it's the speed. Higher = faster, obviously
// emitter.particle.spin = 10; // The number of times each particle rotates while it's being shown. Ex, 1 will make the particle rotate just once before it hides.
emitter.particle.stretchx = 1; // This is how 'stretched' each particle will be, relative to width.
emitter.particle.stretchy = 1; // This is how 'stretched' each particle will be, relative to height.
emitter.addlocalmodifier("once", 0, .1, "angle", "replace", pi*1.5, pi*1.5 + .3);
emitter.addlocalmodifier("once", 0, 0, "x", "replace", -600, screenwidth + 20);
//if (emitter.particle.z == 0) {
// showani(this.particle.x, this.particle.y, "sh_raindrop", NULL);
//}
}
}
function Wind() {
hideimg(255);
with (findimg(255)) {
layer = 3;
emitter.delaymin = 0.2;
emitter.delaymax = 0.4;
emitter.nrofparticles = 1;
emitter.emissionoffset = {0, -9, 10};
emitter.autorotation = false;
emitter.checkbelowterrain = false;
emitter.particle.lifetime = 25;
emitter.particle.image = "g4_particle_leaf.png";
emitter.particle.zangle = -1;
emitter.particle.speed = 0.1;
emitter.particle.alpha = 0.99;
emitter.particle.mode = 1;
emitter.clippingbox = {0, 0, 0, "screenwidth", "screenheight", 11};
emitter.wraptoclippingbox = true;
emitter.cliptoscreen = true;
emitter.addglobalmodifier("impulse", 0.2, 0.2, "zangle", "multiply", 0.95, 0.95);
emitter.addlocalmodifier("once", 0, 0, "angle", "replace", 0, 2*pi);
emitter.addlocalmodifier("once", 0, 0, "angle", "replace", degtorad(200), degtorad(260));
emitter.addlocalmodifier("once", 0, 0, "x", "add", -25, 35);
emitter.addlocalmodifier("once", 0, 0, "y", "add", 0, 20);
emitter.addlocalmodifier("once", 0, 0, "zoom", "replace", 0.6, 1.2);
emitter.addlocalmodifier("once", 0, 0, "green", "replace", 0.5, 1);
emitter.addglobalmodifier("impulse", 0.2, 0.2, "spin", "add", 0, 0.01);
emitter.addlocalmodifier("range", 0, 100000, "speed", "add", 0.1, 0.3);
with (emitter.addlocalmodifier("impulse", 1, 2, "spin", "add", 0, 0.01)) {
addmod("zangle", "add", 0.1, 0.5);
}
}
}
function Lightning() {
/* showimg(256, "sh_particle_lightning.png", x, 0);
with (findimg(256)) {
x = random( -30, screenwidth);
layer = 3;
emitter.delaymin = 0.2;
emitter.delaymax = 0.4;
emitter.nrofparticles = 3;
emitter.particle.lifetime = 5;
emitter.particle.mode = 1;
emitter.particle.alpha = 0.99;
emitter.particle.zoom = 5;
emitter.particle.red = 1;
emitter.particle.green = 1;
emitter.particle.blue = 1;
emitter.addlocalmodifier("range", 0, 3, "zoom", "add", 5, 1);
}*/
if (random(0, 1) >= 0.85 && random(0, 1) >= 0.85) {
play("thunder-02.wav");
seteffect(0, 0, 0.3, 1);
sleep(0.05);
seteffect(1, 1, 1, 1);
sleep(0.05);
seteffect(0, 0, 0, 0);
}
//seteffect(0, 0, 0, 0.7);
}
function Fog() {
hideimg(255);
with (findimg(255)) {
layer = 4;
emitter.delaymin = 0.2;
emitter.delaymax = 0.4;
emitter.nrofparticles = 1;
emitter.autorotation = false;
emitter.maxparticles = 1;
emitter.checkbelowterrain = false;
emitter.particle.lifetime = 25;
emitter.particle.image = "sh_particle_fog.png";
emitter.particle.zangle = 0;
emitter.particle.speed = 0;
emitter.particle.alpha = 1;
emitter.particle.zoom = 1;
emitter.particle.mode = 1;
emitter.addlocalmodifier("range", 0, 3, "zoom", "add", 0.055, 0.05);
}
}
function onTimeout() {
with (findimg(255)) {
x = player.x;
y = player.y;
z = player.z;
}
if (this.lastWeather != this.currentWeather)
{
this.lastWeather = this.currentWeather;
if (this.currentWeather == "rain") {
Rain();
}
elseif (this.currentWeather == "wind") {
Wind();
}
elseif (this.currentWeather == "fog") {
Fog();
}
elseif (this.currentWeather == "storm") {
Rain();
Lightning();
}
else
{
//Calm
hideimg(255);
}
}
setTimer(0.05);
}
You'll have to rewrite Lightning() entirely I'm afraid, since it doesn't make sense anymore. |
|