HTML Code:
//#CLIENTSIDE
function onCreated() {
this.w_drizzle.particles = 30;
this.w_drizzle.image = "weather_raindrop.gif";
this.w_drizzle.control = 1;
this.w_rain.particles = 130;
this.w_rain.image = "weather_raindrop.gif";
this.w_rain.control = 2;
this.w_snow.particles = 10;
this.w_snow.image = "era_snowflake.png";
this.w_snow.control = 3;
this.w_hail.particles = 10;
this.w_hail.image = "era_snowball.png";
this.w_hail.control = 4;
this.w_hail.zoom = 0.5;
this.w_clear.control = 0;
onTimeOut();
}
function onTimeOut() {
temp.newmode = serverr.weather;
if (temp.newmode != this.mode) {
this.mode = temp.newmode;
this.onChangeEffect(this.mode);
//Invoke function
cancelevents("onDrawEffect");
scheduleevent(2, "onDrawEffect", this.mode);
}
if (this.mode == "rain") {
scheduleevent(random(0, 10), "Thunder", "");
}
setTimer(10);
}
function onChangeEffect(mode) {
with (findimg(200)) {
with (emitter) {
addlocalmodifier("range", 0,0.2, "alpha", "replace", 0.3,0.5);
addlocalmodifier("range", 0.2,1, "alpha", "replace", 0.5,0);
addlocalmodifier("range", 0 ,1, "zoom", "replace", 1,0.3);
}
}
}
function onDrawEffect(mode) {
hideimg(200);
if (temp.mode == "clear" || !player.level.name.starts("tsa_")) {
return;
}
temp.modes = this.("w_" @ mode).getdynamicvarnames();
for (temp.i: temp.modes) {
temp.val = this.("w_" @ mode).(@ i);
if (temp.i == "particles") {
temp.pcles = val;
}
else {
temp.("c_" @ i) = val;
}
}
with (findimg(200)) {
// Emitter attributes
layer = 2;
x = player.x;
y = player.y;
with (emitter) {
delaymin = 0.25;
delaymax = 0.4;
nrofparticles = temp.pcles;
emissionoffset = {0, -8, 1};
attachtoowner = true;
with(particle) {
lifetime = int(random(5, 15));
for (temp.i: temp.modes) {
(@ i) = temp.("c_" @ i);
}
alpha = random(.6, .7);
mode = 1;
}
addlocalmodifier("once", 0, 0, "angle", "replace", degtorad(210), degtorad(300));
addlocalmodifier("once", 0, 0, "x", "add", - int(screenwidth / 16 / 2), int(screenwidth / 16 / 2));
addlocalmodifier("once", 0, 0, "y", "add", - int(screenheight / 16 / 2), int(screenheight / 16 / 2));
addlocalmodifier("once", 0, 0, "speed", "replace", 30, 40);
}
}
}
function onThunder() {
cancelevents("Thunder");
if (this.mode != "rain" || !player.level.name.starts("tsa_")) {
return;
}
for (temp.i = 0; temp.i < 5; temp.i++) {
seteffect(0.5, 0.5, 0.5, ("0." @ i));
if (random(0, 10) > 7) {
play("era_thunder.wav");
}
sleep(0.1);
}
seteffect(0, 0, 0, 0);
onTimeOut();
}