查看: 4468|回复: 16

[转载发布] 6R不常见脚本发放,需要的自己拿(转载,常年收集好用)

[复制链接]
梦石
0
星屑
1345
在线时间
378 小时
注册时间
2015-6-16
回帖
526
发表于 2017-7-19 14:49:39 | 显示全部楼层 |阅读模式

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有账号?注册会员

×
本帖最后由 300英雄 于 2017-7-19 15:16 编辑

网址
[pre lang="ruby"]#==============================================================================
# ★ RGSS3_リンク付きクレジット Ver1.1
#==============================================================================
=begin

作者:tomoaky
webサイト:ひきも記は閉鎖しました。 (http://hikimoki.sakura.ne.jp/)

ブラウザでリンク先のサイトを開く機能をもったクレジットシーンです、
タイトルコマンドに追加されます。

以下のおまけ機能があります。

イベントコマンド『スクリプト』を使い、任意のサイトをブラウザで開く。
  open_url("http://hikimoki.sakura.ne.jp/")
  
タイトルシーンからGame.exeと同じ場所にある readme.txt を開く。
  
2014.10.09  Ver1.1
  ・おまけ機能追加

2014.10.08  Ver1.0
  ・公開

=end

#==============================================================================
# □ 設定項目
#==============================================================================
module TMCREDIT
  # クレジットの設定(["サイト名", "説明", "URL"])
  DATA = [
    ["勇冒的通知", "通知", "http://guangmingmofaling.lofter.com/post/1e3937c2_da6506b"],
    ["勇冒1.9。", "1.9", "http://guangmingmofaling.lofter.com/post/1e3937c2_cfa6f62"],
    ["勇冒2.0。", "2.0", "http://guangmingmofaling.lofter.com/post/1e3937c2_ebbe968"],
    ["勇冒2.1。", "2.1", "http://guangmingmofaling.lofter.com/post/1e3937c2_ed79836"],
    ["勇冒2.2。", "2.2", "http://guangmingmofaling.lofter.com/post/1e3937c2_f281213"],
    ["勇冒2.3。", "2.3", "http://guangmingmofaling.lofter.com/post/1e3937c2_f30b3e3"],
  ]
  
  TITLE_INDEX = 2   # タイトルコマンドの何番目に挿入するか(0 が先頭)
  
  USE_MANUAL_CALL = false  # readme.txt の呼び出し機能を使うか(false で無効)
end

#==============================================================================
# □ コマンド
#==============================================================================
module TMCREDIT
module Commands
  #--------------------------------------------------------------------------
  # ○ ブラウザでサイトを開く
  #--------------------------------------------------------------------------
  def open_url(url)
    a = Win32API.new("shell32", "ShellExecuteA", %w(p p p p p i),"i")
    a.call(0, "open", url, 0, 0, 1)
  end
  module_function :open_url
end
end # module TMCREDIT

#==============================================================================
# ■ Game_Event
#==============================================================================
class Game_Event
  include TMCREDIT::Commands
end

#==============================================================================
# ■ Game_Interpreter
#==============================================================================
class Game_Interpreter
  include TMCREDIT::Commands
end

#==============================================================================
# ■ Window_TitleCommand
#==============================================================================
class Window_TitleCommand < Window_Command
  #--------------------------------------------------------------------------
  # ● コマンドリストの作成
  #--------------------------------------------------------------------------
  alias tmcredit_window_titlecommand_make_command_list make_command_list
  def make_command_list
    tmcredit_window_titlecommand_make_command_list
    @list.insert(TMCREDIT::TITLE_INDEX,
      {:name=>"更新网站", :symbol=>:credit, :enabled=>true, :ext=>nil})
    if TMCREDIT::USE_MANUAL_CALL
      @list.insert(TMCREDIT::TITLE_INDEX + 1,
        {:name=>"説明書", :symbol=>:manual, :enabled=>true, :ext=>nil})
    end
  end
end

#==============================================================================
# ■ Window_Credit
#==============================================================================
class Window_Credit < Window_Selectable
  #--------------------------------------------------------------------------
  # ● オブジェクト初期化
  #--------------------------------------------------------------------------
  def initialize(x, y, width, height)
    @data = TMCREDIT::DATA.clone
    super
    select(0)
    activate
    refresh
  end
  #--------------------------------------------------------------------------
  # ● 項目数の取得
  #--------------------------------------------------------------------------
  def item_max
    @data.size
  end
  #--------------------------------------------------------------------------
  # ● アイテムの取得
  #--------------------------------------------------------------------------
  def item
    @data[index]
  end
  #--------------------------------------------------------------------------
  # ● URLの取得
  #--------------------------------------------------------------------------
  def url
    @data[index][2]
  end
  #--------------------------------------------------------------------------
  # ● 項目の描画
  #--------------------------------------------------------------------------
  def draw_item(index)
    item = @data[index]
    if item
      rect = item_rect_for_text(index)
      draw_text(rect, sprintf("%s (%s)", item[0], item[2]))
    end
  end
  #--------------------------------------------------------------------------
  # ● ヘルプテキスト更新
  #--------------------------------------------------------------------------
  def update_help
    text = sprintf("\\C[16]%s\\C[0] %s", item[1], item[0])
    text += "\n\\C[2](确定键进去网址)"
    @help_window.set_text(text)
  end
  #--------------------------------------------------------------------------
  # ● リフレッシュ
  #--------------------------------------------------------------------------
  def refresh
    create_contents
    draw_all_items
  end
end

#==============================================================================
# ■ Scene_Title
#==============================================================================
class Scene_Title < Scene_Base
  #--------------------------------------------------------------------------
  # ● コマンドウィンドウの作成
  #--------------------------------------------------------------------------
  alias tmcredit_scene_title_create_command_window create_command_window
  def create_command_window
    tmcredit_scene_title_create_command_window
    @command_window.set_handler(:credit, method(:command_credit))
    if TMCREDIT::USE_MANUAL_CALL
      @command_window.set_handler(:manual, method(:command_manual))
    end
  end
  #--------------------------------------------------------------------------
  # ○ コマンド[クレジット]
  #--------------------------------------------------------------------------
  def command_credit
    close_command_window
    SceneManager.call(Scene_Credit)
  end
  #--------------------------------------------------------------------------
  # ○ コマンド[説明書]
  #--------------------------------------------------------------------------
  def command_manual
    @command_window.activate
    TMCREDIT::Commands.open_url("readme.txt")
  end
end

#==============================================================================
# ■ Scene_Credit
#==============================================================================
class Scene_Credit < Scene_MenuBase
  #--------------------------------------------------------------------------
  # ● 開始処理
  #--------------------------------------------------------------------------
  def start
    super
    create_help_window
    create_item_window
  end
  #--------------------------------------------------------------------------
  # ● クレジットウィンドウの作成
  #--------------------------------------------------------------------------
  def create_item_window
    ww = Graphics.width
    wh = Graphics.height - @help_window.height
    @credit_window = Window_Credit.new(0, @help_window.height, ww, wh)
    @credit_window.help_window = @help_window
    @credit_window.set_handler(:ok,     method(:on_credit_ok))
    @credit_window.set_handler(:cancel, method(:return_scene))
  end
  #--------------------------------------------------------------------------
  # ● クレジット[決定]
  #--------------------------------------------------------------------------
  def on_credit_ok
    TMCREDIT::Commands.open_url(@credit_window.url)
    @credit_window.activate
  end
end[/pre]

复活机制
[pre lang="ruby"]#encoding:utf-8

=begin
*******************************************************************************************
   * 時間自動復活機制 *
                       for RGSS3
        Ver 1.00   2014.01.29
   原作者:魂(Lctseng),巴哈姆特論壇ID:play123
   替"ace922(容)"撰寫的特製版本
   
   轉載請保留此標籤
   個人小屋連結:http://home.gamer.com.tw/homeindex.php?owner=play123
   主要功能:
                       一、指定回合數到後角色會自動復活
                       二、若角色身上擁有"無法他人復活"狀態,則他人的復活相關技能將對其沒有作用。
                       
   更新紀錄:
    Ver 1.00 :
    日期:2014.01.29
    摘要:■、最初版本
                ■、功能:                  
                       一、指定回合數到後角色會自動復活
                       二、若角色身上擁有"無法他人復活"狀態,則他人的復活相關技能將對其沒有作用。
    撰寫摘要:一、此腳本修改或重新定義以下類別:
                           ■ Game_Actor
                          
                        二、此腳本新定義以下類別和模組:
                           ■ Lctseng::AutoRevive
                          
*******************************************************************************************
=end

#encoding:utf-8
#==============================================================================
# ■ Lctseng::AutoRevive
#------------------------------------------------------------------------------
#  自動復活設定模組
#==============================================================================

module Lctseng
module AutoRevive
  #--------------------------------------------------------------------------
  # ● 設定是否顯示Console 紀錄
  #--------------------------------------------------------------------------
  SHOW_CONSOLE_INFO = true
  #--------------------------------------------------------------------------
  # ● 設定復活所需回合數
  #--------------------------------------------------------------------------
  REVIVE_TURN = 10
  #--------------------------------------------------------------------------
  # ● 設定復活時候,HP與MP的恢復計算公式
  #--------------------------------------------------------------------------
  HP_FORMULA =  " rand(10000) "
  MP_FORMULA =  " mat + mdf "
  #--------------------------------------------------------------------------
  # ● 設定相關狀態編號
  #--------------------------------------------------------------------------
  DEAD_STATE = 1 # 死亡的狀態
  NO_REVIVE_STATES = [197] # 禁止復活的狀態數列
  
end
end

#*******************************************************************************************
#
#   請勿修改從這裡以下的程式碼,除非你知道你在做什麼!
#   DO NOT MODIFY UNLESS YOU KNOW WHAT TO DO !
#
#*******************************************************************************************

#--------------------------------------------------------------------------
# ★ 紀錄腳本資訊
#--------------------------------------------------------------------------
if !$lctseng_scripts  
  $lctseng_scripts = {}
end


$lctseng_scripts[:auto_revive] = "1.00"

puts "載入腳本:Lctseng - 時間自動復活機制,版本:#{$lctseng_scripts[:auto_revive]}"

#encoding:utf-8
#==============================================================================
# ■ Game_Actor
#------------------------------------------------------------------------------
#  管理角色的類。
#   本類在 Game_Actors 類 ($game_actors) 的內部使用。
#   具體使用請查看 Game_Party 類 ($game_party) 。
#==============================================================================

class Game_Actor < Game_Battler
  #--------------------------------------------------------------------------
  # ● 回合結束處理
  #--------------------------------------------------------------------------
  def on_turn_end
    super
    #puts "#{self.name}執行回合結束。" if Lctseng::AutoRevive::SHOW_CONSOLE_INFO
    if dead?
      if !@dead_turn
        @dead_turn = 0
      end
      puts " #{self.name}已經死了#{@dead_turn}個回合..." if Lctseng::AutoRevive::SHOW_CONSOLE_INFO
      if @dead_turn >= Lctseng::AutoRevive::REVIVE_TURN
        puts " #{self.name}復活!清除死亡回合計數!" if Lctseng::AutoRevive::SHOW_CONSOLE_INFO
        revive
        remove_state(Lctseng::AutoRevive::DEAD_STATE,true)
        self.hp += eval_formula(Lctseng::AutoRevive::HP_FORMULA)
        self.mp += eval_formula(Lctseng::AutoRevive::MP_FORMULA)
        @dead_turn = 0
      else
        @dead_turn += 1
      end
    else
      @dead_turn = 0
    end
    if alive?
      ## 還活著,自行解除任何限制復活狀態
      Lctseng::AutoRevive::NO_REVIVE_STATES.each do |state_id|
        if state?(state_id)
          puts " #{self.name}還活著,持有#{$data_states[state_id].name},將自動解除" if Lctseng::AutoRevive::SHOW_CONSOLE_INFO
          remove_state(state_id)
        end
      end
    end
  end
  #--------------------------------------------------------------------------
  # ● 計算公式
  #--------------------------------------------------------------------------
  def eval_formula(formula)
    eval(formula).round rescue 0
  end
  #--------------------------------------------------------------------------
  # ● 計算傷害
  #--------------------------------------------------------------------------
  def make_damage_value(user, item)
    new_item = item
    if dead? && Lctseng::AutoRevive::NO_REVIVE_STATES.any? { |state_id|  state?(state_id) }
      new_item = Marshal.load(Marshal.dump(item))
      new_item.damage.formula = "0"
      puts "#{self.name}已死亡且受到復活限制狀態,恢復HP計算強制歸零" if Lctseng::AutoRevive::SHOW_CONSOLE_INFO
    end
    super(user,new_item)
  end
  #--------------------------------------------------------------------------
  # ● 更改 HP
  #--------------------------------------------------------------------------
  def hp=(hp)
    if dead? && Lctseng::AutoRevive::NO_REVIVE_STATES.any? { |state_id|  state?(state_id) }
      hp = 0
      puts "#{self.name}已死亡且受到復活限制狀態,HP強制為0" if Lctseng::AutoRevive::SHOW_CONSOLE_INFO
    end
    super(hp)
  end
  #--------------------------------------------------------------------------
  # ● 應用“恢復 HP”效果
  #--------------------------------------------------------------------------
  def item_effect_recover_hp(user, item, effect)
    if dead? && Lctseng::AutoRevive::NO_REVIVE_STATES.any? { |state_id|  state?(state_id) }
      puts " #{self.name}有禁止復活的狀態,恢復HP無效。" if Lctseng::AutoRevive::SHOW_CONSOLE_INFO
    else
      super
    end
  end
  #--------------------------------------------------------------------------
  # ● 應用“狀態解除”效果
  #--------------------------------------------------------------------------
  def item_effect_remove_state(user, item, effect)
    if effect.data_id == Lctseng::AutoRevive::DEAD_STATE
      if !Lctseng::AutoRevive::NO_REVIVE_STATES.any? { |state_id|  state?(state_id) }
        super
        if !state?(effect.data_id)
          @dead_turn = 0
          puts "#{self.name}已經復活!清除死亡回合數。"if Lctseng::AutoRevive::SHOW_CONSOLE_INFO
        end
      end
    else
      super
    end
  end
  #--------------------------------------------------------------------------
  # ● 解除狀態
  #--------------------------------------------------------------------------
  def remove_state(state_id,force = false)
    if state_id == Lctseng::AutoRevive::DEAD_STATE
      if force || !Lctseng::AutoRevive::NO_REVIVE_STATES.any? { |state_id|  state?(state_id) }
        super(state_id)
      end
    else
      super(state_id)
    end
  end
  #--------------------------------------------------------------------------
  # ● 死亡
  #--------------------------------------------------------------------------
  def die
    @dead_turn = 0
    @hp = 0
    clear_states_except_revive_limit
    clear_buffs
  end
  #--------------------------------------------------------------------------
  # ● 清除除了死亡限制以外的狀態
  #--------------------------------------------------------------------------
  def clear_states_except_revive_limit
    ## 先記錄死亡狀態資訊
    states = {}
    Lctseng::AutoRevive::NO_REVIVE_STATES.each do |state_id|
      if @states.include?(state_id)
        states[state_id] = [@state_steps[state_id],@state_turns[state_id]]
      end
    end
    ## 呼叫原始的清除方法
    clear_states
    ## 把剛才紀錄的狀態放回去
    states.each_pair do |state_id,data|
      @states.push(state_id)
      @state_steps[state_id] = data[0]
      @state_turns[state_id] = data[1]
    end
    sort_states
  end
  #--------------------------------------------------------------------------
  # ● 判定狀態是否可以附加
  #--------------------------------------------------------------------------
  def state_addable?(state_id)
    if Lctseng::AutoRevive::NO_REVIVE_STATES.include?(state_id)
      $data_states[state_id] && !state_resist?(state_id) &&
      !state_removed?(state_id) && !state_restrict?(state_id)
    else
      super
    end
  end
  #--------------------------------------------------------------------------
  # ● 測試使用效果
  #--------------------------------------------------------------------------
  def item_effect_test(user, item, effect)
    if effect.code == EFFECT_REMOVE_STATE && effect.data_id == Lctseng::AutoRevive::DEAD_STATE
      state?(effect.data_id) && !Lctseng::AutoRevive::NO_REVIVE_STATES.any? { |state_id|  state?(state_id) }
    else
      super
    end
  end
  
end[/pre]

时间脚本
[pre lang="ruby"]#==============================================================================
# ■ BMSP 暦システム[KOYOMISYSTEM] Ver1.24 2014/08/09
#------------------------------------------------------------------------------
#  日付,時間の概念を導入します.
#==============================================================================
#------------------------------------------------------------------------------
# ■内容
# ゲームに日付,時間の概念を導入します.
# 自由に暦を設定して任意のタイミングで時間を進めることができます.
# 時間に合わせて画面の色調を自動で変更することも可能です.
#
# 位置:特に指定はありません
#
# ■使用方法
# スクリプトに丸ごと貼り付けていただければ使用できます.
#
# ●暦の設定
# まずは詳細設定にて暦の設定を行って下さい.
#
# ○RANKS:ランクの設定を行います.
# ランクとは秒,分,時,,などのような時間の単位を表します.
# ランクは上から順にランク0,ランク1と呼び,
# あるランクの値が上限を超えると一つ上のランクに繰り上げされます.
# 各ランクは
#   ランク名 => 値の範囲
# のように設定します.
# 例
#   RANKS = {
#     :sec => 0...60,
#     :min => 0...60,
#     :hour => 0...24,
#     :day => 1..30,
#     :mon => 1..12,
#     :year => 1..9999
#   }
# 上記の例ではランクの低い順に秒,分,時,日,月,年を設定しています.
# また,それぞれ取り得る値の範囲も指定しています.
# (一月30日で年は便宜上9999年を上限としています)
# 例えばdayが25のときに7加算され32になると,
# 結果としてdayは2になり,monは1加算されます.
# このようにして基本となる暦を作成します.
# この部分を任意に変えることで自由な暦を設定できます.
#
# ○ SPECIAL_EXP:ランク以外の特別な暦情報を設定します
# 例えば曜日や季節,時間帯などを設定することができます.
# 設定の仕方は以下のフォーマットにしたがってください.
#   SPECIAL_EXP[:%special%] = ->(cal){
#      任意の式
#   }
# %special%に設定する名前を指定し,対応する任意の式を記述します.
# このときcalにより暦オブジェクトが参照できます.
# 例・時間帯の設定
#   SPECIAL_EXP[:timezone] = ->(cal){
#     case cal.hour
#    when 4,5
#       0 # 早朝は0を返す
#     when 6,7,8
#       1 # 朝は1を返す
#     when 9...16
#       2 # 昼は2を返す
#     when 16,17
#       3 # 夕方は3を返す
#     when 18...22
#       4 # 夜は4を返す
#     when 22...24,0...4
#      5 # 深夜は5を返す
#     end
#   }
#
# ○ TRANSFORM:表示変換の設定を行います.
# 暦を文字列として表現する際,整数以外の形式で表示したい場合に使用します.
# また,全く新しい独自の表示形式を指定することも可能
# 例・月の文字列表記
#   TRANSFORM[:mon] = ->(cal){
#     ["Jan", "Fab", "Mar", "Apr", "May", "Jun",
#      "Jul", "Aug", "Seq", "Oct", "Nov", "Dec"][cal.mon]
#   }
#
# ○ INITIAL_CAL:ゲーム開始時の暦を設定します.
# 設定したいランクと対応する値を指定します.
# 指定されなかったランクの初期値は値の範囲のうち最小のものになります.
# 例
#   INITIAL_CAL = {
#     :day => 15,
#     :mon => 12,
#     :year => 2011
#   }
# この例では2011年12月15日0時0分0秒が初期値となります.
#
# ○ MAP_WINDOW:マップで暦ウインドウを表示するかを設定します.
# この設定はゲーム中以下のスクリプトにて切り替え可能です.
#   $game_map.koyomi_display = true/false
#
# ○ MAP_WINDOW_FADE:マップでの暦ウインドウをフェードするか設定します.
# trueのとき一定時間表示したあとフェードアウトします.
# falseのとき暦ウインドウを常に表示します.
#
# ○ HIDE_MAP_WINDOW:マップで暦ウインドウを常に表示するとき,
#                     ウインドウを一時的に消去できるか設定します.
# この設定はゲーム中以下のスクリプトによって切り替え可能です.
#   $game_koyomi.hide_map_window = true/false
# ○ HIDE_KEY:マップで暦ウインドウを一時的に消去するボタンです.
#              もう一度押すと再び表示します.
# また,次のスクリプトをマップ上で実行するとイベント側から暦ウインドウの
# 一時消去および再表示を行うことができます.
#   $game_map.hide_koyomi_window = true/false
#
# ○ MAP_WINDOW_FORMAT:マップでの暦ウインドウの表示内容を設定します.
# 配列でフォーマットを指定します.一つの要素につき一行となります.
# フォーマットについては後述のメソッドstrftimeを参照してください.
#
# ○ MENU_WINDOW:メニューで暦ウインドウを表示するかを設定します.
#
# ○ MENU_WINDOW_FORAMT:メニューでの暦ウインドウの表示内容を設定します.
# 設定の仕方はMAP_WINDOW_FORMATと同様です.
#
# ○ AUTO_TONE:暦による画面の色調の自動変更を設定します.
# trueの時時間によって画面の色調が自動で変更されます.
# また,イベントコマンドによる画面の色調変更は機能しなくなります.
# ただし,後述する色調固定マップでは機能します.
# この設定はゲーム中以下のスクリプトにて切り替え可能です.
#   $game_koyomi.auto_tone = true/false
#
# ○ AUTO_TONE_DURATION:デフォルトの色調変更時間の設定です.
# 色調変更の条件で色調変更時間が指定されない場合はこの値が適用されます.
#
# ○ AUTO_TONE_COND:色調変更の条件を設定します.
# 色調を変更する条件となる時間とそれに対応する色調(Tone)を指定します.
# 上にある条件ほど優先的にマッチします.
# 条件の指定方法は条件に設定したいrankをキーにして対応する値を直接指定するか
# 値の範囲で指定します.22..4(22...24かつ0..4)のような指定も可能です.
# 範囲に関しては(0...3)の場合0から2まで,0...3の場合0から3までを表します.
# また,対応する色調は以下で指定します.
#   Tone.new(赤(-255~255),緑(-255~255),青(-255~255),グレー(0~255))
# 例・時間帯によって色調を変える
# AUTO_TONE_COND = {
#   {:hour => 16...18} => Tone.new(68,-34,-34,0),
#   {:hour => 18...22} => Tone.new(-34,-34,0,34),
#   {:hour => 22...4} => Tone.new(-68,-68,0,68),
#   {:hour => 4...6} => Tone.new(-34,-34,-34,34),
#   {:hour => 6...9} => Tone.new(34,34,34,34)
# }
#
# ○ FIX_TONE_ON_BATTLE:バトル画面では画面の色調を変更しない設定にできます.
# trueの場合マップで色調が自動変更されている場合でも画面の色調はデフォルト(0,0,0,0)になります.
# また,色調固定マップの場合でもデフォルトの色調になります.
#
# ○ AUTO_TIME_PASS:時間が自動経過するかを設定します.
# この設定はゲーム中以下のスクリプトによって切り替え可能です.
#   $game_koyomi.auto_time_pass = true/false
#
# ○ AUTO_TIME_PASS_DURATION:時間の自動経過間隔を設定します.
# 指定したフレームが経過するごとにTIME_PASSINGで指定した分の時間が経過します.
#
# ○ TIME_PASSING:時間の自動経過量を設定します.
# 加算したいランクと対応する加算量を指定してください.
# 例・1分30秒ずつ加算する
#   TIME_PASSING = {:min => 1, :sec => 30}
#
# ○ STOP_ON_EVENT:イベント中は時間の自動経過を停止するか設定します.
# この設定はゲーム中以下のスクリプトによって切り替え可能です.
#   $game_koyomi.stop_auto_time_pass_on_event = true/false
#
# ○ STOP_ON_BATTLE:バトル中は時間の自動経過を停止するか設定します.
# この設定はゲーム中以下のスクリプトによって切り替え可能です.
#   $game_koyomi.stop_auto_time_pass_on_battle = true/false
#
# ○ MOVE_TIME_PASS:場所移動による時間経過を設定します.
# 「場所移動」が行われる度に時間を経過させることができます.
# 加算したいランクと対応する加算量を指定してください.
# 場所移動により加算したくない場合は空のハッシュを指定してください.
#
# ○ BATTLE_START_TIME_PASS:戦闘開始による時間経過を設定します.
# 戦闘開始時に時間を経過させることができます.
# 加算したいランクと対応する加算量を指定してください.
# 加算したくない場合は空のハッシュを指定してください.
#
# ○ BATTLE_END_TIME_PASS:戦闘終了による時間経過を設定します.
# 戦闘終了時に時間を経過させることができます.
# 加算したいランクと対応する加算量を指定してください.
# 加算したくない場合は空のハッシュを指定してください.
#
# ●暦の操作
# ゲーム中は基本的にスクリプトコマンドから$game_koyomiにアクセスすることで暦を操作できます.
# 以下は$game_koyomiからできる主な操作一覧です.
# ○ $game_koyomi.auto_tone = true/false
# 時間による画面色調の自動変更をするかどうか設定できます.
#
# ○ $game_koyomi.tone_temp_duration = int
# これを設定した次の画面色調自動変更時のみ指定した時間で色調が変化します.
# イベント等で時間を進めた際早く色調を切り替えたいときなどに利用します.
#
# ○ $game_koyomi.move_temp_time_pass = {:rank => value, ...}
# これを指定した次の場所移動時のみ指定した分だけ時間が経過します.
#
# ○ $game_koyomi.battle_start_temp_time_pass = {:rank => value, ...}
# これを指定した次の戦闘開始時のみ指定した分だけ時間が経過します.
#
# ○ $game_koyomi.battle_end_temp_time_pass = {:rank => value, ...}
# これを指定した次の戦闘終了時時のみ指定した分だけ時間が経過します.
#
# ○ $game_koyomi.auto_time_pass = true/false
# 自動で時間を経過させるか設定できます.
#
# ○ $game_koyomi.stop_auto_time_pass_on_event = true/false
# 自動で時間が経過するとき,イベント中は時間経過を停止するか設定できます.
#
# ○ $game_koyomi.stop_auto_time_pass_on_battlet = true/false
# 自動で時間が経過するとき,バトル中は時間経過を停止するか設定できます.
#
# ○ $game_koyomi.rank
# 設定した各ランクの値を取得できます.
# 例・現在の月を取得
#   $game_koyomi.mon
#
# ○ $game_koyomi.rank = value
# 設定した各ランクの値を変更できます.
# 例・現在の月を3に設定
#   $game_koyomi.mon = 3
# 例・3時間進める
#   $game_koyomi.hour += 3
#
# ○ $game_koyomi.special
# 設定した各特殊表現の値を取得できます.
# 例・現在の時間帯を取得
#   $game_koyomi.timezone
#
# ○ $game_koyomi.set(init)
# 暦をセットします.
# initは各ランクと対応する値のハッシュか,後述する起算時からのランク0からみた経過時間
# を指定します.
# 例・ハッシュで暦をセット
#   $game_koyomi.set(year: 2011, mon: 12. day: 15)
# 例・ある暦から得た起算時からの経過時間で暦をセット
#   $game_koyomi.set(koyomi.to_i)
#
# ○ $game_koyomi.time_pass(amount)
# amountに各ランクと対応する値のハッシュを指定して,その分だけ時間を経過させます.
# 例・1月と3時間だけ時間をすすめる
#   $game_koyomi.time_pass(mon: 1, hour: 3)
#
# ○ $game_koyomi.to_i
# 起算時からのランク0からみた経過時間を取得します.
# この結果を変数などに保存することで容易に暦を復元できます.
# 例・暦を整数にして保存・復元する
#   koyomi = $game_koyomi.to_i
#   $game_koyomi.set(koyomi)
#
# ○ $game_koyomi.strftime(format)
# formatに変換文字列を指定して現在の暦を文字列にします.
# format中には以下の二つの特別な文字列を記述することで暦の値を置き換えることができます.
#   <<表示桁#rank>>
# 表示桁は先頭に - または 0 を付けた数字と置き換えます.
# rankは設定したランクのいずれかと置き換えます.
# ランクの値が指定した数字の桁分の幅の文字列と置換されます.
# 先頭に 0 をつけると余った桁0で埋められます.
# 先頭に - をつけると右寄せとなります.
#   <<label>>
# labelはTRANSFORMで指定した変換ラベルと置き換えます.
# TRANSFORMで設定した内容に従って文字列に置換されます.
# 例・2011年12月15日4時00分00秒の暦のとき
#   $game_koyomi.strftime("<<4#year>>-<<4#mon>>-<<04#day>>")
#   #=> 2011-  12-0015
#   $game_koyomi.strftime("<<mon>>-<<-4#day>>:<<timezone>>")
#   #=> Dec-15  :早朝
#
# ●マップの個別設定
# マップのメモ欄に以下を記述することでマップごとに設定を行うことができます.
#   ==暦非表示==
# マップで暦ウインドウを表示する場合でもこの記述があるマップは暦ウインドウを表示しません.
#
#   ==暦停止==
# 自動で時間が経過する場合でもこの記述があるマップは自動で時間が経過しません.
#
#   ==色調固定[r,g,b,gray]==
# 自動で画面色調が変更される場合でもこの記述があるマップは指定した色調になります.
# 屋内マップなどで利用します.薄暗い洞窟等も表現可能です.
# r,g,b,grayはそれぞれ色調(トーン)を指定する値です.
# 例・時間にかかわらず薄暗い洞窟
#   ==色調固定[-34,-34,-34,34]==
#
# ■注意
# このスクリプトでは
# 「RPG::Map」「Game_Map」「Scene_Menu」「Scene_Map」
# 「Game_Screen」「Game_Troop」「Scene_Battle」
# のメソッドを改変しています.
# ■情報
# このスクリプトはgentlawkによって作られたものです.
# 利用規約はhttp://blueredzone.comをご覧ください.
#------------------------------------------------------------------------------
module BMSP
  @@includes ||= {}
  @@includes[:KoyomiSystem] = 1.24
  module KoyomiSystem
    #▲▽▲▽▲▽▲▽▲▽▲▽▲▽▲▽
    #詳細設定
    # ランクの設定
    RANKS = {
      :sec => 0...60,
      :min => 0...60,
      :hour => 0...24,
      :day => 1..30,
      :mon => 1..12,
      :year => 1..9999
    }
    #------------------------------------------------------------
    # ランク以外の暦情報の設定
    SPECIAL_EXP = {}
    SPECIAL_EXP[:timezone] = ->(cal){
      case cal.hour
      when 4,5
        0 # 早朝は0を返す
      when 6,7,8
        1 # 朝は1を返す
      when 9...16
        2 # 昼は2を返す
      when 16,17
        3 # 夕方は3を返す
      when 18...22
        4 # 夜は4を返す
      when 22...24,0...4
        5 # 深夜は5を返す
      end
    }
    #------------------------------------------------------------
    # 表示変換の設定
    TRANSFORM = {}
    TRANSFORM[:mon] = ->(cal){
      ["一月", "二月", "三月", "四月", "五月", "六月",
       "七月", "八月", "九月", "十月", "十一月", "十二月"][cal.mon]
    }
    TRANSFORM[:timezone] = ->(cal){
      case cal.timezone # 上で設定した時間帯で条件分岐
      when 0
        "早朝"
      when 1
        "朝"
      when 2
        "昼"
      when 3
        "夕方"
      when 4
        "夜"
      when 5
        "深夜"
      end
    }
    #------------------------------------------------------------
    # ゲーム開始時の暦
    INITIAL_CAL = {
      :sec => 0,
      :min => 0,
      :hour => 0,
      :day => 7,
      :mon => 5,
      :year => 2017
    }
    #------------------------------------------------------------
    # マップで暦ウインドウを表示するか
    MAP_WINDOW = true
    # マップでの暦ウインドウをフェードするか(falseで常に表示)
    MAP_WINDOW_FADE = false
    # マップでの暦ウインドウの一時消去を許可するか(trueで許可)
    HIDE_MAP_WINDOW = true
    # マップでの暦ウインドウの一時消去ボタン
    # (:DOWN,:UP,:LEFT,:RIGHT,:A,:B,:C,:X,:Y,:Z,:L,:R,:SHIFT,:CTRL,:ALT)
    HIDE_KEY = :L
    # マップでの暦ウインドウの表示内容
    MAP_WINDOW_FORMAT = [
      "<<4#year>>年<<2#mon>>月<<2#day>>日",
      "<<02#hour>>:<<02#min>>:<<02#sec>> [<<timezone>>]"
    ]
    # メニューで暦ウインドウを表示するか
    MENU_WINDOW = true
    # メニューでの暦ウインドウの表示内容
    MENU_WINDOW_FORMAT = [
      "<<4#year>>年<<2#mon>>月<<2#day>>日",
      "<<02#hour>>:<<02#min>>:<<02#sec>>"
    ]
    #------------------------------------------------------------
    # 暦による画面の色調の自動変更
    AUTO_TONE = true
    # デフォルト色調変更時間
    AUTO_TONE_DURATION = 120
    # 色調変更の条件
    AUTO_TONE_COND = {
      {:hour => 16...18} => Tone.new(68,-34,-34,0),
      {:hour => 18...22} => Tone.new(-34,-34,0,34),
      {:hour => 22...4} => Tone.new(-68,-68,0,68),
      {:hour => 4...6} => Tone.new(-34,-34,-34,34),
      {:hour => 6...9} => Tone.new(34,34,34,34)
    }
    # バトル画面では色調を変更しない
    FIX_TONE_ON_BATTLE = false
    #------------------------------------------------------------
    # 時間が自動経過するか
    AUTO_TIME_PASS = true
    # 時間の自動経過間隔
    AUTO_TIME_PASS_DURATION = 15
    # 時間の自動経過量
    TIME_PASSING = {:min => 5}
    # イベント中は自動経過を停止するか
    STOP_ON_EVENT = true
    # バトル中は自動経過を停止するか
    STOP_ON_BATTLE = false
    #------------------------------------------------------------
    # 場所移動による時間経過
    MOVE_TIME_PASS = {:min => 20}
    # 戦闘開始による時間経過
    BATTLE_START_TIME_PASS = {}
    # 戦闘終了による時間経過
    BATTLE_END_TIME_PASS = {}
    #▲▽▲▽▲▽▲▽▲▽▲▽▲▽▲▽
  end
  #--------------------------------------------------------------------------
  # ● 導入スクリプトのチェック
  #--------------------------------------------------------------------------
  class << self
    if method_defined?(:check_script)
      alias koyomisystem_check_script check_script
    end
  end
  def self.check_script(script, version)
    if methods.include?(:koyomisystem_check_script)
      koyomisystem_check_script(script, version)
    end
    @@includes[script] && @@includes[script] >= version
  end
end
#==============================================================================
# ■ RPG::Map
#==============================================================================
class RPG::Map
  #--------------------------------------------------------------------------
  # ● 暦ウインドウ表示のマップか
  #--------------------------------------------------------------------------
  def bmsp_koyomisystem_display_koyomi_on_map?
    return @bmsp_koyomi_display if @bmsp_koyomi_display
    @bmsp_koyomi_display = !self.note.include?('==暦非表示==')
  end
  #--------------------------------------------------------------------------
  # ● 色調固定
  #--------------------------------------------------------------------------
  def bmsp_koyomisystem_fix_tone
    return @bmsp_fix_tone unless @bmsp_fix_tone.nil?
    if self.note =~ /==色調固定\[([+-]?\d+),([+-]?\d+),([+-]?\d+),([+-]?\d+)\]==/
      r,g,b,gray = $1.to_i,$2.to_i,$3.to_i,$4.to_i
      @bmsp_fix_tone = Tone.new(r,g,b,gray)
    else
      @bmsp_fix_tone = false
    end
  end
  #--------------------------------------------------------------------------
  # ● 暦停止のマップか
  #--------------------------------------------------------------------------
  def bmsp_koyomisystem_koyomi_stop?
    return @bmsp_koyomi_stop if @bmsp_koyomi_stop
    @bmsp_koyomi_stop = self.note.include?('==暦停止==')
  end
end
#==============================================================================
# ■ Game_Koyomi
#==============================================================================
class Game_Koyomi
  #============================================================================
  # ■ Ranks
  #============================================================================
  module Ranks
    #--------------------------------------------------------------------------
    # ● モジュール変数
    #--------------------------------------------------------------------------
    @@ranks = BMSP::KoyomiSystem::RANKS
    @@transform = BMSP::KoyomiSystem::TRANSFORM
    #--------------------------------------------------------------------------
    # ● ランクの取得
    #--------------------------------------------------------------------------
    def self.ranks
      @@ranks
    end
    #--------------------------------------------------------------------------
    # ● 表示変換
    #--------------------------------------------------------------------------
    def self.transform(label)
      @@transform[label]
    end
    #--------------------------------------------------------------------------
    # ● ランクの取得(順位指定)
    #--------------------------------------------------------------------------
    def self.rank(i)
      r = @@ranks.to_a
      return nil if r.nil?
      r.first
    end
    #--------------------------------------------------------------------------
    # ● ノーマライズ
    #--------------------------------------------------------------------------
    def self.normalize(i, rank)
      i - @@ranks[rank].min
    end
    #--------------------------------------------------------------------------
    # ● 指定した範囲の値か
    #--------------------------------------------------------------------------
    def self.include_range?(rank, range, value)
      rank_min = @@ranks[rank].min
      rank_max = @@ranks[rank].max
      range_min = range.min
      range_max = range.max
      unless range_min.nil? || range_max.nil? # 有効なRange
        min = [[range_min, rank_min].max, rank_max].min
        max = [[range_max, rank_min].max, rank_max].min
        (min..max).include?(value)
      else # 無効なRange
        first = range.first
        last = range.last
        nf = [[first, rank_min].max, rank_max].min
        nl = [[last, rank_min].max, rank_max].min
        range1 = (nf..rank_max)
        range2 = nl <= last && range.exclude_end? ? (rank_min...nl) : (rank_min..nl)
        range1.include?(value) || range2.include?(value)
      end
    end
    #--------------------------------------------------------------------------
    # ● ランクを一つ進める
    #--------------------------------------------------------------------------
    def self.succ(rank)
      find = false
      @@ranks.each do |r,|
        return r if find
        find = true if r == rank
      end
      return nil
    end
  end
  #============================================================================
  #--------------------------------------------------------------------------
  # ● 公開インスタンス変数
  #--------------------------------------------------------------------------
  attr_accessor :auto_tone # 画面の色調自動変更フラグ
  attr_accessor :tone_temp_duration # 画面の色調時間一時変更フラグ
  attr_accessor :move_temp_time_pass # 場所移動による時間経過一時変更フラグ
  attr_accessor :battle_start_temp_time_pass # 戦闘開始による時間経過一時変更フラグ
  attr_accessor :battle_end_temp_time_pass # 戦闘終了による時間経過一時変更フラグ
  attr_accessor :auto_time_pass # 時間自動経過フラグ
  attr_accessor :stop_auto_time_pass_on_event # イベント中時間自動経過停止フラグ
  attr_accessor :stop_auto_time_pass_on_battle # バトル中時間自動経過停止フラグ
  attr_reader :fix_tone_on_battle # バトル画面色調固定フラグ
  attr_accessor :hide_map_window # 暦ウインドウ一時消去許可フラグ
  #--------------------------------------------------------------------------
  # ● ランクアクセサの定義
  #--------------------------------------------------------------------------
  Ranks.ranks.each_key do |rank|
    reader = rank
    writer = :"#{rank}="
    define_method(reader){ @calendar[rank] }
    define_method(writer){ |value| @calendar[rank] = value; fit; value }
  end
  #--------------------------------------------------------------------------
  # ● 特別表現リーダーの定義
  #--------------------------------------------------------------------------
  BMSP::KoyomiSystem::SPECIAL_EXP.each do |special, exp|
    define_method(special){ exp.call(self) }
  end
  #--------------------------------------------------------------------------
  # ● オブジェクト初期化
  #--------------------------------------------------------------------------
  def initialize(init= {})
    # 各種設定の初期化
    @auto_tone = BMSP::KoyomiSystem::AUTO_TONE
    @tone_temp_duration = 0
    @default_tone = Tone.new(0,0,0,0)
    @auto_time_pass = BMSP::KoyomiSystem::AUTO_TIME_PASS
    @auto_time_pass_amount = {
      :duration => BMSP::KoyomiSystem::AUTO_TIME_PASS_DURATION,
      :amount => BMSP::KoyomiSystem::TIME_PASSING
    }
    @move_time_pass = BMSP::KoyomiSystem::MOVE_TIME_PASS
    @battle_start_time_pass = BMSP::KoyomiSystem::BATTLE_START_TIME_PASS
    @battle_end_time_pass = BMSP::KoyomiSystem::BATTLE_END_TIME_PASS
    @stop_auto_time_pass_on_event = BMSP::KoyomiSystem::STOP_ON_EVENT
    @stop_auto_time_pass_on_battle = BMSP::KoyomiSystem::STOP_ON_BATTLE
    @fix_tone_on_battle = BMSP::KoyomiSystem::FIX_TONE_ON_BATTLE
    @hide_map_window = BMSP::KoyomiSystem::HIDE_MAP_WINDOW
    # 暦の初期化
    set(init)
  end
  #--------------------------------------------------------------------------
  # ● 範囲外の暦を修正
  #--------------------------------------------------------------------------
  def fit
    carry = 0
    @calendar.each_key do |rank|
      @calendar[rank] += carry
      value = @calendar[rank]
      if Ranks.ranks[rank].include?(value)
        carry = 0
      else
        n_value = Ranks.normalize(value, rank)
        card = Ranks.ranks[rank].count
        carry = n_value / card
        @calendar[rank] = n_value % card + Ranks.ranks[rank].min
      end
    end
    @int = calc_to_i
  end
  #--------------------------------------------------------------------------
  # ● 暦のセット
  #--------------------------------------------------------------------------
  def set(init)
    @calendar = {}
    ini_h = init.is_a?(Hash) ? init : {}
    Ranks.ranks.each_key do |rank|
      @calendar[rank] =
        ini_h[rank] ? ini_h[rank] : Ranks.ranks[rank].min
    end
    @calendar[Ranks.rank(0)] += init if init.is_a?(Integer)
    fit
  end
  #--------------------------------------------------------------------------
  # ● 時間自動経過の設定
  #--------------------------------------------------------------------------
  def set_auto_time_pass(passing)
    @auto_time_pass_amount[:duration] = passing[:duration] if passing[:duration]
    @auto_time_pass_amount[:amount] = passing[:amount] if passing[:amount]
  end
  #--------------------------------------------------------------------------
  # ● フレーム更新
  #--------------------------------------------------------------------------
  def update(screen)
    update_auto_time_pass
    update_auto_tone(screen)
  end
  #--------------------------------------------------------------------------
  # ● 時間経過
  #--------------------------------------------------------------------------
  def time_pass(amount)
    amount.each do |rank, value|
      next unless @calendar[rank]
      @calendar[rank] += value
    end
    fit
  end
  #--------------------------------------------------------------------------
  # ● イベント中判定
  #--------------------------------------------------------------------------
  def check_event_running?
    if $game_party.in_battle
      $game_troop.interpreter.running?
    elsif !$BTEST
      $game_map.interpreter.running?
    end
  end
  #--------------------------------------------------------------------------
  # ● 時間自動経過
  #--------------------------------------------------------------------------
  def update_auto_time_pass
    return unless @auto_time_pass
    return if @stop_auto_time_pass_on_event && check_event_running?
    return if @stop_auto_time_pass_on_battle && $game_party.in_battle
    return if !$BTEST && $game_map.map.bmsp_koyomisystem_koyomi_stop?
    if @auto_time_pass_amount[:duration] > 0
      return if Graphics.frame_count % @auto_time_pass_amount[:duration] != 0
      time_pass(@auto_time_pass_amount[:amount])
    end
  end
  #--------------------------------------------------------------------------
  # ● 場所移動による時間経過
  #--------------------------------------------------------------------------
  def move_time_pass
    unless @move_temp_time_pass
      time_pass(@move_time_pass)
    else
      time_pass(@move_temp_time_pass)
      @move_temp_time_pass = nil
    end
  end
  #--------------------------------------------------------------------------
  # ● 戦闘開始による時間経過
  #--------------------------------------------------------------------------
  def battle_start_time_pass
    unless @battle_start_temp_time_pass
      time_pass(@battle_start_time_pass)
    else
      time_pass(@battler_start_temp_time_pass)
      @battle_start_temp_time_pass = nil
    end
  end
  #--------------------------------------------------------------------------
  # ● 戦闘終了による時間経過
  #--------------------------------------------------------------------------
  def battle_end_time_pass
    unless @battle_end_temp_time_pass
      time_pass(@battle_end_time_pass)
    else
      time_pass(@battler_end_temp_time_pass)
      @battle_end_temp_time_pass = nil
    end
  end
  #--------------------------------------------------------------------------
  # ● 画面の色調自動変更
  #--------------------------------------------------------------------------
  def update_auto_tone(screen)
    return if !@auto_tone || (!$BTEST && $game_map.map.bmsp_koyomisystem_fix_tone)
    return if $game_party.in_battle && @fix_tone_on_battle
    target_tone,duration = get_match_tone
    return if target_tone.nil? || screen.tone_target == target_tone
    # 変更時間の設定
    duration = BMSP::KoyomiSystem::AUTO_TONE_DURATION if duration.nil?
    duration = @tone_temp_duration ? @tone_temp_duration : duration
    @tone_temp_duration = nil
    # 色調変更
    screen.start_tone_change(target_tone, duration)
  end
  #--------------------------------------------------------------------------
  # ● 条件にマッチする色調の取得
  #--------------------------------------------------------------------------
  def get_match_tone
    BMSP::KoyomiSystem::AUTO_TONE_COND.each do |cond, (tone,duration)|
      next unless cond.each { |rank, range|
        case range
        when Range
          break unless Ranks.include_range?(rank, range, @calendar[rank])
        else # それ以外(整数指定)
          break if @calendar[rank] != range
        end
      }
      return tone,duration
    end
    @default_tone
  end
  #--------------------------------------------------------------------------
  # ● 暦を一つ進める
  #--------------------------------------------------------------------------
  def succ
    rank0 = Ranks.rank(0)
    @calendar[rank0] += 1
    fit
  end
  #--------------------------------------------------------------------------
  # ● 文字列フォーマット
  #--------------------------------------------------------------------------
  def strftime(format)
    format = format.dup
    Ranks.ranks.each_key do |rank|
      pattern = /<<(-?)(0?)(\d)#(#{rank.to_s})>>/
      format.gsub!(pattern){
        left,zero,digit,r = $1,$2,$3,$4
        sprintf("%#{left + zero + digit}d", @calendar[rank])
      }
    end
    format.gsub!(/<<(.+?)>>/){
     trans =  Ranks.transform($1.to_sym)
     trans.nil? ? "###" : trans.call(self)
    }
    format
  end
  #--------------------------------------------------------------------------
  # ● オブジェクト複製
  #--------------------------------------------------------------------------
  def dup
    Marshal.load(Marshal.dump self)
  end
  #--------------------------------------------------------------------------
  # ● 起算時からのランク0からみた経過時間の計算
  #--------------------------------------------------------------------------
  def calc_to_i
    @int = @calendar.each.reverse_each.inject(0) { |sum, (rank, value)|
      sum * Ranks.ranks[rank].count + Ranks.normalize(value, rank)
    }
  end
  #--------------------------------------------------------------------------
  # ● 起算時からのランク0からみた経過時間の取得
  #--------------------------------------------------------------------------
  def to_i
    @int
  end
  #--------------------------------------------------------------------------
  # ● 比較演算子
  #--------------------------------------------------------------------------
  def ==(koyomi)
    self.to_i == koyomi.to_i
  end
  def !=(koyomi)
    self.to_i != koyomi.to_i
  end
  def <(koyomi)
    self.to_i < koyomi.to_i
  end
  def <=(koyomi)
    self.to_i <= koyomi.to_i
  end
  def >(koyomi)
    self.to_i > koyomi.to_i
  end
  def >=(koyomi)
    self.to_i >= koyomi.to_i
  end
  def <=>(koyomi)
    self.to_i <=> koyomi.to_i
  end
end
#==============================================================================
# ■ DataManager
#==============================================================================
module DataManager
  #--------------------------------------------------------------------------
  # ● 各種ゲームオブジェクトの作成
  #--------------------------------------------------------------------------
  instance_eval{ alias bmsp_koyomisystem_create_game_objects create_game_objects }
  def self.create_game_objects
    bmsp_koyomisystem_create_game_objects
    $game_koyomi = Game_Koyomi.new(BMSP::KoyomiSystem::INITIAL_CAL)
  end
  #--------------------------------------------------------------------------
  # ● セーブ内容の作成
  #--------------------------------------------------------------------------
  instance_eval{ alias bmsp_koyomisystem_make_save_contents make_save_contents }
  def self.make_save_contents
    contents = bmsp_koyomisystem_make_save_contents
    contents[:koyomi] = $game_koyomi
    contents
  end
  #--------------------------------------------------------------------------
  # ● セーブ内容の展開
  #--------------------------------------------------------------------------
  instance_eval{ alias bmsp_koyomisystem_extract_save_contents extract_save_contents }
  def self.extract_save_contents(contents)
    bmsp_koyomisystem_extract_save_contents(contents)
    $game_koyomi = contents[:koyomi]
  end
end
#==============================================================================
# ■ Game_Map
#==============================================================================
class Game_Map
  #--------------------------------------------------------------------------
  # ● 公開インスタンス変数
  #--------------------------------------------------------------------------
  attr_reader :map # 現在のマップデータ
  attr_accessor :koyomi_display             # 暦表示フラグ
  #--------------------------------------------------------------------------
  # ● オブジェクト初期化
  #--------------------------------------------------------------------------
  alias bmsp_koyomisytem_initialize initialize
  def initialize
    bmsp_koyomisytem_initialize
    @koyomi_display = BMSP::KoyomiSystem::MAP_WINDOW
  end
  #--------------------------------------------------------------------------
  # ● セットアップ
  #--------------------------------------------------------------------------
  alias bmsp_koyomisystem_setup setup
  def setup(map_id)
    bmsp_koyomisystem_setup(map_id)
    # 色調固定処理
    bmsp_koyomisystem_change_fix_tone
  end
  #--------------------------------------------------------------------------
  # ● 色調固定マップの処理
  #--------------------------------------------------------------------------
  def bmsp_koyomisystem_change_fix_tone
    tone = self.map.bmsp_koyomisystem_fix_tone
    if tone # 色調固定
      self.screen.start_tone_change(tone, 0)
    else # それ以外
      if $game_koyomi.auto_tone
        tone,duration = $game_koyomi.get_match_tone
        self.screen.start_tone_change(tone, 0)
      else
        self.screen.start_tone_change(Tone.new(0,0,0,0), 0)
      end
    end
  end
  #--------------------------------------------------------------------------
  # ● 暦ウィンドウの一時消去
  #--------------------------------------------------------------------------
  def hide_koyomi_window=(hidden)
    return unless SceneManager.scene_is?(Scene_Map)
   
    koyomi_window = SceneManager.scene.instance_eval{@bmsp_koyomi_window}
    if $game_map.koyomi_display && !BMSP::KoyomiSystem::MAP_WINDOW_FADE
      if $game_koyomi.hide_map_window
        koyomi_window.hide_window if koyomi_window.hidden != hidden
      end
    end
  end
end
#==============================================================================
# ■ Scene_Menu
#==============================================================================
class Scene_Menu < Scene_MenuBase
  #--------------------------------------------------------------------------
  # ● 開始処理
  #--------------------------------------------------------------------------
  alias bmsp_koyomisystem_start start
  def start
    bmsp_koyomisystem_start
    bmsp_koyomisystem_create_koyomi_window if BMSP::KoyomiSystem::MENU_WINDOW
  end
  #--------------------------------------------------------------------------
  # ● 暦ウィンドウの作成
  #--------------------------------------------------------------------------
  def bmsp_koyomisystem_create_koyomi_window
    @bmsp_koyomi_window = BMSP::KoyomiSystem::Window_MenuKoyomi.new
    @bmsp_koyomi_window.x = 0
    @bmsp_koyomi_window.y = Graphics.height - @gold_window.height - @bmsp_koyomi_window.height
    if BMSP.check_script(:EXPDistribution, 1.00) && BMSP::EXPDistribution::EXP_WINDOW
      @bmsp_koyomi_window.y -= @bmsp_koyomi_window.fitting_height(1)
    end
  end
end
#==============================================================================
# ■ Scene_Map
#==============================================================================
class Scene_Map < Scene_Base
  #--------------------------------------------------------------------------
  # ● 全ウィンドウの作成
  #--------------------------------------------------------------------------
  alias bmsp_koyomisystem_create_all_windows create_all_windows
  def create_all_windows
    bmsp_koyomisystem_create_all_windows
    bmsp_koyomisystem_create_koyomi_window
  end
  #--------------------------------------------------------------------------
  # ● 暦ウィンドウの作成
  #--------------------------------------------------------------------------
  def bmsp_koyomisystem_create_koyomi_window
    @bmsp_koyomi_window = BMSP::KoyomiSystem::Window_MapKoyomi.new
  end
  #--------------------------------------------------------------------------
  # ● 場所移動前の処理
  #--------------------------------------------------------------------------
  alias bmsp_koyomisystem_pre_transfer pre_transfer
  def pre_transfer
    @bmsp_koyomi_window.close
    bmsp_koyomisystem_pre_transfer
    bmsp_koyomisystem_move_time_pass
  end
  #--------------------------------------------------------------------------
  # ● 場所移動後の処理
  #--------------------------------------------------------------------------
  alias bmsp_koyomisystem_post_transfer post_transfer
  def post_transfer
    @bmsp_koyomi_window.open unless BMSP::KoyomiSystem::MAP_WINDOW_FADE
    bmsp_koyomisystem_post_transfer
    @bmsp_koyomi_window.open if BMSP::KoyomiSystem::MAP_WINDOW_FADE
  end
  #--------------------------------------------------------------------------
  # ● 場所移動による時間経過
  #--------------------------------------------------------------------------
  def bmsp_koyomisystem_move_time_pass
    $game_koyomi.move_time_pass
  end
end
#==============================================================================
# ■ BMSP::KoyomiSystem::Window_MenuKoyomi
#==============================================================================
class BMSP::KoyomiSystem::Window_MenuKoyomi < Window_Base
  #--------------------------------------------------------------------------
  # ● オブジェクト初期化
  #--------------------------------------------------------------------------
  def initialize
    line_number = BMSP::KoyomiSystem::MENU_WINDOW_FORMAT.size
    super(0, 0, window_width, fitting_height(line_number))
    @time = $game_koyomi.to_i
    @formats = BMSP::KoyomiSystem::MENU_WINDOW_FORMAT
    refresh
  end
  #--------------------------------------------------------------------------
  # ● ウィンドウ幅の取得
  #--------------------------------------------------------------------------
  def window_width
    return 160
  end
  #--------------------------------------------------------------------------
  # ● フレーム更新
  #--------------------------------------------------------------------------
  def update
    super
    refresh if redraw?
  end
  #--------------------------------------------------------------------------
  # ● 再描画するか
  #--------------------------------------------------------------------------
  def redraw?
    if $game_koyomi.to_i != @time
      @time = $game_koyomi.to_i
      return true
    end
    false
  end
  #--------------------------------------------------------------------------
  # ● リフレッシュ
  #--------------------------------------------------------------------------
  def refresh
    contents.clear
    draw_background(contents.rect)
    rect = contents.rect
    rect.height = line_height
    rect.y = 0
    @formats.each do |format|
      draw_text(rect, $game_koyomi.strftime(format), 1)
      rect.y += line_height
    end
  end
  #--------------------------------------------------------------------------
  # ● 背景の描画
  #--------------------------------------------------------------------------
  def draw_background(rect)
  end
end
#==============================================================================
# ■ BMSP::KoyomiSystem::Window_MapKoyomi
#==============================================================================
class BMSP::KoyomiSystem::Window_MapKoyomi < BMSP::KoyomiSystem::Window_MenuKoyomi
  #--------------------------------------------------------------------------
  # ● 公開インスタンス変数
  #--------------------------------------------------------------------------
  attr_reader :hidden
  #--------------------------------------------------------------------------
  # ● オブジェクト初期化
  #--------------------------------------------------------------------------
  def initialize
    super
    line_number = BMSP::KoyomiSystem::MAP_WINDOW_FORMAT.size
    x= Graphics.width - window_width
    move(x, 0, window_width, fitting_height(line_number))
    self.opacity = 0
    if BMSP::KoyomiSystem::MAP_WINDOW_FADE || !$game_map.koyomi_display
      self.contents_opacity = 0
    end
    @show_count = BMSP::KoyomiSystem::MAP_WINDOW_FADE ? 0 : 1
    @time = $game_koyomi.to_i
    @formats = BMSP::KoyomiSystem::MAP_WINDOW_FORMAT
    @hidden = false
    open
  end
  #--------------------------------------------------------------------------
  # ● ウィンドウ幅の取得
  #--------------------------------------------------------------------------
  def window_width
    return 320
  end
  #--------------------------------------------------------------------------
  # ● フレーム更新
  #--------------------------------------------------------------------------
  def update
    super
    if @show_count > 0 && BMSP::KoyomiSystem::MAP_WINDOW_FADE
      if $game_map.koyomi_display || self.contents_opacity != 0
        update_fadein
        @show_count -= 1
      end
    elsif @show_count == 0
      update_fadeout
    elsif $game_map.koyomi_display && !BMSP::KoyomiSystem::MAP_WINDOW_FADE
      if $game_koyomi.hide_map_window
        hide_window if Input.trigger?(BMSP::KoyomiSystem::HIDE_KEY)
      else # 一時消去中にウインドウの消去が禁止になった場合は表示する
        hide_window if @hidden
      end
      if @show_count > 1
        @hidden ? update_fadeout : update_fadein
        @show_count -= 1
      end
    end
  end
  #--------------------------------------------------------------------------
  # ● フェードインの更新
  #--------------------------------------------------------------------------
  def update_fadein
    self.contents_opacity += 16
  end
  #--------------------------------------------------------------------------
  # ● フェードアウトの更新
  #--------------------------------------------------------------------------
  def update_fadeout
    self.contents_opacity -= 16
  end
  #--------------------------------------------------------------------------
  # ● ウインドウの一時消去切り替え
  #--------------------------------------------------------------------------
  def hide_window
    @hidden = !@hidden
    @show_count = 17
  end
  #--------------------------------------------------------------------------
  # ● ウィンドウを開く
  #--------------------------------------------------------------------------
  def open
    refresh
    if $game_map.map.bmsp_koyomisystem_display_koyomi_on_map?
      if !$game_map.koyomi_display
        @show_count = 0
        self.contents_opacity = 0
      elsif BMSP::KoyomiSystem::MAP_WINDOW_FADE
        @show_count = 150
        self.contents_opacity = 0
      else
        if @hidden # 一時消去中
          @show_count = 1
          self.contents_opacity = 0
        else
          @show_count = 1
          self.contents_opacity = 255
        end
      end
    else
      @show_count = 0
      self.contents_opacity = 0
    end
    self
  end
  #--------------------------------------------------------------------------
  # ● ウィンドウを閉じる
  #--------------------------------------------------------------------------
  def close
    @show_count = 0 if BMSP::KoyomiSystem::MAP_WINDOW_FADE
    self
  end
  #--------------------------------------------------------------------------
  # ● 背景の描画
  #--------------------------------------------------------------------------
  def draw_background(rect)
    temp_rect = rect.clone
    temp_rect.width /= 2
    contents.gradient_fill_rect(temp_rect, back_color2, back_color1)
    temp_rect.x = temp_rect.width
    contents.gradient_fill_rect(temp_rect, back_color1, back_color2)
  end
  #--------------------------------------------------------------------------
  # ● 背景色 1 の取得
  #--------------------------------------------------------------------------
  def back_color1
    Color.new(0, 0, 0, 192)
  end
  #--------------------------------------------------------------------------
  # ● 背景色 2 の取得
  #--------------------------------------------------------------------------
  def back_color2
    Color.new(0, 0, 0, 0)
  end
end
#==============================================================================
# ■ Game_Screen
#==============================================================================
class Game_Screen
  #--------------------------------------------------------------------------
  # ● 公開インスタンス変数
  #--------------------------------------------------------------------------
  attr_reader :tone_target
  #--------------------------------------------------------------------------
  # ● フレーム更新
  #--------------------------------------------------------------------------
  alias bmsp_koyomisystem_update update
  def update
    bmsp_koyomisystem_update
    bmsp_koyomisystem_update_koyomi
  end
  #--------------------------------------------------------------------------
  # ● 暦の更新
  #--------------------------------------------------------------------------
  def bmsp_koyomisystem_update_koyomi
    $game_koyomi.update(self)
  end
end
#==============================================================================
# ■ Game_Troop
#==============================================================================
class Game_Troop < Game_Unit
  #--------------------------------------------------------------------------
  # ● セットアップ
  #--------------------------------------------------------------------------
  def setup(troop_id)
    clear
    @troop_id = troop_id
    @enemies = []
    troop.members.each do |member|
      next unless $data_enemies[member.enemy_id]
      enemy = Game_Enemy.new(@enemies.size, member.enemy_id)
      enemy.hide if member.hidden
      enemy.screen_x = member.x
      enemy.screen_y = member.y
      @enemies.push(enemy)
    end
    init_screen_tone
    make_unique_names
  end
  #--------------------------------------------------------------------------
  # ● 画面の色調を初期化
  #--------------------------------------------------------------------------
  alias bmsp_koyomisystem_init_screen_tone init_screen_tone
  def init_screen_tone
    bmsp_koyomisystem_init_screen_tone
    bmsp_koyomisystem_battle_start_time_pass
    bmsp_koyomisystem_fix_tone_on_battle
  end
  #--------------------------------------------------------------------------
  # ● 戦闘開始による時間経過
  #--------------------------------------------------------------------------
  def bmsp_koyomisystem_battle_start_time_pass
    $game_koyomi.battle_start_time_pass
    return if !@auto_tone || (!$BTEST && $game_map.map.bmsp_koyomisystem_fix_tone)
    tone,duration = $game_koyomi.get_match_tone
    $game_troop.screen.start_tone_change(tone, 0)
  end
  #--------------------------------------------------------------------------
  # ● バトル中の色調固定
  #--------------------------------------------------------------------------
  def bmsp_koyomisystem_fix_tone_on_battle
    return unless $game_koyomi.fix_tone_on_battle
    $game_troop.screen.start_tone_change(Tone.new(0,0,0,0), 0)
  end
end
#==============================================================================
# ■ Scene_Battle
#==============================================================================
class Scene_Battle < Scene_Base
  #--------------------------------------------------------------------------
  # ● 終了処理
  #--------------------------------------------------------------------------
  alias bmsp_koyomisystem_terminate terminate
  def terminate
    bmsp_koyomisystem_terminate
    bmsp_koyomisystem_battle_end_time_pass
  end
  #--------------------------------------------------------------------------
  # ● 戦闘終了による時間経過
  #--------------------------------------------------------------------------
  def bmsp_koyomisystem_battle_end_time_pass
    $game_koyomi.battle_end_time_pass
    return if !$game_koyomi.auto_tone || (!$BTEST && $game_map.map.bmsp_koyomisystem_fix_tone)
    tone,duration = $game_koyomi.get_match_tone
    $game_map.screen.start_tone_change(tone, 0)
  end
end

                                                [/pre]

状态感染
[pre lang="ruby"]#==============================================================================
#
# ¥ Yami Engine Symphony - Infective State
# -- Last Updated: 2012.12.14
# -- Level: Easy
# -- Requires: n/a
#
#==============================================================================

$imported = {} if $imported.nil?
$imported["YES-InfectiveState"] = true

#==============================================================================
# ¥ Updates
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# 2012.12.14 - Finished Script.
# 2012.12.12 - Started Script.
#
#==============================================================================
# ¥ Introduction
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# This script provides infect feature for specific states.
#
#==============================================================================
# ¥ Instructions
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# To install this script, open up your script editor and copy/paste this script
# to an open slot below ¥ Materials/‘fÞ but above ¥ Main. Remember to save.
#
# -----------------------------------------------------------------------------
# State Notetags - These notetags go in the state notebox in the database.
# -----------------------------------------------------------------------------
# <infect allies x: y, z%>
# Infects all allies with state x after y turns with a chance of z%.
#
# <infect enemies x: y, z%>
# Infects all enemies with state x after y turns with a chance of z%.
#
# <infect n allies x: y, z%>
# Infects n allies with state x after y turns with a chance of z%.
#
# <infect n enemies x: y, z%>
# Infects n enemies with state x after y turns with a chance of z%.
#
#==============================================================================
# ¥ Compatibility
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# This script is made strictly for RPG Maker VX Ace. It is highly unlikely that
# it will run with RPG Maker VX without adjustments.
#
#==============================================================================

#==============================================================================
# ¥ Editting anything past this point may potentially result in causing
# computer damage, incontinence, explosion of user's head, coma, death, and/or
# halitosis so edit at your own risk.
#==============================================================================

#==============================================================================
# ¡ Regular Expression
#==============================================================================

module REGEXP
  module INFECTIVE_STATE
    INFECT_ALLY = /<(?:INFECT ALLIES)[ ](\d+):[ ]*(\d+)(?:,[ ]*(\d+)[%“]?)?>/i
    INFECT_ENEMY  = /<(?:INFECT ENEMIES)[ ](\d+):[ ]*(\d+)(?:,[ ]*(\d+)[%“]?)?>/i
    INFECT_X_ALLY = /<(?:INFECT[ ](\d+)[ ]ALLIES)[ ](\d+):[ ]*(\d+)(?:,[ ]*(\d+)[%“]?)?>/i
    INFECT_X_ENEMY = /<(?:INFECT[ ](\d+)[ ]ENEMIES)[ ](\d+):[ ]*(\d+)(?:,[ ]*(\d+)[%“]?)?>/i
  end # INFECTIVE_STATE
end # REGEXP

#==============================================================================
# ¡ DataManager
#==============================================================================

module DataManager
   
  #--------------------------------------------------------------------------
  # alias method: load_database
  #--------------------------------------------------------------------------
  class <<self; alias load_database_infective_state load_database; end
  def self.load_database
    load_database_infective_state
    initialize_infective_state
  end
  
  #--------------------------------------------------------------------------
  # new method: initialize_infective_state
  #--------------------------------------------------------------------------
  def self.initialize_infective_state
    groups = [$data_states]
    groups.each { |group|
      group.each { |obj|
        next if obj.nil?
        obj.initialize_infective_state
      }
    }
  end
  
end # DataManager

#==============================================================================
# ¡ RPG::BaseItem
#==============================================================================

class RPG::BaseItem
  
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_accessor :infect_allies
  attr_accessor :infect_enemies

  #--------------------------------------------------------------------------
  # new method: initialize_infective_state
  #--------------------------------------------------------------------------
  def initialize_infective_state
    @infect_allies = {}
    @infect_enemies = {}
    self.note.split(/[\r\n]+/).each { |line|
      case line
      when REGEXP::INFECTIVE_STATE::INFECT_ALLY
        array = [0, $2.to_i, $3.to_i]
        array[2] = 100 if array[2] <= 0
        @infect_allies[$1.to_i] = array if array[1] > 0
      when REGEXP::INFECTIVE_STATE::INFECT_ENEMY
        array = [0, $2.to_i, $3.to_i]
        array[2] = 100 if array[2] <= 0
        @infect_enemies[$1.to_i] = array if array[1] > 0
      when REGEXP::INFECTIVE_STATE::INFECT_X_ALLY
        array = [$1.to_i, $3.to_i, $4.to_i]
        array[2] = 100 if array[2] <= 0
        @infect_allies[$2.to_i] = array if array[1] > 0
      when REGEXP::INFECTIVE_STATE::INFECT_X_ENEMY
        array = [$1.to_i, $3.to_i, $4.to_i]
        array[2] = 100 if array[2] <= 0
        @infect_enemies[$2.to_i] = array if array[1] > 0
      end
    }
  end
  
end # RPG::BaseItem

#==============================================================================
# ¡ Game_Battler
#==============================================================================

class Game_Battler < Game_BattlerBase
  
  #--------------------------------------------------------------------------
  # new method: infective_states
  #--------------------------------------------------------------------------
  def infective_states
    states.select { |state|
      state.infect_allies.size + state.infect_enemies.size > 0
    }
  end
  
  #--------------------------------------------------------------------------
  # new method: infective_allies
  #--------------------------------------------------------------------------
  def infective_allies
    states.select { |state|
      state.infect_allies.size > 0
    }
  end
  
  #--------------------------------------------------------------------------
  # new method: infective_enemies
  #--------------------------------------------------------------------------
  def infective_enemies
    states.select { |state|
      state.infect_enemies.size > 0
    }
  end
  
  #--------------------------------------------------------------------------
  # new method: infect_allies_include?
  #--------------------------------------------------------------------------
  def infect_allies_include?(id)
    infective_allies.any? { |state| state.infect_allies.keys.include?(id) }
  end
  
  #--------------------------------------------------------------------------
  # new method: infect_enemies_include?
  #--------------------------------------------------------------------------
  def infect_enemies_include?(id)
    infective_enemies.any? { |state| state.infect_enemies.keys.include?(id) }
  end
  
  #--------------------------------------------------------------------------
  # new method: infective_calc
  #--------------------------------------------------------------------------
  def update_infective
    @infect_allies ||= {}
    @infect_enemies ||= {}
    #---
    infective_allies.each { |state|
      state.infect_allies.each { |id, hash|
        @infect_allies[id] = hash[1] if @infect_allies[id].nil? || @infect_allies[id] <= 0
        @infect_allies[id] -= 1
      }
    }
    #---
    infective_enemies.each { |state|
      state.infect_enemies.each { |id, hash|
        @infect_enemies[id] = hash[1] if @infect_enemies[id].nil? || @infect_enemies[id] <= 0
        @infect_enemies[id] -= 1
      }
    }
    #---
    infective_allies.each { |state|
      state.infect_allies.each { |id, hash|
        next if @infect_allies[id] > 0
        if self.actor?
          battlers = $game_party.battle_members
        else
          battlers = $game_troop.members
        end
        if hash[0] <= 0
          if rand(100) < hash[2]
            battlers.each { |battler| battler.add_state(id) }
          end
        else
          count = hash[0]
          battlers = battlers.shuffle
          battlers.each { |battler|
            if battler && battler.alive? && !battler.state?(id)
              if rand(100) > hash[2]
                battler.add_state(id)
                count -= 1
              end
            end
            break if count <= 0
          }
        end
      }
    }
    #---
    infective_enemies.each { |state|
      state.infect_enemies.each { |id, hash|
        next if @infect_enemies[id] > 0
        next if rand(100) > hash[2]
        if self.actor?
          battlers = $game_troop.members
        else
          battlers = $game_party.battle_members
        end
        if hash[0] <= 0
          if rand(100) < hash[2]
            battlers.each { |battler| battler.add_state(id) }
          end
        else
          count = hash[0]
          battlers = battlers.shuffle
          battlers.each { |battler|
            if battler && battler.alive? && !battler.state?(id)
              if rand(100) > hash[2]
                battler.add_state(id)
                count -= 1
              end
            end
            break if count <= 0
          }
        end
      }
    }
  end
  
  #--------------------------------------------------------------------------
  # new method: infective_clear
  #--------------------------------------------------------------------------
  def infective_clear
    @infect_allies.each_key { |id|
      @infect_allies[id] = nil unless infect_allies_include?(id)
    }
    #---
    @infect_enemies.each_key { |id|
      @infect_enemies[id] = nil unless infect_enemies_include?(id)
    }
  end
  
  #--------------------------------------------------------------------------
  # alias method: on_turn_end
  #--------------------------------------------------------------------------
  alias yes_infect_state_on_turn_end on_turn_end
  def on_turn_end
    yes_infect_state_on_turn_end
    update_infective
    infective_clear
  end
  
end # Game_Battler

#==============================================================================
#
# ¥ End of File
#
#==============================================================================[/pre]

临死技(仅敌人有效)
[pre lang="ruby"]=begin
      RGSS3

      ★ 断末魔 ★

      戦闘不能になる直前に指定のスキルを発動するエネミーを作れます。
      
      ● 仕様 ●==========================================================
      断末魔を発動したエネミーは、
      自身を断末魔スキルの効果対象にすることはできません。
      ====================================================================
      
      ● 使い方 ●========================================================
      エネミーのメモ欄に「临死技:n」と記述してください。
      nには断末魔として発動させるスキルIDを指定してください。
      ====================================================================
      
      ver1.00

      Last Update : 2015/05/13
      5/13 : RGSS2にあったものを移植
      
      ろかん   http://kaisou-ryouiki.sakura.ne.jp/
=end

$rsi ||= {}
$rsi["临死技"] = true

class RPG::Enemy < RPG::BaseItem
  def death_throes_id
    unless @death_throes_id
      @death_throes_id = 0
      self.note.each_line{|line|
        if line =~ /临死技:(\d+)/i
          @death_throes_id = $1.to_i
          break
        end
      }
    end
    @death_throes_id
  end
end

class << BattleManager
  #--------------------------------------------------------------------------
  # ● ターン終了
  #--------------------------------------------------------------------------
  alias death_throes_turn_end turn_end
  def turn_end
    death_throes_turn_end if @phase
  end
end

class Game_Battler < Game_BattlerBase
  #--------------------------------------------------------------------------
  # ● 断末魔をあげるバトラーであるか
  #--------------------------------------------------------------------------
  def death_throes?
    false
  end
end

class Game_Action
  #--------------------------------------------------------------------------
  # ● 断末魔のターゲットの配列作成
  #--------------------------------------------------------------------------
  def make_targets_with_death_throes
    if item.for_opponent?
      targets_for_opponents
    elsif item.for_friend?
      targets_for_friends_with_death_throes
    else
      []
    end
  end
  #--------------------------------------------------------------------------
  # ● 味方に対するターゲット
  #--------------------------------------------------------------------------
  def targets_for_friends_with_death_throes
    if item.for_user?
      []
    elsif item.for_dead_friend?
      if item.for_one?
        [friends_unit.smooth_dead_target(@target_index)]
      else
        friends_unit.dead_members
      end
    elsif item.for_friend?
      result = friends_unit.alive_members
      result.delete(@subject)
      if item.for_one?
        result.empty? ? [] : [result.sample]
      else
        result
      end
    end
  end
end

class Game_Enemy < Game_Battler
  #--------------------------------------------------------------------------
  # ● 公開インスタンス変数
  #--------------------------------------------------------------------------
  attr_accessor :gave_death_throes
  #--------------------------------------------------------------------------
  # ● オブジェクト初期化
  #--------------------------------------------------------------------------
  alias death_throes_initialize initialize
  def initialize(index, enemy_id)
    death_throes_initialize(index, enemy_id)
    @gave_death_throes = false # 既に断末魔をあげたかの判断に利用
  end
  #--------------------------------------------------------------------------
  # ● 断末魔をあげるバトラーであるか
  #--------------------------------------------------------------------------
  def death_throes?
    @result.added_states.include?(death_state_id) && !death_throes_id.zero? && !@gave_death_throes
  end
  #--------------------------------------------------------------------------
  # ● 断末魔で発動するスキルID
  #--------------------------------------------------------------------------
  def death_throes_id
    enemy.death_throes_id
  end
  #--------------------------------------------------------------------------
  # ● 戦闘不能から復活
  #--------------------------------------------------------------------------
  def revive
    super
    @gave_death_throes = false
  end
  #--------------------------------------------------------------------------
  # ● 戦闘不能判定
  #--------------------------------------------------------------------------
  def dead?
    (!death_throes_id.zero? && !@gave_death_throes) ? false : super
  end
  #--------------------------------------------------------------------------
  # ● 生存判定
  #--------------------------------------------------------------------------
  def alive?
    (!death_throes_id.zero? && !@gave_death_throes) ? true : super
  end
  #--------------------------------------------------------------------------
  # ● 断末魔行動の作成
  #--------------------------------------------------------------------------
  def make_death_throes_actions
    clear_actions
    action = Game_Action.new(self, true)
    action.set_skill(death_throes_id)
    @actions.push(action)
  end
end

class Window_BattleLog < Window_Selectable
  #--------------------------------------------------------------------------
  # ● 断末魔用メソッドの設定
  #--------------------------------------------------------------------------
  def method_death_throes=(method)
    @method_death_throes = method
  end
  #--------------------------------------------------------------------------
  # ● 影響を受けたステータスの表示
  #--------------------------------------------------------------------------
  alias death_throes_display_affected_status display_affected_status
  def display_affected_status(target, item)
    if target.death_throes?
      wait_and_clear
      last_added_states = target.result.added_states.dup
      @method_death_throes.call(target)
      target.result.added_states = last_added_states
      death_throes_display_affected_status(target, item)
      wait_and_clear
      BattleManager.judge_win_loss
    else
      death_throes_display_affected_status(target, item)
    end
  end
end

class Scene_Battle < Scene_Base
  #--------------------------------------------------------------------------
  # ● ログウィンドウの作成
  #--------------------------------------------------------------------------
  alias death_throes_create_log_window create_log_window
  def create_log_window
    death_throes_create_log_window
    @log_window.method_death_throes = method(:process_death_throes)
  end
  #--------------------------------------------------------------------------
  # ● 断末魔の処理
  #--------------------------------------------------------------------------
  def process_death_throes(user)
    last_subject = @subject
    @subject = user
    @subject.make_death_throes_actions
    targets = @subject.current_action.make_targets_with_death_throes.compact
    unless targets.empty?
      if @subject.current_action
        @status_window.open
        use_death_throes(targets)
        @subject.remove_current_action
        process_action_end
      end
    end
    @subject.gave_death_throes = true
    @subject = last_subject
    update_for_wait
  end
  #--------------------------------------------------------------------------
  # ● 断末魔の使用
  #--------------------------------------------------------------------------
  def use_death_throes(targets)
    @subject.sprite_effect_type = :whiten
    item = @subject.current_action.item
    @log_window.display_use_item(@subject, item)
    @subject.use_item(item)
    refresh_status
    show_animation(targets, item.animation_id)
    targets.each {|target| item.repeats.times { invoke_item(target, item) } }
    @log_window.wait_and_clear
  end
end[/pre]


随即出售商品
[pre lang="ruby"]=begin

  說明:
  
  事件中執行腳本呼叫隨機物品商店
  
    random_shop(group, number)
    例:隨機出售組:A中的三件商品:  random_shop(:A, 3)
  
   
  打折出售
  
    random_shop(group, number, disount)
    例:8折出售商品: random_shop(:B, 4, 0.8)
   
   
  不讓玩家出售物品
  
    random_shop(group, number, discount, purchase_only)
    例(須設定折扣):random_shop(:C, 20, 1, 1)
   
=end


class Game_Interpreter
  Random_Goods = { #在這裡定義你的商品列表
  :A => [:i1],
    :时空商人 => [:i1_29, :i154],
    :时空商人2 => [:i1_29, :i154],
    :时空商人3 => [:i1_29, :i97, :i154],
    :时空商人4 => [:i1_29, :i64_i68, :i154],
    :时空商人5 => [:i1_29, :i154],
    :时空商人6 => [:i1_29, :i109, :i154],
    :时空商人7 => [:i1_29],
    :时空商人8 => [:i1_29, :i86, :i154],
    :时空商人9 => [:i1_29, :i154],
    :时空商人10 => [:i1_29, :i104, :i154],
    :时空商人11 => [:i1_29, :i71, :i154],
    :时空商人12 => [:i1_29, :i72, :i154],
    :时空商人13 => [:i1_29, :i130_i132, :i154],
    :时空商人14 => [:i1_29, :i154],
    :时空商人15 => [:i1_29, :i82, :i154],
    :神器商人 => [:w71_75],
    :C => [:w1_60]#i物品,w武器,每個組用逗號隔開
  }
  # 設置變數號碼,當變數改變后商人才會更新商品
  # 設置為 nil 的話,每次跟商人對話商品都會更新
  Goods_Change_Var = 86
  #
  def random_shop(group, num, discount = 1, purchase_only = false)
    return if $game_party.in_battle
    goods = []
    Random_Goods[group].each {|g|
      g = g.to_s
      type = g[0]=="i" ? 0 : g[0]=="w" ? 1 : 2
      if g.include?("_")
        a, b = g.scan(/\d+/)
        for i in a.to_i..b.to_i
          begin
            goods.push(random_goods_info(discount, type, i))
          rescue
            report_random_goods_crash(group, g)
            return
          end
        end
      else
        g =~ /(\d+)/
        begin
          goods.push(random_goods_info(discount, type, $1.to_i))
        rescue
          report_random_goods_crash(group, g)
          return
        end
      end
    }
    SceneManager.call(Scene_Shop)
    SceneManager.scene.prepare(new_random_goods(goods, num), purchase_only)
    Fiber.yield
  end
  #
  def new_random_goods(goods, num)
    return unless event = get_character(0)
    if Goods_Change_Var
      key = [@map_id, @event_id, :random_goods]
      var = $game_variables[Goods_Change_Var]
      unless $game_self_switches.get_value(key) &&
             $game_self_switches.get_value(key)[0] == var
        goods = goods.sample(num).sort
        $game_self_switches.set_without_refresh(key, [var, goods])
        return goods
      else
        return $game_self_switches.get_value(key)[1]
      end
    else
      return goods.sample(num).sort
    end
  end
  #
  def random_goods_info(discount, type, i)
    discount == 1 ?
      [type, i, 0, which_random_goods(type).price] :
      [type, i, 1, (which_random_goods(type).price * discount).round]
  end
  def which_random_goods(type)
    case type
    when 0; $data_items
    when 1; $data_weapons
    when 2; $data_armors
    end
  end
  #
  def report_random_goods_crash(group, g)
    msgbox("隨機商店發生錯誤:Group :#{group}  Element :#{g}") if $TEST
  end
end

class Game_SelfSwitches
  def set_without_refresh(key, value)
    @data[key] = value
  end
  def get_value(key)
    @data[key]
  end
end
[/pre]

随机礼物(两个随机在图书馆有)
[pre lang="ruby"]=begin

  說明:
  
  事件中執行腳本呼叫來獲取隨機物品
  
    random_gift(group, number)
    例:隨機獲得組:A中的三件物品:  random_gift(:A, 3)
   
=end

class Game_Interpreter
  Random_Gifts = { #隨機獎品列表
    :恢复 => [:i1_8], #i物品,w武器,每個組用逗號隔開
    :符文 => [:i9_16],
    :升阶 => [:i17_19],
    :宝珠 => [:i22_29],
    :终焉宝珠 => [:i140_144],
    :攻击神器 => [:w71_75],
    :防御神器 => [:a82_89],
    :时空之光 => [:a108_116],
    :点数 => [:i137_139],
    :低级素材 => [:i1_8, :i20, :i21, :i35_37, :i17_19],
    :中级素材 => [:i9_16, :i38, :i39, :i119, :i132],
    :高级素材 => [:i114, :i103, :i70_72, :i56, :i45,:i22_29],
   
   
   
:奖池普 => [:i9_16, :i38, :i39, :i119, :i132,:i114, :i103, :i70_72, :i56, :i45,:i22_29],
:王者 => [:i9_16, :i38, :i39, :i119, :i132,:i114, :i103, :i70_72, :i56, :i45,:i22_29,:i172_180,:i140_144],
:礼装 => [:i9_16, :i38, :i39, :i119, :i132,:i114, :i103, :i70_72, :i56, :i45,:i22_29,:a118_131],

   
   
    :谱尼 => [:i130_132, :i119,:i144,:i70_72,:i53,:i46],
    :票 => [:i1_8, :i17_19],
    :券 => [:i1_8, :i17_19, :i9_16, :i22_29, :i137_139],
    :药水 => [:i47, :i48, :i53_i56, :i84, :i85, :i78, :i133_i135, :i1_i8],
    :各种礼包 => [:i145_152, :i154, :i155, :i157],
    :末日 => [:i3, :i5, :i6, :i30, :i31, :i36, :i37, :i17_19, :i119, :i152],
    :C => [:w1_60]
  }
  # 設置開關號碼,當開關開啟時一定會獲取到不同的幾件物品
  # 設置為 nil 的話則總是有可能獲取到相同的物品
  Diff_Gift_Swth = nil
  def display_gift_text(name)
    $game_message.add("获得:" + name)
  end
  #
  def random_gift(group, num)
    gifts = []
    Random_Gifts[group].each {|g|
      g = g.to_s
      type = g[0]=="i" ? 0 : g[0]=="w" ? 1 : 2
      if g.include?("_")
        a, b = g.scan(/\d+/)
        for i in a.to_i..b.to_i
          gift = which_random_gift(type)
          gift ? gifts.push(gift) : (return report_random_gifts_crash(group, g))
        end
      else
        g =~ /(\d+)/
        gift = which_random_gift(type)[$1.to_i]
        gift ? gifts.push(gift) : (return report_random_gifts_crash(group, g))
      end
    }
    wait_for_message
    if Diff_Gift_Swth && $game_switches[Diff_Gift_Swth]
      gifts.sample(num).each {|g|
        $game_party.gain_item(g, 1)
        display_gift_text(g.name)
      }
    else
      num.times {
        g = gifts[rand(gifts.size)]
        $game_party.gain_item(g, 1)
        display_gift_text(g.name)
      }
    end
    $game_message.face_name = ''
    $game_message.face_index = 0
    $game_message.background = 0
    $game_message.position = 2
    wait_for_message
  end
  #
  def which_random_gift(type)
    case type
    when 0; $data_items
    when 1; $data_weapons
    when 2; $data_armors
    end
  end
  #
  def report_random_gifts_crash(group, g)
    msgbox("隨機禮物發生錯誤:Group :#{group}  Element :#{g}") if $TEST
  end
end
[/pre]

新套装系统(6RVA帖应该功能最全了)
[pre lang="ruby"]#============================================================================
# Equipment Sets v2.1e
# By Emerald
#----------------------------------------------------------------------------
# You're free to use the script for any game, as long as you give credits
#----------------------------------------------------------------------------
# Version History
# 1.0 -> Script fully ready for public use. Addes sets, unlimited set items,
#        set bonuses for the 8 basic stats, set bonuses requirement (how many
#        items of the set is the actor wearing?)
# 1.1 -> a. changed the set bonuses work. Instead of [parameter, bonus] you now
#        use [sort, parameter, bonus]. Also added sorts 0 and 2. Check SPECIAL
#        VALUES for their corresponding parameters.
#        b. Added sort 1: Standard Parameters (Percentage). The corresponding
#        parameters are the same as for sort 0. See SPECIAL VALUES for extra
#        notes.
# 1.2 -> Added Sort 3: Special Parameters. The values for the parameters can be
#        found in SPECIAL VALUES, just as usual. Addes Sort 4: Skills!! These
#        use a different syntax than the other bonuses, so be sure to check
#        SPECIAL VALUES if you are unfamiliar with them.
# 1.3 -> a. rewritten most of the code to remove so major bugs. Also cleaned
#        code (about 140 lines less this time, WITH 4 added Sorts). Added
#        Module Emerald (EME). Sets and Set_Bonuses move to Module EME. Added
#        MAX_ELEMENTS to Module EME. Added Sort 5 (Elemental Efficiency), Sort
#        6 (Debuff Rate), Sort 7 (State Rate), Sort 8 (State Resist) and Sort 9
#        (Attack Elements). See SPECIAL VALUES for instructions.
#        WARNING these are still in Beta Stage, so report all bugs found.  
#        b. removed many, MANY major bugs! Removed a bug where unequipping
#        resulted in an undefined array, removed some typos, fixed the bonuses
#        for almost EVERY Sort, removed some more typos, shortened code a little
#        bit, removed some more minor bugs regarding change_equip.
# 1.4 -> More bug fixes. Also added Sort 10 (Attack States), Sort 11 (Equipment
#        Types) and Sort 12 (Attack Specials). Refer to SPECIAL VALUES for
#        all needed information.
# 1.5 -> Bug fix to discard_equip(...). Added the foruth value of Sort 11
#        (Dual Wielding), added Sort 13, Sort 14, Sort 15, Sort 16 and Sort 17
#        which are Additional Skill Types, Sealed Skill Types, Sealed Skills,
#        Fixed Equip Types and Sealed Equip Types respectively. As usual, go to
#        SPECIAL VALUES for the needed instructions.
# 1.6 -> Added a compatibility patch for Fomar's Dual Wield -> Free Hands script.
# 1.7 -> Added Sorts 18 (special flags), 19 (party abilities) and 20 (other
#        traits). See SPECIAL VALUES for the instructions.
# 1.8a-> Added sounds to be played when a certain amount of set pieces has been
#        equipped. Also removed a bug regarding skipping amounts of pieces.
# 1.8b-> Small bugfix regarding set sounds.
# 1.8c-> Small bugfix regarding attack states.
#
# 2.0 -> MAJOR REWRITE. Aliased a few more methods than before, to further
#        increases compatability. Added a method which initializes sets which
#        are worn by actors at the start of the game. Halved the code used to
#        determine if items belong to sets. Scraped a few uneccessairy methods.
#        Practically removed 2/3 of my version of release_unequipable_equips,
#        and made the EES + Fomar123's Dual Wield -> Free Hands script patch
#        1 line instead of 10. Almost entirely changed the way Set Skills and
#        Set Equipment Options work. Also fixed a few bugs in the progress
#        (for example additions of variable 2 which I accidentally left in the
#        script.)
# 2.1a-> Start of the debugging patch. Added a function to remove bonuses when
#        unequipping stuff, like usual. Forgot to re-add in 2.0 >.<
# 2.1b-> Fixed a small typo.
# 2.1c-> Fixed initalizition of set equips.
# 2.1d-> Fixed a bug regarding bonuses not being applied upon optimizing equips
#        and a bug regarding the removing of bonuses when unequipping stuff.
# 2.1e-> Removed something which I should have added (regarding the BaseItem
#        class) in release_unequippable_items. This also fixed the compatibility
#        issues with Tsukihime's Effect Manager.
#----------------------------------------------------------------------------
# Started with a Iron Sword? Pretty good. Found a Gold Sword? Awesome! Found
# the complete Bronze Set? Bad stuff...
# Unless, they give you bonuses! In other words, this script allows you to create
# bonuses for wearing multiple items of a set... Just wanted to make it sound
# more fun...
#
# Instructions:
#
# Just as always, put this script between Бе Materials and Бе Main. Put this script
# below any script which rewrites change_equip and above any script which aliases
# 'param' in Game_Actor (usually in Game_BattlerBase, but it only matters if it
# is rewritten/aliased in Game_Actor).
#
# Set MAX_ELEMENTS below module EME and above Sets to the maximum number of
# elements in the database. Else, the script won't recognize any above the value.
#
#
# SETS
#
# To create sets (sorry, no names yet) go to Sets in the configuration part.
# Add the set id, followed by an array containing arrays. The latter arrays
# must be at least two elements long, one for the type of equipment, one for the
# id.
# Examples:
#
# 1 => [[0, 1], [1, 2]], <- The []'s define an array. The arrays like the [0,1]
# and [1, 2] should be at least two elements long (each element is separated by
# a comma.
#
# 2 => [[0, 5], [0, 6], [1, 5], [1,7]], <- If the array is not the last in the
# list, add a comma or you'll get an error. This goes for every array.
#
# set id => [[equipment type, equipment id], [equipment type, equipment id]]
#
# NOTE:
# The set id MUST be 0 or higher. The variable in which the sets are stored (which
# is called a hash) usually begins with 1 =>, so that's why that's also in the
# standard config.
# The Equipment Types are 0 (weapons) and 1 (armors.)
# DO NOT COPY the ID of items in the database. If you put all the useless 0's
# in front of the real ID, you'll get an error/the script won't work.
# Furthermore, you can have an infinite amount of equipment belonging (is that a
# word?) to a set, so don't worry about compatibility issues with Extra Equipment
# Slots scripts. Unless they rewrite change_equip, than there's a slight chance
# on problems. This can be fixed, however, by putting this script below any
# script which rewrites change_equip.
# Also, you can have multiple weapons in array and the same equipment in different
# sets.
#
#
# SET BONUSES
#
# For set bonuses, go to Set_Bonuses. Use the follwing syntax to add bonuses:
#
# set id => {
#    amount of pieces required => [[sort, parameter, bonus]]
#           },
#
# Specifications:
# set id = the same set id as in Sets.
#
# amount of pieces required = the amount of pieces the player must be wearing in
# order to receive the bonuses. If you want to skip one, just skip it. Like:
# 1 => blablabla
# 3 => blablabla
#
# sort = type of bonus. For all sorts, see SPECIAL VALUES.
#
# parameter = the parameter which receives the bonus. For all parameters, see
# SPECIAL VALUES.
#
# bonus = the bonus to be added to parameter. Note that this is a direct bonus,
# not a percentage. If the vale is negative, the bonus will become negative. If
# the value is 0, there will be no bonus to that stat.
#
#
# SPECIAL VALUES
# Sets
# ----
# Equipment types: 0 and 1. 0 is the Weapons tab in the database, 1 is the
# Armors tab in the database.
#
# Set_Bonuses
# ---
# Sorts:
# 0  - Standard Parameter
# 1  - Standard Parameter (Percentage)
# 2  - Extra Parameter
# 3  - Special Paramater
# 4  - Skills (WARNING, DIFFERENT SYNTAX!! See Skills on how to use them)
# 5  - Elemental Efficiency
# 6  - Debuff Rate
# 7  - State Rate
# 8  - State Resistance (WARNING, VALUE HAS A DIFFERENT FUNCTION!!)
# 9  - Attack Elements (WARNING, VALUE HAS A DIFFERENT FUNCTION!!)
# 10 - Attack States
# 11 - Equipment Types (WARNING, DIFFERENT SYNTAX!! See Equipment Types on how
#                       to use them)
# 12 - Attack Specials
# 13 - Additional Skill Types (WARNING, VALUE HAS A DIFFERENT FUNCTION!!)
# 14 - Sealed Skill Types (WARNING, VALUE HAS A DIFFERENT FUNCTION!!)
# 15 - Sealed Skills (WARNING, VALUE HAS A DIFFERENT FUNCTION!!)
# 16 - Fixed Equip Types (WARNING, VALUE HAS A DIFFERENT FUNCTION!!)
# 17 - Sealed Equip Types (WARNING, VALUE HAS A DIFFERENT FUNCTION!!)
# 18 - Special Flags (WARNING, VALUE HAS A DIFFERENT FUNCTION!!)
# 19 - Party Abilities (WARNING, VALUE HAS A DIFFERENT FUNCTION!!)
# 20 - Other Traits
#
# Standard Parameters: (Sort 0)
# 0 - MaxHp
# 1 - MaxMp
# 2 - Attack
# 3 - Defense
# 4 - Magic Attack (Spirit)
# 5 - Magic Defence (Resistance)
# 6 - Agility
# 7 - Luck
#
# Standard Parameters (Percentage): (Sort 1)
# 0 - MaxHp
# 1 - MaxMp
# 2 - Attack
# 3 - Defense
# 4 - Magic Attack (Spirit)
# 5 - Magic Defence (Resistance)
# 6 - Agility
# 7 - Luck
# Note that stats are calculated this way:
# Basic + Equipment Bonuses + Set Bonuses (normal) + Set Bonuses (percentages,
# equal to bonus% (in [1, parameter, bonus]) * basic + equipment bonuses)
#
# Extra Parameters: (Sort 2)
# 0 - Hit Rate
# 1 - Evasion
# 2 - Critical Rate
# 3 - Critical Evasion
# 4 - Magical Evasion
# 5 - Magical Reflection
# 6 - Counter Rate
# 7 - HP Regen
# 8 - MP Regen
# 9 - TP Regen
#
# Special Parameters: (Sort 3)
# 0 - Target Rate/ Accuracy Rate(in Eng Translation Patch)/ Aggro Rate
# 1 - Guard Effect Rate
# 2 - Recovery Effect Rate
# 3 - Pharmacology/ Knowledge in Medicine(in Eng Translation Patch)
# 4 - MP Cost Rate
# 5 - TP Charge Rate
# 6 - Physical Damage Rate
# 7 - Magical Damage Rate
# 8 - Floor Damage Rate
# 9 - Experience Rate
#
# Skills: (Sort 4)
# These skills don't have parameter values. Instead, the last two elements in
# their array have a different effect than usual:
# [sort (4), -----, skill_id]
# Sort = still the same and of course 4
# ----- = before this was Active, but that is no longer required. In order to
# by-pass the need to change this to skill_id (for people who had this script
# before v2.0), this variable has become unused instead of deleted all-together.
# You can put anything you want here, it doesn't even have to be an integer.
# Skill_Id = the id of the skill which the actor learns.
#
# Elemental Efficiency: (Sort 5)
# Values are the same as Element IDs in the database. (SO NO 0!!)
# If the bonus is negative, the actor becomes more resistant to the element.
# If the bonus is positive, the actor becomes weaker to the element.
#
# Debuff Rate: (Sort 6)
# 0 - MaxHp
# 1 - MaxMp
# 2 - Attack
# 3 - Defense
# 4 - Magic Attack (Spirit)
# 5 - Magic Defence (Resistance)
# 6 - Agility
# 7 - Luck
# If the bonus is negative, the actor becomes more resistant to debuffs regarding
# the set parameter.
# If the bonus is positive, the actor becomes weaker to debuffs regarding the set
# parameter.
#
# State Rate: (Sort 7)
# Values are the same as the State IDs in the database (SO NO 0!!)
# If the bonus is negative, the actor becomes more resistant to the state.
# If the bonus is positive, the actor becomes weaker to the state.
#
# State Resist: (Sort 8)
# Values are the same as the State IDs in the database (SO NO 0!!)
# If the bonus is positive, the actor becomes fully resistant to the set state.
# However, if the bonus is negative, the actor LOSES full resistance to the set
# state!
#
# Attack Elements: (Sort 9)
# Values are the same as the Element IDs in the database (SO NO 0!!)
# If the bonus is positive, the element is added to the attack elements.
# However, if the bonus is negative, the element is REMOVED from the attack
# elements!
#
# Attack States: (Sort 10)
# Values are the same as the State IDs in the database (SO NO 0!!)
# Bonus is the chance of the state to occur.
#
# Equipment Types: (Sort 11)
# 0 as parameter means that the bonus type is a Weapon Type.
# 1 as parameter means that the bonus type is a Weapon Type, but instead it will
# be REMOVED from the list of weapon types.
# 2 as parameter means that the bonus type is an Armor Type.
# 3 as parameter means that the bonus type is an Armor Type, but instead it will
# be REMOVED from the list of armor types.
# 4 as parameter allows Dual Wielding.
# Bonus is the same as the ID of the Equipment Types in the database.
# Note that removed types override added types. So you can first remove an
# equip type and afterwards add it, but you can first add it and then remove it.
#
# Attack Specials: (Sort 12)
# 0 - Attack Speed
# 1 - Additional Attacks
# Both in percentages. So for additional attacks, not 1 but 100.
#
# Additional Skill Types: (Sort 13)
# Values are the same as the Skill Types IDs in the database (SO NO 0!!)
# If the bonus is positive, the skill types is added.
# However, if the bonus is negative, the skill type is REMOVED!
#
# Sealed Skill Types: (Sort 14)
# Exact the same as above, only if the bonus is positive the type gets sealed,
# if the bonus is negative the type gets removed from the sealed types.
#
# Sealed Skills: (Sort 15)
# Again, exact the same as above. Only this time, replace the skill type id by
# the skill id.
#
# Fixed Equip Types: (Sort 16)
# Exact the same as Sealed Skill Types, only the equip types get fixed. Of course,
# replace skill type id by equip type id.
#
# Sealed Equip Types: (Sort 17)
# And yet again, exact the same only the equip types get sealed. Of course,
# replace skill type id by equip type id.
#
# Special Flags: (Sort 18)
# 0 - Auto Combat
# 1 - Guard
# 2 - Substitute/Cover
# 3 - Same TP in next battle
# For bonus, put a positive number (or 0) for added trait, and negative number
# for removed trait.
#
# Party Abilities: (Sort 19)
# 0 - Encounter cut down by half
# 1 - No encounters
# 2 - No suprise attacks
# 3 - Preemptive strike rate up
# 4 - Double currency from battles
# 5 - Double items from battles
# For bonus, put a positive number (or 0) for added trait, and negative number
# for removed trait.
#
# Others Traits: (Sort 20)
# 0 - Max TP up by bonus
# 1 - Atk Skill becomes bonus (skill ID) / So, if you have [20, 1, 10] the actor's
# attack skill becomes 10.
# 2 - Guard Skill becomes bonus (skill ID) / So, if you have [20, 2, 10] the
# actor's guard skill becomes 10,
#----------------------------------------------------------------------------
# Credits to:
# Lettuce, if it wasn't for his RMVX Item Sets script, I would not have learned
# how Arrays and Hashes work.
# Many members at www.rpgmakervxace.net for pointing out various bugs and whatnot.
# You for reading through the wall of text ^^ (at least... I hope you did that..)
#----------------------------------------------------------------------------
# If you have any issues with this script, contact me at
# http://www.rpgmakervxace.net/ind ... lds-equipment-sets/
#============================================================================
#
# CONFIGURATION
#
#============================================================================

module EME
  
  MAX_ELEMENTS = 999

#----------------------------------------------------------------------------
# Sets syntax
#----------------------------------------------------------------------------
# Sets = {
#          set_id => [[equipment_type, equipment_id]]
#        }
#
# set_id must be bigger than 0
# equipment_type can be either 0 (weapon) or 1 (armor)
# Add a comma after a ']' if it's not the last element in the array/hash.
#
# Don't forget to add a ungettable item at the end! Else, the last item will
# count for two!
#----------------------------------------------------------------------------

Sets = {
         1 => [[0, 64], [1, 61]],
         2 => [[0, 79], [1, 102], [1, 103], [1, 104]],
         3 => [[0, 86], [1, 106], [1, 107], [1, 117]]
         
       }

#----------------------------------------------------------------------------
# Sets syntax
#----------------------------------------------------------------------------
# Set_Bonuses = {
#       set id => {
#         amount of pieces required => [[sort, parameter, bonus]], [sort, random parameter, 0]]
#                 }
#                }
#
# set_id must correspond to set_id of Sets
# amount of pieces required indicates how many pieces of the set the actor must
# be wearing before receiving the bonus. If you want to skip one, make the only
# element in it's array [0, 0, 0].
# sort indicates which kind of parameters the bonuses change. See SPECIAL VALUES
# for all sorts.
# parameter can be a value depending on sort. See SPECIAL VALUES in the
# instructions for their corresponding stats.
# Bonus is a direct value added to 'parameter'. If 0, no bonus is added. If
# negative, bonus becomes negative.
# Random paramter is just a random parameter to prevent the last bonus from
# being doubled. Always make the bonus of this element 0.
#
# Add a comma after a ']' or '}' if it's not the last element in the array/hash.
#
# Don't forget to add a bonus of [0, 0, 0] at the end! Or else, the last bonus
# will be doubled!
#----------------------------------------------------------------------------
Set_Bonuses =
{
  1 => {
#~     1 => [[2, 7, 5]],
    1 => [4,269],
    2 => [[0, 0, 200]]
       },

  3 => {
    1 => [[0, 2, 120]],
    2 => [[0, 4, 120]],
    3 => [[1, 2, 15]],
    4 => [[1, 4, 15]]
       },
      
  2 => {
    1 => [[0, 2, 120]],
    2 => [[2, 2, 10]],
    3 => [[3, 5, 115]],
    4 => [[1, 2, 25]],
       }
}

#-----------------------------------------------------------------------------
# Sets syntax
#-----------------------------------------------------------------------------
# Set_Sounds = {
#   set_id => {
#     amount_of_pieces_required => [file_name, volume, pitch]
#   }
# }
#
# Resembles the other two parts so I think not much of an explanation is needed.
# When the required amount of pieces has been equipped, the sound sound will be
# played. Doesn't apply for unequipping. Again, watch the comma's!!
#----------------------------------------------------------------------------
Set_Sounds =
{
  1 => {
    1 => ["Flash2", 100, 100], # <- comma here since it isn't the last one!
    2 => ["Flash1", 100, 100],  # <- no comma here since it IS the last one!
    3 => ["Flash1", 100, 100]  # <- no comma here since it IS the last one!
       }
}

end

# Only edit things past here if you know what you're doing

$imported = {} if $imported.nil?
$imported["Emerald's Equipment Sets"] = true

#============================================================================
#
# Game_Actor
# Handles everything for this script.
#============================================================================
class Game_Actor < Game_Battler
  
  attr_reader :active_sets
  attr_reader :item_sets
  
  alias eme_ees_setup setup
  def setup(actor_id)
    @non_set_skills = []
    @skill_from_sets = false
    reset_bonuses
    @active_sets = []
    @item_sets = [0] * (EME::Sets.size + 1)
    eme_ees_setup(actor_id)
  end

  alias eme_init_equips init_equips
  def init_equips(equips)
    eme_init_equips(equips)
    equips.each_with_index{|item_id, i|
      etype_id = index_to_etype_id(i)
      slot_id = empty_slot(etype_id)
      for set_id in 1..EME::Sets.size
        for ees_set_equip in EME::Sets[set_id]
          if item_id != nil and slot_id != nil and ees_is_the_set_item?(etype_id == 0 ? $data_weapons[item_id] : $data_armors[item_id], ees_set_equip)
            @item_sets[set_id] += 1
            @active_sets.push(set_id) unless @active_sets.include?(set_id)
          end
        end
      end
    }
    refresh
  end
   
  def ees_is_the_set_item?(item, ees_set_equip)
    return (((ees_set_equip[0] == 0 and item.is_a?(RPG::Weapon)) or (ees_set_equip[0] == 1 and item.is_a?(RPG::Armor))) and ees_set_equip[1] == item.id)
  end

  alias eme_ees_learn_skill learn_skill
  def learn_skill(skill_id)
    eme_ees_learn_skill(skill_id)
    @non_set_skills.push(skill_id) unless @skill_from_sets
    @skill_from_sets = false
  end

  alias eme_ebs_change_equip change_equip
  def change_equip(slot_id, item)
      for set_id in 1..EME::Sets.size
        for ees_set_equip in EME::Sets[set_id]
          if slot_id != nil and @equips[slot_id] != nil and @equips[slot_id].object != nil
            if ees_is_the_set_item?(@equips[slot_id].object, ees_set_equip)
              @item_sets[set_id] -= 1
              @active_sets.delete(set_id) if @item_sets[set_id] == 0
            end
          end
          if item != nil and ees_is_the_set_item?(item, ees_set_equip)
            @item_sets[set_id] += 1
            @active_sets.push(set_id) unless @active_sets.include?(set_id)
            if EME::Set_Sounds.has_key?(set_id) and EME::Set_Sounds[set_id].has_key?(set_amount_wearing(set_id))
              sound = EME::Set_Sounds[set_id][set_amount_wearing(set_id)]
              Audio.se_play("Audio/SE/" + sound[0], sound[1], sound[2])
            end
          end
        end
      end
    set_check
    eme_ebs_change_equip(slot_id, item)
  end

  def unlearn_set_skills(set_id)
    EME::Set_Bonuses[set_id].each_value{|bonus_array|
      bonus_array.each{|bonus|
        if bonus[0] == 4
          forget_skill(bonus[2]) unless @non_set_skills.include?(bonus[2])
          @ees_skills.delete(bonus[2])
        end
      }
    }
  end
  
  def item_set_reset_all
    @active_sets.each{|set_id| item_set_reset(set_id)}
  end
  
  def item_set_reset(set_id)
    return unless set_id > 0 and @item_sets[set_id] > 0
    unlearn_set_skills(set_id)
  end
  
  def release_unequippable_items(item_gain = true)
    @equips.each_with_index do |item, i|
      if !equippable?(item.object) || item.object.etype_id != equip_slots
        trade_item_with_party(nil, item.object) if item_gain
        item.object = nil
      end
    end
  end

  def release_unequippable_items(item_gain = true)
    loop do
      change_equips = 0
      @equips.each_with_index do |item, i|
        if !equippable?(item.object) or item.object.etype_id != equip_slots
          next if (RPG::Weapon.method_defined?(:two_handed?) and dual_wield? and (equip_slots == 1 and item.object.etype_id == 0))
          trade_item_with_party(nil, item.object) if item_gain
          change_equips += 1 unless item.object.nil?
          unless item.object.nil?
          for set_id in 1..EME::Sets.size
            for ees_set_equip in EME::Sets[set_id]
              if ees_is_the_set_item?(item.object, ees_set_equip)
                @item_sets[set_id] -= 1
                @active_sets.delete(set_id) if @item_sets[set_id] == 0
              end
            end
          end
          end
          item.object = nil
        end
      end
      set_check
      break if change_equips == 0
    end
  end

  alias eme_ebs_discard_equip discard_equip
  def discard_equip(item)
    slot_id = equips.index(item)
    if slot_id != nil
      for set_id in 1..EME::Sets.size
        for ees_set_equip in EME::Sets[set_id]
          if ees_is_the_set_item?(item, ees_set_equip)
            @item_sets[set_id] -= 1
            @active_sets.delete(set_id) if @item_sets[set_id] == 0
          end
        end
      end
    end
    eme_ebs_discard_equip(item)
    refresh
  end
  
  def set_amount_wearing(set_id)
    return @item_sets[set_id]
  end

  def set_check
    item_set_reset_all
    reset_bonuses
    @active_sets.each{|set| change_bonuses(set) unless set == nil}
  end
  
  def change_bonuses(set_id)
    return if set_id == 0 or set_amount_wearing(set_id) == 0
    EME::Set_Bonuses[set_id].each_key{|key|
      if set_amount_wearing(set_id) >= key
        for g in 0...EME::Set_Bonuses[set_id][key].size
          sort = EME::Set_Bonuses[set_id][key][g][0]
          stat = EME::Set_Bonuses[set_id][key][g][1]
          stat_bonus = EME::Set_Bonuses[set_id][key][g][2]
          case EME::Set_Bonuses[set_id][key][g][0]
          when 0
            sets_param_change(stat, stat_bonus)
          when 1
            sets_per_param_change(stat, stat_bonus)
          when 2
            sets_xparam_change(stat, stat_bonus)
          when 3
            sets_sparam_change(stat, stat_bonus)
          when 4
            next if skill_learn?(stat_bonus)
            @skill_from_sets = true
            learn_skill(stat_bonus)
            @ees_skills.push(stat_bonus)
          when 5
            stat -= 1
            sets_element_rate_change(stat, stat_bonus)
          when 6
            stat -= 1
            sets_debuff_rate_change(stat, stat_bonus)
          when 7
            stat -= 1
            sets_state_rate_change(stat, stat_bonus)
          when 8
            sets_state_resist_change(stat, stat_bonus)
          when 9
            sets_atk_elements_change(stat, stat_bonus)
          when 10
            sets_atk_states_change(stat) if stat_bonus > 0
            sets_atk_states_rate_change(stat, stat_bonus)
          when 11
            if stat < 2
              change_sets_additional_wtypes(stat_bonus, (stat == 0 ? true : false))
            elsif stat < 4
              change_sets_additional_atypes(stat_bonus, (stat == 2))
            elsif stat == 4
              @eme_ebs_two_swords_style = true
            end
          when 12
            sets_atk_specials_change(stat, stat_bonus)
          when 13
            add_sets_skill_types(stat, stat_bonus)
          when 14
            add_sets_sealed_skill_types(stat, stat_bonus)
          when 15
            add_sets_sealed_skills(stat, stat_bonus)
          when 16
            add_sets_fixed_equip_types(stat, stat_bonus)
          when 17
            add_sets_sealed_equip_types(stat, stat_bonus)
          when 18
            stat_bonus < 0 ? change_special_flags(stat, true) : change_special_flags(stat)
          when 19
            stat_bonus < 0 ? change_party_abilities(stat, true) : change_party_abilities(stat)
          when 20
            case stat
            when 0
              set_bonus_max_tp(stat_bonus)
            when 1
              set_atk_skill(stat_bonus)
            when 2
              set_grd_skill(stat_bonus)
            end
          end
        end
      end
    }
  end

#-------------------------------------------#
# LABEL FOR AUTHOR                          #
# Don't mind this ;)                        #
#-------------------------------------------#

  def reset_bonuses
    @sets_param_plus = [0] * 8
    @sets_per_param_plus = [0] * 8
    @sets_xparam_plus = [0] * 10
    @sets_sparam_plus = [0] * 10
    @sets_element_rate = [0] * (EME::MAX_ELEMENTS)
    @sets_debuff_rate = [0] * 8
    @sets_state_rate = [0] * ($data_states.size + 1)
    @sets_state_resist = []
    @sets_state_resist_remove = []
    @sets_atk_elements = []
    @sets_atk_elements_remove = []
    @sets_atk_states = []
    @sets_atk_states_rate = [0] * $data_states.size
    @sets_atk_speed_plus = 0
    @sets_atk_times_plus = 0
    @sets_skill_types = []
    @sets_skill_types_remove = []
    @sets_sealed_skill_types = []
    @sets_sealed_skill_types_remove = []
    @sets_sealed_skills = []
    @sets_sealed_skills_remove = []
    @sets_fixed_equip_types = []
    @sets_fixed_equip_types_remove = []
    @sets_sealed_equip_types = []
    @sets_sealed_equip_types_remove = []
   
    @ees_added_special_flags = []
    @ees_removed_special_flags = []
    @ees_added_party_abilities = []
    @ees_removed_party_abilities = []
    @ees_bonus_max_tp = 0
    @new_atk_skill = nil
    @new_grd_skill = nil
   
    @ees_skills = []
    @sets_wtypes = []
    @sets_atypes = []
    @sets_removed_wtypes = []
    @sets_removed_atypes = []
    @eme_ebs_two_swords_style = false
  end

  def sets_param_plus(param_id)
    @sets_param_plus[param_id]
  end

  def sets_param_change(param_id, value)
    @sets_param_plus[param_id] += value
  end

  def sets_per_param_plus(param_id)
    value = param_base(param_id) + param_plus(param_id)
    value *= @sets_per_param_plus[param_id] / 100
    return value
  end

  def sets_per_param_change(param_id, value)
    @sets_per_param_plus[param_id] += value
  end
  
  def sets_xparam_plus(param_id)
    @sets_xparam_plus[param_id]
  end

  def sets_xparam_change(param_id, value)
    @sets_xparam_plus[param_id] += value
  end

  def sets_sparam_plus(param_id)
    @sets_sparam_plus[param_id]
  end
  
  def sets_sparam_change(param_id, value)
    @sets_sparam_plus[param_id] += value
  end
  
  def sets_element_rate(element_id)
    @sets_element_rate[element_id]
  end
  
  def sets_element_rate_change(element_id, value)
    @sets_element_rate[element_id] += value
  end
  
  def sets_debuff_rate(param_id)
    @sets_debuff_rate[param_id]
  end

  def sets_debuff_rate_change(param_id, value)
    @sets_debuff_rate[param_id] += value
  end
  
  def sets_state_rate(state_id)
    @sets_state_rate[state_id]
  end

  def sets_state_rate_change(state_id, value)
    @sets_state_rate[state_id] += value
  end
  
  def sets_state_resist(state_id)
    @sets_state_resist[state_id]
  end
  
  def sets_state_resist_remove(state_id)
    @sets_state_resist_remove[state_id]
  end
  
  def sets_state_resist_change(state_id, value)
    value >= 0 ? (@sets_state_resist.push(state_id) unless @sets_state_resist.include?(state_id)) : (@sets_state_resist_remove.delete(state_id) unless @sets_state_resist_remove.include?(state_id))
  end
  
  def sets_atk_elements(element_id)
    @sets_atk_elements[element_id]
  end
  
  def sets_atk_elements_remove(element_id)
    @sets_atk_elements_remove[element_id]
  end

  def sets_atk_elements_change(element_id, value)
    value >= 0 ? (@sets_atk_elements.push(element_id) unless @sets_atk_elements.include?(element_id)) : (@sets_attack_elements_remove.delete(element_id) unless @sets_atk_elements_remove.include?(element_id))
  end
  
  def sets_atk_states(state_id)
    @sets_atk_states[state_id]
  end

  def sets_atk_states_change(state_id)
    @sets_atk_states.push(state_id) unless @sets_atk_states.include?(state_id)
  end
  
  def sets_atk_states_rate(state_id)
    @sets_atk_states_rate[state_id]
  end

  def sets_atk_states_rate_change(state_id, value)
    @sets_atk_states_rate[state_id] += value
  end
  
  def sets_atk_speed_plus
    @sets_atk_speed_plus
  end

  def sets_atk_times_plus
    @sets_atk_times_plus
  end
  
  def sets_atk_specials_change(parameter, value)
    parameter == 0 ? @sets_atk_speed_plus += value : @sets_atk_times_plus += value
  end
   
  def sets_skill_types(skill_type_id)
    @sets_skill_types[skill_type_id]
  end
  
  def sets_skill_types_remove(skill_type_id)
    @sets_skill_types_remove[skill_type_id]
  end

  def add_sets_skill_types(skill_type_id, value)
    value >= 0 ? (@sets_skill_types.push(skill_type_id) unless @sets_skill_types.include?(skill_type_id)) : (@sets_skill_types_remove.delete(skill_type_id) unless @sets_skill_types_remove.include?(skill_type_id))
  end
  
  def sets_sealed_skill_types(skill_type_id)
    @sets_sealed_skill_types[skill_type_id]
  end
  
  def sets_sealed_skill_types_remove(skill_type_id)
    @sets_sealed_skill_types_remove[skill_type_id]
  end

  def add_sealed_skill_types(skill_type_id, value)
    value >= 0 ? (@sets_sealed_skill_types.push(skill_type_id) unless @sets_sealed_skill_types.include?(skill_type_id)) : (@sets_sealed_skill_types_remove.delete(skill_type_id) unless @sets_sealed_skill_types_remove.include?(skill_type_id))
  end
  
  def sets_sealed_skills(skill_id)
    @sets_sealed_skills[skill_id]
  end
  
  def sets_sealed_skills_remove(skill_id)
    @sets_sealed_skills_remove[skill_id]
  end

  def add_sets_sealed_skills(skill_id, value)
    value > 0 ? (@sets_sealed_skills.push(skill_id) unless @sets_sealed_skills.include?(skill_id)) : (@sets_attack_elements_remove.delete(skill_id) unless @sets_sealed_skills_remove.include?(skill_id))
  end
  
  def sets_additional_wtypes
    @sets_wtypes
  end
  
  def sets_additional_atypes
    @sets_atypes
  end
  
  def sets_removed_wtypes
    @sets_removed_wtypes
  end
  
  def sets_removed_atypes
    @sets_removed_atypes
  end
  
  def change_sets_additional_wtypes(wtype_id, positive_change = true)
    positive_change ? @sets_wtypes.push(wtype_id) : @sets_removed_wtypes.push(wtype_id)
  end
  
  def change_sets_additional_atypes(atype_id, positive_change = true)
    positive_change ? @sets_atypes.push(atype_id) : @sets_removed_atypes.push(atype_id)
  end
  
  def sets_fixed_equip_types(equip_type_id)
    @sets_fixed_equip_types[equip_type_id]
  end
  
  def sets_fixed_equip_types_remove(equip_type_id)
    @sets_fixed_equip_types_remove[equip_type_id]
  end

  def add_fixed_equip_types(equip_type_id, value)
    value >= 0 ? @sets_fixed_equip_types.push(equip_type_id) : @sets_fixed_equip_types_remove.delete(sequip_type_id)
  end
  
  def sets_sealed_equip_types(equip_type_id)
    @sets_sealed_equip_types[equip_type_id]
  end
  
  def sets_sealed_equip_types_remove(equip_type_id)
    @sets_sealed_equip_types_remove[equip_type_id]
  end

  def add_sealed_equip_types(equip_type_id, value)
    value > 0 ? (@sets_sealed_equip_types.push(equip_type_id) unless @sets_sealed_equip_types.include?(equip_type_id)) : (@sets_sealed_equip_types_remove.delete(equip_type_id) unless @sets_sealed_equip_types_remove.include?(equip_type_id))
  end
  
  def change_special_flags(flag_id, negative = false)
    !negative ? @ees_added_special_flags.push(flag_id) : @ees_removed_special_flags.push(flag_id)
  end
  
  def change_party_abilities(ability_id, negative = false)
    !negative ? @ees_added_party_abilities.push(ability_id) : @ees_removed_party_abilities.push(ability_id)
  end
  
  def set_bonus_max_tp(value)
    @ees_bonus_max_tp += value
  end
  
  def set_atk_skill(skill_id)
    @new_atk_skill = skill_id
  end
  
  def set_grd_skill(skill_id)
    @new_grd_skill = skill_id
  end
  
#-------------------------------------------#
# 'NOTHER LABEL FOR AUTHOR                  #
# Don't mind this ;)                        #
#-------------------------------------------#

  def param(param_id)
    value = param_base(param_id) + param_plus(param_id) + sets_param_plus(param_id) #+ [sets_per_param_plus(param_id), 0].max
    value *= param_rate(param_id) * param_buff_rate(param_id)
    [[value, param_max(param_id)].min, param_min(param_id)].max.to_i
  end
  
  alias eme_ebs_xparam xparam
  def xparam(xparam_id)
    value = eme_ebs_xparam(xparam_id) + sets_xparam_plus(xparam_id) / 100
    return value
  end
  
  alias eme_ebs_sparam sparam
  def sparam(sparam_id)
    value = eme_ebs_sparam(sparam_id) + sets_sparam_plus(sparam_id) / 100
    return value
  end
  
  alias eme_ebs_element_rate element_rate
  def element_rate(element_id)
    value = eme_ebs_element_rate(element_id) + sets_element_rate(element_id) / 100
    return value
  end
  
  alias eme_ebs_debuff_rate debuff_rate
  def debuff_rate(param_id)
    value = eme_ebs_debuff_rate(param_id) + sets_debuff_rate(param_id) / 100
    return value
  end

  alias eme_ebs_state_rate state_rate
  def state_rate(state_id)
    value = eme_ebs_state_rate(state_id) + sets_state_rate(state_id) / 100
    return value
  end

  alias eme_ebs_state_resist_set state_resist_set
  def state_resist_set
    value = eme_ebs_state_resist_set
    @sets_state_resist.each{|state| value.push(state) unless value.include?(element)}
    @sets_state_resist_remove.each{|state| value.delete(state)}
    return value
  end
  
  alias eme_ebs_atk_elements atk_elements
  def atk_elements
    value = eme_ebs_atk_elements
    @sets_atk_elements.each{|element| value.push(element) unless value.include?(element)}
    @sets_atk_elements_remove.each{|element| value.delete(element)}
    return value
  end
  
  alias eme_ebs_atk_states atk_states
  def atk_states
    value = eme_ebs_atk_states
    @sets_atk_states.each{|state| value.push(@sets_atk_states) }
    return value
  end
  
  alias eme_ebs_atk_states_rate atk_states_rate
  def atk_states_rate(state_id)
    value = eme_ebs_atk_states_rate(state_id) + sets_atk_states_rate(state_id) / 100
    return value
  end
  
  alias eme_ebs_atk_speed atk_speed
  def atk_speed
    value = eme_ebs_atk_speed + sets_atk_speed_plus / 100
    return value
  end

  alias eme_ebs_atk_times atk_times_add
  def atk_times_add
    value = [eme_ebs_atk_times + sets_atk_times_plus / 100, 0].max
    return value
  end

  alias eme_ebs_dual_wield? dual_wield?
  def dual_wield?
    return true if @eme_ebs_two_swords_style
    eme_ebs_dual_wield?
  end
  
  alias eme_ebs_added_skill_types added_skill_types
  def added_skill_types
    value = eme_ebs_added_skill_types
    @sets_skill_types.each{|sk_type| value.push(sk_type)}
    @sets_skill_types_remove.each{|sk_type| value.delete(sk_type)}
    return value
  end
  
  def skill_type_sealed?(stype_id)
    value = features_set(FEATURE_STYPE_SEAL)
    @sets_sealed_skill_types.each{|sk_type| value.push(sk_type)}
    @sets_sealed_skill_types_remove.each{|sk_type| value.delete(sk_type)}
    return true if value.include?(stype_id)
  end

  def skill_sealed?(skill_id)
    value = features_set(FEATURE_SKILL_SEAL)
    @sets_sealed_skills.each{|skill| value.push(skill)}
    @sets_sealed_skills_remove.each{|skill| value.delete(skill)}
    return true if value.include?(skill_id)
  end
  
  def equip_wtype_ok?(wtype_id)
    value = features_set(FEATURE_EQUIP_WTYPE)
    @sets_wtypes.each{|w_type| value.push(w_type)}
    @sets_removed_wtypes.each{|w_type| value.delete(w_type)}
    return true if value.include?(wtype_id)
  end

  def equip_atype_ok?(atype_id)
    value = features_set(FEATURE_EQUIP_ATYPE)
    @sets_atypes.each{|a_type| value.push(a_type)}
    @sets_removed_atypes.each{|a_type| value.delete(a_type)}
    return true if value.include?(atype_id)
  end

  def equip_type_fixed?(etype_id)
    value = features_set(FEATURE_EQUIP_FIX)
    @sets_fixed_equip_types.each{|e_type| value.push(e_type)}
    @sets_fixed_equip_types_remove.each{|e_type| value.delete(e_type)}
    return true if value.include?(etype_id)
  end
  
  def equip_type_sealed?(etype_id)
    value = features_set(FEATURE_EQUIP_SEAL)
    @sets_sealed_equip_types.each{|e_type| value.push(e_type)}
    @sets_sealed_equip_types_remove.each{|e_type| value.delete(e_type)}
    return true if value.include?(etype_id)
  end
  
  alias eme_ees_special_flag special_flag
  def special_flag(flag_id)
    return false if @ees_removed_special_flags.include?(flag_id)
    return @ees_added_special_flags.include?(flag_id) ? true : eme_ees_special_flag(flag_id)
  end
  
  alias eme_ees_party_ability party_ability
  def party_ability(ability_id)
    return false if @ees_removed_party_abilities.include?(ability_id)
    return @ees_added_party_abilities.include?(ability_id) ? true : eme_ees_party_ability(ability_id)
  end
  
  alias eme_ees_max_tp max_tp
  def max_tp
    return eme_ees_max_tp + @ees_bonus_max_tp
  end
  
  alias eme_ees_attack_skill attack_skill_id
  def attack_skill_id
    return @new_atk_skill unless @new_atk_skill == nil
    return eme_ees_attack_skill
  end

  alias eme_ees_guard_skill guard_skill_id
  def guard_skill_id
    return @new_grd_skill unless @new_grd_skill == nil
    return eme_ees_guard_skill
  end

end
[/pre]

战斗优势:之前那个展示进度的那个大大的帖子。说过这个很特别
[pre lang="ruby"]#------------------------------------------------------------------------------#
#  Galv's Battle Favour
#------------------------------------------------------------------------------#
#  For: RPGMAKER VX ACE
#  Version 1.8
#------------------------------------------------------------------------------#
#  2013-04-25 - version 1.8 - fixed bug when battle ends there is a has full bar
#  2012-12-14 - version 1.7 - option added to change bar widths
#  2012-12-01 - version 1.6 - added a lot more options to tweak bar aesthetics
#  2012-11-18 - version 1.5 - added a switch to disable the favour meter
#                             fixed 'enemy text' positioning
#  2012-11-14 - version 1.4 - fixed a bug where using items would crash the game
#  2012-11-14 - version 1.3 - updated to work better with Yanfly's battle
#  2012-11-12 - version 1.2 - potential bug remedied
#  2012-11-12 - version 1.1 - bug fix
#  2012-11-12 - version 1.0 - release
#------------------------------------------------------------------------------#
#  This scripts adds a 'favour meter' to battle. As the meter fills for each
#  team (enemy or party) they gain a state that can be used to determine the
#  benefits of having higher favour. Upon reaching max favour, a common event
#  can be called to add any additional effects you might like.
#
#  These favour bars increase by causing damage. When one side causes damage, it
#  can also decrease the other side's bar by an amount based on the gain amount.
#
#  Actors and equips can give bonuses to how much these bars increase. Enemies
#  can also have different bonuses for this as well.
#
#  Skills can also be set to modify either side's favour bar without causing
#  damage.
#------------------------------------------------------------------------------#
#  SCRIPT CALLS
#------------------------------------------------------------------------------#
#  You can use script calls to change party or enemy favour during battles.
#
#  $game_party.enemy_favour = x      # set enemy favour to x
#  $game_party.favour = x            # set party favour to x
#
#  $game_actors[y].favour = x        # set actor y's favour bonus to x
#
#  For those with limited scripting knowledge, instead of "=" you can use:
#
#    -=    # minus            +=    # plus            *=    # multiply
#
#  NOTE: The enemy favour and party favour bars are reset each battle.
#  The Actor favour changes remain for the game (and is used for bonuses)
#------------------------------------------------------------------------------#
#  You can use script to get favour amounts (eg. for use in variables 'script')
#
#  $game_party.enemy_favour       # returns the amount the enemy favour bar has
#  $game_party.favour             # returns the amount the party favour bar has
#  $game_actors[x].favour         # returns how much favour actor x has
#  $game_party.members[x].favour  # returns how much favour actor in position x has
#  $game_troop.members[x].favour  # returns how much favour troop x has
#
#------------------------------------------------------------------------------#
#  NOTETAG - ACTORS
#------------------------------------------------------------------------------#
#  <favour: x>          # Where x is the actor's INITIAL favour bonus. This
#                       # bonus can change with above script calls.
#------------------------------------------------------------------------------#
#  NOTETAG - WEAPONS and ARMORS
#------------------------------------------------------------------------------#
#  <favour: x>          # Equips with this notetag will give bonus favour when
#                       # the equipped actor causes damage.
#------------------------------------------------------------------------------#
#  NOTETAG - ENEMIES
#------------------------------------------------------------------------------#
#  <favour: x>          # Enemies tagged with this will get a bonus when they
#                       # cause damage.
#------------------------------------------------------------------------------#
#  NOTETAG - SKILLS
#------------------------------------------------------------------------------#
#  <favour: x>          # Skills with this notetag will give bonus favour when
#                       # the skill used causes damage.
#------------------------------------------------------------------------------#
#
#  HOW DO THE ABOVE NOTETAG BONUSES WORK?
#
#  10% of the total bonuses an actor or enemy has is added to the amount of
#  favour that is generated for their team each time they cause damage.
#
#------------------------------------------------------------------------------#
#  NOTETAG - SKILLS and ITEMS
#------------------------------------------------------------------------------#
#  <mod_pfavour: x>        # How you want to modify party favour
#  <mod_efavour: x>        # How you want to modify enemy favour
#                          # x can be set to:
#                          # 1 for 'add', 2 for 'multiply' or 3 for 'set'.
#                          # If you leave this out, the below won't do anything.
#
#  <do_pfavour: x>         # How much to "add", "mul" or "set" party favour by.
#  <do_efavour: x>         # How much to "add", "mul" or "set" enemy favour by.
#------------------------------------------------------------------------------#
#  EXAMPLE OF TAGS ON A SKILL/ITEM:
#
#  <mod_pfavour: 3>            # This example, the skill would 'set' party
#  <do_pfavour: 50>            # favour to 50 and subtract 30 from enemy.
#  <mod_efavour: 1>            # Only one of each tag will apply.
#  <do_efavour: -30>
#
#------------------------------------------------------------------------------#

($imported ||= {})["Galvs_Battle_Favour"] = true

module Galv_Favour
#------------------------------------------------------------------------------#
#  SCRIPT SETTINGS
#------------------------------------------------------------------------------#  

  DISABLE_SWITCH = 999        # Turn switch ON to disable meters. Do this outside
                            # of combat.

#----------------------------#
#   FAVOUR BAR AESTHETICS:   #
#----------------------------#

  FONT = "Arial"            # The font for all bar related text

  TEXT_SIZE = 22            # The font size of the party/enemy text names.
  TEXT_Y = 0                # Offset ALL bar text vertically different to bars
                             
  PARTY_TEXT = "我方优势"      # Text displayed above party favour bar.
  PARTY_TEXT_COLOR = 0      # The colour of the party text
  ENEMY_TEXT = "敌方优势"      # Text displayed above enemy favour bar.
  ENEMY_TEXT_COLOR = 0      # The colour of the enemy text
   
  TURNS_TEXT_SIZE = 22      # Size of the turns text
  TURNS_TEXT = " CD"     # Text displayed after remaining special turns
  PARTY_TURNS_COLOR = 8     # Colour of the turns text for party
  ENEMY_TURNS_COLOR = 8    # Colour of the turns text for enemy
   
  SHOW_NUMBERS = true       # Show amount of favour as numbers above the bars.
   
  BAR_WIDTH = 250           # How wide the bars are.
  BAR_HEIGHT = 10           # The height of the actual bars.
  BAR_Y = 0                 # Offset the bars vertically different to text
  BAR_POSITION = "bottom"   # Position of the favour bars. Can be "top" or
                            # "bottom" or put in a number without quotes to
                            # display the bar that many pixels from the top.
   
  PARTY_BAR_COLORS = [4,11]     # Gradient colors of party bar.
  ENEMY_BAR_COLORS = [14,10]    # Gradient colors of enemy bar.
   
  PARTY_ACTIVATE_SE = ["Barrier", 100, 100]  # SE when favours reach MAX
  PARTY_ACTIVATE_COLORS = [4,9,12,16]        # bar cycles these colors randomly
   
  ENEMY_ACTIVATE_SE = ["Barrier", 100, 100]  # ["SE Name", volume, pitch]
  ENEMY_ACTIVATE_COLORS = [2,10,18,21]        # bar cycles these colors randomly

#-----------------------#
#   FAVOUR MECHANICS:   #
#-----------------------#

  FAVOUR_MAX = 100          # The number used to determine a full favour bar.
   
  INITIAL_PARTY_FAVOUR = [5,20]    # Set amount of favour when battles begin
  INITIAL_ENEMY_FAVOUR = [5,20]    # randomized between the first and second
                                   # numbers.
                                    
  REDUCE_OPPONENT = 0.5     # When an enemy or party gains favour, the opposing
                            # side loses favour equal to this amount gained
                            # multiplied by this number. ie. 0.5 is 50%

  SPECIAL_ACTIVATE = 119          # Common event ID that is activated when
                                # the party reaches MAX favour.
  ENEMY_SPECIAL_ACTIVATE = 89    # Common event ID that is activated when
                                # the enemy reaches MAX favour.

  SPECIAL_TURNS = 5         # When MAX favour is reached, the party or enemy
                            # team enter a "Special mode". They retain their
  # MAX favour for this many turns. Once the special is over, the favour returns
  # to 0. While in special mode, the opposing team's favour gains are halved.


  # FAVOUR STATES
   
  # Below are lists to set up to determine states to apply for each favour level.
  # They are listed in pairs - a favour amount and a state id.
  # eg.  20 => 21
  # means: when favour amount reaches 20, apply state with id 21 to party/enemy.
  # Each time the next favour level is reached, it removes the previous favour
  # state the party or enemy troop had active.
   

  FAVOUR_STATES = {  # don't touch this.
#------------------------------------------------------------------------------#

    # PARTY FAVOUR STATES
     
      0 => 0,           # when less than 20, display no state. Leave as is.
      20 => 0,         # when 20 favour earned, state 21 applied.
      40 => 0,         # when 40 favour earned, state 22 applied.
      60 => 0,         # when 60 favour earned, state 23 applied.
      80 => 0,         # when 80 favour earned, state 24 applied.
      100 => 0,        # when 100 favour earned, state 25 applied.
      
#------------------------------------------------------------------------------#
  } # don't touch this
#------------------------------------------------------------------------------#

  ENEMY_FAVOUR_STATES = {  # don't touch this.
#------------------------------------------------------------------------------#

    # ENEMY TROOP FAVOUR STATES

      0 => 0,           # when less than 20, display no state. Leave as is.
      20 => 0,         # when 20 favour earned, state 21 applied.
      40 => 0,         # when 40 favour earned, state 22 applied.
      60 => 0,         # when 60 favour earned, state 23 applied.
      80 => 0,         # when 80 favour earned, state 24 applied.
      100 => 0,        # when 100 favour earned, state 25 applied.
      
#------------------------------------------------------------------------------#
  } # don't touch this
#------------------------------------------------------------------------------#
#  CHARGING FAVOUR
#------------------------------------------------------------------------------#
#  Below are equations for enemy and party to charge favour on damage caused.
#  You will need some scripting knowledge to modify this. I have set it up to
#  be used with 100 favour as the max in mind.
#------------------------------------------------------------------------------#

end # don't touch
module Galv_Favour_Mechanics # don't touch

#------------------------------------------------------------------------------#
#  CHARGING PARTY FAVOUR - Equation for gaining favour when causing damage:
#------------------------------------------------------------------------------#  
  def charge_favour(damage) # don't touch
#------------------------------------------------------------------------------#  

    # Generate random favour depending % of max life damage actor does to enemy.
    # Add 10% of all actor's favour bonuses:

    @charge = rand(6) + 5 + (10 * ([damage.to_f,mhp].min / mhp)).to_i
    @charge += (get_actor_favour_bonus * 0.1).to_i

#------------------------------------------------------------------------------#  
  end # don't touch
#------------------------------------------------------------------------------#
#  CHARGING ENEMY FAVOUR - Equation for gaining favour when causing damage:
#------------------------------------------------------------------------------#  
  def charge_enemy_favour(damage) # don't touch
#------------------------------------------------------------------------------#  

    # Generate random favour depending % of max life damage enemy does to actor.
    # Add 10% of enemy favour bonus:
     
    @charge = rand(6) + 5 + (10 * ([damage.to_f,mhp].min / mhp)).to_i
    @charge += (get_enemy_favour_bonus * 0.1).to_i
     
#------------------------------------------------------------------------------#  
#------------------------------------------------------------------------------#
#  END OF SCRIPT SETTINGS
#------------------------------------------------------------------------------#  
  end
   
  def get_actor_favour_bonus
    @bonus = $game_temp.user.favour
    @no_equips = $game_temp.user.equips.count
    @no_equips.times { |i|
      if $game_temp.user.equips != nil
        @bonus += $game_temp.user.equips.favour_bonus
      end
    }
    @bonus += $game_temp.skill_used.favour_bonus
    return @bonus
  end
   
  def get_enemy_favour_bonus
    @bonus = $game_temp.user.favour
    @bonus += $game_temp.skill_used.favour_bonus
    return @bonus
  end

end # Galv_Favour_Mechanics


class RPG::BaseItem

  def favour_bonus
    if @favour_bonus.nil?
      if @note =~ /<favour: (.*)>/i
        @favour_bonus = $1.to_i
      else
        @favour_bonus = 0
      end
    end
    @favour_bonus
  end

  def mod_pfavour
    if @mod_pfavour.nil?
      if @note =~ /<mod_pfavour: (.*)>/i
        @mod_pfavour = $1.to_i
      else
        @mod_pfavour = 0
      end
    end
    @mod_pfavour
  end
  def mod_efavour
    if @mod_efavour.nil?
      if @note =~ /<mod_efavour: (.*)>/i
        @mod_efavour = $1.to_i
      else
        @mod_efavour = 0
      end
    end
    @mod_efavour
  end
   
  def do_pfavour
    if @do_pfavour.nil?
      if @note =~ /<do_pfavour: (.*)>/i
        @do_pfavour = $1.to_i
      else
        @do_pfavour = 0
      end
    end
    @do_pfavour
  end
  def do_efavour
    if @do_efavour.nil?
      if @note =~ /<do_efavour: (.*)>/i
        @do_efavour = $1.to_i
      else
        @do_efavour = 0
      end
    end
    @do_efavour
  end
end # RPG::BaseItem


class Window_Favour < Window_Base

  def initialize
    super(0, 0, Graphics.width, Graphics.height)
    @cycle = 0
    contents.font.name = Galv_Favour::FONT
    update_location
    draw_favour_bars
    self.opacity = 0
  end
   
  def bar_width
    return Galv_Favour::BAR_WIDTH
  end
   
  def update
    self.refresh if $game_party.favour == Galv_Favour::FAVOUR_MAX || $game_party.enemy_favour == Galv_Favour::FAVOUR_MAX || $imported["YEA-BattleEngine"]
  end

  def refresh
    contents.clear
    draw_favour_bars
  end

  def open
    refresh
    super
  end

  def update_location
    case Galv_Favour::BAR_POSITION
    when "top"
      self.y = 0
    when "bottom"
      self.y = Graphics.height - 170
    else
      self.y = Galv_Favour::BAR_POSITION
    end
    self.z = 0
  end
   
  def party_random_color
    @cycle = rand(Galv_Favour::PARTY_ACTIVATE_COLORS.count)
    return Galv_Favour::PARTY_ACTIVATE_COLORS[@cycle]
  end
   
  def enemy_random_color
    @cycle = rand(Galv_Favour::ENEMY_ACTIVATE_COLORS.count)
    return Galv_Favour::ENEMY_ACTIVATE_COLORS[@cycle]
  end

  def draw_favour_bars
    draw_party_favour(Graphics.width / 2, 0, bar_width)
    draw_enemy_favour(Graphics.width / 2 - bar_width - 20, 0, bar_width)
  end
   
  def draw_party_favour(x, y, width)
    if $game_party.favour < Galv_Favour::FAVOUR_MAX
      draw_favour_gauge(x, y, width, favour_rate, text_color(Galv_Favour::PARTY_BAR_COLORS[0]), text_color(Galv_Favour::PARTY_BAR_COLORS[1]))
    else
      draw_favour_gauge(x, y, width, favour_rate, text_color(party_random_color), text_color(party_random_color))
      change_color(text_color(Galv_Favour::PARTY_TURNS_COLOR))
      xr = x + width
      contents.font.size = Galv_Favour::TURNS_TEXT_SIZE
      draw_text(xr - 100, y + Galv_Favour::TEXT_Y, 100, contents.font.size, $game_party.p_special.to_s + Galv_Favour::TURNS_TEXT, 2)
      
    end
    change_color(text_color(Galv_Favour::PARTY_TEXT_COLOR))
    contents.font.size = Galv_Favour::TEXT_SIZE

    draw_text(x, y + Galv_Favour::TEXT_Y, bar_width, contents.font.size, party_text)
    if Galv_Favour::SHOW_NUMBERS && $game_party.p_special <= 0
      xr = x + width
      draw_text(xr - 100, y + Galv_Favour::TEXT_Y, 100, contents.font.size, $game_party.favour.to_s, 2)
    end
  end
   
  def draw_enemy_favour(x, y, width)
     
    if $game_party.enemy_favour < Galv_Favour::FAVOUR_MAX
      draw_reverse_gauge(x, y, width, enemy_favour_rate, text_color(Galv_Favour::ENEMY_BAR_COLORS[0]), text_color(Galv_Favour::ENEMY_BAR_COLORS[1]))
    else
      draw_reverse_gauge(x, y, width, enemy_favour_rate, text_color(enemy_random_color), text_color(enemy_random_color))
      change_color(text_color(Galv_Favour::ENEMY_TURNS_COLOR))
      contents.font.size = Galv_Favour::TURNS_TEXT_SIZE
      draw_text(x + 2, y + Galv_Favour::TEXT_Y, 100, contents.font.size, $game_party.e_special.to_s + Galv_Favour::TURNS_TEXT, 0)
    end
    change_color(text_color(Galv_Favour::ENEMY_TEXT_COLOR))
    contents.font.size = Galv_Favour::TEXT_SIZE
     
    draw_text(x + 2, y + Galv_Favour::TEXT_Y, bar_width, contents.font.size, enemy_text,2)
    if Galv_Favour::SHOW_NUMBERS && $game_party.e_special <= 0
      xr = x + width
      draw_text(x + 2, y + Galv_Favour::TEXT_Y, 100, contents.font.size, $game_party.enemy_favour.to_s, 0)
    end
  end
   
  def enemy_text
    Galv_Favour::ENEMY_TEXT
  end
  def enemy_favour_rate
    [$game_party.enemy_favour.to_f, Galv_Favour::FAVOUR_MAX].min / Galv_Favour::FAVOUR_MAX
  end
   
  def party_text
    Galv_Favour::PARTY_TEXT
  end
  def favour_rate
    [$game_party.favour.to_f, Galv_Favour::FAVOUR_MAX].min / Galv_Favour::FAVOUR_MAX
  end


  def draw_favour_gauge(x, y, width, rate, color1, color2)
    fill_w = (width * rate).to_i
    gauge_y = y + line_height - 8 + Galv_Favour::BAR_Y
    contents.fill_rect(x, gauge_y, width, Galv_Favour::BAR_HEIGHT, gauge_back_color)
    contents.gradient_fill_rect(x, gauge_y, fill_w, Galv_Favour::BAR_HEIGHT, color1, color2)
  end
   
  def draw_reverse_gauge(x, y, width, rate, color1, color2)
    fill_w = (width * rate).to_i
    gauge_y = y + line_height - 8 + Galv_Favour::BAR_Y
    contents.fill_rect(x, gauge_y, width, Galv_Favour::BAR_HEIGHT, gauge_back_color)
    contents.gradient_fill_rect(x + width - fill_w, gauge_y, fill_w, Galv_Favour::BAR_HEIGHT, color1, color2)
  end

end # Window_Favour < Window_Base


class Scene_Battle < Scene_Base
   
  alias galv_favour_sb_start start
  def start
    set_initial_favour
    galv_favour_sb_start
  end
   
  alias galv_favour_sb_terminate terminate
  def terminate
    clear_favour
    galv_favour_sb_terminate
  end
   
  alias galv_favour_create_all_windows create_all_windows
  def create_all_windows
    galv_favour_create_all_windows
    @favour_window = Window_Favour.new if !$game_switches[Galv_Favour::DISABLE_SWITCH]
  end
   
  alias galv_favour_refresh_status refresh_status
  def refresh_status
    galv_favour_refresh_status
    @favour_window.refresh if !$game_switches[Galv_Favour::DISABLE_SWITCH]
  end
   
if $imported["YEA-BattleEngine"]
    def apply_item_effects(target, item)
    if $imported["YEA-LunaticObjects"]
      lunatic_object_effect(:prepare, item, @subject, target)
    end
    target.item_apply(@subject, item)
    status_redraw_target(@subject)
    status_redraw_target(target) unless target == @subject
    @log_window.display_action_results(target, item)
    if $imported["YEA-LunaticObjects"]
      lunatic_object_effect(:during, item, @subject, target)
    end
    @status_window.refresh if !$game_switches[Galv_Favour::DISABLE_SWITCH]
    perform_collapse_check(target)
  end
end

  def set_initial_favour
    $game_party.p_special = 0
    $game_party.e_special = 0
    min = Galv_Favour::INITIAL_PARTY_FAVOUR[0]
    max = Galv_Favour::INITIAL_PARTY_FAVOUR[1]
    $game_party.favour = rand(max - min) + min
    min = Galv_Favour::INITIAL_ENEMY_FAVOUR[0]
    max = Galv_Favour::INITIAL_ENEMY_FAVOUR[1]
    $game_party.enemy_favour = rand(max - min) + min
    if $game_switches[Galv_Favour::DISABLE_SWITCH]
      $game_party.favour = 0
      $game_party.enemy_favour = 0
    end
  end
   
  def clear_favour
    $game_party.favour = 0
    $game_party.enemy_favour = 0
  end
   
end # Scene_Battle < Scene_Base


class Game_Party < Game_Unit
  attr_accessor :favour
  attr_accessor :enemy_favour
  attr_accessor :p_special
  attr_accessor :e_special
   
  alias galv_favour_initialize initialize
  def initialize
    galv_favour_initialize
    @favour = 0
    @enemy_favour = 0
    @p_special = 0
    @e_special = 0
  end
end # Game_Party < Game_Unit


class Game_BattlerBase

  def apply_state
    # get hash with KEYS: favour required and VALUES: state ids
    @list = Galv_Favour::FAVOUR_STATES
     
    # get state_id required:
    @get_state = (@list.select {|k,v| k <= $game_party.favour}).max[1]

    # add state_id required. Remove all other state_id's in list
    Galv_Favour::FAVOUR_STATES.each {|key, value|
      $game_party.alive_members.each do |mem|
         
        if value == @get_state
          if !mem.state?(@get_state) && value != 0
            mem.add_favour_state(@get_state)
          end
        else
          mem.remove_state(value)
        end
      end  
    }
  end
   
  def apply_enemy_state
    # get hash with KEYS: favour required and VALUES: state ids
    @enemy_list = Galv_Favour::ENEMY_FAVOUR_STATES
     
    # get state_id required:
    @get_enemy_state = (@enemy_list.select {|k,v| k <= $game_party.enemy_favour}).max[1]

    # add state_id required. Remove all other state_id's in list
    Galv_Favour::ENEMY_FAVOUR_STATES.each {|key, value|
      $game_troop.alive_members.each do |enemy|
         
        if value == @get_enemy_state
          if !enemy.state?(@get_enemy_state) && value != 0
            enemy.add_favour_state(@get_enemy_state)
          end
        else
          enemy.remove_state(value)
        end
      end  
    }
  end
   
  def check_favour
    return if $game_switches[Galv_Favour::DISABLE_SWITCH]
    if $game_party.favour >= Galv_Favour::FAVOUR_MAX
      $game_party.favour = Galv_Favour::FAVOUR_MAX
      if $game_party.p_special == 0 && $game_party.favour == Galv_Favour::FAVOUR_MAX
        RPG::SE.new(Galv_Favour::PARTY_ACTIVATE_SE[0], Galv_Favour::PARTY_ACTIVATE_SE[1], Galv_Favour::PARTY_ACTIVATE_SE[2]).play
        $game_party.p_special = Galv_Favour::SPECIAL_TURNS
        $game_temp.reserve_common_event(Galv_Favour::SPECIAL_ACTIVATE)
      end
    elsif $game_party.favour <= 0
      $game_party.favour = 0
      $game_party.p_special = 0
    end
     
    if $game_party.enemy_favour >= Galv_Favour::FAVOUR_MAX
      $game_party.enemy_favour = Galv_Favour::FAVOUR_MAX
      if $game_party.e_special == 0 && $game_party.enemy_favour == Galv_Favour::FAVOUR_MAX
        RPG::SE.new(Galv_Favour::ENEMY_ACTIVATE_SE[0], Galv_Favour::ENEMY_ACTIVATE_SE[1], Galv_Favour::ENEMY_ACTIVATE_SE[2]).play
        $game_party.e_special = Galv_Favour::SPECIAL_TURNS
        $game_temp.reserve_common_event(Galv_Favour::ENEMY_SPECIAL_ACTIVATE)
      end
    elsif $game_party.enemy_favour <= 0
      $game_party.enemy_favour = 0
      $game_party.e_special = 0
    end
  end
end # Game_BattlerBase


class Game_Battler < Game_BattlerBase
  include Galv_Favour_Mechanics
   
  alias galv_favour_execute_damage execute_damage
  def execute_damage(user)
    $game_temp.user = user
    galv_favour_execute_damage(user)
  end
   
  alias galv_favour_on_damage on_damage
  def on_damage(value)
    galv_favour_on_damage(value)
    return if $game_switches[Galv_Favour::DISABLE_SWITCH]
    if $game_temp.user.actor?
      # When enemy is damaged
      if $game_party.e_special > 0
        charge = charge_favour(value)
        $game_party.favour += charge / 2
      else
        charge = charge_favour(value)
        $game_party.favour += charge
        $game_party.enemy_favour -= (charge * Galv_Favour::REDUCE_OPPONENT).to_i
      end
    else
      # When party is damaged
      if $game_party.p_special > 0
        charge = charge_enemy_favour(value)
        $game_party.enemy_favour += charge / 2
      else
        charge = charge_enemy_favour(value)
        $game_party.enemy_favour += charge
        $game_party.favour -= (charge * Galv_Favour::REDUCE_OPPONENT).to_i
      end
    end
    check_favour
    apply_state
    apply_enemy_state
  end
   
  def add_favour_state(state_id)
    add_new_state(state_id) unless state?(state_id)
    reset_state_counts(state_id)
    @result.added_states.push(state_id).uniq!
  end
   
  alias galv_favour_use_item use_item
  def use_item(item)
    $game_temp.skill_used = item
    galv_favour_use_item(item)
    change_party_favour if $game_temp.skill_used.mod_pfavour != 0
    change_enemy_favour if $game_temp.skill_used.mod_efavour != 0
    apply_state
    apply_enemy_state
    check_favour
  end
   
  def change_party_favour
    case $game_temp.skill_used.mod_pfavour
    when 1
      $game_party.favour += $game_temp.skill_used.do_pfavour
    when 2
      $game_party.favour *= $game_temp.skill_used.do_pfavour
    when 3
      $game_party.favour = $game_temp.skill_used.do_pfavour
    end
  end
   
  def change_enemy_favour
    case $game_temp.skill_used.mod_efavour
    when 1
      $game_party.enemy_favour += $game_temp.skill_used.do_efavour
    when 2
      $game_party.enemy_favour *= $game_temp.skill_used.do_efavour
    when 3
      $game_party.enemy_favour = $game_temp.skill_used.do_efavour
    end
  end
   
end # Game_Battler < Game_BattlerBase


class Game_Enemy < Game_Battler
  attr_accessor :favour
   
  alias galv_favour_enemy_initialize initialize
  def initialize(index, enemy_id)
    galv_favour_enemy_initialize(index, enemy_id)
    @favour = $data_enemies[enemy_id].favour_bonus
  end

end # Game_Enemy < Game_Battler


class Game_Actor < Game_Battler
  attr_accessor :favour
   
  alias galv_favour_actor_initialize initialize
  def initialize(actor_id)
    galv_favour_actor_initialize(actor_id)
    @favour = $data_actors[actor_id].favour_bonus
  end

end # Game_Actor < Game_Battler


class Game_Temp
  attr_accessor :user
  attr_accessor :skill_used
end # Game_Temp


module BattleManager
   
  class << self
    alias galv_favour_bm_turn_end turn_end
     
    def turn_end
      galv_favour_bm_turn_end
      return if $game_switches[Galv_Favour::DISABLE_SWITCH]
      if $game_party.p_special >= 0 && $game_party.favour == Galv_Favour::FAVOUR_MAX
        $game_party.p_special -= 1
        if $game_party.p_special == 0
          $game_party.favour = 0
          rem_party_state
        end
      end
      
      if $game_party.e_special >= 0 && $game_party.enemy_favour == Galv_Favour::FAVOUR_MAX
        $game_party.e_special -= 1
        if $game_party.e_special == 0
          $game_party.enemy_favour = 0
          rem_enemy_state
        end
      end
    end
      
    def rem_party_state
      @list = Galv_Favour::FAVOUR_STATES

      Galv_Favour::FAVOUR_STATES.each {|key, value|
        $game_party.alive_members.each do |mem|
          mem.remove_state(value)
        end  
      }
    end
   
    def rem_enemy_state
      @enemy_list = Galv_Favour::ENEMY_FAVOUR_STATES

      Galv_Favour::ENEMY_FAVOUR_STATES.each {|key, value|
        $game_troop.alive_members.each do |enemy|
          enemy.remove_state(value)
        end  
      }
    end
  end
   
end # BattleManager[/pre]

状态蓝盾
[pre lang="ruby"]# Manashield
# This will make a manashield state which allow actor takes damage to mana
# instead of health points.
# Usage: use this notetag inside a state <manashield: X, Y%>
# X is damage absorb per mana point.
# Y is damage percentage which can be absorbed.
# Free for all using purposes.
# Credit: Archeia Nessiah for the allowance.

module REGEXP
  module MANASHIELD
    MANASHIELD = /<manashield:[ ]*(\d+),[ ]*(\d+)[%“]?>/i
  end # MANASHIELD
end # REGEXP

#==============================================================================
# ¡ DataManager
#==============================================================================

module DataManager
   
  #--------------------------------------------------------------------------
  # alias method: load_database
  #--------------------------------------------------------------------------
  class <<self; alias load_database_manashield load_database; end
  def self.load_database
    load_database_manashield
    initialize_manashield
  end
  
  #--------------------------------------------------------------------------
  # new method: initialize_manashield
  #--------------------------------------------------------------------------
  def self.initialize_manashield
    groups = [$data_states]
    groups.each { |group|
      group.each { |obj|
        next if obj.nil?
        obj.initialize_manashield
      }
    }
  end
  
end # DataManager

#==============================================================================
# ¡ RPG::BaseItem
#==============================================================================

class RPG::BaseItem
  
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_accessor :manashield

  #--------------------------------------------------------------------------
  # new method: initialize_manashield
  #--------------------------------------------------------------------------
  def initialize_manashield
    #---
    self.note.split(/[\r\n]+/).each { |line|
      case line
      when REGEXP::MANASHIELD::MANASHIELD
        @manashield = [$1.to_i, [$2.to_i, 100].min]
      end
    }
  end
  
end # RPG::BaseItem

#==============================================================================
# ¡ Game_ActionResult
#==============================================================================

class Game_ActionResult
  
  #--------------------------------------------------------------------------
  # alias method: make_damage
  #--------------------------------------------------------------------------
  alias manashield_make_damage make_damage
  def make_damage(value, item)
    manashield_make_damage(value, item)
    #---
    if @battler.manashield && @battler.mp > 0
      dpm = @battler.manashield[0]
      percent = @battler.manashield[1]
      shield = (@hp_damage * percent.to_f) / 100.0
      shield = shield / dpm.to_f
      shield = [shield, @battler.mp.to_f].min
      @hp_damage -= (shield * dpm.to_f).to_i
      @mp_damage += shield.to_i
    end
  end
  
end # Game_ActionResult

#==============================================================================
# ¡ Game_Battler
#==============================================================================

class Game_Battler < Game_BattlerBase
  
  #--------------------------------------------------------------------------
  # new method: manashield
  #--------------------------------------------------------------------------
  def manashield
    mns = nil
    states.each { |state|
      next unless state.manashield
      mns = state.manashield
      break
    }
    return mns ? mns : false
  end
  
end # Game_Battler[/pre]

充能的技能(比那位tarxod大大那个延迟好用,因为T大大每回合都能动,但是到了释放时刻,没达到要求就不放了)
[pre lang="ruby"]#==============================================================================
#
# ¥ Yami Engine Ace - Charge Skill
# -- Last Updated: 2012.05.13
# -- Level: Easy
# -- Requires: none
#
#==============================================================================

$imported = {} if $imported.nil?
$imported["YSE-ChargeSkill"] = true

#==============================================================================
# ¥ Updates
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# 2012.05.13 - Fixed Enemy Charging.
# 2012.03.30 - Fixed Skill Targets.
# 2012.03.29 - Fixed Auto Battle bug.
# 2012.03.27 - Fixed Cancel Charge bug.
# 2012.03.26 - Fixed Battle End bug.
# 2012.03.18 - Started and Finished Script.
#
#==============================================================================
# ¥ Introduction
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# This script provides charging skill feature. Charging Skill means that skill
# will be used after some turn it was choosen.
#
#==============================================================================
# ¥ Instructions
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# To install this script, open up your script editor and copy/paste this script
# to an open slot below ¥ Materials/‘fÞ but above ¥ Main. Remember to save.
#
# -----------------------------------------------------------------------------
# Skill/Item Notetags - These notetags go in the skill/item notebox in the database.
# -----------------------------------------------------------------------------
# <charge turn: x>
# Make skill be a charge skill with x charging turns.
# -----------------------------------------------------------------------------
# <start charge message>
# example
# </start charge message>
#
# Set the Charging Start Message to example.
# -----------------------------------------------------------------------------
# <continue charge message>
# example
# </continue charge message>
#
# Set the Charging Continue Message to example.
#
#==============================================================================
# ¥ Compatibility
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# This script is made strictly for RPG Maker VX Ace. It is highly unlikely that
# it will run with RPG Maker VX without adjusting.
#
#==============================================================================

module YSE
  module CHARGE_SKILL
   
    #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    # - Visual Settings -
    #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    VISUAL_SETTING = { # Start.
      # Message shows when choose a charge skill.
      # Set this to nil to disable.
      :default_msg_start      =>  "%s 开始充能 %s!",
      # Message shows when end a charging turn.
      # Set this to nil to disable.
      :default_msg_continue   =>  "%s 还在充能 %s...",
    } # End.
   
  end # CHARGE_SKILL
end # YSE

#==============================================================================
# ¥ Editting anything past this point may potentially result in causing
# computer damage, incontinence, explosion of user's head, coma, death, and/or
# halitosis so edit at your own risk.
#==============================================================================

#==============================================================================
# ¡ Regular Expression
#==============================================================================

module YSE
  module REGEXP
  module USABLEITEM
   
    CHARGE_TURN = /<(?:CHARGE_TURN|charge turn):[ ](\d+)?>/i
    START_MSG_BEGIN = /<(?:START_CHARGE_MESSAGE|start charge message)>/i
    START_MSG_END = /<\/(?:START_CHARGE_MESSAGE|start charge message)>/i
    CONT_MSG_BEGIN = /<(?:CONTINUE_CHARGE_MESSAGE|continue charge message)>/i
    CONT_MSG_END = /<\/(?:CONTINUE_CHARGE_MESSAGE|continue charge message)>/i
   
  end # STATE
  end # REGEXP
end # YSE

#==============================================================================
# ¡ DataManager
#==============================================================================

module DataManager
  
  #--------------------------------------------------------------------------
  # alias method: load_database
  #--------------------------------------------------------------------------
  class <<self; alias load_database_ysecs load_database; end
  def self.load_database
    load_database_ysecs
    load_notetags_ysecs
  end
  
  #--------------------------------------------------------------------------
  # new method: load_notetags_ysecs
  #--------------------------------------------------------------------------
  def self.load_notetags_ysecs
    groups = [$data_skills, $data_items]
    for group in groups
      for obj in group
        next if obj.nil?
        obj.load_notetags_ysecs
      end
    end
  end
  
end # DataManager

#==============================================================================
# ¡ RPG::UsableItem
#==============================================================================

class RPG::UsableItem < RPG::BaseItem
  
  #--------------------------------------------------------------------------
  # public instance variables
  #--------------------------------------------------------------------------
  attr_accessor :charge_turn
  attr_accessor :start_msg
  attr_accessor :continue_msg
  
  #--------------------------------------------------------------------------
  # common cache: load_notetags_ysecs
  #--------------------------------------------------------------------------
  def load_notetags_ysecs
    @start_begin = false
    @continue_begin = false
    @charge_turn = 0
    #---
    self.note.split(/[\r\n]+/).each { |line|
      case line
      #---
      when YSE::REGEXP::USABLEITEM::CHARGE_TURN
        @charge_turn = $1.to_i
      when YSE::REGEXP::USABLEITEM::START_MSG_BEGIN
        @start_begin = true
      when YSE::REGEXP::USABLEITEM::START_MSG_END
        @start_begin = false
      when YSE::REGEXP::USABLEITEM::CONT_MSG_BEGIN
        @continue_begin = true
      when YSE::REGEXP::USABLEITEM::CONT_MSG_END
        @continue_begin = false
      else
        @start_msg = line.to_s if @start_msg.nil? && @start_begin
        @start_msg += line.to_s if @start_begin
        @continue_msg = line.to_s if @continue_msg.nil? && @continue_begin
        @continue_msg += line.to_s if @continue_begin
      end
    } # self.note.split
    #---
    @charge_turn = nil if @charge_turn <= 0
    @start_msg = YSE::CHARGE_SKILL::VISUAL_SETTING[:default_msg_start]
    @continue_msg = YSE::CHARGE_SKILL::VISUAL_SETTING[:default_msg_continue]
    @start_msg = nil if @start_msg == ""
    @continue_msg = nil if @continue_msg == ""
  end
  
end # RPG::UsableItem

#==============================================================================
# ¡ Game_Battler
#==============================================================================

class Game_Battler < Game_BattlerBase
  
  #--------------------------------------------------------------------------
  # public instance variables
  #--------------------------------------------------------------------------
  attr_accessor :charged
  attr_accessor :first_charge

  #--------------------------------------------------------------------------
  # alias method: auto_battle?
  #--------------------------------------------------------------------------
  alias yse_auto_battle_cs auto_battle?
  def auto_battle?
    charging? ? false : yse_auto_battle_cs
  end
  
  #--------------------------------------------------------------------------
  # new method: charging?
  #--------------------------------------------------------------------------
  def charging?
    !@charging_cache.nil? || @charged
  end
  
  #--------------------------------------------------------------------------
  # new method: start_charge
  #--------------------------------------------------------------------------
  def start_charge
    return false if charging?
    return false if current_action.item.charge_turn.nil?
    @charging_cache = current_action.clone
    @charge_turn = current_action.item.charge_turn
    return true
  end
  
  #--------------------------------------------------------------------------
  # new method: current_charging
  #--------------------------------------------------------------------------
  def current_charging
    @charging_cache
  end
  
  #--------------------------------------------------------------------------
  # new method: end_charge
  #--------------------------------------------------------------------------
  def end_charge
    @actions.push(@charging_cache)
    @charging_cache = nil
    @charge_turn = nil
    @charged = true
    return true
  end
  
  #--------------------------------------------------------------------------
  # new method: cancel_charge
  #--------------------------------------------------------------------------
  def cancel_charge
    clear_actions
    @charging_cache = nil
    @charge_turn = nil
    @charged = false
  end
  
  #--------------------------------------------------------------------------
  # new method: update_charge_skill
  #--------------------------------------------------------------------------
  def update_charge_skill
    @charge_turn -= 1
    return end_charge if @charge_turn == 0
    return false
  end
  
  #--------------------------------------------------------------------------
  # alias method: on_battle_end
  #--------------------------------------------------------------------------
  alias yse_on_battle_end_cs on_battle_end
  def on_battle_end
    cancel_charge
    yse_on_battle_end_cs
  end

end # Game_Battler

#==============================================================================
# ¡ Game_Actor
#==============================================================================

class Game_Actor < Game_Battler
  
  #--------------------------------------------------------------------------
  # alias method: inputable?
  #--------------------------------------------------------------------------
  alias yse_inputable_cs inputable?
  def inputable?
    yse_inputable_cs && !charging?
  end
  
end # Game_Actor

#==============================================================================
# ¡ Game_Enemy
#==============================================================================

class Game_Enemy < Game_Battler
  
  #--------------------------------------------------------------------------
  # alias method: make_actions
  #--------------------------------------------------------------------------
  alias yse_make_actions_cs make_actions
  def make_actions
    return super if charging?
    yse_make_actions_cs
  end
  
end # Game_Enemy

#==============================================================================
# ¡ Scene_Battle
#==============================================================================

class Scene_Battle < Scene_Base
  
  #--------------------------------------------------------------------------
  # alias method: execute_action
  #--------------------------------------------------------------------------
  alias yse_execute_action_bacs execute_action
  def execute_action
    return start_charge if @subject.start_charge
    yse_execute_action_bacs
  end
   
  #--------------------------------------------------------------------------
  # alias method: process_action_end
  #--------------------------------------------------------------------------
  alias yse_process_action_end_bacs process_action_end
  def process_action_end
    process_charge_skill
    yse_process_action_end_bacs
  end
  
  #--------------------------------------------------------------------------
  # new method: start_charge
  #--------------------------------------------------------------------------
  def start_charge
    @subject.first_charge = true
    return if @subject.current_action.item.start_msg.nil?
    str = @subject.current_action.item.start_msg
    skill = @subject.current_action.item
    skill_text = sprintf("\\i[%d]%s", skill.icon_index, skill.name)
    text = sprintf(str, @subject.name, skill_text)
    @log_window.add_text(text)
    3.times do @log_window.wait end
    @log_window.back_one
  end

  #--------------------------------------------------------------------------
  # new method: process_charge_skill
  #--------------------------------------------------------------------------
  def process_charge_skill
    return @subject.first_charge = false if @subject.first_charge
    return unless @subject.charging?
    return unless check_charge_turn
    process_action_charge
  end

  #--------------------------------------------------------------------------
  # new method: check_charge_turn
  #--------------------------------------------------------------------------
  def check_charge_turn
    continue = @subject.update_charge_skill
    if continue
      return true
    else
      return false if @subject.current_charging.item.continue_msg.nil?
      str = @subject.current_charging.item.continue_msg
      skill = @subject.current_charging.item
      skill_text = sprintf("\\i[%d]%s", skill.icon_index, skill.name)
      text = sprintf(str, @subject.name, skill_text)
      @log_window.add_text(text)
      3.times do @log_window.wait end
      @log_window.back_one
    end
    return false
  end
  
  #--------------------------------------------------------------------------
  # new method: process_action_charge
  #--------------------------------------------------------------------------
  def process_action_charge
    loop do
      break if $game_troop.all_dead?
      break unless @subject.current_action
      @subject.current_action.prepare
      execute_action if @subject.current_action.valid?
      @subject.remove_current_action
    end
    @subject.charged = false
  end
  
end # Scene_Battle

#==============================================================================
#
# ¥ End of File
#
#==============================================================================[/pre]

环境脚本
[pre lang="ruby"]#==============================================================================
#
# ▼ Yanfly Engine Ace - Field State Effects v1.00
# -- Last Updated: 2012.01.11
# -- Level: Normal
# -- Requires: n/a
#
#==============================================================================

$imported = {} if $imported.nil?
$imported["YEA-FieldStateEffects"] = true

#==============================================================================
# ▼ Updates
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# 2012.01.11 - Started Script and Finished.
#
#==============================================================================
# ▼ Introduction
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# Field States are states that are applied to all actors and enemies without
# discrimination. Field states cannot be removed through usual means and can
# only be applied through certain skills and items. Multiple field states can
# be added at once whether side by side or overwriting any previous field
# states. Skills and items can also alter the turns of existing field states.
#
#==============================================================================
# ▼ Instructions
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# To install this script, open up your script editor and copy/paste this script
# to an open slot below ▼ Materials/素材 but above ▼ Main. Remember to save.
#
# -----------------------------------------------------------------------------
# Skill Notetags - These notetags go in the skill notebox in the database.
# -----------------------------------------------------------------------------
# <add field state: x>
# <add field state: x, x>
# Causes the action to add state x to the field, making it apply to everyone
# and cannot be removed through normal state removal means. Insert multiples of
# this tag to have the action cause multiple field states.
#
# <remove field state: x>
# <remove field state: x, x>
# Causes the action to remove state x from the field. This does not remove
# states that were inflicted normally. Insert multiples of this tag to remove
# multiple field states.
#
# <remove all field states>
# Causes the action to remove all field states. This does not remove states
# that were inflicted normally.
#
# <overwrite field state: x>
# <overwrite field state: x, x>
# Causes the action to remove all field states and then add field states x,
# making it apply to everyone and cannot be removed through normal state
# removal means. Insert multiples of this tag to have the action overwrite and
# add more field states.
#
# <field state x turns: +y>
# <field state x turns: -y>
# Changes the remaining turns on field state x by y amount. If a field state
# is to reach 0 or less turns through this process, the field state is removed.
# This effect does not add turns to field states that weren't inflicted. Insert
# multiples of this tag to adjust multiple field states at once.
#
# <all field state turns: +x>
# <all field state turns: -x>
# Changes the remaining turns on all field states by x amount. If a field state
# is to reach 0 or less turns through this process, the field state is removed.
#
# -----------------------------------------------------------------------------
# Item Notetags - These notetags go in the items notebox in the database.
# -----------------------------------------------------------------------------
# <add field state: x>
# <add field state: x, x>
# Causes the action to add state x to the field, making it apply to everyone
# and cannot be removed through normal state removal means. Insert multiples of
# this tag to have the action cause multiple field states.
#
# <remove field state: x>
# <remove field state: x, x>
# Causes the action to remove state x from the field. This does not remove
# states that were inflicted normally. Insert multiples of this tag to remove
# multiple field states.
#
# <remove all field states>
# Causes the action to remove all field states. This does not remove states
# that were inflicted normally.
#
# <overwrite field state: x>
# <overwrite field state: x, x>
# Causes the action to remove all field states and then add field states x,
# making it apply to everyone and cannot be removed through normal state
# removal means. Insert multiples of this tag to have the action overwrite and
# add more field states.
#
# <field state x turns: +y>
# <field state x turns: -y>
# Changes the remaining turns on field state x by y amount. If a field state
# is to reach 0 or less turns through this process, the field state is removed.
# This effect does not add turns to field states that weren't inflicted. Insert
# multiples of this tag to adjust multiple field states at once.
#
# <all field state turns: +x>
# <all field state turns: -x>
# Changes the remaining turns on all field states by x amount. If a field state
# is to reach 0 or less turns through this process, the field state is removed.
#
# -----------------------------------------------------------------------------
# State Notetags - These notetags go in the states notebox in the database.
# -----------------------------------------------------------------------------
# <field back 1: string>
# <field back 2: string>
# If this state is being used as a field state and this state is the state with
# the highest priority, these notetags will determine the battlebacks used
# while the field state is in effect. If this notetag is not used, there will
# be no changes to the battleback.
#
#==============================================================================
# ▼ Compatibility
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# This script is made strictly for RPG Maker VX Ace. It is highly unlikely that
# it will run with RPG Maker VX without adjusting.
#
#==============================================================================

module YEA
  module FIELD_STATES
   
    #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    # - Visual Settings -
    #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    # This setting causes a wave effect to play whenever the battlebacks change
    # due to field state effects.
    #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    WAVE_EFFECT = true  # Plays a wave effect when the battleback changes.
   
  end # FIELD_STATES
end # YEA

#==============================================================================
# ▼ Editting anything past this point may potentially result in causing
# computer damage, incontinence, explosion of user's head, coma, death, and/or
# halitosis so edit at your own risk.
#==============================================================================

module YEA
  module REGEXP
  module USABLEITEM
   
    ADD_FIELD_STATE =
      /<(?:ADD_FIELD_STATE|add field state):[ ](\d+(?:\s*,\s*\d+)*)>/i
    REMOVE_FIELD_STATE =
      /<(?:REMOVE_FIELD_STATE|remove field state):[ ](\d+(?:\s*,\s*\d+)*)>/i
    REMOVE_ALL_FIELD_STATES =
      /<(?:REMOVE_ALL_FIELD_STATES|remove all field states)>/i
    OVERWRITE_FIELD_STATE =
    /<(?:OVERWRITE_FIELD_STATE|OVERWRITE field state):[ ](\d+(?:\s*,\s*\d+)*)>/i
    CHANGE_FIELD_STATE_TURN =
      /<(?:FIELD state)[ ](\d+)[ ](?:TURN|turns):[ ]([\+\-]\d+)>/i
    CHANGE_ALL_FIELD_STATE_TURN =
      /<(?:ALL_FIELD_STATE_TURNS|all field state turns):[ ]([\+\-]\d+)>/i
   
  end # USABLEITEM
  module STATE
   
    FIELD_BATTLEBACK1 = /<(?:FIELD_BACK1|field back1|field back 1):[ ](.*)>/i
    FIELD_BATTLEBACK2 = /<(?:FIELD_BACK2|field back2|field back 2):[ ](.*)>/i
   
  end # STATE
  end # REGEXP
end # YEA

#==============================================================================
# ■ DataManager
#==============================================================================

module DataManager
  
  #--------------------------------------------------------------------------
  # alias method: load_database
  #--------------------------------------------------------------------------
  class <<self; alias load_database_fse load_database; end
  def self.load_database
    load_database_fse
    load_notetags_fse
  end
  
  #--------------------------------------------------------------------------
  # new method: load_notetags_fse
  #--------------------------------------------------------------------------
  def self.load_notetags_fse
    groups = [$data_skills, $data_items, $data_states]
    for group in groups
      for obj in group
        next if obj.nil?
        obj.load_notetags_fse
      end
    end
  end
  
end # DataManager

#==============================================================================
# ■ RPG::UsableItem
#==============================================================================

class RPG::UsableItem < RPG::BaseItem
  
  #--------------------------------------------------------------------------
  # public instance variables
  #--------------------------------------------------------------------------
  attr_accessor :add_field_state
  attr_accessor :remove_field_state
  attr_accessor :remove_all_field_states
  attr_accessor :change_field_state_turns
  
  #--------------------------------------------------------------------------
  # common cache: load_notetags_fse
  #--------------------------------------------------------------------------
  def load_notetags_fse
    @add_field_state = []
    @remove_field_state = []
    @remove_all_field_states = false
    @change_field_state_turns = {}
    #---
    self.note.split(/[\r\n]+/).each { |line|
      case line
      #---
      when YEA::REGEXP::USABLEITEM::ADD_FIELD_STATE
        $1.scan(/\d+/).each { |num|
        @add_field_state.push(num.to_i) if num.to_i > 0 }
      when YEA::REGEXP::USABLEITEM::REMOVE_FIELD_STATE
        $1.scan(/\d+/).each { |num|
        @remove_field_state.push(num.to_i) if num.to_i > 0 }
      when YEA::REGEXP::USABLEITEM::REMOVE_ALL_FIELD_STATES
        @remove_all_field_states = true
      when YEA::REGEXP::USABLEITEM::OVERWRITE_FIELD_STATE
        @remove_all_field_states = true
        $1.scan(/\d+/).each { |num|
        @add_field_state.push(num.to_i) if num.to_i > 0 }
      when YEA::REGEXP::USABLEITEM::CHANGE_FIELD_STATE_TURN
        @change_field_state_turns[$1.to_i] = $2.to_i
      when YEA::REGEXP::USABLEITEM::CHANGE_ALL_FIELD_STATE_TURN
        for i in 1...$data_states.size
          @change_field_state_turns = $1.to_i
        end
      end
    } # self.note.split
    #---
  end
  
end # class RPG::UsableItem

#==============================================================================
# ■ RPG::State
#==============================================================================

class RPG::State < RPG::BaseItem
  
  #--------------------------------------------------------------------------
  # public instance variables
  #--------------------------------------------------------------------------
  attr_accessor :field_battlebacks
  
  #--------------------------------------------------------------------------
  # common cache: load_notetags_fse
  #--------------------------------------------------------------------------
  def load_notetags_fse
    @field_battlebacks = ["", ""]
    #---
    self.note.split(/[\r\n]+/).each { |line|
      case line
      #---
      when YEA::REGEXP::STATE::FIELD_BATTLEBACK1
        @field_battlebacks[0] = $1.to_s
      when YEA::REGEXP::STATE::FIELD_BATTLEBACK2
        @field_battlebacks[1] = $1.to_s
      end
    } # self.note.split
    #---
  end
  
end # RPG::State

#==============================================================================
# ■ BattleManager
#==============================================================================

module BattleManager
  
  #--------------------------------------------------------------------------
  # alias method: init_members
  #--------------------------------------------------------------------------
  class <<self; alias battlemanager_init_members_fse init_members; end
  def self.init_members
    battlemanager_init_members_fse
    clear_field_states
  end
  
  #--------------------------------------------------------------------------
  # new method: field_states
  #--------------------------------------------------------------------------
  def self.field_states
    return @field_states.collect {|id| $data_states[id] }
  end
  
  #--------------------------------------------------------------------------
  # new method: field_state_turns
  #--------------------------------------------------------------------------
  def self.field_state_turns(state_id)
    return @field_state_turns[state_id]
  end
  
  #--------------------------------------------------------------------------
  # new method: field_state?
  #--------------------------------------------------------------------------
  def self.field_state?(state_id)
    return @field_states.include?(state_id)
  end
  
  #--------------------------------------------------------------------------
  # new method: sort_field_states
  #--------------------------------------------------------------------------
  def self.sort_field_states
    @field_states = @field_states.sort_by { |id|
      [-$data_states[id].priority, id] }
    set_field_battlebacks
    set_field_state_icons
  end
  
  #--------------------------------------------------------------------------
  # new method: clear_field_states
  #--------------------------------------------------------------------------
  def self.clear_field_states
    @field_states = []
    @field_state_turns = {}
    @field_state_battleback = ["", ""]
    @field_state_icons = []
  end
  
  #--------------------------------------------------------------------------
  # new method: add_field_state
  #--------------------------------------------------------------------------
  def self.add_field_state(state_id)
    return if $data_states[state_id].nil?
    return if @field_states.include?(state_id)
    @field_states.push(state_id)
    state = $data_states[state_id]
    variance = 1 + [state.max_turns - state.min_turns, 0].max
    @field_state_turns[state_id] = state.min_turns + rand(variance)
    sort_field_states
  end
  
  #--------------------------------------------------------------------------
  # new method: remove_field_state
  #--------------------------------------------------------------------------
  def self.remove_field_state(state_id)
    return if $data_states[state_id].nil?
    return unless @field_states.include?(state_id)
    @field_states.delete(state_id)
    @field_state_turns.delete(state_id)
    sort_field_states
  end
  
  #--------------------------------------------------------------------------
  # new method: change_field_state_turns
  #--------------------------------------------------------------------------
  def self.change_field_state_turns(state_id, value)
    return unless field_state?(state_id)
    state_id = state_id.id if state_id.is_a?(RPG::State)
    return if $data_states[state_id].auto_removal_timing <= 0
    @field_state_turns[state_id] = 0 if @field_state_turns[state_id].nil?
    @field_state_turns[state_id] = [value, 0].max
    remove_field_state(state_id) if @field_state_turns[state_id] <= 0
  end
  
  #--------------------------------------------------------------------------
  # alias method: turn_end
  #--------------------------------------------------------------------------
  class <<self; alias battlemanager_turn_end_fse turn_end; end
  def self.turn_end
    battlemanager_turn_end_fse
    update_field_states
    remove_field_states_auto
  end
  
  #--------------------------------------------------------------------------
  # new method: update_field_states
  #--------------------------------------------------------------------------
  def self.update_field_states
    for state_id in @field_states
      next unless @field_state_turns[state_id] > 0
      @field_state_turns[state_id] -= 1
    end
  end
  
  #--------------------------------------------------------------------------
  # new method: remove_field_states_auto
  #--------------------------------------------------------------------------
  def self.remove_field_states_auto
    for state_id in @field_states
      next if $data_states[state_id].auto_removal_timing <= 0
      remove_field_state(state_id) if @field_state_turns[state_id] <= 0
    end
  end
  
  #--------------------------------------------------------------------------
  # new method: field_battlebacks
  #--------------------------------------------------------------------------
  def self.field_battlebacks
    return @field_state_battleback
  end
  
  #--------------------------------------------------------------------------
  # new method: set_field_battlebacks
  #--------------------------------------------------------------------------
  def self.set_field_battlebacks
    @field_state_battleback = ["", ""]
    for state in field_states
      next if state.field_battlebacks == ["", ""]
      @field_state_battleback = state.field_battlebacks
      return
    end
  end
  
  #--------------------------------------------------------------------------
  # new method: field_state_icons
  #--------------------------------------------------------------------------
  def self.field_state_icons
    return @field_state_icons
  end
  
  #--------------------------------------------------------------------------
  # new method: set_field_state_icons
  #--------------------------------------------------------------------------
  def self.set_field_state_icons
    icons = field_states.collect {|state| state.icon_index }
    icons.delete(0)
    @field_state_icons = icons
  end
  
end # BattleManager

#==============================================================================
# ■ Game_BattlerBase
#==============================================================================

class Game_BattlerBase
  
  #--------------------------------------------------------------------------
  # public instance variables
  #--------------------------------------------------------------------------
  attr_accessor :anti_field_states
  
  #--------------------------------------------------------------------------
  # alias method: states
  #--------------------------------------------------------------------------
  alias game_battlerbase_states_fse states
  def states
    result = game_battlerbase_states_fse
    result |= field_states unless @anti_field_states
    return result
  end
  
  #--------------------------------------------------------------------------
  # new method: field_states
  #--------------------------------------------------------------------------
  def field_states
    return [] unless SceneManager.scene_is?(Scene_Battle)
    return BattleManager.field_states
  end
  
  #--------------------------------------------------------------------------
  # alias method: state?
  #--------------------------------------------------------------------------
  alias game_battlerbase_state_fse state?
  def state?(state_id)
    return true if field_states.include?($data_states[state_id])
    return game_battlerbase_state_fse(state_id)
  end
  
end # Game_BattlerBase

#==============================================================================
# ■ Game_Battler
#==============================================================================

class Game_Battler < Game_BattlerBase
  
  #--------------------------------------------------------------------------
  # alias method: item_apply
  #--------------------------------------------------------------------------
  alias game_battler_item_apply_fse item_apply
  def item_apply(user, item)
    game_battler_item_apply_fse(user, item)
    apply_field_state_effect(item)
  end
  
  #--------------------------------------------------------------------------
  # new method: apply_field_state_effect
  #--------------------------------------------------------------------------
  def apply_field_state_effect(item)
    return if item.nil?
    return unless $game_party.in_battle
    return unless SceneManager.scene_is?(Scene_Battle)
    return @result.success = true if item.add_field_state != []
    return @result.success = true if item.remove_field_state != []
    return @result.success = true if item.remove_all_field_states
    for key in item.change_field_state_turns
      return @result.success = true if BattleManager.field_state?(key[0])
    end
  end
  
  #--------------------------------------------------------------------------
  # alias method: on_restrict
  #--------------------------------------------------------------------------
  alias game_battler_on_restrict_fse on_restrict
  def on_restrict
    @anti_field_states = true
    game_battler_on_restrict_fse
    @anti_field_states = nil
  end
  
  #--------------------------------------------------------------------------
  # alias method: update_state_turns
  #--------------------------------------------------------------------------
  alias game_battler_update_state_turns_fse update_state_turns
  def update_state_turns
    @anti_field_states = true
    game_battler_update_state_turns_fse
    @anti_field_states = nil
  end
  
  #--------------------------------------------------------------------------
  # alias method: remove_battle_states
  #--------------------------------------------------------------------------
  alias game_battler_remove_battle_states_fse remove_battle_states
  def remove_battle_states
    @anti_field_states = true
    game_battler_remove_battle_states_fse
    @anti_field_states = nil
  end
  
  #--------------------------------------------------------------------------
  # alias method: remove_states_auto
  #--------------------------------------------------------------------------
  alias game_battler_remove_states_auto_fse remove_states_auto
  def remove_states_auto(timing)
    @anti_field_states = true
    game_battler_remove_states_auto_fse(timing)
    @anti_field_states = nil
  end
  
  #--------------------------------------------------------------------------
  # alias method: remove_states_by_damage
  #--------------------------------------------------------------------------
  alias game_battler_remove_states_by_damage_fse remove_states_by_damage
  def remove_states_by_damage
    @anti_field_states = true
    game_battler_remove_states_by_damage_fse
    @anti_field_states = nil
  end
  
end # Game_Battler

#==============================================================================
# ■ Spriteset_Battle
#==============================================================================

class Spriteset_Battle
  
  #--------------------------------------------------------------------------
  # alias method: create_viewports
  #--------------------------------------------------------------------------
  alias spriteset_battle_create_viewports_fse create_viewports
  def create_viewports
    spriteset_battle_create_viewports_fse
    create_field_state_effect
  end
  
  #--------------------------------------------------------------------------
  # new method: create_field_state_effect
  #--------------------------------------------------------------------------
  def create_field_state_effect
    @field_state_battleback = ["", ""]
    @field_state_effect_sprite1 = Sprite.new(@viewport1)
    @field_state_effect_sprite1.bitmap = Bitmap.new(640, 480)
    @field_state_effect_sprite1.opacity = 0
    @field_state_effect_sprite1.z = 3
    @field_state_effect_sprite2 = Sprite.new(@viewport1)
    @field_state_effect_sprite2.bitmap = Bitmap.new(640, 480)
    @field_state_effect_sprite2.opacity = 0
    @field_state_effect_sprite2.z = 4
  end
  
  #--------------------------------------------------------------------------
  # alias method: dispose
  #--------------------------------------------------------------------------
  alias spriteset_battle_dispose_fse dispose
  def dispose
    dispose_field_state_effect
    spriteset_battle_dispose_fse
  end
  
  #--------------------------------------------------------------------------
  # new method: dispose_field_state_effect
  #--------------------------------------------------------------------------
  def dispose_field_state_effect
    @field_state_effect_sprite1.bitmap.dispose
    @field_state_effect_sprite1.dispose
    @field_state_effect_sprite2.bitmap.dispose
    @field_state_effect_sprite2.dispose
  end
  
  #--------------------------------------------------------------------------
  # alias method: update
  #--------------------------------------------------------------------------
  alias spriteset_battle_update_fse update
  def update
    update_field_state_effect
    spriteset_battle_update_fse
  end
  
  #--------------------------------------------------------------------------
  # new method: update_field_state_effect
  #--------------------------------------------------------------------------
  def update_field_state_effect
    update_field_battleback_images
    update_field_battleback_opacity
    #---
    @field_state_effect_sprite1.update
    @field_state_effect_sprite2.update
  end
  
  #--------------------------------------------------------------------------
  # new method: update_field_battleback_images
  #--------------------------------------------------------------------------
  def update_field_battleback_images
    return if @field_state_battleback == BattleManager.field_battlebacks
    @field_state_battleback = BattleManager.field_battlebacks.clone
    change_field_battleback_images
  end
  
  #--------------------------------------------------------------------------
  # new method: change_field_battleback_images
  #--------------------------------------------------------------------------
  def change_field_battleback_images
    #---
    @field_state_effect_sprite1.bitmap.dispose
    @field_state_effect_sprite1.bitmap =  @back1_sprite.bitmap.clone
    @field_state_effect_sprite1.opacity = 255
    @field_state_effect_sprite1.wave_amp = 0
    center_sprite(@field_state_effect_sprite1)
    #---
    @field_state_effect_sprite2.bitmap.dispose
    @field_state_effect_sprite2.bitmap = @back2_sprite.bitmap.clone
    @field_state_effect_sprite2.opacity = 255
    @field_state_effect_sprite2.wave_amp = 0
    center_sprite(@field_state_effect_sprite2)
    #---
    if YEA::FIELD_STATES::WAVE_EFFECT
      @field_state_effect_sprite1.wave_amp = 16
      @field_state_effect_sprite2.wave_amp = 16
    end
    #---
    @back1_sprite.bitmap.dispose
    @back2_sprite.bitmap.dispose
    if BattleManager.field_battlebacks == ["", ""]
      bb1 = battleback1_bitmap
      bb2 = battleback2_bitmap
    else
      bb1 = Cache.battleback1(BattleManager.field_battlebacks[0])
      bb2 = Cache.battleback2(BattleManager.field_battlebacks[1])
    end
    @back1_sprite.bitmap = bb1
    @back2_sprite.bitmap = bb2
    center_sprite(@back1_sprite)
    center_sprite(@back2_sprite)
  end
  
  #--------------------------------------------------------------------------
  # new method: update_field_battleback_opacity
  #--------------------------------------------------------------------------
  def update_field_battleback_opacity
    return if @field_state_effect_sprite1.opacity <= 0
    @field_state_effect_sprite1.opacity -= 1
    @field_state_effect_sprite2.opacity -= 1
  end
  
end # Spriteset_Battle

#==============================================================================
# ■ Scene_Battle
#==============================================================================

class Scene_Battle < Scene_Base
  
  #--------------------------------------------------------------------------
  # alias method: use_item
  #--------------------------------------------------------------------------
  alias scene_battle_use_item_fse use_item
  def use_item
    item = @subject.current_action.item
    scene_battle_use_item_fse
    apply_field_state_effects(item)
  end
  
  #--------------------------------------------------------------------------
  # new method: apply_field_state_effects
  #--------------------------------------------------------------------------
  def apply_field_state_effects(item)
    return if item.nil?
    remove_all_field_state_effects(item)
    remove_field_state_effects(item)
    add_field_state_effects(item)
    change_field_state_turns(item)
    refresh_all_battlers
  end
  
  #--------------------------------------------------------------------------
  # new method: remove_all_field_state_effects
  #--------------------------------------------------------------------------
  def remove_all_field_state_effects(item)
    return unless item.remove_all_field_states
    BattleManager.clear_field_states
  end
  
  #--------------------------------------------------------------------------
  # new method: remove_field_state_effects
  #--------------------------------------------------------------------------
  def remove_field_state_effects(item)
    return if BattleManager.field_states == []
    return if item.remove_field_state == []
    for state_id in item.remove_field_state
      BattleManager.remove_field_state(state_id)
    end
  end
  
  #--------------------------------------------------------------------------
  # new method: add_field_state_effects
  #--------------------------------------------------------------------------
  def add_field_state_effects(item)
    return if item.add_field_state == []
    for state_id in item.add_field_state
      BattleManager.add_field_state(state_id)
    end
  end
  
  #--------------------------------------------------------------------------
  # new method: change_field_state_turns
  #--------------------------------------------------------------------------
  def change_field_state_turns(item)
    return if item.change_field_state_turns == {}
    for key in item.change_field_state_turns
      state_id = key[0]
      next unless BattleManager.field_state?(state_id)
      next unless $data_states[state_id].auto_removal_timing > 0
      turns = BattleManager.field_state_turns(state_id)
      BattleManager.change_field_state_turns(state_id, turns + key[1])
    end
  end
  
  #--------------------------------------------------------------------------
  # new method: change_field_state_turns
  #--------------------------------------------------------------------------
  def refresh_all_battlers
    all_battle_members.each { |battler| battler.refresh }
    @status_window.refresh
  end
  
end # Scene_Battle

#==============================================================================
#
# ▼ End of File
#
#==============================================================================[/pre]

结尾脚本
[pre lang="ruby"]#==============================================================================
# ■ VX-RGSS2-24 エンディング [Ver.1.0.0]        by Claimh
#------------------------------------------------------------------------------
#  エンディング(スタッフロール)の雛型です
#  あくまで雛形なので、自分で納得がいくように改造してください。
#   
#  表示順:製作者等表示 → ~Fin~表示
#           (→クリアデータをセーブ)→ タイトルor強制終了
#
#  画像パス:Graphics/Pictures
#------------------------------------------------------------------------------
#【呼び出し】
#  SceneManager.goto(Scene_Ending)
#==============================================================================

#==============================================================================
# □ カスタマイズ  ~START~
#==============================================================================
module Ending
  # エンディング後はタイトルに戻す(false:強制終了)
  BACKTO_TITLE = true

  # クリアデータセーブを行う?
  CLRED_SAVE = false
  # クリアデータ上でONにするスイッチ
  CLRED_SWITCH = 10

  # ボタン押下時にエンディングスキップ
  ON_SKIP = true

  # 画像表示位置
  #   0 : 画像いっぱい
  #   1 : 特定位置へ表示
  #   2 : 特定矩形へ表示
  G_TYPE = 1
  # 画像表示位置 [x, y] <G_TYPE=1>
  G_POS = [0, 0]
  # 画像表示矩形 <G_TYPE=2>
  G_RECT = Rect.new(10, 100, 200, 200)

  # シーン番号ごとの切り替え間隔(frame数)
  SC_WAIT = 60 * 3

  # シーン切り替え演出
  #  0 : 演出なし
  #  1 : トランジション(フェード)を挟む
  SC_EFFECT = 1

  # ~FIN~表示位置 [x, y]
  FIN_POS = [Graphics.width - 600, Graphics.height - 420]
  # ~FIN~時のウェイト(nil:ボタンが押されるまでウェイト)
  FIN_WAIT = 60 * 5
end

#==============================================================================
# ■ シーン制御設定
#==============================================================================
class Scene_Ending < Scene_Base
  include Ending
  #--------------------------------------------------------------------------
  # ● エンドミュージック
  #      n  : シーン番号
  #--------------------------------------------------------------------------
  def end_music(n=0)
    case n
    when 0  # 最初のBGM
      return RPG::BGM.new("Theme3")
    when -1 # Fin時のBGM
      return RPG::BGM.new("Scene5", 80, 80)
    end
    return nil
  end
  #--------------------------------------------------------------------------
  # ● エンド背景
  #      n      : シーン番号  (-1:Fin画像)
  #--------------------------------------------------------------------------
  def end_graphic(n=0)
    case n
    when 0  # 最初の画像
      return Cache.picture("Mountains5")
    when -1 # Fin画像
      return Cache.picture("Fin")
    when -2 # Fin画像2
      return Cache.picture("StarlitSky")
#~     when 3  # (例) 途中で画像をチェンジ
#~        return Cache.picture("Ocean1")
    end
    return nil
  end
  #--------------------------------------------------------------------------
  # ★ エンディングロール処理
  #      n      : シーン番号
  #--------------------------------------------------------------------------
  TEXTS = [
  # ["役割", "名前", "付属情報", …]
    ["作者",           "光明魔法灵"],
    ["特别合伙人",       "风"],
    ["开场音楽",               "GILIGI EYE",],
    ["游戏中音乐",         "默认的VA音乐"],
    ["出场人物",         "\\n[11]", "\\n[12]", "\\n[13]", "\\n[14]", "\\n[15]", "\\n[16]", "\\n[17]", "\\n[18]", "\\n[19]", "\\n[20]", "\\n[21]"],
    ["特别穿插", "火影人物类", "火影忍术创作", "火影人物穿插", "火影奥义"]
  ]
  def update_ending(n)
    play_music(n)                   # BGM演奏
    redraw_end_graphic(n)           # 画像描画
    draw_text(10, 10, TEXTS[n])   # テキスト描画
  end
  #--------------------------------------------------------------------------
  # ● Fin表示
  #--------------------------------------------------------------------------
  def finish
    play_music(-1)
    clear_graphic
#~     draw_graphic(end_graphic_rect(-2, 0), -2) # 背景
    draw_graphic(end_graphic_rect(-1, 1, FIN_POS[0], FIN_POS[1]), -1)
  end
end

#==============================================================================
# □ カスタマイズ  ~END~
#==============================================================================


#==============================================================================
# ■ 汎用メソッド  ★部分で使用する
#==============================================================================
class Scene_Ending < Scene_Base
  #--------------------------------------------------------------------------
  # ● ミュージック演奏
  #      n      : シーン番号
  #--------------------------------------------------------------------------
  def play_music(n=0)
    music = end_music(n)
    return if music.nil?
    music.play
  end
  #--------------------------------------------------------------------------
  # ● エンド背景の描画先矩形
  #      n      : シーン番号
  #--------------------------------------------------------------------------
  def end_graphic_rect(n=0, type=G_TYPE, x=G_POS[0], y=G_POS[1])
    case type
    when 0  # 画面いっぱいに描画
      return @viewport.rect
    when 1  # アスペクト比を維持して特定位置に描画
      return Rect.new(x, y, end_graphic(n).width, end_graphic(n).height)
    when 2  # 特定矩形に収まるように描画
      return G_RECT
    end
  end
  #--------------------------------------------------------------------------
  # ● 画像描画
  #      rect   : 描画先矩形
  #      n      : シーン番号
  #--------------------------------------------------------------------------
  def draw_graphic(rect, n=0)
    graphic = end_graphic(n)
    src_rect = Rect.new
    src_rect.width  = graphic.width
    src_rect.height = graphic.height
    @sprite.bitmap.stretch_blt(rect, graphic, src_rect)
  end
  #--------------------------------------------------------------------------
  # ● 画像領域消去
  #      rect   : 消去矩形
  #--------------------------------------------------------------------------
  def clear_graphic(rect=@viewport.rect)
    @sprite.bitmap.clear_rect(rect)
  end
  #--------------------------------------------------------------------------
  # ● シーン番号別  画像描画
  #--------------------------------------------------------------------------
  def draw_end_graphic(n=0, type=G_TYPE)
    draw_graphic(end_graphic_rect(n, type), n)
  end
  #--------------------------------------------------------------------------
  # ● シーン番号別  画像再描画
  #--------------------------------------------------------------------------
  def redraw_end_graphic(n=0, type=G_TYPE)
    return if end_graphic(n).nil?
    clear_graphic
    draw_end_graphic(n, type)
  end
  #--------------------------------------------------------------------------
  # ● テキスト描画
  #--------------------------------------------------------------------------
  def draw_text(x, y, texts)
    texts.size.times do |i|
      xx = (i == 0) ? x : (x+30)
      @window.draw_text_ex(xx, y, texts)
      y += @window.line_height
    end
  end
  #--------------------------------------------------------------------------
  # ● テキスト消去
  #--------------------------------------------------------------------------
  def clear_text
    @window.contents.clear
  end
end


#==============================================================================
# ■ シーンクラス
#==============================================================================
class Scene_Ending < Scene_Base
  #--------------------------------------------------------------------------
  # ● オブジェクト初期化
  #--------------------------------------------------------------------------
  def initialize
    super
    @no = 0
    @called_save = false
  end
  #--------------------------------------------------------------------------
  # ● 開始処理
  #--------------------------------------------------------------------------
  def start
    super
    create_viewport
    create_sprite
    create_window
    return goto_next_scene if @no >= TEXTS.size
    update_ending(@no)
  end
  #--------------------------------------------------------------------------
  # ● 画面Viewport生成
  #--------------------------------------------------------------------------
  def create_viewport
    @viewport = Viewport.new
  end
  #--------------------------------------------------------------------------
  # ● 画像表示用スプライト生成
  #--------------------------------------------------------------------------
  def create_sprite
    @sprite = Sprite_Base.new(@viewport)
    @sprite.bitmap = Bitmap.new(@viewport.rect.width, @viewport.rect.height)
  end
  #--------------------------------------------------------------------------
  # ● 文字描画用ウィンドウ生成
  #--------------------------------------------------------------------------
  def create_window
    r = @viewport.rect
    @window = Window_Base.new(r.x, r.y, r.width, r.width)
    @window.opacity = 0
  end
  #--------------------------------------------------------------------------
  # ● 終了処理
  #--------------------------------------------------------------------------
  def terminate
    dispose_sprite
    dispose_viewport
    super
  end
  #--------------------------------------------------------------------------
  # ● 画面Viewport解放
  #--------------------------------------------------------------------------
  def dispose_viewport
    @viewport.dispose
  end
  #--------------------------------------------------------------------------
  # ● 画像表示用スプライト解放
  #--------------------------------------------------------------------------
  def dispose_sprite
    @sprite.dispose
  end
  #--------------------------------------------------------------------------
  # ● 次のシーンへ
  #--------------------------------------------------------------------------
  def goto_next_scene
    if CLRED_SAVE and !@called_save
      call_save
    elsif BACKTO_TITLE
      SceneManager.goto(Scene_Title)
    else
      fadeout_all
      SceneManager.exit
    end
  end
  #--------------------------------------------------------------------------
  # ● クリアデータをセーブ
  #--------------------------------------------------------------------------
  def call_save
    $game_switches[CLRED_SWITCH] = true
    @called_save = true
    SceneManager.call(Scene_Save)
  end
  #--------------------------------------------------------------------------
  # ● フレーム更新
  #--------------------------------------------------------------------------
  def update
    super
    update_ending_scene
  end
  #--------------------------------------------------------------------------
  # ● フレーム更新 <シーン切り替え制御>
  #--------------------------------------------------------------------------
  def update_ending_scene
    return goto_next_scene if @no >= TEXTS.size
    update_ending(@no)
    perform_transition if SC_EFFECT == 1
    wait
    Graphics.freeze    if SC_EFFECT == 1
    clear_text
    @no += 1
    if @no >= TEXTS.size
      RPG::BGM.fade(transition_speed * 2) if
      finish
      Graphics.transition(transition_speed * 2) if SC_EFFECT == 1
      finish_wait
    end
  end
  #--------------------------------------------------------------------------
  # ● トランジション速度の取得
  #--------------------------------------------------------------------------
  def transition_speed
    return 30
  end
  #--------------------------------------------------------------------------
  # ● トランジション速度の取得
  #--------------------------------------------------------------------------
  def skip_trigger?
    Input.trigger?(:C) or Input.trigger?(:B)
  end
  #--------------------------------------------------------------------------
  # ● フレーム更新
  #--------------------------------------------------------------------------
  def update_skipwait(skip=true)
    update_basic
    skip and skip_trigger?
  end
  #--------------------------------------------------------------------------
  # ● ウェイト
  #--------------------------------------------------------------------------
  def wait(duration=SC_WAIT)
    duration.times { |i| break if update_skipwait(ON_SKIP) }
  end
  #--------------------------------------------------------------------------
  # ● Finishウェイト
  #--------------------------------------------------------------------------
  def finish_wait
    if FIN_WAIT.nil?
      loop do update_skipwait end
    else
      wait(FIN_WAIT)
    end
  end
end
[/pre]

比较好的天气系统
[pre lang="ruby"]#screen.change_weather(13,7,0)
#-------------------------------------------------------------------------------
#  MAWS - Modified Advanced Weather Script for RPG Maker VX
#  Version: 1.1.
#  Based on Advanced Weather Script VX by Ccoa
#  Modifications created by Agckuu Coceg
#-------------------------------------------------------------------------------
# Thanks DerWulfman to his help with VX version of script.
#-------------------------------------------------------------------------------
#  Weather Types:
#    1 - 雨 (Ccoa)
#    2 - 风暴 (Ccoa)
#    3 - 雪 (Ccoa)
#    4 - 冰雹 (Ccoa)
#    5 - 雷阵雨 (Ccoa)
#    6 - 下降棕色叶子 (Ccoa)
#    7 - 吹棕色叶子 (Ccoa)
#    8 - 袅袅棕色叶子 (Ccoa)
#    9 - 下降绿色叶子 (Ccoa)
#   10 - 樱花(樱)花瓣 (Ccoa)
#   11 - 玫瑰花瓣 (Ccoa)
#   12 - 羽毛 (Ccoa)
#   13 - 血雨 (Ccoa)
#   14 - 火花 (Ccoa)
#   15 - 用户自定义
#   16 - 吹雪 (Ccoa)
#   17 - 流星雨 (Ccoa)
#   18 - 落灰 (Ccoa)
#   19 - 气泡 (Ccoa)
#   20 - 气泡 2 (Ccoa)
#   21 - 火花上升 (Ccoa)
#-------------------------------------------------------------------------------
# Version 1.0 addons
#-------------------------------------------------------------------------------
#   Leaves effects:
#   22 - 吹绿叶 (Agckuu Coceg)
#   23 - 袅袅的绿叶 (Agckuu Coceg)
#   24 - 下降的黄叶 (Agckuu Coceg)
#   25 - 吹黄叶 (Agckuu Coceg)
#   26 - 袅袅的黄叶 (Agckuu Coceg)
#   Rain effects:
#   27 - 石油雨 (Agckuu Coceg)
#   28 - 金雨 (Agckuu Coceg)
#   Special effects:
#   29 - 火焰流星雨 (Agckuu Coceg)
#-------------------------------------------------------------------------------
# Version 1.1 addons
#-------------------------------------------------------------------------------
#   Starburst effects addons:
#   30 - 彩色星暴 v.2 (replaced Color Starburst)(Agckuu Coceg)
#   31 - 升级版彩色星暴 v.2 (replaced Uprising color Starburst)
#   (Agckuu Coceg)
#   32 - 彩色星暴雨 v.2 (replaced Color Starburst rain)(Agckuu Coceg)
#   33 - 单色暴 (Agckuu Coceg)
#   34 - 升级版单色暴 (Agckuu Coceg)
#   35 - 单色暴雨 (Agckuu Coceg)
#   Rain effects:
#   36 - 金雨雷电和闪光 (Agckuu Coceg)
#   37 - 金色风暴 (Agckuu Coceg)
#   38 - 石油风暴 (Agckuu Coceg)
#   39 - 酸雨 (Agckuu Coceg)
#   40 - 酸雨闪电和闪光 (Agckuu Coceg)
#   41 - 酸雨风暴 (Agckuu Coceg)
#   42 - 棕褐色雨 (Agckuu Coceg)
#   43 - 棕褐色雨闪电和闪光 (Agckuu Coceg)
#   44 - 棕褐色雨风暴 (Agckuu Coceg)
#   45 - 现实风暴 (Agckuu Coceg)
#   46 - 血雨赤红的闪电和雷声 (Agckuu Coceg)
#   47 - 血雨风暴 (Agckuu Coceg)
#   48 - 血暴雪 (Agckuu Coceg)
#   New leaves effects:
#   49 - 下降红枫叶 (Agckuu Coceg)
#   50 - 吹红枫叶 (Agckuu Coceg)
#   51 - 袅袅的红枫叶 (Agckuu Coceg)
#   Special effects:
#   52 - 水弹 (Agckuu Coceg)
#   53 - 冰弹 (Agckuu Coceg)
#   54 - 照明弹 (Agckuu Coceg)
#-------------------------------------------------------------------------------
#  Weather Power:
#    An integer from 0-40.  0 = no weather, 40 = 400 sprites
#-------------------------------------------------------------------------------
#  Usage:
#  Create a call script with the following: screen.weather(type, power, hue)
#-------------------------------------------------------------------------------
#  Usage of user-defined weather. Look at the following globals:
$WEATHER_UPDATE = false   # the $WEATHER_IMAGES array has changed, please update
$WEATHER_IMAGES = []      # the array of picture names to use
$WEATHER_X = 0           # the number of pixels the image should move horizontally (positive = right, negative = left)
$WEATHER_Y = 0            # the number of pizels the image should move vertically (positive = down, negative = up)
$WEATHER_FADE = 0         # how much the image should fade each update (0 = no fade, 255 = fade instantly)
$WEATHER_ANIMATED = true # whether or not the image should cycle through all the images

# Take these out if you are using screen resolution script of Ccoa.
  HEIGHT = 416
  WIDTH = 544

#==============================================================================
# ** Spriteset_Weather
#------------------------------------------------------------------------------

class Spriteset_Weather
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_reader :type
  attr_reader :power
  attr_reader :ox
  attr_reader :oy
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize(viewport = nil)
    @type = 0
    @power = 0
    @ox = 0
    @oy = 0
   
    @count = 0
    @current_pose = []
    @info = []
    @countarray = []
   
    make_bitmaps
   
    @sprites = []
   
    for i in 1..500
      sprite = Sprite.new(viewport)
      sprite.visible = false
      sprite.opacity = 0
      @sprites.push(sprite)
      @current_pose.push(0)
      @info.push(rand(50))
      @countarray.push(rand(15))
    end
   
  end
  #--------------------------------------------------------------------------
  # * Dispose
  #--------------------------------------------------------------------------
  def dispose
    for sprite in @sprites
      sprite.dispose
    end
    @rain_bitmap.dispose
    @storm_bitmap.dispose
    @snow_bitmap.dispose
    @hail_bitmap.dispose
    @petal_bitmap.dispose
    @blood_rain_bitmap.dispose
    @oil_rain_bitmap.dispose
    @golden_rain_bitmap.dispose
    @golden_storm_bitmap.dispose
    @acid_rain_bitmap.dispose
    @acid_storm_bitmap.dispose
    @sepia_rain_bitmap.dispose
    @sepia_storm_bitmap.dispose
    @blood_storm_bitmap.dispose
    @bloodblizz_bitmap.dispose
    @meteor_bitmap.dispose
    @flame_meteor_bitmap.dispose
    @waterbomb_bitmap.dispose
    @icybomb_bitmap.dispose
    @flarebomb_bitmap.dispose
    for image in @autumn_leaf_bitmaps
      image.dispose
    end
    for image in @green_leaf_bitmaps
      image.dispose
    end
    for image in @yellow_leaf_bitmaps
      image.dispose
    end
    for image in @redmaple_leaf_bitmaps
      image.dispose
    end
    for image in @rose_bitmaps
      image.dispose
    end
    for image in @feather_bitmaps
      image.dispose
    end
    for image in @sparkle_bitmaps
      image.dispose
    end
    for image in @starburst_bitmaps
      image.dispose
    end
    for image in @monostarburst_bitmaps
      image.dispose
    end
    for image in @user_bitmaps
      image.dispose
    end
    $WEATHER_UPDATE = true
  end
  #--------------------------------------------------------------------------
  # * Set weather type
  #     type : new weather type
  #--------------------------------------------------------------------------
  def type=(type)
    return if @type == type
    @type = type
    case @type
    when 1 # rain
      bitmap = @rain_bitmap
    when 2 # storm
      bitmap = @storm_bitmap
    when 3 # snow
      bitmap = @snow_bitmap
   when 4 # hail
      bitmap = @hail_bitmap
    when 5 # rain w/ thunder and lightning
      bitmap = @rain_bitmap
      @thunder = true
    when 6 # falling autumn leaves
      bitmap = @autumn_leaf_bitmaps[0]
    when 7 # blowing autumn leaves
      bitmap = @autumn_leaf_bitmaps[0]
    when 8 # swirling autumn leaves
      bitmap = @autumn_leaf_bitmaps[0]
    when 9 # falling green leaves
      bitmap = @green_leaf_bitmaps[0]
    when 10 # sakura petals
      bitmap = @petal_bitmap
    when 11 # rose petals
      bitmap = @rose_bitmaps[0]
    when 12 # feathers
      bitmap = @feather_bitmaps[0]
    when 13 # blood rain
      bitmap = @blood_rain_bitmap
    when 14 # sparkles
      bitmap = @sparkle_bitmaps[0]
    when 15 # user-defined
        bitmap = @user_bitmaps[rand(@user_bitmaps.size)]
    when 16 # blowing snow
      bitmap = @snow_bitmap
    when 17 # meteors
      bitmap = @meteor_bitmap
    when 18 # falling ash
      bitmap = @ash_bitmaps[rand(@ash_bitmaps.size)]
    when 19 # bubbles
      bitmap = @bubble_bitmaps[rand(@bubble_bitmaps.size)]
    when 21 # sparkles up
      bitmap = @sparkle_bitmaps[0]
    when 22 # blowing green leaves
      bitmap = @green_leaf_bitmaps[0]
    when 23 # swirling green leaves
      bitmap = @green_leaf_bitmaps[0]
    when 24 # falling yellow leaves
      bitmap = @yellow_leaf_bitmaps[0]
    when 25 # blowing yellow leaves
      bitmap = @yellow_leaf_bitmaps[0]
    when 26 # swirling yellow leaves
      bitmap = @yellow_leaf_bitmaps[0]
    when 27 # oil rain
       bitmap = @oil_rain_bitmap
    when 28 # golden rain
       bitmap = @golden_rain_bitmap
    when 29 # flame meteors
       bitmap = @flame_meteor_bitmap
    when 30 # starburst
      bitmap = @starburst_bitmaps[0]
    when 31 # uprising starburst
      bitmap = @starburst_bitmaps[0]
    when 32 # starburst rain
      bitmap = @starburst_bitmaps[0]
    when 33 # mono-starburst
      bitmap = @monostarburst_bitmaps[0]
    when 34 # uprising mono-starburst
      bitmap = @monostarburst_bitmaps[0]
    when 35 # mono-starburst rain
      bitmap = @monostarburst_bitmaps[0]
    when 36 # Golden rain w\ thunder and ligthning
      bitmap = @golden_rain_bitmap
      @golden_thunder = true
    when 37 # Golden storm
      bitmap = @golden_storm_bitmap
    when 38 # Oil storm
      bitmap = @oil_storm_bitmap
    when 39 # # Acid rain
      bitmap = @acid_rain_bitmap
    when 40 # Acid rain w\thunder and lightning
      bitmap = @acid_rain_bitmap
      @acid_thunder = true
    when 41 # Acid storm
      bitmap = @acid_storm_bitmap
    when 42 # Sepia rain
      bitmap = @sepia_rain_bitmap
    when 43 # Sepia rain w\ thunder and lightning
      bitmap = @sepia_rain_bitmap
      @sepia_thunder = true
    when 44 # Sepia storm
      bitmap = @sepia_storm_bitmap
    when 45 # Realistic storm
      bitmap = @storm_bitmap
      @real_storm = true
    when 46 # Blood rain w\ thunder and lightning
      bitmap = @blood_rain_bitmap
      @crimson_thunder = true
    when 47 # Blood storm
      bitmap = @blood_storm_bitmap
    when 48 # Blood blizzard
      bitmap = @bloodblizz_bitmap
    when 49 # Falling red maple leaves
      bitmap = @redmaple_leaf_bitmaps[0]
    when 50 # Blowing red maple leaves
      bitmap = @redmaple_leaf_bitmaps[0]
    when 51 # Swirling red maple leaves
      bitmap = @redmaple_leaf_bitmaps[0]
    when 52
      bitmap = @waterbomb_bitmaps
    when 53
      bitmap = @icybomb_bitmaps
    when 54
      bitmap = @flarebomb_bitmaps
    else
      bitmap = nil
    end
   
    if @type != 5
      @thunder = false
    end
   
    if @type != 36
      @golden_thunder = false
    end
   
    if @type != 40
      @acid_thunder = false
    end
   
    if @type != 43
      @sepia_thunder = false
    end
   
    if @type != 45
      @real_storm = false
    end
   
    if @type != 46
      @crimson_thunder = false
    end
   
    for i in 0...@sprites.size
      sprite = @sprites
      sprite.visible = (i <= @power)
      if @type == 19
        sprite.bitmap = @bubble_bitmaps[rand(@bubble_bitmaps.size)]
      elsif @type == 20
        sprite.bitmap = @bubble2_bitmaps[rand(@bubble2_bitmaps.size)]
      elsif @type == 3
        r = rand(@snow_bitmaps.size)
        @info = r
        sprite.bitmap = @snow_bitmaps[r]
      else
        sprite.bitmap = bitmap
      end
    end
  end
  #--------------------------------------------------------------------------
  # * Set starting point X coordinate
  #     ox : starting point X coordinate
  #--------------------------------------------------------------------------
  def ox=(ox)
    return if @ox == ox;
    @ox = ox
    for sprite in @sprites
      sprite.ox = @ox
    end
  end
  #--------------------------------------------------------------------------
  # * Set starting point Y coordinate
  #     oy : starting point Y coordinate
  #--------------------------------------------------------------------------
  def oy=(oy)
    return if @oy == oy;
    @oy = oy
    for sprite in @sprites
      sprite.oy = @oy
    end
  end
  #--------------------------------------------------------------------------
  # * Set maximum number of sprites
  #     max : maximum number of sprites
  #--------------------------------------------------------------------------
  def power=(power)
    @power = power
    for i in 1..40
      sprite = @sprites
      sprite.visible = (i <= @power) if sprite != nil
      if @type == 19
          sprite.bitmap = @bubble_bitmaps[rand(@bubble_bitmaps.size)]
        elsif @type == 20
          sprite.bitmap = @bubble2_bitmaps[rand(@bubble2_bitmaps.size)]
        elsif @type == 3
          r = rand(@snow_bitmaps.size)
          @info = r
          sprite.bitmap = @snow_bitmaps[r]
        end
    end
  end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
  def update
    return if @type == 0
    for i in 1..@power
      sprite = @sprites
      if @type == 1 or @type == 5 or @type == 13 or @type == 27 or @type == 28 or @type == 36 or @type == 39 or @type == 40 or @type == 42 or @type == 43 or @type == 46 #rain
        if sprite.opacity <= 150
          if @current_pose == 0
            sprite.y += @rain_bitmap.height
            sprite.x -= @rain_bitmap.width
            if @type == 1 or @type == 5
              sprite.bitmap = @rain_splash
            else
              sprite.bitmap = @blood_rain_splash
            end
            if @type == 27
              sprite.bitmap = @oil_rain_splash
            end
            if @type == 28
              sprite.bitmap = @golden_rain_splash
            end
            if @type == 36
              sprite.bitmap = @golden_rain_splash
            end
            if @type == 39
              sprite.bitmap = @acid_rain_splash
            end
            if @type == 40
              sprite.bitmap = @acid_rain_splash
            end
            if @type == 42
              sprite.bitmap = @sepia_rain_splash
            end
            if @type == 43
              sprite.bitmap = @sepia_rain_splash
            end
            if @type == 46
              sprite.bitmap = @blood_rain_splash
            end
            @current_pose = 1
          end
        else
          if @current_pose == 1
            if @type == 1 or @type == 5
              sprite.bitmap = @rain_bitmap
            else
              sprite.bitmap = @blood_rain_bitmap
            end
            if @type == 27
              sprite.bitmap = @oil_rain_bitmap
            end
            if @type == 28
              sprite.bitmap = @golden_rain_bitmap
            end
            if @type == 36
              sprite.bitmap = @golden_rain_bitmap
            end
            if @type == 39
              sprite.bitmap = @acid_rain_bitmap
            end
            if @type == 40
              sprite.bitmap = @acid_rain_bitmap
            end
            if @type == 42
              sprite.bitmap = @sepia_rain_bitmap
            end
            if @type == 43
              sprite.bitmap = @sepia_rain_bitmap
            end
            if @type == 46
              sprite.bitmap = @blood_rain_bitmap
            end
            @current_pose = 0
          end
          sprite.x -= 2
          sprite.y += 16
          if @thunder and (rand(8000 - @power) == 0)
            $game_map.screen.start_flash(Color.new(255, 255, 255, 255), 5)
            Audio.se_play("Audio/SE/Thunder1")
          end
        if @golden_thunder and (rand(8000 - @power) == 0)
            $game_map.screen.start_flash(Color.new(255, 255, 255, 255), 5)
            Audio.se_play("Audio/SE/Thunder1")
          end
       if @acid_thunder and (rand(5000 - @power) == 0)
            $game_map.screen.start_flash(Color.new(255, 255, 255, 255), 5)
            Audio.se_play("Audio/SE/Thunder1")
          end
       if @sepia_thunder and (rand(8000 - @power) == 0)
            $game_map.screen.start_flash(Color.new(169, 152, 142, 255), 5)
            Audio.se_play("Audio/SE/Thunder1")
          end
       if @sepia_thunder and (rand(8000 - @power) == 0)
            $game_map.screen.start_flash(Color.new(169, 152, 142, 255), 5)
            Audio.se_play("Audio/SE/Thunder1")
          end
       if @crimson_thunder and (rand(8000 - @power) == 0)
          $game_map.screen.start_flash(Color.new(141, 9, 9, 255), 5)
          Audio.se_play("Audio/SE/Thunder1")
          end
        end
        sprite.opacity -= 8
      end
      if @type == 2 or @type == 37 or @type == 38 or @type == 41 or @type == 44 or @type == 45 or @type == 47 # storm
        sprite.x -= 8
        sprite.y += 16
        sprite.opacity -= 12
      end
        if @real_storm and (rand(5000 - @power) == 0)
        $game_map.screen.start_flash(Color.new(255, 255, 255, 255), 5)
        $game_map.screen.start_shake(9, 4, 5)
        Audio.se_play("Audio/SE/Thunder9")
      end
      if @type == 3 # snow
        case @info
        when 0 # smallest flake, fall the slowest
          sprite.y += 1
        when 1
          sprite.y += 3
        when 2
          sprite.y += 5
        when 3
          sprite.y += 7
        end
        sprite.opacity -= 3
      end
      if @type == 4 # hail
        sprite.x -= 1
        sprite.y += 18
        sprite.opacity -= 15
      end
      if @type == 6 # falling autumn leaves
        @count = rand(20)
        if @count == 0
          sprite.bitmap = @autumn_leaf_bitmaps[@current_pose]
          @current_pose = (@current_pose + 1) % @autumn_leaf_bitmaps.size
        end
        sprite.x -= 1
        sprite.y += 1
      end
      if @type == 7 # blowing autumn leaves
        @count = rand(20)
        if @count == 0
          sprite.bitmap = @autumn_leaf_bitmaps[@current_pose]
          @current_pose = (@current_pose + 1) % @autumn_leaf_bitmaps.size
        end
        sprite.x -= 10
        sprite.y += (rand(4) - 2)
      end
      if @type == 8 # swirling autumn leaves
        @count = rand(20)
        if @count == 0
          sprite.bitmap = @autumn_leaf_bitmaps[@current_pose]
          @current_pose = (@current_pose + 1) % @autumn_leaf_bitmaps.size
        end
        if @info != 0
          if @info >= 1 and @info <= 10
            sprite.x -= 3
            sprite.y -= 1
          elsif @info >= 11 and @info <= 16
            sprite.x -= 1
            sprite.y -= 2
          elsif @info >= 17 and @info <= 20
            sprite.y -= 3
          elsif @info >= 21 and @info <= 30
            sprite.y -= 2
            sprite.x += 1
          elsif @info >= 31 and @info <= 36
            sprite.y -= 1
            sprite.x += 3
          elsif @info >= 37 and @info <= 40
            sprite.x += 5
          elsif @info >= 41 and @info <= 46
            sprite.y += 1
            sprite.x += 3
          elsif @info >= 47 and @info <= 58
            sprite.y += 2
            sprite.x += 1
          elsif @info >= 59 and @info <= 64
            sprite.y += 3
          elsif @info >= 65 and @info <= 70
            sprite.x -= 1
            sprite.y += 2
          elsif @info >= 71 and @info <= 81
            sprite.x -= 3
            sprite.y += 1
          elsif @info >= 82 and @info <= 87
            sprite.x -= 5
          end
          @info = (@info + 1) % 88
        else
          if rand(200) == 0
            @info = 1
          end
          sprite.x -= 5
          sprite.y += 1
        end
      end
        if @type == 49 # falling red maple leaves
        @count = rand(20)
        if @count == 0
          sprite.bitmap = @redmaple_leaf_bitmaps[@current_pose]
          @current_pose = (@current_pose + 1) % @redmaple_leaf_bitmaps.size
        end
        sprite.x -= 1
        sprite.y += 1
      end
      if @type == 50 # blowing red maple leaves
        @count = rand(20)
        if @count == 0
          sprite.bitmap = @redmaple_leaf_bitmaps[@current_pose]
          @current_pose = (@current_pose + 1) % @redmaple_leaf_bitmaps.size
        end
        sprite.x -= 10
        sprite.y += (rand(4) - 2)
      end
      if @type == 51 # swirling red maple leaves
        @count = rand(20)
        if @count == 0
          sprite.bitmap = @redmaple_leaf_bitmaps[@current_pose]
          @current_pose = (@current_pose + 1) % @redmaple_leaf_bitmaps.size
        end
        if @info != 0
          if @info >= 1 and @info <= 10
            sprite.x -= 3
            sprite.y -= 1
          elsif @info >= 11 and @info <= 16
            sprite.x -= 1
            sprite.y -= 2
          elsif @info >= 17 and @info <= 20
            sprite.y -= 3
          elsif @info >= 21 and @info <= 30
            sprite.y -= 2
            sprite.x += 1
          elsif @info >= 31 and @info <= 36
            sprite.y -= 1
            sprite.x += 3
          elsif @info >= 37 and @info <= 40
            sprite.x += 5
          elsif @info >= 41 and @info <= 46
            sprite.y += 1
            sprite.x += 3
          elsif @info >= 47 and @info <= 58
            sprite.y += 2
            sprite.x += 1
          elsif @info >= 59 and @info <= 64
            sprite.y += 3
          elsif @info >= 65 and @info <= 70
            sprite.x -= 1
            sprite.y += 2
          elsif @info >= 71 and @info <= 81
            sprite.x -= 3
            sprite.y += 1
          elsif @info >= 82 and @info <= 87
            sprite.x -= 5
          end
          @info = (@info + 1) % 88
        else
          if rand(200) == 0
            @info = 1
          end
          sprite.x -= 5
          sprite.y += 1
        end
      end
      if @type == 9 # falling green leaves
        if @countarray == 0
          @current_pose = (@current_pose + 1) % @green_leaf_bitmaps.size
          sprite.bitmap = @green_leaf_bitmaps[@current_pose]
          @countarray = rand(15)
        end
        @countarray = (@countarray + 1) % 15
        sprite.y += 1
      end
      if @type == 10 # sakura petals
        if @info < 25
          sprite.x -= 1
        else
          sprite.x += 1
        end
        @info = (@info + 1) % 50
        sprite.y += 1
      end
      if @type == 11 # rose petals
        @count = rand(20)
        if @count == 0
          sprite.bitmap = @rose_bitmaps[@current_pose]
          @current_pose = (@current_pose + 1) % @rose_bitmaps.size
        end
        if @info % 2 == 0
          if @info < 10
            sprite.x -= 1
          elsif
            sprite.x += 1
          end
        end
        sprite.y += 1
      end
      if @type == 12 # feathers
        if @countarray == 0
          @current_pose = (@current_pose + 1) % @feather_bitmaps.size
          sprite.bitmap = @feather_bitmaps[@current_pose]
        end
        @countarray = (@countarray + 1) % 15
        if rand(100) == 0
          sprite.x -= 1
        end
        if rand(100) == 0
          sprite.y -= 1
        end
        if @info < 50
          if rand(2) == 0
            sprite.x -= 1
          else
            sprite.y -= 1
          end
        else
          if rand(2) == 0
            sprite.x += 1
          else
            sprite.y += 1
          end
        end
        @info = (@info + 1) % 100
      end
      
       if @type == 30 # starburst
        if @countarray == 0
          @current_pose = (@current_pose + 1) % @starburst_bitmaps.size
          sprite.bitmap = @starburst_bitmaps[@current_pose]
        end
        @countarray = (@countarray + 1) % 15
        sprite.y += 1
        sprite.opacity -= 1
      end
      if @type == 31 # starburst up
        if @countarray == 0
          @current_pose = (@current_pose + 1) % @starburst_bitmaps.size
          sprite.bitmap = @starburst_bitmaps[@current_pose]
        end
        @countarray = (@countarray + 1) % 15
        sprite.y -= 1
        sprite.opacity -= 1
      end
      if @type == 32 # starburst up
        if @countarray == 0
          @current_pose = (@current_pose + 1) % @starburst_bitmaps.size
          sprite.bitmap = @starburst_bitmaps[@current_pose]
        end
        @countarray = (@countarray + 1) % 15
        sprite.x -= 2
        sprite.y += 8
        sprite.opacity -= 1
      end     
      
      if @type == 33 # mono-starburst
        if @countarray == 0
          @current_pose = (@current_pose + 1) % @monostarburst_bitmaps.size
          sprite.bitmap = @monostarburst_bitmaps[@current_pose]
        end
        @countarray = (@countarray + 1) % 15
        sprite.y += 1
        sprite.opacity -= 1
      end
      if @type == 34 # mono-starburst up
        if @countarray == 0
          @current_pose = (@current_pose + 1) % @monostarburst_bitmaps.size
          sprite.bitmap = @monostarburst_bitmaps[@current_pose]
        end
        @countarray = (@countarray + 1) % 15
        sprite.y -= 1
        sprite.opacity -= 1
      end
      if @type == 35 # mono-starburst rain
        if @countarray == 0
          @current_pose = (@current_pose + 1) % @monostarburst_bitmaps.size
          sprite.bitmap = @monostarburst_bitmaps[@current_pose]
        end
        @countarray = (@countarray + 1) % 15
        sprite.x -= 2
        sprite.y += 8
        sprite.opacity -= 1
      end           
        if @type == 29 # meteors
        if @countarray > 0
          if rand(20) == 0
            sprite.bitmap = @flame_impact_bitmap
            @countarray = -5
          else
            sprite.x -= 6
            sprite.y += 10
          end
        else
          @countarray += 1
          if @countarray == 0
            sprite.bitmap = @flame_meteor_bitmap
            sprite.opacity = 0
            @count_array = 1
          end
        end
      end
      if @type == 18 # ash
        sprite.y += 2
        case @countarray % 3
        when 0
          sprite.x -= 1
        when 1
          sprite.x += 1
        end
      end      
      
      if @type == 14 # sparkles
        if @countarray == 0
          @current_pose = (@current_pose + 1) % @sparkle_bitmaps.size
          sprite.bitmap = @sparkle_bitmaps[@current_pose]
        end
        @countarray = (@countarray + 1) % 15
        sprite.y += 1
        sprite.opacity -= 1
      end
      if @type == 15 # user-defined
        if $WEATHER_UPDATE
          update_user_defined
          $WEATHER_UPDATE = false
        end
        if $WEATHER_ANIMATED and @countarray == 0
          @current_pose = (@current_pose + 1) % @user_bitmaps.size
          sprite.bitmap = @user_bitmaps[@current_pose]
        end
        sprite.x += $WEATHER_X
        sprite.y += $WEATHER_Y
        sprite.opacity -= $WEATHER_FADE
      end
      if @type == 16 # blowing snow
        sprite.x -= 10
        sprite.y += 6
        sprite.opacity -= 4
      end
      if @type == 48 # blood blizzard
        sprite.x -= 10
        sprite.y += 6
        sprite.opacity -= 4
      end
      if @type == 52 # water bombs
        if @countarray > 0
          if rand(20) == 0
            sprite.bitmap = @waterbomb_impact_bitmap
            @countarray = -5
          else
            sprite.x -= 3
            sprite.y += 5
          end
        else
          @countarray += 1
          if @countarray == 0
            sprite.bitmap = @waterbomb_bitmap
            sprite.opacity = 0
            @count_array = 1
          end
        end
      end
        if @type == 53 # icy bombs
        if @countarray > 0
          if rand(20) == 0
            sprite.bitmap = @icybomb_impact_bitmap
            @countarray = -5
          else
            sprite.x -= 3
            sprite.y += 5
          end
        else
          @countarray += 1
          if @countarray == 0
            sprite.bitmap = @icybomb_bitmap
            sprite.opacity = 0
            @count_array = 1
          end
        end
      end
      if @type == 54 # flare bombs
        if @countarray > 0
          if rand(20) == 0
            sprite.bitmap = @flarebomb_impact_bitmap
            @countarray = -5
          else
            sprite.x -= 3
            sprite.y += 5
          end
        else
          @countarray += 1
          if @countarray == 0
            sprite.bitmap = @flarebomb_bitmap
            sprite.opacity = 0
            @count_array = 1
          end
        end
      end
      if @type == 17 # meteors
        if @countarray > 0
          if rand(20) == 0
            sprite.bitmap = @impact_bitmap
            @countarray = -5
          else
            sprite.x -= 6
            sprite.y += 10
          end
        else
          @countarray += 1
          if @countarray == 0
            sprite.bitmap = @meteor_bitmap
            sprite.opacity = 0
            @count_array = 1
          end
        end
      end
      if @type == 18 # ash
        sprite.y += 2
        case @countarray % 3
        when 0
          sprite.x -= 1
        when 1
          sprite.x += 1
        end
      end
      if @type == 19 or @type == 20 # bubbles
        switch = rand(75) + rand(75) + 1
        if @info < switch / 2
          sprite.x -= 1
        else
          sprite.x += 1
        end
        @info = (@info + 1) % switch
        sprite.y -= 1
        if switch % 2 == 0
          sprite.opacity -= 1
        end
      end
      if @type == 21 # sparkles up
        if @countarray == 0
          @current_pose = (@current_pose + 1) % @sparkle_bitmaps.size
          sprite.bitmap = @sparkle_bitmaps[@current_pose]
        end
        @countarray = (@countarray + 1) % 15
        sprite.y -= 1
        sprite.opacity -= 1
      end
         if @type == 24 # falling yellow leaves
        @count = rand(20)
        if @count == 0
          sprite.bitmap = @yellow_leaf_bitmaps[@current_pose]
          @current_pose = (@current_pose + 1) % @yellow_leaf_bitmaps.size
        end
        sprite.x -= 1
        sprite.y += 1
      end
       if @type == 22 # blowing green leaves
        @count = rand(20)
        if @count == 0
          sprite.bitmap = @green_leaf_bitmaps[@current_pose]
          @current_pose = (@current_pose + 1) % @green_leaf_bitmaps.size
        end
        sprite.x -= 10
        sprite.y += (rand(4) - 2)
      end      
      if @type == 23 # swirling green leaves
        @count = rand(20)
        if @count == 0
          sprite.bitmap = @green_leaf_bitmaps[@current_pose]
          @current_pose = (@current_pose + 1) % @green_leaf_bitmaps.size
        end
        if @info != 0
          if @info >= 1 and @info <= 10
            sprite.x -= 3
            sprite.y -= 1
          elsif @info >= 11 and @info <= 16
            sprite.x -= 1
            sprite.y -= 2
          elsif @info >= 17 and @info <= 20
            sprite.y -= 3
          elsif @info >= 21 and @info <= 30
            sprite.y -= 2
            sprite.x += 1
          elsif @info >= 31 and @info <= 36
            sprite.y -= 1
            sprite.x += 3
          elsif @info >= 37 and @info <= 40
            sprite.x += 5
          elsif @info >= 41 and @info <= 46
            sprite.y += 1
            sprite.x += 3
          elsif @info >= 47 and @info <= 58
            sprite.y += 2
            sprite.x += 1
          elsif @info >= 59 and @info <= 64
            sprite.y += 3
          elsif @info >= 65 and @info <= 70
            sprite.x -= 1
            sprite.y += 2
          elsif @info >= 71 and @info <= 81
            sprite.x -= 3
            sprite.y += 1
          elsif @info >= 82 and @info <= 87
            sprite.x -= 5
          end
          @info = (@info + 1) % 88
        else
          if rand(200) == 0
            @info = 1
          end
          sprite.x -= 5
          sprite.y += 1
        end
      end
        if @type == 24 # falling yellow leaves
        @count = rand(20)
        if @count == 0
          sprite.bitmap = @yellow_leaf_bitmaps[@current_pose]
          @current_pose = (@current_pose + 1) % @yellow_leaf_bitmaps.size
        end
        sprite.x -= 1
        sprite.y += 1
      end      
     if @type == 25 # blowing yellow leaves
        @count = rand(20)
        if @count == 0
          sprite.bitmap = @yellow_leaf_bitmaps[@current_pose]
          @current_pose = (@current_pose + 1) % @yellow_leaf_bitmaps.size
        end
        sprite.x -= 10
        sprite.y += (rand(4) - 2)
      end
       if @type == 26 # swirling yellow leaves
        @count = rand(20)
        if @count == 0
          sprite.bitmap = @yellow_leaf_bitmaps[@current_pose]
          @current_pose = (@current_pose + 1) % @yellow_leaf_bitmaps.size
        end
        if @info != 0
          if @info >= 1 and @info <= 10
            sprite.x -= 3
            sprite.y -= 1
          elsif @info >= 11 and @info <= 16
            sprite.x -= 1
            sprite.y -= 2
          elsif @info >= 17 and @info <= 20
            sprite.y -= 3
          elsif @info >= 21 and @info <= 30
            sprite.y -= 2
            sprite.x += 1
          elsif @info >= 31 and @info <= 36
            sprite.y -= 1
            sprite.x += 3
          elsif @info >= 37 and @info <= 40
            sprite.x += 5
          elsif @info >= 41 and @info <= 46
            sprite.y += 1
            sprite.x += 3
          elsif @info >= 47 and @info <= 58
            sprite.y += 2
            sprite.x += 1
          elsif @info >= 59 and @info <= 64
            sprite.y += 3
          elsif @info >= 65 and @info <= 70
            sprite.x -= 1
            sprite.y += 2
          elsif @info >= 71 and @info <= 81
            sprite.x -= 3
            sprite.y += 1
          elsif @info >= 82 and @info <= 87
            sprite.x -= 5
          end
          @info = (@info + 1) % 88
        else
          if rand(200) == 0
            @info = 1
          end
          sprite.x -= 5
          sprite.y += 1
        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
        sprite.opacity = 255
      end
    end
  end
#-------------------------------------------------------------------------------  
  def make_bitmaps
    color1 = Color.new(255, 255, 255, 255)
    color2 = Color.new(255, 255, 255, 128)
    @rain_bitmap = Bitmap.new(7, 56)
    for i in 0..6
      @rain_bitmap.fill_rect(6-i, i*8, 1, 8, color1)
    end
    @rain_splash = Bitmap.new(8, 5)
    @rain_splash.fill_rect(1, 0, 6, 1, color2)
    @rain_splash.fill_rect(1, 4, 6, 1, color2)
    @rain_splash.fill_rect(0, 1, 1, 3, color2)
    @rain_splash.fill_rect(7, 1, 1, 3, color2)
    @rain_splash.set_pixel(1, 0, color1)
    @rain_splash.set_pixel(0, 1, color1)
#-------------------------------------------------------------------------------   
    @storm_bitmap = Bitmap.new(34, 64)
    for i in 0..31
      @storm_bitmap.fill_rect(33-i, i*2, 1, 2, color2)
      @storm_bitmap.fill_rect(32-i, i*2, 1, 2, color1)
      @storm_bitmap.fill_rect(31-i, i*2, 1, 2, color2)
    end
#-------------------------------------------------------------------------------   
    @snow_bitmap = Bitmap.new(6, 6)
    @snow_bitmap.fill_rect(0, 1, 6, 4, color2)
    @snow_bitmap.fill_rect(1, 0, 4, 6, color2)
    @snow_bitmap.fill_rect(1, 2, 4, 2, color1)
    @snow_bitmap.fill_rect(2, 1, 2, 4, color1)
    @sprites = []   
    @snow_bitmaps = []
   
    color3 = Color.new(255, 255, 255, 204)
    @snow_bitmaps[0] = Bitmap.new(3, 3)
    @snow_bitmaps[0].fill_rect(0, 0, 3, 3, color2)
    @snow_bitmaps[0].fill_rect(0, 1, 3, 1, color3)
    @snow_bitmaps[0].fill_rect(1, 0, 1, 3, color3)
    @snow_bitmaps[0].set_pixel(1, 1, color1)
   
    @snow_bitmaps[1] = Bitmap.new(4, 4)
    @snow_bitmaps[1].fill_rect(0, 1, 4, 2, color2)
    @snow_bitmaps[1].fill_rect(1, 0, 2, 4, color2)
    @snow_bitmaps[1].fill_rect(1, 1, 2, 2, color1)
   
    @snow_bitmaps[2] = Bitmap.new(5, 5)
    @snow_bitmaps[1].fill_rect(0, 1, 5, 3, color3)
    @snow_bitmaps[1].fill_rect(1, 0, 3, 5, color3)
    @snow_bitmaps[1].fill_rect(1, 1, 3, 3, color2)
    @snow_bitmaps[1].fill_rect(2, 1, 3, 1, color1)
    @snow_bitmaps[1].fill_rect(1, 2, 1, 3, color1)
   
    @snow_bitmaps[3] = Bitmap.new(7, 7)
    @snow_bitmaps[1].fill_rect(1, 1, 5, 5, color3)
    @snow_bitmaps[1].fill_rect(2, 0, 7, 3, color3)
    @snow_bitmaps[1].fill_rect(0, 2, 3, 7, color3)
    @snow_bitmaps[1].fill_rect(2, 1, 5, 3, color2)
    @snow_bitmaps[1].fill_rect(1, 2, 3, 5, color2)
    @snow_bitmaps[1].fill_rect(2, 2, 3, 3, color1)
    @snow_bitmaps[1].fill_rect(3, 1, 5, 1, color1)
    @snow_bitmaps[1].fill_rect(1, 3, 1, 5, color1)
#-------------------------------------------------------------------------------   
    #hail
   
    blueGrey  = Color.new(215, 227, 227, 150)
    grey      = Color.new(214, 217, 217, 150)
    lightGrey = Color.new(233, 233, 233, 250)
    lightBlue = Color.new(222, 239, 243, 250)
   
    @hail_bitmap = Bitmap.new(4, 4)
    @hail_bitmap.fill_rect(1, 0, 2, 1, blueGrey)
    @hail_bitmap.fill_rect(0, 1, 1, 2, blueGrey)
    @hail_bitmap.fill_rect(3, 1, 1, 2, grey)
    @hail_bitmap.fill_rect(1, 3, 2, 1, grey)
    @hail_bitmap.fill_rect(1, 1, 2, 2, lightGrey)
    @hail_bitmap.set_pixel(1, 1, lightBlue)
   
#-------------------------------------------------------------------------------   
    #sakura petals

    color3 = Color.new(255, 167, 192, 255) # light pink
    color4 = Color.new(213, 106, 136, 255) # dark pink
    @petal_bitmap = Bitmap.new(4, 4) #This creates a new bitmap that is 4 x 4 pixels
    @petal_bitmap.fill_rect(0, 3, 1, 1, color3) # this makes a 1x1 pixel "rectangle" at the 0, 3 pixel of the image (upper left corner is 0, 0)
    @petal_bitmap.fill_rect(1, 2, 1, 1, color3)
    @petal_bitmap.fill_rect(2, 1, 1, 1, color3)
    @petal_bitmap.fill_rect(3, 0, 1, 1, color3)
    @petal_bitmap.fill_rect(1, 3, 1, 1, color4)
    @petal_bitmap.fill_rect(2, 2, 1, 1, color4)
    @petal_bitmap.fill_rect(3, 1, 1, 1, color4)
   
#-------------------------------------------------------------------------------   
    #autumn brown leaves
   
    brightOrange = Color.new(248, 88, 0, 255)  
    orangeBrown  = Color.new(144, 80, 56, 255)
    burntRed     = Color.new(152, 0, 0, 255)
    paleOrange   = Color.new(232, 160, 128, 255)
    darkBrown    = Color.new(72, 40, 0, 255)
   
    @autumn_leaf_bitmaps = []
   
    @autumn_leaf_bitmaps.push(Bitmap.new(8, 8))
    # draw the first of the leaf1 bitmaps
    @autumn_leaf_bitmaps[0].set_pixel(5, 1, orangeBrown)
    @autumn_leaf_bitmaps[0].set_pixel(6, 1, brightOrange)
    @autumn_leaf_bitmaps[0].set_pixel(7, 1, paleOrange)
    @autumn_leaf_bitmaps[0].set_pixel(3, 2, orangeBrown)
    @autumn_leaf_bitmaps[0].fill_rect(4, 2, 2, 1, brightOrange)
    @autumn_leaf_bitmaps[0].set_pixel(6, 2, paleOrange)
    @autumn_leaf_bitmaps[0].set_pixel(2, 3, orangeBrown)
    @autumn_leaf_bitmaps[0].set_pixel(3, 3, brightOrange)
    @autumn_leaf_bitmaps[0].fill_rect(4, 3, 2, 1, paleOrange)
    @autumn_leaf_bitmaps[0].set_pixel(1, 4, orangeBrown)
    @autumn_leaf_bitmaps[0].set_pixel(2, 4, brightOrange)
    @autumn_leaf_bitmaps[0].set_pixel(3, 4, paleOrange)
    @autumn_leaf_bitmaps[0].set_pixel(1, 5, brightOrange)
    @autumn_leaf_bitmaps[0].set_pixel(2, 5, paleOrange)
    @autumn_leaf_bitmaps[0].set_pixel(0, 6, orangeBrown)
    @autumn_leaf_bitmaps[0].set_pixel(1, 6, paleOrange)
    @autumn_leaf_bitmaps[0].set_pixel(0, 7, paleOrange)
   
    # draw the 2nd of the leaf1 bitmaps
    @autumn_leaf_bitmaps.push(Bitmap.new(8, 8))
    @autumn_leaf_bitmaps[1].set_pixel(3, 0, brightOrange)
    @autumn_leaf_bitmaps[1].set_pixel(7, 0, brightOrange)
    @autumn_leaf_bitmaps[1].set_pixel(3, 1, orangeBrown)
    @autumn_leaf_bitmaps[1].set_pixel(4, 1, burntRed)
    @autumn_leaf_bitmaps[1].set_pixel(6, 1, brightOrange)
    @autumn_leaf_bitmaps[1].set_pixel(0, 2, paleOrange)
    @autumn_leaf_bitmaps[1].set_pixel(1, 2, brightOrange)
    @autumn_leaf_bitmaps[1].set_pixel(2, 2, orangeBrown)
    @autumn_leaf_bitmaps[1].set_pixel(3, 2, burntRed)
    @autumn_leaf_bitmaps[1].set_pixel(4, 2, orangeBrown)
    @autumn_leaf_bitmaps[1].set_pixel(5, 2, brightOrange)
    @autumn_leaf_bitmaps[1].fill_rect(1, 3, 3, 1, orangeBrown)
    @autumn_leaf_bitmaps[1].fill_rect(4, 3, 2, 1, brightOrange)
    @autumn_leaf_bitmaps[1].set_pixel(6, 3, orangeBrown)
    @autumn_leaf_bitmaps[1].set_pixel(2, 4, burntRed)
    @autumn_leaf_bitmaps[1].fill_rect(3, 4, 3, 1, brightOrange)
    @autumn_leaf_bitmaps[1].set_pixel(6, 4, burntRed)
    @autumn_leaf_bitmaps[1].set_pixel(7, 4, darkBrown)
    @autumn_leaf_bitmaps[1].set_pixel(1, 5, orangeBrown)
    @autumn_leaf_bitmaps[1].fill_rect(2, 5, 2, 1, brightOrange)
    @autumn_leaf_bitmaps[1].set_pixel(4, 5, orangeBrown)
    @autumn_leaf_bitmaps[1].set_pixel(5, 5, burntRed)
    @autumn_leaf_bitmaps[1].fill_rect(1, 6, 2, 1, brightOrange)
    @autumn_leaf_bitmaps[1].fill_rect(4, 6, 2, 1, burntRed)
    @autumn_leaf_bitmaps[1].set_pixel(0, 7, brightOrange)
    @autumn_leaf_bitmaps[1].set_pixel(5, 7, darkBrown)
   
    # draw the 3rd of the leaf1 bitmaps
    @autumn_leaf_bitmaps.push(Bitmap.new(8, 8))
    @autumn_leaf_bitmaps[2].set_pixel(7, 1, paleOrange)
    @autumn_leaf_bitmaps[2].set_pixel(6, 2, paleOrange)
    @autumn_leaf_bitmaps[2].set_pixel(7, 2, orangeBrown)
    @autumn_leaf_bitmaps[2].set_pixel(5, 3, paleOrange)
    @autumn_leaf_bitmaps[2].set_pixel(6, 3, brightOrange)
    @autumn_leaf_bitmaps[2].set_pixel(4, 4, paleOrange)
    @autumn_leaf_bitmaps[2].set_pixel(5, 4, brightOrange)
    @autumn_leaf_bitmaps[2].set_pixel(6, 4, orangeBrown)
    @autumn_leaf_bitmaps[2].fill_rect(2, 5, 2, 1, paleOrange)
    @autumn_leaf_bitmaps[2].set_pixel(4, 5, brightOrange)
    @autumn_leaf_bitmaps[2].set_pixel(5, 5, orangeBrown)
    @autumn_leaf_bitmaps[2].set_pixel(1, 6, paleOrange)
    @autumn_leaf_bitmaps[2].fill_rect(2, 6, 2, 1, brightOrange)
    @autumn_leaf_bitmaps[2].set_pixel(4, 6, orangeBrown)
    @autumn_leaf_bitmaps[2].set_pixel(0, 7, paleOrange)
    @autumn_leaf_bitmaps[2].set_pixel(1, 7, brightOrange)
    @autumn_leaf_bitmaps[2].set_pixel(2, 7, orangeBrown)
   
    # draw the 4th of the leaf1 bitmaps
    @autumn_leaf_bitmaps.push(Bitmap.new(8, 8))
    @autumn_leaf_bitmaps[3].set_pixel(3, 0, brightOrange)
    @autumn_leaf_bitmaps[3].set_pixel(7, 0, brightOrange)
    @autumn_leaf_bitmaps[3].set_pixel(3, 1, orangeBrown)
    @autumn_leaf_bitmaps[3].set_pixel(4, 1, burntRed)
    @autumn_leaf_bitmaps[3].set_pixel(6, 1, brightOrange)
    @autumn_leaf_bitmaps[3].set_pixel(0, 2, paleOrange)
    @autumn_leaf_bitmaps[3].set_pixel(1, 2, brightOrange)
    @autumn_leaf_bitmaps[3].set_pixel(2, 2, orangeBrown)
    @autumn_leaf_bitmaps[3].set_pixel(3, 2, burntRed)
    @autumn_leaf_bitmaps[3].set_pixel(4, 2, orangeBrown)
    @autumn_leaf_bitmaps[3].set_pixel(5, 2, brightOrange)
    @autumn_leaf_bitmaps[3].fill_rect(1, 3, 3, 1, orangeBrown)
    @autumn_leaf_bitmaps[3].fill_rect(4, 3, 2, 1, brightOrange)
    @autumn_leaf_bitmaps[3].set_pixel(6, 3, orangeBrown)
    @autumn_leaf_bitmaps[3].set_pixel(2, 4, burntRed)
    @autumn_leaf_bitmaps[3].fill_rect(3, 4, 3, 1, brightOrange)
    @autumn_leaf_bitmaps[3].set_pixel(6, 4, burntRed)
    @autumn_leaf_bitmaps[3].set_pixel(7, 4, darkBrown)
    @autumn_leaf_bitmaps[3].set_pixel(1, 5, orangeBrown)
    @autumn_leaf_bitmaps[3].fill_rect(2, 5, 2, 1, brightOrange)
    @autumn_leaf_bitmaps[3].set_pixel(4, 5, orangeBrown)
    @autumn_leaf_bitmaps[3].set_pixel(5, 5, burntRed)
    @autumn_leaf_bitmaps[3].fill_rect(1, 6, 2, 1, brightOrange)
    @autumn_leaf_bitmaps[3].fill_rect(4, 6, 2, 1, burntRed)
    @autumn_leaf_bitmaps[3].set_pixel(0, 7, brightOrange)
    @autumn_leaf_bitmaps[3].set_pixel(5, 7, darkBrown)
   
#-------------------------------------------------------------------------------

    # Red maple leaves
   
    @redmaple_leaf_bitmaps = []
    brightRed = Color.new(255, 0, 0, 255)
    midRed    = Color.new(179, 17, 17, 255)
    darkRed   = Color.new(141, 9, 9, 255)
   
    @redmaple_leaf_bitmaps.push(Bitmap.new(8, 8))
    # draw the first of the red maple leaves bitmaps
    @redmaple_leaf_bitmaps[0].set_pixel(5, 1, darkRed)
    @redmaple_leaf_bitmaps[0].set_pixel(6, 1, brightRed)
    @redmaple_leaf_bitmaps[0].set_pixel(7, 1, midRed)
    @redmaple_leaf_bitmaps[0].set_pixel(3, 2, darkRed)
    @redmaple_leaf_bitmaps[0].fill_rect(4, 2, 2, 1, brightRed)
    @redmaple_leaf_bitmaps[0].set_pixel(6, 2, midRed)
    @redmaple_leaf_bitmaps[0].set_pixel(2, 3, darkRed)
    @redmaple_leaf_bitmaps[0].set_pixel(3, 3, brightRed)
    @redmaple_leaf_bitmaps[0].fill_rect(4, 3, 2, 1, midRed)
    @redmaple_leaf_bitmaps[0].set_pixel(1, 4, brightRed)
    @redmaple_leaf_bitmaps[0].set_pixel(2, 4, brightRed)
    @redmaple_leaf_bitmaps[0].set_pixel(3, 4, midRed)
    @redmaple_leaf_bitmaps[0].set_pixel(1, 5, brightRed)
    @redmaple_leaf_bitmaps[0].set_pixel(2, 5, midRed)
    @redmaple_leaf_bitmaps[0].set_pixel(0, 6, darkRed)
    @redmaple_leaf_bitmaps[0].set_pixel(1, 6, midRed)
    @redmaple_leaf_bitmaps[0].set_pixel(0, 7, midRed)
   
    # draw the 2nd of the red maple leaves bitmaps
    @redmaple_leaf_bitmaps.push(Bitmap.new(8, 8))
    @redmaple_leaf_bitmaps[1].set_pixel(3, 0, brightRed)
    @redmaple_leaf_bitmaps[1].set_pixel(7, 0, brightRed)
    @redmaple_leaf_bitmaps[1].set_pixel(3, 1, darkRed)
    @redmaple_leaf_bitmaps[1].set_pixel(4, 1, burntRed)
    @redmaple_leaf_bitmaps[1].set_pixel(6, 1, brightRed)
    @redmaple_leaf_bitmaps[1].set_pixel(0, 2, midRed)
    @redmaple_leaf_bitmaps[1].set_pixel(1, 2, brightRed)
    @redmaple_leaf_bitmaps[1].set_pixel(2, 2, darkRed)
    @redmaple_leaf_bitmaps[1].set_pixel(3, 2, burntRed)
    @redmaple_leaf_bitmaps[1].set_pixel(4, 2, darkRed)
    @redmaple_leaf_bitmaps[1].set_pixel(5, 2, brightRed)
    @redmaple_leaf_bitmaps[1].fill_rect(1, 3, 3, 1, darkRed)
    @redmaple_leaf_bitmaps[1].fill_rect(4, 3, 2, 1, brightRed)
    @redmaple_leaf_bitmaps[1].set_pixel(6, 3, darkRed)
    @redmaple_leaf_bitmaps[1].set_pixel(2, 4, burntRed)
    @redmaple_leaf_bitmaps[1].fill_rect(3, 4, 3, 1, brightRed)
    @redmaple_leaf_bitmaps[1].set_pixel(6, 4, burntRed)
    @redmaple_leaf_bitmaps[1].set_pixel(7, 4, darkRed)
    @redmaple_leaf_bitmaps[1].set_pixel(1, 5, darkRed)
    @redmaple_leaf_bitmaps[1].fill_rect(2, 5, 2, 1, brightRed)
    @redmaple_leaf_bitmaps[1].set_pixel(4, 5, darkRed)
    @redmaple_leaf_bitmaps[1].set_pixel(5, 5, burntRed)
    @redmaple_leaf_bitmaps[1].fill_rect(1, 6, 2, 1, brightRed)
    @redmaple_leaf_bitmaps[1].fill_rect(4, 6, 2, 1, burntRed)
    @redmaple_leaf_bitmaps[1].set_pixel(0, 7, brightRed)
    @autumn_leaf_bitmaps[1].set_pixel(5, 7, darkRed)
   
    # draw the 3rd of the red maple leaves bitmaps
    @redmaple_leaf_bitmaps.push(Bitmap.new(8, 8))
    @redmaple_leaf_bitmaps[2].set_pixel(7, 1, midRed)
    @redmaple_leaf_bitmaps[2].set_pixel(6, 2, midRed)
    @redmaple_leaf_bitmaps[2].set_pixel(7, 2, darkRed)
    @redmaple_leaf_bitmaps[2].set_pixel(5, 3, midRed)
    @redmaple_leaf_bitmaps[2].set_pixel(6, 3, brightRed)
    @redmaple_leaf_bitmaps[2].set_pixel(4, 4, midRed)
    @redmaple_leaf_bitmaps[2].set_pixel(5, 4, brightRed)
    @redmaple_leaf_bitmaps[2].set_pixel(6, 4, darkRed)
    @redmaple_leaf_bitmaps[2].fill_rect(2, 5, 2, 1, midRed)
    @redmaple_leaf_bitmaps[2].set_pixel(4, 5, brightRed)
    @redmaple_leaf_bitmaps[2].set_pixel(5, 5, darkRed)
    @redmaple_leaf_bitmaps[2].set_pixel(1, 6, midRed)
    @redmaple_leaf_bitmaps[2].fill_rect(2, 6, 2, 1, brightRed)
    @redmaple_leaf_bitmaps[2].set_pixel(4, 6, darkRed)
    @redmaple_leaf_bitmaps[2].set_pixel(0, 7, midRed)
    @redmaple_leaf_bitmaps[2].set_pixel(1, 7, brightRed)
    @redmaple_leaf_bitmaps[2].set_pixel(2, 7, darkRed)
   
    # draw the 4th of the red maple leaves bitmaps
    @redmaple_leaf_bitmaps.push(Bitmap.new(8, 8))
    @redmaple_leaf_bitmaps[3].set_pixel(3, 0, brightRed)
    @redmaple_leaf_bitmaps[3].set_pixel(7, 0, brightRed)
    @redmaple_leaf_bitmaps[3].set_pixel(3, 1, darkRed)
    @redmaple_leaf_bitmaps[3].set_pixel(4, 1, burntRed)
    @redmaple_leaf_bitmaps[3].set_pixel(6, 1, brightRed)
    @redmaple_leaf_bitmaps[3].set_pixel(0, 2, midRed)
    @redmaple_leaf_bitmaps[3].set_pixel(1, 2, brightRed)
    @redmaple_leaf_bitmaps[3].set_pixel(2, 2, darkRed)
    @redmaple_leaf_bitmaps[3].set_pixel(3, 2, burntRed)
    @redmaple_leaf_bitmaps[3].set_pixel(4, 2, darkRed)
    @redmaple_leaf_bitmaps[3].set_pixel(5, 2, brightRed)
    @redmaple_leaf_bitmaps[3].fill_rect(1, 3, 3, 1, darkRed)
    @redmaple_leaf_bitmaps[3].fill_rect(4, 3, 2, 1, brightRed)
    @redmaple_leaf_bitmaps[3].set_pixel(6, 3, darkRed)
    @redmaple_leaf_bitmaps[3].set_pixel(2, 4, burntRed)
    @redmaple_leaf_bitmaps[3].fill_rect(3, 4, 3, 1, brightRed)
    @redmaple_leaf_bitmaps[3].set_pixel(6, 4, burntRed)
    @redmaple_leaf_bitmaps[3].set_pixel(7, 4, darkRed)
    @redmaple_leaf_bitmaps[3].set_pixel(1, 5, darkRed)
    @redmaple_leaf_bitmaps[3].fill_rect(2, 5, 2, 1, brightRed)
    @redmaple_leaf_bitmaps[3].set_pixel(4, 5, darkRed)
    @redmaple_leaf_bitmaps[3].set_pixel(5, 5, burntRed)
    @redmaple_leaf_bitmaps[3].fill_rect(1, 6, 2, 1, brightRed)
    @redmaple_leaf_bitmaps[3].fill_rect(4, 6, 2, 1, burntRed)
    @redmaple_leaf_bitmaps[3].set_pixel(0, 7, brightRed)
    @redmaple_leaf_bitmaps[3].set_pixel(5, 7, darkRed)
#-------------------------------------------------------------------------------   
    #Green leaves

    @green_leaf_bitmaps = []
    darkGreen  = Color.new(62, 76, 31, 255)
    midGreen   = Color.new(76, 91, 43, 255)
    khaki      = Color.new(105, 114, 66, 255)
    lightGreen = Color.new(128, 136, 88, 255)
    mint       = Color.new(146, 154, 106, 255)
   
    # 1st leaf bitmap
    @green_leaf_bitmaps[0] = Bitmap.new(8, 8)
    @green_leaf_bitmaps[0].set_pixel(1, 0, darkGreen)
    @green_leaf_bitmaps[0].set_pixel(1, 1, midGreen)
    @green_leaf_bitmaps[0].set_pixel(2, 1, darkGreen)
    @green_leaf_bitmaps[0].set_pixel(2, 2, khaki)
    @green_leaf_bitmaps[0].set_pixel(3, 2, darkGreen)
    @green_leaf_bitmaps[0].set_pixel(4, 2, khaki)
    @green_leaf_bitmaps[0].fill_rect(2, 3, 3, 1, midGreen)
    @green_leaf_bitmaps[0].set_pixel(5, 3, khaki)
    @green_leaf_bitmaps[0].fill_rect(2, 4, 2, 1, midGreen)
    @green_leaf_bitmaps[0].set_pixel(4, 4, darkGreen)
    @green_leaf_bitmaps[0].set_pixel(5, 4, lightGreen)
    @green_leaf_bitmaps[0].set_pixel(6, 4, khaki)
    @green_leaf_bitmaps[0].set_pixel(3, 5, midGreen)
    @green_leaf_bitmaps[0].set_pixel(4, 5, darkGreen)
    @green_leaf_bitmaps[0].set_pixel(5, 5, khaki)
    @green_leaf_bitmaps[0].set_pixel(6, 5, lightGreen)
    @green_leaf_bitmaps[0].set_pixel(4, 6, midGreen)
    @green_leaf_bitmaps[0].set_pixel(5, 6, darkGreen)
    @green_leaf_bitmaps[0].set_pixel(6, 6, lightGreen)
    @green_leaf_bitmaps[0].set_pixel(6, 7, khaki)
   
    # 2nd leaf bitmap
    @green_leaf_bitmaps[1] = Bitmap.new(8, 8)
    @green_leaf_bitmaps[1].fill_rect(1, 1, 1, 2, midGreen)
    @green_leaf_bitmaps[1].fill_rect(2, 2, 2, 1, khaki)
    @green_leaf_bitmaps[1].set_pixel(4, 2, lightGreen)
    @green_leaf_bitmaps[1].fill_rect(2, 3, 2, 1, darkGreen)
    @green_leaf_bitmaps[1].fill_rect(4, 3, 2, 1, lightGreen)
    @green_leaf_bitmaps[1].set_pixel(2, 4, midGreen)
    @green_leaf_bitmaps[1].set_pixel(3, 4, darkGreen)
    @green_leaf_bitmaps[1].set_pixel(4, 4, khaki)
    @green_leaf_bitmaps[1].fill_rect(5, 4, 2, 1, lightGreen)
    @green_leaf_bitmaps[1].set_pixel(3, 5, midGreen)
    @green_leaf_bitmaps[1].set_pixel(4, 5, darkGreen)
    @green_leaf_bitmaps[1].set_pixel(5, 5, khaki)
    @green_leaf_bitmaps[1].set_pixel(6, 5, lightGreen)
    @green_leaf_bitmaps[1].set_pixel(5, 6, darkGreen)
    @green_leaf_bitmaps[1].fill_rect(6, 6, 2, 1, khaki)
   
    # 3rd leaf bitmap
    @green_leaf_bitmaps[2] = Bitmap.new(8, 8)
    @green_leaf_bitmaps[2].set_pixel(1, 1, darkGreen)
    @green_leaf_bitmaps[2].fill_rect(1, 2, 2, 1, midGreen)
    @green_leaf_bitmaps[2].set_pixel(2, 3, midGreen)
    @green_leaf_bitmaps[2].set_pixel(3, 3, darkGreen)
    @green_leaf_bitmaps[2].set_pixel(4, 3, midGreen)
    @green_leaf_bitmaps[2].fill_rect(2, 4, 2, 1, midGreen)
    @green_leaf_bitmaps[2].set_pixel(4, 4, darkGreen)
    @green_leaf_bitmaps[2].set_pixel(5, 4, lightGreen)
    @green_leaf_bitmaps[2].set_pixel(3, 5, midGreen)
    @green_leaf_bitmaps[2].set_pixel(4, 5, darkGreen)
    @green_leaf_bitmaps[2].fill_rect(5, 5, 2, 1, khaki)
    @green_leaf_bitmaps[2].fill_rect(4, 6, 2, 1, midGreen)
    @green_leaf_bitmaps[2].set_pixel(6, 6, lightGreen)
    @green_leaf_bitmaps[2].set_pixel(6, 7, khaki)
   
    # 4th leaf bitmap
    @green_leaf_bitmaps[3] = Bitmap.new(8, 8)
    @green_leaf_bitmaps[3].fill_rect(0, 3, 1, 2, darkGreen)
    @green_leaf_bitmaps[3].set_pixel(1, 4, midGreen)
    @green_leaf_bitmaps[3].set_pixel(2, 4, khaki)
    @green_leaf_bitmaps[3].set_pixel(3, 4, lightGreen)
    @green_leaf_bitmaps[3].set_pixel(4, 4, darkGreen)
    @green_leaf_bitmaps[3].set_pixel(7, 4, midGreen)
    @green_leaf_bitmaps[3].set_pixel(1, 5, darkGreen)
    @green_leaf_bitmaps[3].set_pixel(2, 5, midGreen)
    @green_leaf_bitmaps[3].set_pixel(3, 5, lightGreen)
    @green_leaf_bitmaps[3].set_pixel(4, 5, mint)
    @green_leaf_bitmaps[3].set_pixel(5, 5, lightGreen)
    @green_leaf_bitmaps[3].set_pixel(6, 5, khaki)
    @green_leaf_bitmaps[3].set_pixel(7, 5, midGreen)
    @green_leaf_bitmaps[3].fill_rect(2, 6, 2, 1, midGreen)
    @green_leaf_bitmaps[3].set_pixel(4, 6, lightGreen)
    @green_leaf_bitmaps[3].set_pixel(5, 6, khaki)
    @green_leaf_bitmaps[3].set_pixel(6, 6, midGreen)
   
    # 5th leaf bitmap
    @green_leaf_bitmaps[4] = Bitmap.new(8, 8)
    @green_leaf_bitmaps[4].set_pixel(6, 2, midGreen)
    @green_leaf_bitmaps[4].set_pixel(7, 2, darkGreen)
    @green_leaf_bitmaps[4].fill_rect(4, 3, 2, 1, midGreen)
    @green_leaf_bitmaps[4].set_pixel(6, 3, khaki)
    @green_leaf_bitmaps[4].set_pixel(2, 4, darkGreen)
    @green_leaf_bitmaps[4].fill_rect(3, 4, 2, 1, khaki)
    @green_leaf_bitmaps[4].set_pixel(5, 4, lightGreen)
    @green_leaf_bitmaps[4].set_pixel(6, 4, khaki)
    @green_leaf_bitmaps[4].set_pixel(1, 5, midGreen)
    @green_leaf_bitmaps[4].set_pixel(2, 5, khaki)
    @green_leaf_bitmaps[4].set_pixel(3, 5, lightGreen)
    @green_leaf_bitmaps[4].set_pixel(4, 5, mint)
    @green_leaf_bitmaps[4].set_pixel(5, 5, midGreen)
    @green_leaf_bitmaps[4].set_pixel(2, 6, darkGreen)
    @green_leaf_bitmaps[4].fill_rect(3, 6, 2, 1, midGreen)
   
    # 6th leaf bitmap
    @green_leaf_bitmaps[5] = Bitmap.new(8, 8)
    @green_leaf_bitmaps[5].fill_rect(6, 2, 2, 1, midGreen)
    @green_leaf_bitmaps[5].fill_rect(4, 3, 2, 1, midGreen)
    @green_leaf_bitmaps[5].set_pixel(6, 3, khaki)
    @green_leaf_bitmaps[5].set_pixel(3, 4, midGreen)
    @green_leaf_bitmaps[5].set_pixel(4, 4, khaki)
    @green_leaf_bitmaps[5].set_pixel(5, 4, lightGreen)
    @green_leaf_bitmaps[5].set_pixel(6, 4, mint)
    @green_leaf_bitmaps[5].set_pixel(1, 5, midGreen)
    @green_leaf_bitmaps[5].set_pixel(2, 5, khaki)
    @green_leaf_bitmaps[5].fill_rect(3, 5, 2, 1, mint)
    @green_leaf_bitmaps[5].set_pixel(5, 5, lightGreen)
    @green_leaf_bitmaps[5].set_pixel(2, 6, midGreen)
    @green_leaf_bitmaps[5].set_pixel(3, 6, khaki)
    @green_leaf_bitmaps[5].set_pixel(4, 6, lightGreen)
   
    # 7th leaf bitmap
    @green_leaf_bitmaps[6] = Bitmap.new(8, 8)
    @green_leaf_bitmaps[6].fill_rect(6, 1, 1, 2, midGreen)
    @green_leaf_bitmaps[6].fill_rect(4, 2, 2, 1, midGreen)
    @green_leaf_bitmaps[6].fill_rect(6, 2, 1, 2, darkGreen)
    @green_leaf_bitmaps[6].fill_rect(3, 3, 2, 1, midGreen)
    @green_leaf_bitmaps[6].set_pixel(5, 3, khaki)
    @green_leaf_bitmaps[6].set_pixel(2, 4, midGreen)
    @green_leaf_bitmaps[6].set_pixel(3, 4, khaki)
    @green_leaf_bitmaps[6].set_pixel(4, 4, lightGreen)
    @green_leaf_bitmaps[6].set_pixel(5, 4, midGreen)
    @green_leaf_bitmaps[6].set_pixel(1, 5, midGreen)
    @green_leaf_bitmaps[6].set_pixel(2, 5, khaki)
    @green_leaf_bitmaps[6].fill_rect(3, 5, 2, 1, midGreen)
    @green_leaf_bitmaps[6].set_pixel(1, 6, darkGreen)
    @green_leaf_bitmaps[6].set_pixel(2, 6, midGreen)
   
    # 8th leaf bitmap
    @green_leaf_bitmaps[7] = Bitmap.new(8, 8)
    @green_leaf_bitmaps[7].set_pixel(6, 1, midGreen)
    @green_leaf_bitmaps[7].fill_rect(4, 2, 3, 2, midGreen)
    @green_leaf_bitmaps[7].set_pixel(3, 3, darkGreen)
    @green_leaf_bitmaps[7].set_pixel(2, 4, darkGreen)
    @green_leaf_bitmaps[7].set_pixel(3, 4, midGreen)
    @green_leaf_bitmaps[7].fill_rect(4, 4, 2, 1, khaki)
    @green_leaf_bitmaps[7].set_pixel(1, 5, darkGreen)
    @green_leaf_bitmaps[7].set_pixel(2, 5, midGreen)
    @green_leaf_bitmaps[7].fill_rect(3, 5, 2, 1, lightGreen)
    @green_leaf_bitmaps[7].set_pixel(2, 6, midGreen)
    @green_leaf_bitmaps[7].set_pixel(3, 6, lightGreen)
   
    # 9th leaf bitmap
    @green_leaf_bitmaps[8] = Bitmap.new(8, 8)
    @green_leaf_bitmaps[8].fill_rect(6, 1, 1, 2, midGreen)
    @green_leaf_bitmaps[8].fill_rect(4, 2, 2, 1, midGreen)
    @green_leaf_bitmaps[8].fill_rect(6, 2, 1, 2, darkGreen)
    @green_leaf_bitmaps[8].fill_rect(3, 3, 2, 1, midGreen)
    @green_leaf_bitmaps[8].set_pixel(5, 3, khaki)
    @green_leaf_bitmaps[8].set_pixel(2, 4, midGreen)
    @green_leaf_bitmaps[8].set_pixel(3, 4, khaki)
    @green_leaf_bitmaps[8].set_pixel(4, 4, lightGreen)
    @green_leaf_bitmaps[8].set_pixel(5, 4, midGreen)
    @green_leaf_bitmaps[8].set_pixel(1, 5, midGreen)
    @green_leaf_bitmaps[8].set_pixel(2, 5, khaki)
    @green_leaf_bitmaps[8].fill_rect(3, 5, 2, 1, midGreen)
    @green_leaf_bitmaps[8].set_pixel(1, 6, darkGreen)
    @green_leaf_bitmaps[8].set_pixel(2, 6, midGreen)
   
    # 10th leaf bitmap
    @green_leaf_bitmaps[9] = Bitmap.new(8, 8)
    @green_leaf_bitmaps[9].fill_rect(6, 2, 2, 1, midGreen)
    @green_leaf_bitmaps[9].fill_rect(4, 3, 2, 1, midGreen)
    @green_leaf_bitmaps[9].set_pixel(6, 3, khaki)
    @green_leaf_bitmaps[9].set_pixel(3, 4, midGreen)
    @green_leaf_bitmaps[9].set_pixel(4, 4, khaki)
    @green_leaf_bitmaps[9].set_pixel(5, 4, lightGreen)
    @green_leaf_bitmaps[9].set_pixel(6, 4, mint)
    @green_leaf_bitmaps[9].set_pixel(1, 5, midGreen)
    @green_leaf_bitmaps[9].set_pixel(2, 5, khaki)
    @green_leaf_bitmaps[9].fill_rect(3, 5, 2, 1, mint)
    @green_leaf_bitmaps[9].set_pixel(5, 5, lightGreen)
    @green_leaf_bitmaps[9].set_pixel(2, 6, midGreen)
    @green_leaf_bitmaps[9].set_pixel(3, 6, khaki)
    @green_leaf_bitmaps[9].set_pixel(4, 6, lightGreen)
   
    # 11th leaf bitmap
    @green_leaf_bitmaps[10] = Bitmap.new(8, 8)
    @green_leaf_bitmaps[10].set_pixel(6, 2, midGreen)
    @green_leaf_bitmaps[10].set_pixel(7, 2, darkGreen)
    @green_leaf_bitmaps[10].fill_rect(4, 3, 2, 1, midGreen)
    @green_leaf_bitmaps[10].set_pixel(6, 3, khaki)
    @green_leaf_bitmaps[10].set_pixel(2, 4, darkGreen)
    @green_leaf_bitmaps[10].fill_rect(3, 4, 2, 1, khaki)
    @green_leaf_bitmaps[10].set_pixel(5, 4, lightGreen)
    @green_leaf_bitmaps[10].set_pixel(6, 4, khaki)
    @green_leaf_bitmaps[10].set_pixel(1, 5, midGreen)
    @green_leaf_bitmaps[10].set_pixel(2, 5, khaki)
    @green_leaf_bitmaps[10].set_pixel(3, 5, lightGreen)
    @green_leaf_bitmaps[10].set_pixel(4, 5, mint)
    @green_leaf_bitmaps[10].set_pixel(5, 5, midGreen)
    @green_leaf_bitmaps[10].set_pixel(2, 6, darkGreen)
    @green_leaf_bitmaps[10].fill_rect(3, 6, 2, 1, midGreen)
   
    # 12th leaf bitmap
    @green_leaf_bitmaps[11] = Bitmap.new(8, 8)
    @green_leaf_bitmaps[11].fill_rect(0, 3, 1, 2, darkGreen)
    @green_leaf_bitmaps[11].set_pixel(1, 4, midGreen)
    @green_leaf_bitmaps[11].set_pixel(2, 4, khaki)
    @green_leaf_bitmaps[11].set_pixel(3, 4, lightGreen)
    @green_leaf_bitmaps[11].set_pixel(4, 4, darkGreen)
    @green_leaf_bitmaps[11].set_pixel(7, 4, midGreen)
    @green_leaf_bitmaps[11].set_pixel(1, 5, darkGreen)
    @green_leaf_bitmaps[11].set_pixel(2, 5, midGreen)
    @green_leaf_bitmaps[11].set_pixel(3, 5, lightGreen)
    @green_leaf_bitmaps[11].set_pixel(4, 5, mint)
    @green_leaf_bitmaps[11].set_pixel(5, 5, lightGreen)
    @green_leaf_bitmaps[11].set_pixel(6, 5, khaki)
    @green_leaf_bitmaps[11].set_pixel(7, 5, midGreen)
    @green_leaf_bitmaps[11].fill_rect(2, 6, 2, 1, midGreen)
    @green_leaf_bitmaps[11].set_pixel(4, 6, lightGreen)
    @green_leaf_bitmaps[11].set_pixel(5, 6, khaki)
    @green_leaf_bitmaps[11].set_pixel(6, 6, midGreen)
   
    # 13th leaf bitmap
    @green_leaf_bitmaps[12] = Bitmap.new(8, 8)
    @green_leaf_bitmaps[12].set_pixel(1, 1, darkGreen)
    @green_leaf_bitmaps[12].fill_rect(1, 2, 2, 1, midGreen)
    @green_leaf_bitmaps[12].set_pixel(2, 3, midGreen)
    @green_leaf_bitmaps[12].set_pixel(3, 3, darkGreen)
    @green_leaf_bitmaps[12].set_pixel(4, 3, midGreen)
    @green_leaf_bitmaps[12].fill_rect(2, 4, 2, 1, midGreen)
    @green_leaf_bitmaps[12].set_pixel(4, 4, darkGreen)
    @green_leaf_bitmaps[12].set_pixel(5, 4, lightGreen)
    @green_leaf_bitmaps[12].set_pixel(3, 5, midGreen)
    @green_leaf_bitmaps[12].set_pixel(4, 5, darkGreen)
    @green_leaf_bitmaps[12].fill_rect(5, 5, 2, 1, khaki)
    @green_leaf_bitmaps[12].fill_rect(4, 6, 2, 1, midGreen)
    @green_leaf_bitmaps[12].set_pixel(6, 6, lightGreen)
    @green_leaf_bitmaps[12].set_pixel(6, 7, khaki)
#-------------------------------------------------------------------------------   
    #rose petals

    @rose_bitmaps = []
   
    # 1st rose petal bitmap
    @rose_bitmaps[0] = Bitmap.new(3, 3)
    @rose_bitmaps[0].fill_rect(1, 0, 2, 1, brightRed)
    @rose_bitmaps[0].fill_rect(0, 1, 1, 2, brightRed)
    @rose_bitmaps[0].fill_rect(1, 1, 2, 2, midRed)
    @rose_bitmaps[0].set_pixel(2, 2, darkRed)
   
    # 2nd rose petal bitmap
    @rose_bitmaps[1] = Bitmap.new(3, 3)
    @rose_bitmaps[1].set_pixel(0, 1, midRed)
    @rose_bitmaps[1].set_pixel(1, 1, brightRed)
    @rose_bitmaps[1].fill_rect(1, 2, 1, 2, midRed)
#-------------------------------------------------------------------------------   
    #Feathers

    @feather_bitmaps = []
    white = Color.new(255, 255, 255, 255)
   
    # 1st feather bitmap
    @feather_bitmaps[0] = Bitmap.new(3, 3)
    @feather_bitmaps[0].set_pixel(0, 2, white)
    @feather_bitmaps[0].set_pixel(1, 2, grey)
    @feather_bitmaps[0].set_pixel(2, 1, grey)
   
    # 2nd feather bitmap
    @feather_bitmaps[0] = Bitmap.new(3, 3)
    @feather_bitmaps[0].set_pixel(0, 0, white)
    @feather_bitmaps[0].set_pixel(0, 1, grey)
    @feather_bitmaps[0].set_pixel(1, 2, grey)
   
    # 3rd feather bitmap
    @feather_bitmaps[0] = Bitmap.new(3, 3)
    @feather_bitmaps[0].set_pixel(2, 0, white)
    @feather_bitmaps[0].set_pixel(1, 0, grey)
    @feather_bitmaps[0].set_pixel(0, 1, grey)
   
    # 4th feather bitmap
    @feather_bitmaps[0] = Bitmap.new(3, 3)
    @feather_bitmaps[0].set_pixel(2, 2, white)
    @feather_bitmaps[0].set_pixel(2, 1, grey)
    @feather_bitmaps[0].set_pixel(1, 0, grey)
#-------------------------------------------------------------------------------   
    #Blood rain
   
    @blood_rain_bitmap = Bitmap.new(7, 56)
    for i in 0..6
      @blood_rain_bitmap.fill_rect(6-i, i*8, 1, 8, darkRed)
    end
    @blood_rain_splash = Bitmap.new(8, 5)
    @blood_rain_splash.fill_rect(1, 0, 6, 1, darkRed)
    @blood_rain_splash.fill_rect(1, 4, 6, 1, darkRed)
    @blood_rain_splash.fill_rect(0, 1, 1, 3, darkRed)
    @blood_rain_splash.fill_rect(7, 1, 1, 3, darkRed)
#-------------------------------------------------------------------------------

    #Blood storm
   
    @blood_storm_bitmap = Bitmap.new(34, 64)
    for i in 0..31
      @blood_storm_bitmap.fill_rect(33-i, i*2, 1, 2, darkRed)
      @blood_storm_bitmap.fill_rect(32-i, i*2, 1, 2, darkRed)
      @blood_storm_bitmap.fill_rect(31-i, i*2, 1, 2, darkRed)
    end
   
#-------------------------------------------------------------------------------
    #Blood blizzard

    @bloodblizz_bitmap = Bitmap.new(6, 6)
    @bloodblizz_bitmap.fill_rect(0, 1, 6, 4, midRed)
    @bloodblizz_bitmap.fill_rect(1, 0, 4, 6, midRed)
    @bloodblizz_bitmap.fill_rect(1, 2, 4, 2, darkRed)
    @bloodblizz_bitmap.fill_rect(2, 1, 2, 4, darkRed)
    @sprites = []   
    @bloodblizz_bitmaps = []
   
    @bloodblizz_bitmaps[0] = Bitmap.new(3, 3)
    @bloodblizz_bitmaps[0].fill_rect(0, 0, 3, 3, midRed)
    @bloodblizz_bitmaps[0].fill_rect(0, 1, 3, 1, darkRed)
    @bloodblizz_bitmaps[0].fill_rect(1, 0, 1, 3, darkRed)
    @bloodblizz_bitmaps[0].set_pixel(1, 1, darkRed)
   
    @bloodblizz_bitmaps[1] = Bitmap.new(4, 4)
    @bloodblizz_bitmaps[1].fill_rect(0, 1, 4, 2, midRed)
    @bloodblizz_bitmaps[1].fill_rect(1, 0, 2, 4, midRed)
    @bloodblizz_bitmaps[1].fill_rect(1, 1, 2, 2, darkRed)
   
    @bloodblizz_bitmaps[2] = Bitmap.new(5, 5)
    @bloodblizz_bitmaps[1].fill_rect(0, 1, 5, 3, darkRed)
    @bloodblizz_bitmaps[1].fill_rect(1, 0, 3, 5, darkRed)
    @bloodblizz_bitmaps[1].fill_rect(1, 1, 3, 3, midRed)
    @bloodblizz_bitmaps[1].fill_rect(2, 1, 3, 1, darkRed)
    @bloodblizz_bitmaps[1].fill_rect(1, 2, 1, 3, darkRed)
   
    @bloodblizz_bitmaps[3] = Bitmap.new(7, 7)
    @bloodblizz_bitmaps[1].fill_rect(1, 1, 5, 5, darkRed)
    @bloodblizz_bitmaps[1].fill_rect(2, 0, 7, 3, darkRed)
    @bloodblizz_bitmaps[1].fill_rect(0, 2, 3, 7, darkRed)
    @bloodblizz_bitmaps[1].fill_rect(2, 1, 5, 3, midRed)
    @bloodblizz_bitmaps[1].fill_rect(1, 2, 3, 5, midRed)
    @bloodblizz_bitmaps[1].fill_rect(2, 2, 3, 3, darkRed)
    @bloodblizz_bitmaps[1].fill_rect(3, 1, 5, 1, darkRed)
    @bloodblizz_bitmaps[1].fill_rect(1, 3, 1, 5, darkRed)
#-------------------------------------------------------------------------------  

    # Oil rain
   
    darkgrey = Color.new(15, 15, 15, 255)
    black = Color.new(0, 0, 0, 255)
   
    @oil_rain_bitmap = Bitmap.new(7, 56)
    for i in 0..6
    @oil_rain_bitmap.fill_rect(6-i, i*8, 1, 8, darkgrey)
      end
    @oil_rain_splash = Bitmap.new(8, 5)
    @oil_rain_splash.fill_rect(1, 0, 6, 1, darkgrey)
    @oil_rain_splash.fill_rect(1, 4, 6, 1, darkgrey)
    @oil_rain_splash.fill_rect(0, 1, 1, 3, black)
    @oil_rain_splash.fill_rect(7, 1, 1, 3, black)
#-------------------------------------------------------------------------------

    # Oil storm
   
      @oil_storm_bitmap = Bitmap.new(34, 64)
    for i in 0..31
      @oil_storm_bitmap.fill_rect(33-i, i*2, 1, 2, darkgrey)
      @oil_storm_bitmap.fill_rect(32-i, i*2, 1, 2, darkgrey)
      @oil_storm_bitmap.fill_rect(31-i, i*2, 1, 2, darkgrey)
    end
#-------------------------------------------------------------------------------

    # Golden rain
   
    darkYellow  = Color.new(110, 104, 3, 255)
    midYellow   = Color.new(205, 194, 23, 255)
    darkYellowtwo  = Color.new(186, 176, 14, 255)
    lightYellow = Color.new(218, 207, 36, 255)
    lightYellowtwo = Color.new(227, 217, 56, 255)   
   
    @golden_rain_bitmap = Bitmap.new(7, 56)
    for i in 0..6
    @golden_rain_bitmap.fill_rect(6-i, i*8, 1, 8, lightYellow)
      end
    @golden_rain_splash = Bitmap.new(8, 5)
    @golden_rain_splash.fill_rect(1, 0, 6, 1, lightYellow)
    @golden_rain_splash.fill_rect(1, 4, 6, 1, lightYellow)
    @golden_rain_splash.fill_rect(0, 1, 1, 3, lightYellow)
    @golden_rain_splash.fill_rect(7, 1, 1, 3, lightYellow)
#-------------------------------------------------------------------------------

     # Golden storm

      @golden_storm_bitmap = Bitmap.new(34, 64)
    for i in 0..31
      @golden_storm_bitmap.fill_rect(33-i, i*2, 1, 2, lightYellow)
      @golden_storm_bitmap.fill_rect(32-i, i*2, 1, 2, lightYellow)
      @golden_storm_bitmap.fill_rect(31-i, i*2, 1, 2, lightYellow)
    end
#-------------------------------------------------------------------------------

    # Acid rain
         
    @acid_rain_bitmap = Bitmap.new(7, 56)
    for i in 0..6
    @acid_rain_bitmap.fill_rect(6-i, i*8, 1, 8, midGreen)
      end
    @acid_rain_splash = Bitmap.new(8, 5)
    @acid_rain_splash.fill_rect(1, 0, 6, 1, white)
    @acid_rain_splash.fill_rect(1, 4, 6, 1, white)
    @acid_rain_splash.fill_rect(0, 1, 1, 3, white)
    @acid_rain_splash.fill_rect(7, 1, 1, 3, white)
#-------------------------------------------------------------------------------

     # Acid storm

      @acid_storm_bitmap = Bitmap.new(34, 64)
    for i in 0..31
      @acid_storm_bitmap.fill_rect(33-i, i*2, 1, 2, khaki)
      @acid_storm_bitmap.fill_rect(32-i, i*2, 1, 2, khaki)
      @acid_storm_bitmap.fill_rect(31-i, i*2, 1, 2, midGreen)
    end
#-------------------------------------------------------------------------------

    # Sepia rain
   
    sepia_color = Color.new(167, 149, 139, 255)
    sepia_colortwo = Color.new(100, 75, 63, 255)
   
    @sepia_rain_bitmap = Bitmap.new(7, 56)
    for i in 0..6
    @sepia_rain_bitmap.fill_rect(6-i, i*8, 1, 8, sepia_colortwo)
      end
    @sepia_rain_splash = Bitmap.new(8, 5)
    @sepia_rain_splash.fill_rect(1, 0, 6, 1, sepia_colortwo)
    @sepia_rain_splash.fill_rect(1, 4, 6, 1, sepia_color)
    @sepia_rain_splash.fill_rect(0, 1, 1, 3, sepia_colortwo)
    @sepia_rain_splash.fill_rect(7, 1, 1, 3, sepia_color)
#-------------------------------------------------------------------------------

     # Sepia storm

      @sepia_storm_bitmap = Bitmap.new(34, 64)
    for i in 0..31
      @sepia_storm_bitmap.fill_rect(33-i, i*2, 1, 2, sepia_colortwo)
      @sepia_storm_bitmap.fill_rect(32-i, i*2, 1, 2, sepia_colortwo)
      @sepia_storm_bitmap.fill_rect(31-i, i*2, 1, 2, sepia_color)
    end
#-------------------------------------------------------------------------------

    # Yellow leaves

    @yellow_leaf_bitmaps = []
   
   # 1st leaf bitmap
    @yellow_leaf_bitmaps[0] = Bitmap.new(8, 8)
    @yellow_leaf_bitmaps[0].set_pixel(1, 0, darkYellow)
    @yellow_leaf_bitmaps[0].set_pixel(1, 1, midYellow)
    @yellow_leaf_bitmaps[0].set_pixel(2, 1, darkYellow)
    @yellow_leaf_bitmaps[0].set_pixel(2, 2, darkYellowtwo)
    @yellow_leaf_bitmaps[0].set_pixel(3, 2, darkYellow)
    @yellow_leaf_bitmaps[0].set_pixel(4, 2, darkYellowtwo)
    @yellow_leaf_bitmaps[0].fill_rect(2, 3, 3, 1, midYellow)
    @yellow_leaf_bitmaps[0].set_pixel(5, 3, darkYellowtwo)
    @yellow_leaf_bitmaps[0].fill_rect(2, 4, 2, 1, midYellow)
    @yellow_leaf_bitmaps[0].set_pixel(4, 4, darkYellow)
    @yellow_leaf_bitmaps[0].set_pixel(5, 4, lightYellow)
    @yellow_leaf_bitmaps[0].set_pixel(6, 4, darkYellowtwo)
    @yellow_leaf_bitmaps[0].set_pixel(3, 5, midYellow)
    @yellow_leaf_bitmaps[0].set_pixel(4, 5, darkYellow)
    @yellow_leaf_bitmaps[0].set_pixel(5, 5, darkYellowtwo)
    @yellow_leaf_bitmaps[0].set_pixel(6, 5, lightYellow)
    @yellow_leaf_bitmaps[0].set_pixel(4, 6, midYellow)
    @yellow_leaf_bitmaps[0].set_pixel(5, 6, darkYellow)
    @yellow_leaf_bitmaps[0].set_pixel(6, 6, lightYellow)
    @yellow_leaf_bitmaps[0].set_pixel(6, 7, darkYellowtwo)
   
    # 2nd leaf bitmap
    @yellow_leaf_bitmaps[1] = Bitmap.new(8, 8)
    @yellow_leaf_bitmaps[1].fill_rect(1, 1, 1, 2, midYellow)
    @yellow_leaf_bitmaps[1].fill_rect(2, 2, 2, 1, darkYellowtwo)
    @yellow_leaf_bitmaps[1].set_pixel(4, 2, lightYellow)
    @yellow_leaf_bitmaps[1].fill_rect(2, 3, 2, 1, darkYellow)
    @yellow_leaf_bitmaps[1].fill_rect(4, 3, 2, 1, lightYellow)
    @yellow_leaf_bitmaps[1].set_pixel(2, 4, midYellow)
    @yellow_leaf_bitmaps[1].set_pixel(3, 4, darkYellow)
    @yellow_leaf_bitmaps[1].set_pixel(4, 4, darkYellowtwo)
    @yellow_leaf_bitmaps[1].fill_rect(5, 4, 2, 1, lightYellow)
    @yellow_leaf_bitmaps[1].set_pixel(3, 5, midYellow)
    @yellow_leaf_bitmaps[1].set_pixel(4, 5, darkYellow)
    @yellow_leaf_bitmaps[1].set_pixel(5, 5, darkYellowtwo)
    @yellow_leaf_bitmaps[1].set_pixel(6, 5, lightYellow)
    @yellow_leaf_bitmaps[1].set_pixel(5, 6, darkYellow)
    @yellow_leaf_bitmaps[1].fill_rect(6, 6, 2, 1, darkYellowtwo)
   
    # 3rd leaf bitmap
    @yellow_leaf_bitmaps[2] = Bitmap.new(8, 8)
    @yellow_leaf_bitmaps[2].set_pixel(1, 1, darkYellow)
    @yellow_leaf_bitmaps[2].fill_rect(1, 2, 2, 1, midYellow)
    @yellow_leaf_bitmaps[2].set_pixel(2, 3, midYellow)
    @yellow_leaf_bitmaps[2].set_pixel(3, 3, darkYellow)
    @yellow_leaf_bitmaps[2].set_pixel(4, 3, midYellow)
    @yellow_leaf_bitmaps[2].fill_rect(2, 4, 2, 1, midYellow)
    @yellow_leaf_bitmaps[2].set_pixel(4, 4, darkYellow)
    @yellow_leaf_bitmaps[2].set_pixel(5, 4, lightYellow)
    @yellow_leaf_bitmaps[2].set_pixel(3, 5, midYellow)
    @yellow_leaf_bitmaps[2].set_pixel(4, 5, darkYellow)
    @yellow_leaf_bitmaps[2].fill_rect(5, 5, 2, 1, darkYellowtwo)
    @yellow_leaf_bitmaps[2].fill_rect(4, 6, 2, 1, midYellow)
    @yellow_leaf_bitmaps[2].set_pixel(6, 6, lightYellow)
    @yellow_leaf_bitmaps[2].set_pixel(6, 7, darkYellowtwo)
   
    # 4th leaf bitmap
    @yellow_leaf_bitmaps[3] = Bitmap.new(8, 8)
    @yellow_leaf_bitmaps[3].fill_rect(0, 3, 1, 2, darkYellow)
    @yellow_leaf_bitmaps[3].set_pixel(1, 4, midYellow)
    @yellow_leaf_bitmaps[3].set_pixel(2, 4, darkYellowtwo)
    @yellow_leaf_bitmaps[3].set_pixel(3, 4, lightYellow)
    @yellow_leaf_bitmaps[3].set_pixel(4, 4, darkYellow)
    @yellow_leaf_bitmaps[3].set_pixel(7, 4, midYellow)
    @yellow_leaf_bitmaps[3].set_pixel(1, 5, darkYellow)
    @yellow_leaf_bitmaps[3].set_pixel(2, 5, midYellow)
    @yellow_leaf_bitmaps[3].set_pixel(3, 5, lightYellow)
    @yellow_leaf_bitmaps[3].set_pixel(4, 5, lightYellowtwo)
    @yellow_leaf_bitmaps[3].set_pixel(5, 5, lightYellow)
    @yellow_leaf_bitmaps[3].set_pixel(6, 5, darkYellowtwo)
    @yellow_leaf_bitmaps[3].set_pixel(7, 5, midYellow)
    @yellow_leaf_bitmaps[3].fill_rect(2, 6, 2, 1, midYellow)
    @yellow_leaf_bitmaps[3].set_pixel(4, 6, lightYellow)
    @yellow_leaf_bitmaps[3].set_pixel(5, 6, darkYellowtwo)
    @yellow_leaf_bitmaps[3].set_pixel(6, 6, midYellow)
   
    # 5th leaf bitmap
    @yellow_leaf_bitmaps[4] = Bitmap.new(8, 8)
    @yellow_leaf_bitmaps[4].set_pixel(6, 2, midYellow)
    @yellow_leaf_bitmaps[4].set_pixel(7, 2, darkYellow)
    @yellow_leaf_bitmaps[4].fill_rect(4, 3, 2, 1, midYellow)
    @yellow_leaf_bitmaps[4].set_pixel(6, 3, darkYellowtwo)
    @yellow_leaf_bitmaps[4].set_pixel(2, 4, darkYellow)
    @yellow_leaf_bitmaps[4].fill_rect(3, 4, 2, 1, darkYellowtwo)
    @yellow_leaf_bitmaps[4].set_pixel(5, 4, lightYellow)
    @yellow_leaf_bitmaps[4].set_pixel(6, 4, darkYellowtwo)
    @yellow_leaf_bitmaps[4].set_pixel(1, 5, midYellow)
    @yellow_leaf_bitmaps[4].set_pixel(2, 5, darkYellowtwo)
    @yellow_leaf_bitmaps[4].set_pixel(3, 5, lightYellow)
    @yellow_leaf_bitmaps[4].set_pixel(4, 5, lightYellowtwo)
    @yellow_leaf_bitmaps[4].set_pixel(5, 5, midYellow)
    @yellow_leaf_bitmaps[4].set_pixel(2, 6, darkYellow)
    @yellow_leaf_bitmaps[4].fill_rect(3, 6, 2, 1, midYellow)
   
    # 6th leaf bitmap
    @yellow_leaf_bitmaps[5] = Bitmap.new(8, 8)
    @yellow_leaf_bitmaps[5].fill_rect(6, 2, 2, 1, midYellow)
    @yellow_leaf_bitmaps[5].fill_rect(4, 3, 2, 1, midYellow)
    @yellow_leaf_bitmaps[5].set_pixel(6, 3, darkYellowtwo)
    @yellow_leaf_bitmaps[5].set_pixel(3, 4, midYellow)
    @yellow_leaf_bitmaps[5].set_pixel(4, 4, darkYellowtwo)
    @yellow_leaf_bitmaps[5].set_pixel(5, 4, lightYellow)
    @yellow_leaf_bitmaps[5].set_pixel(6, 4, lightYellowtwo)
    @yellow_leaf_bitmaps[5].set_pixel(1, 5, midYellow)
    @yellow_leaf_bitmaps[5].set_pixel(2, 5, darkYellowtwo)
    @yellow_leaf_bitmaps[5].fill_rect(3, 5, 2, 1, lightYellowtwo)
    @yellow_leaf_bitmaps[5].set_pixel(5, 5, lightYellow)
    @yellow_leaf_bitmaps[5].set_pixel(2, 6, midYellow)
    @yellow_leaf_bitmaps[5].set_pixel(3, 6, darkYellowtwo)
    @yellow_leaf_bitmaps[5].set_pixel(4, 6, lightYellow)
   
    # 7th leaf bitmap
    @yellow_leaf_bitmaps[6] = Bitmap.new(8, 8)
    @yellow_leaf_bitmaps[6].fill_rect(6, 1, 1, 2, midYellow)
    @yellow_leaf_bitmaps[6].fill_rect(4, 2, 2, 1, midYellow)
    @yellow_leaf_bitmaps[6].fill_rect(6, 2, 1, 2, darkYellow)
    @yellow_leaf_bitmaps[6].fill_rect(3, 3, 2, 1, midYellow)
    @yellow_leaf_bitmaps[6].set_pixel(5, 3, darkYellowtwo)
    @yellow_leaf_bitmaps[6].set_pixel(2, 4, midYellow)
    @yellow_leaf_bitmaps[6].set_pixel(3, 4, darkYellowtwo)
    @yellow_leaf_bitmaps[6].set_pixel(4, 4, lightYellow)
    @yellow_leaf_bitmaps[6].set_pixel(5, 4, midYellow)
    @yellow_leaf_bitmaps[6].set_pixel(1, 5, midYellow)
    @yellow_leaf_bitmaps[6].set_pixel(2, 5, darkYellowtwo)
    @yellow_leaf_bitmaps[6].fill_rect(3, 5, 2, 1, midYellow)
    @yellow_leaf_bitmaps[6].set_pixel(1, 6, darkYellow)
    @yellow_leaf_bitmaps[6].set_pixel(2, 6, midYellow)
   
    # 8th leaf bitmap
    @yellow_leaf_bitmaps[7] = Bitmap.new(8, 8)
    @yellow_leaf_bitmaps[7].set_pixel(6, 1, midYellow)
    @yellow_leaf_bitmaps[7].fill_rect(4, 2, 3, 2, midYellow)
    @yellow_leaf_bitmaps[7].set_pixel(3, 3, darkYellow)
    @yellow_leaf_bitmaps[7].set_pixel(2, 4, darkYellow)
    @yellow_leaf_bitmaps[7].set_pixel(3, 4, midYellow)
    @yellow_leaf_bitmaps[7].fill_rect(4, 4, 2, 1, darkYellowtwo)
    @yellow_leaf_bitmaps[7].set_pixel(1, 5, darkYellow)
    @yellow_leaf_bitmaps[7].set_pixel(2, 5, midYellow)
    @yellow_leaf_bitmaps[7].fill_rect(3, 5, 2, 1, lightYellow)
    @yellow_leaf_bitmaps[7].set_pixel(2, 6, midYellow)
    @yellow_leaf_bitmaps[7].set_pixel(3, 6, lightYellow)
   
    # 9th leaf bitmap
    @yellow_leaf_bitmaps[8] = Bitmap.new(8, 8)
    @yellow_leaf_bitmaps[8].fill_rect(6, 1, 1, 2, midYellow)
    @yellow_leaf_bitmaps[8].fill_rect(4, 2, 2, 1, midYellow)
    @yellow_leaf_bitmaps[8].fill_rect(6, 2, 1, 2, darkYellow)
    @yellow_leaf_bitmaps[8].fill_rect(3, 3, 2, 1, midYellow)
    @yellow_leaf_bitmaps[8].set_pixel(5, 3, darkYellowtwo)
    @yellow_leaf_bitmaps[8].set_pixel(2, 4, midYellow)
    @yellow_leaf_bitmaps[8].set_pixel(3, 4, darkYellowtwo)
    @yellow_leaf_bitmaps[8].set_pixel(4, 4, lightYellow)
    @yellow_leaf_bitmaps[8].set_pixel(5, 4, midYellow)
    @yellow_leaf_bitmaps[8].set_pixel(1, 5, midYellow)
    @yellow_leaf_bitmaps[8].set_pixel(2, 5, darkYellowtwo)
    @yellow_leaf_bitmaps[8].fill_rect(3, 5, 2, 1, midYellow)
    @yellow_leaf_bitmaps[8].set_pixel(1, 6, darkYellow)
    @yellow_leaf_bitmaps[8].set_pixel(2, 6, midYellow)
   
    # 10th leaf bitmap
    @yellow_leaf_bitmaps[9] = Bitmap.new(8, 8)
    @yellow_leaf_bitmaps[9].fill_rect(6, 2, 2, 1, midYellow)
    @yellow_leaf_bitmaps[9].fill_rect(4, 3, 2, 1, midYellow)
    @yellow_leaf_bitmaps[9].set_pixel(6, 3, darkYellowtwo)
    @yellow_leaf_bitmaps[9].set_pixel(3, 4, midYellow)
    @yellow_leaf_bitmaps[9].set_pixel(4, 4, darkYellowtwo)
    @yellow_leaf_bitmaps[9].set_pixel(5, 4, lightYellow)
    @yellow_leaf_bitmaps[9].set_pixel(6, 4, lightYellowtwo)
    @yellow_leaf_bitmaps[9].set_pixel(1, 5, midYellow)
    @yellow_leaf_bitmaps[9].set_pixel(2, 5, darkYellowtwo)
    @yellow_leaf_bitmaps[9].fill_rect(3, 5, 2, 1, lightYellowtwo)
    @yellow_leaf_bitmaps[9].set_pixel(5, 5, lightYellow)
    @yellow_leaf_bitmaps[9].set_pixel(2, 6, midYellow)
    @yellow_leaf_bitmaps[9].set_pixel(3, 6, darkYellowtwo)
    @yellow_leaf_bitmaps[9].set_pixel(4, 6, lightYellow)
   
    # 11th leaf bitmap
    @yellow_leaf_bitmaps[10] = Bitmap.new(8, 8)
    @yellow_leaf_bitmaps[10].set_pixel(6, 2, midYellow)
    @yellow_leaf_bitmaps[10].set_pixel(7, 2, darkYellow)
    @yellow_leaf_bitmaps[10].fill_rect(4, 3, 2, 1, midYellow)
    @yellow_leaf_bitmaps[10].set_pixel(6, 3, darkYellowtwo)
    @yellow_leaf_bitmaps[10].set_pixel(2, 4, darkYellow)
    @yellow_leaf_bitmaps[10].fill_rect(3, 4, 2, 1, darkYellowtwo)
    @yellow_leaf_bitmaps[10].set_pixel(5, 4, lightYellow)
    @yellow_leaf_bitmaps[10].set_pixel(6, 4, darkYellowtwo)
    @yellow_leaf_bitmaps[10].set_pixel(1, 5, midYellow)
    @yellow_leaf_bitmaps[10].set_pixel(2, 5, darkYellowtwo)
    @yellow_leaf_bitmaps[10].set_pixel(3, 5, lightYellow)
    @yellow_leaf_bitmaps[10].set_pixel(4, 5, lightYellowtwo)
    @yellow_leaf_bitmaps[10].set_pixel(5, 5, midYellow)
    @yellow_leaf_bitmaps[10].set_pixel(2, 6, darkYellow)
    @yellow_leaf_bitmaps[10].fill_rect(3, 6, 2, 1, midYellow)
   
    # 12th leaf bitmap
    @yellow_leaf_bitmaps[11] = Bitmap.new(8, 8)
    @yellow_leaf_bitmaps[11].fill_rect(0, 3, 1, 2, darkYellow)
    @yellow_leaf_bitmaps[11].set_pixel(1, 4, midYellow)
    @yellow_leaf_bitmaps[11].set_pixel(2, 4, darkYellowtwo)
    @yellow_leaf_bitmaps[11].set_pixel(3, 4, lightYellow)
    @yellow_leaf_bitmaps[11].set_pixel(4, 4, darkYellow)
    @yellow_leaf_bitmaps[11].set_pixel(7, 4, midYellow)
    @yellow_leaf_bitmaps[11].set_pixel(1, 5, darkYellow)
    @yellow_leaf_bitmaps[11].set_pixel(2, 5, midYellow)
    @yellow_leaf_bitmaps[11].set_pixel(3, 5, lightYellow)
    @yellow_leaf_bitmaps[11].set_pixel(4, 5, lightYellowtwo)
    @yellow_leaf_bitmaps[11].set_pixel(5, 5, lightYellow)
    @yellow_leaf_bitmaps[11].set_pixel(6, 5, darkYellowtwo)
    @yellow_leaf_bitmaps[11].set_pixel(7, 5, midYellow)
    @yellow_leaf_bitmaps[11].fill_rect(2, 6, 2, 1, midYellow)
    @yellow_leaf_bitmaps[11].set_pixel(4, 6, lightYellow)
    @yellow_leaf_bitmaps[11].set_pixel(5, 6, darkYellowtwo)
    @yellow_leaf_bitmaps[11].set_pixel(6, 6, midYellow)
   
    # 13th leaf bitmap
    @yellow_leaf_bitmaps[12] = Bitmap.new(8, 8)
    @yellow_leaf_bitmaps[12].set_pixel(1, 1, darkYellow)
    @yellow_leaf_bitmaps[12].fill_rect(1, 2, 2, 1, midYellow)
    @yellow_leaf_bitmaps[12].set_pixel(2, 3, midYellow)
    @yellow_leaf_bitmaps[12].set_pixel(3, 3, darkYellow)
    @yellow_leaf_bitmaps[12].set_pixel(4, 3, midYellow)
    @yellow_leaf_bitmaps[12].fill_rect(2, 4, 2, 1, midYellow)
    @yellow_leaf_bitmaps[12].set_pixel(4, 4, darkYellow)
    @yellow_leaf_bitmaps[12].set_pixel(5, 4, lightYellow)
    @yellow_leaf_bitmaps[12].set_pixel(3, 5, midYellow)
    @yellow_leaf_bitmaps[12].set_pixel(4, 5, darkYellow)
    @yellow_leaf_bitmaps[12].fill_rect(5, 5, 2, 1, darkYellowtwo)
    @yellow_leaf_bitmaps[12].fill_rect(4, 6, 2, 1, midYellow)
    @yellow_leaf_bitmaps[12].set_pixel(6, 6, lightYellow)
    @yellow_leaf_bitmaps[12].set_pixel(6, 7, darkYellowtwo)
   
#-------------------------------------------------------------------------------   
    @sparkle_bitmaps = []
   
    lightBlue = Color.new(181, 244, 255, 255)
    midBlue   = Color.new(126, 197, 235, 255)
    darkBlue  = Color.new(77, 136, 225, 255)
   
    # 1st sparkle bitmap
    @sparkle_bitmaps[0] = Bitmap.new(7, 7)
    @sparkle_bitmaps[0].set_pixel(3, 3, darkBlue)
   
    # 2nd sparkle bitmap
    @sparkle_bitmaps[1] = Bitmap.new(7, 7)
    @sparkle_bitmaps[1].fill_rect(3, 2, 1, 3, darkBlue)
    @sparkle_bitmaps[1].fill_rect(2, 3, 3, 1, darkBlue)
    @sparkle_bitmaps[1].set_pixel(3, 3, midBlue)
   
    # 3rd sparkle bitmap
    @sparkle_bitmaps[2] = Bitmap.new(7, 7)
    @sparkle_bitmaps[2].set_pixel(1, 1, darkBlue)
    @sparkle_bitmaps[2].set_pixel(5, 1, darkBlue)
    @sparkle_bitmaps[2].set_pixel(2, 2, midBlue)
    @sparkle_bitmaps[2].set_pixel(4, 2, midBlue)
    @sparkle_bitmaps[2].set_pixel(3, 3, lightBlue)
    @sparkle_bitmaps[2].set_pixel(2, 4, midBlue)
    @sparkle_bitmaps[2].set_pixel(4, 4, midBlue)
    @sparkle_bitmaps[2].set_pixel(1, 5, darkBlue)
    @sparkle_bitmaps[2].set_pixel(5, 5, darkBlue)
   
    # 4th sparkle bitmap
    @sparkle_bitmaps[3] = Bitmap.new(7, 7)
    @sparkle_bitmaps[3].fill_rect(3, 1, 1, 5, darkBlue)
    @sparkle_bitmaps[3].fill_rect(1, 3, 5, 1, darkBlue)
    @sparkle_bitmaps[3].fill_rect(3, 2, 1, 3, midBlue)
    @sparkle_bitmaps[3].fill_rect(2, 3, 3, 1, midBlue)
    @sparkle_bitmaps[3].set_pixel(3, 3, lightBlue)
   
    # 5th sparkle bitmap
    @sparkle_bitmaps[4] = Bitmap.new(7, 7)
    @sparkle_bitmaps[4].fill_rect(2, 2, 3, 3, midBlue)
    @sparkle_bitmaps[4].fill_rect(3, 2, 1, 3, darkBlue)
    @sparkle_bitmaps[4].fill_rect(2, 3, 3, 1, darkBlue)
    @sparkle_bitmaps[4].set_pixel(3, 3, lightBlue)
    @sparkle_bitmaps[4].set_pixel(1, 1, darkBlue)
    @sparkle_bitmaps[4].set_pixel(5, 1, darkBlue)
    @sparkle_bitmaps[4].set_pixel(1, 5, darkBlue)
    @sparkle_bitmaps[4].set_pixel(5, 1, darkBlue)
   
    # 6th sparkle bitmap
    @sparkle_bitmaps[5] = Bitmap.new(7, 7)
    @sparkle_bitmaps[5].fill_rect(2, 1, 3, 5, darkBlue)
    @sparkle_bitmaps[5].fill_rect(1, 2, 5, 3, darkBlue)
    @sparkle_bitmaps[5].fill_rect(2, 2, 3, 3, midBlue)
    @sparkle_bitmaps[5].fill_rect(3, 1, 1, 5, midBlue)
    @sparkle_bitmaps[5].fill_rect(1, 3, 5, 1, midBlue)
    @sparkle_bitmaps[5].fill_rect(3, 2, 1, 3, lightBlue)
    @sparkle_bitmaps[5].fill_rect(2, 3, 3, 1, lightBlue)
    @sparkle_bitmaps[5].set_pixel(3, 3, white)
   
    # 7th sparkle bitmap
    @sparkle_bitmaps[6] = Bitmap.new(7, 7)
    @sparkle_bitmaps[6].fill_rect(2, 1, 3, 5, midBlue)
    @sparkle_bitmaps[6].fill_rect(1, 2, 5, 3, midBlue)
    @sparkle_bitmaps[6].fill_rect(3, 0, 1, 7, darkBlue)
    @sparkle_bitmaps[6].fill_rect(0, 3, 7, 1, darkBlue)
    @sparkle_bitmaps[6].fill_rect(2, 2, 3, 3, lightBlue)
    @sparkle_bitmaps[6].fill_rect(3, 2, 1, 3, midBlue)
    @sparkle_bitmaps[6].fill_rect(2, 3, 3, 1, midBlue)
    @sparkle_bitmaps[6].set_pixel(3, 3, white)
#-------------------------------------------------------------------------------   
    # Meteor bitmap
   
    @meteor_bitmap = Bitmap.new(14, 12)
    @meteor_bitmap.fill_rect(0, 8, 5, 4, paleOrange)
    @meteor_bitmap.fill_rect(1, 7, 6, 4, paleOrange)
    @meteor_bitmap.set_pixel(7, 8, paleOrange)
    @meteor_bitmap.fill_rect(1, 8, 2, 2, brightOrange)
    @meteor_bitmap.set_pixel(2, 7, brightOrange)
    @meteor_bitmap.fill_rect(3, 6, 2, 1, brightOrange)
    @meteor_bitmap.set_pixel(3, 8, brightOrange)
    @meteor_bitmap.set_pixel(3, 10, brightOrange)
    @meteor_bitmap.set_pixel(4, 9, brightOrange)
    @meteor_bitmap.fill_rect(5, 5, 1, 5, brightOrange)
    @meteor_bitmap.fill_rect(6, 4, 1, 5, brightOrange)
    @meteor_bitmap.fill_rect(7, 3, 1, 5, brightOrange)
    @meteor_bitmap.fill_rect(8, 6, 1, 2, brightOrange)
    @meteor_bitmap.set_pixel(9, 5, brightOrange)
    @meteor_bitmap.set_pixel(3, 8, midRed)
    @meteor_bitmap.fill_rect(4, 7, 1, 2, midRed)
    @meteor_bitmap.set_pixel(4, 5, midRed)
    @meteor_bitmap.set_pixel(5, 4, midRed)
    @meteor_bitmap.set_pixel(5, 6, midRed)
    @meteor_bitmap.set_pixel(6, 5, midRed)
    @meteor_bitmap.set_pixel(6, 7, midRed)
    @meteor_bitmap.fill_rect(7, 4, 1, 3, midRed)
    @meteor_bitmap.fill_rect(8, 3, 1, 3, midRed)
    @meteor_bitmap.fill_rect(9, 2, 1, 3, midRed)
    @meteor_bitmap.fill_rect(10, 1, 1, 3, midRed)
    @meteor_bitmap.fill_rect(11, 0, 1, 3, midRed)
    @meteor_bitmap.fill_rect(12, 0, 1, 2, midRed)
    @meteor_bitmap.set_pixel(13, 0, midRed)
   
    # Impact bitmap
   
    @impact_bitmap = Bitmap.new(22, 11)
    @impact_bitmap.fill_rect(0, 5, 1, 2, brightOrange)
    @impact_bitmap.set_pixel(1, 4, brightOrange)
    @impact_bitmap.set_pixel(1, 6, brightOrange)
    @impact_bitmap.set_pixel(2, 3, brightOrange)
    @impact_bitmap.set_pixel(2, 7, brightOrange)
    @impact_bitmap.set_pixel(3, 2, midRed)
    @impact_bitmap.set_pixel(3, 7, midRed)
    @impact_bitmap.set_pixel(4, 2, brightOrange)
    @impact_bitmap.set_pixel(4, 8, brightOrange)
    @impact_bitmap.set_pixel(5, 2, midRed)
    @impact_bitmap.fill_rect(5, 8, 3, 1, brightOrange)
    @impact_bitmap.set_pixel(6, 1, midRed)
    @impact_bitmap.fill_rect(7, 1, 8, 1, brightOrange)
    @impact_bitmap.fill_rect(7, 9, 8, 1, midRed)
#-------------------------------------------------------------------------------   
    # Flame meteor bitmap
   
    @flame_meteor_bitmap = Bitmap.new(14, 12)
    @flame_meteor_bitmap.fill_rect(0, 8, 5, 4, brightOrange)
    @flame_meteor_bitmap.fill_rect(1, 7, 6, 4, brightOrange)
    @flame_meteor_bitmap.set_pixel(7, 8, brightOrange)
    @flame_meteor_bitmap.fill_rect(1, 8, 2, 2, midYellow)
    @flame_meteor_bitmap.set_pixel(2, 7, midYellow)
    @flame_meteor_bitmap.fill_rect(3, 6, 2, 1, midYellow)
    @flame_meteor_bitmap.set_pixel(3, 8, midYellow)
    @flame_meteor_bitmap.set_pixel(3, 10, midYellow)
    @flame_meteor_bitmap.set_pixel(4, 9, midYellow)
    @flame_meteor_bitmap.fill_rect(5, 5, 1, 5, midYellow)
    @flame_meteor_bitmap.fill_rect(6, 4, 1, 5, midYellow)
    @flame_meteor_bitmap.fill_rect(7, 3, 1, 5, midYellow)
    @flame_meteor_bitmap.fill_rect(8, 6, 1, 2, midYellow)
    @flame_meteor_bitmap.set_pixel(9, 5, midYellow)
    @flame_meteor_bitmap.set_pixel(3, 8, lightYellow)
    @flame_meteor_bitmap.fill_rect(4, 7, 1, 2, lightYellowtwo)
    @flame_meteor_bitmap.set_pixel(4, 5, lightYellow)
    @flame_meteor_bitmap.set_pixel(5, 4, lightYellow)
    @flame_meteor_bitmap.set_pixel(5, 6, lightYellow)
    @flame_meteor_bitmap.set_pixel(6, 5, lightYellow)
    @flame_meteor_bitmap.set_pixel(6, 7, lightYellow)
    @flame_meteor_bitmap.fill_rect(7, 4, 1, 3, lightYellow)
    @flame_meteor_bitmap.fill_rect(8, 3, 1, 3, lightYellow)
    @flame_meteor_bitmap.fill_rect(9, 2, 1, 3, lightYellow)
    @flame_meteor_bitmap.fill_rect(10, 1, 1, 3, lightYellow)
    @flame_meteor_bitmap.fill_rect(11, 0, 1, 3, lightYellow)
    @flame_meteor_bitmap.fill_rect(12, 0, 1, 2, lightYellow)
    @flame_meteor_bitmap.set_pixel(13, 0, lightYellow)
   
    # Flame impact bitmap
   
    @flame_impact_bitmap = Bitmap.new(22, 11)
    @flame_impact_bitmap.fill_rect(0, 5, 1, 2, midYellow)
    @flame_impact_bitmap.set_pixel(1, 4, midYellow)
    @flame_impact_bitmap.set_pixel(1, 6, midYellow)
    @flame_impact_bitmap.set_pixel(2, 3, midYellow)
    @flame_impact_bitmap.set_pixel(2, 7, midYellow)
    @flame_impact_bitmap.set_pixel(3, 2, midYellow)
    @flame_impact_bitmap.set_pixel(3, 7, lightYellow)
    @flame_impact_bitmap.set_pixel(4, 2, brightOrange)
    @flame_impact_bitmap.set_pixel(4, 8, brightOrange)
    @flame_impact_bitmap.set_pixel(5, 2, lightYellow)
    @flame_impact_bitmap.fill_rect(5, 8, 3, 1, midYellow)
    @flame_impact_bitmap.set_pixel(6, 1, lightYellow)
    @flame_impact_bitmap.fill_rect(7, 1, 8, 1, midYellow)
    @flame_impact_bitmap.fill_rect(7, 9, 8, 1, lightYellow)
#-------------------------------------------------------------------------------   
   
    # Ash bitmaps
   
    @ash_bitmaps = []
    @ash_bitmaps[0] = Bitmap.new(3, 3)
    @ash_bitmaps[0].fill_rect(0, 1, 1, 3, lightGrey)
    @ash_bitmaps[0].fill_rect(1, 0, 3, 1, lightGrey)
    @ash_bitmaps[0].set_pixel(1, 1, white)
    @ash_bitmaps[1] = Bitmap.new(3, 3)
    @ash_bitmaps[1].fill_rect(0, 1, 1, 3, grey)
    @ash_bitmaps[1].fill_rect(1, 0, 3, 1, grey)
    @ash_bitmaps[1].set_pixel(1, 1, lightGrey)
#-------------------------------------------------------------------------------   

    # Bubble bitmaps
   
    @bubble_bitmaps = []
    darkBlue  = Color.new(77, 136, 225, 160)
    aqua = Color.new(197, 253, 254, 160)
    lavender = Color.new(225, 190, 244, 160)
   
    # first bubble bitmap
    @bubble_bitmaps[0] = Bitmap.new(24, 24)
    @bubble_bitmaps[0].fill_rect(0, 9, 24, 5, darkBlue)
    @bubble_bitmaps[0].fill_rect(1, 6, 22, 11, darkBlue)
    @bubble_bitmaps[0].fill_rect(2, 5, 20, 13, darkBlue)
    @bubble_bitmaps[0].fill_rect(3, 4, 18, 15, darkBlue)
    @bubble_bitmaps[0].fill_rect(4, 3, 16, 17, darkBlue)
    @bubble_bitmaps[0].fill_rect(5, 2, 14, 19, darkBlue)
    @bubble_bitmaps[0].fill_rect(6, 1, 12, 21, darkBlue)
    @bubble_bitmaps[0].fill_rect(9, 0, 5, 24, darkBlue)
    @bubble_bitmaps[0].fill_rect(2, 11, 20, 4, aqua)
    @bubble_bitmaps[0].fill_rect(3, 7, 18, 10, aqua)
    @bubble_bitmaps[0].fill_rect(4, 6, 16, 12, aqua)
    @bubble_bitmaps[0].fill_rect(5, 5, 14, 14, aqua)
    @bubble_bitmaps[0].fill_rect(6, 4, 12, 16, aqua)
    @bubble_bitmaps[0].fill_rect(9, 2, 4, 20, aqua)
    @bubble_bitmaps[0].fill_rect(5, 10, 1, 7, lavender)
    @bubble_bitmaps[0].fill_rect(6, 14, 1, 5, lavender)
    @bubble_bitmaps[0].fill_rect(7, 15, 1, 4, lavender)
    @bubble_bitmaps[0].fill_rect(8, 16, 1, 4, lavender)
    @bubble_bitmaps[0].fill_rect(9, 17, 1, 3, lavender)
    @bubble_bitmaps[0].fill_rect(10, 18, 4, 3, lavender)
    @bubble_bitmaps[0].fill_rect(14, 18, 1, 2, lavender)
    @bubble_bitmaps[0].fill_rect(13, 5, 4, 4, white)
    @bubble_bitmaps[0].fill_rect(14, 4, 2, 1, white)
    @bubble_bitmaps[0].set_pixel(17, 6, white)
   
    # second bubble bitmap
    @bubble_bitmaps[1] = Bitmap.new(14, 15)
    @bubble_bitmaps[1].fill_rect(0, 4, 14, 7, darkBlue)
    @bubble_bitmaps[1].fill_rect(1, 3, 12, 9, darkBlue)
    @bubble_bitmaps[1].fill_rect(2, 2, 10, 11, darkBlue)
    @bubble_bitmaps[1].fill_rect(3, 1, 8, 13, darkBlue)
    @bubble_bitmaps[1].fill_rect(5, 0, 4, 15, darkBlue)
    @bubble_bitmaps[1].fill_rect(1, 5, 12, 4, aqua)
    @bubble_bitmaps[1].fill_rect(2, 4, 10, 6, aqua)
    @bubble_bitmaps[1].fill_rect(3, 3, 8, 8, aqua)
    @bubble_bitmaps[1].fill_rect(4, 2, 6, 10, aqua)
    @bubble_bitmaps[1].fill_rect(1, 5, 12, 4, aqua)
    @bubble_bitmaps[1].fill_rect(3, 9, 1, 2, lavender)
    @bubble_bitmaps[1].fill_rect(4, 10, 1, 2, lavender)
    @bubble_bitmaps[1].fill_rect(5, 11, 4, 1, lavender)
    @bubble_bitmaps[1].fill_rect(6, 12, 2, 1, white)
    @bubble_bitmaps[1].fill_rect(8, 3, 2, 2, white)
    @bubble_bitmaps[1].set_pixel(7, 4, white)
    @bubble_bitmaps[1].set_pixel(8, 5, white)
   
    # Other option for bubbles
    @bubble2_bitmaps = Array.new
    darkSteelGray = Color.new(145, 150, 155, 160)
    midSteelGray = Color.new(180, 180, 185, 160)
    lightSteelGray = Color.new(225, 225, 235, 160)
    steelBlue = Color.new(145, 145, 165, 160)
    lightSteelBlue = Color.new(165, 170, 180, 160)
    transparentWhite = Color.new(255, 255, 255, 160)
   
    # first bubble 2 bitmap
    @bubble2_bitmaps[0] = Bitmap.new(6, 6)
    @bubble2_bitmaps[0].fill_rect(0, 0, 6, 6, darkSteelGray)
    @bubble2_bitmaps[0].fill_rect(0, 2, 6, 2, midSteelGray)
    @bubble2_bitmaps[0].fill_rect(2, 0, 2, 6, midSteelGray)
    @bubble2_bitmaps[0].fill_rect(2, 2, 2, 2, lightSteelGray)
   
    # second bubble 2 bitmap
    @bubble2_bitmaps[1] = Bitmap.new(8, 8)
    @bubble2_bitmaps[1].fill_rect(0, 2, 2, 4, steelBlue)
    @bubble2_bitmaps[1].fill_rect(2, 0, 4, 2, darkSteelGray)
    @bubble2_bitmaps[1].fill_rect(6, 2, 2, 2, darkSteelGray)
    @bubble2_bitmaps[1].fill_rect(2, 6, 2, 2, darkSteelGray)
    @bubble2_bitmaps[1].fill_rect(6, 4, 2, 2, midSteelGray)
    @bubble2_bitmaps[1].fill_rect(4, 6, 2, 2, midSteelGray)
    @bubble2_bitmaps[1].fill_rect(4, 4, 2, 2, lightSteelBlue)
    @bubble2_bitmaps[1].fill_rect(2, 4, 2, 2, lightSteelGray)
    @bubble2_bitmaps[1].fill_rect(4, 2, 2, 2, lightSteelGray)
    @bubble2_bitmaps[1].fill_rect(2, 2, 2, 2, transparentWhite)
   
    # third bubble 2 bitmap
    @bubble2_bitmaps[2] = Bitmap.new(8, 10)
    @bubble2_bitmaps[2].fill_rect(8, 2, 2, 4, steelBlue)
    @bubble2_bitmaps[2].fill_rect(2, 0, 8, 2, darkSteelGray)
    @bubble2_bitmaps[2].fill_rect(2, 6, 8, 2, darkSteelGray)
    @bubble2_bitmaps[2].fill_rect(4, 0, 2, 2, midSteelGray)
    @bubble2_bitmaps[2].fill_rect(4, 6, 2, 2, midSteelGray)
    @bubble2_bitmaps[2].fill_rect(0, 2, 2, 2, midSteelGray)
    @bubble2_bitmaps[2].fill_rect(0, 4, 2, 2, lightSteelBlue)
    @bubble2_bitmaps[2].fill_rect(2, 2, 6, 4, lightSteelGray)
    @bubble2_bitmaps[2].fill_rect(2, 2, 4, 2, transparentWhite)
    @bubble2_bitmaps[2].fill_rect(4, 4, 2, 2, transparentWhite)
   
    # fourth bubble 2 bitmap
    @bubble2_bitmaps[3] = Bitmap.new(14, 14)
    @bubble2_bitmaps[3].fill_rect(4, 0, 4, 2, steelBlue)
    @bubble2_bitmaps[3].fill_rect(0, 4, 2, 4, steelBlue)
    @bubble2_bitmaps[3].fill_rect(12, 4, 2, 4, steelBlue)
    @bubble2_bitmaps[3].fill_rect(8, 0, 2, 2, darkSteelGray)
    @bubble2_bitmaps[3].fill_rect(0, 6, 2, 2, darkSteelGray)
    @bubble2_bitmaps[3].fill_rect(12, 6, 2, 2, darkSteelGray)
    @bubble2_bitmaps[3].fill_rect(4, 12, 6, 2, darkSteelGray)
    @bubble2_bitmaps[3].fill_rect(8, 0, 2, 2, darkSteelGray)
    @bubble2_bitmaps[3].fill_rect(2, 2, 10, 10, midSteelGray)
    @bubble2_bitmaps[3].fill_rect(6, 12, 2, 2, midSteelGray)
    @bubble2_bitmaps[3].fill_rect(2, 4, 10, 6, lightSteelGray)
    @bubble2_bitmaps[3].fill_rect(4, 2, 2, 2, lightSteelGray)
    @bubble2_bitmaps[3].fill_rect(6, 10, 4, 2, lightSteelGray)
    @bubble2_bitmaps[3].fill_rect(6, 4, 2, 2, transparentWhite)
    @bubble2_bitmaps[3].fill_rect(4, 6, 2, 2, transparentWhite)
#-------------------------------------------------------------------------------
   
    # Water bombs bitmap
   
    @waterbomb_bitmap = Bitmap.new(8, 8)
    @waterbomb_bitmap.fill_rect(0, 2, 2, 4, aqua)
    @waterbomb_bitmap.fill_rect(2, 0, 4, 2, aqua)
    @waterbomb_bitmap.fill_rect(6, 2, 2, 2, aqua)
    @waterbomb_bitmap.fill_rect(2, 6, 2, 2, aqua)
    @waterbomb_bitmap.fill_rect(6, 4, 2, 2, aqua)
    @waterbomb_bitmap.fill_rect(4, 6, 2, 2, aqua)
    @waterbomb_bitmap.fill_rect(4, 4, 2, 2, aqua)
    @waterbomb_bitmap.fill_rect(2, 4, 2, 2, aqua)
    @waterbomb_bitmap.fill_rect(4, 2, 2, 2, aqua)
    @waterbomb_bitmap.fill_rect(2, 2, 2, 2, aqua)

   
    # Water bombs impact bitmap
   
    @waterbomb_impact_bitmap = Bitmap.new(8, 5)
    @waterbomb_impact_bitmap.fill_rect(1, 0, 6, 1, aqua)
    @waterbomb_impact_bitmap.fill_rect(1, 4, 6, 1, aqua)
    @waterbomb_impact_bitmap.fill_rect(0, 1, 1, 3, aqua)
    @waterbomb_impact_bitmap.fill_rect(7, 1, 1, 3, aqua)
    @waterbomb_impact_bitmap.set_pixel(1, 0, aqua)
    @waterbomb_impact_bitmap.set_pixel(0, 1, aqua)
#-------------------------------------------------------------------------------

   
    # Icy bombs bitmap
   
    @icybomb_bitmap = Bitmap.new(8, 8)
    @icybomb_bitmap.fill_rect(0, 2, 2, 4, lightBlue)
    @icybomb_bitmap.fill_rect(2, 0, 4, 2, lightBlue)
    @icybomb_bitmap.fill_rect(6, 2, 2, 2, lightBlue)
    @icybomb_bitmap.fill_rect(2, 6, 2, 2, lightBlue)
    @icybomb_bitmap.fill_rect(6, 4, 2, 2, lightBlue)
    @icybomb_bitmap.fill_rect(4, 6, 2, 2, lightBlue)
    @icybomb_bitmap.fill_rect(4, 4, 2, 2, lightBlue)
    @icybomb_bitmap.fill_rect(2, 4, 2, 2, lightBlue)
    @icybomb_bitmap.fill_rect(4, 2, 2, 2, lightBlue)
    @icybomb_bitmap.fill_rect(2, 2, 2, 2, lightBlue)

   
    # Icy bombs impact bitmap
   
    @icybomb_impact_bitmap = Bitmap.new(8, 5)
    @icybomb_impact_bitmap.fill_rect(1, 0, 6, 1, lightBlue)
    @icybomb_impact_bitmap.fill_rect(1, 4, 6, 1, lightBlue)
    @icybomb_impact_bitmap.fill_rect(0, 1, 1, 3, lightBlue)
    @icybomb_impact_bitmap.fill_rect(7, 1, 1, 3, lightBlue)
    @icybomb_impact_bitmap.set_pixel(1, 0, lightBlue)
    @icybomb_impact_bitmap.set_pixel(0, 1, lightBlue)
#-------------------------------------------------------------------------------

   
    # Flare bombs bitmap
   
    @flarebomb_bitmap = Bitmap.new(8, 8)
    @flarebomb_bitmap.fill_rect(0, 2, 2, 4, midYellow)
    @flarebomb_bitmap.fill_rect(2, 0, 4, 2, midYellow)
    @flarebomb_bitmap.fill_rect(6, 2, 2, 2, midYellow)
    @flarebomb_bitmap.fill_rect(2, 6, 2, 2, brightOrange)
    @flarebomb_bitmap.fill_rect(6, 4, 2, 2, brightOrange)
    @flarebomb_bitmap.fill_rect(4, 6, 2, 2, midYellow)
    @flarebomb_bitmap.fill_rect(4, 4, 2, 2, brightOrange)
    @flarebomb_bitmap.fill_rect(2, 4, 2, 2, midYellow)
    @flarebomb_bitmap.fill_rect(4, 2, 2, 2, midYellow)
    @flarebomb_bitmap.fill_rect(2, 2, 2, 2, midYellow)

    # Flare bomb impact bitmap
   
    @flarebomb_impact_bitmap = Bitmap.new(8, 5)
    @flarebomb_impact_bitmap.fill_rect(1, 0, 6, 1, brightOrange)
    @flarebomb_impact_bitmap.fill_rect(1, 4, 6, 1, brightOrange)
    @flarebomb_impact_bitmap.fill_rect(0, 1, 1, 3, midYellow)
    @flarebomb_impact_bitmap.fill_rect(7, 1, 1, 3, midYellow)
    @flarebomb_impact_bitmap.set_pixel(1, 0, midYellow)
    @flarebomb_impact_bitmap.set_pixel(0, 1, midYellow)
#-------------------------------------------------------------------------------

    # Starburst bitmaps

    @starburst_bitmaps = []
   
    starburst_yellow = Color.new(233, 210, 142, 255)
    starburst_yellowtwo = Color.new(219, 191, 95, 255)
    starburst_lightyellow = Color.new(242, 229, 190, 255)
    starburst_pink = Color.new(241, 185, 187, 255)
    starburst_red = Color.new(196, 55, 84, 255)
    starburst_redtwo = Color.new(178, 15, 56, 255)
    starburst_cyan = Color.new(189, 225, 242, 255)
    starburst_blue = Color.new(102, 181, 221, 255)
    starburst_bluetwo = Color.new(5, 88, 168, 255)
    starburst_lightgreen = Color.new(205, 246, 205, 255)
    starburst_green = Color.new(88, 221, 89, 255)
    starburst_greentwo = Color.new(44, 166, 0, 255)
    starburst_purple = Color.new(216, 197, 255, 255)
    starburst_violet = Color.new(155, 107, 255, 255)
    starburst_violettwo = Color.new(71, 0, 222, 255)
    starburst_lightorange = Color.new(255, 220, 177, 255)
    starburst_orange = Color.new(255, 180, 85, 255)
    starburst_orangetwo = Color.new(222, 124, 0, 255)
   
    # 1st starburst bitmap
    @starburst_bitmaps[0] = Bitmap.new(8, 8)
    @starburst_bitmaps[0].set_pixel(3, 3, starburst_lightyellow)
   
    # 2nd starburst bitmap
    @starburst_bitmaps[1] = Bitmap.new(8, 8)
    @starburst_bitmaps[1].fill_rect(3, 2, 1, 3, starburst_yellow)
    @starburst_bitmaps[1].fill_rect(2, 3, 3, 1, starburst_yellow)
    @starburst_bitmaps[1].set_pixel(3, 3, starburst_lightyellow)
   
    # 3rd starburst bitmap
    @starburst_bitmaps[2] = Bitmap.new(7, 7)
    @starburst_bitmaps[2].set_pixel(1, 1, starburst_yellow)
    @starburst_bitmaps[2].set_pixel(5, 1, starburst_yellow)
    @starburst_bitmaps[2].set_pixel(2, 2, starburst_yellowtwo)
    @starburst_bitmaps[2].set_pixel(4, 2, starburst_yellow)
    @starburst_bitmaps[2].set_pixel(3, 3, starburst_lightyellow)
    @starburst_bitmaps[2].set_pixel(2, 4, starburst_yellowtwo)
    @starburst_bitmaps[2].set_pixel(4, 4, starburst_yellowtwo)
    @starburst_bitmaps[2].set_pixel(1, 5, starburst_yellow)
    @starburst_bitmaps[2].set_pixel(5, 5, starburst_yellow)
   
    # 4th starburst bitmap
    @starburst_bitmaps[3] = Bitmap.new(7, 7)
    @starburst_bitmaps[3].fill_rect(3, 1, 1, 5, starburst_yellow)
    @starburst_bitmaps[3].fill_rect(1, 3, 5, 1, starburst_yellowtwo)
    @starburst_bitmaps[3].fill_rect(3, 2, 1, 3, starburst_yellow)
    @starburst_bitmaps[3].fill_rect(2, 3, 3, 1, starburst_yellowtwo)
    @starburst_bitmaps[3].set_pixel(3, 3, starburst_lightyellow)
   
    # 5th starburst bitmap
    @starburst_bitmaps[4] = Bitmap.new(7, 7)
    @starburst_bitmaps[4].fill_rect(2, 2, 3, 3, starburst_yellow)
    @starburst_bitmaps[4].fill_rect(3, 2, 1, 3, starburst_yellow)
    @starburst_bitmaps[4].fill_rect(2, 3, 3, 1, starburst_yellowtwo)
    @starburst_bitmaps[4].set_pixel(3, 3, starburst_lightyellow)
    @starburst_bitmaps[4].set_pixel(1, 1, starburst_yellow)
    @starburst_bitmaps[4].set_pixel(5, 1, starburst_yellow)
    @starburst_bitmaps[4].set_pixel(1, 5, starburst_yellowtwo)
    @starburst_bitmaps[4].set_pixel(5, 1, starburst_yellowtwo)
   
    # 6th starburst bitmap
    @starburst_bitmaps[5] = Bitmap.new(8, 8)
    @starburst_bitmaps[5].fill_rect(3, 2, 1, 3, starburst_yellow)
    @starburst_bitmaps[5].fill_rect(2, 3, 3, 1, starburst_yellow)
    @starburst_bitmaps[5].set_pixel(3, 3, starburst_lightyellow)
   
    # 7th starburst bitmap
    @starburst_bitmaps[6] = Bitmap.new(8, 8)
    @starburst_bitmaps[6].fill_rect(3, 2, 1, 3, starburst_green)
    @starburst_bitmaps[6].fill_rect(2, 3, 3, 1, starburst_green)
    @starburst_bitmaps[6].set_pixel(3, 3, starburst_lightgreen)
   
    # 8th starburst bitmap
    @starburst_bitmaps[7] = Bitmap.new(7, 7)
    @starburst_bitmaps[7].set_pixel(1, 1, starburst_greentwo)
    @starburst_bitmaps[7].set_pixel(5, 1, starburst_greentwo)
    @starburst_bitmaps[7].set_pixel(2, 2, starburst_greentwo)
    @starburst_bitmaps[7].set_pixel(4, 2, starburst_greentwo)
    @starburst_bitmaps[7].set_pixel(3, 3, starburst_green)
    @starburst_bitmaps[7].set_pixel(2, 4, starburst_green)
    @starburst_bitmaps[7].set_pixel(4, 4, starburst_green)
    @starburst_bitmaps[7].set_pixel(1, 5, starburst_green)
    @starburst_bitmaps[7].set_pixel(5, 5, starburst_lightgreen)
   
    # 9th starburst bitmap
    @starburst_bitmaps[8] = Bitmap.new(7, 7)
    @starburst_bitmaps[8].fill_rect(3, 1, 1, 5, starburst_greentwo)
    @starburst_bitmaps[8].fill_rect(1, 3, 5, 1, starburst_greentwo)
    @starburst_bitmaps[8].fill_rect(3, 2, 1, 3, starburst_green)
    @starburst_bitmaps[8].fill_rect(2, 3, 3, 1, starburst_green)
    @starburst_bitmaps[8].set_pixel(3, 3, starburst_lightgreen)
        
    # 10th starburst bitmap
    @starburst_bitmaps[9] = Bitmap.new(7, 7)
    @starburst_bitmaps[9].fill_rect(2, 1, 3, 5, starburst_greentwo)
    @starburst_bitmaps[9].fill_rect(1, 2, 5, 3, starburst_greentwo)
    @starburst_bitmaps[9].fill_rect(2, 2, 3, 3, starburst_green)
    @starburst_bitmaps[9].fill_rect(3, 1, 1, 5, starburst_green)
    @starburst_bitmaps[9].fill_rect(1, 3, 5, 1, starburst_green)
    @starburst_bitmaps[9].fill_rect(3, 2, 1, 3, starburst_lightgreen)
    @starburst_bitmaps[9].fill_rect(2, 3, 3, 1, starburst_lightgreen)
    @starburst_bitmaps[9].set_pixel(3, 3, starburst_lightgreen)
   
    # 11en starburst bitmap
    @starburst_bitmaps[10] = Bitmap.new(7, 7)
    @starburst_bitmaps[10].fill_rect(2, 2, 3, 3, starburst_greentwo)
    @starburst_bitmaps[10].fill_rect(3, 2, 1, 3, starburst_greentwo)
    @starburst_bitmaps[10].fill_rect(2, 3, 3, 1, starburst_green)
    @starburst_bitmaps[10].set_pixel(3, 3, starburst_lightgreen)
    @starburst_bitmaps[10].set_pixel(1, 1, starburst_green)
    @starburst_bitmaps[10].set_pixel(5, 1, starburst_green)
    @starburst_bitmaps[10].set_pixel(1, 5, starburst_greentwo)
    @starburst_bitmaps[10].set_pixel(5, 1, starburst_greentwo)
        
    # 12en starburst bitmap
    @starburst_bitmaps[11] = Bitmap.new(8, 8)
    @starburst_bitmaps[11].fill_rect(3, 2, 1, 3, starburst_green)
    @starburst_bitmaps[11].fill_rect(2, 3, 3, 1, starburst_green)
    @starburst_bitmaps[11].set_pixel(3, 3, starburst_lightgreen)
   
    # 13en starburst bitmap
    @starburst_bitmaps[12] = Bitmap.new(8, 8)
    @starburst_bitmaps[12].fill_rect(3, 2, 1, 3, starburst_blue)
    @starburst_bitmaps[12].fill_rect(2, 3, 3, 1, starburst_blue)
    @starburst_bitmaps[12].set_pixel(3, 3, starburst_cyan)
   
    # 14en starburst bitmap
    @starburst_bitmaps[13] = Bitmap.new(7, 7)
    @starburst_bitmaps[13].set_pixel(1, 1, starburst_bluetwo)
    @starburst_bitmaps[13].set_pixel(5, 1, starburst_bluetwo)
    @starburst_bitmaps[13].set_pixel(2, 2, starburst_bluetwo)
    @starburst_bitmaps[13].set_pixel(4, 2, starburst_bluetwo)
    @starburst_bitmaps[13].set_pixel(3, 3, starburst_blue)
    @starburst_bitmaps[13].set_pixel(2, 4, starburst_blue)
    @starburst_bitmaps[13].set_pixel(4, 4, starburst_blue)
    @starburst_bitmaps[13].set_pixel(1, 5, starburst_blue)
    @starburst_bitmaps[13].set_pixel(5, 5, starburst_cyan)
   
    # 15en starburst bitmap
    @starburst_bitmaps[14] = Bitmap.new(7, 7)
    @starburst_bitmaps[14].fill_rect(3, 1, 1, 5, starburst_bluetwo)
    @starburst_bitmaps[14].fill_rect(1, 3, 5, 1, starburst_bluetwo)
    @starburst_bitmaps[14].fill_rect(3, 2, 1, 3, starburst_blue)
    @starburst_bitmaps[14].fill_rect(2, 3, 3, 1, starburst_blue)
    @starburst_bitmaps[14].set_pixel(3, 3, starburst_cyan)
        
    # 16en starburst bitmap
    @starburst_bitmaps[15] = Bitmap.new(7, 7)
    @starburst_bitmaps[15].fill_rect(2, 1, 3, 5, starburst_bluetwo)
    @starburst_bitmaps[15].fill_rect(1, 2, 5, 3, starburst_bluetwo)
    @starburst_bitmaps[15].fill_rect(2, 2, 3, 3, starburst_blue)
    @starburst_bitmaps[15].fill_rect(3, 1, 1, 5, starburst_blue)
    @starburst_bitmaps[15].fill_rect(1, 3, 5, 1, starburst_blue)
    @starburst_bitmaps[15].fill_rect(3, 2, 1, 3, starburst_cyan)
    @starburst_bitmaps[15].fill_rect(2, 3, 3, 1, starburst_cyan)
    @starburst_bitmaps[15].set_pixel(3, 3, starburst_cyan)
   
    # 17en starburst bitmap
    @starburst_bitmaps[16] = Bitmap.new(8, 8)
    @starburst_bitmaps[16].fill_rect(3, 2, 1, 3, starburst_blue)
    @starburst_bitmaps[16].fill_rect(2, 3, 3, 1, starburst_blue)
    @starburst_bitmaps[16].set_pixel(3, 3, starburst_cyan)
   
    # 18en starburst bitmap
    @starburst_bitmaps[17] = Bitmap.new(8, 8)
    @starburst_bitmaps[17].fill_rect(3, 2, 1, 3, starburst_violet)
    @starburst_bitmaps[17].fill_rect(2, 3, 3, 1, starburst_violet)
    @starburst_bitmaps[17].set_pixel(3, 3, starburst_purple)
   
    # 19en starburst bitmap
    @starburst_bitmaps[18] = Bitmap.new(7, 7)
    @starburst_bitmaps[18].set_pixel(1, 1, starburst_violettwo)
    @starburst_bitmaps[18].set_pixel(5, 1, starburst_violettwo)
    @starburst_bitmaps[18].set_pixel(2, 2, starburst_violettwo)
    @starburst_bitmaps[18].set_pixel(4, 2, starburst_violettwo)
    @starburst_bitmaps[18].set_pixel(3, 3, starburst_violet)
    @starburst_bitmaps[18].set_pixel(2, 4, starburst_violet)
    @starburst_bitmaps[18].set_pixel(4, 4, starburst_violet)
    @starburst_bitmaps[18].set_pixel(1, 5, starburst_violet)
    @starburst_bitmaps[18].set_pixel(5, 5, starburst_purple)
   
    # 20y starburst bitmap
    @starburst_bitmaps[19] = Bitmap.new(7, 7)
    @starburst_bitmaps[19].fill_rect(3, 1, 1, 5, starburst_violettwo)
    @starburst_bitmaps[19].fill_rect(1, 3, 5, 1, starburst_violettwo)
    @starburst_bitmaps[19].fill_rect(3, 2, 1, 3, starburst_violet)
    @starburst_bitmaps[19].fill_rect(2, 3, 3, 1, starburst_violet)
    @starburst_bitmaps[19].set_pixel(3, 3, starburst_violet)
        
    # 21st starburst bitmap
    @starburst_bitmaps[20] = Bitmap.new(7, 7)
    @starburst_bitmaps[20].fill_rect(2, 1, 3, 5, starburst_violettwo)
    @starburst_bitmaps[20].fill_rect(1, 2, 5, 3, starburst_violettwo)
    @starburst_bitmaps[20].fill_rect(2, 2, 3, 3, starburst_violet)
    @starburst_bitmaps[20].fill_rect(3, 1, 1, 5, starburst_violet)
    @starburst_bitmaps[20].fill_rect(1, 3, 5, 1, starburst_violet)
    @starburst_bitmaps[20].fill_rect(3, 2, 1, 3, starburst_purple)
    @starburst_bitmaps[20].fill_rect(2, 3, 3, 1, starburst_purple)
    @starburst_bitmaps[20].set_pixel(3, 3, starburst_purple)
   
    # 22nd starburst bitmap
    @starburst_bitmaps[21] = Bitmap.new(7, 7)
    @starburst_bitmaps[21].fill_rect(2, 1, 3, 5, starburst_violet)
    @starburst_bitmaps[21].fill_rect(1, 2, 5, 3, starburst_violet)
    @starburst_bitmaps[21].fill_rect(3, 0, 1, 7, starburst_violettwo)
    @starburst_bitmaps[21].fill_rect(0, 3, 7, 1, starburst_violettwo)
    @starburst_bitmaps[21].fill_rect(2, 2, 3, 3, starburst_purple)
    @starburst_bitmaps[21].fill_rect(3, 2, 1, 3, starburst_violet)
    @starburst_bitmaps[21].fill_rect(2, 3, 3, 1, starburst_violet)
    @starburst_bitmaps[21].set_pixel(3, 3, starburst_purple)
   
    # 23d starburst bitmap
    @starburst_bitmaps[22] = Bitmap.new(8, 8)
    @starburst_bitmaps[22].fill_rect(3, 2, 1, 3, starburst_violet)
    @starburst_bitmaps[22].fill_rect(2, 3, 3, 1, starburst_violet)
    @starburst_bitmaps[22].set_pixel(3, 3, starburst_purple)
   
    # 24th starburst bitmap
    @starburst_bitmaps[23] = Bitmap.new(8, 8)
    @starburst_bitmaps[23].fill_rect(3, 2, 1, 3, starburst_red)
    @starburst_bitmaps[23].fill_rect(2, 3, 3, 1, starburst_red)
    @starburst_bitmaps[23].set_pixel(3, 3, starburst_pink)
   
    # 25th starburst bitmap
    @starburst_bitmaps[24] = Bitmap.new(7, 7)
    @starburst_bitmaps[24].set_pixel(1, 1, starburst_redtwo)
    @starburst_bitmaps[24].set_pixel(5, 1, starburst_redtwo)
    @starburst_bitmaps[24].set_pixel(2, 2, starburst_redtwo)
    @starburst_bitmaps[24].set_pixel(4, 2, starburst_redtwo)
    @starburst_bitmaps[24].set_pixel(3, 3, starburst_red)
    @starburst_bitmaps[24].set_pixel(2, 4, starburst_red)
    @starburst_bitmaps[24].set_pixel(4, 4, starburst_red)
    @starburst_bitmaps[24].set_pixel(1, 5, starburst_red)
    @starburst_bitmaps[24].set_pixel(5, 5, starburst_pink)
   
    # 26th starburst bitmap
    @starburst_bitmaps[25] = Bitmap.new(7, 7)
    @starburst_bitmaps[25].fill_rect(3, 1, 1, 5, starburst_redtwo)
    @starburst_bitmaps[25].fill_rect(1, 3, 5, 1, starburst_redtwo)
    @starburst_bitmaps[25].fill_rect(3, 2, 1, 3, starburst_red)
    @starburst_bitmaps[25].fill_rect(2, 3, 3, 1, starburst_red)
    @starburst_bitmaps[25].set_pixel(3, 3, starburst_pink)
        
    # 27th starburst bitmap
    @starburst_bitmaps[26] = Bitmap.new(7, 7)
    @starburst_bitmaps[26].fill_rect(2, 1, 3, 5, starburst_redtwo)
    @starburst_bitmaps[26].fill_rect(1, 2, 5, 3, starburst_redtwo)
    @starburst_bitmaps[26].fill_rect(2, 2, 3, 3, starburst_red)
    @starburst_bitmaps[26].fill_rect(3, 1, 1, 5, starburst_red)
    @starburst_bitmaps[26].fill_rect(1, 3, 5, 1, starburst_red)
    @starburst_bitmaps[26].fill_rect(3, 2, 1, 3, starburst_pink)
    @starburst_bitmaps[26].fill_rect(2, 3, 3, 1, starburst_pink)
    @starburst_bitmaps[26].set_pixel(3, 3, starburst_pink)
   
    # 28th starburst bitmap
    @starburst_bitmaps[27] = Bitmap.new(7, 7)
    @starburst_bitmaps[27].fill_rect(2, 1, 3, 5, starburst_red)
    @starburst_bitmaps[27].fill_rect(1, 2, 5, 3, starburst_red)
    @starburst_bitmaps[27].fill_rect(3, 0, 1, 7, starburst_redtwo)
    @starburst_bitmaps[27].fill_rect(0, 3, 7, 1, starburst_redtwo)
    @starburst_bitmaps[27].fill_rect(2, 2, 3, 3, starburst_pink)
    @starburst_bitmaps[27].fill_rect(3, 2, 1, 3, starburst_red)
    @starburst_bitmaps[27].fill_rect(2, 3, 3, 1, starburst_red)
    @starburst_bitmaps[27].set_pixel(3, 3, starburst_pink)
   
    # 29th starburst bitmap
    @starburst_bitmaps[28] = Bitmap.new(8, 8)
    @starburst_bitmaps[28].fill_rect(3, 2, 1, 3, starburst_red)
    @starburst_bitmaps[28].fill_rect(2, 3, 3, 1, starburst_red)
    @starburst_bitmaps[28].set_pixel(3, 3, starburst_pink)
   
    # 30y starburst bitmap
    @starburst_bitmaps[29] = Bitmap.new(8, 8)
    @starburst_bitmaps[29].fill_rect(3, 2, 1, 3, starburst_orange)
    @starburst_bitmaps[29].fill_rect(2, 3, 3, 1, starburst_orange)
    @starburst_bitmaps[29].set_pixel(3, 3, starburst_lightorange)
   
    # 31st starburst bitmap
    @starburst_bitmaps[30] = Bitmap.new(7, 7)
    @starburst_bitmaps[30].set_pixel(1, 1, starburst_orangetwo)
    @starburst_bitmaps[30].set_pixel(5, 1, starburst_orangetwo)
    @starburst_bitmaps[30].set_pixel(2, 2, starburst_orangetwo)
    @starburst_bitmaps[30].set_pixel(4, 2, starburst_orangetwo)
    @starburst_bitmaps[30].set_pixel(3, 3, starburst_orange)
    @starburst_bitmaps[30].set_pixel(2, 4, starburst_orange)
    @starburst_bitmaps[30].set_pixel(4, 4, starburst_orange)
    @starburst_bitmaps[30].set_pixel(1, 5, starburst_orange)
    @starburst_bitmaps[30].set_pixel(5, 5, starburst_lightorange)
   
    # 32nd starburst bitmap
    @starburst_bitmaps[31] = Bitmap.new(7, 7)
    @starburst_bitmaps[31].fill_rect(3, 1, 1, 5, starburst_orangetwo)
    @starburst_bitmaps[31].fill_rect(1, 3, 5, 1, starburst_orangetwo)
    @starburst_bitmaps[31].fill_rect(3, 2, 1, 3, starburst_orange)
    @starburst_bitmaps[31].fill_rect(2, 3, 3, 1, starburst_orange)
    @starburst_bitmaps[31].set_pixel(3, 3, starburst_lightorange)
        
    # 33d starburst bitmap
    @starburst_bitmaps[32] = Bitmap.new(7, 7)
    @starburst_bitmaps[32].fill_rect(2, 1, 3, 5, starburst_orangetwo)
    @starburst_bitmaps[32].fill_rect(1, 2, 5, 3, starburst_orangetwo)
    @starburst_bitmaps[32].fill_rect(2, 2, 3, 3, starburst_orange)
    @starburst_bitmaps[32].fill_rect(3, 1, 1, 5, starburst_orange)
    @starburst_bitmaps[32].fill_rect(1, 3, 5, 1, starburst_orange)
    @starburst_bitmaps[32].fill_rect(3, 2, 1, 3, starburst_lightorange)
    @starburst_bitmaps[32].fill_rect(2, 3, 3, 1, starburst_lightorange)
    @starburst_bitmaps[32].set_pixel(3, 3, starburst_lightorange)
   
    # 34th starburst bitmap
    @starburst_bitmaps[33] = Bitmap.new(7, 7)
    @starburst_bitmaps[33].fill_rect(2, 1, 3, 5, starburst_orange)
    @starburst_bitmaps[33].fill_rect(1, 2, 5, 3, starburst_orange)
    @starburst_bitmaps[33].fill_rect(3, 0, 1, 7, starburst_orangetwo)
    @starburst_bitmaps[33].fill_rect(0, 3, 7, 1, starburst_orangetwo)
    @starburst_bitmaps[33].fill_rect(2, 2, 3, 3, starburst_lightorange)
    @starburst_bitmaps[33].fill_rect(3, 2, 1, 3, starburst_orange)
    @starburst_bitmaps[33].fill_rect(2, 3, 3, 1, starburst_orange)
    @starburst_bitmaps[33].set_pixel(3, 3, starburst_lightorange)
   
    # 35th starburst bitmap
    @starburst_bitmaps[34] = Bitmap.new(8, 8)
    @starburst_bitmaps[34].fill_rect(3, 2, 1, 3, starburst_orange)
    @starburst_bitmaps[34].fill_rect(2, 3, 3, 1, starburst_orange)
    @starburst_bitmaps[34].set_pixel(3, 3, starburst_lightorange)
   
    # 36th starburst bitmap
    @starburst_bitmaps[35] = Bitmap.new(8, 8)
    @starburst_bitmaps[35].set_pixel(3, 3, starburst_lightorange)   
#-------------------------------------------------------------------------------      
    @monostarburst_bitmaps = []
   
    # 1st starburst bitmap
    @monostarburst_bitmaps[0] = Bitmap.new(8, 8)
    @monostarburst_bitmaps[0].set_pixel(3, 3, starburst_lightyellow)
   
    # 2nd starburst bitmap
    @monostarburst_bitmaps[1] = Bitmap.new(8, 8)
    @monostarburst_bitmaps[1].fill_rect(3, 2, 1, 3, starburst_yellow)
    @monostarburst_bitmaps[1].fill_rect(2, 3, 3, 1, starburst_yellow)
    @monostarburst_bitmaps[1].set_pixel(3, 3, starburst_lightyellow)
   
    # 3d starburst bitmap
    @monostarburst_bitmaps[2] = Bitmap.new(7, 7)
    @monostarburst_bitmaps[2].set_pixel(1, 1, starburst_yellowtwo)
    @monostarburst_bitmaps[2].set_pixel(5, 1, starburst_yellowtwo)
    @monostarburst_bitmaps[2].set_pixel(2, 2, starburst_yellowtwo)
    @monostarburst_bitmaps[2].set_pixel(4, 2, starburst_yellowtwo)
    @monostarburst_bitmaps[2].set_pixel(3, 3, starburst_yellow)
    @monostarburst_bitmaps[2].set_pixel(2, 4, starburst_yellow)
    @monostarburst_bitmaps[2].set_pixel(4, 4, starburst_yellow)
    @monostarburst_bitmaps[2].set_pixel(1, 5, starburst_yellow)
    @monostarburst_bitmaps[2].set_pixel(5, 5, starburst_lightyellow)
   
    # 4th starburst bitmap
    @monostarburst_bitmaps[3] = Bitmap.new(7, 7)
    @monostarburst_bitmaps[3].fill_rect(3, 1, 1, 5, starburst_yellowtwo)
    @monostarburst_bitmaps[3].fill_rect(1, 3, 5, 1, starburst_yellowtwo)
    @monostarburst_bitmaps[3].fill_rect(3, 2, 1, 3, starburst_yellow)
    @monostarburst_bitmaps[3].fill_rect(2, 3, 3, 1, starburst_yellow)
    @monostarburst_bitmaps[3].set_pixel(3, 3, starburst_lightyellow)
        
    # 5th starburst bitmap
    @monostarburst_bitmaps[4] = Bitmap.new(7, 7)
    @monostarburst_bitmaps[4].fill_rect(2, 1, 3, 5, starburst_yellowtwo)
    @monostarburst_bitmaps[4].fill_rect(1, 2, 5, 3, starburst_yellowtwo)
    @monostarburst_bitmaps[4].fill_rect(2, 2, 3, 3, starburst_yellow)
    @monostarburst_bitmaps[4].fill_rect(3, 1, 1, 5, starburst_yellow)
    @monostarburst_bitmaps[4].fill_rect(1, 3, 5, 1, starburst_yellow)
    @monostarburst_bitmaps[4].fill_rect(3, 2, 1, 3, starburst_lightyellow)
    @monostarburst_bitmaps[4].fill_rect(2, 3, 3, 1, starburst_lightyellow)
    @monostarburst_bitmaps[4].set_pixel(3, 3, starburst_lightyellow)
   
    # 6th starburst bitmap
    @monostarburst_bitmaps[5] = Bitmap.new(7, 7)
    @monostarburst_bitmaps[5].fill_rect(2, 1, 3, 5, starburst_yellow)
    @monostarburst_bitmaps[5].fill_rect(1, 2, 5, 3, starburst_yellow)
    @monostarburst_bitmaps[5].fill_rect(3, 0, 1, 7, starburst_yellowtwo)
    @monostarburst_bitmaps[5].fill_rect(0, 3, 7, 1, starburst_yellowtwo)
    @monostarburst_bitmaps[5].fill_rect(2, 2, 3, 3, starburst_lightyellow)
    @monostarburst_bitmaps[5].fill_rect(3, 2, 1, 3, starburst_yellow)
    @monostarburst_bitmaps[5].fill_rect(2, 3, 3, 1, starburst_yellow)
    @monostarburst_bitmaps[5].set_pixel(3, 3, starburst_lightyellow)
   
    # 7th starburst bitmap
    @monostarburst_bitmaps[6] = Bitmap.new(8, 8)
    @monostarburst_bitmaps[6].fill_rect(3, 2, 1, 3, starburst_yellow)
    @monostarburst_bitmaps[6].fill_rect(2, 3, 3, 1, starburst_yellow)
    @monostarburst_bitmaps[6].set_pixel(3, 3, starburst_lightyellow)
   
    # 8th starburst bitmap
    @monostarburst_bitmaps[7] = Bitmap.new(8, 8)
    @monostarburst_bitmaps[7].set_pixel(3, 3, starburst_lightyellow)
#-------------------------------------------------------------------------------   
   
    @user_bitmaps = []
    update_user_defined
  end
  
  def update_user_defined
    for image in @user_bitmaps
      image.dispose
    end
   
    #user-defined bitmaps
    for name in $WEATHER_IMAGES
      @user_bitmaps.push(RPG::Cache.picture(name))
    end
    for sprite in @sprites
      sprite.bitmap = @user_bitmaps[rand(@user_bitmaps.size)]
    end
  end
end

class Scene_Map
  def change_weather
    @spriteset.change_weather  
  end
end

class Spriteset_Map
  attr_accessor :change_weather
end[/pre]

战斗天气:与上面那个能完美融合哦
[pre lang="ruby"]=begin
      RGSS3
      
      ★ 戦闘内天候持ち越し ★

      天候を戦闘にも反映させます。
      
      ver1.00

      Last Update : 2011/12/17
      12/17 : RGSS2からの移植
      
      ろかん   http://kaisou-ryouiki.sakura.ne.jp/
=end

#===================================
#  ●設定箇所
#===================================
module BattleWeather
  # 戦闘中に天候が変更された場合、戦闘後のマップにも反映させるかどうか
  BCEMW = true
end
#===================================
#  ここまで
#===================================

$rsi ||= {}
$rsi["戦闘内天候持ち越し"] = true

class Game_Screen
  #--------------------------------------------------------------------------
  # ● 公開インスタンス変数
  #--------------------------------------------------------------------------
  attr_writer   :weather_type
  attr_writer   :weather_power
end

class Game_Interpreter
  #--------------------------------------------------------------------------
  # ● 天候の設定   ※再定義
  #--------------------------------------------------------------------------
  def command_236
    screen.change_weather(@params[0], @params[1], @params[2])
    wait(@params[2]) if @params[3]
  end
end

class Spriteset_Battle
  #--------------------------------------------------------------------------
  # ● インクルード BattleWeather
  #--------------------------------------------------------------------------
  include BattleWeather
  #--------------------------------------------------------------------------
  # ● オブジェクト初期化
  #--------------------------------------------------------------------------
  alias battle_weather_initialize initialize
  def initialize
    battle_weather_initialize
    create_weather
  end
  #--------------------------------------------------------------------------
  # ● 天候の作成
  #--------------------------------------------------------------------------
  def create_weather
    $game_troop.screen.weather_type = $game_map.screen.weather_type
    $game_troop.screen.weather_power = $game_map.screen.weather_power
    @weather = Spriteset_Weather.new(@viewport2)
    @weather.update
    Graphics.update
  end
  #--------------------------------------------------------------------------
  # ● 解放
  #--------------------------------------------------------------------------
  alias battle_weather_dispose dispose
  def dispose
    if BCEMW
      $game_map.screen.weather_type = @weather.type
      $game_map.screen.weather_power = @weather.power
    end
    dispose_weather
    battle_weather_dispose
  end
  #--------------------------------------------------------------------------
  # ● 天候の解放
  #--------------------------------------------------------------------------
  def dispose_weather
    @weather.dispose
  end
  #--------------------------------------------------------------------------
  # ● フレーム更新
  #--------------------------------------------------------------------------
  alias update_battle_weather update
  def update
    update_battle_weather
    update_weather
  end
  #--------------------------------------------------------------------------
  # ● 天候の更新
  #--------------------------------------------------------------------------
  def update_weather
    if @weather
      @weather.type = $game_troop.screen.weather_type
      @weather.power = $game_troop.screen.weather_power
      @weather.update
    end
  end
end[/pre]

状态信息
[pre lang="ruby"]
# ステ―ト詳細確認ウィンドウ
#
# 戦闘時、パーティコマンドに付与されているステートの詳細を確認するためのコマンド
# を追加します。

$imported_yana_scripts ||= {}
$imported_yana_scripts["StateHelpWindow"] = true

module StateHelp
  Buffs = {}
  States = []
  
# 请按照下面的描写进行备注

  Buffs[[0,:up]] = "HP+25%,最高5级\n持续5回合"
  Buffs[[1,:up]] = "MP+25%,最高5级\n持续5回合"
  Buffs[[2,:up]] = "物攻+25%,最高5级\n持续5回合"
  Buffs[[3,:up]] = "物防+25%,最高5级\n持续5回合"
  Buffs[[4,:up]] = "魔攻+25%,最高5级\n持续5回合"
  Buffs[[5,:up]] = "魔防+25%,最高5级\n持续5回合"
  Buffs[[6,:up]] = "敏捷+25%,最高5级\n持续5回合"
  Buffs[[7,:up]] = "幸运+25%,最高5级\n持续5回合"
  
  Buffs[[0,:down]] = "HP-25%,最高5级\n持续5回合"
  Buffs[[1,:down]] = "MP-25%,最高5级\n持续5回合"
  Buffs[[2,:down]] = "物攻-25%,最高5级\n持续5回合"
  Buffs[[3,:down]] = "物防-25%,最高5级\n持续5回合"
  Buffs[[4,:down]] = "魔攻-25%,最高5级\n持续5回合"
  Buffs[[5,:down]] = "魔防-25%,最高5级\n持续5回合"
  Buffs[[6,:down]] = "敏捷-25%,最高5级\n持续5回合"
  Buffs[[7,:down]] = "幸运-25%,最高5级\n持续5回合"

  States[1]  = "无法战斗:死亡。"
  States[2]  = "毒:生命再生-10%\n永续。"
  States[3]  = "致盲:物理命中率-60%\n2~4回合。"
  States[4]  = "沉默:无法使用技能\n2~3回合。"
  States[5]  = "混乱:会攻击双方人物\n2~4回合。"
  States[6]  = "睡眠:无法使用法术技能受到伤害立刻解除\n3~5回合。"
  States[7]  = "麻痹:无法行动,不会闪避任何伤害30%解除\n4~6回合。"
  States[8]  = "眩晕:无法行动,20%解除\n1~2回合。"
  States[53]  = "秘剑:(被动技能)\n技能增加全属性值,减少伤害比例。永续。"
  States[14]  = "体力再生:每回合回复5%体力值\n2回合。"
  States[15]  = "魔力再生:每回合回复5%魔力值\n2回合。"
  States[16]  = "特技再生:每回合回复5%特技值\n2回合。"
  States[24]  = "免疫异常:免疫所有异常状态\n5回合。"
  States[26]  = "月读:攻击附加多种异常状态\n2回合。"
  States[25]  = "魔法回路:减少魔法消耗\n5回合。"
  States[28]  = "雷电天牢:无法行动,每回合减少2%HP\n2回合。"
  States[29]  = "血继限界:(被动技能)\n增加属性百分比,受到伤害反射中毒。永续。"
  States[51]  = "禁锢:无法行动\n2回合。"
  States[52]  = "压制:无法行动,全属性降低5%\n2回合。"
  States[35]  = "仙人模式:增加2%HP MP 攻击 魔攻 防御 特防和5%再生率\n3-5回合。"
  States[45]  = "焚烧:每回合扣除1%HP MP\n2-5回合。"
  States[56]  = "石化:无法行动,增加被伤害值60%减少闪避率20%一定几率解除。\n2-4回合。"
  States[57]  = "永恒睡眠:无法行动,增加150%防御特防和生命上限,增加再生率10%\n4回合。"
  States[59]  = "失魂:无法使用任何类型的技能\n2回合。"
  States[50]  = "王之宝库:增加2次普攻,每次普攻几率附加天之锁状态\n永续。"
  States[48]  = "Gate of Babylon:增加一次普攻,25%增加一次行动\n永续。"
  States[37]  = "仙人屏障:(被动技能)\n增加再生率,增加闪避率和反射率。永续。"
  States[47]  = "圣灵:(被动技能)\n增加20%的攻击魔攻防御特防。永续。"
  States[18]  = "魔法闪避:增加80%魔法闪避\n3回合。"
  States[19]  = "魔法反射:增加80%魔法反射\n3回合。"
  States[60]  = "技能延迟:释放延迟类技能会出现的1回合行动后解除\n1回合。"
  States[58]  = "仙法*天牢:无法行动,每回合减少3%HP\n2-4回合。"
  States[61]  = "无限月读:无法行动,减少全属性20%受到攻击10%会解除或等到6回合后。"
  States[62]  = "神眼:(被动技能)增加暴击率和命中率10%减少魔法消耗20%并减少自身伤害\n永续。"
  States[63]  = "虚弱:减少所有属性20%\n2回合。"
  States[64]  = "连射模式:增加自身攻击次数2次,同时攻击会附加剧毒\n2回合。"
  States[65]  = "神鹰之眼:被动技能:增加暴击率和攻击力15%。命中率30%\n每回合提供5能量暴击造成150%伤害。"
  States[66]  = "免伤:获得减免伤害30%\n1回合。"
  States[67]  = "轮回血印吸收:获得伤害吸收\n1回合。"
  States[68]  = "仙法*轮回之力:大大提高自身的能力。"
  States[69]  = "仙法*反印结:(被动技能)提高伤害反射10%\n永续。"
  States[70]  = "灵魂掌控:(被动技能)提高免疫异常的能力\n永续。"
  States[71]  = "魔法盾术:可以将法力来挡伤害。\n 1MP吸收15比率为50%。"
  States[72]  = "阴之力:大幅度增加双抗,回血回蓝,免疫异常。\n3回合。"
  States[73]  = "阳之力:大幅度增加双攻,增加暴击率,普攻附带虚弱。\n3回合。"
  States[74]  = "免死:免疫死亡。\n1-2回合。"
  States[75]  = "火系附加:攻击附加火属性。\n永续。"
  States[76]  = "冰系附加:攻击附加冰属性。\n永续。"
  States[77]  = "雷系附加:攻击附加雷属性。\n永续。"
  States[78]  = "土系附加:攻击附加土属性。\n永续。"
  States[79]  = "风系附加:攻击附加风属性。\n永续。"
  States[80]  = "时空结界:暂停时间。\n3回合。"
  States[80]  = "时空结界:暂停时间。\n3回合。"
  States[81]  = "圣之时空:增加双抗10%并且增加治疗效果\n每次自己对队友(包括自己使用技能目标回血0-150)"
  States[82]  = "魔之时空:增加双闪避,反击率10%,暴击率30%每回合扣除2%血量\n新被动:每次攻击敌人伤害增加30%+敏捷*2"
  States[83]  = "时空人格变数:攻击附加各种非停止行动的状态。\n永续。"
  States[84]  = "时空暂停:暂停时间。\n1-2回合。"
  States[85]  = "时空倒流:死亡后直接复活。\n3回合。"
  States[86]  = "燃烧时空盾:减少30%,减免蓝的10%伤害并且反射。\n3回合。"
  States[87]  = "时空连接:将伤害连接,可以传达伤害。\n3回合。"
  States[88]  = "被链接:将积蓄的伤害20%传达给这个单位。\n3回合。"
  States[89]  = "永生本能:减少0-70%的伤害,危急生命每次扣血会回复血量。\n被动技能。"
  States[90]  = "灼热之痕:减少命中、闪避、必杀率5%。\n2回合。"
  States[91]  = "金:攻击附加敏捷*3的伤害。\n增加10%MP上限。"
  States[92]  = "木:每次伤害回血。\n增加5%敏捷。"
  States[93]  = "水:每次伤害回蓝。\n增加10%MP上限。"
  States[94]  = "火:每次伤害附加双攻的伤害*2。\n增加双攻10%。"
  States[95]  = "土:减少伤害,反射防御力*2的伤害。\n增加双抗10%。"
  States[96]  = "反馈:受到伤害在回合结束时,给对方给予一定伤害。"
  States[97]  = "嗜血收割:伤害增加1.5倍,提高80%双攻。\n2回合"
  States[98]  = "狩猎打击:每回合扣血伤害值。\n2回合"
  States[99]  = "强弩之翼攻击:增加攻击+敏捷的伤害。"
  States[100]  = "强弩之翼防御:减少伤害,反射敏捷*2+防御*2的伤害。"
  States[101]  = "强狙速影:攻击 敏捷 物抗提高30%。"
  States[102]  = "空间回溯:2次行动后回复到之前的回血。"
  States[103]  = "影杀:技能必定暴击"
  States[104]  = "时空穿梭:10%几率行动两次,5%几率行动三次"
  States[115]  = "灵魂掌控:减少强控几率30%"
  States[116]  = "缭乱写轮眼:暴击+10%免伤+20%魔法消耗-20%命中+10%\n法强+50%物攻+50%法抗+50%"
  States[117]  = "秘境之眼:多行动一次,暴击+20%命中+20%"
  States[118]  = "光明降生:每回合回血300回蓝100"
  States[125]  = "空间折叠:必杀闪避,物理闪避,魔法闪避+10%\n3回合内每回合回复50+0-200血量"
  States[126]  = "空间结界:免疫基础强控"
  States[127]  = "幻术*魔镜幻巷:15%多行动一次,免疫剧毒沉默睡眠焚烧"
  States[132]  = "六道之力:增加物品掉落几率和金币双倍\n增加恢复能力,每次攻击随机获得三回治疗"
  States[133]  = "混沌之力:攻击附加双方全属性"
  States[134]  = "时空掌握:附加15%暴击率和命中率,5%反射力"
  States[135]  = "时空混乱:每回合扣除全属性的血量"
  


end

class Game_BattlerBase
  attr_reader :buffs
end

class Window_State < Window_Selectable
  def initialize(help_window)
    super(0,0,32,32)
#~     self.x = [Graphics.width / 2 - self.width / 2,0].max
#~     self.y = [Graphics.height / 2 - self.height / 2,help_window.height].max
    self.openness = 0
    @help_window = help_window
    refresh
  end
  def all_battle_members;($game_party.battle_members + $game_troop.members).select{|m| m.exist? };end
  def row_max;all_battle_members.size;end
  def col_max
    m = all_battle_members.max_by{|a| a.state_icons.size + a.buff_icons.size }
    [m.state_icons.size + m.buff_icons.size,1].max
  end
  def item_max;row_max*col_max;end
  def item_height; line_height + 2 ; end
  def item_width; line_height + 2 ; end
   
  def fitting_window
    self.height = item_height * row_max + standard_padding*2
    self.width = 144+(col_max*item_width) + standard_padding*2
    self.x = [Graphics.width / 2 - self.width / 2,0].max
    self.y = [Graphics.height / 2 - self.height / 2,help_window.height].max
  end
  def refresh
    fitting_window
    make_data
    create_contents
    all_battle_members.each_with_index{|a,i|
      draw_actor_name(a,0,i*item_height+1)
      draw_text(128,i*item_height+1,20,line_height,":")
      draw_icons(a, 144, i*item_height+1, contents.width - 144)
    }
  end
  
  def draw_icons(subject, x, y, width = 96)
    icons = (subject.state_icons + subject.buff_icons)[0, width / item_width]
    icons.each_with_index {|n, i| draw_icon(n, x + item_width * i, y) }
  end
  
  def item_rect(index)
    rect = Rect.new
    rect.width = item_width
    rect.height = item_height
    rect.x = index % col_max * item_width + 143
    rect.y = index / col_max * item_height
    rect
  end
  
  def update_help
    @help_window.set_text(description)
  end
  
  def make_data
    @data = all_battle_members.inject([]){|r,m|
      a = []
      a += m.states.select{|st| st.icon_index != 0 }
      bf = []
      m.buffs.each_with_index{|b,i| bf.push([i,b > 0 ? :up : :down]) if b != 0}
      a += bf
      a += Array.new(col_max - a.size){nil} if col_max > a.size
      r += a
    }
  end
  
  def description
    return "" unless @data[index]
    if @data[index].is_a?(Array)
      return StateHelp::Buffs[@data[index]]
    else
      return StateHelp::States[@data[index].id]
    end
  end
  def cursor_down(wrap = false)
    return if @data.compact.empty?
    loop do
      select((index + col_max) % item_max)
      break if @data[index]
    end
  end
  def cursor_up(wrap = false)
    return if @data.compact.empty?
    loop do
      select((index - col_max + item_max) % item_max)
      break if @data[index]
    end
  end
  def cursor_right(wrap = false)
    return if @data.compact.empty?
    loop do
      select((index + 1) % item_max)
      break if @data[index]
    end
  end
  def cursor_left(wrap = false)
    return if @data.compact.empty?
    loop do
      select((index - 1 + item_max) % item_max)
      break if @data[index]
    end
  end
  def smooth_select
    return select(0) if @data.compact.empty?
    @data.each_with_index{|d,i|
      if d
        select(i)
        return
      end
    }
  end
end

class Window_PartyCommand < Window_Command
  alias _ex_state_make_command_list make_command_list
  def make_command_list
    _ex_state_make_command_list
    add_command("状态信息",  :state)
  end
end

class Scene_Battle < Scene_Base
  alias _ex_state_create_all_windows create_all_windows
  def create_all_windows
    _ex_state_create_all_windows
    create_state_window
  end
  alias _ex_state_create_party_command_window create_party_command_window
  def create_party_command_window
    _ex_state_create_party_command_window
    @party_command_window.set_handler(:state, method(:command_state))
  end

  def create_state_window
    @state_window = Window_State.new(@help_window)
    @state_window.set_handler(:ok,  method(:command_state_cancel))
    @state_window.set_handler(:cancel, method(:command_state_cancel))
    @state_window.unselect
  end
  
  def command_state
    @party_command_window.deactivate
    @state_window.refresh
    @state_window.open.activate.smooth_select
    @help_window.show
  end
  
  def command_state_cancel
    @state_window.deactivate.close.unselect
    @party_command_window.activate
    @help_window.hide
  end
end[/pre]

随机技能[pre lang="ruby"]#==============================================================================
#
# ▼ Yanfly Engine Ace - Random Skill Invoke v1.00
# -- Last Updated: 2011.12.17
# -- Level: Normal, Hard
# -- Requires: n/a
#
#==============================================================================

$imported = {} if $imported.nil?
$imported["YEA-RandomSkillInvoke"] = true

#==============================================================================
# ▼ Updates
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# 2011.12.17 - Started Script and Finished.
#
#==============================================================================
# ▼ Introduction
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# This script grants the option, that when designated skills with random
# invokes are used, they have the ability to result in other skills (within the
# skill's designated random pool). Only valid skills are capable of being used
# (meaning that they must meet the conditions to be used).
#
#==============================================================================
# ▼ Instructions
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# To install this script, open up your script editor and copy/paste this script
# to an open slot below ▼ Materials/素材 but above ▼ Main. Remember to save.
#
# -----------------------------------------------------------------------------
# Skill Notetags - These notetags go in the skills notebox in the database.
# -----------------------------------------------------------------------------
# <random invoke: x>举个例子比如在1号技能上备注<random invoke: 2>代表你使用1号技能可能会放1号技能或者2号技能
# <random invoke: x, x>
# This adds skill x to the random invoke pool (which includes the base skill
# itself, too). When the base skill is used, it will random select from all of
# the skills within the random invoke pool and use one. Only skills that meet
# the requirements of being used can be selected (meaning the battler must have
# sufficient MP costs, TP costs, no states that seal it, etc.). Multiples of
# this tag may be used to add more skills, and multiples of the same skill may
# be added to the random invoke pool.
#
#==============================================================================
# ▼ Compatibility
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# This script is made strictly for RPG Maker VX Ace. It is highly unlikely that
# it will run with RPG Maker VX without adjusting.
#
#==============================================================================
# ▼ Editting anything past this point may potentially result in causing
# computer damage, incontinence, explosion of user's head, coma, death, and/or
# halitosis so edit at your own risk.
#==============================================================================

module YEA
  module REGEXP
  module SKILL
   
    RANDOM_INVOKE =
      /<(?:RANDOM_INVOKE|random invoke):[ ]*(\d+(?:\s*,\s*\d+)*)>/i
   
  end # SKILL
  end # REGEXP
end # YEA

#==============================================================================
# ■ DataManager
#==============================================================================

module DataManager
  
  #--------------------------------------------------------------------------
  # alias method: load_database
  #--------------------------------------------------------------------------
  class <<self; alias load_database_rsi load_database; end
  def self.load_database
    load_database_rsi
    load_notetags_rsi
  end
  
  #--------------------------------------------------------------------------
  # new method: load_notetags_rsi
  #--------------------------------------------------------------------------
  def self.load_notetags_rsi
    for skill in $data_skills
      next if skill.nil?
      skill.load_notetags_rsi
    end
  end
  
end # DataManager

#==============================================================================
# ■ RPG::Skill
#==============================================================================

class RPG::Skill < RPG::UsableItem
  
  #--------------------------------------------------------------------------
  # public instance variables
  #--------------------------------------------------------------------------
  attr_accessor :random_invoke
  
  #--------------------------------------------------------------------------
  # common cache: load_notetags_rsi
  #--------------------------------------------------------------------------
  def load_notetags_rsi
    @random_invoke = []
    #---
    self.note.split(/[\r\n]+/).each { |line|
      case line
      #---
      when YEA::REGEXP::SKILL::RANDOM_INVOKE
        $1.scan(/\d+/).each { |num|
        @random_invoke.push(num.to_i) if num.to_i > 0 }
      #---
      end
    } # self.note.split
    #---
  end
  
end # RPG::Weapon

#==============================================================================
# ■ Game_Battler
#==============================================================================

class Game_Battler < Game_BattlerBase
  
  #--------------------------------------------------------------------------
  # new method: invoke_random_skill
  #--------------------------------------------------------------------------
  def invoke_random_skill
    return unless current_action.item.is_a?(RPG::Skill)
    valid_skills = [current_action.item]
    for random_skill_id in current_action.item.random_invoke
      next unless usable?($data_skills[random_skill_id])
      valid_skills.push($data_skills[random_skill_id])
    end
    skill_id = valid_skills.sample.id
    current_action.set_skill(skill_id)
  end
  
end # Game_Battler

#==============================================================================
# ■ Scene_Battle
#==============================================================================

class Scene_Battle < Scene_Base
  
  #--------------------------------------------------------------------------
  # alias method: use_item
  #--------------------------------------------------------------------------
  alias scene_battle_use_item_rsi use_item
  def use_item
    @subject.invoke_random_skill
    scene_battle_use_item_rsi
  end
  
end # Scene_Battle

#==============================================================================
#
# ▼ End of File
#
#==============================================================================[/pre]

敌人信息显示[pre lang="ruby"]#==============================================================================
#
# ▼ Yanfly Engine Ace - Enemy Target Info v1.02
# -- Last Updated: 2012.01.01
# -- Level: Normal
# -- Requires: YEA - Ace Battle Engine v1.10+.
#
#==============================================================================

$imported = {} if $imported.nil?
$imported["YEA-EnemyTargetInfo"] = true

#==============================================================================
# ▼ Updates
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# 2012.01.01 - Bug Fixed: <scan info: all> didn't work properly.
# 2011.12.30 - Bug Fixed: Crash when using Ace Battle Engine's F8 debug.
# 2011.12.29 - Started Script and Finished.
#
#==============================================================================
# ▼ Introduction
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# The enemy target info window can be activated in battle to show enemy data
# at the bottom of the screen. Information can be revealed straight from the
# start or requires the player to actively reveal the information on their own
# through either defeating the enemies, using skills on them, or scanning them
# in various ways produced by the script.
#
#==============================================================================
# ▼ Instructions
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# To install this script, open up your script editor and copy/paste this script
# to an open slot below ▼ Materials/素材 but above ▼ Main. Remember to save.
#
# -----------------------------------------------------------------------------
# Skill Notetags - These notetags go in the skill notebox in the database.
# -----------------------------------------------------------------------------
# <scan info: all>
# This will scan the target enemy of all properties that are shown in the
# comparison windows. Unless the enemy has a permanent hide tag, all of the
# data becomes available.
#
# <scan info: parameters>
# This will scan the target enemy's parameters and reveal them to the player
# unless the enemy has a permanent hide tag.
#
# <scan info: elements>
# This will scan the target enemy's elemental resistances and reveal them to
# the player unless the enemy has a permanent hide tag.
#
# <scan info: states>
# This will scan the target enemy's state resistances and reveal them to the
# player unless the enemy has a permanent hide tag.
#
# <scan element: x>
# <scan element: x, x>
# This will scan the target enemy's elemental resistance for element x. Insert
# multiple of these tags to scan more elements. If you have the automatic scan
# element setting on in the module, all skills and items will automatically
# scan whatever element the skill or item deals damage with innately.
#
# <scan state: x>
# <scan state: x, x>
# This will scan the target enemy's state resistance for element x. Insert
# multiple of these tags to scan more states. If you have the automatic scan
# state setting on in the module, all skills and items will automatically
# scan whatever state the skill or item inflicts innately.
#
# -----------------------------------------------------------------------------
# Item Notetags - These notetags go in the item notebox in the database.
# -----------------------------------------------------------------------------
# <scan info: all>
# This will scan the target enemy of all properties that are shown in the
# comparison windows. Unless the enemy has a permanent hide tag, all of the
# data becomes available.
#
# <scan info: parameters>
# This will scan the target enemy's parameters and reveal them to the player
# unless the enemy has a permanent hide tag.
#
# <scan info: elements>
# This will scan the target enemy's elemental resistances and reveal them to
# the player unless the enemy has a permanent hide tag.
#
# <scan info: states>
# This will scan the target enemy's state resistances and reveal them to the
# player unless the enemy has a permanent hide tag.
#
# <scan element: x>
# <scan element: x, x>
# This will scan the target enemy's elemental resistance for element x. Insert
# multiple of these tags to scan more elements. If you have the automatic scan
# element setting on in the module, all skills and items will automatically
# scan whatever element the skill or item deals damage with innately.
#
# <scan state: x>
# <scan state: x, x>
# This will scan the target enemy's state resistance for element x. Insert
# multiple of these tags to scan more states. If you have the automatic scan
# state setting on in the module, all skills and items will automatically
# scan whatever state the skill or item inflicts innately.
#
# -----------------------------------------------------------------------------
# Enemy Notetags - These notetags go in the enemies notebox in the database.
# -----------------------------------------------------------------------------
# <hide info: all>
# <show info: all>
# These notetags will set the enemy to either always hide all of their battle
# information or to always show all of their info. The tags will override
# each other if both are used simultaneously.
#
# <hide info: parameters>
# <show info: parameters>
# These notetags will set the enemy to either always hide their parameter
# information or to always show their parameter info. The tags will override
# each other if both are used simultaneously.
#
# <hide info: elements>
# <show info: elements>
# These notetags will set the enemy to either always hide their element
# information or to always show their element info. The tags will override
# each other if both are used simultaneously.
#
# <hide info: states>
# <show info: states>
# These notetags will set the enemy to either always hide their state
# information or to always show their state info. The tags will override
# each other if both are used simultaneously.
#
#==============================================================================
# ▼ Compatibility
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# This script is made strictly for RPG Maker VX Ace. It is highly unlikely that
# it will run with RPG Maker VX without adjusting.
#
# This script requires Yanfly Engine Ace - Ace Battle Engine v1.10+ and the
# script must be placed under Ace Battle Engine in the script listing.
#
#==============================================================================

module YEA
  module ENEMY_INFO
   
    #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    # - Info Window Settings -
    #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    # These are the general settings revolving around the info windows shown in
    # battle such as the sound effect played, the button used to open up the
    # menus, the page orders, and the info text.
    #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    INFO_SFX = RPG::SE.new("Book2", 80, 150) # SFX played for Info Window.
   
    # Button used to toggle the Info Window. Keep in mind that L and R are
    # used for moving between pages so it's best to not use those.
    INFO_BUTTON = :SHIFT
   
    # This sets the page order in which data is displayed for the player. The
    # player can switch pages by pressing L or R.
    PAGE_ORDER =[
      :parameters,
      :elements,
      :states,
    ] # Do not remove this.
   
    # If testplay is being used, reveal all battle information for non-hidden
    # enemy information?
    SHOW_DEBUG_ALL = true
   
    # The follow adjusts the settings regarding the help window. If this
    # setting is on, the the help info will be displayed.
    SHOW_HELP_INFO = true
    HELP_WINDOW_Y  = 72    # Y location of the help window.
   
    # This is the text displayed to let the player know how to activate and
    # show the info windows.
    HELP_INFO_SHOW = "\e}按 \eC[4]SHIFT键\eC[0] 查看信息."
   
    # This is the text displayed to let the player know how to switch between
    # pages for the info windows.
    HELP_INFO_SWITCH = "\e}按 \eC[4]L键\eC[0] or \eC[4]R键\eC[0] 查看其他信息."
   
    #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    # - General Page Settings -
    #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    # The general page shows the stats of the battlers. The player can compare
    # and contrast the stats of both battlers relative to each other. The
    # settings here adjust the font size, the text displayed if parameters are
    # hidden, and whether or not to show parameters by default?
    #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    PARAM_FONT_SIZE     = 20       # Font size used for parameters.
    HIDDEN_PARAM_TEXT   = "???"    # Text used if parameters are hidden.
   
    # Show the parameters by default? If false, the enemy must be defeated once
    # or scanned to show the those parameters.
    DEFAULT_SHOW_PARAMS = false
   
    #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    # - Element Page Settings -
    #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    # The elements page shows the elemental resistances of the battlers. The
    # player can compare and contrast the resistances relative to each other.
    #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    ELE_FONT_SIZE   = 20       # Font size used for element resistances.
    HIDDEN_ELE_TEXT = "???"    # Text used if element resistances are hidden.
    SHOWN_ELEMENTS  = [3..10]  # Elements shown. Maximum of 8 can be shown.
    ELEMENT_ICONS   ={         # Contains element icon information.
    # Element ID => Icon,
               3 =>  96, # Fire
               4 =>  97, # Ice
               5 =>  98, # Thunder
               6 =>  99, # Water
               7 => 100, # Earth
               8 => 101, # Wind
               9 => 102, # Holy
              10 => 103, # Dark
    } # Do not remove this.
   
    # Show the elemental resistances by default? If false, a skill with the
    # specific element must be used on the enemy to reveal the element data if
    # the AUTO_SCAN_ELEMENT setting is set to true.
    DEFAULT_SHOW_ELEMENTS = false
   
    # If this is set to true, then skills with elemental properties will
    # automatically scan the specific elemental resistance of that enemy type
    # when used against that enemy.
    AUTO_SCAN_ELEMENT = true
   
    #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    # - States Page Settings -
    #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    # The states page shows the state resistances of the battlers. The player
    # can compare and contrast the resistances relative to each other.
    #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    STATE_FONT_SIZE   = 20     # Font size used for state resistances.
    HIDDEN_STATE_TEXT = "???"  # Text used if state resistances are hidden.
    SHOWN_STATES = [7..14]     # States shown. Maximum of 8 can be shown.
   
    # Show the state resistances by default? If false, a skill with the
    # specific state must be used on the enemy to reveal the element data if
    # the AUTO_SCAN_STATES setting is set to true.
    DEFAULT_SHOW_STATES = false
   
    # If this is set to true, then skills with state applying properties will
    # automatically scan the specific state resistance of that enemy type
    # when used against that enemy.
    AUTO_SCAN_STATES = true
   
  end # ENEMY_INFO
end # YEA

#==============================================================================
# ▼ Editting anything past this point may potentially result in causing
# computer damage, incontinence, explosion of user's head, coma, death, and/or
# halitosis so edit at your own risk.
#==============================================================================

if $imported["YEA-BattleEngine"]

module YEA
  module ENEMY_INFO
    module_function
    #--------------------------------------------------------------------------
    # convert_integer_array
    #--------------------------------------------------------------------------
    def convert_integer_array(array)
      result = []
      array.each { |i|
        case i
        when Range; result |= i.to_a
        when Integer; result |=
        end }
      return result
    end
    #--------------------------------------------------------------------------
    # converted_contants
    #--------------------------------------------------------------------------
    SHOWN_ELEMENTS = convert_integer_array(SHOWN_ELEMENTS)
    SHOWN_STATES = convert_integer_array(SHOWN_STATES)
  end # ENEMY_INFO
  module REGEXP
  module ENEMY
   
    HIDE_INFO = /<(?:HIDE_INFO|hide info):[ ](.*)>/i
    SHOW_INFO = /<(?:SHOW_INFO|show info):[ ](.*)>/i
   
  end # ENEMY
  module USABLEITEM
   
    SCAN_INFO = /<(?:SCAN_INFO|scan info):[ ](.*)>/i
    SCAN_ELE = /<(?:SCAN_ELE|scan ele|scan element):[ ]*(\d+(?:\s*,\s*\d+)*)>/i
    SCAN_STATE = /<(?:SCAN_STATE|scan state):[ ]*(\d+(?:\s*,\s*\d+)*)>/i
   
  end # USABLEITEM
  end # REGEXP
end # YEA

#==============================================================================
# ■ Icon
#==============================================================================

module Icon
  
  #--------------------------------------------------------------------------
  # self.element
  #--------------------------------------------------------------------------
  def self.element(id)
    return 0 unless YEA::ENEMY_INFO::ELEMENT_ICONS.include?(id)
    return YEA::ENEMY_INFO::ELEMENT_ICONS[id]
  end
   
end # Icon

#==============================================================================
# ■ Numeric
#==============================================================================

class Numeric
  
  #--------------------------------------------------------------------------
  # new method: group_digits
  #--------------------------------------------------------------------------
  unless $imported["YEA-CoreEngine"]
  def group; return self.to_s; end
  end # $imported["YEA-CoreEngine"]
   
end # Numeric

#==============================================================================
# ■ DataManager
#==============================================================================

module DataManager
  
  #--------------------------------------------------------------------------
  # alias method: load_database
  #--------------------------------------------------------------------------
  class <<self; alias load_database_eti load_database; end
  def self.load_database
    load_database_eti
    load_notetags_etin
  end
  
  #--------------------------------------------------------------------------
  # new method: load_notetags_etin
  #--------------------------------------------------------------------------
  def self.load_notetags_etin
    groups = [$data_enemies, $data_skills, $data_items]
    for group in groups
      for obj in group
        next if obj.nil?
        obj.load_notetags_etin
      end
    end
  end
  
end # DataManager

#==============================================================================
# ■ RPG::Enemy
#==============================================================================

class RPG::Enemy < RPG::BaseItem
  
  #--------------------------------------------------------------------------
  # public instance variables
  #--------------------------------------------------------------------------
  attr_accessor :hide_info
  attr_accessor :show_info
  
  #--------------------------------------------------------------------------
  # common cache: load_notetags_etin
  #--------------------------------------------------------------------------
  def load_notetags_etin
    @hide_info = []
    @show_info = []
    #---
    self.note.split(/[\r\n]+/).each { |line|
      case line
      #---
      when YEA::REGEXP::ENEMY::HIDE_INFO
        case $1.upcase
        when "PARAM", "PARAMETER", "PARAMETERS"
          @hide_info.push(:param)
          @show_info.delete(:param)
        when "ELE", "ELEMENT", "ELEMENTS"
          @hide_info.push(:ele)
          @show_info.delete(:ele)
        when "STATE", "STATES"
          @hide_info.push(:state)
          @show_info.delete(:state)
        when "ALL"
          @hide_info.push(:all)
          @show_info.delete(:all)
        end
      #---
      when YEA::REGEXP::ENEMY::SHOW_INFO
        case $1.upcase
        when "PARAM", "PARAMETER", "PARAMETERS"
          @show_info.push(:param)
          @hide_info.delete(:param)
        when "ELE", "ELEMENT", "ELEMENTS"
          @show_info.push(:ele)
          @hide_info.delete(:ele)
        when "STATE", "STATES"
          @show_info.push(:state)
          @hide_info.delete(:state)
        when "ALL"
          @show_info.push(:all)
          @hide_info.delete(:all)
        end
      #---
      end
    } # self.note.split
    #---
  end
  
end # RPG::Enemy

#==============================================================================
# ■ RPG::UsableItem
#==============================================================================

class RPG::UsableItem < RPG::BaseItem
  
  #--------------------------------------------------------------------------
  # public instance variables
  #--------------------------------------------------------------------------
  attr_accessor :scan_info
  attr_accessor :scan_ele
  attr_accessor :scan_state
  
  #--------------------------------------------------------------------------
  # common cache: load_notetags_etin
  #--------------------------------------------------------------------------
  def load_notetags_etin
    @scan_info = []
    @scan_ele = []
    @scan_state = []
    #---
    self.note.split(/[\r\n]+/).each { |line|
      case line
      #---
      when YEA::REGEXP::USABLEITEM::SCAN_INFO
        case $1.upcase
        when "PARAM", "PARAMETER", "PARAMETERS"
          @scan_info.push(:param)
        when "ELE", "ELEMENT", "ELEMENTS"
          @scan_info.push(:ele)
        when "STATE", "STATES"
          @scan_info.push(:state)
        when "ALL"
          @scan_info.push(:all)
        end
      #---
      when YEA::REGEXP::USABLEITEM::SCAN_ELE
        $1.scan(/\d+/).each { |num|
        @scan_ele.push(num.to_i) if num.to_i > 0 }
      when YEA::REGEXP::USABLEITEM::SCAN_STATE
        $1.scan(/\d+/).each { |num|
        @scan_state.push(num.to_i) if num.to_i > 0 }
      #---
      end
    } # self.note.split
    #---
    @scan_ele.push(self.damage.element_id) if YEA::ENEMY_INFO::AUTO_SCAN_ELEMENT
    if YEA::ENEMY_INFO::AUTO_SCAN_STATES
      for effect in @effects
        next unless effect.code == 21
        next unless effect.data_id > 0
        @scan_state.push(effect.data_id)
      end
    end
  end
  
end # RPG::UsableItem

#==============================================================================
# ■ Game_System
#==============================================================================

class Game_System
  
  #--------------------------------------------------------------------------
  # alias method: initialize
  #--------------------------------------------------------------------------
  alias game_system_initialize_eti initialize
  def initialize
    game_system_initialize_eti
    initialize_enemy_info_data
  end
  
  #--------------------------------------------------------------------------
  # new method: initialize_enemy_info_data
  #--------------------------------------------------------------------------
  def initialize_enemy_info_data
    @param_enemies = [] if @param_enemies.nil?
    @ele_enemies = {} if @ele_enemies.nil?
    @state_enemies = {} if @state_enemies.nil?
  end
  
  #--------------------------------------------------------------------------
  # new method: info_param_enemies
  #--------------------------------------------------------------------------
  def info_param_enemies
    initialize_enemy_info_data if @param_enemies.nil?
    return @param_enemies
  end
  
  #--------------------------------------------------------------------------
  # new method: add_info_param_enemies
  #--------------------------------------------------------------------------
  def add_info_param_enemies(id)
    initialize_enemy_info_data if @param_enemies.nil?
    @param_enemies.push(id) unless @param_enemies.include?(id)
  end
  
  #--------------------------------------------------------------------------
  # new method: info_ele_enemies
  #--------------------------------------------------------------------------
  def info_ele_enemies(ele_id)
    initialize_enemy_info_data if @ele_enemies.nil?
    @ele_enemies[ele_id] = [] if @ele_enemies[ele_id].nil?
    return @ele_enemies[ele_id]
  end
  
  #--------------------------------------------------------------------------
  # new method: add_info_ele_enemies
  #--------------------------------------------------------------------------
  def add_info_ele_enemies(ele_id, id)
    initialize_enemy_info_data if @ele_enemies.nil?
    @ele_enemies[ele_id] = [] if @ele_enemies[ele_id].nil?
    @ele_enemies[ele_id].push(id) unless @ele_enemies[ele_id].include?(id)
  end
  
  #--------------------------------------------------------------------------
  # new method: info_state_enemies
  #--------------------------------------------------------------------------
  def info_state_enemies(state_id)
    initialize_enemy_info_data if @state_enemies.nil?
    @state_enemies[state_id] = [] if @state_enemies[state_id].nil?
    return @state_enemies[state_id]
  end
  
  #--------------------------------------------------------------------------
  # new method: add_info_state_enemies
  #--------------------------------------------------------------------------
  def add_info_state_enemies(state_id, id)
    initialize_enemy_info_data if @state_enemies.nil?
    @state_enemies[state_id] = [] if @state_enemies[state_id].nil?
    @state_enemies[state_id].push(id) if !@state_enemies[state_id].include?(id)
  end
  
end # Game_System

#==============================================================================
# ■ Game_BattlerBase
#==============================================================================

class Game_BattlerBase
  
  #--------------------------------------------------------------------------
  # new method: show_info_param?
  #--------------------------------------------------------------------------
  def show_info_param?
    return true if YEA::ENEMY_INFO::SHOW_DEBUG_ALL && ($TEST || $BTEST)
    return YEA::ENEMY_INFO::DEFAULT_SHOW_PARAMS
  end
  
  #--------------------------------------------------------------------------
  # new method: show_info_element?
  #--------------------------------------------------------------------------
  def show_info_element?(ele_id)
    return true if YEA::ENEMY_INFO::SHOW_DEBUG_ALL && ($TEST || $BTEST)
    return YEA::ENEMY_INFO::DEFAULT_SHOW_ELEMENTS
  end
  
  #--------------------------------------------------------------------------
  # new method: show_info_state?
  #--------------------------------------------------------------------------
  def show_info_state?(state_id)
    return true if YEA::ENEMY_INFO::SHOW_DEBUG_ALL && ($TEST || $BTEST)
    return YEA::ENEMY_INFO::DEFAULT_SHOW_STATES
  end
  
end # Game_BattlerBase

#==============================================================================
# ■ Game_Battler
#==============================================================================

class Game_Battler < Game_BattlerBase
  
  #--------------------------------------------------------------------------
  # alias method: die
  #--------------------------------------------------------------------------
  alias game_battler_die_eti die
  def die
    game_battler_die_eti
    return if actor?
    $game_system.add_info_param_enemies(@enemy_id)
  end
  
  #--------------------------------------------------------------------------
  # alias method: item_user_effect
  #--------------------------------------------------------------------------
  alias game_battler_item_user_effect_eti item_user_effect
  def item_user_effect(user, item)
    game_battler_item_user_effect_eti(user, item)
    scan_enemy_info_effect(user, item)
  end
  
  #--------------------------------------------------------------------------
  # new method: scan_enemy_info_effect
  #--------------------------------------------------------------------------
  def scan_enemy_info_effect(user, item)
    return if self.actor?
    return unless user.actor?
    #---
    for info in item.scan_info
      case info
      when :all
        $game_system.add_info_param_enemies(@enemy_id)
        for i in 0...$data_system.elements.size
          $game_system.add_info_ele_enemies(i, @enemy_id)
        end
        for i in 0...$data_states.size
          $game_system.add_info_state_enemies(i, @enemy_id)
        end
      when :param
        $game_system.add_info_param_enemies(@enemy_id)
      when :ele
        for i in 0...$data_system.elements.size
          $game_system.add_info_ele_enemies(i, @enemy_id)
        end
      when :state
        for i in 0...$data_states.size
          $game_system.add_info_state_enemies(i, @enemy_id)
        end
      end
    end
    #---
    for ele_id in item.scan_ele
      $game_system.add_info_ele_enemies(ele_id, @enemy_id)
    end
    for state_id in item.scan_state
      $game_system.add_info_state_enemies(state_id, @enemy_id)
    end
  end
  
end # Game_Battler

#==============================================================================
# ■ Game_Actor
#==============================================================================

class Game_Actor < Game_Battler
  
  #--------------------------------------------------------------------------
  # new method: show_info_param?
  #--------------------------------------------------------------------------
  def show_info_param?
    return true
  end
  
  #--------------------------------------------------------------------------
  # new method: show_info_element?
  #--------------------------------------------------------------------------
  def show_info_element?(ele_id)
    return true
  end
  
  #--------------------------------------------------------------------------
  # new method: show_info_state?
  #--------------------------------------------------------------------------
  def show_info_state?(state_id)
    return true
  end
  
end # Game_Actor

#==============================================================================
# ■ Game_Enemy
#==============================================================================

class Game_Enemy < Game_Battler
  
  #--------------------------------------------------------------------------
  # new method: show_info_param?
  #--------------------------------------------------------------------------
  def show_info_param?
    return false if enemy.hide_info.include?(:param)
    return false if enemy.hide_info.include?(:all)
    return true if enemy.show_info.include?(:param)
    return true if enemy.show_info.include?(:all)
    return true if $game_system.info_param_enemies.include?(@enemy_id)
    return super
  end
  
  #--------------------------------------------------------------------------
  # new method: show_info_element?
  #--------------------------------------------------------------------------
  def show_info_element?(ele_id)
    return false if enemy.hide_info.include?(:ele)
    return false if enemy.hide_info.include?(:all)
    return true if enemy.show_info.include?(:ele)
    return true if enemy.show_info.include?(:all)
    return true if $game_system.info_ele_enemies(ele_id).include?(@enemy_id)
    return super(ele_id)
  end
  
  #--------------------------------------------------------------------------
  # new method: show_info_state?
  #--------------------------------------------------------------------------
  def show_info_state?(state_id)
    return false if enemy.hide_info.include?(:state)
    return false if enemy.hide_info.include?(:all)
    return true if enemy.show_info.include?(:state)
    return true if enemy.show_info.include?(:all)
    return true if $game_system.info_state_enemies(state_id).include?(@enemy_id)
    return super(state_id)
  end
  
end # Game_Enemy

#==============================================================================
# ■ Window_Comparison
#==============================================================================

class Window_Comparison < Window_Base
  
  #--------------------------------------------------------------------------
  # initialize
  #--------------------------------------------------------------------------
  def initialize(type)
    dx = type == :actor ? 0 : Graphics.width / 2
    dh = fitting_height(4)
    super(dx, Graphics.height - dh, Graphics.width / 2, dh)
    @button = YEA::ENEMY_INFO::INFO_BUTTON
    @battler = nil
    @type = type
    @page = 0
    hide
  end
  
  #--------------------------------------------------------------------------
  # update
  #--------------------------------------------------------------------------
  def update
    super
    return unless @type == :enemy
    process_enemy_window_input
    return unless self.visible
    reveal(SceneManager.scene.enemy_window.enemy)
  end
  
  #--------------------------------------------------------------------------
  # process_enemy_window_input
  #--------------------------------------------------------------------------
  def process_enemy_window_input
    return unless SceneManager.scene_is?(Scene_Battle)
    return unless SceneManager.scene.enemy_window.active
    return if SceneManager.scene.enemy_window.select_all?
    SceneManager.scene.toggle_enemy_info if Input.trigger?(@button)
    return unless self.visible
    SceneManager.scene.enemy_info_page_up if Input.trigger?(:L)
    SceneManager.scene.enemy_info_page_down if Input.trigger?(:R)
  end
  
  #--------------------------------------------------------------------------
  # reveal
  #--------------------------------------------------------------------------
  def reveal(battler)
    return if @battler == battler
    @battler = battler
    refresh
    show
  end
  
  #--------------------------------------------------------------------------
  # clear
  #--------------------------------------------------------------------------
  def clear
    @battler = nil
    @page = 0
    hide
  end
  
  #--------------------------------------------------------------------------
  # actor
  #--------------------------------------------------------------------------
  def actor; return BattleManager.actor; end
  
  #--------------------------------------------------------------------------
  # enemy
  #--------------------------------------------------------------------------
  def enemy; return SceneManager.scene.enemy_window.enemy; end
  
  #--------------------------------------------------------------------------
  # page_up
  #--------------------------------------------------------------------------
  def page_up
    @page = @page == 0 ? YEA::ENEMY_INFO::PAGE_ORDER.size - 1 : @page - 1
    refresh
  end
  
  #--------------------------------------------------------------------------
  # page_down
  #--------------------------------------------------------------------------
  def page_down
    @page = @page == YEA::ENEMY_INFO::PAGE_ORDER.size - 1 ? 0 : @page + 1
    refresh
  end
  
  #--------------------------------------------------------------------------
  # refresh
  #--------------------------------------------------------------------------
  def refresh
    contents.clear
    reset_font_settings
    draw_page(@page)
  end
  
  #--------------------------------------------------------------------------
  # draw_page
  #--------------------------------------------------------------------------
  def draw_page(page_id)
    return if @battler.nil?
    case YEA::ENEMY_INFO::PAGE_ORDER[page_id]
    when :parameters
      @battler = actor if @type == :actor
      draw_parameters
    when :elements
      @battler = enemy if @type == :actor
      draw_parameters if @type == :actor
      draw_elements if @type == :enemy
    when :states
      @battler = enemy if @type == :actor
      draw_parameters if @type == :actor
      draw_states if @type == :enemy
    end
  end
  
  #--------------------------------------------------------------------------
  # draw_parameters
  #--------------------------------------------------------------------------
  def draw_parameters
    draw_text(4, 0, contents.width, line_height, @battler.name)
    dx = contents.width / 2
    contents.font.size = YEA::ENEMY_INFO::PARAM_FONT_SIZE
    draw_param(2, 0, line_height*1); draw_param(3, dx, line_height*1)
    draw_param(4, 0, line_height*2); draw_param(5, dx, line_height*2)
    draw_param(6, 0, line_height*3); draw_param(7, dx, line_height*3)
  end
  
  #--------------------------------------------------------------------------
  # draw_param
  #--------------------------------------------------------------------------
  def draw_param(param_id, dx, dy)
    dw = contents.width / 2
    colour = Color.new(0, 0, 0, translucent_alpha/2)
    rect = Rect.new(dx+1, dy+1, dw - 2, line_height - 2)
    contents.fill_rect(rect, colour)
    #---
    change_color(system_color)
    draw_text(dx+4, dy, dw-8, line_height, Vocab::param(param_id))
    change_color(normal_color)
    if @battler.show_info_param?
      text = @battler.param(param_id).group
    else
      text = YEA::ENEMY_INFO::HIDDEN_PARAM_TEXT
    end
    draw_text(dx+4, dy, dw-8, line_height, text, 2)
  end
  
  #--------------------------------------------------------------------------
  # draw_elements
  #--------------------------------------------------------------------------
  def draw_elements
    dx = 0; dy = 0
    contents.font.size = YEA::ENEMY_INFO::ELE_FONT_SIZE
    for ele_id in YEA::ENEMY_INFO::SHOWN_ELEMENTS
      draw_element_info(ele_id, dx, dy)
      dx = dx == 0 ? contents.width / 2 : 0
      dy += dx == 0 ? line_height : 0
    end
  end
  
  #--------------------------------------------------------------------------
  # draw_element_info
  #--------------------------------------------------------------------------
  def draw_element_info(ele_id, dx, dy)
    dw = contents.width / 2
    colour = Color.new(0, 0, 0, translucent_alpha/2)
    rect = Rect.new(dx+1, dy+1, dw - 2, line_height - 2)
    contents.fill_rect(rect, colour)
    #---
    draw_icon(Icon.element(ele_id), dx, dy)
    change_color(system_color)
    draw_text(dx+24, dy, dw-24, line_height, $data_system.elements[ele_id])
    change_color(normal_color)
    if @battler.show_info_element?(ele_id)
      text = sprintf("%d%%", (@battler.element_rate(ele_id) * 100).to_i)
    else
      text = YEA::ENEMY_INFO::HIDDEN_ELE_TEXT
    end
    draw_text(dx+4, dy, dw-8, line_height, text, 2)
  end
  
  #--------------------------------------------------------------------------
  # draw_states
  #--------------------------------------------------------------------------
  def draw_states
    dx = 0; dy = 0
    contents.font.size = YEA::ENEMY_INFO::ELE_FONT_SIZE
    for state_id in YEA::ENEMY_INFO::SHOWN_STATES
      draw_state_info(state_id, dx, dy)
      dx = dx == 0 ? contents.width / 2 : 0
      dy += dx == 0 ? line_height : 0
    end
  end
  
  #--------------------------------------------------------------------------
  # draw_state_info
  #--------------------------------------------------------------------------
  def draw_state_info(state_id, dx, dy)
    dw = contents.width / 2
    colour = Color.new(0, 0, 0, translucent_alpha/2)
    rect = Rect.new(dx+1, dy+1, dw - 2, line_height - 2)
    contents.fill_rect(rect, colour)
    #---
    draw_icon($data_states[state_id].icon_index, dx, dy)
    change_color(system_color)
    draw_text(dx+24, dy, dw-24, line_height, $data_states[state_id].name)
    change_color(normal_color)
    if @battler.show_info_state?(state_id)
      text = sprintf("%d%%", (@battler.state_rate(state_id) * 100).to_i)
    else
      text = YEA::ENEMY_INFO::HIDDEN_STATE_TEXT
    end
    draw_text(dx+4, dy, dw-8, line_height, text, 2)
  end
  
end # Window_Comparison

#==============================================================================
# ■ Window_ComparisonHelp
#==============================================================================

class Window_ComparisonHelp < Window_Base
  
  #--------------------------------------------------------------------------
  # initialize
  #--------------------------------------------------------------------------
  def initialize(info_window)
    dy = YEA::ENEMY_INFO::HELP_WINDOW_Y
    super(-12, dy, Graphics.width + 24, fitting_height(1))
    @info_window = info_window
    self.opacity = 0
    self.z = 300
    @text = ""
    hide
  end
  
  #--------------------------------------------------------------------------
  # update
  #--------------------------------------------------------------------------
  def update
    super
    return unless YEA::ENEMY_INFO::SHOW_HELP_INFO
    update_visibility
    update_text
  end
  
  #--------------------------------------------------------------------------
  # update_visibility
  #--------------------------------------------------------------------------
  def update_visibility
    return unless SceneManager.scene_is?(Scene_Battle)
    return if SceneManager.scene.enemy_window.select_all?
    self.visible = SceneManager.scene.enemy_window.active
  end
  
  #--------------------------------------------------------------------------
  # update_text
  #--------------------------------------------------------------------------
  def update_text
    return unless self.visible
    if @info_window.visible
      text = YEA::ENEMY_INFO::HELP_INFO_SWITCH
    else
      text = YEA::ENEMY_INFO::HELP_INFO_SHOW
    end
    return if @text == text
    @text = text
    refresh
  end
  
  #--------------------------------------------------------------------------
  # refresh
  #--------------------------------------------------------------------------
  def refresh
    contents.clear
    reset_font_settings
    draw_background
    draw_text_ex(4, 0, @text)
  end
  
  #--------------------------------------------------------------------------
  # draw_background
  #--------------------------------------------------------------------------
  def draw_background
    temp_rect = Rect.new(0, 0, contents.width / 2, contents.height)
    colour1 = Color.new(0, 0, 0, 192)
    colour2 = Color.new(0, 0, 0, 0)
    contents.gradient_fill_rect(temp_rect, colour1, colour2)
  end
  
end # Window_ComparisonHelp

#==============================================================================
# ■ Scene_Battle
#==============================================================================

class Scene_Battle < Scene_Base
  
  #--------------------------------------------------------------------------
  # alias method: create_all_windows
  #--------------------------------------------------------------------------
  alias scene_battle_create_all_windows_eti create_all_windows
  def create_all_windows
    scene_battle_create_all_windows_eti
    create_comparison_windows
  end
  
  #--------------------------------------------------------------------------
  # alias method: create_comparison_windows
  #--------------------------------------------------------------------------
  def create_comparison_windows
    @actor_info_window = Window_Comparison.new(:actor)
    @enemy_info_window = Window_Comparison.new(:enemy)
    @info_help_window = Window_ComparisonHelp.new(@enemy_info_window)
  end
  
  #--------------------------------------------------------------------------
  # new method: toggle_enemy_info
  #--------------------------------------------------------------------------
  def toggle_enemy_info
    YEA::ENEMY_INFO::INFO_SFX.play
    if @enemy_info_window.visible
      hide_comparison_windows
    else
      show_comparison_windows
    end
  end
  
  #--------------------------------------------------------------------------
  # new method: enemy_info_page_up
  #--------------------------------------------------------------------------
  def enemy_info_page_up
    YEA::ENEMY_INFO::INFO_SFX.play
    @actor_info_window.page_up
    @enemy_info_window.page_up
  end
  
  #--------------------------------------------------------------------------
  # new method: enemy_info_page_down
  #--------------------------------------------------------------------------
  def enemy_info_page_down
    YEA::ENEMY_INFO::INFO_SFX.play
    @actor_info_window.page_down
    @enemy_info_window.page_down
  end
  
  #--------------------------------------------------------------------------
  # alias method: on_enemy_ok
  #--------------------------------------------------------------------------
  alias scene_battle_on_enemy_ok_eti on_enemy_ok
  def on_enemy_ok
    hide_comparison_windows
    scene_battle_on_enemy_ok_eti
  end
  
  #--------------------------------------------------------------------------
  # alias method: on_enemy_cancel
  #--------------------------------------------------------------------------
  alias scene_battle_on_enemy_cancel_eti on_enemy_cancel
  def on_enemy_cancel
    hide_comparison_windows
    scene_battle_on_enemy_cancel_eti
  end
  
  #--------------------------------------------------------------------------
  # new method: show_comparison_windows
  #--------------------------------------------------------------------------
  def show_comparison_windows
    @actor_info_window.reveal(BattleManager.actor)
    @enemy_info_window.reveal(@enemy_window.enemy)
    @info_viewport.visible = false
    @skill_window.y = Graphics.height * 2
    @item_window.y = Graphics.height * 2
    @status_aid_window.y = Graphics.height * 2
  end
  
  #--------------------------------------------------------------------------
  # new method: hide_comparison_windows
  #--------------------------------------------------------------------------
  def hide_comparison_windows
    @actor_info_window.clear
    @enemy_info_window.clear
    @info_viewport.visible = true
    @skill_window.y = Graphics.height - @skill_window.height
    @item_window.y = Graphics.height - @item_window.height
    @status_aid_window.y = Graphics.height - @status_aid_window.height
  end
  
end # Scene_Battle

end # $imported["YEA-BattleEngine"]

#==============================================================================
#
# ▼ End of File
#
#==============================================================================[/pre]

自己修改的精英敌人脚本(格式自己画葫芦就行)
[pre lang="ruby"]=begin
# 精英敌人,作者:66RPG的tan12345
# 功能:遇敌时,敌人有一定几率(可设定)变成精英,精英怪比普通怪属性有加成(可修改),
#       当然了,精英怪的经验、金钱、掉落率也同样有加成。
#       也可以设定指定的敌人不会变成精英(比如BOSS)
#
# 使用方法:将脚本插入到main上
#
=end

module Tan_by_enemy_set
  #精英怪出现几率,30代表30%
  Tan_enemy_by = 30
  Tan_king_by = 10
  Tan_god_by = 5
  #Tan_enemy_by_num = 2 2倍属性
#~ ##~   Tan_enemy_by_egold = 3 3倍金钱
#   Tan_enemy_by_eexp = 3 3倍经验
#~ ##~   Tan_enemy_by_edrop = 3 3倍掉落率
  Tan_enemy_by_num = 1.25
  Tan_enemy_by_egold = 1.25
  Tan_enemy_by_eexp = 1.25
  Tan_enemy_by_edrop = 1.25
  Tan_king_num = 1.5
  Tan_king_gold = 1.5
  Tan_king_exp = 1.5
  Tan_king_drop = 1.5
  Tan_god_num = 2
  Tan_god_gold = 2
  Tan_god_exp = 2
  Tan_god_drop = 2
  #不会成为精英的敌人
  NO_BY_ENEMY = [28,29,30,31,32,33,34,35,36,37,38,39,40,43,44,45,46,47,48,49,50,52,51,53,54,55,61,62,63,65,66,67,68,69,70,71,72,73,75,74,76]#表示2号和3号敌人不会变成精英,适合设定BOSS
end
class Game_Enemy < Game_Battler
  
  attr_reader   :is_by  # 是否精英
  attr_reader   :is_king  # 是否精英
  attr_reader   :is_god  # 是否精英
  
  #--------------------------------------------------------------------------
  # ● 精英初始化
  #--------------------------------------------------------------------------
  def init_by_enemy
    @is_by = false
    @is_king = false
    @is_god = false
   
    @is_by = true if rand(100) <= Tan_by_enemy_set::Tan_enemy_by && !Tan_by_enemy_set::NO_BY_ENEMY.include?(enemy_id)
    @original_name = @original_name + "奇才" if @is_by == true
   
    @is_king = true if rand(100) <= Tan_by_enemy_set::Tan_king_by && !Tan_by_enemy_set::NO_BY_ENEMY.include?(enemy_id)
    @original_name = @original_name + "王者" if @is_king == true
   
     @is_god = true if rand(100) <= Tan_by_enemy_set::Tan_god_by && !Tan_by_enemy_set::NO_BY_ENEMY.include?(enemy_id)
    @original_name = @original_name + "神" if @is_god == true
    @hp = mhp
    @mp = mmp
  end
  #--------------------------------------------------------------------------
  # ● 是否精英
  #--------------------------------------------------------------------------
  def is_by?
    return true if @is_by
    return false
   
  end
  
   def is_king?
    return true if @is_king
    return false
  end
   def is_god?
    return true if @is_god
    return false
  end
  #--------------------------------------------------------------------------
  # ● 初始化对象
  #--------------------------------------------------------------------------
  alias tan_by_enemy_initialize initialize
  def initialize(index, enemy_id)
    tan_by_enemy_initialize(index, enemy_id)
    init_by_enemy
  end
  #--------------------------------------------------------------------------
  # ● 获取普通能力的基础值
  #--------------------------------------------------------------------------
  alias tan_by_enemy_param_base param_base
  def param_base(param_id)
    v = tan_by_enemy_param_base(param_id)
    v *= Tan_by_enemy_set::Tan_enemy_by_num if is_by?
    v *= Tan_by_enemy_set::Tan_king_num if is_king?
    v *= Tan_by_enemy_set::Tan_god_num if is_god?
    return v.to_i
  end
  #--------------------------------------------------------------------------
  # ● 获取经验值
  #--------------------------------------------------------------------------
  alias tan_by_enemy_exp exp
  def exp
    v = tan_by_enemy_exp
    v *= Tan_by_enemy_set::Tan_enemy_by_eexp if is_by?
    v *= Tan_by_enemy_set::Tan_king_exp if is_king?
    v *= Tan_by_enemy_set::Tan_god_exp if is_god?
    return v.to_i
  end
  #--------------------------------------------------------------------------
  # ● 获取金钱
  #--------------------------------------------------------------------------
  alias tan_by_enemy_gold gold
  def gold
    v = tan_by_enemy_gold
    v *= Tan_by_enemy_set::Tan_enemy_by_egold if is_by?
    v *= Tan_by_enemy_set::Tan_king_gold if is_king?
    v *= Tan_by_enemy_set::Tan_god_gold if is_god?
    return v.to_i
  end
  #--------------------------------------------------------------------------
  # ● 获取物品掉率的倍率
  #--------------------------------------------------------------------------
  alias tan_by_enemy_drop_item_rate drop_item_rate
  def drop_item_rate
    v = tan_by_enemy_drop_item_rate
    v *= Tan_by_enemy_set::Tan_enemy_by_edrop if is_by?
    v *= Tan_by_enemy_set::Tan_king_drop if is_king?
    v *= Tan_by_enemy_set::Tan_god_drop if is_god?
    return v
  end
end
[/pre]

物品菜单强化
[pre lang="ruby"]#==============================================================================
#
# ▼ Yanfly Engine Ace - Ace Item Menu v1.02
# -- Last Updated: 2012.01.05
# -- Level: Normal, Hard
# -- Requires: n/a
#
#==============================================================================

$imported = {} if $imported.nil?
$imported["YEA-ItemMenu"] = true

#==============================================================================
# ▼ Updates
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# 2012.01.05 - Compatibility Update with Equip Dynamic Stats.
# 2012.01.03 - Started Script and Finished.
#            - Compatibility Update with Ace Menu Engine.
#
#==============================================================================
# ▼ Introduction
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# The Ace Item Menu offers more item categorization control and a better layout
# that simulatenously provides information regarding the items to the player,
# while keeping a good amount of the item list visible on screen at once. The
# script can also be customized to rearrange commands and categories.
#
#==============================================================================
# ▼ Instructions
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# To install this script, open up your script editor and copy/paste this script
# to an open slot below ▼ Materials/素材 but above ▼ Main. Remember to save.
#
# -----------------------------------------------------------------------------
# Item Notetags - These notetags go in the item notebox in the database.
# -----------------------------------------------------------------------------
# <category: string>
# Places this object into the item category for "string". Whenever the selected
# category is highlighted in the Ace Item Menu command window, this object will
# be included and shown in the item window.
#
# <image: string>
# Uses a picture from Graphics\Pictures\ of your RPG Maker VX Ace Project's
# directory with the filename of "string" (without the extension) as the image
# picture shown in the Ace Item Menu.
#
# -----------------------------------------------------------------------------
# Weapon Notetags - These notetags go in the weapon notebox in the database.
# -----------------------------------------------------------------------------
# <category: string>
# Places this object into the item category for "string". Whenever the selected
# category is highlighted in the Ace Item Menu command window, this object will
# be included and shown in the item window.
#
# <image: string>
# Uses a picture from Graphics\Pictures\ of your RPG Maker VX Ace Project's
# directory with the filename of "string" (without the extension) as the image
# picture shown in the Ace Item Menu.
#
# -----------------------------------------------------------------------------
# Armour Notetags - These notetags go in the armour notebox in the database.
# -----------------------------------------------------------------------------
# <category: string>
# Places this object into the item category for "string". Whenever the selected
# category is highlighted in the Ace Item Menu command window, this object will
# be included and shown in the item window.
#
# <image: string>
# Uses a picture from Graphics\Pictures\ of your RPG Maker VX Ace Project's
# directory with the filename of "string" (without the extension) as the image
# picture shown in the Ace Item Menu.
#
#==============================================================================
# ▼ Compatibility
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# This script is made strictly for RPG Maker VX Ace. It is highly unlikely that
# it will run with RPG Maker VX without adjusting.
#
#==============================================================================

module YEA
  module ITEM
   
    #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    # - Item Command Settings -
    #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    # This array adjusts what options appear in the initial item command window
    # before the items are split into separate categories. Add commands, remove
    # commands, or rearrange them. Here's a list of which does what:
    #
    # -------------------------------------------------------------------------
    # :command         Description
    # -------------------------------------------------------------------------
    # :item            Opens up the various item categories. Default.
    # :weapon          Opens up the various weapon categories. Default.
    # :armor           Opens up the various armour categories. Default.
    # :key_item        Shows a list of the various key items. Default.
    #
    # :gogototori      Requires Kread-EX's Go Go Totori Synthesis.
    #
    #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    COMMANDS =[
      :item,         # Opens up the various item categories. Default.
      :weapon,       # Opens up the various weapon categories. Default.
      :armor,        # Opens up the various armour categories. Default.
      :key_item,     # Shows a list of the various key items. Default.
      :gogototori,   # Requires Kread-EX's Go Go Totori Synthesis.
    # :custom1,      # Custom command 1.
    # :custom2,      # Custom command 2.
    ] # Do not remove this.
   
    #--------------------------------------------------------------------------
    # - Item Custom Commands -
    # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    # For those who use scripts to that may produce unique effects for the item
    # scene, use this hash to manage the custom commands for the Item Command
    # Window. You can disable certain commands or prevent them from appearing
    # by using switches. If you don't wish to bind them to a switch, set the
    # proper switch to 0 for it to have no impact.
    #--------------------------------------------------------------------------
    CUSTOM_ITEM_COMMANDS ={
    # :command => ["Display Name", EnableSwitch, ShowSwitch, Handler Method],
      :gogototori => ["合成",            0,         0, :command_totori],
      :custom1 => [ "自定義名稱",            0,          0, :command_name1],
      :custom2 => [ "自定義文本",           13,          0, :command_name2],
    } # Do not remove this.
   
    #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    # - Item Type Settings -
    #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    # These arrays adjusts and shows the various item types shown for Items,
    # Weapons, and Armours. Note that when using :category symbols, the
    # specific category shown will be equal to the text used for the Display
    # and the included item must contain a category equal to the Display name.
    #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    # This array contains the order for the Item categories.
    ITEM_TYPES =[
    # [  :symbol,   "Display"],
      [:all,       "全部"], # Shows all usable items.
      [:field,     "背包内"], # Shows Menu-usable items.
      [:battle,    "战斗用"], # Shows Battle-usable items.
      [:category,   "材料"], # Categorized by <category: 材料>
      [:category,"特别"], # Categorized by <category: 特别>
      [:category,"石头"], # Categorized by <category: 石头>
      [:category,"宝珠"], # Categorized by <category: 宝珠>
      [:category,"药剂"], # Categorized by <category: 技能书>
      [:category,"技能书"], # Categorized by <category: 药剂>
      [:category,"宝物"], # Categorized by <category: 宝物>
      [:category,  "进阶"], # Shows all key items.
    ] # Do not remove this.
   
    # This array contains the order for the Weapon categories.
    WEAPON_TYPES =[
    # [  :symbol,   "Display"],
      [   :types,  "WPNTYPES"], # Lists all of the individual weapon types.
      [     :all,       "全部"], # Shows all weapons.
    ] # Do not remove this.
   
    # This array contains the order for the Armour categories.
    ARMOUR_TYPES =[
    # [  :symbol,   "Display"],
      [   :slots,  "ARMSLOTS"], # Lists all of the individual armour slots.
      [   :types,  "ARMTYPES"], # Lists all of the individual armours types.
      [     :all,       "全部"], # Shows all armours.
    ] # Do not remove this.
   
    #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    # - Item Status Settings -
    #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    # The item status window displays information about the item in detail.
    # Adjust the settings below to change the way the status window appears.
    #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    STATUS_FONT_SIZE = 20       # Font size used for status window.
    MAX_ICONS_DRAWN  = 10       # Maximum number of icons drawn for states.
   
    # The following adjusts the vocabulary used for the status window. Each
    # of the vocabulary settings are self explanatory.
    VOCAB_STATUS ={
      :empty      => "---",          # Text used when nothing is shown.
      :hp_recover => "回复血量",      # Text used for HP Recovery.
      :mp_recover => "回复魔法",      # Text used for MP Recovery.
      :tp_recover => "回复TP",      # Text used for TP Recovery.
      :tp_gain    => "增加TP",      # Text used for TP Gain.
      :applies    => "增加效果",      # Text used for applied states and buffs.
      :removes    => "移除效果",      # Text used for removed states and buffs.
    } # Do not remove this.
   
  end # ITEM
end # YEA

#==============================================================================
# ▼ Editting anything past this point may potentially result in causing
# computer damage, incontinence, explosion of user's head, coma, death, and/or
# halitosis so edit at your own risk.
#==============================================================================

module YEA
  module REGEXP
  module BASEITEM
   
    CATEGORY = /<(?:CATEGORIES|category):[ ](.*)>/i
    IMAGE    = /<(?:IMAGE|image):[ ](.*)>/i
   
  end # BASEITEM
  end # REGEXP
end # YEA

#==============================================================================
# ■ Numeric
#==============================================================================

class Numeric
  
  #--------------------------------------------------------------------------
  # new method: group_digits
  #--------------------------------------------------------------------------
  unless $imported["YEA-CoreEngine"]
  def group; return self.to_s; end
  end # $imported["YEA-CoreEngine"]
   
end # Numeric

#==============================================================================
# ■ Vocab
#==============================================================================

module Vocab
  
  #--------------------------------------------------------------------------
  # new method: self.item_status
  #--------------------------------------------------------------------------
  def self.item_status(type)
    return YEA::ITEM::VOCAB_STATUS[type]
  end
  
end # Vocab

#==============================================================================
# ■ DataManager
#==============================================================================

module DataManager
  
  #--------------------------------------------------------------------------
  # alias method: load_database
  #--------------------------------------------------------------------------
  class <<self; alias load_database_aim load_database; end
  def self.load_database
    load_database_aim
    load_notetags_aim
  end
  
  #--------------------------------------------------------------------------
  # new method: load_notetags_aim
  #--------------------------------------------------------------------------
  def self.load_notetags_aim
    groups = [$data_items, $data_weapons, $data_armors]
    for group in groups
      for obj in group
        next if obj.nil?
        obj.load_notetags_aim
      end
    end
  end
  
end # DataManager

#==============================================================================
# ■ RPG::BaseItem
#==============================================================================

class RPG::BaseItem
  
  #--------------------------------------------------------------------------
  # public instance variables
  #--------------------------------------------------------------------------
  attr_accessor :category
  attr_accessor :image
  
  #--------------------------------------------------------------------------
  # common cache: load_notetags_aim
  #--------------------------------------------------------------------------
  def load_notetags_aim
    @category = []
    #---
    self.note.split(/[\r\n]+/).each { |line|
      case line
      #---
      when YEA::REGEXP::BASEITEM::CATEGORY
        @category.push($1.upcase.to_s)
      when YEA::REGEXP::BASEITEM::IMAGE
        @image = $1.to_s
      end
    } # self.note.split
    #---
  end
  
end # RPG::BaseItem

#==============================================================================
# ■ Game_Temp
#==============================================================================

class Game_Temp
  
  #--------------------------------------------------------------------------
  # public instance variables
  #--------------------------------------------------------------------------
  attr_accessor :scene_item_index
  attr_accessor :scene_item_oy
  
end # Game_Temp

#==============================================================================
# ■ Window_ItemList
#==============================================================================

class Window_ItemList < Window_Selectable
  
  #--------------------------------------------------------------------------
  # overwrite method: draw_item
  #--------------------------------------------------------------------------
  def draw_item(index)
    item = @data[index]
    return if item.nil?
    rect = item_rect(index)
    rect.width -= 4
    draw_item_name(item, rect.x, rect.y, enable?(item), rect.width - 24)
    draw_item_number(rect, item)
  end
  
end # Window_ItemList

#==============================================================================
# ■ Window_ItemCommand
#==============================================================================

class Window_ItemCommand < Window_Command
  
  #--------------------------------------------------------------------------
  # public instance variables
  #--------------------------------------------------------------------------
  attr_reader   :item_window
  
  #--------------------------------------------------------------------------
  # initialize
  #--------------------------------------------------------------------------
  def initialize(x, y)
    super(x, y)
  end
  
  #--------------------------------------------------------------------------
  # window_width
  #--------------------------------------------------------------------------
  def window_width; return 160; end
  
  #--------------------------------------------------------------------------
  # visible_line_number
  #--------------------------------------------------------------------------
  def visible_line_number; return 4; end
  
  #--------------------------------------------------------------------------
  # process_ok
  #--------------------------------------------------------------------------
  def process_ok
    $game_temp.scene_item_index = index
    $game_temp.scene_item_oy = self.oy
    super
  end
  
  #--------------------------------------------------------------------------
  # make_command_list
  #--------------------------------------------------------------------------
  def make_command_list
    for command in YEA::ITEM::COMMANDS
      case command
      #--- Default Commands ---
      when :item
        add_command(Vocab::item, :item)
      when :weapon
        add_command(Vocab::weapon, :weapon)
      when :armor
        add_command(Vocab::armor, :armor)
      when :key_item
        add_command(Vocab::key_item, :key_item)
      #--- Imported ---
      when :gogototori
        next unless $imported["KRX-AlchemicSynthesis"]
        process_custom_command(command)
      #--- Custom Commands ---
      else
        process_custom_command(command)
      end
    end
  end
  
  #--------------------------------------------------------------------------
  # process_custom_command
  #--------------------------------------------------------------------------
  def process_custom_command(command)
    return unless YEA::ITEM::CUSTOM_ITEM_COMMANDS.include?(command)
    show = YEA::ITEM::CUSTOM_ITEM_COMMANDS[command][2]
    continue = show <= 0 ? true : $game_switches[show]
    return unless continue
    text = YEA::ITEM::CUSTOM_ITEM_COMMANDS[command][0]
    switch = YEA::ITEM::CUSTOM_ITEM_COMMANDS[command][1]
    enabled = switch <= 0 ? true : $game_switches[switch]
    add_command(text, command, enabled)
  end
  
  #--------------------------------------------------------------------------
  # update
  #--------------------------------------------------------------------------
  def update
    super
    return unless self.active
    @item_window.category = current_symbol if @item_window
  end
  
  #--------------------------------------------------------------------------
  # item_window=
  #--------------------------------------------------------------------------
  def item_window=(item_window)
    @item_window = item_window
    update
  end
  
end # Window_ItemCommand

#==============================================================================
# ■ Window_ItemType
#==============================================================================

class Window_ItemType < Window_Command
  
  #--------------------------------------------------------------------------
  # public instance variables
  #--------------------------------------------------------------------------
  attr_reader   :item_window
  
  #--------------------------------------------------------------------------
  # initialize
  #--------------------------------------------------------------------------
  def initialize(x, y)
    super(x, y)
    deactivate
    @type = nil
  end
  
  #--------------------------------------------------------------------------
  # window_width
  #--------------------------------------------------------------------------
  def window_width; return 160; end
  
  #--------------------------------------------------------------------------
  # visible_line_number
  #--------------------------------------------------------------------------
  def visible_line_number; return 4; end
  
  #--------------------------------------------------------------------------
  # reveal
  #--------------------------------------------------------------------------
  def reveal(type)
    @type = type
    refresh
    activate
    select(0)
  end
  
  #--------------------------------------------------------------------------
  # make_command_list
  #--------------------------------------------------------------------------
  def make_command_list
    return if @type.nil?
    #---
    case @type
    when :item
      commands = YEA::ITEM::ITEM_TYPES
    when :weapon
      commands = YEA::ITEM::WEAPON_TYPES
    else
      commands = YEA::ITEM::ARMOUR_TYPES
    end
    #---
    for command in commands
      case command[0]
      #---
      when :types
        case @type
        when :weapon
          for i in 1...$data_system.weapon_types.size
            name = $data_system.weapon_types
            add_command(name, :w_type, true, i)
          end
        else
          for i in 1...$data_system.armor_types.size
            name = $data_system.armor_types
            add_command(name, :a_type, true, i)
          end
        end
      #---
      when :slots
        if $imported["YEA-AceEquipEngine"]
          maximum = 1
          for key in YEA::EQUIP::TYPES
            maximum = [maximum, key[0]].max
          end
        else
          maximum = 4
        end
        for i in 1..maximum
          name = Vocab::etype(i)
          add_command(name, :e_type, true, i) if name != ""
        end
      #---
      else
        add_command(command[1], command[0], true, @type)
      end
    end
  end
  
  #--------------------------------------------------------------------------
  # update
  #--------------------------------------------------------------------------
  def update
    super
    return unless self.active
    @item_window.category = current_symbol if @item_window
  end
  
  #--------------------------------------------------------------------------
  # item_window=
  #--------------------------------------------------------------------------
  def item_window=(item_window)
    @item_window = item_window
    update
  end
  
end # Window_ItemType

#==============================================================================
# ■ Window_ItemList
#==============================================================================

class Window_ItemList < Window_Selectable
  
  #--------------------------------------------------------------------------
  # alias method: initialize
  #--------------------------------------------------------------------------
  alias window_itemlist_initialize_aim initialize
  def initialize(dx, dy, dw, dh)
    window_itemlist_initialize_aim(dx, dy, dw, dh)
    @ext = :none
    @name = ""
  end
  
  #--------------------------------------------------------------------------
  # alias method: category=
  #--------------------------------------------------------------------------
  alias window_itemlist_category_aim category=
  def category=(category)
    if @types_window.nil?
      window_itemlist_category_aim(category)
    else
      return unless update_types?(category)
      @category = category
      if @types_window.active
        @name = @types_window.current_data[:name]
        @ext = @types_window.current_ext
      end
      refresh
      self.oy = 0
    end
  end
  
  #--------------------------------------------------------------------------
  # new method: update_types?
  #--------------------------------------------------------------------------
  def update_types?(category)
    return true if @category != category
    return false unless @types_window.active
    if category == :category
      return @name != @types_window.current_data[:name]
    end
    return @ext != @types_window.current_ext
  end
  
  #--------------------------------------------------------------------------
  # new method: types_window=
  #--------------------------------------------------------------------------
  def types_window=(window)
    @types_window = window
  end
  
  #--------------------------------------------------------------------------
  # alias method: include?
  #--------------------------------------------------------------------------
  alias window_itemlist_include_aim include?
  def include?(item)
    if @types_window.nil?
      return window_itemlist_include_aim(item)
    else
      return ace_item_menu_include?(item)
    end
  end
  
  #--------------------------------------------------------------------------
  # new method: ace_item_menu_include?
  #--------------------------------------------------------------------------
  def ace_item_menu_include?(item)
    case @category
    #---
    when :field
      return false unless item.is_a?(RPG::Item)
      return item.menu_ok?
    when :battle
      return false unless item.is_a?(RPG::Item)
      return item.battle_ok?
    #---
    when :w_type
      return false unless item.is_a?(RPG::Weapon)
      return item.wtype_id == @types_window.current_ext
    when :a_type
      return false unless item.is_a?(RPG::Armor)
      return item.atype_id == @types_window.current_ext
    when :e_type
      return false unless item.is_a?(RPG::Armor)
      return item.etype_id == @types_window.current_ext
    #---
    when :all
      case @types_window.current_ext
      when :item
        return item.is_a?(RPG::Item)
      when :weapon
        return item.is_a?(RPG::Weapon)
      else
        return item.is_a?(RPG::Armor)
      end
    #---
    when :category
      case @types_window.current_ext
      when :item
        return false unless item.is_a?(RPG::Item)
      when :weapon
        return false unless item.is_a?(RPG::Weapon)
      else
        return false unless item.is_a?(RPG::Armor)
      end
      return item.category.include?(@types_window.current_data[:name].upcase)
    #---
    else
      return window_itemlist_include_aim(item)
    end
  end
  
end # Window_ItemList

#==============================================================================
# ■ Window_ItemStatus
#==============================================================================

class Window_ItemStatus < Window_Base
  
  #--------------------------------------------------------------------------
  # initialize
  #--------------------------------------------------------------------------
  def initialize(dx, dy, item_window)
    super(dx, dy, Graphics.width - dx, fitting_height(4))
    @item_window = item_window
    @item = nil
    refresh
  end
  
  #--------------------------------------------------------------------------
  # update
  #--------------------------------------------------------------------------
  def update
    super
    update_item(@item_window.item)
  end
  
  #--------------------------------------------------------------------------
  # update_item
  #--------------------------------------------------------------------------
  def update_item(item)
    return if @item == item
    @item = item
    refresh
  end
  
  #--------------------------------------------------------------------------
  # refresh
  #--------------------------------------------------------------------------
  def refresh
    contents.clear
    reset_font_settings
    return draw_empty if @item.nil?
    contents.font.size = YEA::ITEM::STATUS_FONT_SIZE
    draw_item_image
    draw_item_stats
    draw_item_effects
  end
  
  #--------------------------------------------------------------------------
  # draw_empty
  #--------------------------------------------------------------------------
  def draw_empty
    colour = Color.new(0, 0, 0, translucent_alpha/2)
    rect = Rect.new(1, 1, 94, 94)
    contents.fill_rect(rect, colour)
    dx = 96; dy = 0
    dw = (contents.width - 96) / 2
    for i in 0...8
      draw_background_box(dx, dy, dw)
      dx = dx >= 96 + dw ? 96 : 96 + dw
      dy += line_height if dx == 96
    end
  end
  
  #--------------------------------------------------------------------------
  # draw_background_box
  #--------------------------------------------------------------------------
  def draw_background_box(dx, dy, dw)
    colour = Color.new(0, 0, 0, translucent_alpha/2)
    rect = Rect.new(dx+1, dy+1, dw-2, line_height-2)
    contents.fill_rect(rect, colour)
  end
  
  #--------------------------------------------------------------------------
  # draw_item_image
  #--------------------------------------------------------------------------
  def draw_item_image
    colour = Color.new(0, 0, 0, translucent_alpha/2)
    rect = Rect.new(1, 1, 94, 94)
    contents.fill_rect(rect, colour)
    if @item.image.nil?
      icon_index = @item.icon_index
      bitmap = Cache.system("Iconset")
      rect = Rect.new(icon_index % 16 * 24, icon_index / 16 * 24, 24, 24)
      target = Rect.new(0, 0, 96, 96)
      contents.stretch_blt(target, bitmap, rect)
    else
      bitmap = Cache.picture(@item.image)
      contents.blt(0, 0, bitmap, bitmap.rect, 255)
    end
  end
  
  #--------------------------------------------------------------------------
  # draw_item_stats
  #--------------------------------------------------------------------------
  def draw_item_stats
    return unless @item.is_a?(RPG::Weapon) || @item.is_a?(RPG::Armor)
    dx = 96; dy = 0
    dw = (contents.width - 96) / 2
    for i in 0...8
      draw_equip_param(i, dx, dy, dw)
      dx = dx >= 96 + dw ? 96 : 96 + dw
      dy += line_height if dx == 96
    end
  end
  
  #--------------------------------------------------------------------------
  # draw_equip_param
  #--------------------------------------------------------------------------
  def draw_equip_param(param_id, dx, dy, dw)
    draw_background_box(dx, dy, dw)
    change_color(system_color)
    draw_text(dx+4, dy, dw-8, line_height, Vocab::param(param_id))
    if $imported["YEA-EquipDynamicStats"]
      draw_percentage_param(param_id, dx, dy, dw)
    else
      draw_set_param(param_id, dx, dy, dw)
    end
  end
  
  #--------------------------------------------------------------------------
  # draw_percentage_param
  #--------------------------------------------------------------------------
  def draw_percentage_param(param_id, dx, dy, dw)
    if @item.per_params[param_id] != 0 && @item.params[param_id] != 0
      text = draw_set_param(param_id, dx, dy, dw)
      dw -= text_size(text).width
      draw_percent_param(param_id, dx, dy, dw)
    elsif @item.per_params[param_id] != 0 && @item.params[param_id] == 0
      draw_percent_param(param_id, dx, dy, dw)
    else
      draw_set_param(param_id, dx, dy, dw)
    end
  end
  
  #--------------------------------------------------------------------------
  # draw_set_param
  #--------------------------------------------------------------------------
  def draw_set_param(param_id, dx, dy, dw)
    value = @item.params[param_id]
    if $imported["YEA-EquipDynamicStats"] && @item.var_params[param_id] > 0
      value += $game_variables[@item.var_params[param_id]] rescue 0
    end
    change_color(param_change_color(value), value != 0)
    text = value.group
    text = "+" + text if value > 0
    draw_text(dx+4, dy, dw-8, line_height, text, 2)
    return text
  end
  
  #--------------------------------------------------------------------------
  # draw_percent_param
  #--------------------------------------------------------------------------
  def draw_percent_param(param_id, dx, dy, dw)
    value = @item.per_params[param_id]
    change_color(param_change_color(value))
    text = (@item.per_params[param_id] * 100).to_i.group + "%"
    text = "+" + text if @item.per_params[param_id] > 0
    draw_text(dx+4, dy, dw-8, line_height, text, 2)
    return text
  end
  
  #--------------------------------------------------------------------------
  # draw_item_effects
  #--------------------------------------------------------------------------
  def draw_item_effects
    return unless @item.is_a?(RPG::Item)
    dx = 96; dy = 0
    dw = (contents.width - 96) / 2
    draw_hp_recover(dx, dy + line_height * 0, dw)
    draw_mp_recover(dx, dy + line_height * 1, dw)
    draw_tp_recover(dx + dw, dy + line_height * 0, dw)
    draw_tp_gain(dx + dw, dy + line_height * 1, dw)
    dw = contents.width - 96
    draw_applies(dx, dy + line_height * 2, dw)
    draw_removes(dx, dy + line_height * 3, dw)
  end
  
  #--------------------------------------------------------------------------
  # draw_hp_recover
  #--------------------------------------------------------------------------
  def draw_hp_recover(dx, dy, dw)
    draw_background_box(dx, dy, dw)
    change_color(system_color)
    draw_text(dx+4, dy, dw-8, line_height, Vocab::item_status(:hp_recover))
    per = 0
    set = 0
    for effect in @item.effects
      next unless effect.code == 11
      per += (effect.value1 * 100).to_i
      set += effect.value2.to_i
    end
    if per != 0 && set != 0
      change_color(param_change_color(set))
      text = set > 0 ? sprintf("+%s", set.group) : set.group
      draw_text(dx+4, dy, dw-8, line_height, text, 2)
      dw -= text_size(text).width
      change_color(param_change_color(per))
      text = per > 0 ? sprintf("+%s%%", per.group) : sprintf("%s%%", per.group)
      draw_text(dx+4, dy, dw-8, line_height, text, 2)
      return
    elsif per != 0
      change_color(param_change_color(per))
      text = per > 0 ? sprintf("+%s%%", per.group) : sprintf("%s%%", per.group)
    elsif set != 0
      change_color(param_change_color(set))
      text = set > 0 ? sprintf("+%s", set.group) : set.group
    else
      change_color(normal_color, false)
      text = Vocab::item_status(:empty)
    end
    draw_text(dx+4, dy, dw-8, line_height, text, 2)
  end
  
  #--------------------------------------------------------------------------
  # draw_mp_recover
  #--------------------------------------------------------------------------
  def draw_mp_recover(dx, dy, dw)
    draw_background_box(dx, dy, dw)
    change_color(system_color)
    draw_text(dx+4, dy, dw-8, line_height, Vocab::item_status(:mp_recover))
    per = 0
    set = 0
    for effect in @item.effects
      next unless effect.code == 12
      per += (effect.value1 * 100).to_i
      set += effect.value2.to_i
    end
    if per != 0 && set != 0
      change_color(param_change_color(set))
      text = set > 0 ? sprintf("+%s", set.group) : set.group
      draw_text(dx+4, dy, dw-8, line_height, text, 2)
      dw -= text_size(text).width
      change_color(param_change_color(per))
      text = per > 0 ? sprintf("+%s%%", per.group) : sprintf("%s%%", per.group)
      draw_text(dx+4, dy, dw-8, line_height, text, 2)
      return
    elsif per != 0
      change_color(param_change_color(per))
      text = per > 0 ? sprintf("+%s%%", per.group) : sprintf("%s%%", per.group)
    elsif set != 0
      change_color(param_change_color(set))
      text = set > 0 ? sprintf("+%s", set.group) : set.group
    else
      change_color(normal_color, false)
      text = Vocab::item_status(:empty)
    end
    draw_text(dx+4, dy, dw-8, line_height, text, 2)
  end
  
  #--------------------------------------------------------------------------
  # draw_tp_recover
  #--------------------------------------------------------------------------
  def draw_tp_recover(dx, dy, dw)
    draw_background_box(dx, dy, dw)
    change_color(system_color)
    draw_text(dx+4, dy, dw-8, line_height, Vocab::item_status(:tp_recover))
    set = 0
    for effect in @item.effects
      next unless effect.code == 13
      set += effect.value1.to_i
    end
    if set != 0
      change_color(param_change_color(set))
      text = set > 0 ? sprintf("+%s", set.group) : set.group
    else
      change_color(normal_color, false)
      text = Vocab::item_status(:empty)
    end
    draw_text(dx+4, dy, dw-8, line_height, text, 2)
  end
  
  #--------------------------------------------------------------------------
  # draw_tp_gain
  #--------------------------------------------------------------------------
  def draw_tp_gain(dx, dy, dw)
    draw_background_box(dx, dy, dw)
    change_color(system_color)
    draw_text(dx+4, dy, dw-8, line_height, Vocab::item_status(:tp_gain))
    set = @item.tp_gain
    if set != 0
      change_color(param_change_color(set))
      text = set > 0 ? sprintf("+%s", set.group) : set.group
    else
      change_color(normal_color, false)
      text = Vocab::item_status(:empty)
    end
    draw_text(dx+4, dy, dw-8, line_height, text, 2)
  end
  
  #--------------------------------------------------------------------------
  # draw_applies
  #--------------------------------------------------------------------------
  def draw_applies(dx, dy, dw)
    draw_background_box(dx, dy, dw)
    change_color(system_color)
    draw_text(dx+4, dy, dw-8, line_height, Vocab::item_status(:applies))
    icons = []
    for effect in @item.effects
      case effect.code
      when 21
        next unless effect.value1 > 0
        next if $data_states[effect.value1].nil?
        icons.push($data_states[effect.data_id].icon_index)
      when 31
        icons.push($game_actors[1].buff_icon_index(1, effect.data_id))
      when 32
        icons.push($game_actors[1].buff_icon_index(-1, effect.data_id))
      end
      icons.delete(0)
      break if icons.size >= YEA::ITEM::MAX_ICONS_DRAWN
    end
    draw_icons(dx, dy, dw, icons)
  end
  
  #--------------------------------------------------------------------------
  # draw_removes
  #--------------------------------------------------------------------------
  def draw_removes(dx, dy, dw)
    draw_background_box(dx, dy, dw)
    change_color(system_color)
    draw_text(dx+4, dy, dw-8, line_height, Vocab::item_status(:removes))
    icons = []
    for effect in @item.effects
      case effect.code
      when 22
        next unless effect.value1 > 0
        next if $data_states[effect.value1].nil?
        icons.push($data_states[effect.data_id].icon_index)
      when 33
        icons.push($game_actors[1].buff_icon_index(1, effect.data_id))
      when 34
        icons.push($game_actors[1].buff_icon_index(-1, effect.data_id))
      end
      icons.delete(0)
      break if icons.size >= YEA::ITEM::MAX_ICONS_DRAWN
    end
    draw_icons(dx, dy, dw, icons)
  end
  
  #--------------------------------------------------------------------------
  # draw_icons
  #--------------------------------------------------------------------------
  def draw_icons(dx, dy, dw, icons)
    dx += dw - 4
    dx -= icons.size * 24
    for icon_id in icons
      draw_icon(icon_id, dx, dy)
      dx += 24
    end
    if icons.size == 0
      change_color(normal_color, false)
      text = Vocab::item_status(:empty)
      draw_text(4, dy, contents.width-8, line_height, text, 2)
    end
  end
  
end # Window_ItemStatus

#==============================================================================
# ■ Scene_Item
#==============================================================================

class Scene_Item < Scene_ItemBase
  
  #--------------------------------------------------------------------------
  # alias method: start
  #--------------------------------------------------------------------------
  alias scene_item_start_aim start
  def start
    scene_item_start_aim
    create_types_window
    create_status_window
    relocate_windows
  end
  
  #--------------------------------------------------------------------------
  # overwrite method: return_scene
  #--------------------------------------------------------------------------
  def return_scene
    $game_temp.scene_item_index = nil
    $game_temp.scene_item_oy = nil
    super
  end
  
  #--------------------------------------------------------------------------
  # overwrite method: create_category_window
  #--------------------------------------------------------------------------
  def create_category_window
    wy = @help_window.height
    @category_window = Window_ItemCommand.new(0, wy)
    @category_window.viewport = @viewport
    @category_window.help_window = @help_window
    @category_window.y = @help_window.height
    if !$game_temp.scene_item_index.nil?
      @category_window.select($game_temp.scene_item_index)
      @category_window.oy = $game_temp.scene_item_oy
    end
    $game_temp.scene_item_index = nil
    $game_temp.scene_item_oy = nil
    @category_window.set_handler(:ok, method(:on_category_ok))
    @category_window.set_handler(:cancel, method(:return_scene))
    @category_window.set_handler(:item, method(:open_types))
    @category_window.set_handler(:weapon, method(:open_types))
    @category_window.set_handler(:armor, method(:open_types))
    process_custom_item_commands
  end
  
  #--------------------------------------------------------------------------
  # new method: process_custom_item_commands
  #--------------------------------------------------------------------------
  def process_custom_item_commands
    for command in YEA::ITEM::COMMANDS
      next unless YEA::ITEM::CUSTOM_ITEM_COMMANDS.include?(command)
      called_method = YEA::ITEM::CUSTOM_ITEM_COMMANDS[command][3]
      @category_window.set_handler(command, method(called_method))
    end
  end
  
  #--------------------------------------------------------------------------
  # new method: create_types_window
  #--------------------------------------------------------------------------
  def create_types_window
    wy = @category_window.y
    @types_window = Window_ItemType.new(Graphics.width, wy)
    @types_window.viewport = @viewport
    @types_window.help_window = @help_window
    @types_window.y = @help_window.height
    @types_window.item_window = @item_window
    @item_window.types_window = @types_window
    @types_window.set_handler(:ok, method(:on_types_ok))
    @types_window.set_handler(:cancel, method(:on_types_cancel))
  end
  
  #--------------------------------------------------------------------------
  # new method: create_status_window
  #--------------------------------------------------------------------------
  def create_status_window
    wx = @category_window.width
    wy = @category_window.y
    @status_window = Window_ItemStatus.new(wx, wy, @item_window)
    @status_window.viewport = @viewport
  end
  
  #--------------------------------------------------------------------------
  # new method: relocate_windows
  #--------------------------------------------------------------------------
  def relocate_windows
    return unless $imported["YEA-AceMenuEngine"]
    case Menu.help_window_location
    when 0 # Top
      @help_window.y = 0
      @category_window.y = @help_window.height
      @item_window.y = @category_window.y + @category_window.height
    when 1 # Middle
      @category_window.y = 0
      @help_window.y = @category_window.height
      @item_window.y = @help_window.y + @help_window.height
    else # Bottom
      @category_window.y = 0
      @item_window.y = @category_window.height
      @help_window.y = @item_window.y + @item_window.height
    end
    @types_window.y = @category_window.y
    @status_window.y = @category_window.y
  end
  
  #--------------------------------------------------------------------------
  # new method: open_categories
  #--------------------------------------------------------------------------
  def open_types
    @category_window.x = Graphics.width
    @types_window.x = 0
    @types_window.reveal(@category_window.current_symbol)
  end
  
  #--------------------------------------------------------------------------
  # new method: on_types_ok
  #--------------------------------------------------------------------------
  def on_types_ok
    @item_window.activate
    @item_window.select_last
  end
  
  #--------------------------------------------------------------------------
  # new method: on_types_cancel
  #--------------------------------------------------------------------------
  def on_types_cancel
    @category_window.x = 0
    @category_window.activate
    @types_window.unselect
    @types_window.x = Graphics.width
  end
  
  #--------------------------------------------------------------------------
  # alias method: on_item_cancel
  #--------------------------------------------------------------------------
  alias scene_item_on_item_cancel_aim on_item_cancel
  def on_item_cancel
    if @types_window.x <= 0
      @item_window.unselect
      @types_window.activate
    else
      scene_item_on_item_cancel_aim
    end
  end
  
  #--------------------------------------------------------------------------
  # new method: command_totori
  #--------------------------------------------------------------------------
  def command_totori
    SceneManager.call(Scene_Alchemy)
  end
  
  #--------------------------------------------------------------------------
  # new method: command_name1
  #--------------------------------------------------------------------------
  def command_name1
    # Do nothing.
  end
  
  #--------------------------------------------------------------------------
  # new method: command_name2
  #--------------------------------------------------------------------------
  def command_name2
    # Do nothing.
  end
  
end # Scene_Item

#==============================================================================
#
# ▼ End of File
#
#==============================================================================[/pre]

掉落强化
[pre lang="ruby"]#==============================================================================
#
# ▼ Yanfly Engine Ace - Extra Drops v1.01
# -- Last Updated: 2011.12.31
# -- Level: Normal
# -- Requires: n/a
#
#==============================================================================

$imported = {} if $imported.nil?
$imported["YEA-ExtraDrops"] = true

#==============================================================================
# ▼ Updates
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# 2011.12.31 - Bug Fixed: Drop ratios now work properly.
# 2011.12.17 - Started Script and Finished.
#
#==============================================================================
# ▼ Introduction
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# Enemies by default only drop three items maximum in RPG Maker VX Ace. The
# drop rates are also limited to rates that can only be achieved through
# denominator values. A drop rate of say, 75% cannot be achieved. This script
# provides the ability to add more than just three drops and more control over
# the drop rates, too.
#
#==============================================================================
# ▼ Instructions
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# To install this script, open up your script editor and copy/paste this script
# to an open slot below ▼ Materials/素材 but above ▼ Main. Remember to save.
#
# -----------------------------------------------------------------------------
# Enemy Notetags - These notetags go in the enemies notebox in the database.
# -----------------------------------------------------------------------------
# <drop Ix: y%>在敌人备注添加额外的物品掉落,X为物品编号,Y为概率
# <drop Wx: y%>在敌人备注添加额外的武器掉落,X为武器编号,Y为概率
# <drop Ax: y%>在敌人备注添加额外的防具掉落,X为防具编号,Y为概率
# Causes enemy to drop item, weapon, or armour (marked by I, W, or A) x at a
# rate of y percent. Insert multiples of this tag to increase the number of
# drops an enemy can possibly have.
#
#==============================================================================
# ▼ Compatibility
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# This script is made strictly for RPG Maker VX Ace. It is highly unlikely that
# it will run with RPG Maker VX without adjusting.
#
#==============================================================================
# ▼ Editting anything past this point may potentially result in causing
# computer damage, incontinence, explosion of user's head, coma, death, and/or
# halitosis so edit at your own risk.
#==============================================================================

module YEA
  module REGEXP
  module ENEMY
   
    DROP_PLUS = /<(?:DROP|drop)[ ]([IWA])(\d+):[ ](\d+)([%%])>/i
   
  end # ENEMY
  end # REGEXP
end # YEA

#==============================================================================
# ■ DataManager
#==============================================================================

module DataManager
  
  #--------------------------------------------------------------------------
  # alias method: load_database
  #--------------------------------------------------------------------------
  class <<self; alias load_database_edr load_database; end
  def self.load_database
    load_database_edr
    load_notetags_edr
  end
  
  #--------------------------------------------------------------------------
  # new method: load_notetags_al
  #--------------------------------------------------------------------------
  def self.load_notetags_edr
    for enemy in $data_enemies
      next if enemy.nil?
      enemy.load_notetags_edr
    end
  end
  
end # DataManager

#==============================================================================
# ■ RPG::Enemy
#==============================================================================

class RPG::Enemy < RPG::BaseItem
  
  #--------------------------------------------------------------------------
  # public instance variables
  #--------------------------------------------------------------------------
  attr_accessor :extra_drops
  
  #--------------------------------------------------------------------------
  # common cache: load_notetags_edr
  #--------------------------------------------------------------------------
  def load_notetags_edr
    @extra_drops = []
    #---
    self.note.split(/[\r\n]+/).each { |line|
      case line
      #---
      when YEA::REGEXP::ENEMY::DROP_PLUS
        case $1.upcase
        when "I";  kind = 1
        when "W";  kind = 2
        when "A";  kind = 3
        else; next
        end
        item = RPG::Enemy::DropItem.new
        item.kind = kind
        item.data_id = $2.to_i
        item.drop_rate = $3.to_i * 0.01
        @extra_drops.push(item)
      end
    } # self.note.split
    #---
  end
  
end # RPG::Enemy

#==============================================================================
# ■ RPG::Enemy::DropItem
#==============================================================================

class RPG::Enemy::DropItem
  
  #--------------------------------------------------------------------------
  # public instance variables
  #--------------------------------------------------------------------------
  attr_accessor :drop_rate
  
  #--------------------------------------------------------------------------
  # new method: drop_rate
  #--------------------------------------------------------------------------
  def drop_rate
    return 0 if @drop_rate.nil?
    return @drop_rate
  end
  
end # RPG::Enemy::DropItem

#==============================================================================
# ■ Game_Enemy
#==============================================================================

class Game_Enemy < Game_Battler
  
  #--------------------------------------------------------------------------
  # alias method: make_drop_items
  #--------------------------------------------------------------------------
  alias game_enemy_make_drop_items_edr make_drop_items
  def make_drop_items
    result = game_enemy_make_drop_items_edr
    result += make_extra_drops
    return result
  end
  
  #--------------------------------------------------------------------------
  # new method: make_extra_drops
  #--------------------------------------------------------------------------
  def make_extra_drops
    result = []
    for drop in enemy.extra_drops
      next if rand > drop.drop_rate
      result.push(item_object(drop.kind, drop.data_id))
    end
    return result
  end
  
end # Game_Enemy

#==============================================================================
#
# ▼ End of File
#
#==============================================================================[/pre]

点评

脚本都不点评吗,毕竟好心给你们发放的说。  发表于 2017-7-22 09:41
所有脚本摆出来太长了,应该加个折叠隐藏。  发表于 2017-7-22 08:19

评分

参与人数 3星屑 +66 赞 +2 收起 理由
zzz2207981 + 1 精品文章
3231152940 + 1 精品文章
zaiy2863 + 66 谢谢 很6

查看全部评分

P1不太上了,有问题加个Q1286124843,不管是脚本还是游戏问题都可以来找我
梦石
0
星屑
2306
在线时间
1010 小时
注册时间
2012-4-30
回帖
1455

开拓者

发表于 2017-7-19 18:11:51 | 显示全部楼层
本帖最后由 铅笔描绘的思念 于 2017-7-20 12:55 编辑

善用
点击展开/收起这个标签




怎么可能会很长啊。。难道长了有bug?
点击展开/收起[pre lang="ruby"]#==============================================================================
#
# ▼ Yanfly Engine Ace - Extra Drops v1.01
# -- Last Updated: 2011.12.31
# -- Level: Normal
# -- Requires: n/a
#
#==============================================================================

$imported = {} if $imported.nil?
$imported["YEA-ExtraDrops"] = true

#==============================================================================
# ▼ Updates
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# 2011.12.31 - Bug Fixed: Drop ratios now work properly.
# 2011.12.17 - Started Script and Finished.
#
#==============================================================================
# ▼ Introduction
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# Enemies by default only drop three items maximum in RPG Maker VX Ace. The
# drop rates are also limited to rates that can only be achieved through
# denominator values. A drop rate of say, 75% cannot be achieved. This script
# provides the ability to add more than just three drops and more control over
# the drop rates, too.
#
#==============================================================================
# ▼ Instructions
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# To install this script, open up your script editor and copy/paste this script
# to an open slot below ▼ Materials/素材 but above ▼ Main. Remember to save.
#
# -----------------------------------------------------------------------------
# Enemy Notetags - These notetags go in the enemies notebox in the database.
# -----------------------------------------------------------------------------
# <drop Ix: y%>在敌人备注添加额外的物品掉落,X为物品编号,Y为概率
# <drop Wx: y%>在敌人备注添加额外的武器掉落,X为武器编号,Y为概率
# <drop Ax: y%>在敌人备注添加额外的防具掉落,X为防具编号,Y为概率
# Causes enemy to drop item, weapon, or armour (marked by I, W, or A) x at a
# rate of y percent. Insert multiples of this tag to increase the number of
# drops an enemy can possibly have.
#
#==============================================================================
# ▼ Compatibility
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# This script is made strictly for RPG Maker VX Ace. It is highly unlikely that
# it will run with RPG Maker VX without adjusting.
#
#==============================================================================
# ▼ Editting anything past this point may potentially result in causing
# computer damage, incontinence, explosion of user's head, coma, death, and/or
# halitosis so edit at your own risk.
#==============================================================================

module YEA
  module REGEXP
  module ENEMY

    DROP_PLUS = /<(?:DROP|drop)[ ]([IWA])(\d+):[ ](\d+)([%%])>/i

  end # ENEMY
  end # REGEXP
end # YEA

#==============================================================================
# ■ DataManager
#==============================================================================

module DataManager

  #--------------------------------------------------------------------------
  # alias method: load_database
  #--------------------------------------------------------------------------
  class <<self; alias load_database_edr load_database; end
  def self.load_database
    load_database_edr
    load_notetags_edr
  end

  #--------------------------------------------------------------------------
  # new method: load_notetags_al
  #--------------------------------------------------------------------------
  def self.load_notetags_edr
    for enemy in $data_enemies
      next if enemy.nil?
      enemy.load_notetags_edr
    end
  end

end # DataManager

#==============================================================================
# ■ RPG::Enemy
#==============================================================================

class RPG::Enemy < RPG::BaseItem

  #--------------------------------------------------------------------------
  # public instance variables
  #--------------------------------------------------------------------------
  attr_accessor :extra_drops

  #--------------------------------------------------------------------------
  # common cache: load_notetags_edr
  #--------------------------------------------------------------------------
  def load_notetags_edr
    @extra_drops = []
    #---
    self.note.split(/[\r\n]+/).each { |line|
      case line
      #---
      when YEA::REGEXP::ENEMY::DROP_PLUS
        case $1.upcase
        when "I";  kind = 1
        when "W";  kind = 2
        when "A";  kind = 3
        else; next
        end
        item = RPG::Enemy::DropItem.new
        item.kind = kind
        item.data_id = $2.to_i
        item.drop_rate = $3.to_i * 0.01
        @extra_drops.push(item)
      end
    } # self.note.split
    #---
  end

end # RPG::Enemy

#==============================================================================
# ■ RPG::Enemy::DropItem
#==============================================================================

class RPG::Enemy::DropItem

  #--------------------------------------------------------------------------
  # public instance variables
  #--------------------------------------------------------------------------
  attr_accessor :drop_rate

  #--------------------------------------------------------------------------
  # new method: drop_rate
  #--------------------------------------------------------------------------
  def drop_rate
    return 0 if @drop_rate.nil?
    return @drop_rate
  end

end # RPG::Enemy::DropItem

#==============================================================================
# ■ Game_Enemy
#==============================================================================

class Game_Enemy < Game_Battler

  #--------------------------------------------------------------------------
  # alias method: make_drop_items
  #--------------------------------------------------------------------------
  alias game_enemy_make_drop_items_edr make_drop_items
  def make_drop_items
    result = game_enemy_make_drop_items_edr
    result += make_extra_drops
    return result
  end

  #--------------------------------------------------------------------------
  # new method: make_extra_drops
  #--------------------------------------------------------------------------
  def make_extra_drops
    result = []
    for drop in enemy.extra_drops
      next if rand > drop.drop_rate
      result.push(item_object(drop.kind, drop.data_id))
    end
    return result
  end

end # Game_Enemy

#==============================================================================
#
# ▼ End of File
#
#==============================================================================
[/pre]
回复

使用道具 举报

梦石
0
星屑
1345
在线时间
378 小时
注册时间
2015-6-16
回帖
526
 楼主| 发表于 2017-7-19 18:56:26 | 显示全部楼层
肉包大大建议用代码框。亲测FOLD。第二个脚本够你们拉的2333。每个脚本都很长呢

点评

就是这么做的,然后发布以后,很长。然后干脆 只用代码了  发表于 2017-7-20 09:50
把[code][/code]整个放在[fold][/fold]里。。  发表于 2017-7-19 20:42
P1不太上了,有问题加个Q1286124843,不管是脚本还是游戏问题都可以来找我
回复

使用道具 举报

梦石
0
星屑
878
在线时间
576 小时
注册时间
2010-6-26
回帖
709
发表于 2017-7-19 23:11:13 | 显示全部楼层
感谢分享

点评

SQ,话说今天赶制一下2.4.到时候你来玩玩看。群里面有最新图片的。消耗条现在可视了。肉包大大给我绘制好了。  发表于 2017-7-20 09:48
回复

使用道具 举报

梦石
0
星屑
1345
在线时间
378 小时
注册时间
2015-6-16
回帖
526
 楼主| 发表于 2017-7-20 09:50:00 | 显示全部楼层
这些脚本,一部分是外站的。很多人翻不了墙,我拿到了就拿出来分享
P1不太上了,有问题加个Q1286124843,不管是脚本还是游戏问题都可以来找我
回复

使用道具 举报

梦石
0
星屑
354
在线时间
127 小时
注册时间
2016-10-8
回帖
54
发表于 2017-7-21 00:00:07 | 显示全部楼层
抱歉,能在這兒問嗎?@@

想問那個敵人信息顯示腳本,該如何使用…
全是英文,看沒有懂

是要在敵人備註欄輸入嗎?
那麼又是輸入什麼呢?
完全搞不懂 冏

点评

shift是选一个单体敌人的技能,然后才能出现这句话。随机一个什么的出现不了(全体也不能的)  发表于 2017-7-21 19:22
感謝回答,雖然我按了shift沒跳出東西,可能腳本卡到了XD 不要緊,我摸一下,不行的話再另起帖問一下好了,感謝您 *3*  发表于 2017-7-21 17:14
英文的话,可以从Instructions看下去,是介绍,然后用谷歌翻译/有道翻译什么的去翻译就知道了  发表于 2017-7-21 10:54
默认情况是均可查看  发表于 2017-7-21 10:53
其实不需要,那些备注确实要写在敌人里面(也可以不写),因为是确定敌人到底要隐藏/显示什么信息。默认的话按shift键就可以查看了  发表于 2017-7-21 10:52
(´_ゝ`)...仍未命名的遊戲製作進度:0%
回复

使用道具 举报

梦石
0
星屑
791
在线时间
51 小时
注册时间
2021-6-14
回帖
30
发表于 2021-9-11 19:10:13 | 显示全部楼层
good,真不错
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部