Basic Climate System v1.3
By V.M.
Introduction
Provides a basic weather system that will randomly rain or storm. Random weather, woot! Also a few functions for use as well.
How to Use
Plug and play and customize as needed.
Script
By V.M.
Introduction
Provides a basic weather system that will randomly rain or storm. Random weather, woot! Also a few functions for use as well.
How to Use
Plug and play and customize as needed.
Script
- Code:
#Basic Climate System
#----------#
#Features: Provides a basic weather system that will randomly rain or storm.
# Random weather, woot! Also a few functions for use as well.
#
#Usage: Plug and play!
# Script calls:
# Climate::rain #Sets Climate weather to rain
# Climate::storm #Sets Climate weather to storm
# Climate::clear #Sets Climate weather to none
# Climate::suppress(true/false) #Stops Climate weather
# Climate::weather? #Returns 0 for clear
# 1 for rain
# 2 for storm
#
#Customization: Set below, in comments.
#
#Examples: Climate::rain
# Climate::suppress
# if Climate::weather? == 2 /* Used in Conditional Branches */
#
#----------#
#-- Script by: V.M of D.T
#--- Free to use in any project with credit given
module Climate
#------#
#MAXDURATION is duration of weather effects in frames i.e 18000 frames is 5 mins
MAXDURATION = 18000
RAIN = 50 #Chance to Rain
STORM = 60 #Chance to Storm (Chance is STORM - RAIN, 10 by feault)
#Map Ids of SNOWYMAPS = Maps with snow instead of rain
# INDOORMAPS = Maps with no weather effect yet BGS
# INDOORMAPSNS = Maps with no weather effect and no BGS
SNOWYMAPS = [0]
INDOORMAPS = [0]
INDOORMAPSNS = [0]
USE_SOUND = true #Whether to use weather BGS or not
#BGS's to use during RAIN, STORM, or in an INSIDE map
#Format is FILENAME, VOLUME(1-100), and PITCH(50-150)
RAIN_BGS = ["Rain", 75, 100]
STORM_BGS = ["Storm", 75, 100]
INSIDE_BGS = ["Rain", 75, 100]
#------#
def self.init
@player_suppress = false
@weather_suppressed
@active_weather = 0
@duration = 600
Climate::update
end
def self.update
if SceneManager.scene_is?(Scene_Map) then else return end
@duration -= 1
if @duration < 0 then Climate::change_weather end
if Climate::suppress_weather?(0) then Climate::suppress_weather(true) end
end
def self.change_weather
@duration = MAXDURATION + (MAXDURATION * ((rand(40) - 20) / 100))
if @active_weather == 0 then Climate::new_weather else Climate::clear end
end
def self.weather?
return @active_weather
end
def self.new_weather
case rand(100)
when 0..RAIN
@active_weather = 1
Climate::rain
when RAIN..STORM
@active_weather = 2
Climate::storm
else
Climate::clear
end
end
def self.rain(selfset = true)
if selfset then @active_weather = 1 end
if Climate::freezing?
$game_map.screen.change_weather(:snow, 9, 120)
else
$game_map.screen.change_weather(:rain, 9, 120)
Audio.bgs_play('Audio/BGS/' + RAIN_BGS[0], RAIN_BGS[1], RAIN_BGS[2], 0) if USE_SOUND
end
end
def self.storm(selfset = true)
if selfset then @active_weather = 2 end
Audio.bgs_play('Audio/BGS/' + STORM_BGS[0], STORM_BGS[1], STORM_BGS[2], 0) if USE_SOUND
$game_map.screen.change_weather(:storm, 9, 120)
end
def self.clear
@active_weather = 0
Audio.bgs_stop
$game_map.screen.change_weather(:none, 0, 120)
end
def self.freezing?
snowy = false
SNOWYMAPS.each {|id| snowy = true if id == $game_map.map_id }
return snowy
end
def self.suppress(check)
@player_suppress = check
Climate::suppress_weather(@player_suppress)
end
def self.suppress_weather?(check)
suppress = false
case check
when 0
return true if @player_suppress == true
INDOORMAPS.each {|id| suppress = true if id == $game_map.map_id }
INDOORMAPSNS.each {|id| suppress = true if id == $game_map.map_id }
return suppress
when 1
INDOORMAPS.each {|id| suppress = true if id == $game_map.map_id }
return suppress
when 2
INDOORMAPSNS.each {|id| suppress = true if id == $game_map.map_id }
return suppress
end
end
def self.suppress_weather(check)
case check
when true
@weather_suppressed = true
if Climate::suppress_weather?(1)
$game_map.screen.change_weather(:none, 0, 0)
if @active_weather != 0 then
Audio.bgs_play('Audio/BGS/' + INSIDE_BGS[0], INSIDE_BGS[1], INSIDE_BGS[2], 0) if USE_SOUND end
else
$game_map.screen.change_weather(:none, 0, 0)
Audio.bgs_stop
end
when false
@weather_suppress = false
case @active_weather
when 1
Climate::rain
when 2
Climate::storm
else
Climate::clear
end
end
end
end
class Scene_Map < Scene_Base
alias climate_initialize start
alias climate_post_transfer post_transfer
def start
climate_initialize
case Climate::weather?
when 0
when 1
Climate::rain
when 2
Climate::storm
end
end
def post_transfer
if Climate::suppress_weather?(0) then Climate::suppress_weather(true) else Climate::suppress_weather(false) end
climate_post_transfer
end
end
class Scene_Base
alias climate_update update
def update
climate_update
Climate::update
end
end
Climate::init
And in a pastebin for ease: Here
FAQ
None at the moment. Maybe.
Credit and Thanks
- By V.M. of D.T.
- Free to use in any project with credit given
Author's Notes
Spelt supress wrong the entire time writing this.
Bored, posted another script here.
This one has known bugs, it needs to be rewritten
I'll get on that, eventually.
I'm sure you will.
History:
Version 1.3 - Fixed bug where weather would play on indoor maps anyways just to spite you
Version 1.2 - Fixed Bug where BGS would not replay after battle
Version 1.1 - Added custom BGS for inside and outside maps.
FAQ
None at the moment. Maybe.
Credit and Thanks
- By V.M. of D.T.
- Free to use in any project with credit given
Author's Notes
Spelt supress wrong the entire time writing this.
Bored, posted another script here.
This one has known bugs, it needs to be rewritten
I'll get on that, eventually.
I'm sure you will.
History:
Version 1.3 - Fixed bug where weather would play on indoor maps anyways just to spite you
Version 1.2 - Fixed Bug where BGS would not replay after battle
Version 1.1 - Added custom BGS for inside and outside maps.