| 
 
| 赞 | 0 |  
| VIP | 0 |  
| 好人卡 | 2 |  
| 积分 | 2 |  
| 经验 | 3063 |  
| 最后登录 | 2016-7-20 |  
| 在线时间 | 54 小时 |  
 Lv1.梦旅人 
	梦石0 星屑235 在线时间54 小时注册时间2012-12-28帖子31 | 
| 11區有人寫了 159左右開始,就是年月日左右的變量,應該做到你想要的效果?复制代码=begin  =======================================================================
  ☆ カレンダー機能追加  by 白雪レイカ
-------------------------------------------------------------------------------
  プロジェクトに「時刻」の概念を加えます。
  時間帯でBGMや画面の色調が切り替わり、季節ごとにランダムで天候が変化します。
  主なデータはすべて変数に格納されるので、
  それを使ってイベントを分岐させたりできます。
-------------------------------------------------------------------------------
 
  ◆使い方
    基本的に設定項目をカスタマイズして導入するだけなのですが、
    一部説明が必要な部分があるのでご説明します。
    
    ○時間帯について
    
       3:00 ~  5:59 => 早朝 (:early_morning)
       6:00 ~ 10:59 => 朝   (:morning)
      11:00 ~ 15:59 => 昼   (:noon)
      16:00 ~ 18:59 => 夕方 (:evening)
      19:00 ~ 22:59 => 夜   (:night)
      23:00 ~  2:59 => 深夜 (:midnight)
      
      となっています。
      
    
    ○時間帯ごとのBGM切り替え
      マップ設定の「BGMの自動切換え」にチェックが入っているときのみ有効。
      マップのメモ欄に以下のように記述してください。
      
      <早朝(またはearly) ファイル名, 音量, ピッチ>
      
      これで早朝のBGMが設定できます。
      早朝 の部分を 朝(またはmorning)、昼(またはnoon)、夕方(またはevening)、
      夜(またはnight)、深夜(またはmid)とすることで
      対応する時間帯のBGMを設定することができます。
      ファイル名の拡張子は省略することができます(例 Town1)。
      
      
    ○イベントでの時刻etc設定
      イベントコマンド「スクリプト」から実行
      
        set_time(hour, min)
          # 時刻を hour:min に設定します。
          # このメソッドによって日数が経過することはありません。
        
        set_date(month, date, day)
          # カレンダーを month月 date日 day曜日に設定します。
          # 曜日の経過とか完全に無視してしまうので非推奨です。
          # 曜日はシンボルで設定します。
          
          # 日曜 => :Sun  月曜 => :Mon  火曜 => :Tue
          # 水曜 => :Wed  木曜 => :Thr  金曜 => :Fri
          # 土曜 => :Sat
          
        set_year(year)
          # カレンダーをyear年に設定します。
          # 上と同じく非推奨です。
        
        shift_date(date)
          # カレンダーをdate日だけ進めます。
          # こちらは曜日もちゃんと加味します。
          
        shift_month(month)
          # カレンダーをmonth月だけ進め、
          # 進めた月の1日に設定します。
           
         shift_year(year)
          # カレンダーを指定した年数経過させます。
          # shift_monthと違って日付は変わりません。
          
        shift_date_to(month, date[, year])
          # カレンダーを指定した日付(year年 month月 date日)まで進めます。
          # yearを省略した場合は現在の年と同じ値になります。
          # 現在の日付よりも前の日付を設定すると、
          # その日まで時間が巻き戻ります。
           
         set_weather(weather)
          # 天候を設定します。
          # weatherはシンボルで指定します。
          
          # 晴れ => :fine  雨 => :rain   雪 => :snow
          # 雷 => :thunder 嵐 => :storm  晴れ(夜) => :star
          # 吹雪 => :s_storm
          
  ◆おことわり
    改造・再配布等自由です。
    再配布の際には作者の明示をお願いします。
    バグを発見したら速やかにご報告ください。
    
=end
#==============================================================================
# ■ 設定項目
#==============================================================================
module WhiteSnow
 
  # ↓↓ここから初期設定↓↓
 
  INITAL_MIN = 0
    # ゲーム開始時の「分」の値
 
  INITAL_HOUR = 7
    # ゲーム開始時の「時」の値
 
  INITAL_DATE = 6
    # ゲーム開始時の「日」の値
 
  INITAL_DAY = :Sun
    # ゲーム開始時の「曜日」の値
 
  INITAL_MONTH = 4
    # ゲーム開始時の「月」の値
 
  INITAL_YEAR = 395
    # ゲーム開始時の「年」の値
 
  # ↑↑ここまで初期設定↑↑
 
 
  TIME_COUNT_FORBID_SID = 10
    # 時間経過を禁止するスイッチID
 
  TONE_CHANGE_FORBID_SID = 11
    # 時間経過による画面の色調変更を禁止するスイッチID
 
  WEATHER_EFFECT_FORBID_SID = 12
    # 天候エフェクトを無効化するスイッチID
 
  CALENDER_WINDOW_HIDE_SID = 13
    # 日付ウィンドウを消すスイッチID
    # ウィンドウが消えていても止めない限り時間は経過します
 
  INSIDE_FLAG_SID = 14
    # 屋内フラグを立てるスイッチID
    # 色調変更、天候エフェクトをまとめて無効化します
 
  WEATHER_BGS_ENABLE = true
    # 天候によるBGS機能を使用するか
    # trueで使用する、falseで使用しないとなります
 
  INSIDE_BGS_TYPE = 1
    # 屋内フラグまたは天候エフェクト無効フラグのスイッチがONになった
    # ときのBGSのタイプ
    # BGS機能を使用するときのみ有効
    # 0で音を消す、1で音量を60%にして流す、2でそのまま流す
    # となります。
 
  WEATHER_BGS_DISABLE = 15
    # 天候BGS機能停止スイッチ
 
    # このスイッチIDがONのときは天候BGSは流れません。
    # ただしこのスイッチ単体では、今流れているBGSの再生を止める効果はありません。
    # あくまで一時的にBGS機能を無効化するだけです。
    # 屋内フラグを切り替えるスイッチと一緒に使うなりしてください。
 
    # また、このスイッチがOFFになっても止まっていたBGSが再び流れるような
    # ことはありません。
 
 
  MIN_STORE_VID = 101
    # 現在の「分」の値が格納される変数ID
 
  HOUR_STORE_VID = 102
    # 現在の「時」の値が格納される変数ID
 
  TIME_ZONE_STORE_VID = 103
    # 現在の「時間帯」が格納される変数ID
    # 早朝に0、朝に1、昼に2、夕方に3、夜に4、深夜で5になります。
 
  DATE_STORE_VID = 104
    # 現在の「日」の値が格納される変数ID
 
  DAY_STORE_VID = 105
    # 現在の「曜日」が格納される変数ID
    # 日曜のとき0、月曜のとき1、と続き土曜のとき6になります。
 
  MONTH_STORE_VID = 106
    # 現在の「月」の値が格納される変数ID
 
  SEASON_STORE_VID = 107
    # 現在の「季節」が格納される変数ID
    # 春のとき0、夏のとき1、秋のとき2、冬のとき3になります。
 
  WEATHER_STORE_VID = 108
    # 現在の「天候」が格納される変数ID
    # 晴れのとき0、雨のとき1、雪のとき2、雷のとき3、
    # 嵐のとき4、晴れ(夜)のとき5、吹雪のとき6になります。
 
  YEAR_STORE_VID = 109
    # 現在の「年」の値が格納される変数ID
 
 
  EARLY_MORNING_SCREEN_TONE = [15, 10, 0, 0]
    # 早朝の画面の色調
    # R, G, B, Darkの順に指定してください。
 
  MORNING_SCREEN_TONE = [0, 0, 0, 0]
    # 朝の画面の色調
    # R, G, B, Darkの順に指定してください。
 
  NOON_SCREEN_TONE = [15, 15, 15, 0]
    # 昼の画面の色調
    # R, G, B, Darkの順に指定してください。
 
  AFTERNOON_SCREEN_TONE = [32, -8, -32, 16]
    # 夕方の画面の色調
    # R, G, B, Darkの順に指定してください。
 
  NIGHT_SCREEN_TONE = [-64, -64, -16, 32]
    # 夜の画面の色調
    # R, G, B, Darkの順に指定してください。
 
  MIDNIGHT_SCREEN_TONE = [-72, -72, -20, 48]
    # 深夜の画面の色調
    # R, G, B, Darkの順に指定してください。
 
 
  DAYS_TABLE = {0 => 31, 1 => 31, 2 => 28, 3 => 31, 4 => 30, 5 => 31, 6 => 30,
                7 => 31, 8 => 31, 9 => 30, 10 => 31, 11 => 30, 12 => 31}
    # 月毎の日数のテーブル
    # 基本的に変更しないでください。
 
 
    # 以下天候リスト
 
    # 設定例
    # WEATHER = {:icon => 天候アイコンインデックス,
    #            :weather => [天候エフェクトの種類, 強さ]},
    #            :bgs => ["ファイル名", 音量, ピッチ](設定しない場合はnil),
    #
    # 天候エフェクトの種類  :noneで「なし」、:rainで「雨」、
    #                       :stormで「嵐」、:snowで「雪」となります。
 
  FINE = {:icon => 1, :weather => [:none, 0],
          :bgs => nil}
    # 天候:晴れ
 
  RAIN = {:icon => 2, :weather => [:rain, 5],
          :bgs => ["Rain", 50, 90]}
    # 天候:雨
 
  SNOW = {:icon => 3, :weather => [:snow, 4],
          :bgs => nil}
    # 天候:雪
 
  THUNDER = {:icon => 4, :weather => [:storm, 4],
             :bgs => ["Storm", 60, 75],
 
             :flash => [255, 255, 200, 180, 12],
             :se => ["Thunder9", 80, 95]}
    # 天候:雷
    # 雷エフェクト用の設定項目について
    # :flash => [(フラッシュの色)R, G, B, Alpha, フラッシュの長さ]
    # :se => フラッシュの後に鳴るSE
 
  STORM = {:icon => 5, :weather => [:storm, 8],
           :bgs => ["Storm", 70, 100]}
    # 天候:嵐
 
  STAR = {:icon => 6, :weather => [:none, 0],
          :bgs => nil}
    # 天候:晴れ(夜)
 
  S_STORM = {:icon => 7, :weather => [:snow, 9],
             :bgs => ["Wind", 70, 95]}
    # 天候:吹雪
