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 v7.0

OS

Sponsor

Thanks! Seeing so many posts in my thread in a row by me was kind of making me feel down. Thanks for the pick-me-up!

Now, I have the Time System almost finished. It has tinting based on hour, the ability to rewind time while the player is able to play, and it runs really smooth.

The weather system is just getting started. It is already plug-in capable, so technically all I have to do is create the part where weather changes, and it will be ready for pre-plug-ins release! YAY!

I can't be certain, but I think by the end of the week I'll have Weather 7.0 release 1 ready to go.

Peace!
 
YAY! To be honest, I think I'll test it out for you. Oh, I am SO looking forward to this script, especially the panorama layering feature, you will go down in history if you make this!!!
 

OS

Sponsor

Hmmm...somehow that sounds very familiar to me...

Thanks for your support! I'll show you the time system when I finish the Reverse Method. Peace!
 

OS

Sponsor

Here ya go! A sample of the time system. It is fully capable of moving forward and back, with the ability to change tone. It requires the weather class, but that thing is empty atm. I'm just showing you this to prove that I am still working hard on it!

Code:
class Game_Time
  def initialize
    #Current Time = Hour, Minute, Second
    @hour, @minute, @second = OS::T_StartHour, OS::T_StartMinute, 0
    #Current Time = Day, Month, Year
    @day, @month, @year = OS::T_StartDay, OS::T_StartMonth, OS::T_StartYear
    #Speeds
    @sbase = OS::T_Speed
    @sfast = OS::T_Speed * 10
    @sslow = OS::T_Speed / 10
    @speed = @sbase
    #Switches and 0's
    @frame = 0
    @reverse = false
    @pause = false
    @pm = false
    #Tint
    @tone = create_new_tone
    $game_screen.start_tone_change(@tone,1)
  end
  
  def time?
    string = sprintf("%02d:%02d:%02d", hour?, @minute, @second)
    string += " #{@month}-#{@day}-#{@year}"
    return string
  end
  
  def hour?(base=12)
    if base == 24
      return @hour
    elsif base == 12
      return @hour > OS::T_MaxHours ? @hour - 12 : @hour
    else
      return 0
    end
  end
  
  def create_new_tone
    case @hour
    when 1
      return Tone.new(-90,-90,-90,0)
    when 2
      return Tone.new(-80,-80,-80,0)
    when 3
      return Tone.new(-70,-70,-70,0)
    when 4
      return Tone.new(-60,-60,-60,0)
    when 5
      return Tone.new(-50,-50,-50,0)
    when 6
      return Tone.new(-40,-40,-40,0)
    when 7
      return Tone.new(-30,-30,-30,0)
    when 8
      return Tone.new(-20,-20,-20,0)
    when 9
      return Tone.new(-10,-10,-10,0)
    when 10
      return Tone.new(0,0,0,0)
    when 11
      return Tone.new(10,10,10,0)
    when 12
      return Tone.new(20,20,20,0)
    when 13
      return Tone.new(10,10,10,0)
    when 14
      return Tone.new(0,0,0,0)
    when 15
      return Tone.new(-10,-10,-10,0)
    when 16
      return Tone.new(-20,-20,-20,0)
    when 17
      return Tone.new(-30,-30,-30,0)
    when 18
      return Tone.new(-40,-40,-40,0)
    when 19
      return Tone.new(-50,-50,-50,0)
    when 20
      return Tone.new(-60,-60,-60,0)
    when 21
      return Tone.new(-70,-70,-70,0)
    when 22
      return Tone.new(-80,-80,-80,0)
    when 23
      return Tone.new(-90,-90,-90,0)
    when 24
      return Tone.new(-100,-100,-100,0)
    end
  end
  
  def update
    if @reverse
      update_back
    else
      update_forward
    end
    return
  end
  
  def update_back
    @frame += 1
    if @frame == @speed
      @frame = 0
      @second -= 1
    end
    if @second == 0
      @second = OS::T_MaxSeconds
      @minute -= 1
    end
    if @minute == 0
      @minute = OS::T_MaxMinutes
      @hour -= 1
    end
    if @hour == 0
      @hour = OS::T_MaxHours
    end
    @tone = create_new_tone
    $game_screen.start_tone_change(@tone,1)
    type = $game_world.weather.type
    power = $game_world.weather.power
    $game_screen.weather(type, power, rand(19)+1)
    return
  end
  
  def update_forward
    @frame += 1
    if @frame == @speed
      @frame = 0
      @second += 1
    end
    if @second == OS::T_MaxSeconds
      @second = 0
      @minute += 1
    end
    if @minute == OS::T_MaxMinutes
      @minute = 1
      @hour += 1
    end
    if @hour == OS::T_MaxHours
      @hour = 1
      @day = new_day
    end
    if @day[0] = OS::T_Days[OS::T_Days.size - 1]
      @day[0] = OS::T_Days[0]
      @day[1] += 1
    end
    #if @day[1] == OS::T_Months[OS::T_Months.index(@month)][1]
      #@day[1] = 1
      #@month = OS::T_Months[OS::T_Months.index(@month)+1]
    #end
    #if @month == OS::T_Months[OS::T_Months.size - 1]
      #@month = OS::T_Months[0]
      #@year += 1
    #end
    @tone = create_new_tone
    $game_screen.start_tone_change(@tone,1)
    type = $game_world.weather.type
    power = $game_world.weather.power
    $game_screen.weather(type, power, rand(19)+1)
    return
  end
