天候の追加



雨、嵐、雪以外の天候エフェクトを作ってみたい・・・ってか血の雨を降らせて見たい、赤い雪を降らせて見たい
それだけじゃなく、画像も降らせて見たいぞ〜〜〜ってな人に推奨。ちなみに各colorを変更することによって
カラフルな雨、雪を降らせることも可能です。(追加、変更をしてさらに天候を増やすことも可能だね。)

現在、吹雪、血の雨、血の嵐、赤い雪、赤い吹雪、桜吹雪、紅葉、雹、血の雹、霙、血の霙、氷雨、血の氷雨、
黒い雨、お札という天候(?)があります。

貪藻矢射妥←ダイヤモンドベースモジュールが必要です。

変更点
2005:10:27
 桜吹雪、紅葉を追加

2005:10:28
 雪を画像にするかどうかを設定可能に
 桜吹雪、紅葉の降らせる画像パターンを増やした
 無駄な行を省いてみた

2006:03:15
 雹、霙を追加

2006:03:22
 雪の画像タイプを廃棄
 無駄な行を省いてみた

2006:03:26
 氷雨、黒い雨、お札を追加
 無駄な行を省いてみた
 霙の雨の部分のアルファ値を128に修正
 雪の降らせ方を変更できるように修正

2008:12:24
 カスタマイズポイントを追加
 天候の画像の最大数を変更可能に

2010:12:04
・微修正

#==============================================================================
# 天候の追加 By 貪藻矢射妥←
#------------------------------------------------------------------------------
# 天候は以下の通り。イベントのスクリプトで呼び出そう。(1〜3は省略)
# 
# 吹雪      $game_screen.weather( 4, 強さ(1〜9), ウェイト)
# 血の雨    $game_screen.weather( 5, 強さ(1〜9), ウェイト)
# 血の嵐    $game_screen.weather( 6, 強さ(1〜9), ウェイト)
# 赤い雪    $game_screen.weather( 7, 強さ(1〜9), ウェイト)
# 赤い吹雪  $game_screen.weather( 8, 強さ(1〜9), ウェイト)
# 桜吹雪    $game_screen.weather( 9, 強さ(1〜9), ウェイト)
# 紅葉      $game_screen.weather(10, 強さ(1〜9), ウェイト)
# 雹        $game_screen.weather(11, 強さ(1〜9), ウェイト)
# 血の雹    $game_screen.weather(12, 強さ(1〜9), ウェイト)
# 霙        $game_screen.weather(13, 強さ(1〜9), ウェイト)
# 血の霙    $game_screen.weather(14, 強さ(1〜9), ウェイト)
# 氷雨      $game_screen.weather(15, 強さ(1〜9), ウェイト)
# 血の氷雨  $game_screen.weather(16, 強さ(1〜9), ウェイト)
# 黒い雨    $game_screen.weather(17, 強さ(1〜9), ウェイト)
# お札      $game_screen.weather(18, 強さ(1〜9), ウェイト)
# 
# ※強さは実際には 0<n<=9 ならば何でもいいハズ。
# 
#==============================================================================
# 更新っぽいもの
# 2005:10:27
# ・桜吹雪、紅葉を追加
# 
# 2005:10:28
# ・雪を画像にするかどうかを設定可能に
# ・桜吹雪、紅葉の降らせる画像パターンを増やした
# ・無駄な行を省いてみた
# 
# 2006:03:15
# ・雹、霙を追加
# 
# 2006:03:22
# ・雪の画像タイプを廃棄
# ・無駄な行を省いてみた
# 
# 2006:03:26
# ・氷雨、黒い雨、お札を追加
# ・無駄な行を省いてみた
# ・霙の雨の部分のアルファ値を128に修正
# ・雪の降らせ方を変更できるように修正
# 
# 2008:12:24
# ・カスタマイズポイントを追加
# ・天候の画像の最大数を変更可能に
# 
# 2010:12:04
# ・微修正