end
 
#==============================================================================
# ■ Calender
#------------------------------------------------------------------------------
#  カレンダーのクラスです。
#==============================================================================
 
class Calender
  #--------------------------------------------------------------------------
  # ● 公開インスタンス変数
  #--------------------------------------------------------------------------
  attr_accessor :count
  attr_accessor :min
  attr_accessor :hour
  attr_accessor :date
  attr_accessor :day
  attr_accessor :month
  attr_accessor :season
  attr_accessor :year
  attr_accessor :weather
  attr_accessor :weather_count
  attr_accessor :time_zone
  attr_reader   :interpreter
  attr_accessor :thunder_count
  #--------------------------------------------------------------------------
  # ● オブジェクト初期化
  #--------------------------------------------------------------------------
  def initialize
    @count = 0
    @weather = :fine
    @interpreter = Game_Interpreter.new
    init_calender
    change_weather
  end
  #--------------------------------------------------------------------------
  # ● カレンダーの初期化
  #--------------------------------------------------------------------------
  def init_calender
    [url=home.php?mod=space&uid=25749]@min[/url]    = WhiteSnow::INITAL_MIN
    @hour   = WhiteSnow::INITAL_HOUR
    @date   = WhiteSnow::INITAL_DATE
    [url=home.php?mod=space&uid=11519]@day[/url]    = WhiteSnow::INITAL_DAY
    [url=home.php?mod=space&uid=26122]@Month[/url]  = WhiteSnow::INITAL_MONTH
    @year   = WhiteSnow::INITAL_YEAR
    get_time_zone
 
    $game_variables[WhiteSnow::MIN_STORE_VID] = @min
    $game_variables[WhiteSnow::HOUR_STORE_VID] = @hour
    $game_variables[WhiteSnow::DATE_STORE_VID] = @date
 
    case @month
    when 1..2
      [url=home.php?mod=space&uid=31546]@season[/url] = :Winter
      $game_variables[WhiteSnow::SEASON_STORE_VID] = 3
    when 3..5
      [url=home.php?mod=space&uid=31546]@season[/url] = :Spring
      $game_variables[WhiteSnow::SEASON_STORE_VID] = 0
    when 6..8
      [url=home.php?mod=space&uid=31546]@season[/url] = :Summer
      $game_variables[WhiteSnow::SEASON_STORE_VID] = 1
    when 9..11
      @season = :Autumn
      $game_variables[WhiteSnow::SEASON_STORE_VID] = 2
    when 12
      @season = :Winter
      $game_variables[WhiteSnow::SEASON_STORE_VID] = 3
    end
 
    case @day
    when :Sun
      $game_variables[WhiteSnow::DAY_STORE_VID] = 0
    when :Mon
      $game_variables[WhiteSnow::DAY_STORE_VID] = 1
    when :Tue
      $game_variables[WhiteSnow::DAY_STORE_VID] = 2
    when :Wed
      $game_variables[WhiteSnow::DAY_STORE_VID] = 3
    when :Thr
      $game_variables[WhiteSnow::DAY_STORE_VID] = 4
    when :Fri
      $game_variables[WhiteSnow::DAY_STORE_VID] = 5
    when :Sat
      $game_variables[WhiteSnow::DAY_STORE_VID] = 6
    end
    $game_variables[WhiteSnow::MONTH_STORE_VID] = @month
    $game_variables[WhiteSnow::YEAR_STORE_VID] = @year
    change_tone_by_calender
  end
  #--------------------------------------------------------------------------
  # ● 時間帯の取得
  #--------------------------------------------------------------------------
  def get_time_zone
    case @hour
    when 0..2
      @time_zone = :midnight
      $game_variables[WhiteSnow::TIME_ZONE_STORE_VID] = 5
    when 3..5
      @time_zone = :early_morning
      $game_variables[WhiteSnow::TIME_ZONE_STORE_VID] = 0
    when 6..10
      @time_zone = :morning
      $game_variables[WhiteSnow::TIME_ZONE_STORE_VID] = 1
    when 11..15
      @time_zone = :noon
      $game_variables[WhiteSnow::TIME_ZONE_STORE_VID] = 2
    when 16..18
      @time_zone = :evening
      $game_variables[WhiteSnow::TIME_ZONE_STORE_VID] = 3
    when 19..22
      @time_zone = :night
      $game_variables[WhiteSnow::TIME_ZONE_STORE_VID] = 4
    when 23..24
      @time_zone = :midnight
      $game_variables[WhiteSnow::TIME_ZONE_STORE_VID] = 5
    end
  end
  #--------------------------------------------------------------------------
  # ● 天候カウントの取得
  #--------------------------------------------------------------------------
  def randomize_weather_count
    @weather_count = p_ex_rand(40, 100) + (109 - p_ex_rand(40, 110)) + 90
  end
  #--------------------------------------------------------------------------
  # ● 画面の色調変更
  #--------------------------------------------------------------------------
  def change_tone_by_calender(dur = 60)
    return if $game_switches[WhiteSnow::TONE_CHANGE_FORBID_SID]
    return if $game_switches[WhiteSnow::INSIDE_FLAG_SID]
    case @time_zone
    when :early_morning
      tone = WhiteSnow::EARLY_MORNING_SCREEN_TONE
      @interpreter.change_tone(tone[0], tone[1], tone[2], tone[3], dur)
    when :morning
      tone = WhiteSnow::MORNING_SCREEN_TONE
      @interpreter.change_tone(tone[0], tone[1], tone[2], tone[3], dur)
    when :noon
      tone = WhiteSnow::NOON_SCREEN_TONE
      @interpreter.change_tone(tone[0], tone[1], tone[2], tone[3], dur)
    when :evening
      tone = WhiteSnow::AFTERNOON_SCREEN_TONE
      @interpreter.change_tone(tone[0], tone[1], tone[2], tone[3], dur)
    when :night
      tone = WhiteSnow::NIGHT_SCREEN_TONE
      @interpreter.change_tone(tone[0], tone[1], tone[2], tone[3], dur)
    when :midnight
      tone = WhiteSnow::MIDNIGHT_SCREEN_TONE
      @interpreter.change_tone(tone[0], tone[1], tone[2], tone[3], dur)
    end
  end
  #--------------------------------------------------------------------------
  # ● 天候の変更
  #--------------------------------------------------------------------------
  def change_weather
    srand
    p_weather = @weather
    case @month
    when 1
      case rand
      when 0...0.2
        if @hour >= 3 and @hour < 18
          @weather = :fine
        else
          @weather = :star
        end
      when 0.2...0.8
        @weather = :snow
      when 0.8...1
        @weather = :s_storm
      end
    when 2
      case rand
      when 0...0.3
        if @hour >= 3 and @hour < 18
          @weather = :fine
        else
          @weather = :star
        end
      when 0.3...0.8
        @weather = :snow
      when 0.8...0.9
        @weather = :rain
      when 0.9...1
        @weather = :s_storm
      end
    when 3..4
      case rand
      when 0...0.8
        if @hour >= 3 and @hour < 18
          @weather = :fine
        else
          @weather = :star
        end
      when 0.8...0.9
        @weather = :rain
      when 0.9...1
        @weather = :storm
      end
    when 5
      case rand
      when 0...0.7
        if @hour >= 3 and @hour < 18
          @weather = :fine
        else
          @weather = :star
        end
      when 0.7...0.8
        @weather = :rain
      when 0.8...0.9
        @weather = :thunder
      when 0.9...1
        @weather = :storm
      end
    when 6
      case rand
      when 0...0.4
        if @hour >= 3 and @hour < 18
          @weather = :fine
        else
          @weather = :star
        end
      when 0.4...0.8
        @weather = :rain
      when 0.8...0.9
        @weather = :thunder
      when 0.9...1
        @weather = :storm
      end
    when 7..8
      case rand
      when 0...0.6
        if @hour >= 3 and @hour < 18
          @weather = :fine
        else
          @weather = :star
        end
      when 0.6...0.7
        @weather = :rain
      when 0.7...0.9
        @weather = :storm
      when 0.9...1
        @weather = :thunder
      end
    when 9..10
      case rand
      when 0...0.6
        if @hour >= 3 and @hour < 18
          @weather = :fine
        else
          @weather = :star
        end
      when 0.6...0.8
        @weather = :storm
      when 0.8...0.9
        @weather = :rain
      when 0.9...1
        @weather = :thunder
      end
    when 11
      if @date < 25
        case rand
        when 0...0.7
          if @hour >= 3 and @hour < 18
            @weather = :fine
          else
            @weather = :star
          end
        when 0.7...0.8
          @weather = :storm
        when 0.8...0.9
          @weather = :rain
        when 0.9...1
          @weather = :thunder
        end
      else
        case rand
        when 0...0.6
          if @hour >= 3 and @hour < 18
            @weather = :fine
          else
            @weather = :star
          end
        when 0.6...0.7
          @weather = :storm
        when 0.7...0.8
          @weather = :rain
        when 0.8...0.9
          @weather = :thunder
        when 0.9...1
          @weather = :snow
        end
      end
    when 12
      case rand
      when 0...0.2
        if @hour >= 3 and @hour < 18
          @weather = :fine
        else
          @weather = :star
        end
      when 0.2...0.8
        @weather = :snow
      when 0.8...1
        @weather = :s_storm
      end
    end
    if @weather != p_weather
      RPG::BGS.fade(10)
      perform_weather_effect
    end
    randomize_weather_count
  end
  #--------------------------------------------------------------------------
  # ● 天候エフェクト
  #--------------------------------------------------------------------------
  def perform_weather_effect(dur = 30)
    return unless SceneManager.scene_is?(Scene_Map)
    return if $game_switches[WhiteSnow::WEATHER_EFFECT_FORBID_SID]
    return if $game_switches[WhiteSnow::INSIDE_FLAG_SID]
    case @weather
    when :fine
      weather = WhiteSnow::FINE
      @interpreter.change_weather(weather[:weather][0], weather[:weather][1], dur)
      if weather[:bgs] and WhiteSnow::WEATHER_BGS_ENABLE and !$game_switches[WhiteSnow::WEATHER_BGS_DISABLE]
        bgs = RPG::BGS.new(weather[:bgs][0], weather[:bgs][1], weather[:bgs][2])
        bgs.play
      end
      $game_variables[WhiteSnow::WEATHER_STORE_VID] = 0
 
    when :rain
      weather = WhiteSnow::RAIN
      @interpreter.change_weather(weather[:weather][0], weather[:weather][1], dur)
      if weather[:bgs] and WhiteSnow::WEATHER_BGS_ENABLE and !$game_switches[WhiteSnow::WEATHER_BGS_DISABLE]
        bgs = RPG::BGS.new(weather[:bgs][0], weather[:bgs][1], weather[:bgs][2])
        bgs.play
      end
      $game_variables[WhiteSnow::WEATHER_STORE_VID] = 1
 
    when :snow
      weather = WhiteSnow::SNOW
      @interpreter.change_weather(weather[:weather][0], weather[:weather][1], dur)
      if weather[:bgs] and WhiteSnow::WEATHER_BGS_ENABLE and !$game_switches[WhiteSnow::WEATHER_BGS_DISABLE]
        bgs = RPG::BGS.new(weather[:bgs][0], weather[:bgs][1], weather[:bgs][2])
        bgs.play
      end
      $game_variables[WhiteSnow::WEATHER_STORE_VID] = 2
 
    when :thunder
      weather = WhiteSnow::THUNDER
      @interpreter.change_weather(weather[:weather][0], weather[:weather][1], dur)
      if weather[:bgs] and WhiteSnow::WEATHER_BGS_ENABLE and !$game_switches[WhiteSnow::WEATHER_BGS_DISABLE]
        bgs = RPG::BGS.new(weather[:bgs][0], weather[:bgs][1], weather[:bgs][2])
        bgs.play
      end
      $game_variables[WhiteSnow::WEATHER_STORE_VID] = 3
 
    when :storm
      weather = WhiteSnow::STORM
      @interpreter.change_weather(weather[:weather][0], weather[:weather][1], dur)
      if weather[:bgs] and WhiteSnow::WEATHER_BGS_ENABLE and !$game_switches[WhiteSnow::WEATHER_BGS_DISABLE]
        bgs = RPG::BGS.new(weather[:bgs][0], weather[:bgs][1], weather[:bgs][2])
        bgs.play
      end
      $game_variables[WhiteSnow::WEATHER_STORE_VID] = 4
 
    when :star
      weather = WhiteSnow::STAR
      @interpreter.change_weather(weather[:weather][0], weather[:weather][1], dur)
      if weather[:bgs] and WhiteSnow::WEATHER_BGS_ENABLE and !$game_switches[WhiteSnow::WEATHER_BGS_DISABLE]
        bgs = RPG::BGS.new(weather[:bgs][0], weather[:bgs][1], weather[:bgs][2])
        bgs.play
      end
      $game_variables[WhiteSnow::WEATHER_STORE_VID] = 5
 
    when :s_storm
      weather = WhiteSnow::S_STORM
      @interpreter.change_weather(weather[:weather][0], weather[:weather][1], dur)
      if weather[:bgs] and WhiteSnow::WEATHER_BGS_ENABLE and !$game_switches[WhiteSnow::WEATHER_BGS_DISABLE]
        bgs = RPG::BGS.new(weather[:bgs][0], weather[:bgs][1], weather[:bgs][2])
        bgs.play
      end
      $game_variables[WhiteSnow::WEATHER_STORE_VID] = 6
    end
  end
  #--------------------------------------------------------------------------
  # ● 屋内BGSの演奏
  #--------------------------------------------------------------------------
  def play_inside_bgs
    case @weather
    when :fine
      weather = WhiteSnow::FINE
      if weather[:bgs] and WhiteSnow::WEATHER_BGS_ENABLE and !$game_switches[WhiteSnow::WEATHER_BGS_DISABLE]
        bgs = RPG::BGS.new(weather[:bgs][0], weather[:bgs][1] * 0.6, weather[:bgs][2])
        bgs.play
      end
 
    when :rain
      weather = WhiteSnow::RAIN
      if weather[:bgs] and WhiteSnow::WEATHER_BGS_ENABLE and !$game_switches[WhiteSnow::WEATHER_BGS_DISABLE]
        bgs = RPG::BGS.new(weather[:bgs][0], weather[:bgs][1] * 0.7, weather[:bgs][2])
        bgs.play
      end
 
    when :snow
      weather = WhiteSnow::SNOW
      if weather[:bgs] and WhiteSnow::WEATHER_BGS_ENABLE and !$game_switches[WhiteSnow::WEATHER_BGS_DISABLE]
        bgs = RPG::BGS.new(weather[:bgs][0], weather[:bgs][1] * 0.7, weather[:bgs][2])
        bgs.play
      end
 
    when :thunder
      weather = WhiteSnow::THUNDER
      if weather[:bgs] and WhiteSnow::WEATHER_BGS_ENABLE and !$game_switches[WhiteSnow::WEATHER_BGS_DISABLE]
        bgs = RPG::BGS.new(weather[:bgs][0], weather[:bgs][1] * 0.7, weather[:bgs][2])
        bgs.play
      end
 
    when :storm
      weather = WhiteSnow::STORM
      if weather[:bgs] and WhiteSnow::WEATHER_BGS_ENABLE and !$game_switches[WhiteSnow::WEATHER_BGS_DISABLE]
        bgs = RPG::BGS.new(weather[:bgs][0], weather[:bgs][1] * 0.7, weather[:bgs][2])
        bgs.play
      end
 
    when :star
      weather = WhiteSnow::STAR
      if weather[:bgs] and WhiteSnow::WEATHER_BGS_ENABLE and !$game_switches[WhiteSnow::WEATHER_BGS_DISABLE]
        bgs = RPG::BGS.new(weather[:bgs][0], weather[:bgs][1] * 0.7, weather[:bgs][2])
        bgs.play
      end
 
    when :s_storm
      weather = WhiteSnow::S_STORM
      if weather[:bgs] and WhiteSnow::WEATHER_BGS_ENABLE and !$game_switches[WhiteSnow::WEATHER_BGS_DISABLE]
        bgs = RPG::BGS.new(weather[:bgs][0], weather[:bgs][1] * 0.7, weather[:bgs][2])
        bgs.play
      end
    end
  end
  #--------------------------------------------------------------------------
  # ● 天候「雷」エフェクトの実行
  #--------------------------------------------------------------------------
  def perform_thunder_effect(r, g, b, alpha, dur)
    @interpreter.perform_flash(r, g, b, alpha, dur)
  end
  #--------------------------------------------------------------------------
  # ● 曜日の更新
  #--------------------------------------------------------------------------
  def shift_day
    case @day
    when :Sun
      [url=home.php?mod=space&uid=11519]@day[/url] = :Mon
      $game_variables[WhiteSnow::DAY_STORE_VID] = 1
    when :Mon
      [url=home.php?mod=space&uid=11519]@day[/url] = :Tue
      $game_variables[WhiteSnow::DAY_STORE_VID] = 2
    when :Tue
      @day = :Wed
      $game_variables[WhiteSnow::DAY_STORE_VID] = 3
    when :Wed
      @day = :Thr
      $game_variables[WhiteSnow::DAY_STORE_VID] = 4
    when :Thr
      @day = :Fri
      $game_variables[WhiteSnow::DAY_STORE_VID] = 5
    when :Fri
      @day = :Sat
      $game_variables[WhiteSnow::DAY_STORE_VID] = 6
    when :Sat
      @day = :Sun
      $game_variables[WhiteSnow::DAY_STORE_VID] = 0
    end
  end
  #--------------------------------------------------------------------------
  # ● 曜日を戻す
  #--------------------------------------------------------------------------
  def back_day
    case @day
    when :Sun
      @day = :Sat
      $game_variables[WhiteSnow::DAY_STORE_VID] = 1
    when :Sat
      @day = :Fri
      $game_variables[WhiteSnow::DAY_STORE_VID] = 2
    when :Fri
      @day = :Thr
      $game_variables[WhiteSnow::DAY_STORE_VID] = 3
    when :Thr
      @day = :Wed
      $game_variables[WhiteSnow::DAY_STORE_VID] = 4
    when :Wed
      @day = :Tue
      $game_variables[WhiteSnow::DAY_STORE_VID] = 5
    when :Tue
      @day = :Mon
      $game_variables[WhiteSnow::DAY_STORE_VID] = 6
    when :Mon
      @day = :Sun
      $game_variables[WhiteSnow::DAY_STORE_VID] = 0
    end
  end
  #--------------------------------------------------------------------------
  # ● 月の更新
  #--------------------------------------------------------------------------
  def shift_month
    case @month
    when 1
      return unless @date > 31
      [url=home.php?mod=space&uid=26122]@Month[/url] += 1
      @date = 1
    when 2
      return unless @date > 28
      [url=home.php?mod=space&uid=26122]@Month[/url] += 1
      @season = :Spring
      @date = 1
      $game_variables[WhiteSnow::SEASON_STORE_VID] = 0
    when 3
      return unless @date > 31
      @month += 1
      @date = 1
    when 4
      return unless @date > 30
      @month += 1
      @date = 1
    when 5
      return unless @date > 31
      @month += 1
      @season = :Summer
      @date = 1
      $game_variables[WhiteSnow::SEASON_STORE_VID] = 1
    when 6
      return unless @date > 30
      @month += 1
      @date = 1
    when 7
      return unless @date > 31
      @month += 1
      @date = 1
    when 8
      return unless @date > 31
      @month += 1
      @season = :Autumn
      @date = 1
      $game_variables[WhiteSnow::SEASON_STORE_VID] = 2
    when 9
      return unless @date > 30
      @month += 1
      @date = 1
    when 10
      return unless @date > 31
      @month += 1
      @date = 1
    when 11
      return unless @date > 30
      @month += 1
      @season = :Winter
      @date = 1
      $game_variables[WhiteSnow::SEASON_STORE_VID] = 3
    when 12
      return unless @date > 31
      @year += 1
      @month = 1
      @date = 1
      $game_variables[WhiteSnow::YEAR_STORE_VID] = @year
    end
    $game_variables[WhiteSnow::DATE_STORE_VID] = @date
    $game_variables[WhiteSnow::MONTH_STORE_VID] = @month
  end
  #--------------------------------------------------------------------------
  # ● 月を戻す
  #--------------------------------------------------------------------------
  def back_month
    return unless @date < 1
    case @month
    when 1
      @month = 12
      @date = 31
      @year -= 1
      $game_variables[WhiteSnow::YEAR_STORE_VID] = @year
    when 2
      @month -= 1
      @date = 31
    when 3
      @month -= 1
      @date = 28
      @season = :Winter
      $game_variables[WhiteSnow::SEASON_STORE_VID] = 3
    when 4
      @month -= 1
      @date = 31
    when 5
      @month -= 1
      @date = 30
    when 6
      @month -= 1
      @date = 31
      @season = :Spring
      $game_variables[WhiteSnow::SEASON_STORE_VID] = 0
    when 7
      @month -= 1
      @date = 30
    when 8
      @month -= 1
      @date = 31
    when 9
      @month -= 1
      @date = 31
      @season = :Summer
      $game_variables[WhiteSnow::SEASON_STORE_VID] = 1
    when 10
      @month -= 1
      @date = 30
    when 11
      @month -= 1
      @date = 31
    when 12
      @month -= 1
      @date = 30
      @season = :Autumn
      $game_variables[WhiteSnow::SEASON_STORE_VID] = 2
    end
    $game_variables[WhiteSnow::DATE_STORE_VID] = @date
    $game_variables[WhiteSnow::MONTH_STORE_VID] = @month
  end
  #--------------------------------------------------------------------------
  # ● 日付を進める
  #--------------------------------------------------------------------------
  def shift_date
    @date += 1
    shift_day
    shift_month
    $game_variables[WhiteSnow::HOUR_STORE_VID] = @hour
    $game_variables[WhiteSnow::DATE_STORE_VID] = @date
  end
  #--------------------------------------------------------------------------
  # ● 日付を戻す
  #--------------------------------------------------------------------------
  def back_date
    @date += 1
    back_day
    back_month
    $game_variables[WhiteSnow::HOUR_STORE_VID] = @hour
    $game_variables[WhiteSnow::DATE_STORE_VID] = @date
  end
  #--------------------------------------------------------------------------
  # ● 指定された日時と現在の日時の差を求める
  #--------------------------------------------------------------------------
  def days_dif(y, m, d)
    table = WhiteSnow::DAYS_TABLE
    dy_n = (@year - 1) * 365
    dy_s = (y - 1) * 365
    dm_n = 0 ; 1.upto(@month - 1){|n| dm_n += table[n]} unless @month == 1
    dm_s = 0 ; 1.upto(m - 1){|n| dm_s += table[n]} unless m == 1
    d_n = @date - 1
    d_s = d - 1
    n = dy_n + dm_n + d_n
    s = dy_s + dm_s + d_s
    return s - n
  end
