Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Random Weather Generator 3.0

Status
Not open for further replies.

OS

Sponsor

Random Weather Generator
Current Version: 3.0

Introduction

This is my Random Weather Generator that I built for Leknaat's Rhapsodia Village. The script is used to create random weather effects that fade in and out like real weather. In other words, after a few minutes, it may begin to rain. Then after an other minute, it may hail. And then it may grow into a thunder storm. Then the weather will slowly die down into soft rain, and eventually clear weather.

Features
Not many, yet. More planned for later.
  • Random Effects
  • Memorize and Restore Weather
  • Turn RandWeather ON or OFF with a simple Call Script

Future Feature//Regionalized Weather//Types

EDIT: This feature will work by placing [r] in Event 001 on any map, where r is the region type on that map.

  1. ALL -- Every Effect!
  2. PLAIN -- Rain, Hail, Storm, and Rain w/Th&Li
  3. FOREST -- Rain, Hail, Storm, Rain w/Th&Li, and All of the Leef Effects (except Sakura...)
  4. DESERT -- Falling Ash (sorry, but it is all I can do with what I have right now!)
  5. ARCTIC -- Snow and Blowing Snow
  6. OCEAN -- See PLAINS. I didn't realize this until now, but PLAINS and OCEAN are the same!

Screenshots

No point. This system doesn't have any means of displaying other than weather you have all probably already seen...

Demo

I will post a demo when I have more scripts to put into it.

Script

Code:
# Random Weather Generator
# Broken Wire
# Version: 3.0
# Date: 1/28/07
module BSR
  # Constructer Event ID
  CONSTRUCT_ID = 1
  # Region IDs ####Please do not edit, though you may add to the list!
  ALL = 'All'
  PLAINS = 'Plains'
  FOREST = 'Forest'
  DESERT = 'Desert'
  ARCTIC = 'Arctic'
  OCEAN  = 'Ocean'
  # Weather Hash
  WEATHER = {
  ALL => [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 16, 17, 18, 19],
  PLAINS => [1, 2, 4, 5], FOREST => [1, 2, 4, 5, 6, 7, 8, 9],
  DESERT => [18], ARCTIC => [3, 16], OCEAN => [1, 2, 4, 5]
  }
end

