RMParadise

It seems you either have yet to login or are not a member of RMP. If you are not yet a member, please feel free to sign up so that you can unlock every feature our forums have to offer. If you have yet to login, please do so soon.

A Paradise for RPGMakers.

Welcome everyone to RMP, your very own RPGMaker Paradise.
If you are reading this, that means that you are one of the select few who have been invited to experience our site as a Beta User.
Being a Beta User only requires that you report any bugs and/or problems upon finding them.
You get the chance to have free roam over the boards before they are public and are further up in line for promotions (which will be happening very soon, so stay on your best behavior).
Check out the thread for the RMP Beta Contest. Lets get some new content rolling.
Chat
Back to Top

    Basic Climate System

    Share
    avatar
    Vlue
    I'm a new member :)
    I'm a new member :)

    Registered on Registered on : 2012-05-28
    Posts Posts : 30
    Rep. Points Rep. Points : 13

    Basic Climate System

    Post by Vlue on Thu May 31, 2012 12:32 am

    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
    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.
    avatar
    DawningStar
    I'm a new member :)
    I'm a new member :)

    Registered on Registered on : 2012-05-29
    Posts Posts : 65
    Rep. Points Rep. Points : 9

    Re: Basic Climate System

    Post by DawningStar on Thu May 31, 2012 12:46 am

    Beautiful, I especially appreciate it since I am trying to rebuild my collected scripts folder! I will definitely use!


    Quick question: Is it also possible to add in other types of weather?
    * For example, say i had another script that allowed me to add in other effects like levaes falling, can I also trigger this script to work with that too? *
    avatar
    Vlue
    I'm a new member :)
    I'm a new member :)

    Registered on Registered on : 2012-05-28
    Posts Posts : 30
    Rep. Points Rep. Points : 13

    Re: Basic Climate System

    Post by Vlue on Thu May 31, 2012 2:04 am

    Other weather types? Falling leaves?
    Sounds like the Atelier Weather system.
    If so, yes.
    If no, maybe.
    avatar
    DawningStar
    I'm a new member :)
    I'm a new member :)

    Registered on Registered on : 2012-05-29
    Posts Posts : 65
    Rep. Points Rep. Points : 9

    Re: Basic Climate System

    Post by DawningStar on Thu May 31, 2012 1:01 pm

    Yeah, Atelier Weather system was the one I was referring too, alright thank you for clearing that up! I really appreciate it!
    avatar
    Vlue
    I'm a new member :)
    I'm a new member :)

    Registered on Registered on : 2012-05-28
    Posts Posts : 30
    Rep. Points Rep. Points : 13

    Re: Basic Climate System

    Post by Vlue on Thu May 31, 2012 2:36 pm

    DawningStar wrote:Yeah, Atelier Weather system was the one I was referring too, alright thank you for clearing that up! I really appreciate it!

    You weren't the first to ask! (If you couldn't tell)
    Here's a version of the script that will (should) work with Atelier

    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 = 30              #Chance to Rain
      STORM = 60              #Chance to Storm (Chance is STORM - RAIN)
      CUSTOM1 = 80                  ##NEW##
      CUSTOM2 = 100            ##NEW## Numbers in succession, nothing over 100
     
      #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 = [3,4,5,6,7,8,9,10,11,12,13,14,15,16,23]
      INDOORMAPSNS = [17,18,19,20,21]

      ##NEW## Type(See Atelier Weather, 0-6), power (0-9), Image file name
      RAINTYPE      = [0, 9, "Rain_01A"]
      SNOWTYPE      = [4, 9, "Snow_01"]
      STORMTYPE    = [0, 9, "Rain_01B"]
      CUSTOM1TYPE  = [0, 9, "Rain_01B"]
      CUSTOM2TYPE  = [0, 9, "Rain_01B"]
      ##NEW##
     
      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",  95, 100]     
      STORM_BGS  = ["Storm", 75, 100]
      CUSTOM1_BGS = ["Rain", 75, 100]        ##NEW##
      CUSTOM2_BGS = ["Rain", 75, 100]        ##NEW##
      INSIDE_BGS = ["Rain", 75, 100]     
      #------#
     
      def self.init
        @player_suppress = false
        @weather_suppressed
        @active_weather = 0
        @duration = 600#MAXDURATION
        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
        when STORM..CUSTOM1
          @active_weather = 3
          Climate::custom1
        when CUSTOM1..CUSTOM2
          @active_weather = 4
          Climate::custom2
        else
          Climate::clear
        end
      end
      def self.rain(selfset = true)
        if selfset then @active_weather = 1 end
        if Climate::freezing?
          $game_system.weather.clear
          $game_system.weather = SNOWTYPE
        else
          $game_system.weather.clear
          $game_system.weather = RAINTYPE
          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_system.weather.clear
        $game_system.weather = STORMTYPE
      end
      def self.custom1(selfset = true)
        if selfset then @active_weather = 3 end
        Audio.bgs_play('Audio/BGS/' + CUSTOM1_BGS[0], CUSTOM1_BGS[1], CUSTOM1_BGS[2], 0) if USE_SOUND
        $game_system.weather.clear
        $game_system.weather = CUSTOM1TYPE
      end
      def self.custom2(selfset = true)
        if selfset then @active_weather = 4 end
        Audio.bgs_play('Audio/BGS/' + CUSTOM2_BGS[0], CUSTOM2_BGS[1], CUSTOM2_BGS[2], 0) if USE_SOUND
        $game_system.weather.clear
        $game_system.weather = CUSTOM2TYPE
      end
      def self.clear
        @active_weather = 0
        Audio.bgs_stop
        $game_system.weather.clear
        $game_system.weather = [-1,0,""]
      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
          suppress = 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_system.weather = [-1,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_system.weather = [-1,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
    avatar
    DawningStar
    I'm a new member :)
    I'm a new member :)

    Registered on Registered on : 2012-05-29
    Posts Posts : 65
    Rep. Points Rep. Points : 9

    Re: Basic Climate System

    Post by DawningStar on Thu May 31, 2012 2:38 pm

    Alright! Thank you! I'll probably save both scripts then! :D
    avatar
    Hyde
    Administrator
    Administrator

    Registered on Registered on : 2012-05-18
    Posts Posts : 101
    Rep. Points Rep. Points : 6

    Re: Basic Climate System

    Post by Hyde on Thu May 31, 2012 7:19 pm

    I havent used Atelier yet, but I am really hooked on Moghunter's ACE Weather script. It has nice customization.

    I may be overlooking this as I am pretty tired right now, but does this have the option to set different weather types for different maps? Like say I have a map that is in the tundra and I would like the random weather to be between calm snow, fast moving snow, and a blizzard. I could then set it to where that certain map can cycle through those options and another map can cycle through different set options. Didnt know if this script did that or if it is set for everything being random.

    (P.S. I am going to check out that other system soon, but if this ever becomes compatible with Moghunter's, let me know.)


    _________________

    avatar
    Vlue
    I'm a new member :)
    I'm a new member :)

    Registered on Registered on : 2012-05-28
    Posts Posts : 30
    Rep. Points Rep. Points : 13

    Re: Basic Climate System

    Post by Vlue on Thu May 31, 2012 9:56 pm

    No, it's pretty set between rain, storm, snow, and nothing..

    I will let you know if that changes!
    avatar
    Hyde
    Administrator
    Administrator

    Registered on Registered on : 2012-05-18
    Posts Posts : 101
    Rep. Points Rep. Points : 6

    Re: Basic Climate System

    Post by Hyde on Fri Jun 01, 2012 3:32 am

    Ok, thank you.
    And dont worry, I have this in my script directory on my computer now and I plan on using it in one of my projects.


    _________________


    Sponsored content

    Re: Basic Climate System

    Post by Sponsored content


      Current date/time is Tue Oct 23, 2018 8:34 am