end
 
#==============================================================================
# ■ Window_Calender
#------------------------------------------------------------------------------
#  カレンダーの内容を表示するウィンドウです。
#==============================================================================
 
class Window_Calender < Window_Base
  #--------------------------------------------------------------------------
  # ● オブジェクト初期化
  #--------------------------------------------------------------------------
  def initialize(x = Graphics.width - 208, y = 0, w = 208)
    super(x, y, w, fitting_height(2))
    refresh
  end
  #--------------------------------------------------------------------------
  # ● フレーム更新
  #--------------------------------------------------------------------------
  def update
    self.visible = false if $game_switches[WhiteSnow::CALENDER_WINDOW_HIDE_SID]
    super
    refresh if $calender.count == 0
  end
  #--------------------------------------------------------------------------
  # ● リフレッシュ
  #--------------------------------------------------------------------------
  def refresh
    contents.clear
    draw_year
    draw_date
    draw_time
    draw_weather_icon
  end
  #--------------------------------------------------------------------------
  # ● 年・季節の描画
  #--------------------------------------------------------------------------
  def draw_year
    season = $calender.season.to_s
    season.gsub!("Spring"){"春"}
    season.gsub!("Summer"){"夏"}
    season.gsub!("Autumn"){"秋"}
    season.gsub!("Winter"){"冬"}
    draw_text(0, 0, contents_width, line_height, "#{$calender.year}" + "年")
    draw_text(0, 0, contents_width, line_height, season, 1)
  end
  #--------------------------------------------------------------------------
  # ● 月・日付・曜日の描画
  #--------------------------------------------------------------------------
  def draw_date
    w = contents_width
    h = line_height
    month = $calender.month
    if (0..9).to_a.include?(month)
      month = "0" + month.to_s
    else
      month = month.to_s
    end
    date = $calender.date
    if (0..9).to_a.include?(date)
      date = "0" + date.to_s
    else
      date = date.to_s
    end
    day = $calender.day.to_s
    day.gsub!("Sun"){"\\c[2]日\\c[0]"}
    day.gsub!("Mon"){"月"}
    day.gsub!("Tue"){"火"}
    day.gsub!("Wed"){"水"}
    day.gsub!("Thr"){"木"}
    day.gsub!("Fri"){"金"}
    day.gsub!("Sat"){"土"}
    draw_text_ex(0, h, month + "月" + date + "日" + "(" + day + ")")
  end
  #--------------------------------------------------------------------------
  # ● 時・分の描画
  #--------------------------------------------------------------------------
  def draw_time
    w = contents_width - 6
    h = line_height
    hour = "#{$calender.hour}"
    min = $calender.min
    if (0..9).to_a.include?(min)
      min = "0" + min.to_s
    else
      min = min.to_s
    end
    draw_text(0, h, w, h, hour + ":" + min, 2)
  end
  #--------------------------------------------------------------------------
  # ● 天候アイコンの描画
  #--------------------------------------------------------------------------
  def draw_weather_icon
    case $calender.weather
    when :fine
      icon_index = WhiteSnow::FINE[:icon]
    when :rain
      icon_index = WhiteSnow::RAIN[:icon]
    when :snow
      icon_index = WhiteSnow::SNOW[:icon]
    when :thunder
      icon_index = WhiteSnow::THUNDER[:icon]
    when :storm
      icon_index = WhiteSnow::STORM[:icon]
    when :star
      icon_index = WhiteSnow::STAR[:icon]
    when :s_storm
      icon_index = WhiteSnow::S_STORM[:icon]
    end
    draw_icon(icon_index, contents_width - 30, 0)
  end