end

Now I am working on making Days and Months run perfectly, and setting up Seasons! Peace!
 

OS

Sponsor

BUMP: It's the big day! The system is finally presentable, Time, Weather and all!

Check the first post for Weather System v7.0 Plug-In Compatible today!
 
Just wanted to say, playtested, and it works fine :').

However as a n00b scripter, I assume there'll be more documentation in time on how to implement/customize this better? Otherwise I fear you'll be receiving 1.2 million posts from people saying, "i cnt get thiss to wurk plz my screan is dark plz help".

I know they'll come in time no matter what anyone does, but maybe this'll curb the first few.

;')
 

OS

Sponsor

Yeah, I'll be adding more comments while I start making the plug-ins.

The very first plug-in I want to make is the Panorama Layer Weather Effects plug-in (probably needs a better name?). See ya!
 

OS

Sponsor

Panorama Layer Effects now released, and FULLY FUNCTIONAL! Unlike the version 7.0, which appears to have a slight bug, the Panorama Script works perfectly. I tested it three times, and each time, it moved smoothly, flawlessly, from above the tileset to below it!

Use this tileset to test it out:

View attachment 2655

Be sure to use the windows that I edited when testing. I'M SO EXCITED. This little bit has been buggin me all week, and it turns out all I had to do was manipulate a tiny little Z value of several hundred sprites! No problem!

Enjoy.
 

OS

Sponsor