module W_RT
  include BM
  # 雪、吹雪を直線的に降らすかゆらゆらさせるか。(true:ゆらゆら false:直線)
  # 霙の場合、雨で水分を含むのでゆらゆらさせないようにしてます。
  # (設定が面倒ってな理由もあったり・・・)
  LQD_FLG = false
  # 読み込む画像
  W_CG = "sakura.png"
  # 雪の色
  SNOW_COLOR1    = Color.new(255, 255, 255, MAX8BIT)
  SNOW_COLOR2    = SNOW_COLOR1.clone
  SNOW_COLOR2.alpha = HARF8BIT
  # 雨の色
  RAIN_COLOR1    = Color.new(192, 255, 255, MAX8BIT)
  RAIN_COLOR2    = Color.new(200, 255, 255, MAX8BIT)
  RAIN_COLOR3    = RAIN_COLOR1.clone
  RAIN_COLOR3.alpha = HARF8BIT
  # 血の雨の色
  BLOOD_COLOR1   = Color.new(192,   0,   0, MAX8BIT)
  BLOOD_COLOR2   = Color.new(200,   0,   0, MAX8BIT)
  BLOOD_COLOR3   = BLOOD_COLOR1.clone
  BLOOD_COLOR3.alpha = HARF8BIT
  # 血の氷の色
  C_BLOOD_COLOR1 = Color.new(200, 100, 100, MAX8BIT)
  C_BLOOD_COLOR2 = C_BLOOD_COLOR1.clone
  C_BLOOD_COLOR2.alpha = HARF8BIT
  # 黒い雨の色
  BLACK_COLOR    = Color.new(  0,   0,   0, MAX8BIT)
  # オブジェクトの最大値基礎
  # 通常は4.0
  OBJ_MAX = 12.0
  # 画像の基本サイズ
  CG_SIZE = 24
  # 霙とかの雨/雪比率の雨の比率
  RAIN_RATE = 2
  # 霙とかの雨/雪比率の雪の比率
  SNOW_RATE = 3
end

#==============================================================================
# ■ Game_Screen
#------------------------------------------------------------------------------
#  色調変更やフラッシュなど、画面全体に関係する処理のデータを保持するクラスで
# す。このクラスのインスタンスは $game_screen で参照されます。
#==============================================================================

class Game_Screen
  include W_RT
  #--------------------------------------------------------------------------
  # ● 天候の設定
  #     type     : タイプ
  #     power    : 強さ
  #     duration : 時間
  #--------------------------------------------------------------------------
  def weather(type, power, duration)
    @weather_type_target = type
    if @weather_type_target != 0
      @weather_type = @weather_type_target
    end
    if @weather_type_target == 0
      @weather_max_target = 0.0
    else
      @weather_max_target = (power + 1) * OBJ_MAX
    end
    @weather_duration = duration
    if @weather_duration == 0
      @weather_type = @weather_type_target
      @weather_max = @weather_max_target
    end
  end
end