end
 
#==============================================================================
# ■ Window_MenuCalender
#------------------------------------------------------------------------------
#  カレンダーの内容を表示するウィンドウです(メニュー画面用)。
#==============================================================================
 
class Window_MenuCalender < Window_Base
  #--------------------------------------------------------------------------
  # ● オブジェクト初期化
  #--------------------------------------------------------------------------
  def initialize(x = Graphics.width - 220, y = 0, w = 220)
    super(x, y, w, fitting_height(3))
    refresh
  end
  #--------------------------------------------------------------------------
  # ● リフレッシュ
  #--------------------------------------------------------------------------
  def refresh
    contents.clear
    draw_year
    draw_date
    draw_time
    draw_weather_icon
  end
  #--------------------------------------------------------------------------
  # ● 年の描画
  #--------------------------------------------------------------------------
  def draw_year
    season = $calender.season.to_s
    season.gsub!("Spring"){"春"}
    season.gsub!("Summer"){"夏"}
    season.gsub!("Autumn"){"秋"}
    season.gsub!("Winter"){"冬"}
    draw_text(0, 0, contents_width, line_height, "#{$calender.year}" + "年")
    draw_text(0, 0, contents_width + 12, line_height, season, 1)
  end
  #--------------------------------------------------------------------------
  # ● 月・日付・曜日の描画
  #--------------------------------------------------------------------------
  def draw_date
    w = contents_width
    h = line_height
    month = $calender.month
    if (0..9).to_a.include?(month)
      month = "0" + month.to_s
    else
      month = month.to_s
    end
    date = $calender.date
    if (0..9).to_a.include?(date)
      date = "0" + date.to_s
    else
      date = date.to_s
    end
    day = $calender.day.to_s
    day.gsub!("Sun"){"\\c[2]日\\c[0]"}
    day.gsub!("Mon"){"月"}
    day.gsub!("Tue"){"火"}
    day.gsub!("Wed"){"水"}
    day.gsub!("Thr"){"木"}
    day.gsub!("Fri"){"金"}
    day.gsub!("Sat"){"土"}
    draw_text_ex(12, h, month + "月" + date + "日" + "(" + day + ")")
  end
  #--------------------------------------------------------------------------
  # ● 時・分の描画
  #--------------------------------------------------------------------------
  def draw_time
    w = contents_width - 12
    h = line_height
    hour = "#{$calender.hour}"
    min = $calender.min
    if (0..9).to_a.include?(min)
      min = "0" + min.to_s
    else
      min = min.to_s
    end
    draw_text(0, h * 2, w, h, hour + ":" + min, 2)
  end
  #--------------------------------------------------------------------------
  # ● 天候アイコンの描画
  #--------------------------------------------------------------------------
  def draw_weather_icon
    case $calender.weather
    when :fine
      icon_index = WhiteSnow::FINE[:icon]
    when :rain
      icon_index = WhiteSnow::RAIN[:icon]
    when :snow
      icon_index = WhiteSnow::SNOW[:icon]
    when :thunder
      icon_index = WhiteSnow::THUNDER[:icon]
    when :storm
      icon_index = WhiteSnow::STORM[:icon]
    when :star
      icon_index = WhiteSnow::STAR[:icon]
    when :s_storm
      icon_index = WhiteSnow::S_STORM[:icon]
    end
    draw_icon(icon_index, contents_width - 30, 0)
  end
