The RPG Maker Resource Kit

RMRK RPG Maker Creation => VX => VX Scripts Database => Topic started by: Fall From Eden on March 17, 2012, 08:13:16 PM

Title: Rain Candy
Post by: Fall From Eden on March 17, 2012, 08:13:16 PM
Rain Candy
Version: 1.0
Author: Marc of Fall From Eden
Date: March 17, 2012

Version History




Description



This script creates a more aesthetically-pleasing rain effect than the one provided by RMVX. In other words, it's pure eye candy. ;)

Features


Screenshots

(https://rmrk.net/proxy.php?request=http%3A%2F%2Fdl.dropbox.com%2Fu%2F7444326%2FRGSS2%2FPictures%2FRain%2520Candy%25201.png&hash=cb5f5155d04cdc021a3dbd16ee145f6bd7126f2d)

Instructions

This script makes use of the default way RMVX handles weather. As such, all you need to do is set weather effects the way you normally would, and the intensity of the rain effect will adjust accordingly. If you want to change any of the default values used, simply modify their related constants in the Marc::Weather module of the script.

Script



This script requires an image to display for the rain effect. The image included in the demo (http://dl.dropbox.com/u/7444326/RGSS2/Pictures/rain.png) is one we created for the effect, but this image (http://www.mediafire.com/?yzap3criknm4324) created by ak47lol for their "realistic rain" tutorial works just as well (if not better). ;)

If you use ak47lol's rain image, please be sure to credit them!


# ============================================================================ #
# Rain Candy v1.0 by Marc (of Fall From Eden)                                  #
# This script is licensed under the Creative Commons BY-SA 3.0 license.        #
# ============================================================================ #
# DESCRIPTION                                                                  #
# ---------------------------------------------------------------------------- #
# This script creates a more aesthetically-pleasing rain effect than the one   #
# provided by RMVX. In other words, it's pure eye candy. ;)                    #
# ============================================================================ #
# USAGE INSTRUCTIONS                                                           #
# ---------------------------------------------------------------------------- #
# This script makes use of the default way RMVX handles weather. As such, all  #
# you need to do is set weather effects the way you normally would, and the    #
# intensity of the rain effect will adjust accordingly. If you want to change  #
# any of the default values used, simply modify their related constants in the #
# Marc::Weather module below.                                                  #
# ============================================================================ #

module Marc
  module Weather
    # Set RAIN_FILE to the picture you want to use for the rain effect.
    RAIN_FILE = "rain"
    # RAIN2_FILE is the file to display underneath RAIN_FILE; this creates a
    # more visually pleasing effect, as RAIN2_FILE subtracts from RAIN_FILE.
    RAIN2_FILE = RAIN_FILE
    # The tone you want rain to be. Set as Tone.new(red, green, blue, gray).
    RAIN_TONE = Tone.new(0, 0, 128, 75)
    # Determine the zoom levels of RAIN_FILE and RAIN2_FILE here. 1.0 is 100%,
    # 2.0 is 200%, and so on.
    RAIN_ZOOM = 1.0
    RAIN2_ZOOM = 1.5
  end
end # module Marc::Weather

# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! #
# !                      DO NOT EDIT BEYOND THIS POINT.                      ! #
# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! #

# ============================================================================ #
# Spriteset_Weather                                                            #
# ---------------------------------------------------------------------------- #
# Aliased methods: initialize, update, dispose, type=                          #
# New methods: dispose_weather_planes                                          #
# ============================================================================ #
class Spriteset_Weather
  alias marc_rain_spriteset_weather_initialize initialize
  def initialize(viewport = nil)
    @type, @max, @ox, @oy = 0
    @rain_bitmap, @storm_bitmap = nil
    @weather_plane = Plane.new(viewport)
    @weather_plane2 = Plane.new(viewport)
    @weather_plane2.blend_type = 2
    @weather_plane.zoom_x = Marc::Weather::RAIN_ZOOM
    @weather_plane.zoom_y = Marc::Weather::RAIN_ZOOM
    @weather_plane2.zoom_x = Marc::Weather::RAIN2_ZOOM
    @weather_plane2.zoom_y = Marc::Weather::RAIN2_ZOOM
    marc_rain_spriteset_weather_initialize
  end # initialize
 
  alias marc_rain_spriteset_weather_update update
  def update
    return if @type == 0
    case @type
    when 1
      @weather_plane.opacity = (@max * 4)
      @weather_plane2.opacity = (@max * 3)
      @weather_plane.ox += (@max / 9).to_i
      @weather_plane.oy -= 8
      @weather_plane2.ox += (@max / 6).to_i
      @weather_plane2.oy -= 6
    when 2
      @weather_plane.opacity = (@max * 5)
      @weather_plane2.opacity = (@max * 4)
      @weather_plane.ox += (@max / 6).to_i
      @weather_plane.oy -= 16
      @weather_plane2.ox += (@max / 4).to_i
      @weather_plane2.oy -= 12
    else
      dispose_weather_planes
    end
    marc_rain_spriteset_weather_update
  end # update
 
  alias marc_rain_spriteset_weather_dispose dispose
  def dispose
    dispose_weather_planes
    marc_rain_spriteset_weather_dispose
  end # dispose
 
  def dispose_weather_planes
    unless @weather_plane.bitmap.nil? or @weather_plane2.bitmap.nil?
      @weather_plane.bitmap.dispose
      @weather_plane2.bitmap.dispose
    end
  end # dispose_weather_planes
 
  alias marc_rain_spriteset_weather_type type=
  def type=(type)
    return if @type == type
    if type == 1 or type == 2
      @type = type
      for sprite in @sprites
        sprite.bitmap = nil
      end
      @weather_plane.bitmap = Cache.picture(Marc::Weather::RAIN_FILE)
      @weather_plane2.bitmap = Cache.picture(Marc::Weather::RAIN2_FILE)
      @weather_plane.tone = Marc::Weather::RAIN_TONE
    else
      dispose_weather_planes
      marc_rain_spriteset_weather_type(type)
    end
  end # type=
end # class Spriteset_Weather


Credit




Thanks


Support



You may receive support for this script in this topic or by sending us a personal message on these forums.

Known Compatibility Issues

This script only modifies Spriteset_Weather, so it should be compatible with just about anything except another script which affects how weather is drawn or handled.

Demo



Rain Candy Demo (http://dl.dropbox.com/u/7444326/RGSS2/Demos/Marc%20Rain%20Candy.exe)
There's nothing to demonstrate, but if you want to see the effect.... ;)

Author's Notes



This script was inspired by a topic we recently viewed about creating "realistic rain" on VX.net written by ak47lol. Marc then decided to script in a similar effect that makes use of RMVX's default weather effects (and how they are set) to keep things as simple as possible for the end-user. :)

(We might also be using this in our own game, but that's beside the point on this one.) :P

Restrictions

:ccbysa:
This script is licensed under a Creative Commons BY-SA 3.0 license. Essentially, you may use it for commercial games, but proper attribution is required; as well, you may modify the script any way you like as long as the modified version retains attribution to the original author and is released under an identical license.
Title: Re: Rain Candy
Post by: Acolyte on March 17, 2012, 09:26:32 PM
I thought this was a script for raining down candy from the sky. I am disappoint.  :mad:

But cool normal rain.
Title: Re: Rain Candy
Post by: Fall From Eden on March 17, 2012, 10:35:42 PM
You know, you could always change the rain graphic to candy. :D