class Scene_Map
  #Aliases
  alias brkn_init initialize
  alias brkn_updt update
  
  #Init
  def initialize
    @weather_on = true
    @weather = [0, 0] #Current weather [type, power]
    @memorized = [0, 0] #Memorized weather data [type, power]
    @fade_active = false
    @rage_actice = false
    @count = 0 #Count value for update method
  end
  
  # Memorize Weather
  def memorize_weather
    if !memorized?
      @memorized[0] = @weather[0]
      @memorized[1] = @weather[1]
      @weather[0] = 0
      @weather[1] = 0
      $game_screen.weather(@weather[0], @weather[1], 0)
    end
  end
  
  # Memorized?
  def memorized?
    if @memorized[0] != nil
      return true
    end
    return false
  end
  
  # Restore Weather
  def restore_weather
    if memorized?
      @weather[0] = @memorized[0]
      @weather[1] = @memorized[1]
      @memorized[0] = 0
      @memorized[1] = 0
      $game_screen.weather(@weather[0], @weather[1], 0)
    end
  end
  
  # Enragen the Weather
  def rage_weather
    power = @weather[1] + rand(10)
    $game_screen.weather(@weather[0], power, rand(19) + 1)
    if rand(5) > 3
      @rage_active = true
    else
      @rage_active = false
    end
    update
  end
  
  # Fade the Weather
  def fade_weather
    power = @weather[1] - rand(10)
    $game_screen.weather(@weather[0], power, rand(19) + 1)
    if rand(5) > 3
      @fade_active = true
    else
      @fade_active = false
    end
    update
  end
  
  # Update
  def update
    # Update regularly
    brkn_updt
    if @weather_on == true
      if memorized?
        restore_weather
      end
      types = []
      # Fade Weather
      if @fade_active == true
        fade_weather
      # Rage Weather
      elsif @rage_active == true
        rage_weather
      end
      event = $game_map.events[CONSTRUCT_ID]
      unless event.erased
        unless event.list.nil?
          event.list.each do |event_command|
          if event_command.code == 108 && event_command.code == 408
            line0 = event_command.parameters[0]
            #Weather Update
            if line0.include?(BSR::ALL)
              @count = (@count + 1) % 1400
              if @count == (rand(99) + 1) + 100 and @fade_active == false and @rage_active == false
                #use special Fade or Rage features here if weather_type != 0
                if $game_screen.weather_type != 0
                  if $game_screen.power? > 25
                    @fade_active = true #Make the weather fade out a little.
                    update
                  elsif $game_screen.power? <= 25
                    @rage_active = true #Make the weather get heavier/harsher
                    update
                  end
                end
                #Otherwise, create a random weather effect at low power!
                $game_screen.weather(rand(BRW::WEATHER.keys.size - 1) + 1, rand(10), rand(9) + 1)
              end
            elsif line0.include?(BSR::PLAINS)
              @count = (@count + 1) % 1400
              if @count == (rand(99) + 1) + 100 and @fade_active == false and @rage_active == false
                plains = BSR::WEATHER[BSR::PLAINS].values
                #use special Fade or Rage features here if weather_type != 0
                if $game_screen.weather_type != 0
                  if $game_screen.power? > 25
                    @fade_active = true #Make the weather fade out a little.
                    update
                  elsif $game_screen.power? <= 25
                    @rage_active = true #Make the weather get heavier/harsher
                    update
                  end
                end
                #Otherwise, create a random weather effect at low power!
                n_weather = plains[rand(plains.size - 1)]
                $game_screen.weather(n_weather, rand(10), rand(9) + 1)
              end
            elsif line0.include?(BSR::FOREST)
              @count = (@count + 1) % 1400
              if @count == (rand(99) + 1) + 100 and @fade_active == false and @rage_active == false
                forest = BSR::WEATHER[BSR::FOREST].values
                #use special Fade or Rage features here if weather_type != 0
                if $game_screen.weather_type != 0
                  if $game_screen.power? > 25
                    @fade_active = true #Make the weather fade out a little.
                    update
                  elsif $game_screen.power? <= 25
                    @rage_active = true #Make the weather get heavier/harsher
                    update
                  end
                end
                #Otherwise, create a random weather effect at low power!
                n_weather = forest[rand(forest.size - 1)]
                $game_screen.weather(n_weather, rand(10), rand(9) + 1)
              end
            elsif line0.include?(BSR::DESERT)
              @count = (@count + 1) % 1400
              if @count == (rand(99) + 1) + 100 and @fade_active == false and @rage_active == false
                desert = BSR::WEATHER[BSR::DESERT].values
                #use special Fade or Rage features here if weather_type != 0
                if $game_screen.weather_type != 0
                  if $game_screen.power? > 25
                    @fade_active = true #Make the weather fade out a little.
                    update
                  elsif $game_screen.power? <= 25
                    @rage_active = true #Make the weather get heavier/harsher
                    update
                  end
                end
                #Otherwise, create a random weather effect at low power!
                n_weather = desert[rand(desert.size - 1)]
                $game_screen.weather(n_weather, rand(10), rand(9) + 1)
              end
            elsif line0.include?(BSR::ARCTIC)
              @count = (@count + 1) % 1400
              if @count == (rand(99) + 1) + 100 and @fade_active == false and @rage_active == false
                arctic = BSR::WEATHER[BSR::ARCTIC].values
                #use special Fade or Rage features here if weather_type != 0
                if $game_screen.weather_type != 0
                  if $game_screen.power? > 25
                    @fade_active = true #Make the weather fade out a little.
                    update
                  elsif $game_screen.power? <= 25
                    @rage_active = true #Make the weather get heavier/harsher
                    update
                  end
                end
                #Otherwise, create a random weather effect at low power!
                n_weather = arctic[rand(arctic.size - 1)]
                $game_screen.weather(n_weather, rand(10), rand(9) + 1)
              end
            elsif line0.include?(BSR::OCEAN)
              @count = (@count + 1) % 1400
              if @count == (rand(99) + 1) + 100 and @fade_active == false and @rage_active == false
                ocean = BSR::WEATHER[BSR::OCEAN].values
                #use special Fade or Rage features here if weather_type != 0
                if $game_screen.weather_type != 0
                  if $game_screen.power? > 25
                    @fade_active = true #Make the weather fade out a little.
                    update
                  elsif $game_screen.power? <= 25
                    @rage_active = true #Make the weather get heavier/harsher
                    update
                  end
                end
                #Otherwise, create a random weather effect at low power!
                n_weather = ocean[rand(ocean.size - 1)]
                $game_screen.weather(n_weather, rand(10), rand(9) + 1)
              end
            end
          end
        end
      end
    elsif @weather_on == false
      memorize_weather
    end
  end
end

