| coreys |
01-26-2008 09:13 PM |
Weather System
1 Attachment(s)
I have yet to see any decent weather system around Graal, so, after I found some old weather effects I made using the particle system, I decided to make my own and release it.
Main WNPC:
PHP Code:
/* Weather System v1 by Abjorn (*coreys) This script is free to use by all, so long as this comment block remains intact and unedited and credit is attributed.*/ //#CLIENTSIDE function onCreated() { player.attr[9] = ""; this.weather = ""; this.types = {"weather_rain.gani"}; //list of weather ganis this.chance = {49,51}; /*chance variables When the weather changes it will create a random number betwee 0 and the second number in this array. If the number is above the first number in this array, the weather will be something other than none.*/ this.levels = {}; //List of levels with weather this.levelstarts = {"mal-"}; //List of level name starts with weather this.attr = 9; //number of the player.attr[] that will hold //the weather gani this.maxtime = 800; //Time period before the weather changes this.timer = 0; onTimeOut(); } function onTimeOut() { //Check if the players level allows weather temp.check = false; for (temp.lvl: this.levelstarts) { if (player.level.starts(temp.lvl)) temp.check = true; } if (player.level in this.levels) temp.check = true; if (temp.check) { //Make sure the weather gani is correct if (player.attr[this.attr] != this.weather) player.attr[this.attr] = this.weather; client.weather = this.weather; if (this.timer < this.maxtime) this.timer++; else { //It's time to change weather this.timer = 0; temp.change = random(0,this.chance[1]); if (temp.change > this.chance[0]) //If the weather changes this.weather = randomstring(this.types); else this.weather = ""; //Or returns to normal } } else { //Turns weather off if your level doesn't allow it player.attr[this.attr] = ""; client.weather = ""; } setTimer(1); } //If the weather gani ends the weather manually function onActionEndWeather(acc) { if (player.account == acc) this.timer = this.maxtime; }
This weather system uses gani's to show weather effects. It's completely clientside, so not every player is going to be experiencing the same weather. I may make a serverwide weather system sometime in the future. The gani is set to a player.attr[], which you can change in the script. I think I've commented it fairly well, so anything you want to change should be easy to figure out.
Here's the gani for the rain effect that I am releasing. It uses the particle engine, as I would suggest everyone use for any weather effects they want to make.
PHP Code:
GANI0001
DEFAULTHEAD head19.png DEFAULTBODY body.png
ANI
ANIEND SCRIPT //#CLIENTSIDE function onCreated() { with (findImg(401)) {
// 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 = "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.05); } function onTimeOut() { temp.i = findImg(401); temp.i.x = player.x; temp.i.y = player.y; if (this.timer < .5) this.timer += .05; else { if (this.lifetime < 800) { if (temp.i.emitter.nrofparticles < 200) temp.i.emitter.nrofparticles++; this.timer = 0; } } if (this.lifetime < 800) this.lifetime += .05; else { if (temp.i.emitter.nrofparticles > 0) temp.i.emitter.nrofparticles--; else triggeraction(player.x, player.y, "EndWeather", player.account); } hideimg(202); if (temp.i.nrofparticles > 100) { temp.chance = int(random(0, 400)); if (temp.chance > 395) { showpoly(402, {0,0,screenwidth,0,screenwidth,screenheight,0,screenheight}); changeimgvis(402,4); changeimgcolors(402,1,1,1,.1); } } setTimer(0.05); } SCRIPTEND
And attached I have a rain particle GFX.
Enjoy!
|