end
 
#==============================================================================
# ■ Scene_Map
#------------------------------------------------------------------------------
#  マップ画面の処理を行うクラスです。
#==============================================================================
 
class Scene_Map < Scene_Base
  #--------------------------------------------------------------------------
  # ● 全ウィンドウの作成
  #--------------------------------------------------------------------------
  alias calender_create_all_windows create_all_windows
  def create_all_windows
    calender_create_all_windows
    create_calender_window
  end
  #--------------------------------------------------------------------------
  # ● 日付表示ウィンドウの作成
  #--------------------------------------------------------------------------
  def create_calender_window
    @calender_window = Window_Calender.new
  end
end
 
#==============================================================================
# ■ Scene_Base
#------------------------------------------------------------------------------
#  ゲーム中の全てのシーンのスーパークラスです。
#==============================================================================
 
class Scene_Base
  #--------------------------------------------------------------------------
  # ● フレーム更新(基本)
  #--------------------------------------------------------------------------
  alias calender_update_basic update_basic
  def update_basic
    calender_update_basic
    update_calender
  end
  #--------------------------------------------------------------------------
  # ● 時刻の更新
  #--------------------------------------------------------------------------
  def update_calender
    return unless SceneManager.scene_is?(Scene_Map)
    return if $game_switches[WhiteSnow::TIME_COUNT_FORBID_SID]
    $calender.count += 1
    if $calender.weather == :thunder and !($game_switches[WhiteSnow::WEATHER_EFFECT_FORBID_SID] or $game_switches[WhiteSnow::INSIDE_FLAG_SID])
      $calender.thunder_count ||= [Graphics.frame_rate * 5 + (rand * Graphics.frame_rate * 10).floor, false]
      $calender.thunder_count[0] -= 1
      if $calender.thunder_count[1]
        if $calender.thunder_count[0] == 0
          se = RPG::SE.new(WhiteSnow::THUNDER[:se][0], WhiteSnow::THUNDER[:se][1], WhiteSnow::THUNDER[:se][2])
          se.play
          $calender.thunder_count = nil
        end
      elsif $calender.thunder_count[0] < 12 + rand(43)
        flash = WhiteSnow::THUNDER[:flash]
        $calender.perform_thunder_effect(flash[0], flash[1], flash[2], flash[3], flash[4])
        $calender.thunder_count[1] = true
      end
    else
      $calender.thunder_count = nil
    end
    if $calender.count % Graphics.frame_rate == 0
      $calender.min += 1
      $calender.count = 0
      $game_variables[WhiteSnow::MIN_STORE_VID] = $calender.min
      $calender.weather_count -= 1
      $calender.change_weather if $calender.weather_count <= 0
    end
    if $calender.min == 60
      $calender.hour += 1
      $calender.min = 0
      if $calender.hour >= 3 and $calender.hour < 19
        $calender.weather = :fine if $calender.weather == :star
      else
        $calender.weather = :star if $calender.weather == :fine
      end
      $calender.get_time_zone
      $calender.change_tone_by_calender
      $game_map.autoplay
      $game_variables[WhiteSnow::MIN_STORE_VID] = $calender.min
      $game_variables[WhiteSnow::HOUR_STORE_VID] = $calender.hour
    end
    if $calender.hour == 24
      $calender.hour = 0
      $calender.shift_date
    end
  end