class Game_Screen
  alias brkn_init initialize
  def initialize
    @power = 0
    brkn_init
  end
  
  def weather(type, power, duration)
    @weather_type_target = type
    if @weather_type_target != 0
      @weather_type = @weather_type_target
      @power = power
    end
    if @weather_type_target == 0
      @weather_max_target = 0.0
    else
      @weather_max_target = (power + 1) * 4.0
    end
    @weather_duration = duration
    if @weather_duration == 0
      @weather_type = @weather_type_target
      @weather_max = @weather_max_target
    end
  end
  
  def power?
    return @power
  end
end

Instructions

Easy as pie. All you have to do is paste the script above Main. Here is how to use Memorize and Restore:

To effectively use Memorize, go into an event that transports the player to an inside map. After adding Prepare for Transition, add Call Script: Scene_Map.memorize_weather.​
Then transport the player and use Execute Transition. (WILL ONLY WORK IF YOU HAVE NOTHING MEMORIZED YET!)

To effectively use Restore, go into an event that transports the player to an outside map. After adding Prepare for Transition, add Call Script: Scene_Map.restore_weather.​
Then transport the player and use Execute Transition. (WILL ONLY WORK IF YOU HAVE USED MEMORIZE!)

FAQ

Q: What does Random mean?
A: ... ... ...

Q: Which Weather Effects does this have?
A: Every one of Ccoa's Weather Script weather effects!

Q: How do I...?
A: How do you what?

Compatibility

I know it works with f0tz!baerchen's AntiLag script, but that's all I have tested it with. You MUST have Ccoa's Weather Script to make this work!

RandWeather only alters Scene_Map's initialize and update methods, and gives it new methods. It also changes Game_Screen's initialize and adds the method power?.

Credits and Thanks

Credit me, Ccoa, and if you so feel the need, SephirothSpawn, who I indirectly got my Event Checking code snipets from!

Author's Notes

Next Release: Already Out!
New Features: Above if I mentioned them!
I am taking requests for add ons, clean ups, whatever! But be polite and patient. I may not accept to do any if I so wish.

Future/Planned Features:

1. Screen Tinting based on weather (clear weather = normal, sunny = bright, rainy = dark, etc.)

2. possible use of fogs (overlapping Map Fogs if possible!)

3. Easily add new Random Weather Effects (Blood Rain, anyone?)

4. Regionalized Weather ('Forest' = RAIN, 'Desert' = Sand Storm, etc.) COMPLETE

5. Weather Fade into other weather at command call. For example, Rain can turn to now by using Scene_Map.fade_to('Rain', 'Snow'). Something along these lines.

Peace!
 

OS

Sponsor

Added SUN constant that allows for normal weather to occur more often than rain.

Planning Ragional Weather Setup for later.

Peace Out!

~Broken
 

OS

Sponsor

That last post was from todasy. I posted the script yesterday. Didn't think it counted if it was an update. Sorry though, Thanks for replying!

Peace Out!

~Broken
 

Mac

Member

Oh wait, yeah sorry..i forgot that updates are allowed...my mistake, i apologise.

I will check this more out tomorrow.
 
There should be overcast - just use a grey fog. Then it could fade into drizzle, then rain, storm and then clear. Not exactly the Australian cycle of weather, but anyways.

Q. Does it use BGM's to compliment the weather effects? If so, how do you change them? (If not, can you please add that too!)

Thanks, I've been looking for a script like this, hope it works well with Kylock's Time System.:)

Thanks again,

Samboy
 

OS

Sponsor

@samboy: My script does play BGS's, but to change them you must go into the script and find the proper lines. Later I might redesign my RATE hash to hold BGS as well, so you can change them with ease.

I might add the use of fogs when I learn more about graphics handling, though.

And lastly, I think that when Weather becomes Sunny or clear, my script turns off all BGS's. This may affect Back Ground Sounds not related to the script. I will change this later so that only the sound used in the script is affected.

Peace Out!

~Broken

EDIT:

Added list of Future Features in first post! Tell me what you all think!
 

OS

Sponsor

I need to know which Regions you want for the next version?

So far I have:

ALL
PLAINS
FOREST
DESERT

What else should I add?

Peace!

~Broken
 
Wow! Cool script... But does it begin to change weather ffects even if yout in a house or something? Just wondering. Becouse that would be funny. XD
 

OS

Sponsor

You must turn the rand_weather_on variable false with a method in the script just before entering. Use Memorize and Restore methods as described in my post above!
 

OS

Sponsor

Fixed. Sorry 'bout that. It was a minor error (I forgot to declare the methods I was aliasing.) Thanks for telling me 'bout the error. Peace!
 
Status
Not open for further replies.

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top