Alrighty! Version 7.1 of the module is complete and will be released as soon as the Game_Weather 7.1 is finished, which will be by Wednesday. It works almost perfectly: I need to fix the Tone Bug (the screen gets darker every time the weather changes, which right now is every second to ensure that it works...) and the UpDown Bug (the script won't upgrade or downgrade weather correctly...)

These are minor bugs. I assure you all that this version of the script is producing random weather, and in every test. Peace!
 
I... hate to be the asshole begging the script maker for a demo, but...could you please make a demo for me? And when I say me, I really mean us. The community.

EDIT: I tried to make one, but failed miserably. Come up with an error:

http://img154.imageshack.us/img154/5861/errorid4.png[/IMG]


Anyways, here's a link to the (failed) demo.

Thanks so much.
 

OS

Sponsor

Haha. You don't want this version, do you? I'm writing version 7.2 (yes, yet an other upgrade), with guaranteed results. It seems the 7.0 had a bug in which weather wouldn't actually generate, and 7.1 had a bug in which tone changes based on weather caused the screen to darken all the way.

7.2 won't have tone changes just yet, but it will have better features, and just because you asked, a demo with all the possible functions. I'll post as soon as it's done. Peace!
 

OS

Sponsor

Nah, I'm still gonna make the Demo. It'll be fun. I haven't made many events or maps recently, so it'd be nice.
 

OS

Sponsor

Hey, everyone! I have an idea!

I set up the newest edition of my script to use the F5, F6, and F7 keys to Memorize the current weather, launch memorized weather, and end the current weather effects respectively. This feature only works in DEBUG mode.

Sounds cool, huh? Well, what about this: I can create a Universal Weather Cycle Button that will allow you to press a key to change weather. It would cycle between all the weather available to a particular map without editing from the developer, so your lives are made easier! Chya! Now, what do you think? If you have any ideas for more DEBUG-only features let me know!

Come to think of it, I could make it so that holding shift and F5 forces a menu to open with a list of all of the available weather effects, and maybe even a Power menu for setting the strength of the weather. Just imagine how this will help when testing, eh?

Peace!

EDIT: I forgot to mention, I am using Game_System this time around so that you don't have to alter Scene_Title or Scene_Map. Game_System is also set to save by default, so your weather can be saved as well. Weather is still in its own class, but an instance of OS::Weather is placed in instance variable weather inside Game_System. Game_System also updates the weather and holds some methods for changing the weather and a new update_input method to get the F Key Functions. Hope that works out for you all when it is done.
 

OS

Sponsor

Haha. You are right. I tried to make the menu, and it turns out the most efficient way is to make an entirely new scene. So I'm just sticking with my first three buttons.

ALMOST READY! Woo!

EDIT: Guess what? 7.2 will be released today! It is finished, so all I have to do is add the comments and make the demo. YAY!
 

OS

Sponsor

Use the Demo to see how it all works!

Script:
Code:
#===============================================================================
# Module OS
# By OS
#===============================================================================
# Holds the base of the Weather Script, including the following methods:
# NOTE: () means NEW, (*) means editted.
#
# (*) Initialize
# (*) Update
# () End Weather
# (*) Memorize
# (*) Launch
# (*) Gen Weather
# (*) Upgrade
# (*) Downgrade
# (*) Fix Tone
# () Fix Power
#===============================================================================
# To use the script:
#
# Place above main and below Scene_Debug. For Inner Support, go to www.rmxp.org
# to find the RPG::Weather Inners Edit by OS.
#
# While in Test Play, you can press F5 to memorize the current weather,
# F6 to launch memorized weather, and F7 to terminate the current weather.
#
# Terminating weather with F7 also stops weather effects from continuing.
# To allow weather to continue again, do this:
#
# Use $game_system.weather.allowed = true in a Call Script event.
#
# To stop weather without pressing a button, use
# $game_system.weather.allowed = false
# in a call script command.
#
# To use weather effects to change events, use:
# if $game_system.weather.type == 1
# in a Conditional Branch Script command. Replace 1 with the Weather Effect Type
# of your choice.
#
# To change the weather using the script, use
# $game_system.new_weather(type)
# in a Call Script command.
#
# You can also decide the power like this:
# $game_system.new_weather(type,power)
# Not providing a power will cause the script to create a random power for you.
#
# One last note: Fix Tone still isn't perfect. I'm working diligently to fix the
# problem, though.
#
# If you have any questions, advice, ideas, errors, etc. PM me or e-mail me
# at rusu.arc@gmail.com. Peace!
#===============================================================================
module OS
  # The Weather Effects per Map
  Weathers = {
  #Map_ID => [Type, Type, etc.]
  1 => [1,2,3],
  2 => [1,2,3]
  }
  # The max amount of frames between weather changes
  W_MaxCount = 100
  # The Upgrade Links
  Upgrade = {
  #StartType => UpgradeType
  1 => 2
  }
  # The Downgrade Links
  Downgrade = {
  #StartType => DowngradeType
  2 => 1
  }
  # The Tones for each wetaher effect:
  Tones = {
  #Type => [red,green,blue,gray] modifiers
  0 => [0,0,0,0],
  1 => [0,0,-10,0],
  2 => [0,0,-20,0]
  }
  # Inners
  # RPG::Weather Inners Edit by OS required to use Inner Support
  W_Inners = [
  #InnerMap_ID
  2
  ]
  #=============================================================================
  # Class Weather
  # By OS
  #=============================================================================
  class Weather
    # Attribute Writers and Readers
    attr_accessor :type, :power, :weathers, :allowed
    # Initialize
    def initialize
      # Type
      @type = 0
      # Power
      @power = 0
      # Memorized Weather Effects 
      @memorized = []
      # Weathers available in the current map
      @weathers = []
      # The current map id
      @map_id = 0
      # Randomly selected frame count using W_MacCount
      @count = rand(W_MaxCount - 1) + 1
      # Weather Affects Allowed
      @allowed = true
    end
    # Update
    def update
      # If weather effects are allowed
      if @allowed == true
        # And if the map id is different than the current map
        if @map_id != $game_map.map_id
          # Fix the map id and current weathers
          @map_id = $game_map.map_id
          @weathers = Weathers[@map_id]
        end
        # Count Down
        @count -= 1
        # If count reaches 0
        if @count <= 0
          # Reset Count randomly
          @count = rand(W_MaxCount - 1) + 1
          # Generate Weather
          gen_weather
        end
        # Fixes power so it isn't above 50
        fix_power
        # Fix Tone (Not perfect yet)
        fix_tone
        # Set weather effects
        $game_screen.weather(@type,@power,rand(19) + 1)
      end
      return
    end
    # Fix Power
    def fix_power
      if @power >= 50
        @power = 0
        while @power <= 40
          @power = rand(49) + 1
        end
      elsif @power <= 0
        @power = rand(9) + 1
      end
    end
    # Gen Weather
    def gen_weather
      # If the current weather type is 0 (No Weather)
      if @type == 0
        # Creates a random weather effect based on @weathers
        @type = @weathers[rand(@weathers.size - 1)]
        # Randomly generated power
        @power = rand(19) + 1
        # Allow for fix_tone to run
        @tone = true
        return
      # Or if the current weather is not 0
      else
        # If power is high and random value is high
        if @power >= 40 and rand(9) + 1 > 6
          # Upgrade to stronger weather
          upgrade
          return
        # Or if power is low and random value is high
        elsif @power <= 20 and rand(9) + 1 > 6
          # Downgrade to weaker weather
          downgrade
          return
        # Or else:
        else
          # Just change power
          if rand(9) + 1 > 6
            @power += rand(9) + 1
          else
            @power -= rand(9) + 1
          end
          return
        end
      end
    end
    # Upgrade
    def upgrade
      if Upgrade.keys.include?(@type)
        if rand(9) + 1 >= 6
          @type = Upgrade[@type]
          @power = rand(19) + 1
          @tone = true
        end
      end
      return
    end
    # Downgrade
    def downgrade
      if Downgrade.keys.include?(@type)
        if rand(9) + 1 >= 6
          @type = Downgrade[@type]
          @power = 0
          while @power <= 30
            @power = rand(49) + 1
          end
          @tone = true
        end
      end
      return
    end
    # End Weather
    def end_weather
      @allowed = false
      @type = 0
      @power = 0
      $game_screen.weather(@type,@power,0)
      return
    end
    # Memorize
    def memorize
      @memorized = [@type, @power]
      return
    end
    # Launch
    def launch
      if !@memorized.empty?
        @type = @memorized[0]
        @power = @memorized[1]
        @tone = true
      end
      return
    end
    # Fix Tone
    def fix_tone
      if @tone == true
        red = $game_screen.tone.red + Tones[@type][0]
        green = $game_screen.tone.green + Tones[@type][1]
        blue = $game_screen.tone.blue + Tones[@type][2]
        gray = $game_screen.tone.gray + Tones[@type][3]
        $game_screen.start_tone_change(Tone.new(red,green,blue,gray),20)
        @tone = false
      end
      return
    end
  end
end
#===============================================================================
# Game_System
# For ease of use. Added methods for easier access to the Weather Script.
#
# (*) Initialize
# (*) Update
# () Weather=(type,power)
# () Weather?
# () Update Input
#===============================================================================
class Game_System
  attr_accessor :weather
  alias os_init initialize
  alias os_updt update
  def initialize
    os_init
    @weather = OS::Weather.new
  end
  
  def update
    @weather.update
    update_input
    os_updt
    return
  end
  
  def new_weather(type,power=-1)
    @weather.type = type
    @weather.power = power == -1 ? (rand(19) + 1) : power
    return
  end
  
  def weather?
    return @weather.type
  end
  
  def update_input
    if $DEBUG
      if Input.trigger?(Input::F5)
        @weather.memorize
        return
      elsif Input.trigger?(Input::F6)
        @weather.launch
        return
      elsif Input.trigger?(Input::F7)
        @weather.end_weather
        return
      end
    end
    return
  end
end

I'm sorry about not finishing the comments, but I got bored. Demo is at the top of the post. The script has the instructions. This is the Core 7.2. Not all plug-ins are available for this version yet. Enjoy!
 

OS

Sponsor

What errors!? I never got any...I'll go look at it real quick...

EDIT: haha. My bad. Take the ifs out of the conditionals. Instead of it saying 'if $game_system.blahblah' it should say '$game_system.blahblah'.

Sorry about that.

EDIT2: Demo Fixed.
 

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