end
 
#==============================================================================
# ■ Scene_Menu
#------------------------------------------------------------------------------
#  メニュー画面の処理を行うクラスです。
#==============================================================================
 
class Scene_Menu
  #--------------------------------------------------------------------------
  # ● 開始処理
  #--------------------------------------------------------------------------
  alias calender_start start
  def start
    calender_start
    create_calender_window
  end
  #--------------------------------------------------------------------------
  # ● 日付ウィンドウの作成
  #--------------------------------------------------------------------------
  def create_calender_window
    x = 0
    w = @gold_window.width
    @calender_window = Window_MenuCalender.new(x, 0, w)
    @calender_window.y = Graphics.height - @gold_window.height - @calender_window.height
  end
end
 
#==============================================================================
# ■ DataManager
#------------------------------------------------------------------------------
#  データベースとゲームオブジェクトを管理するモジュールです。ゲームで使用する
# ほぼ全てのグローバル変数はこのモジュールで初期化されます。
#==============================================================================
 
module DataManager
  #--------------------------------------------------------------------------
  # ● エイリアス用特異メソッド
  #--------------------------------------------------------------------------
  class << self
    alias :calender_create_game_objects :create_game_objects
    alias :calender_extract_save_contents :extract_save_contents
  end
  #--------------------------------------------------------------------------
  # ● 各種ゲームオブジェクトの作成
  #--------------------------------------------------------------------------
  def self.create_game_objects
    calender_create_game_objects
    $calender = Calender.new
  end
  #--------------------------------------------------------------------------
  # ● セーブ内容の作成 (再定義)
  #--------------------------------------------------------------------------
  def self.make_save_contents
    contents = {}
    contents[:system]           = $game_system
    contents[:timer]            = $game_timer
    contents[:message]          = $game_message
    contents[:switches]         = $game_switches
    contents[:variables]        = $game_variables
    contents[:self_switches]    = $game_self_switches
    contents[:actors]           = $game_actors
    contents[:party]            = $game_party
    contents[:troop]            = $game_troop
    contents[:map]              = $game_map
    contents[:player]           = $game_player
    contents[:calender]         = $calender
    contents
  end
  #--------------------------------------------------------------------------
  # ● セーブ内容の作成
  #--------------------------------------------------------------------------
  def self.extract_save_contents(contents)
    calender_extract_save_contents(contents)
    $calender = contents[:calender]
  end
