Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting > Code Gallery
FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Search this Thread Display Modes
  #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
  #2  
Old 01-26-2008, 09:52 PM
Chompy Chompy is offline
¯\(º_o)/¯
Chompy's Avatar
Join Date: Sep 2006
Location: Norway
Posts: 2,815
Chompy is just really niceChompy is just really niceChompy is just really nice
Send a message via MSN to Chompy
Nice Vash
__________________
Reply With Quote
  #3  
Old 01-26-2008, 10:12 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
Well, it seems I'm having some unforeseen problems with this.
For some reason every player can see someones weather effect. I've tried everything I could think of to make it so it doesn't show globally, but I can't figure it out. I'm using image indexes over 200...I even tried well over that, but I can't figure it out.

Halp D:
__________________

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
Reply With Quote
  #4  
Old 01-27-2008, 03:17 AM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Quote:
Originally Posted by coreys View Post
Well, it seems I'm having some unforeseen problems with this.
For some reason every player can see someones weather effect. I've tried everything I could think of to make it so it doesn't show globally, but I can't figure it out. I'm using image indexes over 200...I even tried well over that, but I can't figure it out.

Halp D:
You can't set the player attribute

I would do a showani or something. If you set the player attribute, of course everyone can see it. That's how a lot of name systems, chat systems, etc are done.
__________________
Reply With Quote
  #5  
Old 01-27-2008, 03:57 AM
DustyPorViva DustyPorViva is offline
Will work for food. Maybe
DustyPorViva's Avatar
Join Date: Sep 2003
Location: Maryland, USA
Posts: 9,589
DustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond repute
Send a message via AIM to DustyPorViva Send a message via MSN to DustyPorViva
Yes, showani with an index >200. If you set an attr as a gani, everyone else will be able to see your gani. That's where the problems arise, I believe.
Reply With Quote
  #6  
Old 01-27-2008, 01:53 PM
Inverness Inverness is offline
Incubator
Inverness's Avatar
Join Date: Aug 2004
Location: Houston, Texas
Posts: 3,613
Inverness is a jewel in the roughInverness is a jewel in the rough
My brain crashed at the part where you said you used a gani to display the weather.
__________________
Reply With Quote
  #7  
Old 01-27-2008, 04:14 PM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Quote:
Originally Posted by Inverness View Post
My brain crashed at the part where you said you used a gani to display the weather.
CTRL+ALT+DELETE
__________________
Reply With Quote
  #8  
Old 01-27-2008, 06:00 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
I chose ganis and attributes, because otherwise, when you move, the weather effect will lag behind you.
__________________

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
Reply With Quote
  #9  
Old 01-27-2008, 10:53 PM
zokemon zokemon is offline
That one guy...
zokemon's Avatar
Join Date: Mar 2001
Location: Sonoma County, California
Posts: 2,925
zokemon is a jewel in the roughzokemon is a jewel in the rough
Send a message via ICQ to zokemon Send a message via AIM to zokemon Send a message via MSN to zokemon Send a message via Yahoo to zokemon
I made a weather system on GK a while ago. People usually just turn it off though as having it combined with the terrain and a bunch of other particle effects from monsters and other players was not the friendliest thing on people's CPUs and graphics cards, especially when the rain was on "heavy".

It had different settings of rain, snow and leaves (for autumn) that would do very very slow transitions when the settings changed. Each setting also had a light and a heavy version. No one really knows about the transitions though as they usually take about a half hour to complete :P.

Quote:
Originally Posted by coreys View Post
I chose ganis and attributes, because otherwise, when you move, the weather effect will lag behind you.
Just put have findimg(i).attachtoowner = true;
__________________
Do it with a DON!
Reply With Quote
  #10  
Old 01-28-2008, 01:10 AM
TheFisherman TheFisherman is offline
Banned
Join Date: Jan 2008
Posts: 117
TheFisherman is on a distinguished road
Send a message via AIM to TheFisherman
Could you show any screenshots?
Reply With Quote
  #11  
Old 01-28-2008, 02:07 AM
Bolivian Bolivian is offline
Lifetime Gold Winner
Bolivian's Avatar
Join Date: Jan 2008
Location: Canada
Posts: 37
Bolivian is on a distinguished road
Send a message via MSN to Bolivian
O.o o.O

Lol
__________________
Hi there
Reply With Quote
  #12  
Old 01-28-2008, 03:33 AM
Rapidwolve24 Rapidwolve24 is offline
North*
Join Date: Oct 2007
Location: Massachusetts
Posts: 178
Rapidwolve24 is on a distinguished road
Send a message via AIM to Rapidwolve24 Send a message via MSN to Rapidwolve24
Quote:
Originally Posted by Bolivian View Post
O.o o.O

Lol
What is wrong with you?
Reply With Quote
  #13  
Old 01-28-2008, 04:06 AM
Inverness Inverness is offline
Incubator
Inverness's Avatar
Join Date: Aug 2004
Location: Houston, Texas
Posts: 3,613
Inverness is a jewel in the roughInverness is a jewel in the rough
Quote:
Originally Posted by coreys View Post
I chose ganis and attributes, because otherwise, when you move, the weather effect will lag behind you.
What Zero said.
There is also the GUI layer.
__________________
Reply With Quote
  #14  
Old 01-29-2008, 12:38 AM
TheFisherman TheFisherman is offline
Banned
Join Date: Jan 2008
Posts: 117
TheFisherman is on a distinguished road
Send a message via AIM to TheFisherman
Quote:
Originally Posted by TheFisherman View Post
Could you show any screenshots?
Reply With Quote
  #15  
Old 01-29-2008, 12:38 AM
Rufus Rufus is offline
Registered User
Join Date: Jun 2004
Location: United Kingdom
Posts: 4,698
Rufus has much to be proud ofRufus has much to be proud ofRufus has much to be proud ofRufus has much to be proud ofRufus has much to be proud ofRufus has much to be proud of
Quote:
Originally Posted by TheFisherman View Post
Or a video.
__________________
Quote:
Originally Posted by Loriel View Post
Seriously, you have ****-all for content and you're not exactly pulling in new developer talent, angling for prestigious titles should be your last concern.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 11:11 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.