module RPG
  class Weather
    include BM
    include W_RT
    #--------------------------------------------------------------------------
    # ○ オブジェクト初期化
    #--------------------------------------------------------------------------
    def initialize(viewport = nil)
      @type = 0
      @max = 0
      @ox = 0
      @oy = 0
      @luquid = LQD_FLG
      @snowb = true
      
      # 読み込む画像の分割
      @b_re1 = Rect.new(0 * CG_SIZE, 0, CG_SIZE, CG_SIZE) # 桜の位置1
      @b_re2 = Rect.new(1 * CG_SIZE, 0, CG_SIZE, CG_SIZE) # 桜の位置2
      @b_re3 = Rect.new(2 * CG_SIZE, 0, CG_SIZE, CG_SIZE) # 銀杏の位置1
      @b_re4 = Rect.new(3 * CG_SIZE, 0, CG_SIZE, CG_SIZE) # 銀杏の位置2
      @b_re5 = Rect.new(4 * CG_SIZE, 0, CG_SIZE, CG_SIZE) # 紅葉の位置1
      @b_re6 = Rect.new(5 * CG_SIZE, 0, CG_SIZE, CG_SIZE) # 紅葉の位置2
      @b_re7 = Rect.new(6 * CG_SIZE, 0, CG_SIZE, CG_SIZE) # お札の位置
      
      # 読み込む画像
      @sh_c = RPG::Cache.picture(W_CG)
      
      # 雨の場合
      @rain_bitmap = Bitmap.new(7, 56)
      for i in 0..6
        @rain_bitmap.fill_rect(6-i, i*8, 1, 8, RAIN_COLOR1)
      end
      
      # 血の雨の場合
      @bloodrain_bitmap = Bitmap.new(7, 56)
      for i in 0..6
        @bloodrain_bitmap.fill_rect(6-i, i*8, 1, 8, BLOOD_COLOR2)
      end
      
      # 黒い雨の場合
      @blackrain_bitmap = Bitmap.new(7, 56)
      for i in 0..6
        @blackrain_bitmap.fill_rect(6-i, i*8, 1, 8, BLACK_COLOR)
      end
      
      # 嵐の場合
      @storm_bitmap = Bitmap.new(34, 64)
      for i in 0..31
        @storm_bitmap.fill_rect(33-i, i*2, 1, 2, RAIN_COLOR2)
        @storm_bitmap.fill_rect(32-i, i*2, 1, 2, RAIN_COLOR1)
        @storm_bitmap.fill_rect(31-i, i*2, 1, 2, RAIN_COLOR2)
      end
      
      # 血の嵐の場合
      @bloodstorm_bitmap = Bitmap.new(34, 64)
      for i in 0..31
        @bloodstorm_bitmap.fill_rect(33-i, i*2, 1, 2, BLOOD_COLOR2)
        @bloodstorm_bitmap.fill_rect(32-i, i*2, 1, 2, BLOOD_COLOR1)
        @bloodstorm_bitmap.fill_rect(31-i, i*2, 1, 2, BLOOD_COLOR2)
      end
      
      # 雪の場合
      @snow_bitmap = Bitmap.new(6, 6)
      @snow_bitmap.fill_rect(0, 1, 6, 4, SNOW_COLOR2)
      @snow_bitmap.fill_rect(1, 0, 4, 6, SNOW_COLOR2)
      @snow_bitmap.fill_rect(1, 2, 4, 2, SNOW_COLOR1)
      @snow_bitmap.fill_rect(2, 1, 2, 4, SNOW_COLOR1)
      
      # 赤い雪の場合
      @bloodsnow_bitmap = Bitmap.new(6, 6)
      @bloodsnow_bitmap.fill_rect(0, 1, 6, 4, BLOOD_COLOR3)
      @bloodsnow_bitmap.fill_rect(1, 0, 4, 6, BLOOD_COLOR3)
      @bloodsnow_bitmap.fill_rect(1, 2, 4, 2, BLOOD_COLOR1)
      @bloodsnow_bitmap.fill_rect(2, 1, 2, 4, BLOOD_COLOR1)
      
      # 雹の場合
      @hyou_bitmap = Bitmap.new(8, 8)
      @hyou_bitmap.fill_rect(0, 1, 8, 6, RAIN_COLOR3)
      @hyou_bitmap.fill_rect(1, 0, 6, 8, RAIN_COLOR3)
      @hyou_bitmap.fill_rect(1, 2, 6, 4, RAIN_COLOR1)
      @hyou_bitmap.fill_rect(2, 1, 4, 6, RAIN_COLOR1)
      
      # 血の雹の場合
      @bloodhyou_bitmap = Bitmap.new(8, 8)
      @bloodhyou_bitmap.fill_rect(0, 1, 8, 6, C_BLOOD_COLOR2)
      @bloodhyou_bitmap.fill_rect(1, 0, 6, 8, C_BLOOD_COLOR2)
      @bloodhyou_bitmap.fill_rect(1, 2, 6, 4, C_BLOOD_COLOR1)
      @bloodhyou_bitmap.fill_rect(2, 1, 4, 6, C_BLOOD_COLOR1)
      
      # 桜吹雪の場合
      @sakurahubuki_bitmap = Bitmap.new(48, 48)
      @sakurahubuki_bitmap.stretch_blt(Rect.new( 0,  0, 24, 24), @sh_c, @b_re1)
      @sakurahubuki_bitmap.stretch_blt(Rect.new(15,  8, 22, 22), @sh_c, @b_re2)
      @sakurahubuki_bitmap.stretch_blt(Rect.new( 6, 20, 20, 20), @sh_c, @b_re1)
      
      @sakurahubuki_bitmap2 = Bitmap.new(48, 48)
      @sakurahubuki_bitmap2.stretch_blt(Rect.new( 0,  0, 24, 24), @sh_c, @b_re1)
      @sakurahubuki_bitmap2.stretch_blt(Rect.new(15,  8, 22, 22), @sh_c, @b_re2)
      
      @sakurahubuki_bitmap3 = Bitmap.new(48, 48)
      @sakurahubuki_bitmap3.stretch_blt(Rect.new( 0,  0, 24, 24), @sh_c, @b_re1)

      # 紅葉の場合
      @kouyou_bitmap = Bitmap.new(100, 100)
      @kouyou_bitmap.stretch_blt(Rect.new( 0,  0, 32, 32), @sh_c, @b_re5)
      
      @kouyou_bitmap2 = Bitmap.new(100, 100)
      @kouyou_bitmap2.stretch_blt(Rect.new(15, 30, 30, 30), @sh_c, @b_re4)
      
      @kouyou_bitmap3 = Bitmap.new(100, 100)
      @kouyou_bitmap3.stretch_blt(Rect.new(50, 27, 30, 30), @sh_c, @b_re6)
      
      @kouyou_bitmap4 = Bitmap.new(100, 100)
      @kouyou_bitmap4.stretch_blt(Rect.new(45, 57, 26, 26), @sh_c, @b_re3)
      
      # お札の場合
      @osatu_bitmap = Bitmap.new(24, 24)
      @osatu_bitmap.stretch_blt(Rect.new( 0,  0, 24, 24), @sh_c, @b_re7)
      
      @sprites = []
      for i in 1..Integer(OBJ_MAX * 10)
        sprite = Sprite.new(viewport)
        sprite.z = 1000
        sprite.visible = false
        sprite.opacity = 0
        @sprites.push(sprite)
      end
    end
    #--------------------------------------------------------------------------
    # ○ 天候エフェクト解放
    #--------------------------------------------------------------------------
    def dispose
      for sprite in @sprites
        sprite.dispose
      end
      @rain_bitmap.dispose
      @storm_bitmap.dispose
      @snow_bitmap.dispose
      @bloodrain_bitmap.dispose
      @bloodstorm_bitmap.dispose
      @bloodsnow_bitmap.dispose
      @sakurahubuki_bitmap.dispose
      @sakurahubuki_bitmap2.dispose
      @sakurahubuki_bitmap3.dispose
      @kouyou_bitmap.dispose
      @kouyou_bitmap2.dispose
      @kouyou_bitmap3.dispose
      @kouyou_bitmap4.dispose
      @hyou_bitmap.dispose
      @bloodhyou_bitmap.dispose
      @blackrain_bitmap.dispose
      @osatu_bitmap.dispose
      @sh_c.dispose
    end
    #--------------------------------------------------------------------------
    # ○ 天候エフェクト変更
    #--------------------------------------------------------------------------
    def type=(type)
      return if @type == type
      @type = type
      case @type
      when 1 || 13 || 15
        bitmap = @rain_bitmap
      when 2
        bitmap = @storm_bitmap
      when 3
        bitmap = @snow_bitmap
      when 4
        bitmap = @snow_bitmap
      when 5 || 14 || 16
        bitmap = @bloodrain_bitmap
      when 6
        bitmap = @bloodstorm_bitmap
      when 7
        bitmap = @bloodsnow_bitmap
      when 8
        bitmap = @bloodsnow_bitmap
      when 9
        bitmap = @sakurahubuki_bitmap
      when 10
        bitmap = @kouyou_bitmap
      when 11
        bitmap = @hyou_bitmap
      when 12
        bitmap = @bloodhyou_bitmap
      when 17
        bitmap = @blackrain_bitmap
      when 18
        bitmap = @osatu_bitmap
      else
        bitmap = nil
      end
      for i in 1..Integer(OBJ_MAX * 10)
        sprite = @sprites[i]
        if sprite != nil
          sprite.visible = (i <= @max)
          sprite.bitmap = bitmap
        end
      end
    end
    #--------------------------------------------------------------------------
    # ○ 転送元原点の X 座標
    #--------------------------------------------------------------------------
    def ox=(ox)
      return if @ox == ox;
      @ox = ox
      for sprite in @sprites
        sprite.ox = @ox
      end
    end
    #--------------------------------------------------------------------------
    # ○ 転送元原点の Y 座標
    #--------------------------------------------------------------------------
    def oy=(oy)
      return if @oy == oy;
      @oy = oy
      for sprite in @sprites
        sprite.oy = @oy
      end
    end
    #--------------------------------------------------------------------------
    # ○ オブジェクトの最大量
    #--------------------------------------------------------------------------
    def max=(max)
      return if @max == max;
      @max = [[max, 0].max, Integer(OBJ_MAX * 10)].min
      for i in 1..Integer(OBJ_MAX * 10)
        sprite = @sprites[i]
        if sprite != nil
          sprite.visible = (i <= @max)
        end
      end
    end
    #--------------------------------------------------------------------------
    # ○ フレーム更新
    #--------------------------------------------------------------------------
    def update
      return if @type == 0
      for i in 1..@max
        sprite = @sprites[i]
        if sprite == nil
          break
        end
        # 左右反転しない天候(桜吹雪、紅葉以外全部)
        if (@type >= 1 && @type <= 8) || (@type >= 11 && @type <= 17)
          sprite.mirror = false
        end
        # 雨、嵐、吹雪、雹のy移動数値
        if @type == 1 || @type == 2 || (@type >= 4 && @type <= 6) || @type == 8 || 
          @type == 11 || @type == 12 || @type == 17
          sprite.y += 16
        end
        # 雨、雪、桜吹雪、紅葉、霙、氷雨、お札の消失数
        if @type == 1 || @type == 3 || @type == 5 || @type == 7 ||
          (@type >= 9 && @type <= 18)
          sprite.opacity -= 8
        end
        # 雨、霙、氷雨のx移動数値
        if @type == 1 || @type == 5 || (@type >= 11 && @type <= 17)
          sprite.x -= 2
        end
        # 雪のx移動数値
        if @type == 3 || @type == 7
          if @snowb == true
            sprite.x -= (1 + 3 * Math.cos(30 * rand(12)))
          else
            sprite.x -= 2
          end
        end
        # 嵐のx移動数値+消失数
        if @type == 2 || @type == 6
          sprite.x -= 8
          sprite.opacity -= 12
        end
        # 吹雪のx移動数値+消失数
        if @type == 4 || @type == 8
          if @snowb == true
            sprite.x -= (6 + 4 * Math.cos(30 * rand(12)))
          else
            sprite.x -= 8
          end
          sprite.opacity -= 12
        end
        # 雪のy移動数値
        if @type == 3 || @type == 7
          sprite.y += 8
        end
        # 桜吹雪、紅葉のx、y移動数値
        if @type == 9 || @type == 10 || @type == 18
          sprite.x -= (2 * Math.cos(30 * rand(12)))
          sprite.y += 4
        end
        # 霙、氷雨の場合
        if (@type >= 13 && @type <= 16)
          # 比率によって雨と雪(雹)に変更する
          r = rand(RAIN_RATE + SNOW_RATE)
          if (r > RAIN_RATE - 1)
            @luquid = false
            if @type == 13
              sprite.y += 8
              sprite.bitmap = @snow_bitmap
            elsif @type == 14
              sprite.y += 8
              sprite.bitmap = @bloodsnow_bitmap
            elsif @type == 15
              sprite.y += 16
              sprite.bitmap = @hyou_bitmap
            else
              sprite.y += 16
              sprite.bitmap = @bloodhyou_bitmap
            end
          else
            @luquid = true
            sprite.y += 16
            if @type == 13 || @type == 15
              sprite.bitmap = @rain_bitmap
            else
              sprite.bitmap = @bloodrain_bitmap
            end
          end
        end
        x = sprite.x - @ox
        y = sprite.y - @oy
        if sprite.opacity < 64 or x < -50 or x > 750 or y < -300 or y > 500
          sprite.x = rand(800) - 50 + @ox
          sprite.y = rand(800) - 200 + @oy
          # 雨など液体が降る場合最初の透明度を127に
          if @type == 1 || @type == 2 || @type == 5 || @type == 6 ||
            (@luquid == true && (@type >= 13 && @type <= 16)) || @type == 17
            sprite.opacity = HARF8BIT
          # 雪、雹など固体の場合最初の透明度を255に
          else
            sprite.opacity = MAX8BIT
          end
          # 桜吹雪、紅葉、お札の場合の左右反転のための処理
          if (@type >= 9 && @type <= 10) || @type == 18
            mi = rand(2)
            if mi == 0
              sprite.mirror = true
            else
              sprite.mirror = false
            end
          else
            sprite.mirror = false
          end
          # 桜吹雪のパターン変化
          if @type == 9
            r = rand(3)
            case r
            when 0
              sprite.bitmap = @sakurahubuki_bitmap
            when 1
              sprite.bitmap = @sakurahubuki_bitmap2
            when 2
              sprite.bitmap = @sakurahubuki_bitmap3
            end
          end
          # 紅葉のパターン変化
          if @type == 10
            r = rand(4)
            case r
            when 0
              sprite.bitmap = @kouyou_bitmap
            when 1
              sprite.bitmap = @kouyou_bitmap2
            when 2
              sprite.bitmap = @kouyou_bitmap3
            when 3
              sprite.bitmap = @kouyou_bitmap4
            end
          end
        end
      end
    end
    #--------------------------------------------------------------------------
    # ○ 公開インスタンス変数
    #--------------------------------------------------------------------------
    attr_reader :type
    attr_reader :max
    attr_reader :ox
    attr_reader :oy
  end