end
 
#==============================================================================
# ■ Game_Interpreter
#------------------------------------------------------------------------------
#  イベントコマンドを実行するインタプリタです。このクラスは Game_Map クラス、
# Game_Troop クラス、Game_Event クラスの内部で使用されます。
#==============================================================================
 
class Game_Interpreter
  #--------------------------------------------------------------------------
  # ● 画面の色調変更(引数指定)
  #--------------------------------------------------------------------------
  def change_tone(r, g, b, gray = 0, dur = 60)
    tone = Tone.new(r, g, b, gray)
    screen.start_tone_change(tone, dur)
  end
  #--------------------------------------------------------------------------
  # ● 天候の変更(引数指定)
  #--------------------------------------------------------------------------
  def change_weather(type, power, dur = 30)
    return if $game_party.in_battle
    screen.change_weather(type, power, dur)
  end
  #--------------------------------------------------------------------------
  # ● 時間を設定
  #--------------------------------------------------------------------------
  def set_time(hour, min)
    hour = 23 if hour > 23
    hour = 0 if hour < 0
    min = 59 if min > 59
    min = 0 if min < 0
    $calender.hour = hour
    $calender.min = min
    $calender.get_time_zone
    $game_variables[WhiteSnow::MIN_STORE_VID] = $calender.min
    $game_variables[WhiteSnow::HOUR_STORE_VID] = $calender.hour
    $game_variables[WhiteSnow::DATE_STORE_VID] = $calender.date
    $game_map.autoplay
    $calender.change_weather
    $calender.change_tone_by_calender
    if $calender.hour >= 3 and $calender.hour < 19
      $calender.weather = :fine if $calender.weather == :star
    else
      $calender.weather = :star if $calender.weather == :fine
    end
  end
  #--------------------------------------------------------------------------
  # ● 日付を設定
  #--------------------------------------------------------------------------
  def set_date(month, date, day)
    $calender.month = month
    $calender.date = date
    $calender.day = day
    $game_variables[WhiteSnow::MIN_STORE_VID] = $calender.month
    $game_variables[WhiteSnow::DATE_STORE_VID] = $calender.date
    case $calender.day
    when :Sun
      $game_variables[WhiteSnow::DAY_STORE_VID] = 0
    when :Mon
      $game_variables[WhiteSnow::DAY_STORE_VID] = 1
    when :Tue
      $game_variables[WhiteSnow::DAY_STORE_VID] = 2
    when :Wed
      $game_variables[WhiteSnow::DAY_STORE_VID] = 3
    when :Thr
      $game_variables[WhiteSnow::DAY_STORE_VID] = 4
    when :Fri
      $game_variables[WhiteSnow::DAY_STORE_VID] = 5
    when :Sat
      $game_variables[WhiteSnow::DAY_STORE_VID] = 6
    end
 
    case $calender.month
    when 1..2
      $calender.season = :Winter
      $game_variables[WhiteSnow::SEASON_STORE_VID] = 3
    when 3..5
      $calender.season = :Spring
      $game_variables[WhiteSnow::SEASON_STORE_VID] = 0
    when 6..8
      $calender.season = :Summer
      $game_variables[WhiteSnow::SEASON_STORE_VID] = 1
    when 9..11
      $calender.season = :Autumn
      $game_variables[WhiteSnow::SEASON_STORE_VID] = 2
    when 12
      $calender.season = :Winter
      $game_variables[WhiteSnow::SEASON_STORE_VID] = 3
    end
    $calender.change_weather
  end
  #--------------------------------------------------------------------------
  # ● 年を設定
  #--------------------------------------------------------------------------
  def set_year(year)
    $calender.year = year
    $game_variables[WhiteSnow::YEAR_STORE_VID] = year
    $calender.change_weather
  end
  #--------------------------------------------------------------------------
  # ● 天候を設定
  #--------------------------------------------------------------------------
  def set_weather(weather)
    $calender.weather = weather
    $calender.randomize_weather_count
    $calender.perform_weather_effect
    case weather
    when :fine
      $game_variables[WhiteSnow::WEATHER_STORE_VID] = 0
    when :rain
      $game_variables[WhiteSnow::WEATHER_STORE_VID] = 1
    when :snow
      $game_variables[WhiteSnow::WEATHER_STORE_VID] = 2
    when :thunder
      $game_variables[WhiteSnow::WEATHER_STORE_VID] = 3
    when :storm
      $game_variables[WhiteSnow::WEATHER_STORE_VID] = 4
    when :star
      $game_variables[WhiteSnow::WEATHER_STORE_VID] = 5
    when :s_storm
      $game_variables[WhiteSnow::WEATHER_STORE_VID] = 6
    end
  end
  #--------------------------------------------------------------------------
  # ● 天候エフェクトを発生させる
  #--------------------------------------------------------------------------
  def perform_weather_effect
    $calender.perform_weather_effect
  end
  #--------------------------------------------------------------------------
  # ● 画面のフラッシュ(引数指定)
  #--------------------------------------------------------------------------
  def perform_flash(r, g, b, alpha, dur = 12)
    color = Color.new(r, g, b, alpha)
    screen.start_flash(color, dur)
  end
  #--------------------------------------------------------------------------
  # ● 日付を進める
  #--------------------------------------------------------------------------
  def shift_date(num)
    num.times{$calender.shift_date}
    $calender.change_weather
  end
  #--------------------------------------------------------------------------
  # ● 月を進める
  #--------------------------------------------------------------------------
  def shift_month(num)
    table = WhiteSnow::DAYS_TABLE
    days = table[$calender.month] - $calender.date + 1
    for i in 1..num
      days += table[($calender.month + i) % 12]
    end
    days.times{$calender.shift_date}
    $calender.change_weather
  end
  #--------------------------------------------------------------------------
  # ● 年を進める
  #--------------------------------------------------------------------------
  def shift_year(num)
    (num * 365).times{$calender.shift_date}
    $calender.change_weather
  end
  #--------------------------------------------------------------------------
  # ● 指定した日まで日付を進める
  #--------------------------------------------------------------------------
  def shift_date_to(m, d, y = -1)
    y = $calender.year if y == -1
    if $calender.days_dif(y, m, d) > 0
      $calender.days_dif(y, m, d).times{$calender.shift_date}
    else
      $calender.days_dif(y, m, d).abs.times{$calender.back_date}
    end
    $calender.change_weather
  end
