Thread: Weather System
View Single Post
  #1  
Old 01-26-2008, 09:13 PM
coreys coreys is offline
N-Pulse Assistant Manager
coreys's Avatar
Join Date: Mar 2005
Posts: 2,180
coreys has a spectacular aura about
Send a message via AIM to coreys Send a message via MSN to coreys Send a message via Yahoo to coreys
Weather System

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.lvlthis.levelstarts) {
    if (
player.level.starts(temp.lvl))
      
temp.check true;
  }
  if (
player.level in this.levelstemp.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;
    
player.xplayer.y;
    
emitter.delaymin 0.1;
    
emitter.delaymax 0.3;
    
emitter.nrofparticles 5;
    
emitter.emissionoffset = {-12, -1550};
    
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.20.2"zangle""multiply"0.950.95);
    
emitter.addlocalmodifier("impulse"020"zoom""add", -1.5.2);
    
emitter.addlocalmodifier("once"00"angle""replace"degtorad(260), degtorad(230));
    
emitter.addlocalmodifier("once"00"x""add", -6464);
    
emitter.addlocalmodifier("once"00"y""add", -100);
    
emitter.addlocalmodifier("once"00"zoom""replace"0.61.2);
    
emitter.addlocalmodifier("range"010"speed""add"13);
    
emitter.addglobalmodifier("range"0.125"angle""add", -degtorad(45), degtorad(45));
  }
  
this.timer 0;
  
this.lifetime 0;
  
setTimer(0.05);
}
function 
onTimeOut() {
  
temp.findImg(401);
  
temp.i.player.xtemp.i.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.xplayer.y"EndWeather"player.account);
  }
  
hideimg(202);
  if (
temp.i.nrofparticles 100) {
    
temp.chance int(random(0400));
    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!
Attached Images
 
__________________

Quote:
*SlikRick: so should I even ask about your aim status?
*Xor: well if you want to
*Xor: but i am LARPING
*SlikRick: While on a computer?
*Xor: yes
*Xor: in my living room
*SlikRick: ahh
*Xor: i have a fort setup to hide from beasts

Last edited by coreys; 01-26-2008 at 09:31 PM..
Reply With Quote