end
降らせる画像はこちらに用意してあったりします。ピクチャにインポートして使ってください。 これ→ 画像が気に入らない場合は各自で造ってください。(24*n × 24の規格で造っていますが、それ以外でもOK。 ただし、その場合@b_re1〜@b_renと、画像の配置を変更する必要があります。) ちなみに薄赤色をfalseにすることで雪が直線的に降るようになり、 薄緑色の部分を変えることによって雨:雪の比率を変えることができます。 これで天候エフェクトは増やせたわけですが、ツクールのコマンドでは3の雪までしか対応していない。 そこで・・・最初の方に書いてあるようにスクリプトで以下のようにして呼び出してください。 ちなみに天候を戻す(晴れの状態)にするにはコマンド、天候の設定で『無し』にすればいいです。
吹雪 $game_screen.weather(4, 強さ(1〜9), ウェイト)
血の雨 $game_screen.weather(5, 強さ(1〜9), ウェイト)
血の嵐 $game_screen.weather(6, 強さ(1〜9), ウェイト)
赤い雪 $game_screen.weather(7, 強さ(1〜9), ウェイト)
赤い吹雪 $game_screen.weather(8, 強さ(1〜9), ウェイト)
桜吹雪 $game_screen.weather(9, 強さ(1〜9), ウェイト)
紅葉 $game_screen.weather(10, 強さ(1〜9), ウェイト)
$game_screen.weather(11, 強さ(1〜9), ウェイト)
血の雹 $game_screen.weather(12, 強さ(1〜9), ウェイト)
$game_screen.weather(13, 強さ(1〜9), ウェイト)
血の霙 $game_screen.weather(14, 強さ(1〜9), ウェイト)
氷雨 $game_screen.weather(15, 強さ(1〜9), ウェイト)
血の氷雨 $game_screen.weather(16, 強さ(1〜9), ウェイト)
黒い雨 $game_screen.weather(17, 強さ(1〜9), ウェイト)
お札 $game_screen.weather(18, 強さ(1〜9), ウェイト)

戻る