end
 
#==============================================================================
# ■ SceneManager
#------------------------------------------------------------------------------
#  シーン遷移を管理するモジュールです。たとえばメインメニューからアイテム画面
# を呼び出し、また戻るというような階層構造を扱うことができます。
#==============================================================================
 
module SceneManager
  #--------------------------------------------------------------------------
  # ● エイリアス用特異メソッド
  #--------------------------------------------------------------------------
  class << self
    alias :calender_goto   :goto
    alias :calender_call   :call
    alias :calender_return :return
  end
  #--------------------------------------------------------------------------
  # ● 直接遷移
  #--------------------------------------------------------------------------
  def self.goto(scene_class)
    calender_goto(scene_class)
    if scene_class == Scene_Map
      $calender.perform_weather_effect
      $calender.change_tone_by_calender
    end
  end
  #--------------------------------------------------------------------------
  # ● 呼び出し
  #--------------------------------------------------------------------------
  def self.call(scene_class)
    calender_call(scene_class)
    if scene_class == Scene_Map
      $calender.perform_weather_effect
      $calender.change_tone_by_calender
    end
  end
  #--------------------------------------------------------------------------
  # ● 呼び出し元へ戻る
  #--------------------------------------------------------------------------
  def self.return
    calender_return
    if @scene.class == Scene_Map
      $calender.perform_weather_effect
      $calender.change_tone_by_calender
    end
  end
end
 
#==============================================================================
# ■ Game_Switches
#------------------------------------------------------------------------------
#  スイッチを扱うクラスです。組み込みクラス Array のラッパーです。このクラス
# のインスタンスは $game_switches で参照されます。
#==============================================================================
 
class Game_Switches
  #--------------------------------------------------------------------------
  # ● スイッチの設定 (再定義)
  #     value : ON (true) / OFF (false)
  #--------------------------------------------------------------------------
  def []=(switch_id, value)
    @data[switch_id] = value
    on_change
    if switch_id == WhiteSnow::TONE_CHANGE_FORBID_SID or switch_id == WhiteSnow::INSIDE_FLAG_SID
      case value
      when true
        $calender.interpreter.change_tone(0, 0, 0, 0, 0)
      when false
        $calender.change_tone_by_calender(0)
      end
    end
    if switch_id == WhiteSnow::WEATHER_EFFECT_FORBID_SID or switch_id == WhiteSnow::INSIDE_FLAG_SID
      case value
      when true
        $calender.interpreter.change_weather(:none, 0, 0)
        RPG::BGS.stop if (WhiteSnow::WEATHER_BGS_ENABLE and [0, 1].include?(WhiteSnow::INSIDE_BGS_TYPE)) or $game_switches[WhiteSnow::WEATHER_BGS_DISABLE]
        $calender.play_inside_bgs if WhiteSnow::WEATHER_BGS_ENABLE and WhiteSnow::INSIDE_BGS_TYPE == 1 and !$game_switches[WhiteSnow::WEATHER_BGS_DISABLE]
      when false
        $calender.perform_weather_effect(0)
      end
    end
  end
end
 
#==============================================================================
# ■ Game_Player
#------------------------------------------------------------------------------
#  プレイヤーを扱うクラスです。イベントの起動判定や、マップのスクロールなどの
# 機能を持っています。このクラスのインスタンスは $game_player で参照されます。
#==============================================================================
 
class Game_Player
  #--------------------------------------------------------------------------
  # ● 場所移動の実行
  #--------------------------------------------------------------------------
  alias calender_perform_transfer perform_transfer
  def perform_transfer
    if transfer?
      $calender.perform_weather_effect(0)
      $calender.change_tone_by_calender(0)
    end
    calender_perform_transfer
  end
end
 
#==============================================================================
# ■ RPG::Map
#------------------------------------------------------------------------------
#  マップのデータクラスです。
#==============================================================================
 
class RPG::Map
  #--------------------------------------------------------------------------
  # ● マップBGM
  #--------------------------------------------------------------------------
  def bgm
    bgm = Hash.new(@bgm)
    @note.each_line do |line|
      case line
      when /<(?:早朝|early)\s*(.+)\s*\,\s*(\d+)\s*\,\s*(\d+)>/
        bgm[:early_morning] = RPG::BGM.new($1, $2.to_i, $3.to_i)
      when /<(?:朝|morning)\s*(.+)\s*\,\s*(\d+)\s*\,\s*(\d+)>/
        bgm[:morning] = RPG::BGM.new($1, $2.to_i, $3.to_i)
      when /<(?:昼|noon)\s*(.+)\s*\,\s*(\d+)\s*\,\s*(\d+)>/
        bgm[:noon] = RPG::BGM.new($1, $2.to_i, $3.to_i)
      when /<(?:夕方|evening)\s*(.+)\s*\,\s*(\d+)\s*\,\s*(\d+)>/
        bgm[:evening] = RPG::BGM.new($1, $2.to_i, $3.to_i)
      when /<(?:夜|night)\s*(.+)\s*\,\s*(\d+)\s*\,\s*(\d+)>/
        bgm[:night] = RPG::BGM.new($1, $2.to_i, $3.to_i)
      when /<(?:深夜|mid)\s*(.+)\s*\,\s*(\d+)\s*\,\s*(\d+)>/
        bgm[:midnight] = RPG::BGM.new($1, $2.to_i, $3.to_i)
      end
    end
    return bgm
  end
end
 
#==============================================================================
# ■ Game_Map
#------------------------------------------------------------------------------
#  マップを扱うクラスです。スクロールや通行可能判定などの機能を持っています。
# このクラスのインスタンスは $game_map で参照されます。
#==============================================================================
 
class Game_Map
  #--------------------------------------------------------------------------
  # ● BGM / BGS 自動切り替え (再定義)
  #--------------------------------------------------------------------------
  def autoplay
    case $calender.time_zone
    when :early_morning
      @map.bgm[:early_morning].play if @map.autoplay_bgm
    when :morning
      @map.bgm[:morning].play if @map.autoplay_bgm
    when :noon
      @map.bgm[:noon].play if @map.autoplay_bgm
    when :evening
      @map.bgm[:evening].play if @map.autoplay_bgm
    when :night
      @map.bgm[:night].play if @map.autoplay_bgm
    when :midnight
      @map.bgm[:midnight].play if @map.autoplay_bgm
    end
    @map.bgs.play if @map.autoplay_bgs
  end
end
 
module Kernel
  #--------------------------------------------------------------------------
  # ● 重み付きの乱数を生成
  #--------------------------------------------------------------------------
  def p_ex_rand(rate, n = 0)
    srand
    rate = 99 if rate == 100
    if n == 0
      r = 1 - rand ** (1 - rate * 0.01)
      if r == 1
        return 0
      else
        return r
      end
    else
      num = n.truncate
      r = 1 - rand ** (1 - rate * 0.01)
      r = 0 if r == 1
      return (r * num).floor
    end
  end
end
 | 
 评分
查看全部评分
 |