查看: 1604|回复: 4

[已经解决] 求一个像幻想三国志那样的带阵形功能的战斗系统

[复制链接]
梦石
0
星屑
50
在线时间
197 小时
注册时间
2014-9-16
回帖
57
发表于 2015-8-19 18:57:37 | 显示全部楼层 |阅读模式

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

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

×
就像幻想三国志那样的:
1.敌我分别有一个5*5的区域,敌我使用相应的阵法时候会自动将角色移动到这个5*5区域中的特定位置,然后每个角色逐一添加这个阵法的buff或debuff(每个角色的buff和debuff都要能独立设置互不干扰)
2.此外一个角色的正前方如果有其他角色,那这个角色不能被普通攻击,对于有些法术可以突破这一限制
希望有现成的脚本,多谢,论坛搜索和图书馆里没翻到相关内容

点评

如果没有现成的,就不麻烦各位大大了,我感觉写一个这个脚本会很费劲  发表于 2015-8-19 18:59
梦石
0
星屑
5256
在线时间
760 小时
注册时间
2009-1-21
回帖
236
发表于 2015-8-19 22:05:44 | 显示全部楼层
本帖最后由 御之嵐 于 2015-8-19 22:51 编辑

雖然這是『VX的橫版戰鬥陣形』腳本
但是功能應該很接近你的需求
你要學 RUBY的話
這個腳本給你參考吧
https://rpg.blue/forum.php?mod=viewthread&tid=189131

雖然RGSS2 和 RGSS3 不太一樣
但我想思路應該是差不多的


=======================================
這個是剛剛在日站找到的
13年的東西
但是好像沒完成的樣子
http://blog.livedoor.jp/kuremente-rgssscript/archives/21745117.html
是VA橫版的腳本

預覽截圖
未命名.jpg

=======================================
日站
ツクール工房 A1(仮)的 VA橫版陣形腳本
http://a1tktk.web.fc2.com/scripts_page/battle_formation.html

預覽截圖
ml.jpg

点评

不知道是我浏览器有问题还是怎么着,我打开日站那个以后注释部分全是乱码,你能把那两个脚本粘过来吗?多谢  发表于 2015-8-20 18:05
感谢  发表于 2015-8-20 10:20

评分

参与人数 1梦石 +1 收起 理由
taroxd + 1 认可答案

查看全部评分

回复

使用道具 举报

梦石
2
星屑
34497
在线时间
614 小时
注册时间
2014-7-18
回帖
647

MZ评测员开拓者

发表于 2015-8-19 19:07:16 | 显示全部楼层
我准备在今后写一个类似的脚本,但是近期不会写,因为脚本知识严重不足,正在学脚本补课。
你能等到大约1~3年之后吗?

点评

好像MV不是RGSS4,因为都不用ruby了,用JS,专业人士说所有语言都差不多,关键是思路。 所以等出来再学~  发表于 2015-8-20 11:53
1-3年之后RGSS4就出来了 建议前辈去学这个吧 MV刚出来肯定会缺脚本的  发表于 2015-8-20 11:32
回复

使用道具 举报

梦石
0
星屑
50
在线时间
197 小时
注册时间
2014-9-16
回帖
57
 楼主| 发表于 2015-8-19 19:20:29 | 显示全部楼层
xjzsq 发表于 2015-8-19 19:07
我准备在今后写一个类似的脚本,但是近期不会写,因为脚本知识严重不足,正在学脚本补课。
你能等到大约1~3 ...

学脚本要那么久?先等等看有没有其他大大回复我吧,没有的话我就去学Ruby了,多谢回复

点评

我设计的游戏涉及到了鼠标脚本,要研究的透彻一点。  发表于 2015-8-19 20:06
回复

使用道具 举报

梦石
0
星屑
5256
在线时间
760 小时
注册时间
2009-1-21
回帖
236
发表于 2015-8-20 22:23:21 | 显示全部楼层
本帖最后由 御之嵐 于 2016-4-16 00:37 编辑

@朢瑏禾火氺  

不知道為什麼
用了兩個摺疊的語法
內文就會天下大亂ლ(゚Д゚ლ)
後面的腳本我只用代碼的語法去顯示
所以給他一點時間顯示吧
會有點久_(:з」∠)_

========================================

RGSSスクリプト倉庫
RPG探検隊Sideview対応隊列設定 Ver0.20-α
  1. #==============================================================================
  2. # ■RPG探検隊Sideview対応隊列設定 for RGSS3 Ver0.20-alpha
  3. # □author kure
  4. #
  5. # 呼び出し方法  SceneManager.call(Scene_Formation)
  6. #
  7. #===============================================================================
  8. module KURE
  9.   module Formation
  10.     #初期設定(変更しない事)-----------------------------------------------------
  11.     FORMATION = []
  12.     FORMATION_SETTING = []
  13.    
  14.     #隊列設定-------------------------------------------------------------------
  15.     #FORMATION_SETTING = [隊列名,発動エフェクト, 出現スイッチ]
  16.     FORMATION_SETTING[0] = ["隊列1",[14,15,16,17],0]
  17.     FORMATION_SETTING[1] = ["隊列2",[0,16,0,0],1]
  18.     FORMATION_SETTING[2] = ["隊列3",[0,0,19,0],0]
  19.    
  20.     #FORMATION[0~] =[アクター1人目,アクター2人目,…]
  21.     #アクター位置設定…[X座標, Y座標, H座標]
  22.     FORMATION[0] = [[415,160, 0],[435,185, 0],[455,210, 0],[475,235, 0]]
  23.     FORMATION[1] = [[415,195, 0],[455,225, 0],[465,195, 0],[505,225, 0]]
  24.     FORMATION[2] = [[415,195, 0],[435,145, 0],[435,245, 0],[505,195, 0]]

  25.   end
  26. end

  27. #==============================================================================
  28. # ■ Scene_Formation
  29. #==============================================================================
  30. class Scene_Formation < Scene_MenuBase
  31.   #--------------------------------------------------------------------------
  32.   # ● 開始処理
  33.   #--------------------------------------------------------------------------
  34.   def start
  35.     super
  36.     create_help_window
  37.     create_formation_window
  38.     create_info_window
  39.     create_setting_window
  40.    
  41.     window_setting
  42.   end
  43.   #--------------------------------------------------------------------------
  44.   # ● ヘルプウィンドウの作成
  45.   #--------------------------------------------------------------------------
  46.   def create_help_window
  47.     @help_window = Window_Help.new(1)
  48.     @help_window.set_text("隊列を選択してください")
  49.     @help_window.viewport = @viewport
  50.   end
  51.   #--------------------------------------------------------------------------
  52.   # ● 隊列ウィンドウの作成
  53.   #--------------------------------------------------------------------------
  54.   def create_formation_window
  55.     @formation_window = Window_Formation.new(0,@help_window.height,Graphics.height - @help_window.height)
  56.    
  57.     #ハンドラのセット
  58.     @formation_window.set_handler(:cancel,   method(:formation_cancel))
  59.     @formation_window.set_handler(:ok,   method(:formation_ok))   
  60.   end
  61.   #--------------------------------------------------------------------------
  62.   # ● インフォメーションウィンドウの作成
  63.   #--------------------------------------------------------------------------
  64.   def create_info_window
  65.     wx = @formation_window.width
  66.     wy = @help_window.height
  67.     ww = Graphics.width - @formation_window.width
  68.     wh = 48
  69.     @info_window = Window_k_Formation_InfoWindow.new(wx, wy, ww, wh)
  70.     @info_window.refresh
  71.   end
  72.   #--------------------------------------------------------------------------
  73.   # ● セッティングウィンドウの作成
  74.   #--------------------------------------------------------------------------
  75.   def create_setting_window
  76.     wx = @formation_window.width
  77.     wy = @help_window.height + @info_window.height
  78.     ww = Graphics.width - @formation_window.width
  79.     wh = Graphics.height - wy   
  80.     @setting_window = Window_k_Formation_SettingWindow.new(wx, wy, ww, wh)
  81.   end
  82.   #--------------------------------------------------------------------------
  83.   # ● ウィンドウのセット
  84.   #--------------------------------------------------------------------------
  85.   def window_setting
  86.     @formation_window.setting_window = @setting_window
  87.    
  88.     @setting_window.draw_index = @formation_window.current_ext
  89.   end
  90.   #--------------------------------------------------------------------------
  91.   # ● 隊列ウィンドウ[決定]
  92.   #--------------------------------------------------------------------------
  93.   def formation_ok
  94.     if @formation_window.current_ext != -1
  95.       $game_party.formation = @formation_window.current_ext
  96.       @info_window.refresh
  97.       @formation_window.activate
  98.     else
  99.       return_scene
  100.     end
  101.   end
  102.   #--------------------------------------------------------------------------
  103.   # ● 隊列ウィンドウ[キャンセル]
  104.   #--------------------------------------------------------------------------
  105.   def formation_cancel
  106.     return_scene
  107.   end
  108.   
  109. end

  110. #==============================================================================
  111. # ■ Window_k_Formation_InfoWindow
  112. #==============================================================================
  113. class Window_k_Formation_InfoWindow < Window_Base
  114.   #--------------------------------------------------------------------------
  115.   # ● リフレッシュ
  116.   #--------------------------------------------------------------------------
  117.   def refresh
  118.     contents.clear
  119.     change_color(system_color)
  120.     draw_text(0, 0, contents.width / 2, line_height, "現在の隊列")
  121.    
  122.     formation = KURE::Formation::FORMATION_SETTING[$game_party.formation][0]
  123.    
  124.     change_color(normal_color)
  125.     draw_text(contents.width / 2, 0, contents.width / 2, line_height, formation, 2)
  126.   end
  127. end

  128. #==============================================================================
  129. # ■ Window_Formation
  130. #------------------------------------------------------------------------------
  131. #  全てのパーティーメンバーを表示するウィンドウです。
  132. #==============================================================================
  133. class Window_Formation< Window_Command
  134.   attr_accessor :setting_window
  135.   #--------------------------------------------------------------------------
  136.   # ● オブジェクト初期化
  137.   #--------------------------------------------------------------------------
  138.   def initialize(x,y,height)
  139.     @window_height = height
  140.     super(x,y)
  141.   end
  142.   #--------------------------------------------------------------------------
  143.   # ● ウィンドウ幅の取得
  144.   #--------------------------------------------------------------------------
  145.   def window_width
  146.     150
  147.   end
  148.   #--------------------------------------------------------------------------
  149.   # ● ウィンドウ高さの取得
  150.   #--------------------------------------------------------------------------
  151.   def window_height
  152.     @window_height
  153.   end
  154.   #--------------------------------------------------------------------------
  155.   # ● コマンドリストの作成
  156.   #--------------------------------------------------------------------------
  157.   def make_command_list
  158.     formation = KURE::Formation::FORMATION_SETTING

  159.     for list in 0..formation.size - 1
  160.       if formation[list][2] != 0
  161.         if $game_switches[formation[list][2]]
  162.           add_command(formation[list][0], :ok, true, list)
  163.         end
  164.       else
  165.         add_command(formation[list][0], :ok, true, list)
  166.       end
  167.     end
  168.    
  169.     add_command(" 設定終了", :ok, true, -1)
  170.   end
  171.   #--------------------------------------------------------------------------
  172.   # ● カーソル位置の設定
  173.   #--------------------------------------------------------------------------
  174.   def index=(index)
  175.     @index = index
  176.     update_cursor
  177.     call_update_help
  178.    
  179.     @setting_window.draw_index = current_ext if @setting_window
  180.   end
  181. end

  182. #==============================================================================
  183. # ■ Window_k_Formation_SettingWindow
  184. #==============================================================================
  185. class Window_k_Formation_SettingWindow < Window_Base
  186.   attr_accessor :draw_index
  187.   #--------------------------------------------------------------------------
  188.   # ● 選択中の項目の設定
  189.   #--------------------------------------------------------------------------
  190.   def draw_index=(draw_index)
  191.     return if @draw_index == draw_index
  192.     @draw_index = draw_index
  193.     refresh
  194.   end
  195.   #--------------------------------------------------------------------------
  196.   # ● リフレッシュ
  197.   #--------------------------------------------------------------------------
  198.   def refresh
  199.     contents.clear
  200.    
  201.     #共通描画
  202.     draw_gauge(0,0, contents.width , 1, mp_gauge_color2,crisis_color)
  203.     change_color(normal_color)
  204.     draw_text(0,0, 200, line_height, "隊列効果")
  205.    
  206.     return unless @draw_index
  207.     return if @draw_index == -1
  208.    
  209.     #隊列に使用する配列を取得
  210.     ptm = $game_party.battle_members
  211.     f_set = KURE::Formation::FORMATION_SETTING[@draw_index]
  212.     f_pos = KURE::Formation::FORMATION[@draw_index]
  213.    
  214.     #隊列名描画
  215.     draw_text(0,0, contents.width, line_height, f_set[0], 2)
  216.         
  217.     #PTMの描画
  218.     change_color(normal_color)
  219.     for battler in 0..ptm.size - 1
  220.       draw_text(0, line_height * (1 + battler) ,contents.width / 4, line_height, ptm[battler].name)
  221.       
  222.       #発動ステートの描画
  223.       if f_set[1][battler] != 0
  224.         draw_text(contents.width / 4, line_height * (1 + battler) ,contents.width / 4, line_height, $data_states[f_set[1][battler]].name)
  225.       end
  226.     end
  227.    
  228.     #隊列の描画
  229.     for battler in 0..f_pos.size - 1
  230.       draw_x = contents.width - (Graphics.width - f_pos[battler][0])
  231.       draw_y = 100 + contents.height - (Graphics.height - f_pos[battler][1])
  232.       if ptm[battler]
  233.         draw_formation_character(ptm[battler].character_name, ptm[battler].character_index , draw_x, draw_y)
  234.       end
  235.     end
  236.    
  237.   end
  238.   #--------------------------------------------------------------------------
  239.   # ● 横向きのグラフィックの描画(追加定義)
  240.   #--------------------------------------------------------------------------
  241.   def draw_formation_character(character_name, character_index, x, y)
  242.     return unless character_name
  243.     bitmap = Cache.character(character_name)
  244.     sign = character_name[/^[\!\$]./]
  245.     if sign && sign.include?('[/fold]


  246. ========================================

  247. ツクール工房 A1(仮)
  248. 這個日站的腳本需要他的戰鬥系統
  249. 所以會用到很多腳本

  250. A1バトル共通スクリプト
  251. バトルアクション
  252. フェイスステータスウィンドウ
  253. 個別バトルステータスウィンドウ
  254. サイドビューバトルアクション設定
  255. サイドビューバトル
  256. 陣形

  257. )
  258.       cw = bitmap.width / 3
  259.       ch = bitmap.height / 4
  260.     else
  261.       cw = bitmap.width / 12
  262.       ch = bitmap.height / 8
  263.     end
  264.     n = character_index
  265.     src_rect = Rect.new((n%4*3+1)*cw, (n/4*4+1)*ch, cw, ch)
  266.     contents.blt(x - cw / 2, y - ch, bitmap, src_rect)
  267.   end
  268. end

  269. #==============================================================================
  270. # ■ Game_Party
  271. #==============================================================================
  272. class Game_Party < Game_Unit
  273.   #--------------------------------------------------------------------------
  274.   # ● 隊列を設定(追加定義)
  275.   #--------------------------------------------------------------------------
  276.   def formation=(id)
  277.     @formation = 0 unless @formation
  278.     @formation = id
  279.   end
  280.   #--------------------------------------------------------------------------
  281.   # ● 隊列を呼び出し(追加定義)
  282.   #--------------------------------------------------------------------------
  283.   def formation
  284.     @formation = 0 unless @formation
  285.     return @formation
  286.   end
  287. end

  288. #==============================================================================
  289. # ■ Scene_Battle
  290. #==============================================================================
  291. class Scene_Battle < Scene_Base
  292.   #--------------------------------------------------------------------------
  293.   # ● 戦闘開始(エイリアス再定義)
  294.   #--------------------------------------------------------------------------
  295.   alias k_before_formation_command_battle_start battle_start
  296.   def battle_start
  297.    
  298.    
  299.     #隊列ステートを付与
  300.     battle_m = $game_party.battle_members
  301.     formation_s = KURE::Formation::FORMATION_SETTING[$game_party.formation]
  302.     for actor in 0..battle_m.size - 1
  303.       if formation_s[1][actor]
  304.         battle_m[actor].add_state(formation_s[1][actor])
  305.       end
  306.     end
  307.    
  308.     k_before_formation_command_battle_start
  309.   end
  310.   #--------------------------------------------------------------------------
  311.   # ● 終了前処理(エイリアス再定義)
  312.   #--------------------------------------------------------------------------
  313.   alias k_before_formation_command_pre_terminate pre_terminate
  314.   def pre_terminate
  315.    
  316.     #隊列ステートを削除
  317.     battle_m = $game_party.battle_members
  318.     formation_s = KURE::Formation::FORMATION_SETTING[$game_party.formation]
  319.     for actor in 0..battle_m.size - 1
  320.       if formation_s[1][actor]
  321.         battle_m[actor].remove_state(formation_s[1][actor])
  322.       end
  323.     end
  324.    
  325.     k_before_formation_command_pre_terminate
  326.   end
  327. end

  328. #==============================================================================
  329. # ■ Sideview Ver100
  330. #==============================================================================
  331. class SideView
  332.   #--------------------------------------------------------------------------
  333.   # ● ベース座標をセット data = [X軸, Y軸, H軸]  moment_set…瞬間配置(再定義)
  334.   #--------------------------------------------------------------------------
  335.   def set_base_position(moment_set = true)
  336.     mirroring_reset
  337.     if @battler.actor?
  338.       data = KURE::Formation::FORMATION[$game_party.formation][@battler.index].dup
  339.       @base_x = data[0] * 100 if !@mirror
  340.       @base_x = (Graphics.width - data[0]) * 100 if @mirror
  341.     else
  342.       data = [@battler.screen_x, @battler.screen_y, 0].dup
  343.       @base_x = data[0] * 100 if !$sv_camera.mirror
  344.       @base_x = (Graphics.width - data[0]) * 100 if $sv_camera.mirror
  345.     end
  346.     @base_y = data[1] * 100
  347.     @base_h = data[2] * 100
  348.     @base_z = @y
  349.     return if !moment_set
  350.     @x = @base_x
  351.     @y = @base_y
  352.     @z = @base_z
  353.   end
  354. end
复制代码



========================================

ツクール工房 A1(仮)
這個日站的腳本需要他的戰鬥系統
所以會用到很多腳本

A1共通スクリプト
[pre lang="ruby"]# ===========================================================================
# ◆ A1 Scripts ◆
#    A1共通処理(RGSS2/RGSS3共用)
#
# バージョン   : 4.50 (2012/01/26)
# 作者         : A1
# URL     : http://a1tktk.web.fc2.com/
# ---------------------------------------------------------------------------
# 更新履歴   :2011/11/11 Ver1.00 新規作成
#        :2011/12/22 Ver2.00 RGSS3用と同様の処理に変更
#        :2011/12/30 Ver2.10 RGSS3用メソッドを追加
#        :2011/12/30 Ver3.00 RGSS3用共通処理と統合
#        :2011/12/31 Ver3.10 マップチップサーチの仕様を変更
#        :2011/12/31 Ver3.10 拡張通行判定を追加
#        :2012/01/01 Ver3.11 クラス名の取得処理を追加
#              :2012/01/02 Ver3.20 配列を考慮したsplit処理を追加
#              :2012/01/02 Ver3.20 配列の全ての要素を整数にする処理を追加
#              :2012/01/02 Ver3.30 注釈の処理の仕様を変更
#              :2012/01/02 Ver3.40 「前のイベントコマンドの取得」を追加
#              :2012/01/03 Ver3.50 「フレーム更新」を追加
#              :2012/01/04 Ver3.60 「指定のウィンドウが開いている間ウェイト」追加
#              :2012/01/04 Ver3.70 RGSS2用処理見直し
#              :2012/01/05 Ver3.80 注釈文字列にエスケープコマンド対応
#              :2012/01/05 Ver3.80 多次元配列を考慮したsplit処理を追加
#              :2012/01/05 Ver3.80 注釈にスクリプト処理機能を追加
#              :2012/01/10 Ver3.90 文字縁取り描画を追加
#              :2012/01/11 Ver4.00 テキストビットマップのキャッシュを追加
#              :2012/01/13 Ver4.01 「タイルセットの変更」ができなくなる不具合を修正
#              :2012/01/14 Ver4.10 split処理を強化
#              :2012/01/14 Ver4.20 空白を含む注釈コマンドに対応
#              :2012/01/14 Ver4.21 split処理の不具合を修正
#              :2012/01/21 Ver4.30 メモの内容を取得する関数を追加
#              :2012/01/24 Ver4.40 メモの内容を取得する関数を追加
#              :2012/01/24 Ver4.50 メモの内容を取得する関数を追加
# ---------------------------------------------------------------------------
# 設置場所      
#  なるべく上の方
#
# 必要スクリプト
#    なし
#==============================================================================
$imported = {} if $imported == nil
$imported["A1_Common_Script"] = 4.50
#==============================================================================
# ■ Kernel
#==============================================================================
module Kernel
  #--------------------------------------------------------------------------
  # ○ RGSSのバージョン取得
  #--------------------------------------------------------------------------
  def rgss_version
    return 3 if defined? Graphics.play_movie
    return 2 if defined? Graphics.resize_screen
    return 1
  end
  #--------------------------------------------------------------------------
  # ○ コモンスクリプトのバージョン取得
  #--------------------------------------------------------------------------
  def common_version
    $imported["A1_Common_Script"]
  end
  #--------------------------------------------------------------------------
  # ○ コモンスクリプトのバージョンが古い
  #--------------------------------------------------------------------------
  def old_common_script(script_name, version)
    msgbox("#{script_name}にはA1共通スクリプトVer#{version}以上が必要です")
  end
end
#==============================================================================
# ■ A1_System
#==============================================================================
module A1_System
end
#==============================================================================
# ■ A1_System::CommonModule
#==============================================================================

class A1_System::CommonModule
  #--------------------------------------------------------------------------
  # ○ 定数
  #--------------------------------------------------------------------------
  TWOBYTE_LIST = {
                  " " => " ",
                  "=" => "=",
                  ":" => ":"
                  }
  #--------------------------------------------------------------------------
  # ○ オブジェクト初期化
  #--------------------------------------------------------------------------
  def initialize
    define_command
  end
  #--------------------------------------------------------------------------
  # ○ 変換対象の全角文字を半角に置換
  #--------------------------------------------------------------------------
  def replace_twobyte(str)
    for key in TWOBYTE_LIST.keys
      str.gsub!(key) {TWOBYTE_LIST[key]}
    end
    return str
  end
  #--------------------------------------------------------------------------
  # ○ マイナスが含まれている文字列を数値にする
  #--------------------------------------------------------------------------
  def minus_to_i(s)
    if s[0,0] == "-"
      s.gsub!("-","")
      return s.to_i * -1
    else
      return s.to_i
    end
  end
  #--------------------------------------------------------------------------
  # ○ ミリ秒単位の現在時間
  #--------------------------------------------------------------------------
  def now_usec
    now = Time.now
    hour = now.hour * 60 * 60
    min  = now.min * 60
    sec  = now.sec
    msec = (now.usec / 1000.0).round
    return (hour + min + sec) * 1000 + msec
  end
  #--------------------------------------------------------------------------
  # ○ イベントリストの作成
  #--------------------------------------------------------------------------
  def create_event_list(code, indent, parameters)
    list = RPG::EventCommand.new
    list.code       = code
    list.indent     = indent
    list.parameters = parameters
    return list
  end
  #--------------------------------------------------------------------------
  # ○ メソッド呼び出し
  #--------------------------------------------------------------------------
  def send_method(method_name)
    return send(method_name) if respond_to?(method_name)
  end
  #--------------------------------------------------------------------------
  # ○ オブジェクトの型を判断してStringならエンコード
  #--------------------------------------------------------------------------
  def encoding_string(obj)
    obj.force_encoding("UTF-8") if obj.is_a?(String)
    return obj
  end
  #--------------------------------------------------------------------------
  # ○ メモの内容から必要な情報を取得
  #--------------------------------------------------------------------------
  def note_data(note, key)
    result = []
    note.each_line {|line|
      next unless line =~ /<#{key}[ ]?(.*)>/
      return true if $1.empty?
      data = $a1_common.replace_twobyte($1).split(" ")
      for st in data
        result.push(st)
      end
    }
    return false if result.empty?
    return result
  end
  #--------------------------------------------------------------------------
  # ○ メモの内容からハッシュを作成
  #--------------------------------------------------------------------------
  def note_data_hash(note, key, data_default = nil, default = {}, ret = {})
    list = note_data_split(note, key)
    return default if list.empty?
    list.each {|data| ret[data[0]] = data[1] ? data[1] : data_default }
    return ret
  end
  #--------------------------------------------------------------------------
  # ○ メモの内容からカンマ区切りの多元配列を取得
  #--------------------------------------------------------------------------
  def note_data_split(note, key, default = [], ret = [])
    data = note_data(note, key)
    return default unless data.is_a?(Array)
    data.each {|str| ret.push(convert_integer_from_array(split_array(str)))}
    return ret
  end
  #--------------------------------------------------------------------------
  # ○ 配列の内容から数値があれば変換
  #--------------------------------------------------------------------------
  def convert_integer_from_array(data, ret = [])
    data.each {|str| ret.push(convert_integer(str))}
    return ret
  end
  #--------------------------------------------------------------------------
  # ○ 数値があれば変換
  #--------------------------------------------------------------------------
  def convert_integer(str)
    return $1.to_i if str =~ /(^[-]?[0-9]+$)/
    str.is_a?(Array) ? convert_integer_from_array(str) : str
  end
  #--------------------------------------------------------------------------
  # ○ メモの内容から単項目の数値を取得
  #--------------------------------------------------------------------------
  def note_data_one_value(note, key, default)
    data = note_data(note, key)
    return data[0].to_i if data.is_a?(Array)
    return default
  end
  #--------------------------------------------------------------------------
  # ○ メモの内容から単項目を取得
  #--------------------------------------------------------------------------
  def note_data_one(note, key, default)
    data = note_data(note, key)
    return data[0] if data.is_a?(Array)
    return default
  end
  #--------------------------------------------------------------------------
  # ○ メモの内容からカンマ区切りの文字列を取得
  #--------------------------------------------------------------------------
  def note_data_array_str(note, key, default)
    data = note_data(note, key)
    return data[0].split(",") if data.is_a?(Array)
    return default
  end
  #--------------------------------------------------------------------------
  # ○ メモの内容からカンマ区切りの数値を取得
  #--------------------------------------------------------------------------
  def note_data_array_value(note, key, default)
    data = note_data(note, key)
    return default unless data.is_a?(Array)
    return convert_integer_from_array(split_array(data[0]))
  end
  #--------------------------------------------------------------------------
  # ○ カンマ区切りの文字列メモを変換
  #--------------------------------------------------------------------------
  def note_data_array(note, key, type, default = nil, through = true)
    ret = []
    default.each {|dat| ret.push(dat)} if default != nil
   
    data = note_data(note, key)
    return ret unless data.is_a?(Array)
   
    data = data[0].split(",")
    for d in data
      next if ret.include?(d) if through
      ret.push(d.to_i) if type.is_a?(Integer)
      ret.push(d)      if type.is_a?(String)
    end
    return ret
  end
  #--------------------------------------------------------------------------
  # ○ ディレクトリの作成
  #--------------------------------------------------------------------------
  def make_directory(dir_name)
    Dir::mkdir(dir_name) unless FileTest.exist?(dir_name)
  end
  #--------------------------------------------------------------------------
  # ○ コマンドリスト
  #--------------------------------------------------------------------------
  def make_command(command, src = "", dect = "")
    src.gsub!("/","\\")
    dect.gsub!("/","\\")
    cmd = "#{command} \"#{src}\" \"#{dect}\""
    return cmd
  end
  #--------------------------------------------------------------------------
  # ○ 素材の拡張子を取得
  #--------------------------------------------------------------------------
  def material_ext(directory, file, direct = false)
    exts = []
    exts = [".png",".bmp",".jpg"]               if directory =~ /(.*)Graphics\/(.*)/
    exts = [".mid",".ogg",".wav",".mp3",".wma"] if directory =~ /(.*)Audio(.*)/
   
    find_file = sprintf("%s%s", directory, file) unless direct
    find_file = file if direct
   
    for ext in exts
      return ext if File.exist?(sprintf("%s%s", find_file, ext))
    end
    return nil
  end
  #--------------------------------------------------------------------------
  # ○ 素材が存在するかチェック
  #--------------------------------------------------------------------------
  def material_exist?(directory, file, direct = false)
    return false if material_ext(directory, file, direct) == nil
    return true
  end
  #--------------------------------------------------------------------------
  # ○ ファイルコピー
  #--------------------------------------------------------------------------
  def copy_file(src, dest)
    srcFile = File.open( src, "rb" )
    dstFile = File.open( dest, "wb" )
    dstFile.write( srcFile.read )
    srcFile.close
    dstFile.close
  end
  #--------------------------------------------------------------------------
  # ○ ファイルの存在を確認してファイルコピー
  #--------------------------------------------------------------------------
  def material_copy(src, dest, directory)
    ext = material_ext(directory, src, true)
    copy_file( src + ext, dest + ext ) if ext != nil
  end
  #--------------------------------------------------------------------------
  # ○ 配列からAudioを作成
  #--------------------------------------------------------------------------
  def set_audio(sound, kind)
    case kind
    when "BGM"; audio = RPG::BGM.new
    when "BGS"; audio = RPG::BGS.new
    when "ME";  audio = RPG::ME.new
    when "SE";  audio = RPG::SE.new
    end
    audio.name   = sound[0]
    audio.volume = sound[1]
    audio.pitch  = sound[2]
    return audio
  end
  #--------------------------------------------------------------------------
  # ○ 既に準拠識別子を持っているかチェック
  #--------------------------------------------------------------------------
  def chk_rtp(file_name, default)
    return "" if file_name =~ /^VX_.*/
    return "" if file_name =~ /^XP_.*/
    return "" if file_name =~ /^2000_.*/
    return "" if file_name =~ /^2003_.*/
    return default
  end
  #--------------------------------------------------------------------------
  # ○ 先頭の $ を切り出す
  #--------------------------------------------------------------------------
  def one_character(file_name)
    return file_name unless file_name[0] == "$"
    tmp = file_name.clone
    tmp[0] = ""
    return tmp
  end
  #--------------------------------------------------------------------------
  # ○ 配列を入れ替える
  #--------------------------------------------------------------------------
  def change_array(array, index1, index2)
    tmp = array[index1]
    array[index1] = array[index2]
    array[index2] = tmp
    return array
  end
  #--------------------------------------------------------------------------
  # ○ 移動ルートの作成
  #--------------------------------------------------------------------------
  def create_move_route(repeat, skippable, wait, list)
    move_route = RPG::MoveRoute.new
    move_route.repeat    = repeat
    move_route.skippable = skippable
    move_route.wait      = wait
    move_route.list      = list
    return move_route
  end
  #--------------------------------------------------------------------------
  # ○ 移動ルートコマンドの作成
  #--------------------------------------------------------------------------
  def create_move_command(code, parameters)
    list = RPG::MoveCommand.new
    list.code       = code
    list.parameters = parameters
    return list
  end
  #--------------------------------------------------------------------------
  # ○ インタプリタ起動用リストの作成
  #--------------------------------------------------------------------------
  def create_list(code, indent, parameters)
    list            = RPG::EventCommand.new
    list.code       = code
    list.indent     = indent
    list.parameters = parameters
    return list
  end
  #--------------------------------------------------------------------------
  # ○ クラス名の取得
  #--------------------------------------------------------------------------
  def class_name(class_instance)
    return class_instance.to_s.split(":")[0].gsub("#<","")
  end
  #--------------------------------------------------------------------------
  # ○ 配列を考慮したsplit
  #--------------------------------------------------------------------------
  def split_array(str)
    str = convert_escape_characters(str)
   
    ret       = []
    tmp_array = str.split(",")
   
    return strip_array_str(tmp_array) unless str.include?("[")
    tmp_str   = ""
    tmp_array.each {|s|
      if char_in_str(s, "[", "]") && tmp_str.empty?
        ret.push(s) unless s =~ /^\[/
        ret.push([s[1...s.size-1]]) if s =~ /^\[/
      else
        tmp_str = "#{tmp_str}#{s},"
        if char_in_str(tmp_str, "[", "]")
          unless tmp_str =~ /^\[/
            ret.push(tmp_str[0...tmp_str.size-1])
            tmp_str = ""
          else
            tmp_str = tmp_str[1...tmp_str.size-2]
            tmp_str = split_array(tmp_str) if tmp_str.include?("[")
            tmp_str = tmp_str.split(",") if tmp_str.include?(",")
            ret.push(tmp_str)   if tmp_str.is_a?(Array)
            ret.push([tmp_str]) if !tmp_str.is_a?(Array)
            tmp_str = ""
          end
        end
      end
    }
    return strip_array_str(ret)
  end
  #--------------------------------------------------------------------------
  # ○ 配列の中の文字列の先頭と末尾の空白を除去
  #--------------------------------------------------------------------------
  def strip_array_str(array, ret = [])
    array.each {|str| ret.push(strip_array_str(str)) if str.is_a?(Array); next if str.is_a?(Array); ret.push(str.strip) }
    return ret
  end
  #--------------------------------------------------------------------------
  # ○ 文字列の中に文字が何文字含まれているか調べて同数ならtrueを返す
  #--------------------------------------------------------------------------
  def char_in_str(str, c1, c2)
    num1 = 0
    num2 = 0
    (0...str.size).each {|i| num1 += 1 if str == c1; num2 += 1 if str == c2 }
    return num1 == num2
  end
  #--------------------------------------------------------------------------
  # ○ 制御文字の変換
  #--------------------------------------------------------------------------
  def convert_escape_characters(text)
    result = text.to_s.clone
    result.gsub!(/\\/)                           { "\e" }
    result.gsub!(/\e\e/)                         { "\\" }
    result.gsub!(/\eV\[(\d+)\]/i)                { $game_variables[$1.to_i] }
    result.gsub!(/\eV\[(\d+)\]/i)                { $game_variables[$1.to_i] }
    result.gsub!(/\eN\[(\d+)\]/i)                { actor_name($1.to_i) }
    result.gsub!(/\eP\[(\d+)\]/i)                { party_member_name($1.to_i) }
    result.gsub!(/\eG/i)                         { Vocab::currency_unit }
    loop { result = result.sub(/<s>(.+?)<\/s>/i) { eval($1) }; break unless $1 }
    result
  end
  #--------------------------------------------------------------------------
  # ○ アクター n 番の名前を取得
  #--------------------------------------------------------------------------
  def actor_name(n)
    actor = n >= 1 ? $game_actors[n] : nil
    actor ? actor.name : ""
  end
  #--------------------------------------------------------------------------
  # ○ パーティメンバー n 番の名前を取得
  #--------------------------------------------------------------------------
  def party_member_name(n)
    actor = n >= 1 ? $game_party.members[n - 1] : nil
    actor ? actor.name : ""
  end
  #--------------------------------------------------------------------------
  # ○ 配列を全て整数にする
  #--------------------------------------------------------------------------
  def params_to_i(params)
    ret = []
    params.each {|param| ret.push(param.to_i)}
    return ret
  end
  #--------------------------------------------------------------------------
  # ○ 注釈コマンド定義
  #--------------------------------------------------------------------------
  def define_command
    @cmd_108 = {}
  end
  #--------------------------------------------------------------------------
  # ○ 注釈コマンド定義取得
  #--------------------------------------------------------------------------
  def cmd_108
    @cmd_108
  end
  #--------------------------------------------------------------------------
  # ○ フレーム更新
  #--------------------------------------------------------------------------
  def update
  end
  #--------------------------------------------------------------------------
  # ○ 文字の幅と高さを取得
  #--------------------------------------------------------------------------
  def text_size(font, size, text)
    bitmap = Cache.system("")
    bitmap.font.name = font
    bitmap.font.size = size
    tw = bitmap.text_size(text).width
    th = bitmap.text_size(text).height
    bitmap.dispose
    return [tw, th]
  end
  #--------------------------------------------------------------------------
  # ○ 文字の幅を取得
  #--------------------------------------------------------------------------
  def text_width(font, text)
    texts = text.split("\n")
    @max_width = 0
    texts.each {|text|
      width = text_size(font.name, font.size, text)[0]
      @max_width = @max_width < width ? width : @max_width
    }
    return @max_width
  end
end
#==============================================================================
# ◆ RGSS3用処理
#==============================================================================
if rgss_version == 3
#==============================================================================
# ■ RPG::Tileset
#==============================================================================

class RPG::Tileset
  #--------------------------------------------------------------------------
  # ○ 拡張通行判定
  #--------------------------------------------------------------------------
  def ex_flags
    @ex_flags ||= Table.new(8192)
    return @ex_flags
  end
  #--------------------------------------------------------------------------
  # ○ 拡張通行判定初期化
  #--------------------------------------------------------------------------
  def init_ex_flags
    @ex_flags = Table.new(8192)
  end
end
#==============================================================================
# ■ Game_Interpreter
#------------------------------------------------------------------------------
#  イベントコマンドを実行するインタプリタです。このクラスは Game_Map クラス、
# Game_Troop クラス、Game_Event クラスの内部で使用されます。
#==============================================================================

class Game_Interpreter
  #--------------------------------------------------------------------------
  # ☆ オブジェクト初期化
  #     depth : ネストの深さ
  #--------------------------------------------------------------------------
  alias a1_common_gi_rgss3_initialize initialize
  def initialize(depth = 0, sub_interpreter = false)
    @sub_interpreter = sub_interpreter
    a1_common_gi_rgss3_initialize(depth)
  end
  #--------------------------------------------------------------------------
  # ☆ メッセージ表示がビジー状態の間ウェイト
  #--------------------------------------------------------------------------
  alias a1_common_gi_wait_for_message wait_for_message
  def wait_for_message
    return if @sub_interpreter
    a1_common_gi_wait_for_message
  end
end
#==============================================================================
# ■ Window_Message
#------------------------------------------------------------------------------
#  文章表示に使うメッセージウィンドウです。
#==============================================================================

class Window_Message < Window_Base
  #--------------------------------------------------------------------------
  # ☆ 通常文字の処理
  #--------------------------------------------------------------------------
  alias a1_common_wm_process_normal_character process_normal_character
  def process_normal_character(c, pos)
    wait_for_one_character_before
    a1_common_wm_process_normal_character(c, pos)
  end
  #--------------------------------------------------------------------------
  # ○ 一文字出力前のウェイト
  #--------------------------------------------------------------------------
  def wait_for_one_character_before
  end
end
#==============================================================================
# ■ RPG::Map
#==============================================================================

class RPG::Map
  #--------------------------------------------------------------------------
  # ○ マップチップを調べるか判定する
  #--------------------------------------------------------------------------
  def search_map_chip?
    return true if $a1_common.note_data(self.note, "マップチップサーチ")
    return false
  end
end
#==============================================================================
# ■ Game_Map
#------------------------------------------------------------------------------
#  マップを扱うクラスです。スクロールや通行可能判定などの機能を持っています。
# このクラスのインスタンスは $game_map で参照されます。
#==============================================================================

class Game_Map
  #--------------------------------------------------------------------------
  # ☆ セットアップ
  #--------------------------------------------------------------------------
  alias a1_common_gm_setup setup
  def setup(map_id)
    a1_common_gm_setup(map_id)
    setup_tileset
    map_chip_search if search_map_chip?
  end
  #--------------------------------------------------------------------------
  # ★ タイルセットの取得
  #--------------------------------------------------------------------------
  def tileset
    setup_tileset unless @tileset && @now_tileset_id == @tileset_id
    return @tileset
  end
  #--------------------------------------------------------------------------
  # ○ タイルセットのセットアップ
  #--------------------------------------------------------------------------
  def setup_tileset
    @tileset        = $data_tilesets[@tileset_id].clone
    @tileset.flags  = $data_tilesets[@tileset_id].flags.clone
    @now_tileset_id = @tileset_id
  end
  #--------------------------------------------------------------------------
  # ○ マップチップを調べるか判定する
  #--------------------------------------------------------------------------
  def search_map_chip?
    return @map.search_map_chip?
  end
  #--------------------------------------------------------------------------
  # ○ 指定座標の全レイヤーのフラグ判定(イベント含む)
  #--------------------------------------------------------------------------
  def all_tiles_flag?(x, y, bit)
    all_tiles(x, y).any? {|tile_id| tileset.flags[tile_id] & bit != 0 }
  end
  #--------------------------------------------------------------------------
  # ○ 指定座標の全レイヤーの拡張フラグ判定(イベント含む)
  #--------------------------------------------------------------------------
  def all_tiles_flag_ex?(x, y, bit)
    all_tiles(x, y).any? {|tile_id| tileset.ex_flags[tile_id] & bit != 0 }
  end
  #--------------------------------------------------------------------------
  # ○ 指定座標の全レイヤーの拡張フラグ判定
  #--------------------------------------------------------------------------
  def layered_tiles_flag_ex?(x, y, bit)
    layered_tiles(x, y).any? {|tile_id| tileset.ex_flags[tile_id] & bit != 0 }
  end
  #--------------------------------------------------------------------------
  # ○ 地形タグの取得(イベント含む)
  #--------------------------------------------------------------------------
  def terrain_tag_all_tailes(x, y)
    return 0 unless valid?(x, y)
    all_tiles(x, y).each do |tile_id|
      tag = tileset.flags[tile_id] >> 12
      return tag if tag > 0
    end
    return 0
  end
end
#==============================================================================
# ■ DataManager
#------------------------------------------------------------------------------
#  データベースとゲームオブジェクトを管理するモジュールです。ゲームで使用する
# ほぼ全てのグローバル変数はこのモジュールで初期化されます。
#==============================================================================

module DataManager
  #--------------------------------------------------------------------------
  # ○ エイリアス用特異メソッド
  #--------------------------------------------------------------------------
  class << self
    alias :a1_common_create_game_objects :create_game_objects
  end
  #--------------------------------------------------------------------------
  # ☆ 各種ゲームオブジェクトの作成
  #--------------------------------------------------------------------------
  def self.create_game_objects
    $a1_common ||= A1_System::CommonModule.new
    a1_common_create_game_objects
  end
end
#==============================================================================
# ■ Scene_Base
#------------------------------------------------------------------------------
#  ゲーム中の全てのシーンのスーパークラスです。
#==============================================================================

class Scene_Base
  #--------------------------------------------------------------------------
  # ☆ フレーム更新(基本)
  #--------------------------------------------------------------------------
  alias a1_common_sb_update_basic update_basic
  def update_basic
    a1_common_sb_update_basic
    $a1_common.update
  end
  #--------------------------------------------------------------------------
  # ○ 指定のウィンドウが開いている間ウェイト
  #--------------------------------------------------------------------------
  def wait_for_window_open(window)
    update_basic until window.openness == 0
  end
end
#==============================================================================
# ■ Window_Base
#------------------------------------------------------------------------------
#  ゲーム中の全てのウィンドウのスーパークラスです。
#==============================================================================

class Window_Base < Window
  #--------------------------------------------------------------------------
  # ★ 制御文字の事前変換
  #    実際の描画を始める前に、原則として文字列に変わるものだけを置き換える。
  #    文字「\」はエスケープ文字(\e)に変換。
  #--------------------------------------------------------------------------
  def convert_escape_characters(text)
    return $a1_common.convert_escape_characters(text)
  end
end
#==============================================================================
# ◆ RGSS2用処理
#==============================================================================
elsif rgss_version == 2
#==============================================================================
# ■ Window
#==============================================================================

class Window
  #--------------------------------------------------------------------------
  # ○ ウィンドウが開いている?
  #--------------------------------------------------------------------------
  def open?
    return self.openness == 255
  end
  #--------------------------------------------------------------------------
  # ○ ウィンドウが閉じている?
  #--------------------------------------------------------------------------
  def close?
    return self.openness == 0
  end
end
#==============================================================================
# ■ Cache
#------------------------------------------------------------------------------
#  各種グラフィックを読み込み、Bitmap オブジェクトを作成、保持するモジュール
# です。読み込みの高速化とメモリ節約のため、作成した Bitmap オブジェクトを内部
# のハッシュに保存し、同じビットマップが再度要求されたときに既存のオブジェクト
# を返すようになっています。
#==============================================================================

module Cache
  #--------------------------------------------------------------------------
  # ○ キャッシュ存在チェック
  #--------------------------------------------------------------------------
  def self.include?(key)
    @cache[key] && !@cache[key].disposed?
  end
end
#==============================================================================
# ■ Game_Interpreter
#------------------------------------------------------------------------------
#  イベントコマンドを実行するインタプリタです。このクラスは Game_Map クラス、
# Game_Troop クラス、Game_Event クラスの内部で使用されます。
#==============================================================================

class Game_Interpreter
  #--------------------------------------------------------------------------
  # ○ 注釈
  #--------------------------------------------------------------------------
  def command_108
    @comments = [@params[0]]
    while next_event_code == 408
      @index += 1
      @comments.push(@list[@index].parameters[0])
    end
  end
  #--------------------------------------------------------------------------
  # ★ イベントコマンドの実行
  #--------------------------------------------------------------------------
  def execute_command
    return rgss3_execute_command unless @index >= @list.size-1
    command_end
    return true
  end
  #--------------------------------------------------------------------------
  # ○ RGSS3風「イベントコマンドの実行」
  #--------------------------------------------------------------------------
  def rgss3_execute_command
    command = @list[@index]
    @params = command.parameters
    @indent = command.indent
    method_name = "command_#{command.code}"
    send(method_name) if respond_to?(method_name)
  end
  #--------------------------------------------------------------------------
  # ○ 次のイベントコマンドのコードを取得
  #--------------------------------------------------------------------------
  def next_event_code
    @list[@index + 1].code
  end
end
#==============================================================================
# ■ Game_Map
#------------------------------------------------------------------------------
#  マップを扱うクラスです。スクロールや通行可能判定などの機能を持っています。
# このクラスのインスタンスは $game_map で参照されます。
#==============================================================================

class Game_Map
  #--------------------------------------------------------------------------
  # ○ マップチップを調べるか判定する
  #--------------------------------------------------------------------------
  def search_map_chip?
    return $data_map_infos[@map_id].name =~ /\[サーチ\]/
  end
  #--------------------------------------------------------------------------
  # ○ 指定座標に存在するタイル扱いイベント(すり抜け以外)の配列取得
  #--------------------------------------------------------------------------
  def tile_events_xy(x, y)
    @tile_events.select {|event| event.pos_nt?(x, y) }
  end
  #--------------------------------------------------------------------------
  # ○ タイル扱いイベントの配列をリフレッシュ
  #--------------------------------------------------------------------------
  def refresh_tile_events
    @tile_events = @events.values.select {|event| event.tile? }
  end
end
#==============================================================================
# ■ Game_Character
#------------------------------------------------------------------------------
#  キャラクターを扱うクラスです。このクラスは Game_Player クラスと Game_Event
# クラスのスーパークラスとして使用されます。
#==============================================================================

class Game_Character
  #--------------------------------------------------------------------------
  # ○ タイル判定
  #--------------------------------------------------------------------------
  def tile?
    @tile_id > 0 && @priority_type == 0
  end
end
#==============================================================================
# ■ Scene_Title
#------------------------------------------------------------------------------
#  タイトル画面の処理を行うクラスです。
#==============================================================================

class Scene_Title < Scene_Base
  #--------------------------------------------------------------------------
  # ☆ データベースのロード
  #--------------------------------------------------------------------------
  alias a1_common_st_load_database load_database
  def load_database
    a1_common_st_load_database
    $data_map_infos = load_data("Data/MapInfos.rvdata")
  end
  #--------------------------------------------------------------------------
  # ☆ 各種ゲームオブジェクトの作成
  #--------------------------------------------------------------------------
  alias a1_common_st_create_game_objects create_game_objects
  def create_game_objects
    $a1_common ||= A1_System::CommonModule.new
    a1_common_st_create_game_objects
  end
end
#==============================================================================
# ◆ RGSS用処理
#==============================================================================
elsif rgss_version == 1
end
#==============================================================================
# ■ Cache
#------------------------------------------------------------------------------
#  各種グラフィックを読み込み、Bitmap オブジェクトを作成、保持するモジュール
# です。読み込みの高速化とメモリ節約のため、作成した Bitmap オブジェクトを内部
# のハッシュに保存し、同じビットマップが再度要求されたときに既存のオブジェクト
# を返すようになっています。
#==============================================================================

module Cache
  #--------------------------------------------------------------------------
  # ○ 拡大縮小したビットマップのロード
  #--------------------------------------------------------------------------
  def self.load_resize_bitmap(load_path, key, resize = nil)
    @cache ||= {}
    key = load_path if key == nil
    return @cache[key] if include?(key)
   
    @cache[key] = Bitmap.new(load_path)
    return @cache[key] if resize == nil
    return @cache[key] if @cache[key].width == resize[0] and @cache[key].height == resize[1]
   
    info = calc_size(resize, key)
    return resize_bitmap(@cache[key], info[0], info[1], key)
  end
  #--------------------------------------------------------------------------
  # ○ 拡大縮小した色相変化済みビットマップを作成/取得
  #--------------------------------------------------------------------------
  def self.load_resize_hue_changed_bitmap(load_path, path, hue, resize)
    key = [path, hue]
    return @cache[key] if include?(key)
   
    @cache[key] = load_resize_bitmap(load_path, path, resize).clone
    @cache[key].hue_change(hue)
    return @cache[key]
  end
  #--------------------------------------------------------------------------
  # ○ リサイズするサイズを取得
  #--------------------------------------------------------------------------
  def self.calc_size(resize, key)
    width  = resize[0]
    width  = @cache[key].width * width.abs if width < 0
    height = resize[1]
    height = @cache[key].height * height.abs if height < 0
    height = Integer(@cache[key].height * (width.to_f / @cache[key].width.to_f)) if height == 0
    return [width, height]
  end
  #--------------------------------------------------------------------------
  # ○ ビットマップの拡大縮小
  #--------------------------------------------------------------------------
  def self.resize_bitmap(bitmap, width, height, key)
    resize = Bitmap.new(width, height)
    resize.stretch_blt(resize.rect, bitmap, bitmap.rect)
    @cache[key] = resize
    return resize
  end
  #--------------------------------------------------------------------------
  # ○ テキストビットマップの取得
  #--------------------------------------------------------------------------
  def self.text_picture(text, font)
    load_text_bitmap(text, font)
  end
  #--------------------------------------------------------------------------
  # ○ フォントのキーを作成
  #--------------------------------------------------------------------------
  def self.make_font_key(text, font)
    [text, font.name, font.size, font.bold, font.italic, font.outline, font.shadow, font.color.to_s, font.out_color.to_s]
  end
  #--------------------------------------------------------------------------
  # ○ テキストビットマップの作成
  #--------------------------------------------------------------------------
  def self.load_text_bitmap(text, font)
    @cache ||= {}
    key = make_font_key(text, font)
    return @cache[key] if include?(key)
   
    # 計算用ダミービットマップ
    bitmap = Cache.system("")
    bitmap.font = font
    tw = bitmap.text_size(text).width + 8
   
    # ビットマップ作成
    bitmap = Bitmap.new(tw, bitmap.font.size + 4)
    bitmap.font = font
    bitmap.draw_text(0, 0, bitmap.width, bitmap.height, text, 1)
   
    @cache[key] = bitmap
    return @cache[key]
  end
end
#==============================================================================
# ■ Game_Interpreter
#------------------------------------------------------------------------------
#  イベントコマンドを実行するインタプリタです。このクラスは Game_Map クラス、
# Game_Troop クラス、Game_Event クラスの内部で使用されます。
#==============================================================================

class Game_Interpreter
  #--------------------------------------------------------------------------
  # ○ 注釈
  #--------------------------------------------------------------------------
  alias a1_common_command_108 command_108
  def command_108
    a1_common_command_108
    proc_comment(@comments)
  end
  #--------------------------------------------------------------------------
  # ○ 注釈の処理
  #--------------------------------------------------------------------------
  def proc_comment(comments)
    param = ""
    comments.each {|comment| param += comment }
    params = param.sub(/^(\S+)/, "")
    command = $1
    comment_parameters = $a1_common.split_array(params) if params
    proc_comment_command(command, comment_parameters)
  end
  #--------------------------------------------------------------------------
  # ○ 注釈の実行
  #--------------------------------------------------------------------------
  def proc_comment_command(command, params)
    cmd_108 = $a1_common.cmd_108[command]
    method(cmd_108).call(params) if cmd_108 != nil
  end
  #--------------------------------------------------------------------------
  # ○ 前のイベントコマンドを取得
  #--------------------------------------------------------------------------
  def prev_event
    @list[@index - 1]
  end
end
#==============================================================================
# ■ Game_Map
#------------------------------------------------------------------------------
#  マップを扱うクラスです。スクロールや通行可能判定などの機能を持っています。
# このクラスのインスタンスは $game_map で参照されます。
#==============================================================================

class Game_Map
  #--------------------------------------------------------------------------
  # ○ 全マップチップを調べる
  #--------------------------------------------------------------------------
  def map_chip_search
    tileset.init_ex_flags
    (0...@map.data.xsize).each {|x| map_chip_search_y(x) }
  end
  #--------------------------------------------------------------------------
  # ○ x座標にあるy座標のマップチップを調べる
  #--------------------------------------------------------------------------
  def map_chip_search_y(x)
    (0...@map.data.ysize).each {|y| map_pos_proc(x, y); map_chip_search_z(x, y) }
  end
  #--------------------------------------------------------------------------
  # ○ x,y座標にあるz座標のマップチップを調べる
  #--------------------------------------------------------------------------
  def map_chip_search_z(x, y)
    (0...@map.data.zsize).each {|z| map_chip_proc(x, y, z) }
    tile_events_xy(x, y).collect {|ev| tile_event_proc(ev.tile_id) }
  end
  #--------------------------------------------------------------------------
  # ○ 座標に対して処理を行う
  #--------------------------------------------------------------------------
  def map_pos_proc(x, y)
  end
  #--------------------------------------------------------------------------
  # ○ マップチップに対して処理を行う
  #--------------------------------------------------------------------------
  def map_chip_proc(x, y, z)
  end
  #--------------------------------------------------------------------------
  # ○ タイルのイベントに対して処理を行う
  #--------------------------------------------------------------------------
  def tile_event_proc(tile_id)
  end
end
#==============================================================================
# ■ Window_Base
#------------------------------------------------------------------------------
#  ゲーム中の全てのウィンドウのスーパークラスです。
#==============================================================================

class Window_Base < Window
  #--------------------------------------------------------------------------
  # ○ 入力を受け付けるか?
  #--------------------------------------------------------------------------
  def can_input?
    @can_input
  end
  #--------------------------------------------------------------------------
  # ○ 入力受け付け設定
  #--------------------------------------------------------------------------
  def can_input=(flag)
    @can_input = flag
  end
end
#==============================================================================
# ■ Bitmap
#==============================================================================

class Bitmap
  #--------------------------------------------------------------------------
  # ○ 文字縁取り描画
  #--------------------------------------------------------------------------
  def draw_text_f(x, y, width, height, str, align = 0, color = Color.new(64,32,128))
    shadow = self.font.shadow
    b_color = self.font.color.dup
    font.shadow = false
    font.color = color
    draw_text(x + 1, y, width, height, str, align)
    draw_text(x - 1, y, width, height, str, align)
    draw_text(x, y + 1, width, height, str, align)
    draw_text(x, y - 1, width, height, str, align)
    font.color = b_color
    draw_text(x, y, width, height, str, align)
    font.shadow = shadow
  end
  #--------------------------------------------------------------------------
  # ○ 文字縁取り描画の矩形を取得
  #--------------------------------------------------------------------------
  def draw_text_f_rect(r, str, align = 0, color = Color.new(64,32,128))
    draw_text_f(r.x, r.y, r.width, r.height, str, align = 0, color)
  end
end[/pre]

A1バトル共通スクリプト
[pre lang="ruby"]# ===========================================================================
# ◆ A1 Scripts ◆
#    A1バトル共通スクリプト(RGSS3)
#
# バージョン   : 1.23 (2012/01/27)
# 作者         : A1
# URL     : http://a1tktk.web.fc2.com/
# ---------------------------------------------------------------------------
# 更新履歴   :2012/01/18 Ver1.00 リリース
#                2012/01/21 Ver1.10 装備拡張対応
#                2012/01/21 Ver1.10 メンバー加入時の不具合を修正
#                2012/01/21 Ver1.10 メンバー加入時に既にパーティに居るさい何もしないように修正
#                2012/01/24 Ver1.20 スキル拡張対応
#                2012/01/24 Ver1.21 Window_BattleActorの不具合を修正
#                2012/01/26 Ver1.22 Window_BattleSkillの不具合を修正
#                2012/01/27 Ver1.23 戦闘行動がない際の不具合を修正
# ---------------------------------------------------------------------------
# 設置場所      
#  A1共通スクリプトより下
#    一部再定義メソッドがあるため、なるべく上の方
#
# 必要スクリプト
#    A1共通スクリプトVer4.30以上
#==============================================================================
$imported = {} if $imported == nil
if $imported["A1_Common_Script"]
$imported["A1_BattleCommonScript"] = true
old_common_script("A1バトル共通スクリプト", "4.30") if common_version < 4.30
#==============================================================================
# ■ Window_Base
#------------------------------------------------------------------------------
#  ゲーム中の全てのウィンドウのスーパークラスです。
#==============================================================================

class Window_Base < Window
  #--------------------------------------------------------------------------
  # ○ メソッドの定義
  #--------------------------------------------------------------------------
  def define_method(method, symbol)
    @method ||= {}
    @method[symbol] = method
  end
  #--------------------------------------------------------------------------
  # ○ メソッドのコール
  #--------------------------------------------------------------------------
  def call_method(symbol, *args)
    @method ||= {}
    @method[symbol].call(*args) if @method[symbol]
  end
  #--------------------------------------------------------------------------
  # ○ 顔グラフィックの描画(解放なし)
  #--------------------------------------------------------------------------
  def draw_face_no_dispose(face_name, face_index, x, y, enabled = true)
    bitmap = Cache.face(face_name)
    rect = Rect.new(face_index % 4 * 96, face_index / 4 * 96, 96, 96)
    contents.blt(x, y, bitmap, rect, enabled ? 255 : translucent_alpha)
  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
#==============================================================================
# ■ Window_Help
#------------------------------------------------------------------------------
#  スキルやアイテムの説明、アクターのステータスなどを表示するウィンドウです。
#==============================================================================

class Window_Help < Window_Base
  #--------------------------------------------------------------------------
  # ○ センターにテキストを描画
  #--------------------------------------------------------------------------
  def draw_center_text(text)
    contents.clear
    draw_text(0, 0, contents.width, line_height, text, 1)
  end
end
#==============================================================================
# ■ Window_BattleActor
#------------------------------------------------------------------------------
#  バトル画面で、行動対象のアクターを選択するウィンドウです。
#==============================================================================

class Window_BattleActor < Window_BattleStatus
  #--------------------------------------------------------------------------
  # ★ ウィンドウの表示
  #--------------------------------------------------------------------------
  def show
    setup_remain if @info_viewport
    self.visible = true
    refresh
    open
    self
  end
  #--------------------------------------------------------------------------
  # ★ ウィンドウの非表示
  #--------------------------------------------------------------------------
  def hide
    close
    @info_viewport.rect.width = Graphics.width if @info_viewport
    call_method(:select_actor_end)
  end
  #--------------------------------------------------------------------------
  # ○ フレーム更新
  #--------------------------------------------------------------------------
  def update
    return update_basic unless self.visible
    super
    self.visible = false if self.openness == 0
  end
  #--------------------------------------------------------------------------
  # ○ フレーム更新(基本)
  #--------------------------------------------------------------------------
  def update_basic
    process_cursor_move
    process_handling
  end
  #--------------------------------------------------------------------------
  # ○ 項目の選択
  #--------------------------------------------------------------------------
  def select(index)
    super
    call_method(:select_actor, index)
  end
  #--------------------------------------------------------------------------
  # ○ ウィンドウの調整
  #--------------------------------------------------------------------------
  def setup_remain
    width_remain = Graphics.width - width
    self.x = width_remain
    @info_viewport.rect.width = width_remain
    select(0)
  end
end
#==============================================================================
# ■ Window_BattleEnemy
#------------------------------------------------------------------------------
#  バトル画面で、行動対象の敵キャラを選択するウィンドウです。
#==============================================================================

class Window_BattleEnemy < Window_Selectable
  #--------------------------------------------------------------------------
  # ★ ウィンドウの表示
  #--------------------------------------------------------------------------
  def show
    setup_remain if @info_viewport
    self.visible = true
    open
    self
  end
  #--------------------------------------------------------------------------
  # ★ ウィンドウの非表示
  #--------------------------------------------------------------------------
  def hide
    close
    @info_viewport.rect.width = Graphics.width if @info_viewport
    call_method(:select_enemy_end)
  end
  #--------------------------------------------------------------------------
  # ○ フレーム更新
  #--------------------------------------------------------------------------
  def update
    return update_basic unless self.visible
    super
    self.visible = false if self.openness == 0
  end
  #--------------------------------------------------------------------------
  # ○ フレーム更新(基本)
  #--------------------------------------------------------------------------
  def update_basic
    process_cursor_move
    process_handling
  end
  #--------------------------------------------------------------------------
  # ○ 項目の選択
  #--------------------------------------------------------------------------
  def select(index)
    super
    call_method(:select_enemy, index)
  end
  #--------------------------------------------------------------------------
  # ○ ウィンドウの調整
  #--------------------------------------------------------------------------
  def setup_remain
    width_remain = Graphics.width - width
    self.x = width_remain
    @info_viewport.rect.width = width_remain
    select(0)
  end
end
#==============================================================================
# ■ Window_BattleSkill
#------------------------------------------------------------------------------
#  バトル画面で、使用するスキルを選択するウィンドウです。
#==============================================================================

class Window_BattleSkill < Window_SkillList
  #--------------------------------------------------------------------------
  # ☆ オブジェクト初期化
  #     info_viewport : 情報表示用ビューポート
  #--------------------------------------------------------------------------
  alias a1_psw_wbs_initialize initialize
  def initialize(help_window, info_viewport)
    a1_psw_wbs_initialize(help_window, info_viewport)
    self.openness = 0
    self.visible  = true
    @help_window.openness = 0
    @help_window.visible = true
  end
  #--------------------------------------------------------------------------
  # ○ 高さを変える
  #--------------------------------------------------------------------------
  def resize_height(base_y)
    self.height = base_y - self.y
    create_contents
  end
  #--------------------------------------------------------------------------
  # ★ ウィンドウの表示
  #--------------------------------------------------------------------------
  def show
    self.visible = true
    @help_window.visible = true
    select_last
    open
    @help_window.open
    self
  end
  #--------------------------------------------------------------------------
  # ★ ウィンドウの非表示
  #--------------------------------------------------------------------------
  def hide
    close
    @help_window.close
    @info_viewport.rect.width = Graphics.width if @info_viewport
    call_method(:skill_item_window_hide)
  end
  #--------------------------------------------------------------------------
  # ○ オープン
  #--------------------------------------------------------------------------
  def open
    self.visible = true
    call_method(:skill_item_window_show)
    super
  end
  #--------------------------------------------------------------------------
  # ○ アクティブ化
  #--------------------------------------------------------------------------
  def activate
    open
    @help_window.open
    super
  end
end
#==============================================================================
# ■ Window_BattleItem
#------------------------------------------------------------------------------
#  バトル画面で、使用するアイテムを選択するウィンドウです。
#==============================================================================

class Window_BattleItem < Window_ItemList
  #--------------------------------------------------------------------------
  # ☆ オブジェクト初期化
  #     info_viewport : 情報表示用ビューポート
  #--------------------------------------------------------------------------
  alias a1_battle_common_wbi_initialize initialize
  def initialize(help_window, info_viewport)
    a1_battle_common_wbi_initialize(help_window, info_viewport)
    self.openness = 0
    self.visible  = true
    @help_window.openness = 0
    @help_window.visible = true
  end
  #--------------------------------------------------------------------------
  # ○ 高さを変える
  #--------------------------------------------------------------------------
  def resize_height(base_y)
    self.height = base_y - self.y
    create_contents
  end
  #--------------------------------------------------------------------------
  # ★ ウィンドウの表示
  #--------------------------------------------------------------------------
  def show
    self.visible = true
    @help_window.visible = true
    select_last
    open
    @help_window.open
    self
  end
  #--------------------------------------------------------------------------
  # ★ ウィンドウの非表示
  #--------------------------------------------------------------------------
  def hide
    close
    @help_window.close
    call_method(:skill_item_window_hide)
  end
  #--------------------------------------------------------------------------
  # ○ オープン
  #--------------------------------------------------------------------------
  def open
    self.visible = true
    call_method(:skill_item_window_show)
    super
  end
  #--------------------------------------------------------------------------
  # ○ アクティブ化
  #--------------------------------------------------------------------------
  def activate
    open
    @help_window.open
    super
  end
  #--------------------------------------------------------------------------
  # ○ フレーム更新
  #--------------------------------------------------------------------------
  def update
    return unless self.visible
    super
    self.visible = false if self.openness == 0
  end
end
#==============================================================================
# ■ Window_ActorCommand
#------------------------------------------------------------------------------
#  バトル画面で、アクターの行動を選択するウィンドウです。
#==============================================================================

class Window_ActorCommand < Window_Command
  #--------------------------------------------------------------------------
  # ☆ セットアップ
  #--------------------------------------------------------------------------
  alias a1_battle_common_wac_setup setup
  def setup(actor)
    call_method(:actor_command_setup, actor)
    a1_battle_common_wac_setup(actor)
  end
  #--------------------------------------------------------------------------
  # ○ ウィンドウのアクティブ化
  #--------------------------------------------------------------------------
  def activate
    open
    super
  end
  #--------------------------------------------------------------------------
  # ○ オープン
  #--------------------------------------------------------------------------
  def open
    call_method(:actor_command_open)
    super
  end
  #--------------------------------------------------------------------------
  # ○ クローズ
  #--------------------------------------------------------------------------
  def close
    call_method(:actor_command_close)
    super
  end
end
#==============================================================================
# ■ Window_BattleStatus
#------------------------------------------------------------------------------
#  バトル画面で、パーティメンバーのステータスを表示するウィンドウです。
#==============================================================================

class Window_BattleStatus < Window_Selectable
  #--------------------------------------------------------------------------
  # ☆ リフレッシュ
  #--------------------------------------------------------------------------
  alias a1_battle_common_wbs_refresh refresh
  def refresh
    call_method(:refresh_statsu_window)
    return unless self.visible
    a1_battle_common_wbs_refresh
  end
  #--------------------------------------------------------------------------
  # ○ ウィンドウを開く
  #--------------------------------------------------------------------------
  def open
    super
    call_method(:open_status_window)
  end
  #--------------------------------------------------------------------------
  # ○ ウィンドウを閉じる
  #--------------------------------------------------------------------------
  def close
    super
    call_method(:close_status_window)
  end
  #--------------------------------------------------------------------------
  # ○ 項目の選択
  #--------------------------------------------------------------------------
  def select(index)
    super
    call_method(:select_status_window, index)
  end
  #--------------------------------------------------------------------------
  # ○ フレーム更新
  #--------------------------------------------------------------------------
  def update
    call_method(:update_status_window)
    return unless self.visible
    super
  end
  #--------------------------------------------------------------------------
  # ○ 解放
  #--------------------------------------------------------------------------
  def dispose
    super
    call_method(:dispose_status_window)
  end
end
#==============================================================================
# ■ Window_PersonalStatus
#==============================================================================

class Window_PersonalStatus < Window_Base
  #--------------------------------------------------------------------------
  # ○ オブジェクト初期化
  #--------------------------------------------------------------------------
  def initialize(x, y, opacity = 0)
    super(x, y, Graphics.width / 2, 120)
    self.opacity  = opacity
    self.openness = 0
    @actor = nil
  end
  #--------------------------------------------------------------------------
  # ○ アクターの設定
  #--------------------------------------------------------------------------
  def actor=(actor)
    @actor = actor
    refresh
  end
  #--------------------------------------------------------------------------
  # ○ リフレッシュ
  #--------------------------------------------------------------------------
  def refresh
    contents.clear
    draw_face(@actor.face_name, @actor.face_index, 0, 0)
    draw_text(116, line_height * 0, contents.width, line_height, @actor.name)
    draw_actor_level(@actor, 116, 0 + line_height * 1)
    draw_actor_icons(@actor, 180, 0 + line_height * 1)
    draw_actor_hp(@actor, 116, 0 + line_height * 2, 128)
    draw_actor_mp(@actor, 116, 0 + line_height * 3, 60)
    draw_actor_tp(@actor, 184, 0 + line_height * 3, 60) if $data_system.opt_display_tp
  end
  #--------------------------------------------------------------------------
  # ○ フレーム更新
  #--------------------------------------------------------------------------
  def update
    return unless self.visible
    super
    self.visible = false if self.openness == 0
  end
  #--------------------------------------------------------------------------
  # ○ オープン
  #--------------------------------------------------------------------------
  def open
    self.visible = true
    super
  end
  #--------------------------------------------------------------------------
  # ○ 顔グラフィックの描画
  #--------------------------------------------------------------------------
  def draw_face(face_name, face_index, x, y, enabled = true)
    draw_face_no_dispose(face_name, face_index, x, y, enabled)
  end
end
#==============================================================================
# ■ RPG::Enemy
#==============================================================================

class RPG::Enemy < RPG::BaseItem
  #--------------------------------------------------------------------------
  # ○ 初期装備
  #--------------------------------------------------------------------------
  def equips
    @equips ||= [0,0,0,0,0]
    @equips[0] ||= $a1_common.note_data_one(self.note, "エネミー武器", 0)
    return @equips
  end
end
#==============================================================================
# ■ Game_Enemy
#------------------------------------------------------------------------------
#  敵キャラを扱うクラスです。このクラスは Game_Troop クラス($game_troop)の
# 内部で使用されます。
#==============================================================================

class Game_Enemy < Game_Battler
  #--------------------------------------------------------------------------
  # ☆ オブジェクト初期化
  #--------------------------------------------------------------------------
  alias a1_battle_common_ge_initialize initialize
  def initialize(index, enemy_id)
    @equips = []
    a1_battle_common_ge_initialize(index, enemy_id)
    init_equips(enemy.equips)
  end
end
#==============================================================================
# ■ Game_Actor
#------------------------------------------------------------------------------
#  アクターを扱うクラスです。このクラスは Game_Actors クラス($game_actors)
# の内部で使用され、Game_Party クラス($game_party)からも参照されます。
#==============================================================================

class Game_Actor < Game_Battler
  #--------------------------------------------------------------------------
  # ★ 装備品の初期化
  #     equips : 初期装備の配列
  #--------------------------------------------------------------------------
  def init_equips(equips)
    super
  end
  #--------------------------------------------------------------------------
  # ★ 装備タイプからスロット ID に変換(空きを優先)
  #--------------------------------------------------------------------------
  def empty_slot(etype_id)
    super
  end
  #--------------------------------------------------------------------------
  # ★ 装備タイプからスロット ID のリストに変換
  #--------------------------------------------------------------------------
  def slot_list(etype_id)
    super
  end
  #--------------------------------------------------------------------------
  # ★ エディタで設定されたインデックスを装備タイプ ID に変換
  #--------------------------------------------------------------------------
  def index_to_etype_id(index)
    super
  end
  #--------------------------------------------------------------------------
  # ★ 装備スロットの配列を取得
  #--------------------------------------------------------------------------
  def equip_slots
    super
  end
  #--------------------------------------------------------------------------
  # ★ 装備品オブジェクトの配列取得
  #--------------------------------------------------------------------------
  def equips
    super
  end
  #--------------------------------------------------------------------------
  # ★ 武器オブジェクトの配列取得
  #--------------------------------------------------------------------------
  def weapons
    super
  end
  #--------------------------------------------------------------------------
  # ★ 通常能力値の加算値取得
  #--------------------------------------------------------------------------
  def param_plus(param_id)
    super
  end
  #--------------------------------------------------------------------------
  # ☆ 通常攻撃 アニメーション ID の取得
  #--------------------------------------------------------------------------
  alias a1_battle_common_ga_atk_animation_id1 atk_animation_id1
  def atk_animation_id1
    return a1_battle_common_ga_atk_animation_id1 if !@current_weapon || @current_weapon.is_a?(Array)
    @current_weapon.animation_id
  end
  #--------------------------------------------------------------------------
  # ☆ 通常攻撃 アニメーション ID の取得(二刀流:武器2)
  #--------------------------------------------------------------------------
  alias a1_battle_common_ga_atk_animation_id2 atk_animation_id2
  def atk_animation_id2
    return a1_battle_common_ga_atk_animation_id2 if !@current_weapon || @current_weapon.is_a?(Array)
    @current_weapon.animation_id
  end
  #--------------------------------------------------------------------------
  # ○ 装備タイプ名を取得
  #--------------------------------------------------------------------------
  def e_type_name(item)
    return $data_system.weapon_types[item.wtype_id] if item.is_a?(RPG::Weapon)
    return $data_system.armor_types[item.atype_id] if item.is_a?(RPG::Armor)
  end
end
#==============================================================================
# ■ Game_BattlerBase
#------------------------------------------------------------------------------
#  バトラーを扱う基本のクラスです。主に能力値計算のメソッドを含んでいます。こ
# のクラスは Game_Battler クラスのスーパークラスとして使用されます。
#==============================================================================

class Game_BattlerBase
  #--------------------------------------------------------------------------
  # ○ 二刀流?
  #--------------------------------------------------------------------------
  def two_sword_style?
    weapons[0] && weapons[1]
  end
  #--------------------------------------------------------------------------
  # ○ バトラーオブジェクト取得
  #--------------------------------------------------------------------------
  def battler
    return actor if self.actor?
    return enemy
  end
end
#==============================================================================
# ■ Game_Battler
#------------------------------------------------------------------------------
#  スプライトや行動に関するメソッドを追加したバトラーのクラスです。このクラス
# は Game_Actor クラスと Game_Enemy クラスのスーパークラスとして使用されます。
#==============================================================================

class Game_Battler < Game_BattlerBase
  #--------------------------------------------------------------------------
  # ○ 公開インスタンス変数
  #--------------------------------------------------------------------------
  attr_accessor :current_weapon
  attr_accessor :current_main
  #--------------------------------------------------------------------------
  # ○ 装備品の初期化
  #     equips : 初期装備の配列
  #--------------------------------------------------------------------------
  def init_equips(equips)
    @equips = Array.new(equip_slots.size) { Game_BaseItem.new }
    equips.each_with_index do |item_id, i|
      etype_id = index_to_etype_id(i)
      slot_id = empty_slot(etype_id)
      @equips[slot_id].set_equip(etype_id == 0, item_id) if slot_id
    end
    refresh
  end
  #--------------------------------------------------------------------------
  # ○ 装備タイプからスロット ID に変換(空きを優先)
  #--------------------------------------------------------------------------
  def empty_slot(etype_id)
    list = slot_list(etype_id)
    list.find {|i| @equips.is_nil? } || list[0]
  end
  #--------------------------------------------------------------------------
  # ○ 装備タイプからスロット ID のリストに変換
  #--------------------------------------------------------------------------
  def slot_list(etype_id)
    result = []
    equip_slots.each_with_index {|e, i| result.push(i) if e == etype_id }
    result
  end
  #--------------------------------------------------------------------------
  # ○ エディタで設定されたインデックスを装備タイプ ID に変換
  #--------------------------------------------------------------------------
  def index_to_etype_id(index)
    index == 1 && dual_wield? ? 0 : index
  end
  #--------------------------------------------------------------------------
  # ○ 装備スロットの配列を取得
  #--------------------------------------------------------------------------
  def equip_slots
    return [0,0,2,3,4] if dual_wield?       # 二刀流
    return [0,1,2,3,4]                      # 通常
  end
  #--------------------------------------------------------------------------
  # ○ 装備品オブジェクトの配列取得
  #--------------------------------------------------------------------------
  def equips
    @equips.collect {|item| item.object }
  end
  #--------------------------------------------------------------------------
  # ○ 武器オブジェクトの配列取得
  #--------------------------------------------------------------------------
  def weapons
    @equips.select {|item| item.is_weapon? }.collect {|item| item.object }
  end
  #--------------------------------------------------------------------------
  # ○ 通常能力値の加算値取得
  #--------------------------------------------------------------------------
  def param_plus(param_id)
    equips.compact.inject(super) {|r, item| r += item.params[param_id] + ex_item_params(item, param_id) }
  end
  #--------------------------------------------------------------------------
  # ○ アイテムにかける追加要素
  #--------------------------------------------------------------------------
  def ex_item_params(item, param_id)
    return 0
  end
  #--------------------------------------------------------------------------
  # ○ スキルを取得
  #--------------------------------------------------------------------------
  def skill(skill_id)
    $data_skills[skill_id]
  end
end
#==============================================================================
# ■ Game_Party
#------------------------------------------------------------------------------
#  パーティを扱うクラスです。所持金やアイテムなどの情報が含まれます。このクラ
# スのインスタンスは $game_party で参照されます。
#==============================================================================

class Game_Party < Game_Unit
  #--------------------------------------------------------------------------
  # ☆ アクターを加える
  #--------------------------------------------------------------------------
  alias a1_battle_common_gp_add_actor add_actor
  def add_actor(actor_id)
    return a1_battle_common_gp_add_actor(actor_id) unless in_battle
    return if @actors.include?(actor_id)
    prev_add_actor(battle_members)
    insert_actor(actor_id)
    post_add_actor($game_actors[actor_id])
  end
  #--------------------------------------------------------------------------
  # ○ アクターを加える
  #--------------------------------------------------------------------------
  def insert_actor(actor_id)
    @new_index = @remove_member_index ? @remove_member_index[0] : @actors.size
    @actors.insert(@new_index, actor_id) unless @actors.include?(actor_id)
    $game_player.refresh
    $game_map.need_refresh = true
    return unless @remove_member_index
    @remove_member_index.delete_at(0)
    @remove_member_index = nil if @remove_member_index.empty?
  end
  #--------------------------------------------------------------------------
  # ○ アクターを加えたIndexを取得
  #--------------------------------------------------------------------------
  def new_index
    @new_index
  end
  #--------------------------------------------------------------------------
  # ○ アクターを加える前処理
  #--------------------------------------------------------------------------
  def prev_add_actor(members)
    BattleManager.call_method(:prev_add_battler, members)
  end
  #--------------------------------------------------------------------------
  # ○ アクターを加えた後処理
  #--------------------------------------------------------------------------
  def post_add_actor(member)
    BattleManager.call_method(:post_add_battler, member)
  end
  #--------------------------------------------------------------------------
  # ☆ アクターを外す
  #--------------------------------------------------------------------------
  alias a1_battle_common_gp_remove_actor remove_actor
  def remove_actor(actor_id)
    prev_remove_actor($game_actors[actor_id]) if in_battle
    a1_battle_common_gp_remove_actor(actor_id)
    post_remove_actor if in_battle
  end
  #--------------------------------------------------------------------------
  # ○ アクターを外す前処理
  #--------------------------------------------------------------------------
  def prev_remove_actor(member)
    @remove_member_index ||= []
    @remove_member_index.push(member.index)
    BattleManager.call_method(:prev_remove_battler, member)
  end
  #--------------------------------------------------------------------------
  # ○ アクターを外した後処理
  #--------------------------------------------------------------------------
  def post_remove_actor
    BattleManager.call_method(:post_remove_battler)
  end
end
#==============================================================================
# ■ BattleManager
#------------------------------------------------------------------------------
#  戦闘の進行を管理するモジュールです。
#==============================================================================

module BattleManager
  #--------------------------------------------------------------------------
  # ○ エイリアス用特異メソッド
  #--------------------------------------------------------------------------
  class << self
    alias :a1_battle_common_bm_turn_end :turn_end
    alias :a1_battle_common_bm_turn_start :turn_start
    alias :a1_battle_common_bm_battle_end :battle_end
  end
  #--------------------------------------------------------------------------
  # ☆ ターン開始
  #--------------------------------------------------------------------------
  def self.turn_start
    @turn_end_wait = 0
    a1_battle_common_bm_turn_start
  end
  #--------------------------------------------------------------------------
  # ☆ ターン終了
  #--------------------------------------------------------------------------
  def self.turn_end
    call_method(:wait, @turn_end_wait) if @turn_end_wait > 0
    @turn_end_wait = 0
    a1_battle_common_bm_turn_end
  end
  #--------------------------------------------------------------------------
  # ○ メソッドの設定
  #--------------------------------------------------------------------------
  def self.define_method(method, symbol)
    @method ||= {}
    @method[symbol] = method
  end
  #--------------------------------------------------------------------------
  # ○ メソッドのコール
  #--------------------------------------------------------------------------
  def self.call_method(symbol, *args)
    @method[symbol].call(*args) if @method[symbol]
  end
  #--------------------------------------------------------------------------
  # ○ ターン終了後ウェイト設定
  #--------------------------------------------------------------------------
  def self.turn_end_wait=(flame)
    @turn_end_wait = flame if @turn_end_wait < flame || flame == 0
  end
  #--------------------------------------------------------------------------
  # ☆ 戦闘終了
  #     result : 結果(0:勝利 1:逃走 2:敗北)
  #--------------------------------------------------------------------------
  def self.battle_end(result)
    call_method(:battle_end, result)
    a1_battle_common_bm_battle_end(result)
  end
end
#==============================================================================
# ■ Game_Action
#------------------------------------------------------------------------------
#  戦闘行動を扱うクラスです。このクラスは Game_Battler クラスの内部で使用され
# ます。
#==============================================================================

class Game_Action
  #--------------------------------------------------------------------------
  # ☆ ターゲットの配列作成
  #--------------------------------------------------------------------------
  alias a1_battle_common_gac_make_targets make_targets
  def make_targets
    @targets ||= pre_make_targets
    return @targets
  end
  #--------------------------------------------------------------------------
  # ○ ターゲットの配列先行作成
  #--------------------------------------------------------------------------
  def pre_make_targets
    @targets = a1_battle_common_gac_make_targets
  end
  #--------------------------------------------------------------------------
  # ○ ターゲットの配列を取得
  #--------------------------------------------------------------------------
  def targets
    @targets.compact
  end
  #--------------------------------------------------------------------------
  # ○ ターゲットの配列をクリア
  #--------------------------------------------------------------------------
  def clear_targets
    @targets = nil
  end
end
#==============================================================================
# ■ Scene_Battle
#------------------------------------------------------------------------------
#  バトル画面の処理を行うクラスです。
#==============================================================================

class Scene_Battle < Scene_Base
  #--------------------------------------------------------------------------
  # ☆ 開始処理
  #--------------------------------------------------------------------------
  alias a1_battle_common_sb_start start
  def start
    a1_battle_common_sb_start
    define_battle_manager_method
  end
  #--------------------------------------------------------------------------
  # ○ バトルマネージャメソッドの定義
  #--------------------------------------------------------------------------
  def define_battle_manager_method
    BattleManager.define_method(method(:wait), :wait)
    BattleManager.define_method(method(:post_add_battler),       :post_add_battler)
    BattleManager.define_method(method(:post_remove_battler),    :post_remove_battler)
    BattleManager.define_method(method(:prev_remove_battler),    :prev_remove_battler)
    BattleManager.define_method(method(:prev_add_battler),       :prev_add_battler)
    BattleManager.define_method(method(:process_victory),        :process_victory)
    BattleManager.define_method(method(:battle_end),             :battle_end)
  end
  #--------------------------------------------------------------------------
  # ☆ ステータスウィンドウの作成
  #--------------------------------------------------------------------------
  alias a1_battle_common_sb_create_status_window create_status_window
  def create_status_window
    a1_battle_common_sb_create_status_window
    post_create_status_window
    define_status_window_method
  end
  #--------------------------------------------------------------------------
  # ○ ステータスウィンドウ作成の後処理
  #--------------------------------------------------------------------------
  def post_create_status_window
  end
  #--------------------------------------------------------------------------
  # ○ ステータスウィンドウメソッドの定義
  #--------------------------------------------------------------------------
  def define_status_window_method
    @status_window.define_method(method(:refresh_statsu_window), :refresh_statsu_window)
    @status_window.define_method(method(:close_status_window),   :close_status_window)
    @status_window.define_method(method(:open_status_window),    :open_status_window)
    @status_window.define_method(method(:select_status_window),  :select_status_window)
    @status_window.define_method(method(:update_status_window),  :update_status_window)
    @status_window.define_method(method(:dispose_status_window), :dispose_status_window)
  end
  #--------------------------------------------------------------------------
  # ○ ステータスウィンドウがリフレッシュされた時の処理
  #--------------------------------------------------------------------------
  def refresh_statsu_window
  end
  #--------------------------------------------------------------------------
  # ○ ステータスウィンドウがクローズされた時の処理
  #--------------------------------------------------------------------------
  def close_status_window
  end
  #--------------------------------------------------------------------------
  # ○ ステータスウィンドウがオープンされた時の処理
  #--------------------------------------------------------------------------
  def open_status_window
  end
  #--------------------------------------------------------------------------
  # ○ ステータスウィンドウがセレクトされた時の処理
  #--------------------------------------------------------------------------
  def select_status_window(index)
  end
  #--------------------------------------------------------------------------
  # ○ ステータスウィンドウが更新された時の処理
  #--------------------------------------------------------------------------
  def update_status_window
  end
  #--------------------------------------------------------------------------
  # ○ ステータスウィンドウが解放された時の処理
  #--------------------------------------------------------------------------
  def dispose_status_window
  end
  #--------------------------------------------------------------------------
  # ☆ 情報表示ビューポートの作成
  #--------------------------------------------------------------------------
  alias a1_battle_common_sb_create_info_viewport create_info_viewport
  def create_info_viewport
    a1_battle_common_sb_create_info_viewport
    post_create_info_viewport
  end
  #--------------------------------------------------------------------------
  # ○ 情報表示ビューポート作成の後処理
  #--------------------------------------------------------------------------
  def post_create_info_viewport
  end
  #--------------------------------------------------------------------------
  # ☆ スキルウィンドウの作成
  #--------------------------------------------------------------------------
  alias a1_battle_common_sb_create_skill_window create_skill_window
  def create_skill_window
    a1_battle_common_sb_create_skill_window
    post_create_skill_window
    define_skill_window_method
  end
  #--------------------------------------------------------------------------
  # ○ スキルウィンドウ作成の後処理
  #--------------------------------------------------------------------------
  def post_create_skill_window
  end
  #--------------------------------------------------------------------------
  # ○ スキルウィンドウメソッドの定義
  #--------------------------------------------------------------------------
  def define_skill_window_method
    @skill_window.define_method(method(:skill_item_window_show), :skill_item_window_show)
    @skill_window.define_method(method(:skill_item_window_hide), :skill_item_window_hide)
  end
  #--------------------------------------------------------------------------
  # ☆ アイテムウィンドウの作成
  #--------------------------------------------------------------------------
  alias a1_battle_common_sb_create_item_window create_item_window
  def create_item_window
    a1_battle_common_sb_create_item_window
    post_create_item_window
    define_item_window_method
  end
  #--------------------------------------------------------------------------
  # ○ アイテムウィンドウ作成の後処理
  #--------------------------------------------------------------------------
  def post_create_item_window
  end
  #--------------------------------------------------------------------------
  # ○ アイテムウィンドウメソッドの定義
  #--------------------------------------------------------------------------
  def define_item_window_method
    @item_window.define_method(method(:skill_item_window_show), :skill_item_window_show)
    @item_window.define_method(method(:skill_item_window_hide), :skill_item_window_hide)
  end
  #--------------------------------------------------------------------------
  # ○ スキル/アイテムウィンドウが表示された時の処理
  #--------------------------------------------------------------------------
  def skill_item_window_show
  end
  #--------------------------------------------------------------------------
  # ○ スキル/アイテムウィンドウが非表示になった時の処理
  #--------------------------------------------------------------------------
  def skill_item_window_hide
  end
  #--------------------------------------------------------------------------
  # ☆ パーティコマンドウィンドウの作成
  #--------------------------------------------------------------------------
  alias a1_battle_common_sb_create_party_command_window create_party_command_window
  def create_party_command_window
    a1_battle_common_sb_create_party_command_window
    post_create_party_command_window
    define_party_command_window_method
    define_party_command_window_handle
  end
  #--------------------------------------------------------------------------
  # ○ パーティコマンドウィンドウ作成の後処理
  #--------------------------------------------------------------------------
  def post_create_party_command_window
  end
  #--------------------------------------------------------------------------
  # ○ パーティコマンドウィンドウメソッドの定義
  #--------------------------------------------------------------------------
  def define_party_command_window_method
  end
  #--------------------------------------------------------------------------
  # ○ パーティコマンドウィンドウハンドルの定義
  #--------------------------------------------------------------------------
  def define_party_command_window_handle
  end
  #--------------------------------------------------------------------------
  # ☆ アクターウィンドウの作成
  #--------------------------------------------------------------------------
  alias a1_battle_common_sb_create_actor_window create_actor_window
  def create_actor_window
    a1_battle_common_sb_create_actor_window
    post_create_actor_window
    define_actor_window_method
  end
  #--------------------------------------------------------------------------
  # ○ アクターウィンドウ作成の後処理
  #--------------------------------------------------------------------------
  def post_create_actor_window
  end
  #--------------------------------------------------------------------------
  # ○ アクターウィンドウメソッドの定義
  #--------------------------------------------------------------------------
  def define_actor_window_method
    @actor_window.define_method(method(:select_actor),     :select_actor)
    @actor_window.define_method(method(:select_actor_end), :select_actor_end)
  end
  #--------------------------------------------------------------------------
  # ○ アクターウィンドウをセレクトした時の処理
  #--------------------------------------------------------------------------
  def select_actor(index)
  end
  #--------------------------------------------------------------------------
  # ○ アクターウィンドウをセレクト終了した時の処理
  #--------------------------------------------------------------------------
  def select_actor_end
  end
  #--------------------------------------------------------------------------
  # ☆ 敵キャラウィンドウの作成
  #--------------------------------------------------------------------------
  alias a1_battle_common_sb_create_enemy_window create_enemy_window
  def create_enemy_window
    a1_battle_common_sb_create_enemy_window
    post_create_enemy_window
    define_enemy_window_method
  end
  #--------------------------------------------------------------------------
  # ○ 敵キャラウィンドウ作成の後処理
  #--------------------------------------------------------------------------
  def post_create_enemy_window
  end
  #--------------------------------------------------------------------------
  # ○ 敵キャラウィンドウメソッドの定義
  #--------------------------------------------------------------------------
  def define_enemy_window_method
    @enemy_window.define_method(method(:select_enemy),     :select_enemy)
    @enemy_window.define_method(method(:select_enemy_end) ,:select_enemy_end)
  end
  #--------------------------------------------------------------------------
  # ○ 敵キャラウィンドウをセレクトした時の処理
  #--------------------------------------------------------------------------
  def select_enemy(index)
  end
  #--------------------------------------------------------------------------
  # ○ 敵キャラウィンドウをセレクト終了した時の処理
  #--------------------------------------------------------------------------
  def select_enemy_end
  end
  #--------------------------------------------------------------------------
  # ☆ アクターコマンドウィンドウの作成
  #--------------------------------------------------------------------------
  alias a1_battle_common_sb_start_create_actor_command_window create_actor_command_window
  def create_actor_command_window
    a1_battle_common_sb_start_create_actor_command_window
    post_create_actor_command_window
    define_actor_command_handle
    define_actor_command_window
  end
  #--------------------------------------------------------------------------
  # ○ アクターコマンドウィンドウ作成の後処理
  #--------------------------------------------------------------------------
  def post_create_actor_command_window
  end
  #--------------------------------------------------------------------------
  # ○ アクターコマンドウィンドウメソッドの定義
  #--------------------------------------------------------------------------
  def define_actor_command_window
    @actor_command_window.define_method(method(:actor_command_open),  :actor_command_open)
    @actor_command_window.define_method(method(:actor_command_close), :actor_command_close)
    @actor_command_window.define_method(method(:actor_command_setup), :actor_command_setup)
  end
  #--------------------------------------------------------------------------
  # ○ アクターコマンドウィンドウハンドルの定義
  #--------------------------------------------------------------------------
  def define_actor_command_handle
  end
  #--------------------------------------------------------------------------
  # ○ アクターコマンドウィンドウがオープンした時の処理
  #--------------------------------------------------------------------------
  def actor_command_open
  end
  #--------------------------------------------------------------------------
  # ○ アクターコマンドウィンドウがクローズした時の処理
  #--------------------------------------------------------------------------
  def actor_command_close
  end
  #--------------------------------------------------------------------------
  # ○ アクターコマンドウィンドウのセットアップ時の処理
  #--------------------------------------------------------------------------
  def actor_command_setup(actor)
  end
  #--------------------------------------------------------------------------
  # ☆ パーティコマンド選択の開始
  #--------------------------------------------------------------------------
  alias a1_battle_common_sb_start_party_command_selection start_party_command_selection
  def start_party_command_selection
    prev_start_party_command_selection
    a1_battle_common_sb_start_party_command_selection
    post_start_party_command_selection
  end
  #--------------------------------------------------------------------------
  # ○ パーティコマンド選択の開始の前処理
  #--------------------------------------------------------------------------
  def prev_start_party_command_selection
  end
  #--------------------------------------------------------------------------
  # ○ パーティコマンド選択の開始の後処理
  #--------------------------------------------------------------------------
  def post_start_party_command_selection
  end
  #--------------------------------------------------------------------------
  # ☆ 次のコマンド入力へ
  #--------------------------------------------------------------------------
  alias a1_battle_common_sb_next_command next_command
  def next_command
    prev_next_command
    a1_battle_common_sb_next_command
    post_next_command
  end
  #--------------------------------------------------------------------------
  # ○ 次のコマンド入力への前処理
  #--------------------------------------------------------------------------
  def prev_next_command
  end
  #--------------------------------------------------------------------------
  # ○ 次のコマンド入力への後処理
  #--------------------------------------------------------------------------
  def post_next_command
  end
  #--------------------------------------------------------------------------
  # ☆ 前のコマンド入力へ
  #--------------------------------------------------------------------------
  alias a1_battle_common_sb_prior_command prior_command
  def prior_command
    prev_prior_command
    a1_battle_common_sb_prior_command
    post_prior_command
  end
  #--------------------------------------------------------------------------
  # ○ 前のコマンド入力への前処理
  #--------------------------------------------------------------------------
  def prev_prior_command
  end
  #--------------------------------------------------------------------------
  # ○ 前のコマンド入力への後処理
  #--------------------------------------------------------------------------
  def post_prior_command
  end
  #--------------------------------------------------------------------------
  # ☆ ターン開始
  #--------------------------------------------------------------------------
  alias a1_battle_common_sb_turn_start turn_start
  def turn_start
    prev_turn_start
    a1_battle_common_sb_turn_start
    post_turn_start
  end
  #--------------------------------------------------------------------------
  # ○ ターン開始の前処理
  #--------------------------------------------------------------------------
  def prev_turn_start
  end
  #--------------------------------------------------------------------------
  # ○ ターン開始の後処理
  #--------------------------------------------------------------------------
  def post_turn_start
  end
  #--------------------------------------------------------------------------
  # ☆ ターン終了
  #--------------------------------------------------------------------------
  alias a1_battle_common_sb_turn_end turn_end
  def turn_end
    prev_turn_end
    a1_battle_common_sb_turn_end
    post_turn_end
  end
  #--------------------------------------------------------------------------
  # ○ ターン終了の前処理
  #--------------------------------------------------------------------------
  def prev_turn_end
  end
  #--------------------------------------------------------------------------
  # ○ ターン終了の後処理
  #--------------------------------------------------------------------------
  def post_turn_end
  end
  #--------------------------------------------------------------------------
  # ○ ウィンドウが閉じるまでウェイト
  #--------------------------------------------------------------------------
  def wait_fot_window_close(window)
    update_basic while window.close?
  end
  #--------------------------------------------------------------------------
  # ○ アクターのバトルメンバー取得
  #--------------------------------------------------------------------------
  def battle_members
    @party_battle_members ||= $game_party.battle_members
    return @party_battle_members
  end
  #--------------------------------------------------------------------------
  # ○ バトルメンバーの追加の前処理
  #--------------------------------------------------------------------------
  def prev_add_battler(members)
  end
  #--------------------------------------------------------------------------
  # ○ バトルメンバーの追加後の処理
  #--------------------------------------------------------------------------
  def post_add_battler(member)
    @party_battle_members = $game_party.battle_members
  end
  #--------------------------------------------------------------------------
  # ○ バトルメンバー削除の前処理
  #--------------------------------------------------------------------------
  def prev_remove_battler(member)
  end
  #--------------------------------------------------------------------------
  # ○ バトルメンバーの削除後の処理
  #--------------------------------------------------------------------------
  def post_remove_battler
    @party_battle_members = $game_party.battle_members
  end
  #--------------------------------------------------------------------------
  # ☆ 戦闘行動の実行
  #--------------------------------------------------------------------------
  alias a1_battle_common_sb_execute_action execute_action
  def execute_action
    prev_execute_action
    a1_battle_common_sb_execute_action
    post_execute_action
  end
  #--------------------------------------------------------------------------
  # ○ 戦闘行動の実行の前処理
  #--------------------------------------------------------------------------
  def prev_execute_action
    @subject.current_action.pre_make_targets
  end
  #--------------------------------------------------------------------------
  # ○ 戦闘行動の実行の後処理
  #--------------------------------------------------------------------------
  def post_execute_action
    @subject.current_action.clear_targets if @subject.current_action
  end
  #--------------------------------------------------------------------------
  # ☆ スキル/アイテムの使用
  #--------------------------------------------------------------------------
  alias a1_battle_common_sb_use_item use_item
  def use_item
    prev_use_item
    a1_battle_common_sb_use_item
    post_use_item
  end
  #--------------------------------------------------------------------------
  # ○ スキル/アイテムの使用の前処理
  #--------------------------------------------------------------------------
  def prev_use_item
  end
  #--------------------------------------------------------------------------
  # ○ スキル/アイテムの使用の後処理
  #--------------------------------------------------------------------------
  def post_use_item
  end
  #--------------------------------------------------------------------------
  # ○ 勝利の処理
  #--------------------------------------------------------------------------
  def process_victory
  end
  #--------------------------------------------------------------------------
  # ○ 戦闘終了
  #--------------------------------------------------------------------------
  def battle_end(result)
    $game_party.all_members.each {|member| init_member_battle_end(member) }
  end
  #--------------------------------------------------------------------------
  # ○ 戦闘終了時のメンバー初期化
  #--------------------------------------------------------------------------
  def init_member_battle_end(member)
    member.current_weapon = nil
    member.current_main   = nil
  end
end
end[/pre]

バトルアクション
[pre lang="ruby"]#===========================================================================
# ◆ A1 Scripts ◆
#    バトルアクション(RGSS3)
#
# バージョン   : 2.00 (2012/01/18)
# 作者         : A1
# URL     : http://a1tktk.web.fc2.com/
#---------------------------------------------------------------------------
# 機能:
# ・バトル中のスキル・アイテム使用時に行うアクションを設定します
# ・バトル時のアニメーションを複数同時表示します
#---------------------------------------------------------------------------
# 更新履歴   :2012/01/10 Ver1.00 リリース
#              :2012/01/10 Ver1.01 アクターのアニメーションを画面左上に表示してしまう不具合を修正
#              :2012/01/18 Ver2.00 反撃・戦闘不能時に攻撃を続ける不具合を修正
#              :2012/01/18 Ver2.00 位置がずれる不具合を修正
#              :2012/01/18 Ver2.00 A1バトル共通スクリプト対応
#---------------------------------------------------------------------------
# 設置場所      
#    A1バトル共通スクリプト以下
#
# 必要スクリプト
#    A1バトル共通スクリプト
#---------------------------------------------------------------------------
# 使い方
#   スキルorアイテムのメモ欄に記述します
#
#     <アクション action,action,acton・・・>
#
#       actionの書き方
#       アニメーション:A(ID)(Damage)(Skip)
#         例:A103DS → アニメーションID 103 を表示し
#                       ダメージを与えて、アニメーションの終了を待ちません
#
#         例:A76D   → アニメーションID 76 を表示し
#                       ダメージを与えて、アニメーションの終了を待ちます
#     
#         例:A124S  → アニメーションID 124 を表示し
#                       ダメージを与えず、アニメーションの終了を待ちません
#     
#         例:A53    → アニメーションID 53 を表示し
#                       ダメージを与えず、アニメーションの終了を待ちます
#
#       ダメージ発生:D(times)(Skip)
#         例:D3     → ダメージを3回発生させ、ログのウェイトを発生させます
#         例:D1S    → ダメージを1回発生させ、ログのウェイトを発生させません
#
#       ウェイト:W(frame)
#         例:W60    → 60フレーム(1秒)の間ウェイトします
#
#     ※アクション中にダメージを発生させると
#       アクション終了後にダメージを発生させません
#
#     アクション設定例
#       例:桜花夢幻刃
#           <アクション A88S,D1S,W8,D1S,W8,D1S,W8,D1S,W30>
#
#           この設定でアニメーション「斬撃/必殺技4」に合わせてダメージが入ります
#
#       例:連続アニメーション
#           <アクション A7D,A7D,A7D,A7D,A7D>
#
#           この設定でアニメーション「斬撃/物理」をダメージ付きで5回連続させます
#==============================================================================
$imported ||= {}
if $imported["A1_BattleCommonScript"]
$imported["A1_BattleAction"] = true
old_common_script("バトルアクション", "3.30") if common_version < 3.30
#==============================================================================
# ■ RPG::UsableItem
#==============================================================================

class RPG::UsableItem < RPG::BaseItem
  #--------------------------------------------------------------------------
  # ○ アクション
  #--------------------------------------------------------------------------
  def actions
    @actions = $a1_common.note_data_array(self.note, "アクション", "A", nil, false) if @actions == nil
    return nil if @actions.empty?
    return @actions
  end
end
#==============================================================================
# ■ Scene_Battle
#------------------------------------------------------------------------------
#  バトル画面の処理を行うクラスです。
#==============================================================================

class Scene_Battle < Scene_Base
  #--------------------------------------------------------------------------
  # ☆ ウェイト
  #--------------------------------------------------------------------------
  alias a1_chain_animation_sb_wait wait
  def wait(duration)
    a1_chain_animation_sb_wait(duration) unless @skip_animation_wait || @skip_effect_wait
  end
  #--------------------------------------------------------------------------
  # ☆ アニメーション表示が終わるまでウェイト
  #--------------------------------------------------------------------------
  alias a1_chain_animation_sb_wait_for_animation wait_for_animation
  def wait_for_animation
    a1_chain_animation_sb_wait_for_animation unless @skip_animation_wait
  end
  #--------------------------------------------------------------------------
  # ☆ エフェクト実行が終わるまでウェイト
  #--------------------------------------------------------------------------
  alias a1_chain_animation_sb_wait_for_effect wait_for_effect
  def wait_for_effect
    a1_chain_animation_sb_wait_for_effect unless @skip_effect_wait
  end
  #--------------------------------------------------------------------------
  # ☆ スキル/アイテムの使用
  #--------------------------------------------------------------------------
  alias a1_chain_animation_sb_use_item use_item
  def use_item
    return if @subject.hp <= 0
    @skip_animation_wait  = false
    @action_invoke        = false
    @invoke_damage        = false
    @log_window.wait_skip = false
    @action_item          = @subject.current_action.item if @subject.current_action
    a1_chain_animation_sb_use_item
  end
  #--------------------------------------------------------------------------
  # ☆ アニメーションの表示
  #     targets      : 対象者の配列
  #     animation_id : アニメーション ID(-1: 通常攻撃と同じ)
  #--------------------------------------------------------------------------
  alias a1_chain_animation_sb_show_animation show_animation
  def show_animation(targets, animation_id)
    return a1_chain_animation_sb_show_animation(targets, animation_id) unless check_action_item
    set_wait_collapse(targets, true)
    @action_item.actions.each {|action| proc_action(targets, action) }
    set_wait_collapse(targets, false)
    @action_invoke = @invoke_damage
    @action_item   = nil
  end
  #--------------------------------------------------------------------------
  # ○ アクションの存在チェック
  #--------------------------------------------------------------------------
  def check_action_item
    return false unless @action_item
    return false unless @action_item.actions
    return true
  end
  #--------------------------------------------------------------------------
  # ○ コラプス処理保留の設定
  #--------------------------------------------------------------------------
  def set_wait_collapse(targets, flag)
    @skip_effect_wait = true unless flag
    targets.each {|target| target.wait_collapse = flag; next if flag
      target.refresh
      @log_window.display_added_states(target)
    }
    @skip_effect_wait = false
    wait_for_effect unless flag
  end
  #--------------------------------------------------------------------------
  # ○ アクションの実行
  #--------------------------------------------------------------------------
  def proc_action(targets, action)
    @skip_animation_wait  = false
    @log_window.wait_skip = false
    return action_animation(targets, $1.to_i, $2) if action =~ /A([-]?\d+)(.*)/
    return wait($1.to_i) if action =~ /W(\d+)/
    proc_damage(targets, $1.to_i, $2) if action =~ /D(\d+)(.*)/
  end
  #--------------------------------------------------------------------------
  # ○ ダメージの実行
  #--------------------------------------------------------------------------
  def proc_damage(targets, num, params)
    @log_window.wait_skip = true if params.include?("S")
    @skip_animation_wait  = true if params.include?("S")
    targets.each {|target| num.times { invoke_item(target, @action_item) } }
    @invoke_damage = true
  end
  #--------------------------------------------------------------------------
  # ○ アクションのアニメーション
  #--------------------------------------------------------------------------
  def action_animation(targets, animation_id, params)
    return if @subject.hp <= 0
    @skip_animation_wait  = true if params.include?("S")
    @log_window.wait_skip = true if params.include?("S")
    a1_chain_animation_sb_show_animation(targets, animation_id)
    targets.each {|target| invoke_item(target, @action_item) } if params.include?("D")
    @invoke_damage = true if params.include?("D")
  end
  #--------------------------------------------------------------------------
  # ☆ スキル/アイテムの発動
  #--------------------------------------------------------------------------
  alias a1_chain_animation_sb_invoke_item invoke_item
  def invoke_item(target, item)
    return if @subject.hp <= 0
    a1_chain_animation_sb_invoke_item(target, item) unless @action_invoke
  end
end
#==============================================================================
# ■ Sprite_BattleAnimation
#==============================================================================

class Sprite_BattleAnimation < Sprite_Base
  #--------------------------------------------------------------------------
  # ○ オブジェクト初期化
  #--------------------------------------------------------------------------
  def initialize(viewport, battler_sprite, index, use_sprite)
    @use_sprite     = use_sprite
    super(viewport)
    self.x          = battler_sprite.x
    self.y          = battler_sprite.y
    self.z          = battler_sprite.z + index
    self.ox         = battler_sprite.ox
    self.oy         = battler_sprite.oy
    self.src_rect   = battler_sprite.src_rect
  end
end
#==============================================================================
# ■ Sprite_Battler
#------------------------------------------------------------------------------
#  バトラー表示用のスプライトです。Game_Battler クラスのインスタンスを監視し、
# スプライトの状態を自動的に変化させます。
#==============================================================================

class Sprite_Battler < Sprite_Base
  #--------------------------------------------------------------------------
  # ☆ オブジェクト初期化
  #--------------------------------------------------------------------------
  alias a1_multi_animation_sb_initialize initialize
  def initialize(viewport, battler = nil)
    @viewport = viewport
    @sprite_animation = []
    a1_multi_animation_sb_initialize(viewport, battler)
  end
  #--------------------------------------------------------------------------
  # ○ アニメーションの開始
  #--------------------------------------------------------------------------
  def start_animation(animation, mirror)
    sprite_animation = Sprite_BattleAnimation.new(@viewport, self, @sprite_animation.size, @battler.use_sprite?)
    sprite_animation.start_animation(animation, mirror)
    @sprite_animation.push(sprite_animation)
  end
  #--------------------------------------------------------------------------
  # ○ アニメーション表示中判定
  #--------------------------------------------------------------------------
  def battle_animation?
    @sprite_animation.each {|animation| return true if animation.animation? }
    return false
  end
  #--------------------------------------------------------------------------
  # ☆ フレーム更新
  #--------------------------------------------------------------------------
  alias a1_multi_animation_sb_update update
  def update
    a1_multi_animation_sb_update
    update_animation_ex
  end
  #--------------------------------------------------------------------------
  # ○ アニメーションの更新
  #--------------------------------------------------------------------------
  def update_animation_ex
    @sprite_animation.each_with_index {|animation, i|
      animation.update
      next if animation.animation?
      animation.dispose
      @sprite_animation.delete_at(i)
    }
  end
end
#==============================================================================
# ■ Window_BattleLog
#------------------------------------------------------------------------------
#  戦闘の進行を実況表示するウィンドウです。枠は表示しませんが、便宜上ウィンド
# ウとして扱います。
#==============================================================================

class Window_BattleLog < Window_Selectable
  #--------------------------------------------------------------------------
  # ☆ オブジェクト初期化
  #--------------------------------------------------------------------------
  alias a1_chain_animation_wbl_initialize initialize
  def initialize
    @wait_skip = false
    a1_chain_animation_wbl_initialize
  end
  #--------------------------------------------------------------------------
  # ☆ ウェイト
  #--------------------------------------------------------------------------
  alias a1_chain_animation_wbl_wait wait
  def wait
    a1_chain_animation_wbl_wait unless @wait_skip
    @wait_skip = false
  end
  #--------------------------------------------------------------------------
  # ○ ウェイトスキップの設定
  #--------------------------------------------------------------------------
  def wait_skip=(flag)
    @wait_skip = flag
  end
end
#==============================================================================
# ■ Game_Battler
#------------------------------------------------------------------------------
#  スプライトや行動に関するメソッドを追加したバトラーのクラスです。このクラス
# は Game_Actor クラスと Game_Enemy クラスのスーパークラスとして使用されます。
#==============================================================================

class Game_Battler < Game_BattlerBase
  #--------------------------------------------------------------------------
  # ☆ オブジェクト初期化
  #--------------------------------------------------------------------------
  alias a1_battle_action_gb_initialize initialize
  def initialize
    a1_battle_action_gb_initialize
    @wait_collapse = false
  end
  #--------------------------------------------------------------------------
  # ☆ ステートの付加
  #--------------------------------------------------------------------------
  alias a1_battle_action_gb_add_state add_state
  def add_state(state_id)
    return if @wait_collapse && state_id == death_state_id
    a1_battle_action_gb_add_state(state_id)
  end
  #--------------------------------------------------------------------------
  # ○ コラプスウェイト
  #--------------------------------------------------------------------------
  def wait_collapse=(flg)
    @wait_collapse = flg
  end
end
end[/pre]

フェイスステータスウィンドウ
[pre lang="ruby"]#===========================================================================
# ◆ A1 Scripts ◆
#    フェイスステータスウィンドウ(RGSS3)
#
# バージョン   : 1.00 (2012/01/18)
# 作者         : A1
# URL     : http://a1tktk.web.fc2.com/
#---------------------------------------------------------------------------
# 機能:
# ・顔グラフィックを表示するバトルステータスウィンドウです
#---------------------------------------------------------------------------
# 更新履歴   :2012/01/18 Ver1.00 リリース
#---------------------------------------------------------------------------
# 設置場所      
#    A1バトル共通スクリプト以下
#    (戦闘中入れ替えスクリプト以下)
#
# 必要スクリプト
#    A1バトル共通スクリプト
#---------------------------------------------------------------------------
# 使い方
#   導入することで適用されます
#==============================================================================
$imported ||= {}
if $imported["A1_BattleCommonScript"]
$imported["A1_FaceStatusWindow"] = true
old_common_script("フェイスステータスウィンドウ", "3.90") if common_version < 3.90
#==============================================================================
# ■ Window_FaceStatus
#==============================================================================

class Window_FaceStatus < Window_Base
  #--------------------------------------------------------------------------
  # ○ オブジェクト初期化
  #--------------------------------------------------------------------------
  def initialize
    @actors = $game_party.battle_members
    super(0, 0, 0, 0)
    setup_window_pos
    self.openness = 0
    self.contents.font.size = 21
  end
  #--------------------------------------------------------------------------
  # ○ 項目数の取得
  #--------------------------------------------------------------------------
  def item_max
    @actors.size
  end
  #--------------------------------------------------------------------------
  # ○ ウィンドウ位置のセットアップ
  #--------------------------------------------------------------------------
  def setup_window_pos
    self.width  = actor_width * @actors.size + standard_padding * 1.5
    self.height = 96 + standard_padding * 2
    self.y      = Graphics.height - height
    self.x      = Graphics.width  - width
    create_contents
  end
  #--------------------------------------------------------------------------
  # ○ アクターの設定
  #--------------------------------------------------------------------------
  def actors=(actors)
    @actors = actors
    setup_window_pos
  end
  #--------------------------------------------------------------------------
  # ○ 一人のアクターにかける幅
  #--------------------------------------------------------------------------
  def actor_width
    return 96 + standard_padding / 2
  end
  #--------------------------------------------------------------------------
  # ○ 項目の描画
  #--------------------------------------------------------------------------
  def draw_item(index)
    actor = @actors[index]
    x     = actor_width * index
    draw_face(actor.face_name, actor.face_index, x, 0, false)
    draw_text(x, line_height * 0, actor_width - (standard_padding / 2), line_height, actor.name, 1)
    draw_actor_icons(actor, x, 0 + line_height * 3)
    draw_actor_hp(actor, x, 0 + line_height * 1, 95)
    draw_actor_mp(actor, x, 0 + line_height * 2, 48)
    draw_actor_tp(actor, x + 50, 0 + line_height * 2, 45) if $data_system.opt_display_tp
  end
  #--------------------------------------------------------------------------
  # ○ 全項目の描画
  #--------------------------------------------------------------------------
  def draw_all_items
    item_max.times {|i| draw_item(i) }
  end
  #--------------------------------------------------------------------------
  # ○ リフレッシュ
  #--------------------------------------------------------------------------
  def refresh
    return unless self.visible
    contents.clear
    draw_all_items
  end
  #--------------------------------------------------------------------------
  # ○ フレーム更新
  #--------------------------------------------------------------------------
  def update
    return unless self.visible
    super
    self.visible = false if self.openness == 0
  end
  #--------------------------------------------------------------------------
  # ○ オープン
  #--------------------------------------------------------------------------
  def open
    self.visible = true
    refresh
    super
  end
  #--------------------------------------------------------------------------
  # ○ 顔グラフィックの描画
  #--------------------------------------------------------------------------
  def draw_face(face_name, face_index, x, y, enabled = true)
    draw_face_no_dispose(face_name, face_index, x, y, enabled)
  end
end
#==============================================================================
# ■ Scene_Battle
#------------------------------------------------------------------------------
#  バトル画面の処理を行うクラスです。
#==============================================================================

class Scene_Battle < Scene_Base
  #--------------------------------------------------------------------------
  # ☆ 全ウィンドウの作成
  #--------------------------------------------------------------------------
  alias a1_face_status_window_sb_create_all_windows create_all_windows
  def create_all_windows
    create_face_status_window
    create_personal_status_window
    a1_face_status_window_sb_create_all_windows
  end
  #--------------------------------------------------------------------------
  # ○ ステータスウィンドウ作成の後処理
  #--------------------------------------------------------------------------
  def post_create_status_window
    @status_window.visible = false
  end
  #--------------------------------------------------------------------------
  # ○ フェイスステータスウィンドウの作成
  #--------------------------------------------------------------------------
  def create_face_status_window
    @face_status_window = Window_FaceStatus.new
  end
  #--------------------------------------------------------------------------
  # ○ 個人ステータスウィンドウの作成
  #--------------------------------------------------------------------------
  def create_personal_status_window
    @personal_status_window = Window_PersonalStatus.new(0, Graphics.height - 120, 0)
  end
  #--------------------------------------------------------------------------
  # ☆ ステータスウィンドウがリフレッシュされた時の処理
  #--------------------------------------------------------------------------
  alias a1_face_status_window_sb_refresh_statsu_window refresh_statsu_window
  def refresh_statsu_window
    a1_face_status_window_sb_refresh_statsu_window
    @face_status_window.refresh
  end
  #--------------------------------------------------------------------------
  # ☆ ステータスウィンドウがクローズされた時の処理
  #--------------------------------------------------------------------------
  alias a1_face_status_window_sb_close_status_window close_status_window
  def close_status_window
    a1_face_status_window_sb_close_status_window
    @face_status_window.close
  end
  #--------------------------------------------------------------------------
  # ○ 個人ステータスウィンドウのアクター設定
  #--------------------------------------------------------------------------
  def setup_personal_status_actor
    actor = BattleManager.actor
    actor ? @personal_status_window.actor = actor : @personal_status_window.close
    @personal_status_window.open if actor
  end
  #--------------------------------------------------------------------------
  # ○ パーティコマンド選択の開始の後処理
  #--------------------------------------------------------------------------
  alias a1_face_status_window_sb_post_start_party_command_selection post_start_party_command_selection
  def post_start_party_command_selection
    a1_face_status_window_sb_post_start_party_command_selection
    @face_status_window.close
  end
  #--------------------------------------------------------------------------
  # ☆ 次のコマンド入力への後処理
  #--------------------------------------------------------------------------
  alias a1_face_status_window_sb_post_next_command post_next_command
  def post_next_command
    a1_face_status_window_sb_post_next_command
    setup_personal_status_actor
  end
  #--------------------------------------------------------------------------
  # ☆ 前のコマンド入力への後処理
  #--------------------------------------------------------------------------
  alias a1_face_status_window_sb_post_prior_command post_prior_command
  def post_prior_command
    a1_face_status_window_sb_post_prior_command
    setup_personal_status_actor
  end
  #--------------------------------------------------------------------------
  # ☆ ターン開始の前処理
  #--------------------------------------------------------------------------
  alias a1_face_status_window_sb_prev_turn_start prev_turn_start
  def prev_turn_start
    a1_face_status_window_sb_prev_turn_start
    @personal_status_window.close
    @face_status_window.open
    @face_status_window.refresh
  end
  #--------------------------------------------------------------------------
  # ○ バトルメンバーの追加後の処理
  #--------------------------------------------------------------------------
  alias a1_face_status_window_sb_post_add_battler post_add_battler
  def post_add_battler(member)
    a1_face_status_window_sb_post_add_battler(member)
    @face_status_window.actors = $game_party.battle_members
  end
  #--------------------------------------------------------------------------
  # ○ バトルメンバーの削除後の処理
  #--------------------------------------------------------------------------
  alias a1_face_status_window_sb_post_remove_battler post_remove_battler
  def post_remove_battler
    a1_face_status_window_sb_post_remove_battler
    @face_status_window.actors = $game_party.battle_members
  end
#==============================================================================
# ■ 戦闘中入れ替えインポート時処理
#==============================================================================
if $imported["A1_ChangeMember"]
  #--------------------------------------------------------------------------
  # ○ メンバーチェンジ[キャンセル]
  #--------------------------------------------------------------------------
  alias a1_face_status_window_sb_on_member_change_cancel on_member_change_cancel
  def on_member_change_cancel
    a1_face_status_window_sb_on_member_change_cancel
    @face_status_window.actors = $game_party.battle_members
  end;end
end
#==============================================================================
# ■ ポップアップダメージインポート時処理
#==============================================================================
if $imported["A1_DamagePopUp"]
#==============================================================================
# ■ Window_BattleLog
#------------------------------------------------------------------------------
#  戦闘の進行を実況表示するウィンドウです。枠は表示しませんが、便宜上ウィンド
# ウとして扱います。
#==============================================================================

class Window_BattleLog < Window_Selectable
  #--------------------------------------------------------------------------
  # ★ ポップアップの位置取得・アクター
  #--------------------------------------------------------------------------
  def popup_pos_actor(target)
    y           = (Graphics.height - (96 + standard_padding * 2) / 2 )
    actor_width = (96 + standard_padding / 2)
    width       = actor_width * $game_party.battle_members.size + standard_padding * 1.5
    x           = Graphics.width  - width
    x           = x + actor_width * target.index + actor_width / 2
    return [x, y]
  end
end;end
end[/pre]

個別バトルステータスウィンドウ
[pre lang="ruby"]#===========================================================================
# ◆ A1 Scripts ◆
#    個別バトルステータスウィンドウ(RGSS3)
#
# バージョン   : 2.11 (2012/01/24)
# 作者         : A1
# URL     : http://a1tktk.web.fc2.com/
#---------------------------------------------------------------------------
# 機能:
# ・おれは「個別バトルステータスウィンドウ」だけを作っていたと思ったら
#  いつの間にかバトル画面全部を作っていた
#
#  な… 何を言ってるのか わからねーと思うが
#   おれも何をしてたのかわからなかった…
#
#   頭がどうにかなりそうだった…
#
#   ついでだとかヒマだっただとか
#   そんなチャチなもんじゃあ 断じてねえ
#
#   もっと恐ろしいものの片鱗を味わったぜ…
#---------------------------------------------------------------------------
# 更新履歴   :2012/01/10 Ver1.00 リリース
#              :2012/01/10 Ver1.10 敵選択の不具合を修正
#              :2012/01/10 Ver1.10 顔グラフィック位置の不具合を修正
#              :2012/01/10 Ver1.10 顔グラフィック切り替えの際、一瞬カクつく不具合を修正
#              :2012/01/16 Ver1.11 二回行動の際顔グラフィックが1段階上にせりあがる不具合を修正
#              :2012/01/17 Ver1.20 陣形対応
#              :2012/01/17 Ver1.20 戦闘中入れ替え対応
#              :2012/01/19 Ver2.00 A1バトル共通スクリプト対応
#              :2012/01/21 Ver2.10 ウィンドウのフォントサイズ調整できるようにしました
#              :2012/01/24 Ver2.11 フェイスステータスウィンドウを使用しない際の不具合を修正
#---------------------------------------------------------------------------
# 設置場所      
#    A1バトル共通スクリプト以下
#    (リザルトウィンドウ以下)
#    (ダメージポップアップ以下)
#    (戦闘中入れ替えスクリプト以下)
#
# 必要スクリプト
#    A1バトル共通スクリプト
#---------------------------------------------------------------------------
# 使い方
#   ■ 設定項目 に設定します
#
#   ※顔グラフィックモード false 時
#   データベース「アクター」のメモ欄にバトラーグラフィックを設定します
#
#     <バトラー filename>
#     
#     顔グラフィックの代わりに、設定したピクチャを使用します  
#     インポート先は「Picture」ディレクトリになります
#==============================================================================
$imported ||= {}
if $imported["A1_BattleCommonScript"]
$imported["A1_PersonalBattleStatus"] = true
old_common_script("個別バトルステータスウィンドウ", "3.90") if common_version < 3.90
#==============================================================================
# ■ 設定項目
#==============================================================================
module A1_System::PersonalBattleStatusConfig
  #--------------------------------------------------------------------------
  # 顔グラフィックモード
  #--------------------------------------------------------------------------
  FACE_MODE       = true
  #--------------------------------------------------------------------------
  # ウィンドウのフォントサイズ
  #--------------------------------------------------------------------------
  FONT_SIZE       = 18
end
#==============================================================================
# ■ ポップアップダメージインポート時処理
#==============================================================================
if $imported["A1_DamagePopUp"]
#==============================================================================
# ■ Window_BattleLog
#------------------------------------------------------------------------------
#  戦闘の進行を実況表示するウィンドウです。枠は表示しませんが、便宜上ウィンド
# ウとして扱います。
#==============================================================================

class Window_BattleLog < Window_Selectable
  #--------------------------------------------------------------------------
  # ★ ポップアップの位置取得・アクター
  #--------------------------------------------------------------------------
  def popup_pos_actor(target)
    [target.screen_x ,target.screen_y - target.sprite_height / 2]
  end
end
#==============================================================================
# ■ ポップアップダメージ非インポート時処理
#==============================================================================
else
#==============================================================================
# ■ Scene_Battle
#------------------------------------------------------------------------------
#  バトル画面の処理を行うクラスです。
#==============================================================================

class Scene_Battle < Scene_Base
  #--------------------------------------------------------------------------
  # ☆ 開始処理
  #--------------------------------------------------------------------------
  alias a1_damege_popup_sb_start start
  def start
    a1_damege_popup_sb_start
    setup_actor_index
  end
  #--------------------------------------------------------------------------
  # ○ アクターインデックスの割り当て
  #--------------------------------------------------------------------------
  def setup_actor_index
    $game_party.battle_members.each_with_index {|actor, i| actor.index = i }
  end
end
#==============================================================================
# ■ Game_Actor
#------------------------------------------------------------------------------
#  アクターを扱うクラスです。このクラスは Game_Actors クラス($game_actors)
# の内部で使用され、Game_Party クラス($game_party)からも参照されます。
#==============================================================================

class Game_Actor < Game_Battler
  #--------------------------------------------------------------------------
  # ○ 公開インスタンス変数
  #--------------------------------------------------------------------------
  attr_accessor :index
  #--------------------------------------------------------------------------
  # ☆ セットアップ
  #--------------------------------------------------------------------------
  alias a1_damege_popup_setup setup
  def setup(actor_id)
    a1_damege_popup_setup(actor_id)
    @index = nil
  end
end;end
#==============================================================================
# ■ RPG::Actor
#==============================================================================

class RPG::Actor < RPG::BaseItem
  #--------------------------------------------------------------------------
  # ○ バトラー名
  #--------------------------------------------------------------------------
  def battler_name
    @battler_name ||= $a1_common.note_data_one(self.note, "バトラー", "")
    return @battler_name
  end
end
#==============================================================================
# ■ BattleManager
#------------------------------------------------------------------------------
#  戦闘の進行を管理するモジュールです。
#==============================================================================

module BattleManager
  #--------------------------------------------------------------------------
  # ○ エイリアス用特異メソッド
  #--------------------------------------------------------------------------
  class << self
    alias :a1_psw_bm_turn_end :turn_end
    alias :a1_psw_bm_turn_start :turn_start
  end
  #--------------------------------------------------------------------------
  # ☆ ターン開始
  #--------------------------------------------------------------------------
  def self.turn_start
    @regenerate_actor = []
    a1_psw_bm_turn_start
  end
  #--------------------------------------------------------------------------
  # ☆ ターン終了
  #--------------------------------------------------------------------------
  def self.turn_end
    call_method(:show_regenerate_actor, @regenerate_actor) unless @regenerate_actor.empty?
    a1_psw_bm_turn_end
  end
  #--------------------------------------------------------------------------
  # ○ 自動回復したアクターの取得
  #--------------------------------------------------------------------------
  def self.regenerate_actor
    @regenerate_actor
  end
end
#==============================================================================
# ■ Window_BattleActors
#==============================================================================

class Window_BattleActors < Window_Base
  #--------------------------------------------------------------------------
  # ○ 定数
  #--------------------------------------------------------------------------
  FACE_MODE = A1_System::PersonalBattleStatusConfig::FACE_MODE
  FONT_SIZE = A1_System::PersonalBattleStatusConfig::FONT_SIZE
  #--------------------------------------------------------------------------
  # ○ オブジェクト初期化
  #--------------------------------------------------------------------------
  def initialize(index, actor)
    @actor    = actor
    @states   = []
    super(0, 0, 0, 0)
    self.visible  = false
    self.opacity  = 0
  end
  #--------------------------------------------------------------------------
  # ○ ウィンドウ位置のセット
  #--------------------------------------------------------------------------
  def setup_window_pos(index)
    width       = Graphics.width / 4
    width       = Graphics.width / $game_party.battle_members.size if $game_party.battle_members.size > 4
    @line_num   = $data_system.opt_display_tp ? 5 : 4
    height      = fitting_height(@line_num)
    self.x      = width * index
    self.y      = Graphics.height - height
    self.width  = width
    self.height = height + 24
    create_contents
    self.contents.font.size = FONT_SIZE
    @target_y = self.y
    @org_y    = self.y
    refresh
  end
  #--------------------------------------------------------------------------
  # ○ リフレッシュ
  #--------------------------------------------------------------------------
  def refresh
    contents.clear
    draw_info
  end
  #--------------------------------------------------------------------------
  # ○ 情報の描画
  #--------------------------------------------------------------------------
  def draw_info
    draw_background(contents.rect)
    draw_face(@actor.face_name, @actor.face_index, (self.contents.width - 96) / 2, 0, false) if FACE_MODE
    draw_actor_icons(@actor, 4, line_height * 0, contents.width)
    draw_text(0, draw_y(1) - 8, contents.width, line_height, @actor.name, 1)
    draw_actor_hp(@actor, 4, draw_y(2), contents.width)
    draw_actor_mp(@actor, 4, draw_y(3), contents.width)
    draw_actor_tp(@actor, 4, draw_y(4), contents.width) if $data_system.opt_display_tp
  end
  #--------------------------------------------------------------------------
  # ○ 描画するy座標
  #--------------------------------------------------------------------------
  def draw_y(index)
    self.height - (line_height - 6) * (@line_num - index) - 42
  end
  #--------------------------------------------------------------------------
  # ○ 1行の高さ
  #--------------------------------------------------------------------------
  def line_height
    return 20
  end
  #--------------------------------------------------------------------------
  # ○ 上に移動
  #--------------------------------------------------------------------------
  def move_up
    @target_y = @org_y - 24
  end
  #--------------------------------------------------------------------------
  # ○ 戻る
  #--------------------------------------------------------------------------
  def move_return
    @target_y = @org_y
  end
  #--------------------------------------------------------------------------
  # ○ フレーム更新
  #--------------------------------------------------------------------------
  def update
    super
    self.y -= 6 if @target_y < self.y
    self.y += 6 if @target_y > self.y
  end
  #--------------------------------------------------------------------------
  # ○ 顔グラフィックの描画
  #--------------------------------------------------------------------------
  def draw_face(face_name, face_index, x, y, enabled = true)
    draw_face_no_dispose(face_name, face_index, x, y, enabled)
  end
end
#==============================================================================
# ■ Scene_Battle
#------------------------------------------------------------------------------
#  バトル画面の処理を行うクラスです。
#==============================================================================

class Scene_Battle < Scene_Base
  #--------------------------------------------------------------------------
  # ○ 定数
  #--------------------------------------------------------------------------
  FACE_MODE = A1_System::PersonalBattleStatusConfig::FACE_MODE
  #--------------------------------------------------------------------------
  # ☆ バトルマネージャメソッドの定義
  #--------------------------------------------------------------------------
  alias a1_psw_sb_define_battle_manager_method define_battle_manager_method
  def define_battle_manager_method
    a1_psw_sb_define_battle_manager_method
    BattleManager.define_method(method(:show_regenerate_actor),  :show_regenerate_actor)
  end
  #--------------------------------------------------------------------------
  # ☆ 全ウィンドウの作成
  #--------------------------------------------------------------------------
  alias a1_psw_sb_create_all_windows create_all_windows
  def create_all_windows
    a1_psw_sb_create_all_windows
    create_name_help_window
  end
  #--------------------------------------------------------------------------
  # ☆ ステータスウィンドウ作成の後処理
  #--------------------------------------------------------------------------
  alias a1_psw_sb_post_create_status_window post_create_status_window
  def post_create_status_window
    a1_psw_sb_post_create_status_window
    create_status_windows
    a1_psw_sb_post_create_status_window
    @status_window.visible = false
    @status_window.y       = @status_window_y
  end
  #--------------------------------------------------------------------------
  # ○ 名前表示用ヘルプウィンドウの作成
  #--------------------------------------------------------------------------
  def create_name_help_window
    @name_help_window = Window_Help.new
    @name_help_window.openness = 0
    @name_help_window.visible  = true
    @actor_window.help_window = @name_help_window
    @enemy_window.help_window = @name_help_window
  end
  #--------------------------------------------------------------------------
  # ○ 個別ステータスウィンドウの作成
  #--------------------------------------------------------------------------
  def create_status_windows
    @status_windows = []
    @status_window_height = 0
    battle_members.each_with_index {|actor, i| setup_status_windows(i, actor) }
  end
  #--------------------------------------------------------------------------
  # ○ 個別ステータスウィンドウのセットアップ
  #--------------------------------------------------------------------------
  def setup_status_windows(index, actor)
    @status_windows[index] = Window_BattleActors.new(index, actor)
    @status_windows[index].z = 15
    setup_status_windows_pos(index, actor)
  end
  #--------------------------------------------------------------------------
  # ○ 個別ステータスウィンドウとアクターの位置をセットアップ
  #--------------------------------------------------------------------------
  def setup_status_windows_pos(index, actor)
    @status_windows[index].setup_window_pos(index)
    setup_actor_battler(index, actor)
    @status_window_height = @status_windows[index].height
    @status_window_y      = @status_windows[index].y
  end
  #--------------------------------------------------------------------------
  # ○ アクター位置のセットアップ
  #--------------------------------------------------------------------------
  def setup_actor_battler(index, actor)
    actor.screen_x = @status_windows[index].x + @status_windows[index].width / 2
    actor.screen_z = 10
    return setup_actor_sprite(actor, index) if actor.use_sprite && !FACE_MODE
    return setup_empty_sprite(actor, index)
  end
  #--------------------------------------------------------------------------
  # ○ アクタースプライトのセットアップ
  #--------------------------------------------------------------------------
  def setup_actor_sprite(actor, index)
    actor.screen_y = Graphics.height
    actor.visible  = false
  end
  #--------------------------------------------------------------------------
  # ○ 空のダミースプライトのセットアップ
  #--------------------------------------------------------------------------
  def setup_empty_sprite(actor, index)
    actor.screen_y    = @status_windows[index].y + @status_windows[index].height / 2
    actor.use_sprite = true
    sprite = @spriteset.actor_sprite[index]
    height = (Graphics.height - @status_windows[index].y) / 2
    sprite.setup_empty_actor_bitmap(@status_windows[index].width, height)
  end
  #--------------------------------------------------------------------------
  # ☆ 情報表示ビューポートの作成
  #--------------------------------------------------------------------------
  alias a1_psw_sb_create_info_viewport create_info_viewport
  def create_info_viewport
    a1_psw_sb_create_info_viewport
    @info_viewport.rect.y = Graphics.height - (@status_window.height + @status_window_height)
  end
  #--------------------------------------------------------------------------
  # ☆ ステータスウィンドウがリフレッシュされた時の処理
  #--------------------------------------------------------------------------
  alias a1_psw_sb_refresh_statsu_window refresh_statsu_window
  def refresh_statsu_window
    a1_psw_sb_refresh_statsu_window
    refresh_status_windows
  end
  #--------------------------------------------------------------------------
  # ☆ スキルウィンドウ作成の後処理
  #--------------------------------------------------------------------------
  alias a1_psw_sb_post_create_skill_window post_create_skill_window
  def post_create_skill_window
    a1_psw_sb_post_create_skill_window
    @skill_window.resize_height(@status_window_y)
  end
  #--------------------------------------------------------------------------
  # ☆ アイテムウィンドウ作成の後処理
  #--------------------------------------------------------------------------
  alias a1_psw_sb_post_create_item_window post_create_item_window
  def post_create_item_window
    a1_psw_sb_post_create_item_window
    @item_window.resize_height(@status_window_y)
  end
  #--------------------------------------------------------------------------
  # ☆ パーティコマンド選択の開始の前処理
  #--------------------------------------------------------------------------
  alias a1_psw_sb_prev_start_party_command_selection prev_start_party_command_selection
  def prev_start_party_command_selection
    battle_members.each {|actor| enable_open_status(actor.index) }
    a1_psw_sb_prev_start_party_command_selection
  end
  #--------------------------------------------------------------------------
  # ☆ コマンド[戦う]
  #--------------------------------------------------------------------------
  alias a1_psw_sb_prev_command_fight command_fight
  def command_fight
    battle_members.each {|actor| disable_open_status(actor.index) }
    a1_psw_sb_prev_command_fight
  end
  #--------------------------------------------------------------------------
  # ☆ コマンド[逃げる]
  #--------------------------------------------------------------------------
  alias a1_psw_sb_prev_command_escape command_escape
  def command_escape
    battle_members.each {|actor| disable_open_status(actor.index) }
    a1_psw_sb_prev_command_escape
  end
  #--------------------------------------------------------------------------
  # ☆ コマンド[スキル]
  #--------------------------------------------------------------------------
  alias a1_psw_sb_command_skill command_skill
  def command_skill
    a1_psw_sb_command_skill
    @actor_command_window.close
  end
  #--------------------------------------------------------------------------
  # ☆ コマンド[アイテム]
  #--------------------------------------------------------------------------
  alias a1_psw_sb_command_item command_item
  def command_item
    a1_psw_sb_command_item
    @actor_command_window.close
  end
  #--------------------------------------------------------------------------
  # ☆ アクター選択の開始
  #--------------------------------------------------------------------------
  alias a1_psw_sb_select_actor_selection select_actor_selection
  def select_actor_selection
    @skill_window.hide
    @item_window.hide
    a1_psw_sb_select_actor_selection
    @actor_window.visible = false
  end
  #--------------------------------------------------------------------------
  # ☆ 敵キャラ選択の開始
  #--------------------------------------------------------------------------
  alias a1_psw_sb_select_enemy_selection select_enemy_selection
  def select_enemy_selection
    @skill_window.hide
    @item_window.hide
    a1_psw_sb_select_enemy_selection
    @enemy_window.visible = false
  end
  #--------------------------------------------------------------------------
  # ☆ ターン開始の前処理
  #--------------------------------------------------------------------------
  alias a1_psw_sb_prev_turn_start prev_turn_start
  def prev_turn_start
    close_status_windows
    a1_psw_sb_prev_turn_start
    @face_status_window.close if $imported["A1_FaceStatusWindow"]
  end
  #--------------------------------------------------------------------------
  # ☆ ターン開始の後処理
  #--------------------------------------------------------------------------
  alias a1_psw_sb_post_turn_start post_turn_start
  def post_turn_start
    battle_members.each {|actor| disable_status_window(actor) }
  end
  #--------------------------------------------------------------------------
  # ☆ 戦闘行動終了時の処理
  #--------------------------------------------------------------------------
  alias a1_psw_sb_process_action_end process_action_end
  def process_action_end
    close_status_windows
    diseble_close_status(@subject.index) if @subject.actor?
    a1_psw_sb_process_action_end
  end
  #--------------------------------------------------------------------------
  # ☆ 戦闘行動の実行
  #--------------------------------------------------------------------------
  alias a1_psw_sb_execute_action execute_action
  def execute_action
    close_status_windows
    enable_open_status(@subject.index) if @subject.actor?
    a1_psw_sb_execute_action
  end
  #--------------------------------------------------------------------------
  # ☆ アニメーションの表示
  #     targets      : 対象者の配列
  #     animation_id : アニメーション ID(-1: 通常攻撃と同じ)
  #--------------------------------------------------------------------------
  alias a1_psw_sb_show_animation show_animation
  def show_animation(targets, animation_id)
    targets.each {|target| on_target_window_open(target) }
    a1_psw_sb_show_animation(targets, animation_id)
  end
  #--------------------------------------------------------------------------
  # ○ ターゲットされた個別ステータスウィンドウをオープンする
  #--------------------------------------------------------------------------
  def on_target_window_open(target)
    disable_open_status(target.index) if target.actor? && target != @subject
  end
  #--------------------------------------------------------------------------
  # ○ 個別ステータスウィンドウをクローズして非選択状態にする
  #--------------------------------------------------------------------------
  def diseble_close_status(index)
    @status_windows[index].visible = false
    battle_members[index].visible =  false
    battle_members[index].opacity =  128
  end
  #--------------------------------------------------------------------------
  # ○ 個別ステータスウィンドウを非選択状態でオープン
  #--------------------------------------------------------------------------
  def disable_open_status(index)
    @status_windows[index].visible = true
    battle_members[index].visible  = true
    battle_members[index].opacity  = 128
  end
  #--------------------------------------------------------------------------
  # ○ 個別ステータスウィンドウを選択状態でオープン
  #--------------------------------------------------------------------------
  def enable_open_status(index)
    @status_windows[index].visible = true
    battle_members[index].visible  = true
    battle_members[index].opacity  = 255
  end
  #--------------------------------------------------------------------------
  # ○ 自動回復したアクターのウィンドウをオープン
  #--------------------------------------------------------------------------
  def show_regenerate_actor(actors_index)
    actors_index.each {|index| enable_open_status(index) }
  end
  #--------------------------------------------------------------------------
  # ○ 個別ステータスウィンドウのクローズ
  #--------------------------------------------------------------------------
  def close_status_windows
    battle_members.each_with_index {|actor, i| actor_visible(false, i, actor) }
  end
  #--------------------------------------------------------------------------
  # ○ 可視状態設定してウィンドウ位置を戻す
  #--------------------------------------------------------------------------
  def actor_visible(flag, i, actor)
    actor.visible = flag;
    @status_windows.visible = flag
    return_window(actor)
  end
  #--------------------------------------------------------------------------
  # ☆ ステータスウィンドウが更新された時の処理
  #--------------------------------------------------------------------------
  alias a1_psw_sb_update_status_window update_status_window
  def update_status_window
    a1_psw_sb_update_status_window
    @status_windows.each {|window| window.update }
  end
  #--------------------------------------------------------------------------
  # ☆ ステータスウィンドウが解放された時の処理
  #--------------------------------------------------------------------------
  alias a1_psw_sb_dispose_status_window dispose_status_window
  def dispose_status_window
    a1_psw_sb_dispose_status_window
    @status_windows.each {|window| window.dispose }
  end
  #--------------------------------------------------------------------------
  # ☆ 次のコマンド入力への前処理
  #--------------------------------------------------------------------------
  alias a1_psw_sb_prev_next_command prev_next_command
  def prev_next_command
    a1_psw_sb_prev_next_command
    disable_status_window(BattleManager.actor) if BattleManager.actor
  end
  #--------------------------------------------------------------------------
  # ☆ 次のコマンド入力への後処理
  #--------------------------------------------------------------------------
  alias a1_psw_sb_post_next_command post_next_command
  def post_next_command
    a1_psw_sb_post_next_command
    move_up_status_window(BattleManager.actor) if BattleManager.actor
  end
  #--------------------------------------------------------------------------
  # ○ 前のコマンド入力への前処理
  #--------------------------------------------------------------------------
  alias a1_psw_sb_prev_prior_command prev_prior_command
  def prev_prior_command
    a1_psw_sb_prev_prior_command
    disable_status_window(BattleManager.actor) if BattleManager.actor
  end
  #--------------------------------------------------------------------------
  # ☆ 前のコマンド入力への後処理
  #--------------------------------------------------------------------------
  alias a1_psw_sb_post_prior_command post_prior_command
  def post_prior_command
    a1_psw_sb_post_prior_command
    move_up_status_window(BattleManager.actor) if BattleManager.actor
  end
  #--------------------------------------------------------------------------
  # ○ 個別ステータスウィンドウを非選択状態にする
  #--------------------------------------------------------------------------
  def disable_status_window(actor)
    actor.opacity = 128
    return_window(actor)
  end
  #--------------------------------------------------------------------------
  # ○ 個別ステータスウィンドウを選択状態にする
  #--------------------------------------------------------------------------
  def move_up_status_window(actor)
    actor.opacity = 255
    @status_windows[actor.index].move_up if FACE_MODE || actor.battler_name.empty?
  end
  #--------------------------------------------------------------------------
  # ○ 個別ステータスウィンドウを定位置に戻す
  #--------------------------------------------------------------------------
  def return_window(actor)
    @status_windows[actor.index].move_return if FACE_MODE || actor.battler_name.empty?
  end
  #--------------------------------------------------------------------------
  # ○ 個別ステータスウィンドウをリフレッシュ
  #--------------------------------------------------------------------------
  def refresh_status_windows
    @status_windows.each {|window| window.refresh }
  end
  #--------------------------------------------------------------------------
  # ○ アクターの選択
  #--------------------------------------------------------------------------
  def select_actor(index)
    @spriteset.cursor.target = battle_members[index]
  end
  #--------------------------------------------------------------------------
  # ○ アクターの選択の終了
  #--------------------------------------------------------------------------
  def select_actor_end
    @spriteset.cursor.target = nil
  end
  #--------------------------------------------------------------------------
  # ○ 敵の選択
  #--------------------------------------------------------------------------
  def select_enemy(index)
    @spriteset.cursor.target = @enemy_window.enemy
  end
  #--------------------------------------------------------------------------
  # ○ 敵の選択の終了
  #--------------------------------------------------------------------------
  def select_enemy_end
    @spriteset.cursor.target = nil
  end
  #--------------------------------------------------------------------------
  # ○ バトラースプライトの変更
  #--------------------------------------------------------------------------
  def change_battler_sprite(member)
    @spriteset.actor_sprite[member.index] ||= @spriteset.add_actor_sprite(member.index, member)
    @spriteset.actor_sprite[member.index].battler = member
  end
  #--------------------------------------------------------------------------
  # ☆ バトルメンバー追加の後処理
  #--------------------------------------------------------------------------
  alias a1_psw_sb_post_add_battler post_add_battler
  def post_add_battler(member)
    a1_psw_sb_post_add_battler(member)
    battle_members.each {|member| recreate_status_windows(member) }
  end
  #--------------------------------------------------------------------------
  # ○ 個別ステータスウィンドウを再作成する
  #--------------------------------------------------------------------------
  def recreate_status_windows(member)
    @status_windows[member.index].dispose if @status_windows[member.index]
    setup_status_windows(member.index, member)
    change_battler_sprite(member)
  end
  #--------------------------------------------------------------------------
  # ☆ バトルメンバー削除の前処理
  #--------------------------------------------------------------------------
  alias a1_psw_sb_prev_remove_battler prev_remove_battler
  def prev_remove_battler(member)
    a1_psw_sb_prev_remove_battler(member)
    delete_actor_sprite(member.index)
  end
  #--------------------------------------------------------------------------
  # ○ 削除するメンバーの個別バトルステータスウィンドウとスプライトを解放
  #--------------------------------------------------------------------------
  def delete_actor_sprite(index)
    @spriteset.actor_sprite[index].battler.battler_name = ""
    @status_windows[index].dispose
    @status_windows.delete_at(index)
  end
#==============================================================================
# ■ フェイスステータスウィンドウ対応処理
#==============================================================================
  if $imported["A1_FaceStatusWindow"]
  #--------------------------------------------------------------------------
  # ☆ 個人ステータスウィンドウのアクター設定(エイリアスを取って潰す)
  #--------------------------------------------------------------------------
  alias a1_psw_sb_setup_personal_status_actor setup_personal_status_actor
  def setup_personal_status_actor
  end;end
#==============================================================================
# ■ 戦闘中入れ替え対応処理
#==============================================================================
  if $imported["A1_ChangeMember"]
  #--------------------------------------------------------------------------
  # ○ 入れ替え
  #--------------------------------------------------------------------------
  alias a1_psw_command_member_change command_member_change
  def command_member_change
    battle_members.each {|actor| close_status_windows }
    a1_psw_command_member_change
  end
  #--------------------------------------------------------------------------
  # ☆ メンバーチェンジ[キャンセル]
  #--------------------------------------------------------------------------
  alias a1_psw_on_member_change_cancel on_member_change_cancel
  def on_member_change_cancel
    a1_psw_on_member_change_cancel
    battle_members.each {|member| member_change_refresh(member) }
  end
  #--------------------------------------------------------------------------
  # ○ メンバーチェンジリフレッシュ
  #--------------------------------------------------------------------------
  def member_change_refresh(member)
    recreate_status_windows(member)
    enable_open_status(member.index)
  end;end
end
#==============================================================================
# ■ Sprite_BattleCursor
#==============================================================================

class Sprite_BattleCursor < Sprite_Base
  #--------------------------------------------------------------------------
  # ○ 定数
  #--------------------------------------------------------------------------
  FACE_MODE     = A1_System::PersonalBattleStatusConfig::FACE_MODE
  FONT_NAME     = "VL-Gothic-Regular"
  FONT_SIZE     = 32
  DEFAULT_COLOR = Color.new(255,0,255)
  #--------------------------------------------------------------------------
  # ○ 公開インスタンス変数
  #--------------------------------------------------------------------------
  attr_accessor :target
  #--------------------------------------------------------------------------
  # ○ オブジェクト初期化
  #--------------------------------------------------------------------------
  def initialize(color = DEFAULT_COLOR)
    super(nil)
    @color = color
    create_bitmap
    self.visible = false
    self.z = 10
    @target = nil
    @plus_x = 0
    @plus_y = 0
  end
  #--------------------------------------------------------------------------
  # ○ ビットマップ作成
  #--------------------------------------------------------------------------
  def create_bitmap
    text = "▼"
   
    # 計算用ダミービットマップ
    bitmap = Cache.system("")
    bitmap.font.name = FONT_NAME
    bitmap.font.size = FONT_SIZE
    tw = bitmap.text_size(text).width + 8
   
    # ビットマップ作成
    bitmap = Bitmap.new(tw, (bitmap.font.size + 4) * text.size * 1.5)
    bitmap.font.name = FONT_NAME
    bitmap.font.size = FONT_SIZE
    bitmap.font.color = @color
    bitmap.draw_text_f(0, 0, bitmap.width, bitmap.height, text, 2, Color.new(0,0,0))
   
    # スプライト設定
    self.bitmap = bitmap
    self.ox = bitmap.width / 2
    self.oy = bitmap.height / 2
  end
  #--------------------------------------------------------------------------
  # ○ x座標補正値の設定
  #--------------------------------------------------------------------------
  def plus_x=(x)
    @plus_x = x
  end
  #--------------------------------------------------------------------------
  # ○ y座標補正値の設定
  #--------------------------------------------------------------------------
  def plus_y=(y)
    @plus_y = y
  end
  #--------------------------------------------------------------------------
  # ○ フレーム更新
  #--------------------------------------------------------------------------
  def update
    self.visible = @target ? true : false
    return unless @target
    super
    self.x = @target.screen_x + @plus_x
    self.y = @target.screen_y - @target.battler_height + @plus_y
    self.y = @target.screen_y - 96 if @target.actor? && (FACE_MODE || @target.battler_name.empty?)
  end
end
#==============================================================================
# ■ Spriteset_Battle
#------------------------------------------------------------------------------
#  バトル画面のスプライトをまとめたクラスです。このクラスは Scene_Battle クラ
# スの内部で使用されます。
#==============================================================================

class Spriteset_Battle
  #--------------------------------------------------------------------------
  # ☆ オブジェクト初期化
  #--------------------------------------------------------------------------
  alias a1_psw_spsb_initialize initialize
  def initialize
    create_cursor_sprite
    a1_psw_spsb_initialize
  end
  #--------------------------------------------------------------------------
  # ○ カーソルスプライトの作成
  #--------------------------------------------------------------------------
  def create_cursor_sprite
    @cursor_sprite = Sprite_BattleCursor.new
  end
  #--------------------------------------------------------------------------
  # ○ アクタースプライト
  #--------------------------------------------------------------------------
  def actor_sprite
    return @actor_sprites
  end
  #--------------------------------------------------------------------------
  # ☆ フレーム更新
  #--------------------------------------------------------------------------
  alias a1_psw_spsb_update update
  def update
    a1_psw_spsb_update
    update_cursor
  end
  #--------------------------------------------------------------------------
  # ○ カーソルスプライトの更新
  #--------------------------------------------------------------------------
  def update_cursor
    @cursor_sprite.update
  end
  #--------------------------------------------------------------------------
  # ○ カーソルスプライトの取得
  #--------------------------------------------------------------------------
  def cursor
    @cursor_sprite
  end
  #--------------------------------------------------------------------------
  # ★ アクタースプライトの作成
  #--------------------------------------------------------------------------
  def create_actors
    @actor_sprites = []
    $game_party.battle_members.each {|actor| @actor_sprites.push(Sprite_Battler.new(@viewport1, actor)) }
  end
  #--------------------------------------------------------------------------
  # ○ カーソルの解放
  #--------------------------------------------------------------------------
  def add_actor_sprite(index, actor)
    @actor_sprites[index] = Sprite_Battler.new(@viewport1, actor)
  end
  #--------------------------------------------------------------------------
  # ★ アクタースプライトの更新
  #--------------------------------------------------------------------------
  def update_actors
    @actor_sprites.each {|sprite| sprite.update }
  end
  #--------------------------------------------------------------------------
  # ☆ 解放
  #--------------------------------------------------------------------------
  alias a1_psw_spsb_dispose dispose
  def dispose
    a1_psw_spsb_dispose
    dispose_cursor
  end
  #--------------------------------------------------------------------------
  # ○ カーソルの解放
  #--------------------------------------------------------------------------
  def dispose_cursor
    @cursor_sprite.dispose
  end
end
#==============================================================================
# ■ Game_Battler
#------------------------------------------------------------------------------
#  スプライトや行動に関するメソッドを追加したバトラーのクラスです。このクラス
# は Game_Actor クラスと Game_Enemy クラスのスーパークラスとして使用されます。
#==============================================================================

class Game_Battler < Game_BattlerBase
  #--------------------------------------------------------------------------
  # ○ バトラーの高さを取得
  #--------------------------------------------------------------------------
  def battler_height
    @battler_height ||= 0
    return @battler_height
  end
  #--------------------------------------------------------------------------
  # ○ バトラーの高さを設定
  #--------------------------------------------------------------------------
  def battler_height=(height)
    @battler_height = height
  end
#==============================================================================
# ■ ダメージポップアップ対応処理
#==============================================================================
  if $imported["A1_DamagePopUp"]
  #--------------------------------------------------------------------------
  # ○ ポップアップのセットアップ
  #--------------------------------------------------------------------------
  alias a1_psw_gbt_setup_popup setup_popup
  def setup_popup(kind)
    BattleManager.regenerate_actor.push(self.index) unless BattleManager.regenerate_actor.include?(self.index)
    a1_psw_gbt_setup_popup(kind)
  end;end
end
#==============================================================================
# ■ Sprite_Battler
#------------------------------------------------------------------------------
#  バトラー表示用のスプライトです。Game_Battler クラスのインスタンスを監視し、
# スプライトの状態を自動的に変化させます。
#==============================================================================

class Sprite_Battler < Sprite_Base
  #--------------------------------------------------------------------------
  # ☆ オブジェクト初期化
  #--------------------------------------------------------------------------
  alias a1_psw_spb_initialize initialize
  def initialize(viewport, battler = nil)
    a1_psw_spb_initialize(viewport, battler)
    setup_battler_info
  end
  #--------------------------------------------------------------------------
  # ○ バトラー情報のセットアップ
  #--------------------------------------------------------------------------
  def setup_battler_info
    return unless @battler
    @battler.battler_height = self.height
  end
  #--------------------------------------------------------------------------
  # ☆ 転送元ビットマップの更新
  #--------------------------------------------------------------------------
  alias a1_psw_spb_update_bitmap update_bitmap
  def update_bitmap
    return update_bitmap_actor if @battler.actor?
    a1_psw_spb_update_bitmap
  end
  #--------------------------------------------------------------------------
  # ○ アクター用転送元ビットマップの更新
  #--------------------------------------------------------------------------
  def update_bitmap_actor
    self.opacity = @battler.opacity
    self.visible = @battler.visible
    return unless update_bitmap?
    return self.bitmap = nil if @battler.battler_name.empty?
    new_bitmap   = Cache.picture(@battler.battler_name)
    @prev_battler_name = @battler.battler_name
    self.bitmap = new_bitmap
    @battler.sprite_height = self.bitmap.height
    setup_battler_info
  end
  #--------------------------------------------------------------------------
  # ○ アクターのビットマップをアップデートするか判断
  #--------------------------------------------------------------------------
  def update_bitmap?
    return false if @battler.battler_name == @prev_battler_name
    return false if @battler.battler_name.empty?
    return true
  end
  #--------------------------------------------------------------------------
  # ☆ 可視状態の初期化
  #--------------------------------------------------------------------------
  alias a1_psw_spb_init_visibility init_visibility
  def init_visibility
    a1_psw_spb_init_visibility
    setup_battler_info
  end
  #--------------------------------------------------------------------------
  # ○ アクターの空Bitmapのセットアップ
  #--------------------------------------------------------------------------
  def setup_empty_actor_bitmap(width, height)
    self.bitmap = Bitmap.new(width, height)
  end
end
#==============================================================================
# ■ Game_Actor
#------------------------------------------------------------------------------
#  アクターを扱うクラスです。このクラスは Game_Actors クラス($game_actors)
# の内部で使用され、Game_Party クラス($game_party)からも参照されます。
#==============================================================================

class Game_Actor < Game_Battler
  #--------------------------------------------------------------------------
  # ○ 定数
  #--------------------------------------------------------------------------
  FACE_MODE = A1_System::PersonalBattleStatusConfig::FACE_MODE
  #--------------------------------------------------------------------------
  # ○ 公開インスタンス変数
  #--------------------------------------------------------------------------
  attr_accessor :screen_x
  attr_accessor :screen_y
  attr_accessor :screen_z
  attr_accessor :opacity
  attr_accessor :visible
  attr_accessor :use_sprite
  attr_accessor :sprite_height
  attr_accessor :battler_name
  #--------------------------------------------------------------------------
  # ☆ セットアップ
  #--------------------------------------------------------------------------
  alias a1_psw_setup setup
  def setup(actor_id)
    a1_psw_setup(actor_id)
    @screen_x      = 0
    @screen_y      = 0
    @screen_z      = 0
    @opacity       = 255
    @visible       = true
    @sprite_height = 0
    @battler_name  = FACE_MODE ? "" : actor.battler_name
    @use_sprite    = @battler_name.empty? ? false : true
  end
  #--------------------------------------------------------------------------
  # ★ スプライトを使うか?
  #--------------------------------------------------------------------------
  def use_sprite?
    @use_sprite
  end
end
#==============================================================================
# ■ Window_BattleEnemy
#------------------------------------------------------------------------------
#  バトル画面で、行動対象の敵キャラを選択するウィンドウです。
#==============================================================================

class Window_BattleEnemy < Window_Selectable
  #--------------------------------------------------------------------------
  # ☆ ウィンドウの非表示
  #--------------------------------------------------------------------------
  alias a1_psw_wbe_hide hide
  def hide
    @help_window.close
    a1_psw_wbe_hide
  end
  #--------------------------------------------------------------------------
  # ○ カーソルの移動処理
  #--------------------------------------------------------------------------
  def process_cursor_move
    return unless cursor_movable?
    last_index = @index
    cursor_down (Input.trigger?(:DOWN))  if Input.repeat?(:DOWN)
    cursor_up   (Input.trigger?(:UP))    if Input.repeat?(:UP)
    cursor_down (Input.trigger?(:RIGHT)) if Input.repeat?(:RIGHT)
    cursor_up   (Input.trigger?(:LEFT))  if Input.repeat?(:LEFT)
    Sound.play_cursor if @index != last_index
  end
  #--------------------------------------------------------------------------
  # ○ ヘルプテキスト更新
  #--------------------------------------------------------------------------
  def update_help
    @help_window.draw_center_text(enemy.name)
  end
  #--------------------------------------------------------------------------
  # ○ ヘルプウィンドウの設定
  #--------------------------------------------------------------------------
  def help_window=(window)
    @help_window = window
    @help_window.height = fitting_height(1)
    @help_window.create_contents
  end
  #--------------------------------------------------------------------------
  # ○ ウィンドウのアクティブ化
  #--------------------------------------------------------------------------
  def activate
    @help_window.open
    super
  end
  #--------------------------------------------------------------------------
  # ★ 桁数の取得
  #--------------------------------------------------------------------------
  def col_max
    return 1
  end
end
#==============================================================================
# ■ Window_BattleActor
#------------------------------------------------------------------------------
#  バトル画面で、行動対象のアクターを選択するウィンドウです。
#==============================================================================

class Window_BattleActor < Window_BattleStatus
  #--------------------------------------------------------------------------
  # ☆ ウィンドウの非表示
  #--------------------------------------------------------------------------
  alias a1_psw_wba_hide hide
  def hide
    @help_window.close
    a1_psw_wba_hide
  end
  #--------------------------------------------------------------------------
  # ○ カーソルの移動処理
  #--------------------------------------------------------------------------
  def process_cursor_move
    return unless cursor_movable?
    last_index = @index
    cursor_down (Input.trigger?(:DOWN))  if Input.repeat?(:DOWN)
    cursor_up   (Input.trigger?(:UP))    if Input.repeat?(:UP)
    cursor_down (Input.trigger?(:RIGHT)) if Input.repeat?(:RIGHT)
    cursor_up   (Input.trigger?(:LEFT))  if Input.repeat?(:LEFT)
    Sound.play_cursor if @index != last_index
  end
  #--------------------------------------------------------------------------
  # ○ アクターオブジェクト取得
  #--------------------------------------------------------------------------
  def actor
    $game_party.battle_members[@index]
  end
  #--------------------------------------------------------------------------
  # ○ ヘルプテキスト更新
  #--------------------------------------------------------------------------
  def update_help
    @help_window.draw_center_text(actor.name)
  end
  #--------------------------------------------------------------------------
  # ○ ヘルプウィンドウの設定
  #--------------------------------------------------------------------------
  def help_window=(window)
    @help_window = window
    @help_window.height = fitting_height(1)
    @help_window.create_contents
  end
  #--------------------------------------------------------------------------
  # ○ ウィンドウのアクティブ化
  #--------------------------------------------------------------------------
  def activate
    @help_window.open
    super
  end
end
end[/pre]

サイドビューバトルアクション設定
[pre lang="ruby"]#===========================================================================
# ◆ A1 Scripts ◆
#    サイドビューバトルアクション設定(RGSS3)
#
# バージョン   : 1.10 (2012/01/17)
# 作者         : A1
# URL     : http://a1tktk.web.fc2.com/
#---------------------------------------------------------------------------
# 機能:
# ・パトラッシュ・・・僕はもう疲れたよ・・・
#---------------------------------------------------------------------------
# 更新履歴   :2012/01/16 Ver1.00 リリース
#            :2012/01/17 Ver1.10 防御待機追加
#---------------------------------------------------------------------------
# 設置場所      
#    フェイスステータスウィンドウ以下
#    個別バトルステータスウィンドウ以下
#    バトルアクション以下
#    (リザルトウィンドウ以下)
#    (ダメージポップアップ以下)
#    (Audioフェードイン以下)
#
# 必要スクリプト
#    フェイスステータスウィンドウスクリプト
#    個別バトルステータスウィンドウスクリプト
#    バトルアクションスクリプト
#---------------------------------------------------------------------------
# 使い方
#   ■ サイドビューアクション設定 に設定します
#
#   個別バトルステータスウィンドウのフォントサイズは
#   個別バトルステータスウィンドウスクリプトののフォントサイズ依存になりました
#
#   二刀流の攻撃力補正値は撤廃になりました
#   設定する際は「装備拡張」スクリプトが必要になります
#---------------------------------------------------------------------------
# 注意
#   このスクリプトは「個別バトルステータスウィンドウ」のFACEモードを無効化します
#   FACEモード時での動作は保証できませんので、FACEモードは false で使用してください
#==============================================================================
$imported ||= {}
if $imported["A1_PersonalBattleStatus"] && $imported["A1_FaceStatusWindow"] && $imported["A1_BattleAction"]
$imported["A1_SideViewBattleConfig"] = true
old_common_script("サイドビューバトル", "4.20") if common_version < 4.20
#==============================================================================
# ■ サイドビューアクション設定
#==============================================================================
module A1_System::SideViewActionConfig
  #--------------------------------------------------------------------------
  # 戦闘画面突入時の位置
  #--------------------------------------------------------------------------
  INTT_POS     = [ [758, 152], [774, 208], [790, 264], [806, 320], [822, 376] ]
  #--------------------------------------------------------------------------
  # 戦闘中の定位置
  #--------------------------------------------------------------------------
  STANDARD_POS = [ [472, 250], [488, 304], [504, 364], [520, 418], [536, 476] ]
  #--------------------------------------------------------------------------
  # 個別バトルステータスウィンドウの位置
  #--------------------------------------------------------------------------
  WINDOW_POS   = [ [488, 181], [504, 237], [520, 293], [536, 349], [552, 405] ]
  #--------------------------------------------------------------------------
  # 敵のy座標補正値(+方向で画面下方に補正)
  #--------------------------------------------------------------------------
  TROOP_COMP_Y = 96
  #--------------------------------------------------------------------------
  # 二刀流時のTP増加量補正値(倍率)
  #--------------------------------------------------------------------------
  TSS_TP_RATE  = 0.5
  #--------------------------------------------------------------------------
  # 各アクションのメソッドシンボル
  #   それぞれのアクションは、Game_Battler クラスのメソッドが呼ばれます
  #   この項目にメソッドを追加することで、アクションを追加できます(上級者向け)
  #
  #   アクションを呼ぶ時は メソッドキー[引数1,引数2・・・] と記述し
  #   メソッドは シンボル(params) で、params に引数が配列として渡されます
  #--------------------------------------------------------------------------
  ACTION_SYMBOL = {
  #--------------------------------------------------------------------------
  # 移動[params, ジャンプ]:移動アクションです
  #      params   定位置[duration, wait]     定位置に戻ります
  #               前進[duration, wait]       1歩前に移動します
  #               後退[duration, wait]       1歩後に移動します
  #               対象[duration, wait]       対象まで移動します
  #               敵中心[duration, wait]     敵の中心まで移動します(アクター限定)
  #               相対[x, y, duration, wait] x y で指定した相対座標まで移動します
  #               絶対[x, y, duration, wait] x y で指定した絶対座標まで移動します
  #
  #               duration:移動にかける時間(フレーム数)
  #               wait 移動完了までウェイト 省略すると待ちません
  #
  #     ジャンプ 移動をジャンプで行います
  #               duration の値が大きいほど高くジャンプします
  #--------------------------------------------------------------------------
  "移動"     => :move_pos,
  #--------------------------------------------------------------------------
  # 直立[params]  歩行アニメーションの有無を設定するアクションです
  #
  #      params   予約 アクション終了後に直立します
  #               解除 歩行アニメーションを再開します
  #
  #      params を省略し 直立 とすると、即座に直立します
  #--------------------------------------------------------------------------
  "直立"     => :set_pattern_fix,
  #--------------------------------------------------------------------------
  # 武器[action]  武器アクションを実行します
  #               詳しくは「武器アクション」参照
  #--------------------------------------------------------------------------
  "武器"     => :weapon_action,
  #--------------------------------------------------------------------------
  # 実行[skip]    スキル/アイテムを実行します
  #
  #      skip     実行終了を待たずに次のアクションに進みます
  #      skip を省略し 実行 とすると、スキル実行終了まで待ちます
  #--------------------------------------------------------------------------
  "実行"     => :proc_use_item,
  #--------------------------------------------------------------------------
  # アニメ[id,skip]  アニメーションを表示します
  #
  #        id        表示するアニメーションIDを指定します
  #        skip      アニメーションの終了を待ちません 省略可
  #--------------------------------------------------------------------------
  "アニメ"   => :proc_animation,
  #--------------------------------------------------------------------------
  # 向き[direction, pattern]
  #                 キャラクターの向きを設定します(アクター専用)
  #
  #      direction  上 下 左 右 で設定します
  #      pattern    0 ~ 2 の値でパターンを設定します 省略可
  #--------------------------------------------------------------------------
  "向き"     => :change_direction,
  #--------------------------------------------------------------------------
  # キャラ[params] キャラクターアクションを実行します
  #                詳しくはキャラクターアクションを参照のこと
  #--------------------------------------------------------------------------
  "キャラ"   => :character_action,
  #--------------------------------------------------------------------------
  # 状態[params] ステートアクションを実行します
  #              詳しくはステートアクションを参照のこと
  #--------------------------------------------------------------------------
  "状態"     => :state_action,
  #--------------------------------------------------------------------------
  # 派生[action] アクションを派生させます
  #               
  #      action  記述したアクション名のアクションに派生し、戻ってきます
  #               
  # 派生[スキル[id]]
  # 派生[アイテム[id]]
  #
  #      指定した id のスキル/アイテムに派生し、派生先で終了します
  #--------------------------------------------------------------------------
  "派生"     => :next_action,
  #--------------------------------------------------------------------------
  # 条件[condition, not] 条件を判断し、false の場合次のアクションを飛ばします
  #
  #      condition  二刀流             二刀流で両手に武器を持っている場合 true を返します
  #                 スキル使用可[id]   id のスキルが使用可の場合 true を返します
  #                 アイテム使用可[id] id のアイテムが使用可の場合 true を返します
  #                 対象生存           攻撃対象のいずれかが生存している場合 true を返します
  #
  #      not        条件を反転させ、true の場合に次のアクションを飛ばします 省略可
  #
  # その他の条件は、アクション「条件」の追加項目 参照のこと
  #--------------------------------------------------------------------------
  "条件"     => :next_condition,
  #--------------------------------------------------------------------------
  # G変更[c_info, direction, pattern, pattern_fix]
  #      キャラクターのグラフィックを変更します(アクター専用)
  #            
  #      c_info データベース「アクター」のメモ欄に設定したグラフィックを指定します
  #        <サブ1 Actor4_ex,  7> と設定した場合 サブ1 を指定します
  #        <サブ3 Actor4_ex2, 7> と設定した場合 サブ3 を指定します
  #        データベースの設定は、名前の重複がなければ複数可
  #
  #      direction 向きを 上 下 左 右 で指定します
  #
  #      pattern     0 ~ 2 の値でパターンを設定します 省略可
  #
  #      pattern_fix 固定 とするとパターンを固定します
  #--------------------------------------------------------------------------
  "G変更"    => :change_graphic,
  #--------------------------------------------------------------------------
  # コラプス[許可] コラプスエフェクトを許可します
  #--------------------------------------------------------------------------
  "コラプス" => :set_collapse,
  #--------------------------------------------------------------------------
  # 繰り返し[num] num の回数だけ次のアクションを繰り返します
  #--------------------------------------------------------------------------
  "繰り返し" => :repeat_action,
  #--------------------------------------------------------------------------
  # ピクチャ[action] ピクチャの操作を行います
  #                  詳しくはピクチャ操作を参照のこと
  #--------------------------------------------------------------------------
  "ピクチャ" => :picture_action,
  #--------------------------------------------------------------------------
  # 同時[action, member] 複数キャラクターを同時に行動させます
  #
  #      action 行動させるアクションを指定します
  #      member Index[no,no,...]    指定したIndexのメンバーを同時に行動させます
  #             名前[name,name,...] 指定した名前のメンバーを同時に行動させます(アクター専用)
  #
  #      member を省略すると全員が同時に行動します
  #--------------------------------------------------------------------------
  "同時"     => :parallel_action,
  #--------------------------------------------------------------------------
  # 中断  アクションを中断します
  #
  #   派生アクション中(スキル/アイテム指定除く)は 派生アクションを中断して
  #   親アクションに戻ります
  #
  #   親アクション中に中断すると、定位置に戻ります
  #--------------------------------------------------------------------------
  "中断"     => :break_action,
  #--------------------------------------------------------------------------
  # ダメージ ダメージを与えます
  #--------------------------------------------------------------------------
  "ダメージ" => :proc_damage,
  #--------------------------------------------------------------------------
  # Audio オーディオを操作します
  #
  #   Audio[BGM[name, volume, pitch], 停止]
  #   Audio[BGS[name, volume, pitch], 停止]
  #   Audio[ME[name, volume, pitch], 停止]
  #   Audio[SE[name, volume, pitch], 停止]
  #
  #     各種Audioの演奏/停止を行います
  #     停止 を省略すると 演奏します
  #
  #   Audio[BGM[フェードアウト, duration]]
  #   Audio[BGS[フェードアウト, duration]]
  #
  #     BGMやBGSを duration の時間をかけてフェードアウトします
  #     duration は ミリ秒 単位で設定します
  #
  #   Audio[BGM[フェードイン, volume, duration]]
  #   Audio[BGS[フェードイン, volume, duration]]
  #
  #     BGMやBGSを duration の時間をかけて volume までフェードインします
  #     duration は ミリ秒 単位で設定します
  #
  #     フェードイン機能は「Audioフェードイン」スクリプトが必要です
  #--------------------------------------------------------------------------
  "Audio"      => :audio_action,
  "使用武器"   => :use_weapon_pos,
  }
  #--------------------------------------------------------------------------
  # アクション内容
  #--------------------------------------------------------------------------
  ACTION_LIST = {
  #--------------------------------------------------------------------------
  # プリセットアクション
  #   ※ 内容の変更はOK、項目名を変更するとエラー発生
  #--------------------------------------------------------------------------
  "戦闘開始の登場"     => ["状態","条件[自身生存]","移動[定位置[30],ジャンプ]"],
  "コマンド選択開始"   => ["状態","移動[前進[10]]","直立[予約]","ピクチャ[表示[<s>@name</s>立ち絵]]","ピクチャ[移動[立ち絵移動]]"],
  "コマンド選択終了"   => ["ピクチャ[消去[1]]","状態","移動[定位置[10]]","状態[待機]","直立[解除]"],
  "勝利アクション"     => ["同時[勝利アクション実行]"],
  "勝利アクション実行" => ["状態[通常]","キャラ[高速回転l]","移動[{高ジャンプ}]", "キャラ[左を向く]", 5, "移動[{高速画面外}]"],
  "初期位置にジャンプ" => ["移動[初期位置[30],ジャンプ]"],
  "逃げる"             => ["同時[逃げる実行]"],
  "逃げる実行"         => ["条件[自身生存]","向き[右]","移動[{逃げる画面外}]"],
  "逃げる失敗"         => ["同時[逃げる失敗戻り]"],
  "逃げる失敗戻り"     => ["条件[自身生存]","向き[左]","移動[{帰還}]"],
  
  "回避アクション"     => ["移動[{小J始}]","移動[{小J終}]","移動[{回避戻り}]"],
  "敵回避アクション"   => ["移動[{敵小J始}]","移動[{敵小J終}]","派生[帰還]"],
  "ダメージアクション" => ["移動[{ダメージ}]","移動[{帰還}]"],
  "状態変化アクション" => ["状態"],
  "帰還"               => ["条件[自身生存]","移動[{帰還}]","状態"],
  "カウンターダメージ" => ["移動[{ダメージ}]","移動[{対象w}]"],
  "回復アクション"     => ["状態","移動[{帰還}]"],
  "身代わり動作"       => ["移動[身代わり[10w]]"],
  "身代わられ動作"     => ["移動[後退[10]]"],
  "身代わりダメージ"   => ["移動[{ダメージ}]","移動[{ダメージ戻り}]",10,"同時[同時帰還]"],
  "身代わり回避"       => ["移動[{小J始}]","移動[{小J終}]","移動[{回避戻り}]",10,"同時[同時帰還]"],
  "同時帰還"           => ["移動[{帰還}]"],
  
  "通常攻撃"           => ["移動[{対象w}]","直立","派生[武器振り実行]","条件[二刀流]","派生[二刀流攻撃]","派生[行動終了]"],
  "武器振り実行"       => ["武器[振り]","実行"],
  "二刀流攻撃"         => ["条件[対象生存, not]","中断","武器[振り]","使用武器[左]","実行"],
  "防御"               => ["実行"],
  "汎用スキル使用"     => ["移動[前進[{10w}]]","武器[掲げ]","アニメ[{詠唱}]",15,"武器[振り]","実行","派生[行動終了]"],
  "汎用アイテム使用"   => ["移動[前進[{10w}]]","武器[振り]","実行","派生[行動終了]"],
  "行動終了"           => ["コラプス[許可]","派生[帰還]"],
  #--------------------------------------------------------------------------
  # スキルアクション
  #
  #   データベース「スキル」「アイテム」「武器」のメモ欄に
  #   <SVアクション アクション名> と記述すると
  #   以下で設定するアクションを実行します
  #
  #   また「バトルアクション」スクリプトで設定したアクションも有効です
  #   その場合、アクション「実行」時にバトルアクションのアクションを実行します
  #
  #   アクションを設定していないスキルは
  #   データベース「スキル」の「攻撃属性」が「通常攻撃」なら 通常攻撃 を
  #   「通常攻撃」以外なら 汎用スキル使用 を実行します
  #
  #   アクションを設定していないアイテムは 汎用アイテム使用 を実行します
  #
  #   スキル「防御」(スキルID 2) は 防御 を実行します
  #
  #   データベース「エネミー」のメモ欄に
  #   <エネミー武器 id> と記述すると
  #   エネミーの通常攻撃のアニメーションが指定した id の武器アニメーションになります
  #
  #   数字のみのアクションは 数字分のフレームウェイトします
  #--------------------------------------------------------------------------
  "桜花夢幻刃"         => ["移動[敵中心[{10w}]]","直立","武器[振り]","実行","派生[行動終了]"],
  "トリプルショット"   => ["移動[前進[{10w}]]","武器[振り]","実行","派生[スキル[109]]","派生[行動終了]"],
  "サウザンドアロー"   => ["移動[前進[{10w}]]","武器[振り]","実行","派生[行動終了]"],
  "三回攻撃"           => ["移動[{対象w}]","直立","繰り返し[3]","派生[武器振り実行]","派生[行動終了]"],
  "弓発射"             => ["移動[前進[{10w}]]",10,"アニメ[{弓発射}]",20,"実行","派生[行動終了]"],
  }
  #--------------------------------------------------------------------------
  # 汎用アクションパラメータ
  #
  #   {} で囲まれた部分は汎用アクションパラメータで設定した項目に置き換わります
  #   汎用アクションパラメータで{}を使うことも可能です
  #
  #   移動[{帰還}] としたアクションは
  #   移動[定位置[{10w}]] と記述するのと同じで、{10w}も汎用アクションパラメータなので
  #   移動[定位置[10,wait]] が最終的なアクションになります
  #--------------------------------------------------------------------------
  ACTION_PARAMS = {
  "ダメージ"       => "相対[32, 0, 5, wait]",
  "ダメージ戻り"   => "相対[-32, 0, 5, wait]",
  "回避戻り"       => "相対[-64, 0,10, wait]",
  "対象w"          => "対象[{10w}]",
  "詠唱"           => "44,自身,skip",
  "弓発射"         => "111,自身,skip",
  "帰還"           => "定位置[{10w}]",
  "10w"            => "10,wait",
  "5w"             => "5,wait",
  "高ジャンプ"     => "相対[0, 0, 30, wait],ジャンプ",
  "小J始"          => "相対[32, -32, 5, wait]",
  "小J終"          => "相対[32,  32, 5, wait]",
  "敵小J始"        => "相対[-32, -32, 5, wait]",
  "敵小J終"        => "相対[-32,  32, 5, wait]",
  "高速画面外"     => "絶対[-64, <s>@screen_y</s>, 20]",
  "逃げる画面外"   => "絶対[<s>Graphics.width + 64</s>, <s>@screen_y</s>, 10, wait]",
  "4方向高速回転"  => ["向き[左]", 2, "向き[上]", 2, "向き[右]", 2, "向き[下]", 2],
  }
  #--------------------------------------------------------------------------
  # アクション「条件」の追加項目(上級者向け)
  #
  #   条件[設定例] とした 設定例 の部分をハッシュのキーに
  #   <s>スクリプト</s> で記述したスクリプトを用いて条件を追加します
  #
  #   スクリプトの実行は Game_Battler クラスで行います
  #--------------------------------------------------------------------------
  CONDITION_LIST = {
  "設定例"    => "<s>@name == \"エリック\"</s>"
  }
  #--------------------------------------------------------------------------
  # ピクチャ操作
  #
  #   基本的にイベントコマンド「ピクチャの表示」「ピクチャの移動」・・・等に準拠します
  #
  #   ピクチャ名を「バトラー」にすると
  #   データベース「アクター」のメモ欄に <バトラー picture_name> とした
  #   ピクチャを表示します
  #
  #   「表示」「移動」「回転」「色調」全てこの項目で設定します
  #--------------------------------------------------------------------------
  PICTURE_PARAMS = {
                      # 番号, ピクチャ名,   原点,    x,  y, 横拡大, 縦拡大, 不透明度, 合成方法
  "エリック立ち絵"   => [1,   "バトラー", "左上", -300,  0,     50,     50,      255,    0],
  "アーネスト立ち絵" => [1,   "バトラー", "左上", -300,  0,     50,     50,      255,    0],
  "ブレンダ立ち絵"   => [1,   "バトラー", "左上", -300,  0,     50,     50,      255,    0],
  "アリス立ち絵"     => [1,   "バトラー", "左上", -300,  0,     50,     50,      255,    0],
  "イザベル立ち絵"   => [1,   "バトラー", "左上", -300,  0,     50,     50,      255,    0],
                      # 番号, 原点, x, y, 横拡大, 縦拡大, 不透明度, 合成方法, 時間
  "立ち絵移動"       => [1, "左上", 0, 0,     50,     50,      255,        0,   10],
  }
  #--------------------------------------------------------------------------
  # アクション対象のステート
  #
  #   アクション対象のステートです
  #   追加する場合、以下のステートアクションも設定すること
  #--------------------------------------------------------------------------
  STATE_LIST   = ["戦闘不能","毒"]
  #--------------------------------------------------------------------------
  # ステートアクション
  #
  #   アクション対象のステートにかかった時や
  #   待機時に実行するキャラクターアクションです
  #
  #   通常    :コマンド未入力時の状態です
  #   通常待機:「攻撃」「防御」「アイテム」時の待機状態です
  #   魔法待機:スキルタイプ「魔法」時の待機状態です
  #   特技待機:スキルタイプ「特技」時の待機状態です
  #
  #   「○○待機」とすることでスキルタイプに対応した待機状態になります
  #
  #   戦闘不能:ステート「戦闘不能」時の待機状態です
  #   毒      :ステート「毒」時の待機状態です
  #
  #   中断 を true にすると、アクション「状態」の後のアクションを中断します
  #   吹き出しを 1 以上にすると該当する吹き出しが表示されます
  #--------------------------------------------------------------------------
  STATE_ACTIONS = {
              # キャラクターアクション,中断, 吹き出し
  "通常"     => ["通常時",             false, 0],
  "通常待機" => ["左を向く",           false, 0],
  "魔法待機" => ["左を向く",           false, 0],
  "特技待機" => ["左を向く",           false, 0],
  "防御待機" => ["防御待機",           false, 0],
  "戦闘不能" => ["戦闘不能",           true,  0],
  "毒"       => ["左を向く",           false, 7],
  }
  #--------------------------------------------------------------------------
  # 武器アクション
  #
  #   武器(アイコン)に対してピクチャアクションを実行します
  #   キャラクターアクションを設定していると、キャラクターアクションを実行します
  #--------------------------------------------------------------------------
  WEAPN_ACTION = {
            # ピクチャアクション, キャラクターアクション
  "振り" => ["振り"],
  "掲げ" => ["掲げ"],
  }
  #--------------------------------------------------------------------------
  # キャラクターアクション
  #
  #   アクションには「汎用アクションパラメータ」を設定することが可能です
  #   ループを true にすると、一連のアクション終了後に最初にループします
  #
  #   ループすると、他のキャラクターアクションで上書きしない限り
  #   ループを続けます
  #
  #   ピクチャアクションを指定すると、ピクチャアクションを実行します
  #--------------------------------------------------------------------------
  CHARACTER_ACTION = {
                  # アクション,        ループ, ピクチャアクション
  "高速回転l"  => ["{4方向高速回転}",         true],
  "左を向く"   => [["向き[左]"],              false],
  "防御待機"   => [["向き[左]","直立[予約]"], false],
  "通常時"     => [["向き[左]","直立[解除]"], false, "通常"],
  "戦闘不能"   => [["向き[上]","直立"],       false, "戦闘不能"],
  }
  #--------------------------------------------------------------------------
  # ピクチャアクション
  #
  #   始 から 終 まで 時間 フレームかけて変化させていきます
  #   「回転」に限り、終 には 始 から見た回転角度を指定します
  #   -720 としたら、始 の角度から時計回りに720度(2回転)回転します
  #
  #   「色調」は配列で [red, green, blue, gray] を指定します
  #   gray は省略可
  #
  #   消去 を true にすると、時間 フレーム後に消えます
  #--------------------------------------------------------------------------
  PICTURE_ACTION = {
               # 始[x,  y, 回転, x拡大, y拡大, 色調, 透明], 終[  x,  y, 回転, x拡大, y拡大, 色調, 透明], 時間, 消去
  "振り"     => [[  0,-32,  -90,   100,   100,  nil,  255],   [-10,  0,  180,   100,   100,  nil,  255],  10, false],
  "掲げ"     => [[  0,-32,  -45,   100,   100,  nil,  255],   [  0,-32,    0,   100,   100,  nil,  255],  10, false],
  "戦闘不能" => [[  0,  0,  -90,   100,   100,  nil,  255],   [  0,  0,    0,   100,   100,  nil,  255],   1, false],
  "通常"     => [[  0,  0,    0,   100,   100,  nil,  255],   [  0,  0,    0,   100,   100,  nil,  255],   1, false],
  }
end
end[/pre]

サイドビューバトル
[pre lang="ruby"]#===========================================================================
# ◆ A1 Scripts ◆
#    サイドビューバトル基本スクリプト(RGSS3)
#
# バージョン   : 2.40 (2012/01/26)
# 作者         : A1
# URL     : http://a1tktk.web.fc2.com/
#---------------------------------------------------------------------------
# 機能:
# ・パトラッシュ・・・僕はもう疲れたよ・・・
#---------------------------------------------------------------------------
# 更新履歴   :2012/01/16 Ver1.00 リリース
#            :2012/01/17 Ver1.10 同時アクションの見直し
#            :2012/01/17 Ver1.10 防御待機追加
#            :2012/01/17 Ver1.10 陣形対応
#              :2012/01/17 Ver1.10 戦闘中入れ替え対応
#              :2012/01/18 Ver2.00 A1バトル共通スクリプト対応
#              :2012/01/18 Ver2.00 「逃げる」対応
#              :2012/01/18 Ver2.00 「身代わり」対応
#              :2012/01/18 Ver2.00 「反撃」「反射」対応
#              :2012/01/19 Ver2.10 パーティ加入/脱退対応
#              :2012/01/19 Ver2.10 イベントコマンド「注釈」からアクション発動実装
#              :2012/01/21 Ver2.20 全体通常攻撃対応
#              :2012/01/21 Ver2.20 装備拡張対応
#              :2012/01/24 Ver2.30 スキル拡張対応
#              :2012/01/24 Ver2.30 左利きの場合、左から攻撃するように変更
#              :2012/01/26 Ver2.40 スキル拡張の新機能対応
#---------------------------------------------------------------------------
# 設置場所      
#    サイドビューバトルアクション設定以下
#
# 必要スクリプト
#    サイドビューバトルアクション設定
#---------------------------------------------------------------------------
# 使い方
#   ■ サイドビューアクション設定 に設定します
#
#   バトル用イベントコマンド「注釈」に記述します
#
#     加入アクション アクション名
#     脱退アクション アクション名
#
#       次にメンバーが加入/脱退した時に行うアクションを指定します
#
#     アクション実行 index|アクター名 アクション名
#
#       戦闘時のIndexか、アクター名を指定して
#       指定したアクションを実行します
#
#       戦闘行動を伴うもの(攻撃など)は動作保証外です
#==============================================================================
$imported ||= {}
if $imported["A1_SideViewBattleConfig"]
$imported["A1_SideViewBattle"] = true
old_common_script("サイドビューバトル", "4.20") if common_version < 4.20
#==============================================================================
# ■ A1_System::SideViewAction
#==============================================================================

class A1_System::SideViewAction
  #--------------------------------------------------------------------------
  # ○ 公開インスタンス変数
  #--------------------------------------------------------------------------
  attr_reader   :action_list
  attr_reader   :action_params
  attr_reader   :action_symbol
  attr_reader   :weapon_action
  attr_reader   :character_action
  attr_reader   :state_actions
  attr_reader   :condition_list
  attr_reader   :picture_params
  #--------------------------------------------------------------------------
  # ○ オブジェクト初期化
  #--------------------------------------------------------------------------
  def initialize
    @action_list      = A1_System::SideViewActionConfig::ACTION_LIST
    @action_symbol    = A1_System::SideViewActionConfig::ACTION_SYMBOL
    @picture_action   = A1_System::SideViewActionConfig::PICTURE_ACTION
    @weapon_action    = A1_System::SideViewActionConfig::WEAPN_ACTION
    @character_action = A1_System::SideViewActionConfig::CHARACTER_ACTION
    @action_params    = A1_System::SideViewActionConfig::ACTION_PARAMS
    @state_actions    = A1_System::SideViewActionConfig::STATE_ACTIONS
    @condition_list   = A1_System::SideViewActionConfig::CONDITION_LIST
    @picture_params   = A1_System::SideViewActionConfig::PICTURE_PARAMS
    @action_cache     = {}
  end
  #--------------------------------------------------------------------------
  # ○ ピクチャアクション
  #--------------------------------------------------------------------------
  def picture_action(kind)
    key = "picture_#{kind}"
    @action_cache[key] ||= A1_System::SpriteAction.new(@picture_action[kind])
    return @action_cache[key]
  end
end
#==============================================================================
# ■ A1_System::SpriteAction
#==============================================================================

class A1_System::SpriteAction
  #--------------------------------------------------------------------------
  # ○ 公開インスタンス変数
  #--------------------------------------------------------------------------
  attr_reader   :st_x
  attr_reader   :st_y
  attr_reader   :st_angle
  attr_reader   :st_zoom_x
  attr_reader   :st_zoom_y
  attr_reader   :st_tone
  attr_reader   :st_opacity
  attr_reader   :ed_x
  attr_reader   :ed_y
  attr_reader   :ed_angle
  attr_reader   :ed_zoom_x
  attr_reader   :ed_zoom_y
  attr_reader   :ed_tone
  attr_reader   :ed_opacity
  attr_reader   :duration
  attr_reader   :erase
  #--------------------------------------------------------------------------
  # ○ オブジェクト初期化
  #--------------------------------------------------------------------------
  def initialize(info)
    action_start = info[0]
    action_end   = info[1]
    @duration    = info[2]
    @erase       = info[3]
    @st_x        = action_start[0]
    @st_y        = action_start[1]
    @st_angle    = action_start[2]
    @st_zoom_x   = action_start[3]
    @st_zoom_y   = action_start[4]
    @st_tone     = action_start[5]
    @st_opacity  = action_start[6]
    @ed_x        = action_end[0]
    @ed_y        = action_end[1]
    @ed_angle    = action_end[2]
    @ed_zoom_x   = action_end[3]
    @ed_zoom_y   = action_end[4]
    @ed_tone     = action_end[5]
    @ed_opacity  = action_end[6]
  end
end
#==============================================================================
# ■ RPG::Troop::Member
#==============================================================================

class RPG::Troop::Member
  #--------------------------------------------------------------------------
  # ○ x座標
  #--------------------------------------------------------------------------
  def y
    return @y + A1_System::SideViewActionConfig::TROOP_COMP_Y
  end
end
#==============================================================================
# ■ RPG::Weapon
#==============================================================================

class RPG::Weapon < RPG::EquipItem
  #--------------------------------------------------------------------------
  # ○ サイドビューアイコン
  #--------------------------------------------------------------------------
  def sv_icon
    @sv_icon ||= $a1_common.note_data_one(self.note, "SVアイコン", -1).to_i
    return @sv_icon
  end
end
#==============================================================================
# ■ RPG::Actor
#==============================================================================

class RPG::Actor < RPG::BaseItem
  #--------------------------------------------------------------------------
  # ○ マルチキャラクター
  #--------------------------------------------------------------------------
  def multi_character(kind)
    @multi_character ||= {}
    @multi_character[kind] ||= $a1_common.note_data_array_str(self.note, kind, [@character_name, @character_index])
    return @multi_character[kind]
  end
  #--------------------------------------------------------------------------
  # ○ バトラーピクチャ
  #--------------------------------------------------------------------------
  def battler_picture
    @battler_picture ||= $a1_common.note_data_one(self.note, "バトラー", "")
    return @battler_picture
  end
end
#==============================================================================
# ■ RPG::Enemy
#==============================================================================

class RPG::Enemy < RPG::BaseItem
  #--------------------------------------------------------------------------
  # ○ バトラーピクチャ
  #--------------------------------------------------------------------------
  def battler_picture
    @battler_picture ||= $a1_common.note_data_one(self.note, "バトラー", "")
    return @battler_picture
  end
end
#==============================================================================
# ■ Game_Enemy
#------------------------------------------------------------------------------
#  敵キャラを扱うクラスです。このクラスは Game_Troop クラス($game_troop)の
# 内部で使用されます。
#==============================================================================

class Game_Enemy < Game_Battler
  #--------------------------------------------------------------------------
  # ☆ オブジェクト初期化
  #--------------------------------------------------------------------------
  alias a1_side_view_ge_initialize initialize
  def initialize(index, enemy_id)
    a1_side_view_ge_initialize(index, enemy_id)
    @battler_picture = enemy.battler_picture
  end
  #--------------------------------------------------------------------------
  # ○ 標準位置を設定
  #--------------------------------------------------------------------------
  def set_standard_pos
    @standard_x = @screen_x
    @standard_y = @screen_y
  end
  #--------------------------------------------------------------------------
  # ○ 通常攻撃 アニメーション ID の取得
  #--------------------------------------------------------------------------
  def atk_animation_id1
    if dual_wield?
      return weapons[0].animation_id if weapons[0]
      return weapons[1] ? 0 : 1
    else
      return weapons[0] ? weapons[0].animation_id : 1
    end
  end
  #--------------------------------------------------------------------------
  # ○ 通常攻撃 アニメーション ID の取得(二刀流:武器2)
  #--------------------------------------------------------------------------
  def atk_animation_id2
    if dual_wield?
      return weapons[1] ? weapons[1].animation_id : 0
    else
      return 0
    end
  end
  #--------------------------------------------------------------------------
  # ★ 通常能力値の加算値取得
  #--------------------------------------------------------------------------
  def param_plus(param_id)
    super
  end
end
#==============================================================================
# ■ RPG::UsableItem
#==============================================================================

class RPG::BaseItem
  #--------------------------------------------------------------------------
  # ○ アクション
  #--------------------------------------------------------------------------
  def sv_action
    @sv_action = $a1_common.note_data_one(self.note, "SVアクション", "")
    return @sv_action
  end
end
#==============================================================================
# ■ BattleManager
#------------------------------------------------------------------------------
#  戦闘の進行を管理するモジュールです。
#==============================================================================

module BattleManager
  #--------------------------------------------------------------------------
  # ○ エイリアス用特異メソッド
  #--------------------------------------------------------------------------
  class << self
    alias :a1_side_view_bm_battle_start :battle_start
    alias :a1_side_view_bm_play_battle_end_me :play_battle_end_me
    alias :a1_side_view_bm_process_escape :process_escape
  end
  #--------------------------------------------------------------------------
  # ☆ 戦闘開始
  #--------------------------------------------------------------------------
  def self.battle_start
    call_method(:move_start_pos)
    a1_side_view_bm_battle_start
  end
  #--------------------------------------------------------------------------
  # ○ サイドビューアクション取得
  #--------------------------------------------------------------------------
  def self.side_view_actions
    @side_view_actions ||= A1_System::SideViewAction.new
    return @side_view_actions
  end
  #--------------------------------------------------------------------------
  # ○ 移動先ターゲットの設定
  #--------------------------------------------------------------------------
  def self.move_target=(target)
    @move_target = target
  end
  #--------------------------------------------------------------------------
  # ○ 移動先ターゲットの取得
  #--------------------------------------------------------------------------
  def self.move_target
    @move_target
  end
  #--------------------------------------------------------------------------
  # ○ 全ターゲットの設定
  #--------------------------------------------------------------------------
  def self.all_targets=(targets)
    @all_targets = targets
  end
  #--------------------------------------------------------------------------
  # ○ 全ターゲットの取得
  #--------------------------------------------------------------------------
  def self.all_targets
    @all_targets
  end
  #--------------------------------------------------------------------------
  # ○ アクションウェイトの設定
  #--------------------------------------------------------------------------
  def self.action_wait_skip=(flag)
    @action_wait_skip = flag
  end
  #--------------------------------------------------------------------------
  # ○ アクションウェイトの取得
  #--------------------------------------------------------------------------
  def self.action_wait_skip
    @action_wait_skip
  end
  #--------------------------------------------------------------------------
  # ☆ 戦闘終了 ME の演奏
  #--------------------------------------------------------------------------
  def self.play_battle_end_me
    a1_side_view_bm_play_battle_end_me
    call_method(:victory_action)
  end
  #--------------------------------------------------------------------------
  # ☆ 逃走の処理
  #--------------------------------------------------------------------------
  def self.process_escape
    success = a1_side_view_bm_process_escape
    call_method(:escape_failure) unless success
    return success
  end
end
#==============================================================================
# ■ Window_BattleActors
#==============================================================================

class Window_BattleActors < Window_Base
  #--------------------------------------------------------------------------
  # ○ 定数
  #--------------------------------------------------------------------------
  WINDOW_POS = A1_System::SideViewActionConfig::WINDOW_POS
  #--------------------------------------------------------------------------
  # ★ ウィンドウ位置のセット(個別バトルステータスウィンドウの再定義)
  #--------------------------------------------------------------------------
  def setup_window_pos(index)
    width       = 68 + (FONT_SIZE - 18) * 4
    @line_num   = 3
    height      = fitting_height(@line_num)
    pos         = window_pos(index)
    self.x      = pos[0]
    self.y      = pos[1]
    self.width  = width
    self.height = height
    create_contents
    self.contents.font.size = FONT_SIZE
    @state_icon_window.dispose if @state_icon_window
    @state_icon_window = Window_StateIcons.new(self.x + 48, self.y + line_height + 8)
    @target_y = self.y
    @org_y    = self.y
    refresh
  end
  #--------------------------------------------------------------------------
  # ○ ウィンドウ位置の取得
  #--------------------------------------------------------------------------
  def window_pos(index)
    WINDOW_POS[index]
  end
  #--------------------------------------------------------------------------
  # ○ 情報の描画
  #--------------------------------------------------------------------------
  def draw_info
    draw_actor_hp(@actor, 0, draw_y(0), 44+ (FONT_SIZE - 18) * 4)
    draw_actor_mp(@actor, 0, draw_y(1), 44+ (FONT_SIZE - 18) * 4)
    draw_actor_tp(@actor, 0, draw_y(2), 44+ (FONT_SIZE - 18) * 4)
    @state_icon_window.state_icons = (@actor.state_icons + @actor.buff_icons)
  end
  #--------------------------------------------------------------------------
  # ○ 描画するy座標
  #--------------------------------------------------------------------------
  def draw_y(index)
    (line_height - 8) * index
  end
  #--------------------------------------------------------------------------
  # ○ 1行の高さ
  #--------------------------------------------------------------------------
  def line_height
    return 24
  end
  #--------------------------------------------------------------------------
  # ○ ステートおよび強化/弱体のアイコンを描画
  #--------------------------------------------------------------------------
  def draw_actor_icons(actor, x, y, width = 96)
    icons = (actor.state_icons + actor.buff_icons)[0, width / 24]
    icons.each_with_index {|n, i| draw_icon(n, x, y - 24 * i) }
  end
  #--------------------------------------------------------------------------
  # ○ フレーム更新
  #--------------------------------------------------------------------------
  def update
    super
    update_state_icons
  end
  #--------------------------------------------------------------------------
  # ○ 解放
  #--------------------------------------------------------------------------
  def dispose
    @state_icon_window.dispose
    super
  end
  #--------------------------------------------------------------------------
  # ○ ステートアイコンの更新
  #--------------------------------------------------------------------------
  def update_state_icons
    @state_icon_window.update
  end
  #--------------------------------------------------------------------------
  # ○ 可視状態の変更
  #--------------------------------------------------------------------------
  def visible=(flag)
    super
    @state_icon_window.visible = flag if @state_icon_window
  end
end
#==============================================================================
# ■ Window_StateIcons
#==============================================================================

class Window_StateIcons < Window_Base
  #--------------------------------------------------------------------------
  # ○ 定数
  #--------------------------------------------------------------------------
  MOVE_COUNT = 24
  DRAW_COUNT = 60
  #--------------------------------------------------------------------------
  # ○ オブジェクト初期化
  #--------------------------------------------------------------------------
  def initialize(x ,y)
    @state_icons = []
    @draw_count  = 0
    @move_count  = 0
    @icon_draw   = false
    @icon_index  = 0
    super(x, y, 48, 48)
    skin = Cache.system("Window").clone
    skin.clear_rect(80, 16, 32, 32)
    self.windowskin = skin
    self.opacity = 0
  end
  #--------------------------------------------------------------------------
  # ○ ステートアイコンの設定
  #--------------------------------------------------------------------------
  def state_icons=(icons)
    return if @state_icons == icons
    @state_icons = icons
    clear
    draw_icon(@state_icons[0], 0, 0) if !@icon_draw && @state_icons.size > 0
    @draw_count = DRAW_COUNT if @state_icons.size > 1
  end
  #--------------------------------------------------------------------------
  # ○ クリア
  #--------------------------------------------------------------------------
  def clear
    contents.clear
    @icon_draw = false if @state_icons.size == 0
    @icon_index = @state_icons.size - 1 if @icon_index >= @state_icons.size
    @draw_count = 0 if @state_icons.size <= 1
    @move_count = 0 if @state_icons.size <= 1
  end
  #--------------------------------------------------------------------------
  # ○ ステートアイコンの描画
  #--------------------------------------------------------------------------
  def draw_state_icon(icon_index, x, y)
    draw_icon(icon_index, x, y)
    @icon_draw = true
  end
  #--------------------------------------------------------------------------
  # ○ フレーム更新
  #--------------------------------------------------------------------------
  def update
    super
    update_state_icons if @draw_count > 0
    update_sprite_move if @move_count > 0
  end
  #--------------------------------------------------------------------------
  # ○ ステートアイコン移動の更新
  #--------------------------------------------------------------------------
  def update_sprite_move
    @move_count -= 1
    self.ox += 1
    return if @move_count > 0
    contents.clear_rect(0, 0, 24, 24)
    draw_icon(@state_icons[@icon_index], 0, 0)
    self.ox = 0
    @draw_count = DRAW_COUNT
  end
  #--------------------------------------------------------------------------
  # ○ ステートアイコンの更新
  #--------------------------------------------------------------------------
  def update_state_icons
    @draw_count -= 1
    return if @draw_count > 0
    @icon_index += 1
    @icon_index = 0 if @icon_index == @state_icons.size
    contents.clear_rect(24, 0, 24, 24)
    draw_icon(@state_icons[@icon_index], 24, 0)
    @move_count = MOVE_COUNT
  end
  #--------------------------------------------------------------------------
  # ○ ウィンドウ内容の幅を計算
  #--------------------------------------------------------------------------
  def contents_width
    return 48
  end
end
#==============================================================================
# ■ Window_NameActor
#==============================================================================

class Window_NameActor < Window_Base
  #--------------------------------------------------------------------------
  # ○ オブジェクト初期化
  #--------------------------------------------------------------------------
  def initialize(main_window)
    @text = ""
    @main_window = main_window
    super(0, @main_window.y, 0, fitting_height(1))
    self.openness = 0
  end
  #--------------------------------------------------------------------------
  # ○ リフレッシュ
  #--------------------------------------------------------------------------
  def refresh
    contents.clear
    draw_text(0, 0, contents.width, line_height, @text, 1)
  end
  #--------------------------------------------------------------------------
  # ○ テキストの設定
  #--------------------------------------------------------------------------
  def text=(str)
    @text = str
    self.width = $a1_common.text_width(contents.font, @text) + standard_padding * 2
    self.x     = @main_window.x - self.width
    create_contents
    refresh
  end
end
#==============================================================================
# ■ Window_BattleLog
#------------------------------------------------------------------------------
#  戦闘の進行を実況表示するウィンドウです。枠は表示しませんが、便宜上ウィンド
# ウとして扱います。
#==============================================================================

class Window_BattleLog < Window_Selectable
  #--------------------------------------------------------------------------
  # ☆ ウェイト
  #--------------------------------------------------------------------------
  alias a1_side_view_sbl_wait wait
  def wait
    a1_side_view_sbl_wait unless @skip_wait_for_action
  end
  #--------------------------------------------------------------------------
  # ☆ HP ダメージ表示
  #--------------------------------------------------------------------------
  alias a1_side_view_sbl_display_hp_damage display_hp_damage
  def display_hp_damage(target, item)
    @skip_wait_for_action = true if target.hp <= 0 || target.actor?
    a1_side_view_sbl_display_hp_damage(target, item)
    proc_damage_action(target) if target.actor?
    @counter = false
    @skip_wait_for_action = false
  end
  #--------------------------------------------------------------------------
  # ○ 身代わりアクション
  #--------------------------------------------------------------------------
  def substitute_action(kind)
    @substitute.proc_action("身代わりダメージ") if kind == "ダメージ"
    @substitute.proc_action("身代わり回避")     if kind == "回避"
    @substitute.substitute_target = nil if @substitute
    @substitute = nil
  end
  #--------------------------------------------------------------------------
  # ○ ダメージアクションの実行
  #--------------------------------------------------------------------------
  def proc_damage_action(target)
    return if target.result.hp_damage == 0
    return target.proc_action("回復アクション")        if target.result.hp_damage < 0
    return target.proc_action("カウンターダメージ")    if @counter
    return substitute_action("ダメージ")               if @substitute
    target.proc_action("ダメージアクション")
  end
  #--------------------------------------------------------------------------
  # ☆ 反撃の表示
  #--------------------------------------------------------------------------
  alias a1_side_view_sbl_display_counter display_counter
  def display_counter(target, item)
    @counter = true
    a1_side_view_sbl_display_counter(target, item)
  end
  #--------------------------------------------------------------------------
  # ☆ 反射の表示
  #--------------------------------------------------------------------------
  alias a1_side_view_sbl_display_reflection display_reflection
  def display_reflection(target, item)
    @counter = true
    a1_side_view_sbl_display_reflection(target, item)
  end
  #--------------------------------------------------------------------------
  # ☆ 身代わりの表示
  #--------------------------------------------------------------------------
  alias a1_side_view_sbl_display_substitute display_substitute
  def display_substitute(substitute, target)
    substitute.substitute_target = target.index
    target.proc_action("身代わられ動作")   if target.actor?
    substitute.proc_action("身代わり動作") if target.actor?
    @substitute = substitute
    a1_side_view_sbl_display_substitute(substitute, target)
  end
  #--------------------------------------------------------------------------
  # ☆ ステート付加の表示
  #--------------------------------------------------------------------------
  alias a1_side_view_sbl_display_added_states display_added_states
  def display_added_states(target)
    a1_side_view_sbl_display_added_states(target)
    target.proc_action("状態変化アクション")
  end
  #--------------------------------------------------------------------------
  # ☆ ステート解除の表示
  #--------------------------------------------------------------------------
  alias a1_side_view_sbl_display_removed_states display_removed_states
  def display_removed_states(target)
    a1_side_view_sbl_display_removed_states(target)
    target.proc_action("状態変化アクション")
  end
  #--------------------------------------------------------------------------
  # ☆ ミスの表示
  #--------------------------------------------------------------------------
  alias a1_side_view_sbl_display_miss display_miss
  def display_miss(target, item)
    @skip_wait_for_action = true
    a1_side_view_sbl_display_miss(target, item)
    proc_evasion_action(target)
    @skip_wait_for_action = false
  end
  #--------------------------------------------------------------------------
  # ☆ 回避の表示
  #--------------------------------------------------------------------------
  alias a1_side_view_sbl_display_evasion display_evasion
  def display_evasion(target, item)
    @skip_wait_for_action = true
    a1_side_view_sbl_display_evasion(target, item)
    proc_evasion_action(target)
    @skip_wait_for_action = false
  end
  #--------------------------------------------------------------------------
  # ○ 回避アクションの実行
  #--------------------------------------------------------------------------
  def proc_evasion_action(target)
    return substitute_action("回避")     if @substitute
    target.proc_action("回避アクション") if target.actor?
    target.proc_action("敵回避アクション") unless target.actor?
  end
end
#==============================================================================
# ■ Window_BattleActor
#------------------------------------------------------------------------------
#  バトル画面で、行動対象のアクターを選択するウィンドウです。
#==============================================================================

class Window_BattleActor < Window_BattleStatus
  #--------------------------------------------------------------------------
  # ○ ヘルプテキスト更新
  #--------------------------------------------------------------------------
  alias a1_wide_view_wba_update_help update_help
  def update_help
    @help_window.width = $a1_common.text_width(@help_window.contents.font, actor.name) + standard_padding * 2
    @help_window.x = actor.screen_x - @help_window.width - 48
    @help_window.y = actor.screen_y - 64
    @help_window.create_contents
    a1_wide_view_wba_update_help
  end
end
#==============================================================================
# ■ Window_BattleEnemy
#------------------------------------------------------------------------------
#  バトル画面で、行動対象の敵キャラを選択するウィンドウです。
#==============================================================================

class Window_BattleEnemy < Window_Selectable
  #--------------------------------------------------------------------------
  # ○ ヘルプテキスト更新
  #--------------------------------------------------------------------------
  alias a1_wide_view_wbe_update_help update_help
  def update_help
    @help_window.width = $a1_common.text_width(@help_window.contents.font, enemy.name) + standard_padding * 2
    @help_window.x = [enemy.screen_x - @help_window.width, 0].max
    @help_window.y = enemy.screen_y
    @help_window.create_contents
    a1_wide_view_wbe_update_help
  end
end
#==============================================================================
# ■ Scene_Battle
#------------------------------------------------------------------------------
#  バトル画面の処理を行うクラスです。
#==============================================================================

class Scene_Battle < Scene_Base
  #--------------------------------------------------------------------------
  # ○ 定数
  #--------------------------------------------------------------------------
  INTT_POS = A1_System::SideViewActionConfig::INTT_POS
  #--------------------------------------------------------------------------
  # ○ エイリアス
  #--------------------------------------------------------------------------
  alias a1_side_view_sb_execute_action execute_action
  alias a1_side_view_sb_use_item use_item
  alias a1_side_view_sb_show_animation show_animation
  #--------------------------------------------------------------------------
  # ☆ バトルマネージャメソッドのセットアップ
  #--------------------------------------------------------------------------
  alias a1_side_view_sb_define_battle_manager_method define_battle_manager_method
  def define_battle_manager_method
    a1_side_view_sb_define_battle_manager_method
    BattleManager.define_method(method(:a1_side_view_sb_use_item),       :use_item)
    BattleManager.define_method(method(:a1_side_view_sb_execute_action), :execute_action)
    BattleManager.define_method(method(:wait_for_move),                  :wait_for_move)
    BattleManager.define_method(method(:action_icon),                    :action_icon)
    BattleManager.define_method(method(:a1_side_view_sb_show_animation), :show_animation)
    BattleManager.define_method(method(:move_start_pos),                 :move_start_pos)
    BattleManager.define_method(method(:set_wait_collapse),              :set_wait_collapse)
    BattleManager.define_method(method(:victory_action),                 :victory_action)
    BattleManager.define_method(method(:invoke_item),                    :invoke_item)
    BattleManager.define_method(method(:escape_failure),                 :escape_failure)
    BattleManager.define_method(method(:setup_actor_battler),            :setup_actor_battler)
    BattleManager.define_method(method(:setup_status_windows),           :setup_status_windows)
    BattleManager.define_method(method(:change_battler_sprite),          :change_battler_sprite)
    BattleManager.define_method(method(:proc_event_action),              :proc_event_action)
  end
  #--------------------------------------------------------------------------
  # ☆ 全ウィンドウの作成
  #--------------------------------------------------------------------------
  alias a1_side_view_sb_create_all_windows create_all_windows
  def create_all_windows
    a1_side_view_sb_create_all_windows
    create_actor_name_window
  end
  #--------------------------------------------------------------------------
  # ☆ スキルウィンドウ作成の後処理
  #--------------------------------------------------------------------------
  alias a1_side_view_post_create_skill_window post_create_skill_window
  def post_create_skill_window
    a1_side_view_post_create_skill_window
    @skill_window.resize_height(Graphics.height - 120)
  end
  #--------------------------------------------------------------------------
  # ○ アイテムウィンドウ作成の後処理
  #--------------------------------------------------------------------------
  alias a1_side_view_post_create_item_window post_create_item_window
  def post_create_item_window
    @item_window.resize_height(Graphics.height - 120)
  end
  #--------------------------------------------------------------------------
  # ○ スキル/アイテムウィンドウが表示された時の処理
  #--------------------------------------------------------------------------
  alias a1_side_view_skill_item_window_show skill_item_window_show
  def skill_item_window_show
    a1_side_view_skill_item_window_show
    @face_status_window.open
  end
  #--------------------------------------------------------------------------
  # ○ スキル/アイテムウィンドウが非表示になった時の処理
  #--------------------------------------------------------------------------
  alias a1_side_view_skill_item_window_hide skill_item_window_hide
  def skill_item_window_hide
    @face_status_window.close
  end
  #--------------------------------------------------------------------------
  # ○ アクターネームウィンドウ作成
  #--------------------------------------------------------------------------
  def create_actor_name_window
    @actor_name_window = Window_NameActor.new(@actor_command_window)
  end
  #--------------------------------------------------------------------------
  # ☆ アクターコマンドウィンドウがオープンした時の処理
  #--------------------------------------------------------------------------
  alias a1_side_view_sb_actor_command_open actor_command_open
  def actor_command_open
    a1_side_view_sb_actor_command_open
    @actor_name_window.open
  end
  #--------------------------------------------------------------------------
  # ☆ アクターコマンドウィンドウがクローズした時の処理
  #--------------------------------------------------------------------------
  alias a1_side_view_sb_actor_command_close actor_command_close
  def actor_command_close
    a1_side_view_sb_actor_command_close
    @actor_name_window.close
  end
  #--------------------------------------------------------------------------
  # ☆ アクターコマンドウィンドウのセットアップ時の処理
  #--------------------------------------------------------------------------
  alias a1_side_view_sb_actor_command_setup actor_command_setup
  def actor_command_setup(actor)
    a1_side_view_sb_actor_command_setup(actor)
    @actor_name_window.text = actor.name
  end
  #--------------------------------------------------------------------------
  # ○ 移動完了待ち
  #--------------------------------------------------------------------------
  def wait_for_move
    update_basic
  end
  #--------------------------------------------------------------------------
  # ☆ メッセージウィンドウの作成
  #--------------------------------------------------------------------------
  alias a1_side_view_sb_create_message_window create_message_window
  def create_message_window
    a1_side_view_sb_create_message_window
    $game_message.position = 0
  end
  #--------------------------------------------------------------------------
  # ○ 戦闘開始の登場
  #--------------------------------------------------------------------------
  def move_start_pos
    battle_members.each {|actor| actor.proc_action("戦闘開始の登場") }
  end
  #--------------------------------------------------------------------------
  # ○ アクターの初期位置
  #--------------------------------------------------------------------------
  def members_init_pos(index)
    INTT_POS[index]
  end
  #--------------------------------------------------------------------------
  # ★ アクター位置のセットアップ(個別バトルステータスウィンドウの再定義)
  #--------------------------------------------------------------------------
  def setup_actor_battler(index, actor)
    pos = members_init_pos(index)
    pos = actor.members_standard_pos(index) if actor.hp <= 0
    setup_actor_screen_pos(actor, pos)
    actor.init_x   = pos[0]
    actor.init_y   = pos[1]
    actor.screen_z = 50
    actor.target_x = actor.screen_x
    actor.target_y = actor.screen_y
    actor.setup_standard_pos(index)
    actor.visible  = true
  end
  #--------------------------------------------------------------------------
  # ○ アクターの画面位置を設定
  #--------------------------------------------------------------------------
  def setup_actor_screen_pos(actor, pos)
    actor.screen_x = pos[0]
    actor.screen_y = pos[1]
  end
  #--------------------------------------------------------------------------
  # ☆ 次のコマンド入力への前処理
  #--------------------------------------------------------------------------
  alias a1_side_view_sb_prev_next_command prev_next_command
  def prev_next_command
    BattleManager.actor.proc_action("コマンド選択終了") if BattleManager.actor
    a1_side_view_sb_prev_next_command
  end
  #--------------------------------------------------------------------------
  # ☆ 次のコマンド入力への後処理
  #--------------------------------------------------------------------------
  alias a1_side_view_sb_post_next_command post_next_command
  def post_next_command
    a1_side_view_sb_post_next_command
    BattleManager.actor.proc_action("コマンド選択開始") if BattleManager.actor
  end
  #--------------------------------------------------------------------------
  # ○ 前のコマンド入力への前処理
  #--------------------------------------------------------------------------
  alias a1_side_view_sb_prev_prior_command prev_prior_command
  def prev_prior_command
    BattleManager.actor.proc_action("コマンド選択終了") if BattleManager.actor
    a1_side_view_sb_prev_prior_command
  end
  #--------------------------------------------------------------------------
  # ☆ 前のコマンド入力への後処理
  #--------------------------------------------------------------------------
  alias a1_side_view_sb_post_prior_command post_prior_command
  def post_prior_command
    a1_side_view_sb_post_prior_command
    BattleManager.actor.proc_action("コマンド選択開始") if BattleManager.actor
  end
  #--------------------------------------------------------------------------
  # ○ 同時アクションを実行するメンバーを取得
  #--------------------------------------------------------------------------
  def alive_index
    battle_members.each {|member| return member.index if member.alive?}
  end
  #--------------------------------------------------------------------------
  # ○ 勝利アクション
  #--------------------------------------------------------------------------
  def victory_action
    @victory_action = true
    battle_members[alive_index].proc_action("勝利アクション")
  end
  #--------------------------------------------------------------------------
  # ☆ コマンド[逃げる]
  #--------------------------------------------------------------------------
  alias a1_side_view_sb_command_escape command_escape
  def command_escape
    battle_members[alive_index].proc_action("逃げる")
    a1_side_view_sb_command_escape
  end
  #--------------------------------------------------------------------------
  # ○ 逃げる失敗
  #--------------------------------------------------------------------------
  def escape_failure
    battle_members[0].proc_action("逃げる失敗")
  end
  #--------------------------------------------------------------------------
  # ☆ パーティコマンドウィンドウ作成の後処理
  #--------------------------------------------------------------------------
  alias a1_side_view_sb_post_create_party_command_window post_create_party_command_window
  def post_create_party_command_window
    @party_command_window.viewport = nil
    @party_command_window.x = Graphics.width - @party_command_window.width
    @party_command_window.y = 0
  end
  #--------------------------------------------------------------------------
  # ○ アクターウィンドウ作成の後処理
  #--------------------------------------------------------------------------
  alias a1_side_view_sb_post_create_actor_window post_create_actor_window
  def post_create_actor_window
    a1_side_view_sb_post_create_actor_window
    @actor_command_window.viewport = nil
    @actor_command_window.x = Graphics.width - @actor_command_window.width
    @actor_command_window.y = 0
  end
  #--------------------------------------------------------------------------
  # ☆ 敵キャラ選択の開始
  #--------------------------------------------------------------------------
  alias a1_side_view_sb_select_enemy_selection select_enemy_selection
  def select_enemy_selection
    a1_side_view_sb_select_enemy_selection
    @actor_command_window.close
  end
  #--------------------------------------------------------------------------
  # ☆ コラプス処理保留の設定
  #--------------------------------------------------------------------------
  alias a1_side_view_sb_set_wait_collapse set_wait_collapse
  def set_wait_collapse(targets, flag, sv_flag = true)
    return if !flag && sv_flag
    a1_side_view_sb_set_wait_collapse(targets, flag)
  end
  #--------------------------------------------------------------------------
  # ☆ 戦闘行動の実行
  #--------------------------------------------------------------------------
  def execute_action
    @subject.execute_action
  end
  #--------------------------------------------------------------------------
  # ☆ スキル/アイテムの使用
  #--------------------------------------------------------------------------
  def use_item
    @subject.battler_use_item
  end
  #--------------------------------------------------------------------------
  # ★ 攻撃アニメーションの表示
  #--------------------------------------------------------------------------
  def show_attack_animation(targets)
    show_normal_animation(targets, @subject.atk_animation_id1, false)
  end
  #--------------------------------------------------------------------------
  # ○ アクションアイコン
  #--------------------------------------------------------------------------
  def action_icon(icon_index, action_info = nil, battler = nil)
    return @spriteset.erase_icon(icon_index) unless action_info
    @spriteset.setup_action_icon(action_info, icon_index, battler)
  end
  #--------------------------------------------------------------------------
  # ☆ ウェイト
  #--------------------------------------------------------------------------
  alias a1_side_view_sb_wait wait
  def wait(duration)
    a1_side_view_sb_wait(duration) unless action_wait_skip
  end
  #--------------------------------------------------------------------------
  # ☆ 短時間ウェイト(早送り無効)
  #--------------------------------------------------------------------------
  alias a1_side_view_sb_abs_wait_short abs_wait_short
  def abs_wait_short
    a1_side_view_sb_abs_wait_short unless action_wait_skip
  end
  #--------------------------------------------------------------------------
  # ☆ アニメーション表示が終わるまでウェイト
  #--------------------------------------------------------------------------
  alias a1_side_view_sb_wait_for_animation wait_for_animation
  def wait_for_animation
    a1_side_view_sb_wait_for_animation unless action_wait_skip
  end
  #--------------------------------------------------------------------------
  # ○ アクションのウェイト
  #--------------------------------------------------------------------------
  def action_wait_skip
    BattleManager.action_wait_skip
  end
  #--------------------------------------------------------------------------
  # ☆ 個別ステータスウィンドウを再作成する
  #--------------------------------------------------------------------------
  alias a1_side_view_sb_recreate_status_windows recreate_status_windows
  def recreate_status_windows(member)
    a1_side_view_sb_recreate_status_windows(member)
    return add_party_action(member) if member.index == $game_party.new_index
    setup_actor_screen_pos(member, member.members_standard_pos(member.index))
  end
  #--------------------------------------------------------------------------
  # ○ パーティ加入時のアクション
  #--------------------------------------------------------------------------
  def add_party_action(member)
    member.proc_action($game_temp.add_party_action) if $game_temp.add_party_action
    $game_temp.add_party_action = nil
  end
  #--------------------------------------------------------------------------
  # ☆ アクターを外す前処理
  #--------------------------------------------------------------------------
  alias a1_side_view_sb_prev_remove_battler prev_remove_battler
  def prev_remove_battler(member)
    member.proc_action($game_temp.remove_party_action) if $game_temp.remove_party_action
    a1_side_view_sb_prev_remove_battler(member)
    $game_temp.remove_party_action = nil
  end
  #--------------------------------------------------------------------------
  # ○ イベントアクション実行
  #--------------------------------------------------------------------------
  def proc_event_action(member, action)
    member.proc_action(action)
  end
#==============================================================================
# ■ パッシブスキル/スキルレベル対応処理
#==============================================================================
  if $imported["A1_PassiveSkill"]
  #--------------------------------------------------------------------------
  # ☆ 戦闘行動の実行の前処理
  #--------------------------------------------------------------------------
  alias a1_side_view_sb_prev_execute_action prev_execute_action
  def prev_execute_action
    a1_side_view_sb_prev_execute_action
    @original_current_weapon = @subject.current_weapon
  end
  #--------------------------------------------------------------------------
  # ☆ スキル/アイテムの使用の前処理
  #--------------------------------------------------------------------------
  alias a1_side_view_sb_prev_use_item prev_use_item
  def prev_use_item
    @subject.current_action.set_skill(@original_action_item.id) if @original_action_item.is_a?(RPG::Skill) && change_current_weapon?
    a1_side_view_sb_prev_use_item
  end
  #--------------------------------------------------------------------------
  # ○ 使用武器が変わった?
  #--------------------------------------------------------------------------
  def change_current_weapon?
    @original_current_weapon != @subject.current_weapon
  end
  #--------------------------------------------------------------------------
  # ☆ 通常攻撃がスキルに変化する条件のチェック
  #--------------------------------------------------------------------------
  alias a1_side_view_sb_skill_change_condition skill_change_condition
  def skill_change_condition(passive, skill_id)
    return false if @subject.actor? && !@subject.skill_change_condition
    a1_side_view_sb_skill_change_condition(passive, skill_id)
  end
  #--------------------------------------------------------------------------
  # ☆ スキル/アイテムの使用後の追加発動スキル
  #--------------------------------------------------------------------------
  alias a1_side_view_sb_use_after_next_skill use_after_next_skill
  def use_after_next_skill(item)
    return false if @subject.actor? && !@subject.skill_change_condition
    a1_side_view_sb_use_after_next_skill(item)
  end
  #--------------------------------------------------------------------------
  # ☆ コンボスキルの実行
  #--------------------------------------------------------------------------
  alias a1_side_view_sb_next_combo next_combo
  def next_combo(skill)
    @subject.start_combo
    a1_side_view_sb_next_combo(skill)
  end;end
#==============================================================================
# ■ 消耗品装備対応処理
#==============================================================================
  if $imported["A1_ConsumerEquip"] && $imported["A1_PassiveSkill"]
  #--------------------------------------------------------------------------
  # ☆ 戦闘行動の実行の前処理
  #--------------------------------------------------------------------------
  def prev_execute_action
    a1_side_view_sb_prev_execute_action
    @original_current_weapon = @subject.current_weapon
    @original_current_main   = @subject.current_main
  end
  #--------------------------------------------------------------------------
  # ○ 使用武器が変わった?
  #--------------------------------------------------------------------------
  def change_current_weapon?
    @original_current_weapon != @subject.current_weapon || @original_current_main != @subject.current_main
  end;end
#==============================================================================
# ■ 戦闘中入れ替え対応処理
#==============================================================================
  if $imported["A1_ChangeMember"]
  #--------------------------------------------------------------------------
  # ☆ メンバーチェンジ[キャンセル]
  #--------------------------------------------------------------------------
  alias a1_side_view_on_member_change_cancel on_member_change_cancel
  def on_member_change_cancel
    @window_member_change.close
    change_diss_members.each{|member| @prev_battle_members[member.index].proc_action("初期位置にジャンプ") }
    wait(30) unless change_diss_members.empty?
    a1_side_view_on_member_change_cancel
    change_diss_members.each {|member| return_for_change_member(member)  }
  end
  #--------------------------------------------------------------------------
  # ○ 入れ替えメンバー向け初期位置設定
  #--------------------------------------------------------------------------
  def return_for_change_member(member)
    pos = members_init_pos(member.index)
    member.init_x   = pos[0]
    member.init_y   = pos[1]
    member.screen_x = pos[0]
    member.screen_y = pos[1]
    member.proc_action("戦闘開始の登場")
  end;end
end
#==============================================================================
# ■ Spriteset_Battle
#------------------------------------------------------------------------------
#  バトル画面のスプライトをまとめたクラスです。このクラスは Scene_Battle クラ
# スの内部で使用されます。
#==============================================================================

class Spriteset_Battle
  #--------------------------------------------------------------------------
  # ☆ オブジェクト初期化
  #--------------------------------------------------------------------------
  alias a1_side_view_ssb_initialize initialize
  def initialize
    create_action_icon
    a1_side_view_ssb_initialize
  end
  #--------------------------------------------------------------------------
  # ○ アクションアイコンの作成
  #--------------------------------------------------------------------------
  def create_action_icon
    @action_icons = {}
  end
  #--------------------------------------------------------------------------
  # ○ アクションアイコンのセットアップ
  #--------------------------------------------------------------------------
  def setup_action_icon(action_info, icon_index, battler)
    @action_icons[icon_index] ||= Sprite_ActionIcon.new(@viewport1, icon_index)
    @action_icons[icon_index].setup_action(action_info, battler)
  end
  #--------------------------------------------------------------------------
  # ○ アクションアイコンのセットアップ
  #--------------------------------------------------------------------------
  def erase_icon(icon_index)
    @action_icons[icon_index].visible = false if @action_icons[icon_index]
  end
  #--------------------------------------------------------------------------
  # ☆ フレーム更新
  #--------------------------------------------------------------------------
  alias a1_side_view_ssb_update update
  def update
    a1_side_view_ssb_update
    update_action_icon
  end
  #--------------------------------------------------------------------------
  # ☆ 解放
  #--------------------------------------------------------------------------
  alias a1_side_view_ssb_dispose dispose
  def dispose
    dispose_action_icon
    a1_side_view_ssb_dispose
  end
  #--------------------------------------------------------------------------
  # ○ アクションアイコンの更新
  #--------------------------------------------------------------------------
  def update_action_icon
    @action_icons.values.each {|icon| icon.update }
  end
  #--------------------------------------------------------------------------
  # ○ アクションアイコンの解放
  #--------------------------------------------------------------------------
  def dispose_action_icon
    @action_icons.values.each {|icon| icon.dispose }
  end
end
#==============================================================================
# ■ Sprite_ActionIcon
#==============================================================================

class Sprite_ActionIcon < Sprite
  #--------------------------------------------------------------------------
  # ○ オブジェクト初期化
  #--------------------------------------------------------------------------
  def initialize(viewport, icon_index)
    super(viewport)
    setup_icon(icon_index)
  end
  #--------------------------------------------------------------------------
  # ○ アイコンのセットアップ
  #--------------------------------------------------------------------------
  def setup_icon(icon_index)
    self.bitmap = Bitmap.new(24, 24)
    icon_bitmap = Cache.system("Iconset")
    rect = Rect.new(icon_index % 16 * 24, icon_index / 16 * 24, 24, 24)
    self.bitmap.blt(0, 0, icon_bitmap, rect, 255)
    self.ox = self.bitmap.width / 2
    self.oy = self.bitmap.height / 2
    self.visible = false
  end
  #--------------------------------------------------------------------------
  # ○ アクションのセットアップ
  #--------------------------------------------------------------------------
  def setup_action(action_info, battler)
    @battler      = battler
    @action_info  = action_info
    @duration     = action_info.duration
    self.x        = @battler.screen_x + action_info.st_x
    self.y        = @battler.screen_y + action_info.st_y
    self.z        = @battler.screen_z - 10
    self.angle    = action_info.st_angle
    self.opacity  = action_info.st_opacity
    self.zoom_x   = action_info.st_zoom_x / 100.0
    self.zoom_y   = action_info.st_zoom_y / 100.0
    self.tone     = action_info.st_tone ? action_info.st_tone : Tone.new(0, 0, 0)
    @x_plus       = (action_info.ed_x - action_info.st_x)             / @duration.to_f
    @y_plus       = (action_info.ed_y - action_info.st_y)             / @duration.to_f
    @angle_plus   = action_info.ed_angle                              / @duration.to_f
    @opacity_plus = (action_info.ed_opacity - action_info.st_opacity) / @duration.to_f
    @zoom_x_plus  = (action_info.ed_zoom_x - action_info.st_zoom_x)   / @duration.to_f
    @zoom_y_plus  = (action_info.ed_zoom_y - action_info.st_zoom_y)   / @duration.to_f
    @tone_r_plus  = 0
    @tone_g_plus  = 0
    @tone_b_plus  = 0
    @tone_gr_plus = 0
    setup_tone_plus(action_info.st_tone, action_info.ed_tone)
    self.visible = true
  end
  #--------------------------------------------------------------------------
  # ○ トーンの差分セットアップ
  #--------------------------------------------------------------------------
  def setup_tone_plus(st_tone, ed_tone)
    return unless st_tone && ed_tone
    @tone_r_plus  = ed_tone[0] - st_tone[0] / @duration.to_f
    @tone_g_plus  = ed_tone[1] - st_tone[1] / @duration.to_f
    @tone_b_plus  = ed_tone[2] - st_tone[2] / @duration.to_f
    @tone_gr_plus = ed_tone[3] - st_tone[3] / @duration.to_f if st_tone[3] && ed_tone[3]
  end
  #--------------------------------------------------------------------------
  # ○ フレーム更新
  #--------------------------------------------------------------------------
  def update
    return unless @battler
    @duration -= 1
    super
    update_position
    update_zoom
    update_other
    clear if @duration == 0
  end
  #--------------------------------------------------------------------------
  # ○ クリア
  #--------------------------------------------------------------------------
  def clear
    self.visible = false if @action_info.erase
    @battler     = nil
    @action_info = nil
  end
  #--------------------------------------------------------------------------
  # ○ 位置の更新
  #--------------------------------------------------------------------------
  def update_position
    self.x += @x_plus
    self.y += @y_plus
  end
  #--------------------------------------------------------------------------
  # ○ 拡大率の更新
  #--------------------------------------------------------------------------
  def update_zoom
    self.zoom_x += @zoom_x_plus / 100.0
    self.zoom_y += @zoom_y_plus / 100.0
  end
  #--------------------------------------------------------------------------
  # ○ その他の更新
  #--------------------------------------------------------------------------
  def update_other
    self.opacity    += @opacity_plus
    self.angle      += @angle_plus
    self.tone.red   += @tone_r_plus
    self.tone.green += @tone_g_plus
    self.tone.blue  += @tone_b_plus
    self.tone.gray  += @tone_gr_plus
  end
end
#==============================================================================
# ■ Sprite_Battler
#------------------------------------------------------------------------------
#  バトラー表示用のスプライトです。Game_Battler クラスのインスタンスを監視し、
# スプライトの状態を自動的に変化させます。
#==============================================================================

class Sprite_Battler < Sprite_Base
  #--------------------------------------------------------------------------
  # ☆ オブジェクト初期化
  #--------------------------------------------------------------------------
  alias a1_side_view_sb_initialize initialize
  def initialize(viewport, battler = nil)
    @balloon_duration = 0
    a1_side_view_sb_initialize(viewport, battler)
  end
  #--------------------------------------------------------------------------
  # ☆ 新しいエフェクトの設定
  #--------------------------------------------------------------------------
  alias a1_side_view_sb_setup_new_effect setup_new_effect
  def setup_new_effect
    a1_side_view_sb_setup_new_effect
    if !@balloon_sprite && @battler.balloon_id > 0
      @balloon_id = @battler.balloon_id
      start_balloon
    end
  end
  #--------------------------------------------------------------------------
  # ☆ バトラー情報のセットアップ
  #--------------------------------------------------------------------------
  alias a1_side_view_sb_setup_battler_info setup_battler_info
  def setup_battler_info
    clear
    a1_side_view_sb_setup_battler_info
    return unless @battler
    set_character_bitmap if @battler.actor?
  end
  #--------------------------------------------------------------------------
  # ☆ 位置の更新
  #--------------------------------------------------------------------------
  alias a1_side_view_sb_update_position update_position
  def update_position
    a1_side_view_sb_update_position
    update_battler_move
    update_battler_action
    update_balloon
  end
  #--------------------------------------------------------------------------
  # ○ バトラーアクションの更新
  #--------------------------------------------------------------------------
  def update_battler_action
    setup_action(@battler.battler_action) if @battler.battler_action && !@action_info
    return unless @action_info
    @duration -= 1 if @duration && @duration > 0
    update_zoom
    update_other
    clear if @duration == 0
  end
  #--------------------------------------------------------------------------
  # ★ アクター用転送元ビットマップの更新(個別バトルステータスウィンドウの再定義)
  #--------------------------------------------------------------------------
  def update_bitmap_actor
    update_src_rect
    return unless change_graphic?
    setup_battler_info
    update_src_rect
  end
  #--------------------------------------------------------------------------
  # ○ グラフィック変更?
  #--------------------------------------------------------------------------
  def change_graphic?
    @now_battler_name != @battler.battler_name || @now_battler_index != @battler.battler_index
  end
  #--------------------------------------------------------------------------
  # ○ バトラー移動の更新
  #--------------------------------------------------------------------------
  def update_battler_move
    @battler.update_battler_move
  end
  #--------------------------------------------------------------------------
  # ○ キャラクターのビットマップを設定
  #--------------------------------------------------------------------------
  def set_character_bitmap
    self.bitmap = Cache.character(@battler.battler_name)
    sign = @battler.battler_name[/^[\!\$]./]
    if sign && sign.include?('$')
      @cw = bitmap.width / 3
      @ch = bitmap.height / 4
    else
      @cw = bitmap.width / 12
      @ch = bitmap.height / 8
    end
    self.ox = @cw / 2
    self.oy = @ch
    @now_battler_name      = @battler.battler_name
    @now_battler_index     = @battler.battler_index
    @battler.sprite_height = @ch
  end
  #--------------------------------------------------------------------------
  # ○ 転送元矩形の更新
  #--------------------------------------------------------------------------
  def update_src_rect
    @battler.update_pattern
    index = @battler.battler_index
    pattern = @battler.pattern < 3 ? @battler.pattern : 1
    sx = (index % 4 * 3 + pattern) * @cw
    sy = (index / 4 * 4 + (@battler.direction - 2) / 2) * @ch
    self.src_rect.set(sx, sy, @cw, @ch)
  end
  #--------------------------------------------------------------------------
  # ☆ 原点の更新
  #--------------------------------------------------------------------------
  alias a1_side_view_spb_update_origin update_origin
  def update_origin
    a1_side_view_spb_update_origin unless @battler.actor?
  end
  #--------------------------------------------------------------------------
  # ☆ 通常の設定に戻す
  #--------------------------------------------------------------------------
  alias a1_side_view_spb_revert_to_normal revert_to_normal
  def revert_to_normal
    a1_side_view_spb_revert_to_normal unless @battler.actor?
  end
  #--------------------------------------------------------------------------
  # ○ アクションのセットアップ
  #--------------------------------------------------------------------------
  def setup_action(action_info)
    @action_info  = action_info
    @duration     = action_info.duration
    self.angle    = action_info.st_angle
    self.opacity  = action_info.st_opacity
    self.zoom_x   = action_info.st_zoom_x / 100.0
    self.zoom_y   = action_info.st_zoom_y / 100.0
    self.tone     = action_info.st_tone ? action_info.st_tone : Tone.new(0, 0, 0)
    @angle_plus   = action_info.ed_angle                              / @duration.to_f
    @opacity_plus = (action_info.ed_opacity - action_info.st_opacity) / @duration.to_f
    @zoom_x_plus  = (action_info.ed_zoom_x - action_info.st_zoom_x)   / @duration.to_f
    @zoom_y_plus  = (action_info.ed_zoom_y - action_info.st_zoom_y)   / @duration.to_f
    @tone_r_plus  = 0
    @tone_g_plus  = 0
    @tone_b_plus  = 0
    @tone_gr_plus = 0
    setup_tone_plus(action_info.st_tone, action_info.ed_tone)
    self.visible = true
  end
  #--------------------------------------------------------------------------
  # ○ トーンの差分セットアップ
  #--------------------------------------------------------------------------
  def setup_tone_plus(st_tone, ed_tone)
    return unless @action_info
    return unless st_tone && ed_tone
    @tone_r_plus  = ed_tone[0] - st_tone[0] / @duration.to_f
    @tone_g_plus  = ed_tone[1] - st_tone[1] / @duration.to_f
    @tone_b_plus  = ed_tone[2] - st_tone[2] / @duration.to_f
    @tone_gr_plus = ed_tone[3] - st_tone[3] / @duration.to_f if st_tone[3] && ed_tone[3]
  end
  #--------------------------------------------------------------------------
  # ○ クリア
  #--------------------------------------------------------------------------
  def clear
    return unless @action_info
    self.visible = false if @action_info.erase
    @action_info = nil
    @battler.battler_action = nil
    @angle_plus   = 0
    @opacity_plus = 0
    @zoom_x_plus  = 0
    @zoom_y_plus  = 0
    @tone_r_plus  = 0
    @tone_g_plus  = 0
    @tone_b_plus  = 0
    @tone_gr_plus = 0
  end
  #--------------------------------------------------------------------------
  # ○ 拡大率の更新
  #--------------------------------------------------------------------------
  def update_zoom
    return unless @action_info
    self.zoom_x += @zoom_x_plus / 100.0
    self.zoom_y += @zoom_y_plus / 100.0
  end
  #--------------------------------------------------------------------------
  # ○ その他の更新
  #--------------------------------------------------------------------------
  def update_other
    return unless @action_info
    self.opacity    += @opacity_plus
    self.angle      += @angle_plus
    self.tone.red   += @tone_r_plus
    self.tone.green += @tone_g_plus
    self.tone.blue  += @tone_b_plus
    self.tone.gray  += @tone_gr_plus
  end
  #--------------------------------------------------------------------------
  # ○ フキダシアイコン表示の開始
  #--------------------------------------------------------------------------
  def start_balloon
    dispose_balloon
    @balloon_sprite = ::Sprite.new(viewport)
    set_balloon_duration
    @balloon_sprite.bitmap = Cache.system("Balloon")
    @balloon_sprite.ox = 16
    @balloon_sprite.oy = 32
    update_balloon
  end
  #--------------------------------------------------------------------------
  # ○ フキダシアイコンの時間設定
  #--------------------------------------------------------------------------
  def set_balloon_duration
    @balloon_duration = 8 * balloon_speed + balloon_wait
  end   
  #--------------------------------------------------------------------------
  # ○ フキダシアイコンの解放
  #--------------------------------------------------------------------------
  def dispose_balloon
    if @balloon_sprite
      @balloon_sprite.dispose
      @balloon_sprite = nil
    end
  end
  #--------------------------------------------------------------------------
  # ○ フキダシアイコンの更新
  #--------------------------------------------------------------------------
  def update_balloon
    if @balloon_duration > 0
      @balloon_duration -= 1
      if @balloon_duration > 0
        @balloon_sprite.x = x
        @balloon_sprite.y = y - height
        @balloon_sprite.z = z + 200
        sx = balloon_frame_index * 32
        sy = (@balloon_id - 1) * 32
        @balloon_sprite.src_rect.set(sx, sy, 32, 32)
      else
        set_balloon_duration
      end
      end_balloon if @battler.balloon_id == 0
    end
  end
  #--------------------------------------------------------------------------
  # ○ フキダシアイコンの終了
  #--------------------------------------------------------------------------
  def end_balloon
    dispose_balloon
    @balloon_duration   = 0
    @battler.balloon_id = 0
  end
  #--------------------------------------------------------------------------
  # ○ フキダシアイコンの表示速度
  #--------------------------------------------------------------------------
  def balloon_speed
    return 8
  end
  #--------------------------------------------------------------------------
  # ○ フキダシ最終フレームのウェイト時間
  #--------------------------------------------------------------------------
  def balloon_wait
    return 12
  end
  #--------------------------------------------------------------------------
  # ○ フキダシアイコンのフレーム番号
  #--------------------------------------------------------------------------
  def balloon_frame_index
    return 7 - [(@balloon_duration - balloon_wait) / balloon_speed, 0].max
  end
  #--------------------------------------------------------------------------
  # ☆ エフェクトの開始
  #--------------------------------------------------------------------------
  alias a1_side_view_spb_start_effect start_effect
  def start_effect(effect_type)
    return revert_to_normal if @battler.actor? && effect_type == :collapse
    a1_side_view_spb_start_effect(effect_type)
  end
end
#==============================================================================
# ■ Game_Unit
#------------------------------------------------------------------------------
#  ユニットを扱うクラスです。このクラスは Game_Party クラスと Game_Troop クラ
# スのスーパークラスとして使用されます。
#==============================================================================

class Game_Unit
  #--------------------------------------------------------------------------
  # ○ 公開インスタンス変数
  #--------------------------------------------------------------------------
  attr_accessor :parallel_action_members
  #--------------------------------------------------------------------------
  # ☆ オブジェクト初期化
  #--------------------------------------------------------------------------
  alias a1_side_view_gu_initialize initialize
  def initialize
    a1_side_view_gu_initialize
    @parallel_action_members = []
  end
end
#==============================================================================
# ■ Game_Party
#------------------------------------------------------------------------------
#  パーティを扱うクラスです。所持金やアイテムなどの情報が含まれます。このクラ
# スのインスタンスは $game_party で参照されます。
#==============================================================================

class Game_Party < Game_Unit
  #--------------------------------------------------------------------------
  # ○ 生存している戦闘メンバーの配列取得
  #--------------------------------------------------------------------------
  def alive_battle_members
    battle_members.select {|member| member.alive? }
  end
  #--------------------------------------------------------------------------
  # ○ 同時アクションのメンバーを設定
  #--------------------------------------------------------------------------
  def parallel_action_alive_members
    battle_members.select {|member| member.alive? && @parallel_action_members.include?(member.index) }
  end
end
#==============================================================================
# ■ Game_Troop
#------------------------------------------------------------------------------
#  敵グループおよび戦闘に関するデータを扱うクラスです。バトルイベントの処理も
# 行います。このクラスのインスタンスは $game_troop で参照されます。
#==============================================================================

class Game_Troop < Game_Unit
  #--------------------------------------------------------------------------
  # ☆ セットアップ
  #--------------------------------------------------------------------------
  alias a1_side_view_gtp_setup setup
  def setup(troop_id)
    a1_side_view_gtp_setup(troop_id)
    @enemies.each {|enemy| enemy.set_standard_pos }
  end
  #--------------------------------------------------------------------------
  # ○ 同時アクションのメンバーを設定
  #--------------------------------------------------------------------------
  def parallel_action_alive_members
    members.select {|member| member.alive? && @parallel_action_members.include?(member.index) }
  end
end
#==============================================================================
# ■ Game_Actor
#------------------------------------------------------------------------------
#  アクターを扱うクラスです。このクラスは Game_Actors クラス($game_actors)
# の内部で使用され、Game_Party クラス($game_party)からも参照されます。
#==============================================================================

class Game_Actor < Game_Battler
  #--------------------------------------------------------------------------
  # ○ 定数
  #--------------------------------------------------------------------------
  PATTERN_COUNT = 20
  STANDARD_POS  = A1_System::SideViewActionConfig::STANDARD_POS
  #--------------------------------------------------------------------------
  # ○ 公開インスタンス変数
  #--------------------------------------------------------------------------
  attr_accessor :pattern
  attr_accessor :pattern_fix
  attr_accessor :pre_pattern_fix
  attr_accessor :direction
  attr_accessor :battler_index
  #--------------------------------------------------------------------------
  # ★ セットアップ(個別バトルステータスウィンドウの再定義)
  #--------------------------------------------------------------------------
  def setup(actor_id)
    a1_psw_setup(actor_id)
    @screen_x        = 0
    @screen_y        = 0
    @screen_z        = 0
    @opacity         = 255
    @visible         = true
    @sprite_height   = 0
    @battler_name    = actor.character_name  
    @use_sprite      = @battler_name.empty? ? false : true
    @pattern         = 1
    @pattern_fix     = -1
    @pre_pattern_fix = -1
    @direction       = 4
    @target_x        = @screen_x
    @target_y        = @screen_y
    @distance_x      = 0.0
    @distance_y      = 0.0
    @pattern_count   = PATTERN_COUNT
    @pattern_plus    = 1
    @battler_index   = @character_index
    @battler_picture = actor.battler_picture
  end
  #--------------------------------------------------------------------------
  # ○ 歩行パターンの更新
  #--------------------------------------------------------------------------
  def update_pattern
    return @pattern = @pattern_fix if @pattern_fix >= 0
    @pattern_count -= 1
    change_pattern if @pattern_count == 0
  end
  #--------------------------------------------------------------------------
  # ○ 歩行パターンの変更
  #--------------------------------------------------------------------------
  def change_pattern
    @pattern += @pattern_plus
    @pattern_plus = -1 if @pattern_plus > 0 && @pattern == 2
    @pattern_plus =  1 if @pattern_plus < 0 && @pattern == 0
    @pattern_count = PATTERN_COUNT
  end
  #--------------------------------------------------------------------------
  # ○ 定位置を取得
  #--------------------------------------------------------------------------
  def members_standard_pos(index)
    STANDARD_POS[index]
  end
  #--------------------------------------------------------------------------
  # ○ 定位置をセット
  #--------------------------------------------------------------------------
  def setup_standard_pos(index)
    pos = members_standard_pos(index)
    @standard_x = pos[0]
    @standard_y = pos[1]
  end
  #--------------------------------------------------------------------------
  # ★ ダメージ効果の実行
  #--------------------------------------------------------------------------
  def perform_damage_effect
    Sound.play_actor_damage
  end
  #--------------------------------------------------------------------------
  # ☆ 通常能力値の加算値取得
  #--------------------------------------------------------------------------
  alias a1_side_view_ga_param_plus param_plus
  def param_plus(param_id)
    ret = a1_side_view_ga_param_plus(param_id)
    return ret if param_id != 2
    return ret - no_current_weapon_atk
  end
  #--------------------------------------------------------------------------
  # ○ 使用中の武器でない武器の攻撃力を取得
  #--------------------------------------------------------------------------
  def no_current_weapon_atk
    return 0 unless no_calc_weapon_atk?
    return calc_no_current_weapon_atk(no_current_weapon)
  end
  #--------------------------------------------------------------------------
  # ○ 使用中の武器でない武器を取得
  #--------------------------------------------------------------------------
  def no_current_weapon
    (weapons - [@current_weapon])[0]
  end
  #--------------------------------------------------------------------------
  # ○ 使用中の武器でない武器の攻撃力を計算
  #--------------------------------------------------------------------------
  def calc_no_current_weapon_atk(weapon)
    weapon.params[2]
  end
  #--------------------------------------------------------------------------
  # ○ 使用中の武器でない武器の攻撃力を計算しない?
  #--------------------------------------------------------------------------
  def no_calc_weapon_atk?
    weapons && @current_weapon && $game_party.in_battle && two_sword_style?
  end
  #--------------------------------------------------------------------------
  # ○ 通常攻撃が他のスキルに変化する条件
  #--------------------------------------------------------------------------
  def skill_change_condition
    return true unless two_sword_style?
    weapons.index(no_current_weapon) == 1
  end
#==============================================================================
# ■ 消耗品装備対応処理
#==============================================================================
  if $imported["A1_ConsumerEquip"]
  #--------------------------------------------------------------------------
  # ○ 使用中のメイン武器
  #--------------------------------------------------------------------------
  def current_main
    @current_main
  end
  #--------------------------------------------------------------------------
  # ○ 通常攻撃が他のスキルに変化する条件
  #--------------------------------------------------------------------------
  def skill_change_condition
    return true unless two_sword_style?
    no_current_index = weapons.index(no_current_weapon)
    return no_current_index == 0 if dominant_hand == "左"
    no_current_index == 1
  end
  #--------------------------------------------------------------------------
  # ☆ 通常能力値の基本値取得
  #--------------------------------------------------------------------------
  alias a1_side_view_ga_param_base param_base
  def param_base(param_id)
    ret = a1_side_view_ga_param_base(param_id)
    return ret if param_id != 2
    return ret unless no_calc_weapon_atk?
    no_current_index = weapons.index(no_current_weapon)
    basic = a1_ex_equip_ga_param_base(param_id)
    no_current_index = no_current_index == 1 ? 0 : 1 if dominant_hand == "左"
    no_current_index = 1 if dominant_hand == "両"
    return (ret - basic * DUAL_BASIC_RATE * dual_wirld_rate[no_current_index]).round.to_i
  end
  #--------------------------------------------------------------------------
  # ○ 使用中の武器でない武器を取得
  #--------------------------------------------------------------------------
  def no_current_weapon
    (weapons - [@current_weapon] - [@current_main])[0]
  end
  #--------------------------------------------------------------------------
  # ○ 使用中の武器でない武器の攻撃力を計算
  #--------------------------------------------------------------------------
  alias a1_side_view_for_consumer_equip_ga_calc_no_current_weapon_atk calc_no_current_weapon_atk
  def calc_no_current_weapon_atk(weapon)
    w_atk = a1_side_view_for_consumer_equip_ga_calc_no_current_weapon_atk(weapon)
    no_current_index = weapons.index(weapon)
    return (w_atk * dual_wirld_rate[no_current_index]).round.to_i
  end;end
#==============================================================================
# ■ パッシブスキル/スキルレベル対応処理
#==============================================================================
  if $imported["A1_PassiveSkill"]
  #--------------------------------------------------------------------------
  # ○ 使用中の武器でない武器の攻撃力を計算
  #--------------------------------------------------------------------------
  alias a1_side_view_for_passive_skill_ga_calc_no_current_weapon_atk calc_no_current_weapon_atk
  def calc_no_current_weapon_atk(weapon)
    w_atk = a1_side_view_for_passive_skill_ga_calc_no_current_weapon_atk(weapon)
    return w_atk if @current_weapon.wtype_id == weapon.wtype_id
    return w_atk + params_equip_passive(weapon, 2)
  end;end
end
#==============================================================================
# ■ Sprite_BattleCursor
#==============================================================================

class Sprite_BattleCursor < Sprite_Base
  #--------------------------------------------------------------------------
  # ☆ オブジェクト初期化
  #--------------------------------------------------------------------------
  alias a1_side_view_sbc_initialize initialize
  def initialize(color = DEFAULT_COLOR)
    a1_side_view_sbc_initialize(color)
    @angle     = 0
    @set_angle = 0
  end
  #--------------------------------------------------------------------------
  # ★ フレーム更新
  #--------------------------------------------------------------------------
  def update
    self.visible = @target ? true : false
    return unless @target
    super
    update_for_actor if @target.actor?
    update_for_enemy unless @target.actor?
    set_angle if @set_angle != @angle
  end
  #--------------------------------------------------------------------------
  # ○ 回転角度のセット
  #--------------------------------------------------------------------------
  def set_angle
    self.angle = @set_angle
    @angle = @set_angle
  end
  #--------------------------------------------------------------------------
  # ○ エネミー用フレーム更新
  #--------------------------------------------------------------------------
  def update_for_enemy
    self.x = @target.screen_x + @plus_x
    self.y = @target.screen_y - @target.battler_height + @plus_y
    @set_angle = 0
  end
  #--------------------------------------------------------------------------
  # ○ アクター用フレーム更新
  #--------------------------------------------------------------------------
  def update_for_actor
    self.x = @target.screen_x - 32 + @plus_x
    self.y = @target.screen_y - 16 + @plus_y
    @set_angle = 90
  end
end
#==============================================================================
# ■ Sprite_Base
#------------------------------------------------------------------------------
#  アニメーションの表示処理を追加したスプライトのクラスです。
#==============================================================================

class Sprite_Base < Sprite
  #--------------------------------------------------------------------------
  # ☆ アニメーションの開始
  #--------------------------------------------------------------------------
  alias a1_side_view_sb_start_animation start_animation
  def start_animation(animation, mirror = false)
    clone_animation = animation.clone
    clone_animation.position = $game_temp.force_animation_position if $game_temp.force_animation_position
    a1_side_view_sb_start_animation(clone_animation, mirror)
  end
end
#==============================================================================
# ■ Game_Temp
#------------------------------------------------------------------------------
#  セーブデータに含まれない、一時的なデータを扱うクラスです。このクラスのイン
# スタンスは $game_temp で参照されます。
#==============================================================================

class Game_Temp
  #--------------------------------------------------------------------------
  # ○ 公開インスタンス変数
  #--------------------------------------------------------------------------
  attr_accessor :force_animation_position
  #--------------------------------------------------------------------------
  # ☆ オブジェクト初期化
  #--------------------------------------------------------------------------
  alias a1_side_view_gt_initialize initialize
  def initialize
    a1_side_view_gt_initialize
    @force_animation_position = nil
  end
end
#==============================================================================
# ■ Game_Battler
#------------------------------------------------------------------------------
#  スプライトや行動に関するメソッドを追加したバトラーのクラスです。このクラス
# は Game_Actor クラスと Game_Enemy クラスのスーパークラスとして使用されます。
#==============================================================================

class Game_Battler < Game_BattlerBase
  #--------------------------------------------------------------------------
  # ○ 定数
  #--------------------------------------------------------------------------
  TSS_TP_RATE   = A1_System::SideViewActionConfig::TSS_TP_RATE
  DIRECTION_SET = {"下" => 2, "左" => 4, "右" => 6, "上" => 8}
  STATE_LIST    = A1_System::SideViewActionConfig::STATE_LIST
  #--------------------------------------------------------------------------
  # ○ 公開インスタンス変数
  #--------------------------------------------------------------------------
  attr_accessor :target_x
  attr_accessor :target_y
  attr_accessor :distance_x
  attr_accessor :distance_y
  attr_accessor :standard_x
  attr_accessor :standard_y
  attr_accessor :move_count
  attr_accessor :move_duration
  attr_accessor :pre_move_x
  attr_accessor :pre_move_y
  attr_accessor :battler_action
  attr_accessor :balloon_id
  attr_accessor :wait_collapse
  attr_accessor :reserve_wait
  attr_accessor :parallel_action
  attr_accessor :parallel_members
  attr_accessor :init_x
  attr_accessor :init_y
  attr_accessor :substitute_target
  #--------------------------------------------------------------------------
  # ☆ オブジェクト初期化
  #--------------------------------------------------------------------------
  alias a1_side_view_sb_initialize initialize
  def initialize
    @jump_peak         = 0
    @move_count        = 0
    @move_duration     = 0
    @c_action_count    = 0
    @c_action_index    = 0
    @c_action_list     = nil
    @c_action_loop     = false
    @battler_action    = nil
    @direction         = 4
    @break_action      = false
    @force_break       = false
    @balloon_id        = 0
    @continue          = true
    @wait_collapse     = false
    @next_action       = false
    @repeat_count      = []
    @next_repeat_count = []
    @action_depth      = 0
    @reserve_wait      = 0
    @parallel_action   = false
    @proc_reserve_wait = false
    @parallel_members  = []
    @init_x            = 0
    @init_y            = 0
    @substitute_target = nil
    a1_side_view_sb_initialize
  end
  #--------------------------------------------------------------------------
  # ○ パラメータの初期化
  #--------------------------------------------------------------------------
  def init_params
    @action_depth      = 0
    @repeat_count      = []
    @next_repeat_count = []
  end
  #--------------------------------------------------------------------------
  # ○ 戦闘行動の実行
  #--------------------------------------------------------------------------
  def execute_action
    @collapse_flag = true
    @return_flag   = false
    @screen_z += 100 if @screen_z
    set_current_weapon
    BattleManager.call_method(:execute_action)
    @screen_z -= 100 if @screen_z
  end
  #--------------------------------------------------------------------------
  # ○ スキル/アイテムの使用
  #--------------------------------------------------------------------------
  def battler_use_item
    @next_action = false
    init_params
    item    = current_action.item
    targets = current_action.pre_make_targets.compact
    BattleManager.move_target = targets[0]
    BattleManager.all_targets = targets
    BattleManager.call_method(:set_wait_collapse, targets, true)
    proc_item_action(item, targets)
    battler_use_item if @next_action
  end
  #--------------------------------------------------------------------------
  # ○ スキル/アイテム使用時のアクション実行
  #--------------------------------------------------------------------------
  def proc_item_action(item, targets)
    action_key = item.sv_action
    action_key = get_action(item) if action_key.empty?
    proc_action(action_key)
    @break_action   = false
    @force_break    = false
  end
  #--------------------------------------------------------------------------
  # ○ アクションの実行
  #--------------------------------------------------------------------------
  def proc_action(action_key, members = nil)
    actions = BattleManager.side_view_actions.action_list[action_key]
    actions.each {|action| conv_action_members(action, members)
      break if @break_action || @force_break
      @repeat_count[@action_depth] = @next_repeat_count[@action_depth]
    }
    return_standard_pos(members) unless @next_action
    BattleManager.action_wait_skip = false
  end
  #--------------------------------------------------------------------------
  # ○ 定位置に戻る
  #--------------------------------------------------------------------------
  def return_standard_pos(members)
    end_combo
    return unless @break_action && @action_depth == 0
    conv_action_members("コラプス[許可]", members)
    conv_action_members("移動[定位置[10, wait]]", members)
  end
  #--------------------------------------------------------------------------
  # ○ 使用武器のセット
  #--------------------------------------------------------------------------
  def set_current_weapon
    @current_weapon = weapons[0]
  end
  #--------------------------------------------------------------------------
  # ○ アクションの変換とメソッドのコール
  #--------------------------------------------------------------------------
  def conv_action_members(action, members, i = 0)
    @parallel_action = false
    return conv_action(action) unless members
    num = alive_members_num(members)
    members.each {|member| next unless member.alive?; parallel_action_proc(member, action, i, num); i+= 1 }
    $game_party.parallel_action_members = [] if self.actor?
    $game_troop.parallel_action_members = [] if self.enemy?
  end
  #--------------------------------------------------------------------------
  # ○ 同時アクションメンバーの生存メンバー数を取得
  #--------------------------------------------------------------------------
  def alive_members_num(members)
    return actor_alive_members_num(members) if self.actor?
    return enemy_alive_members_num(members)
  end
  #--------------------------------------------------------------------------
  # ○ 同時アクションメンバーの生存メンバー数を取得(アクター)
  #--------------------------------------------------------------------------
  def actor_alive_members_num(members)
    members.each {|member| $game_party.parallel_action_members.push(member.index) }
    return $game_party.parallel_action_alive_members.size - 1
  end
  #--------------------------------------------------------------------------
  # ○ 同時アクションメンバーの生存メンバー数を取得(エネミー)
  #--------------------------------------------------------------------------
  def enemy_alive_members_num(members)
    members.each {|member| $game_troop.parallel_action_members.push(member.index) }
    return $game_troop.parallel_action_alive_members.size - 1
  end
  #--------------------------------------------------------------------------
  # ○ ダメージの実行
  #--------------------------------------------------------------------------
  def proc_damage(params)
    action_targets.each {|target| BattleManager.call_method(:invoke_item, target, current_action.item) }
  end
  #--------------------------------------------------------------------------
  # ○ 使用武器
  #--------------------------------------------------------------------------
  def use_weapon_pos(params)
    next_use_weapon = params[0] == "左" && weapons[1] ? weapons[1] : weapons[0]
    change_weapon_and_target(next_use_weapon)
  end
  #--------------------------------------------------------------------------
  # ○ 使用武器変更とターゲットの再設定
  #--------------------------------------------------------------------------
  def change_weapon_and_target(next_use_weapon)
    BattleManager.call_method(:action_icon, @current_weapon.icon_index) if self.actor?
    @current_weapon = next_use_weapon
    BattleManager.all_targets = current_action.pre_make_targets.compact
  end
  #--------------------------------------------------------------------------
  # ○ ターゲットの取得
  #--------------------------------------------------------------------------
  def action_targets
    BattleManager.all_targets
  end
  #--------------------------------------------------------------------------
  # ○ 同時アクションの実行
  #--------------------------------------------------------------------------
  def parallel_action_proc(member, action, index, alive_members_num)
    member.parallel_action = true
    member.conv_action(action)
    wait_for_action(member.reserve_wait.to_i) if member.reserve_wait > 0 && index == alive_members_num
    member.reserve_wait = 0 if member
    member.parallel_action = false
  end
  #--------------------------------------------------------------------------
  # ○ アクションの変換とメソッドのコール
  #--------------------------------------------------------------------------
  def conv_action(action)
    @next_repeat_count[@action_depth] = 0
    return @continue = true unless @continue
    BattleManager.action_wait_skip = false
    return wait_for_action(action) if action.is_a?(Integer)
    p_action = action.gsub(/\[(.+)\]/, "")
    call_action_method(p_action, $1)
    proc_repeat(action) if @repeat_count[@action_depth] && @repeat_count[@action_depth] > 0
  end
  #--------------------------------------------------------------------------
  # ○ ウェイト
  #--------------------------------------------------------------------------
  def wait_for_action(duration)
    BattleManager.call_method(:wait, duration)
  end
  #--------------------------------------------------------------------------
  # ○ アクションの中断
  #--------------------------------------------------------------------------
  def break_action(params)
    @break_action = true
  end
  #--------------------------------------------------------------------------
  # ○ リピートの実行
  #--------------------------------------------------------------------------
  def proc_repeat(action)
    @repeat_count[@action_depth] -= 1
    conv_action(action)
  end
  #--------------------------------------------------------------------------
  # ○ 繰り返し
  #--------------------------------------------------------------------------
  def repeat_action(params)
    @next_repeat_count[@action_depth] = params[0].to_i - 1
  end
  #--------------------------------------------------------------------------
  # ○ 条件
  #--------------------------------------------------------------------------
  def next_condition(params)
    ret = check_condition(params[0])
    @continue = params[1] == "not" ? !ret : ret
  end
  #--------------------------------------------------------------------------
  # ○ 同時
  #--------------------------------------------------------------------------
  def parallel_action(params)
    members = parallel_all_members
    members = parallel_index_members(members, $1) if params[1] =~ /Index\[(.*?)\]/
    members = parallel_name_members(members, $1)  if params[1] =~ /名前\[(.*?)\]/
    proc_parallel_action(members, params[0])
  end
  #--------------------------------------------------------------------------
  # ○ 名前指定同時のメンバー取得
  #--------------------------------------------------------------------------
  def parallel_name_members(members, param, ret = [])
    return members unless self.actor?
    names = $a1_common.split_array(param)
    names.each {|name| members.each {|member| ret.push(member) if member.name == name }}
    return ret
  end
  #--------------------------------------------------------------------------
  # ○ Index指定同時のメンバー取得
  #--------------------------------------------------------------------------
  def parallel_index_members(members, param, ret = [])
    indexs = $a1_common.split_array(param)
    indexs.each {|index| ret.push(members[index.to_i]) }
    return ret
  end
  #--------------------------------------------------------------------------
  # ○ 全員同時のメンバー取得
  #--------------------------------------------------------------------------
  def parallel_all_members
    return $game_party.battle_members if self.actor?
    return $game_troop.members unless self.actor?
  end
  #--------------------------------------------------------------------------
  # ○ 同時アクション実行
  #--------------------------------------------------------------------------
  def proc_parallel_action(members, action_key)
    proc_action(action_key, members)
  end
  #--------------------------------------------------------------------------
  # ○ コンボ開始
  #--------------------------------------------------------------------------
  def start_combo
    @commbo      = true
    @next_action = true
  end
  #--------------------------------------------------------------------------
  # ○ コンボ終了
  #--------------------------------------------------------------------------
  def end_combo
    @commbo      = false
  end
  #--------------------------------------------------------------------------
  # ○ 派生
  #--------------------------------------------------------------------------
  def next_action(params)
    return setup_next_skill($1.to_i) if params[0] =~ /スキル\[(\d+)\]/
    return setup_next_item($1.to_i)  if params[0] =~ /アイテム\[(\d+)\]/
    @action_depth += 1
    proc_action(params[0])
    @action_depth -= 1 if @action_depth > 0
  end
  #--------------------------------------------------------------------------
  # ○ 派生スキルのセット
  #--------------------------------------------------------------------------
  def setup_next_skill(skill_id)
    current_action.set_skill(skill_id)
    @break_action = true
    @next_action  = true
  end
  #--------------------------------------------------------------------------
  # ○ 派生アイテムのセット
  #--------------------------------------------------------------------------
  def setup_next_item(item_id)
    current_action.set_item(item_id)
    @break_action = true
    @next_action  = true
  end
  #--------------------------------------------------------------------------
  # ○ メソッドのコール
  #--------------------------------------------------------------------------
  def call_action_method(action, param)
    param  = conv_action_params(param) if param
    params = $a1_common.split_array(param) if param
    method(BattleManager.side_view_actions.action_symbol[action]).call(params)
  end
  #--------------------------------------------------------------------------
  # ○ スクリプトのコンバート(配列から)
  #--------------------------------------------------------------------------
  def convert_script_array(params, ret = [])
    params.each {|param| ret.push(convert_script(param)) }
    return ret
  end
  #--------------------------------------------------------------------------
  # ○ スクリプトのコンバート
  #--------------------------------------------------------------------------
  def convert_script(param)
    return param unless param.is_a?(String)
    loop { param = param.sub(/<s>(.+?)<\/s>/i) { eval($1) }; break unless $1 }
    return param
  end
  #--------------------------------------------------------------------------
  # ○ アクションパラメータのコンバート
  #--------------------------------------------------------------------------
  def conv_action_params(param)
    param = convert_script(param)
    loop { param = param.sub(/<s>(.+?)<\/s>/i) { eval($1) }; break unless $1 }
    param = param.sub(/\{(.*?)\}/) { BattleManager.side_view_actions.action_params[$1] }
    return param unless $1
    conv_data = BattleManager.side_view_actions.action_params[$1]
    return conv_data unless conv_data.is_a?(String)
    param = conv_action_params(param) if $1
    return param
  end
  #--------------------------------------------------------------------------
  # ○ スキル/アイテムのアクションを取得
  #--------------------------------------------------------------------------
  def get_action(item)
    return get_item_action if item.is_a?(RPG::Item)
    get_skill_action(item)
  end
  #--------------------------------------------------------------------------
  # ○ アイテムのアクションを取得
  #--------------------------------------------------------------------------
  def get_item_action
    return "汎用アイテム使用"
  end
  #--------------------------------------------------------------------------
  # ○ スキルのアクションを取得
  #--------------------------------------------------------------------------
  def get_skill_action(item)
    return "防御" if item.id == 2
    return "汎用スキル使用" if item.damage.element_id >= 0
    action_key = @current_weapon.sv_action if @current_weapon
    return "通常攻撃" if !action_key || action_key.empty?
    return action_key
  end
  #--------------------------------------------------------------------------
  # ○ 実行
  #--------------------------------------------------------------------------
  def proc_use_item(params)
    BattleManager.action_wait_skip = true if params && params[0] == "skip"
    BattleManager.call_method(:use_item)
  end
  #--------------------------------------------------------------------------
  # ○ 移動
  #--------------------------------------------------------------------------
  def move_pos(params)
    return if @commbo
    @jump = (params[1] == "ジャンプ")
    return move_standard_pos($a1_common.split_array($1)) if params[0] =~ /定位置\[(.*?)\]/
    return move_leftstep($a1_common.split_array($1))     if params[0] =~ /前進\[(.*?)\]/
    return move_rightstep($a1_common.split_array($1))    if params[0] =~ /後退\[(.*?)\]/
    return move_to_target($a1_common.split_array($1))    if params[0] =~ /対象\[(.*?)\]/
    return move_to_center($a1_common.split_array($1))    if params[0] =~ /敵中心\[(.*?)\]/
    return rel_move($a1_common.split_array($1))          if params[0] =~ /相対\[(.*?)\]/
    return abs_move($a1_common.split_array($1))          if params[0] =~ /絶対\[(.*?)\]/
    return move_init_pos($a1_common.split_array($1))     if params[0] =~ /初期位置\[(.*?)\]/
    return move_substitute($a1_common.split_array($1))   if params[0] =~ /身代わり\[(.*?)\]/
  end
  #--------------------------------------------------------------------------
  # ○ 身代わり先に移動
  #--------------------------------------------------------------------------
  def move_substitute(params)
    substitute_target = $game_party.battle_members[@substitute_target]
    x = substitute_target.screen_x - 32
    y = substitute_target.screen_y
    move_to_pos(params[0].to_f, x, y)
    wait_for_move if params[1] == "wait"
  end
  #--------------------------------------------------------------------------
  # ○ 敵中心に移動
  #--------------------------------------------------------------------------
  def move_to_center(params)
    return move_to_target(params) unless self.actor?
    move_to_pos(params[0].to_f, Graphics.width / 3, Graphics.height / 3 * 2)
    wait_for_move if params[1] == "wait"
  end
  #--------------------------------------------------------------------------
  # ○ 初期位置に戻る
  #--------------------------------------------------------------------------
  def move_init_pos(params)
    move_to_pos(params[0].to_f, @init_x, @init_y)
    wait_for_move if params[1] == "wait"
  end
  #--------------------------------------------------------------------------
  # ○ 定位置に戻る
  #--------------------------------------------------------------------------
  def move_standard_pos(params)
    return if @screen_x == @standard_x && @screen_y == @standard_y
    BattleManager.call_method(:action_icon, @current_weapon.icon_index) if self.actor? && @current_weapon
    move_to_pos(params[0].to_f, @standard_x, @standard_y)
    wait_for_move if params[1] == "wait"
  end
  #--------------------------------------------------------------------------
  # ○ ターゲット前まで移動
  #--------------------------------------------------------------------------
  def move_to_target(params)
    target = BattleManager.move_target
    move_to_pos(params[0].to_f, post_target_x(target.screen_x), target.screen_y)
    wait_for_move if params[1] == "wait"
  end
  #--------------------------------------------------------------------------
  # ○ ターゲットの前を取得
  #--------------------------------------------------------------------------
  def post_target_x(target_screen_x)
    return target_screen_x + 64 if self.actor?
    return target_screen_x - 64
  end
  #--------------------------------------------------------------------------
  # ○ 指定位置まで移動
  #--------------------------------------------------------------------------
  def move_to_pos(duration, target_x, target_y)
    @move_count      = 0
    @move_duration   = duration
    @pre_move_x      = @screen_x
    @pre_move_y      = @screen_y
    @target_x        = @screen_x + (target_x - @screen_x)
    @distance_x      = (target_x - @screen_x) / duration
    @target_y        = @screen_y + (target_y - @screen_y)
    @distance_y      = (target_y - @screen_y) / duration
  end
  #--------------------------------------------------------------------------
  # ○ 左に1歩移動
  #--------------------------------------------------------------------------
  def move_leftstep(params)
    plus = self.actor? ? -32 : 32
    move_to_pos(params[0].to_f, @standard_x + plus, @standard_y)
    wait_for_move if params[1] == "wait"
  end
  #--------------------------------------------------------------------------
  # ○ 右に1歩移動
  #--------------------------------------------------------------------------
  def move_rightstep(params)
    plus = self.actor? ? 32 : -32
    move_to_pos(params[0].to_f, @standard_x + plus, @standard_y)
    wait_for_move if params[1] == "wait"
  end
  #--------------------------------------------------------------------------
  # ○ 相対移動
  #--------------------------------------------------------------------------
  def rel_move(params)
    target_x = @screen_x + params[0].to_i
    target_y = @screen_y + params[1].to_i
    move_to_pos(params[2].to_f, target_x, target_y)
    wait_for_move if params[3] == "wait"
  end
  #--------------------------------------------------------------------------
  # ○ 絶対移動
  #--------------------------------------------------------------------------
  def abs_move(params)
    move_to_pos(params[2].to_f, params[0].to_i, params[1].to_i)
    wait_for_move if params[3] == "wait"
  end
  #--------------------------------------------------------------------------
  # ○ 直立
  #--------------------------------------------------------------------------
  def set_pattern_fix(params)
    return @pre_pattern_fix =  1 if params && params[0] == "予約"
    return release_ptattern_fix  if params && params[0] == "解除"
    @pattern_fix = 1
  end
  #--------------------------------------------------------------------------
  # ○ 直立解除
  #--------------------------------------------------------------------------
  def release_ptattern_fix
    @pre_pattern_fix = -1
    @pattern_fix     = -1
  end
  #--------------------------------------------------------------------------
  # ○ 移動が終わるまでウェイト
  #--------------------------------------------------------------------------
  def wait_for_move
    return @reserve_wait = @move_duration if @parallel_action
    BattleManager.call_method(:wait_for_move) while move_now?
  end
  #--------------------------------------------------------------------------
  # ○ 移動中?
  #--------------------------------------------------------------------------
  def move_now?
    @move_duration > 0
  end
  #--------------------------------------------------------------------------
  # ○ 武器動作
  #--------------------------------------------------------------------------
  def weapon_action(params)
    return unless self.actor?
    sv_action = BattleManager.side_view_actions
    w_action  = sv_action.weapon_action[params[0]]
    p_action  = sv_action.picture_action(w_action[0])
    p_action  = conv_action_params(p_action) if p_action.is_a?(String)
    character_action([w_action[1]]) if w_action[1]
    use_icon  = @current_weapon.sv_icon >= 0 ?  @current_weapon.sv_icon : @current_weapon.icon_index
    BattleManager.call_method(:action_icon, use_icon, p_action, self)
  end
  #--------------------------------------------------------------------------
  # ○ ステート動作
  #--------------------------------------------------------------------------
  def state_action(params)
    return unless self.actor?
    param = params[0] if params
    action_name = now_state(param)
    action_name = wait_type if action_name == "待機"
    action_list = BattleManager.side_view_actions.state_actions[action_name]
    character_action([action_list[0]])
    @force_break  = action_list[1]
    @balloon_id   = action_list[2]
  end
  #--------------------------------------------------------------------------
  # ○ 表示するステート取得
  #--------------------------------------------------------------------------
  def now_state(now_state)
    states.each {|state| return state.name if STATE_LIST.include?(state.name)}
    return "防御待機" if guard?
    now_state ? now_state : "通常"
  end
  #--------------------------------------------------------------------------
  # ○ 待機タイプ取得
  #--------------------------------------------------------------------------
  def wait_type
    return "通常待機" unless current_action
    return "通常待機" unless current_action.item.is_a?(RPG::Skill)
    return "通常待機" if current_action.item.stype_id == 0
    return "#{$data_system.skill_types[current_action.item.stype_id]}待機"
  end
  #--------------------------------------------------------------------------
  # ○ キャラクター動作
  #--------------------------------------------------------------------------
  def character_action(params)
    return unless self.actor?
    c_action = BattleManager.side_view_actions.character_action[params[0]]
    proc_character_action(c_action)
  end
  #--------------------------------------------------------------------------
  # ○ キャラクター動作の実行
  #--------------------------------------------------------------------------
  def proc_character_action(c_action)
    @c_action_loop     = c_action[1]
    @c_action_list     = c_action[0]
    @c_action_list     = conv_action_params(@c_action_list) if @c_action_list.is_a?(String)
    @c_action_index    = 0
    setup_action_battler(c_action[2]) if c_action[2]
  end
  #--------------------------------------------------------------------------
  # ○ キャラクター動作の更新
  #--------------------------------------------------------------------------
  def update_character_action
    return unless @c_action_list
    return @c_action_count -= 1 if @c_action_count > 0
    action = @c_action_list[@c_action_index]
    @c_action_index += 1
    @c_action_index = 0   if !@c_action_list[@c_action_index] && @c_action_loop
    @c_action_list  = nil if !@c_action_list[@c_action_index] && !@c_action_loop
    return @c_action_count = action if action.is_a?(Integer)
    return unless action
    conv_action(action)
  end
  #--------------------------------------------------------------------------
  # ○ バトラーアクションの設定
  #--------------------------------------------------------------------------
  def setup_action_battler(action_name)
    sv_action = BattleManager.side_view_actions
    @battler_action = sv_action.picture_action(action_name)
    @battler_action = conv_action_params(@battler_action) if @battler_action.is_a?(String)
    @x_plus         = (@battler_action.ed_x - @battler_action.st_x) / @battler_action.duration.to_f
    @y_plus         = (@battler_action.ed_y - @battler_action.st_y) / @battler_action.duration.to_f
    @pre_move_x = @screen_x
    @pre_move_y = @screen_y
    update_action_pos
  end
  #--------------------------------------------------------------------------
  # ○ アニメ
  #--------------------------------------------------------------------------
  def proc_animation(params)
    BattleManager.action_wait_skip = true if params[1] == "skip"
    animation_id = params[0].to_i
    BattleManager.call_method(:show_animation, animation_targets(params), animation_id)
  end
  #--------------------------------------------------------------------------
  # ○ アニメのターゲットと位置を取得
  #--------------------------------------------------------------------------
  def animation_targets(params)
    targets = action_targets                if params[1] == "対象" || params[1] == "画面"
    targets = [self]                        if params[1] == "自身"
    $game_temp.force_animation_position = 1 if params[1] == "対象" || params[1] == "自身"
    $game_temp.force_animation_position = 3 if params[1] == "画面"
    return targets
  end
  #--------------------------------------------------------------------------
  # ○ 向き
  #--------------------------------------------------------------------------
  def change_direction(params)
    return unless self.actor?
    @direction = DIRECTION_SET[params[0]] if params[0]
    @pattern   = params[1].to_i if params[1]
  end
  #--------------------------------------------------------------------------
  # ○ ジャンプの高さを計算
  #--------------------------------------------------------------------------
  def jump_height
    return 0 unless @jump
    jump_peak = @move_duration / 2
    (jump_peak * jump_peak - (@move_count - jump_peak).abs ** 2) / 2
  end
  #--------------------------------------------------------------------------
  # ○ バトラー移動の更新
  #--------------------------------------------------------------------------
  def update_battler_move
    update_character_action if self.actor?
    update_action_pos if @battler_action
    return unless @distance_x && @distance_y
    return if @move_duration == 0
    @screen_x = @pre_move_x + @distance_x * @move_count
    @screen_y = @pre_move_y + @distance_y * @move_count - jump_height
    @move_count += 1
    move_end   if @move_count     >  @move_duration + 1
    return unless self.actor?
    @pattern_fix = @pre_pattern_fix if @distance_x == 0 && @distance_y == 0
  end
  #--------------------------------------------------------------------------
  # ○ バトラーアクション時の位置更新
  #--------------------------------------------------------------------------
  def update_action_pos
    @screen_x = @pre_move_x + @battler_action.st_x + @x_plus
    @screen_y = @pre_move_y + @battler_action.st_y + @y_plus
  end
  #--------------------------------------------------------------------------
  # ○ 移動の完了
  #--------------------------------------------------------------------------
  def move_end
    move_end_x
    move_end_y
    @jump = false
    @move_duration = 0
  end
  #--------------------------------------------------------------------------
  # ○ x座標移動の完了
  #--------------------------------------------------------------------------
  def move_end_x
    @screen_x = @target_x
    @distance_x = 0
  end
  #--------------------------------------------------------------------------
  # ○ y座標移動の完了
  #--------------------------------------------------------------------------
  def move_end_y
    @screen_y = @target_y
    @distance_y = 0
  end
  #--------------------------------------------------------------------------
  # ○ グラフィック変更
  #--------------------------------------------------------------------------
  def change_graphic(params)
    return unless self.actor?
    c_info         = actor.multi_character(params[0])
    @battler_name  = c_info[0]
    @battler_index = c_info[1]
    @direction     = DIRECTION_SET[params[1]] if params[1]
    @pattern       = params[2] ? params[2].to_i : 1
    @pattern_fix   = @pattern if params[3] == "固定"
  end
  #--------------------------------------------------------------------------
  # ○ コラプス許可の設定
  #--------------------------------------------------------------------------
  def set_collapse(params)
    return unless @collapse_flag
    @collapse_flag = params[0] == "許可" ? false : true
    BattleManager.call_method(:set_wait_collapse, action_targets, @collapse_flag, @collapse_flag)
  end
  #--------------------------------------------------------------------------
  # ○ アイテム/スキル使用可能チェック
  #--------------------------------------------------------------------------
  def item_usable?(kind, id)
    return usable?($data_skills[id]) if kind == "スキル"
    return $game_party.usable?($data_items[id]) if kind == "アイテム" && self.actor?
  end
  #--------------------------------------------------------------------------
  # ○ ピクチャ
  #--------------------------------------------------------------------------
  def picture_action(params)
    return unless params
    return show_picture($1)        if params[0] =~ /表示\[(.+)\]/
    return move_picture($1)        if params[0] =~ /移動\[(.+)\]/
    return rotate_picture($1)      if params[0] =~ /回転\[(.+)\]/
    return tone_change_picture($1) if params[0] =~ /色調\[(.+)\]/
    return erase_picture($1.to_i)  if params[0] =~ /消去\[(\d+)\]/
  end
  #--------------------------------------------------------------------------
  # ○ ピクチャの表示
  #--------------------------------------------------------------------------
  def show_picture(param_name)
    params     = BattleManager.side_view_actions.picture_params[param_name]
    params     = convert_script_array(params)
    pic_name   = params[1] == "バトラー" ? @battler_picture : params[1]
    return if pic_name.empty?
    picture    = $game_troop.screen.pictures[params[0].to_i]
    name       = pic_name
    origin     = params[2] == "左上" ? 0 : 1
    x          = params[3].to_i
    y          = params[4].to_i
    zoom_x     = params[5].to_i
    zoom_y     = params[6].to_i
    opacity    = params[7].to_i
    blend_type = params[8].to_i
    picture.show(name, origin, x, y, zoom_x, zoom_y, opacity, blend_type)   
  end
  #--------------------------------------------------------------------------
  # ○ ピクチャの移動
  #--------------------------------------------------------------------------
  def move_picture(param_name)
    params     = BattleManager.side_view_actions.picture_params[param_name]
    params     = convert_script_array(params)
    picture    = $game_troop.screen.pictures[params[0].to_i]
    origin     = params[1] == "左上" ? 0 : 1
    x          = params[2].to_i
    y          = params[3].to_i
    zoom_x     = params[4].to_i
    zoom_y     = params[5].to_i
    opacity    = params[6].to_i
    blend_type = params[7].to_i
    duration   = params[8].to_i
    picture.move(origin, x, y, zoom_x, zoom_y, opacity, blend_type, duration)
  end
  #--------------------------------------------------------------------------
  # ○ ピクチャの回転
  #--------------------------------------------------------------------------
  def rotate_picture(param_name)
    params     = BattleManager.side_view_actions.picture_params[param_name]
    params     = convert_script_array(params)
    $game_troop.screen.pictures[params[0].to_i].rotate(params[1].to_i)
  end
  #--------------------------------------------------------------------------
  # ○ ピクチャの色調変更
  #--------------------------------------------------------------------------
  def tone_change_picture(param_name)
    params     = BattleManager.side_view_actions.picture_params[param_name]
    params     = convert_script_array(params)
    picture    = $game_troop.screen.pictures[params[0].to_i]
    r          = params[1].to_i
    g          = params[2].to_i
    b          = params[3].to_i
    gr         = params[4].to_i if params[4]
    tone       = Tone.new(r, g, b, gr) if params[4]
    tone       = Tone.new(r, g, b) unless params[4]
    picture.start_tone_change(tone, params[5].to_i)
  end
  #--------------------------------------------------------------------------
  # ○ ピクチャの消去
  #--------------------------------------------------------------------------
  def erase_picture(pic_no)
    $game_troop.screen.pictures[pic_no].erase
  end
  #--------------------------------------------------------------------------
  # ★ スキル/アイテムの使用者側への効果
  #--------------------------------------------------------------------------
  def item_user_effect(user, item)
    gain = user.two_sword_style? ? item.tp_gain * TSS_TP_RATE : item.tp_gain
    user.tp += gain.round * user.tcr
  end
  #--------------------------------------------------------------------------
  # ○ ターゲットの生存チェック
  #--------------------------------------------------------------------------
  def target_alive_check
    action_targets.each {|target| return true if target.hp > 0 }
    return false
  end
  #--------------------------------------------------------------------------
  # ○ 条件のチェック
  #--------------------------------------------------------------------------
  def check_condition(condition)
    return two_sword_style?                        if condition == "二刀流"
    return item_usable?($1, $2.to_i)               if condition =~ /(\S+)使用可\[(\d+)\]/
    return target_alive_check                      if condition == "対象生存"
    return hp > 0                                  if condition == "自身生存"
    return @substitute_target                      if condition == "身代わり"
    list = BattleManager.side_view_actions.condition_list
    return eval($1) if list[condition] =~ /<s>(.+?)<\/s>/
    return true
  end
  #--------------------------------------------------------------------------
  # ○ オーディオアクション
  #--------------------------------------------------------------------------
  def audio_action(params)
    return audio_se(params[1], $1, $2.to_i, $3.to_i)  if params[0] =~ /SE\[(\S+)[,](\d+)[,](\d+)\]/
    return audio_me(params[1], $1, $2.to_i, $3.to_i)  if params[0] =~ /ME\[(\S+)[,](\d+)[,](\d+)\]/
    return audio_bgs(params[1], $1, $2.to_i, $3.to_i) if params[0] =~ /BGS\[(\S+)[,](\d+)[,](\d+)\]/
    return audio_bgm_fede($1, $2.to_i, $3.to_i)       if params[0] =~ /BGM\[フェード(\S+?)[,](\d+)[,]?(\d+)?\]/
    return audio_bgm(params[1], $1, $2.to_i, $3.to_i) if params[0] =~ /BGM\[(\S+)[,](\d+)[,](\d+)\]/
  end
  #--------------------------------------------------------------------------
  # ○ SEの演奏/停止
  #--------------------------------------------------------------------------
  def audio_se(kind, name, volume, pitch)
    return RPG::SE.stop if kind == "停止"
    RPG::SE.new(name, volume, pitch).play
  end
  #--------------------------------------------------------------------------
  # ○ MEの演奏/停止
  #--------------------------------------------------------------------------
  def audio_me(kind, name, volume, pitch)
    return RPG::ME.stop if kind == "停止"
    RPG::ME.new(name, volume, pitch).play
  end
  #--------------------------------------------------------------------------
  # ○ BGSの演奏/停止
  #--------------------------------------------------------------------------
  def audio_bgs(kind, name, volume, pitch)
    return RPG::BGS.stop if kind == "停止"
    RPG::BGS.new(name, volume, pitch).play
  end
  #--------------------------------------------------------------------------
  # ○ BGMの演奏/停止
  #--------------------------------------------------------------------------
  def audio_bgm(kind, name, volume, pitch)
    return RPG::BGM.stop if kind == "停止"
    RPG::BGM.new(name, volume, pitch).play
  end
  #--------------------------------------------------------------------------
  # ○ BGMのフェードイン/フェードアウト
  #--------------------------------------------------------------------------
  def audio_bgm_fede(kind, param1, param2)
    return RPG::BGM.fade(param1) if kind == "アウト"
    audio_class = A1_System::AudioFile.new(RPG::BGM.last, param1, param2)
    $a1_common.fadein_bgm = audio_class
  end
  #--------------------------------------------------------------------------
  # ○ BGSのフェードイン/フェードアウト
  #--------------------------------------------------------------------------
  def audio_bgs_fede(kind, param1, param2)
    return RPG::BGS.fade(param1) if kind == "アウト"
    audio_class = A1_System::AudioFile.new(RPG::BGS.last, param1, param2)
    $a1_common.fadein_bgs = audio_class
  end
#==============================================================================
# ■ 消耗品装備対応処理
#==============================================================================
  if $imported["A1_ConsumerEquip"]
  #--------------------------------------------------------------------------
  # ○ 使用武器
  #--------------------------------------------------------------------------
  def use_weapon_pos(params)
    next_weapon = next_use_weapon(params)
    change_weapon_and_target(next_weapon)
  end
  #--------------------------------------------------------------------------
  # ○ 次に使う武器を取得
  #--------------------------------------------------------------------------
  def next_use_weapon(params)
    return chenge_consumer_main(params) if use_consumer?
    return dominant_hand == "左" && two_sword_style? ? weapons[0] : weapons[1] if params[0] == "左"
    return dominant_hand == "左" && two_sword_style? ? weapons[1] : weapons[0]
    return weapons[0]
  end
  #--------------------------------------------------------------------------
  # ○ 消耗品を使う武器のメインを変更
  #--------------------------------------------------------------------------
  def chenge_consumer_main(params)
    @current_main = dominant_hand == "左" && two_sword_style? ? weapons[0] : weapons[1] if params[0] == "左"
    @current_main = dominant_hand == "左" && two_sword_style? ? weapons[1] : weapons[0] if params[0] != "左"
    return consumer_equip[0]
  end
  #--------------------------------------------------------------------------
  # ○ 主武器
  #--------------------------------------------------------------------------
  def main_weapon
    return weapons[0] unless self.actor?
    dominant_hand == "左" && two_sword_style? ? weapons[1] : weapons[0]
  end
  #--------------------------------------------------------------------------
  # ○ 使用武器のセット
  #--------------------------------------------------------------------------
  def set_current_weapon
    main = main_weapon
    @current_weapon = main
    return if !self.actor?
    return if !use_consumer?
    @current_main   = main
    @current_weapon = consumer_equip[0]
  end;end
#==============================================================================
# ■ 全体通常攻撃対応処理
#==============================================================================
  if $imported["A1_WideNomalAttack"]
  #--------------------------------------------------------------------------
  # ★ 全体攻撃武器?(全体通常攻撃の再定義)
  #--------------------------------------------------------------------------
  def wide_attack_weapon?(any)
    return @current_weapon.wide_attack if @current_weapon && any
    return weapons.all? {|weapon| next unless weapon; weapon.wide_attack }
  end;end
end
#==============================================================================
# ■ Game_Temp
#------------------------------------------------------------------------------
#  セーブデータに含まれない、一時的なデータを扱うクラスです。このクラスのイン
# スタンスは $game_temp で参照されます。
#==============================================================================

class Game_Temp
  #--------------------------------------------------------------------------
  # ○ 公開インスタンス変数
  #--------------------------------------------------------------------------
  attr_accessor :remove_party_action
  attr_accessor :add_party_action
  #--------------------------------------------------------------------------
  # ☆ オブジェクト初期化
  #--------------------------------------------------------------------------
  alias a1_side_view_gtp_initialize initialize
  def initialize
    a1_side_view_gtp_initialize
    @remove_party_action = nil
    @add_party_action    = nil
  end
end
#==============================================================================
# ■ A1_System::CommonModule
#==============================================================================

class A1_System::CommonModule
  #--------------------------------------------------------------------------
  # ☆ 注釈コマンド定義
  #--------------------------------------------------------------------------
  alias a1_side_view_define_command define_command
  def define_command
    a1_side_view_define_command
    @cmd_108["脱退アクション"] = :remove_party_action
    @cmd_108["加入アクション"] = :add_party_action
    @cmd_108["アクション実行"] = :proc_event_action
  end
end
#==============================================================================
# ■ Game_Interpreter
#------------------------------------------------------------------------------
#  イベントコマンドを実行するインタプリタです。このクラスは Game_Map クラス、
# Game_Troop クラス、Game_Event クラスの内部で使用されます。
#==============================================================================

class Game_Interpreter
  #--------------------------------------------------------------------------
  # ○ 脱退アクション
  #--------------------------------------------------------------------------
  def remove_party_action(params)
    return unless $game_party.in_battle
    $game_temp.remove_party_action = params[0]
  end
  #--------------------------------------------------------------------------
  # ○ 加入アクション
  #--------------------------------------------------------------------------
  def add_party_action(params)
    return unless $game_party.in_battle
    $game_temp.add_party_action = params[0]
  end
  #--------------------------------------------------------------------------
  # ○ アクション実行
  #--------------------------------------------------------------------------
  def proc_event_action(params)
    return unless $game_party.in_battle
    member = params[0] =~ /([0-9]+)/ ? $game_party.battle_members[$1.to_i] : search_battle_members(params[0])
    return unless member
    BattleManager.call_method(:proc_event_action, member, params[1])
  end
  #--------------------------------------------------------------------------
  # ○ バトルメンバーの名前から検索
  #--------------------------------------------------------------------------
  def search_battle_members(name)
    $game_party.battle_members.each {|member| return member if member.name == name }
  end
end
end[/pre]

陣形
[pre lang="ruby"]#===========================================================================
# ◆ A1 Scripts ◆
#    陣形(RGSS3)
#
# バージョン   : 1.00 (2012/01/18)
# 作者         : A1
# URL     : http://a1tktk.web.fc2.com/
#---------------------------------------------------------------------------
# 機能:
# ・われわれはインペリアルクロスという陣形で戦う
#---------------------------------------------------------------------------
# 更新履歴   :2012/01/18 Ver1.00 リリース
#              :2012/01/21 Ver1.10 指定した陣形がない時はフリーファイトにするよう調整
#---------------------------------------------------------------------------
# 設置場所      
#    サイドビューバトルスクリプト以下
#
# 必要スクリプト
#    サイドビューバトルスクリプト
#    戦闘中入れ替えスクリプト
#---------------------------------------------------------------------------
# 使い方
#   ■ 陣形設定 に設定します
#   ■ サイドビューアクション設定 に設定します
#
#   イベントコマンド「注釈」に記述します
#
#     陣形メニュー
#
#       陣形メニュー画面を開きます
#
#     陣形習得 追加|削除 陣形no
#
#       指定した陣形noの陣形を追加/削除します
#
#     陣形変更 陣形no
#
#       現在の陣形を指定した陣形noの陣形に変更します
#==============================================================================
$imported ||= {}
if $imported["A1_SideViewBattle"] && $imported["A1_ChangeMember"]
$imported["A1_BattleFormation"] = true
old_common_script("陣形", "4.20") if common_version < 4.20
#==============================================================================
# ■ 陣形設定
#==============================================================================
module A1_System::BattleFormationConfig
  #--------------------------------------------------------------------------
  # 陣形メニュー画面を開く、メニュー画面でのコマンド名
  #--------------------------------------------------------------------------
  COMMAND_NAME       = "陣形"
  #--------------------------------------------------------------------------
  # 初期状態で習得している陣形no
  #--------------------------------------------------------------------------
  STARTING_LEARNED   = [0, 1]
  #--------------------------------------------------------------------------
  # 初期状態の陣形
  #--------------------------------------------------------------------------
  STARTING_FORMATION = 1
  #--------------------------------------------------------------------------
  # 最大戦闘参加人数
  #--------------------------------------------------------------------------
  MAX_BATTLE_MEMBERS = 5
  #--------------------------------------------------------------------------
  # 戦闘テストで5人目を使う
  #--------------------------------------------------------------------------
  TEST_5TH_MEMBER    = true
  #--------------------------------------------------------------------------
  # 各陣形のウィンドウ位置/メンバー初期位置/メンバー定位置座標
  #--------------------------------------------------------------------------
  FF_I_POS  = [ [790, 264], [774, 208], [806, 320], [758, 152], [822, 376] ]
  
  FF_W_POS  = [ [520, 293], [504, 237], [536, 349], [488, 181], [552, 405] ]
  FF_S_POS  = [ [504, 364], [488, 304], [520, 418], [472, 250], [536, 476] ]
  
  FF4_W_POS = [ [504, 253], [520, 309], [488, 197], [536, 365] ]
  FF4_S_POS = [ [488, 320], [504, 380], [472, 266], [520, 434] ]
  
  IC_W_POS  = [ [448, 317], [538, 317], [358, 317], [406, 237], [470, 409] ]
  IC_S_POS  = [ [464, 334], [554, 334], [374, 334], [448, 254], [480, 426] ]
  
  AS_W_POS  = [ [378, 285], [444, 253], [460, 333], [518, 221], [534, 381] ]
  AS_S_POS  = [ [374, 334], [440, 302], [456, 382], [514, 270], [530, 430] ]
  
  RS_W_POS  = [ [498, 293], [504, 237], [536, 349], [488, 181], [552, 405] ]
  RS_S_POS  = [ [472, 364], [488, 304], [520, 418], [472, 250], [536, 476] ]
  #--------------------------------------------------------------------------
  # 陣形位置設定
  #
  #   選択できる陣形は、現在の戦闘参加人数で固定です
  #
  #   陣形No:            陣形Noを指定します
  #                       イベントコマンドでメンバーの変更をした場合
  #                       陣形No 0 に強制的に変わります
  #   陣形名            :陣形名を指定します
  #   ウィンドウ位置    :各メンバーの個別ステータスウィンドウの位置を指定します
  #   初期位置          :各メンバーのバトル初期位置を指定します
  #   定位置            :各メンバーのバトル定位置を指定します
  #   上下カーソル移動順:カーソルを上下に動かした時のカーソル移動順を指定します
  #--------------------------------------------------------------------------
  BATTLE_FORMATION_POS = [
  {
  #--------------------------------------------------------------------------
  # 1人陣形
  #--------------------------------------------------------------------------
  # 陣形No   陣形名,               ウィンドウ位置, 初期位置, 定位置,   上下カーソル移動順
     0   => ["フリーファイト",     FF_W_POS,       FF_I_POS, FF_S_POS,  []],
  },{
  #--------------------------------------------------------------------------
  # 2人陣形
  #--------------------------------------------------------------------------
  # 陣形No   陣形名,               ウィンドウ位置, 初期位置, 定位置,   上下カーソル移動順
     0   => ["フリーファイト",     FF4_W_POS,      FF_I_POS, FF4_S_POS, [0, 1]],
  },{
  #--------------------------------------------------------------------------
  # 3人陣形
  #--------------------------------------------------------------------------
  # 陣形No   陣形名,               ウィンドウ位置, 初期位置, 定位置,   上下カーソル移動順
     0   => ["フリーファイト",     FF_W_POS,       FF_I_POS, FF_S_POS,  [1, 0, 2]],
  },{
  #--------------------------------------------------------------------------
  # 4人陣形
  #--------------------------------------------------------------------------
  # 陣形No   陣形名,               ウィンドウ位置, 初期位置, 定位置,   上下カーソル移動順
     0   => ["フリーファイト",     FF4_W_POS,      FF_I_POS, FF4_S_POS, [2, 0, 1, 3]],
  },{
  #--------------------------------------------------------------------------
  # 5人陣形
  #--------------------------------------------------------------------------
  # 陣形No   陣形名,               ウィンドウ位置, 初期位置, 定位置,   上下カーソル移動順
     0   => ["フリーファイト",     FF_W_POS,       FF_I_POS, FF_S_POS,  [3, 1, 0, 2, 4]],
     1   => ["インペリアルクロス", IC_W_POS,       FF_I_POS, IC_S_POS,  [2, 3, 0, 4, 1]],
     2   => ["アマゾンストライク", AS_W_POS,       FF_I_POS, AS_S_POS,  [0, 1, 2, 3, 4]],
     3   => ["ラピッドストリーム", RS_W_POS,       FF_I_POS, RS_S_POS,  [3, 1, 0, 2, 4]],
  }]
  #--------------------------------------------------------------------------
  # 陣形ボーナス設定
  #
  #   陣形名      :陣形位置設定で設定した陣形名を指定します
  #   付与メンバー:ボーナスを付与するメンバーの位置を指定します
  #   内容        :付与するボーナスの内容を指定します
  #--------------------------------------------------------------------------
  BATTLE_FORMATION_BONUS = {
  # 陣形名                付与メンバー => [内容]
  "フリーファイト"     => {},
  "インペリアルクロス" => {  1 => ["狙われ率-50"],
                             2 => ["行動前防御", "狙われ率50"],
                          },
  "アマゾンストライク" => {  0 => ["攻撃力25", "行動後防御", "すばやさ25"],
                             1 => ["攻撃力25", "行動後防御", "すばやさ25"],  
                             2 => ["攻撃力25", "行動後防御", "すばやさ25"],  
                          },
  "ラピッドストリーム" => { -1 => ["先制行動[RS]"] },
  
  }
  #--------------------------------------------------------------------------
  # 陣形ボーナスの内容設定
  #
  #   ボーナス名    :任意の文字列を指定します
  #   付与タイミング:開始時 行動後 ターン終了時 行動順序 のいずれかを指定します
  #
  #                   「開始時」は各種パラメータボーナスのみ
  #                   「行動後」は「防御状態」のみ
  #                   「ターン終了時」は「HP回復」「MP回復」「TP回復」のみ
  #                   「行動順序」は「先制行動」「敵行動待ち」「連続行動」のみ
  #
  #   内容          :防御状態            防御状態になります
  #                   狙われ率[val]       狙われ率が val の値追加されます
  #                   最大HP[val]         最大HPが val の値追加されます
  #                   最大MP[val]         最大MPが val の値追加されます
  #                   攻撃力[val,w_kind]  攻撃力が val の値追加されます w_kind 省略可
  #                                       w_kind を指定すると指定した武器タイプのみになります
  #                   防御力[val]         防御力が val の値追加されます
  #                   魔法力[val]         魔法力が val の値追加されます
  #                   魔法防御[val]       魔法防御が val の値追加されます
  #                   すばやさ[val]       すばやさが val の値追加されます
  #                   運[val]             運が val の値追加されます
  #                   HP回復[val%]        HPが val% の値回復します
  #                                       % を省略すると固定値になります
  #                   MP回復[val%]        MPが val% の値回復します
  #                                       % を省略すると固定値になります
  #                   TP回復[val%]        TPが val% の値回復します
  #                                       % を省略すると固定値になります
  #                   先制行動[order]     order の順番に先制行動します
  #                   敵行動待ち[order]   敵の行動を待ってから order の順番に行動します
  #                   連続行動[order]     order の最初のメンバーの行動順が回ってきたら
  #                                       order の順番に連続して行動します
  #--------------------------------------------------------------------------
  BONUS_INFO = {
  # ボーナス名         付与タイミング,  内容,            解除タイミング
  "行動前防御"     => ["開始時",       "防御状態",      "行動後"],
  "行動後防御"     => ["行動後",       "防御状態"],
  "狙われ率50"     => ["開始時",       "狙われ率[50]"],
  "狙われ率-50"    => ["開始時",       "狙われ率[-50]"],
  "攻撃力25"       => ["開始時",       "攻撃力[25]"],
  "弓攻撃力25"     => ["開始時",       "攻撃力[25,弓]"],
  "魔法力50"       => ["開始時",       "魔法力[50]"],
  "すばやさ25"     => ["開始時",       "すばやさ[25]"],
  "HP回復[5%]"     => ["ターン終了時", "HP回復[5%]"],
  "先制行動[RS]"   => ["行動順序",     "先制行動[0, 1, 2, 3, 4]"],
  "敵行動待ち[MF]" => ["行動順序",     "敵行動待ち[0, 1, 2, 3, 4]"],
  "連続行動[稲妻]" => ["行動順序",     "連続行動[3, 4, 1, 2, 0]"],
  "連続行動[龍陣]" => ["行動順序",     "連続行動[0, 1, 2, 3, 4]"],
  }
end
#==============================================================================
# ■ サイドビューアクション設定
#==============================================================================
module A1_System::SideViewActionConfig
  ACTION_LIST["陣形変更"]         = ["同時[陣形変更ジャンプ]"]
  ACTION_LIST["位置変更"]         = ["同時[陣形変更ジャンプ, Index[{1人目},{2人目}]]"]
  ACTION_LIST["陣形変更ジャンプ"] = ["移動[定位置[30, wait],ジャンプ]"]
  ACTION_PARAMS["1人目"]          = "<s>@parallel_members[0]</s>"
  ACTION_PARAMS["2人目"]          = "<s>@parallel_members[1]</s>"
end
#==============================================================================
# ■ BattleManager
#------------------------------------------------------------------------------
#  戦闘の進行を管理するモジュールです。
#==============================================================================

module BattleManager
  #--------------------------------------------------------------------------
  # ○ エイリアス用特異メソッド
  #--------------------------------------------------------------------------
  class << self
    alias :a1_battle_formation_bm_battle_end :battle_end
    alias :a1_battle_formation_bm_make_action_orders :make_action_orders
  end
  #--------------------------------------------------------------------------
  # ☆ 行動順序の作成
  #--------------------------------------------------------------------------
  def self.make_action_orders
    a1_battle_formation_bm_make_action_orders
    party_bonus = $game_party.formation_bonus[-1]
    return unless party_bonus && !@surprise
    members = $game_party.battle_members
    party_bonus.each {|bonus| orders_bonus(bonus, members)}
  end
  #--------------------------------------------------------------------------
  # ○ 行動順序系陣形ボーナス付与
  #--------------------------------------------------------------------------
  def self.orders_bonus(party_bonus, members)
    return if call_method(:member_any_dead?)
    bonus = $game_party.bonus_info(party_bonus)
    return unless bonus[0] == "行動順序"
    return all_members_preemptive($a1_common.split_array($1), members) if bonus[1] =~ /^先制行動\[(.+?)\]/
    return enemy_actionend_wait($a1_common.split_array($1), members)   if bonus[1] =~ /^敵行動待ち\[(.+?)\]/
    return chain_start_action($a1_common.split_array($1), members)     if bonus[1] =~ /^連続行動\[(.+?)\]/
  end
  #--------------------------------------------------------------------------
  # ○ 先制行動
  #--------------------------------------------------------------------------
  def self.all_members_preemptive(bonus, members)
    members.each {|member| @action_battlers.delete(member) }
    bonus.each_with_index {|index, i| @action_battlers.insert(i, members[index.to_i])  }
  end
  #--------------------------------------------------------------------------
  # ○ 敵行動待ち
  #--------------------------------------------------------------------------
  def self.enemy_actionend_wait(bonus, members)
    members.each {|member| @action_battlers.delete(member) }
    bonus.each {|index| @action_battlers.push(members[index.to_i]) }
  end
  #--------------------------------------------------------------------------
  # ○ 連続行動
  #--------------------------------------------------------------------------
  def self.chain_start_action(bonus, members)
    start_member = members[bonus[0].to_i]
    members.each {|member| next if start_member == member; @action_battlers.delete(member) }
    start_order  = @action_battlers.index(start_member)
    bonus.each_with_index {|index, i| next if i == 0; @action_battlers.insert(start_order + i, members[index.to_i]) }
  end
  #--------------------------------------------------------------------------
  # ☆ 戦闘終了
  #     result : 結果(0:勝利 1:逃走 2:敗北)
  #--------------------------------------------------------------------------
  def self.battle_end(result)
    call_method(:init_formation_bonus)
    a1_battle_formation_bm_battle_end(result)
  end
end
#==============================================================================
# ■ DataManager
#------------------------------------------------------------------------------
#  データベースとゲームオブジェクトを管理するモジュールです。ゲームで使用する
# ほぼ全てのグローバル変数はこのモジュールで初期化されます。
#==============================================================================

module DataManager
  #--------------------------------------------------------------------------
  # ○ エイリアス用特異メソッド
  #--------------------------------------------------------------------------
  class << self
    alias :a1_battle_formation_bm_load_battle_test_database :load_battle_test_database
  end
  #--------------------------------------------------------------------------
  # ☆ 戦闘テスト用のデータベースをロード
  #--------------------------------------------------------------------------
  def self.load_battle_test_database
    a1_battle_formation_bm_load_battle_test_database
    return unless A1_System::BattleFormationConfig::TEST_5TH_MEMBER
    test_battler = RPG::System::TestBattler.new
    test_battler.actor_id = 9
    test_battler.level    = 30
    test_battler.equips   = [49,0,0,1]
    $data_system.test_battlers.push(test_battler)
  end
end
#==============================================================================
# ■ Game_Party
#------------------------------------------------------------------------------
#  パーティを扱うクラスです。所持金やアイテムなどの情報が含まれます。このクラ
# スのインスタンスは $game_party で参照されます。
#==============================================================================

class Game_Party < Game_Unit
  #--------------------------------------------------------------------------
  # ○ 定数
  #--------------------------------------------------------------------------
  BATTLE_FORMATION_POS   = A1_System::BattleFormationConfig::BATTLE_FORMATION_POS
  #--------------------------------------------------------------------------
  # ○ 公開インスタンス変数
  #--------------------------------------------------------------------------
  attr_accessor :learned_formation
  attr_accessor :battle_formation
  #--------------------------------------------------------------------------
  # ☆ オブジェクト初期化
  #--------------------------------------------------------------------------
  alias a1_battle_formation_gp_initialize initialize
  def initialize
    @learned_formation = A1_System::BattleFormationConfig::STARTING_LEARNED
    @battle_formation  = A1_System::BattleFormationConfig::STARTING_FORMATION
    a1_battle_formation_gp_initialize
  end
  #--------------------------------------------------------------------------
  # ☆ 戦闘テスト用パーティのセットアップ
  #--------------------------------------------------------------------------
  alias a1_battle_formation_gp_setup_battle_test_members setup_battle_test_members
  def setup_battle_test_members
    a1_battle_formation_gp_setup_battle_test_members
    @battle_formation  = A1_System::BattleFormationConfig::STARTING_FORMATION
  end
  #--------------------------------------------------------------------------
  # ★ バトルメンバーの最大数を取得
  #--------------------------------------------------------------------------
  def max_battle_members
    return A1_System::BattleFormationConfig::MAX_BATTLE_MEMBERS
  end
  #--------------------------------------------------------------------------
  # ○ 現在有効な陣形を取得
  #--------------------------------------------------------------------------
  def enable_formation(ret = [])
    can_use_formation.keys.each {|key| ret.push(key) if @learned_formation.include?(key) }
    return ret
  end
  #--------------------------------------------------------------------------
  # ○ 現在の人数で使用できる陣形の取得
  #--------------------------------------------------------------------------
  def can_use_formation
    BATTLE_FORMATION_POS[battle_members.size - 1]
  end
  #--------------------------------------------------------------------------
  # ☆ アクターを加える
  #--------------------------------------------------------------------------
  alias a1_battle_formation_gp_add_actor add_actor
  def add_actor(actor_id)
    @battle_formation = 0
    a1_battle_formation_gp_add_actor(actor_id)
  end
  #--------------------------------------------------------------------------
  # ☆ アクターを外す
  #--------------------------------------------------------------------------
  alias a1_battle_formation_gp_remove_actor remove_actor
  def remove_actor(actor_id)
    @battle_formation = 0
    a1_battle_formation_gp_remove_actor(actor_id)
  end
end
#==============================================================================
# ■ Game_Troop
#------------------------------------------------------------------------------
#  敵グループおよび戦闘に関するデータを扱うクラスです。バトルイベントの処理も
# 行います。このクラスのインスタンスは $game_troop で参照されます。
#==============================================================================

class Game_Troop < Game_Unit
  #--------------------------------------------------------------------------
  # ○ 公開インスタンス変数
  #--------------------------------------------------------------------------
  attr_accessor :battle_formation
  attr_accessor :use_formation_type
  #--------------------------------------------------------------------------
  # ☆ オブジェクト初期化
  #--------------------------------------------------------------------------
  alias a1_battle_formation_gtp_initialize initialize
  def initialize
    @battle_formation   = 0
    @use_formation_type = 4
    a1_battle_formation_gtp_initialize
  end
  #--------------------------------------------------------------------------
  # ○ 現在使用できる陣形の取得
  #--------------------------------------------------------------------------
  def can_use_formation
    @use_formation_type
  end
end
#==============================================================================
# ■ Game_Unit
#------------------------------------------------------------------------------
#  ユニットを扱うクラスです。このクラスは Game_Party クラスと Game_Troop クラ
# スのスーパークラスとして使用されます。
#==============================================================================

class Game_Unit
  #--------------------------------------------------------------------------
  # ○ 定数
  #--------------------------------------------------------------------------
  BATTLE_FORMATION_BONUS = A1_System::BattleFormationConfig::BATTLE_FORMATION_BONUS
  BONUS_INFO             = A1_System::BattleFormationConfig::BONUS_INFO
  #--------------------------------------------------------------------------
  # ○ 陣形を取得
  #--------------------------------------------------------------------------
  def formation(id)
    ret = can_use_formation
    return ret[0] unless ret[id]
    return ret[id]
  end
  #--------------------------------------------------------------------------
  # ○ 現在の陣形の名前を取得
  #--------------------------------------------------------------------------
  def formation_name(id = @battle_formation)
    formation(id)[0]
  end
  #--------------------------------------------------------------------------
  # ○ 現在の陣形のウィンドウ位置を取得
  #--------------------------------------------------------------------------
  def formation_window_pos(id = @battle_formation)
    formation(id)[1]
  end
  #--------------------------------------------------------------------------
  # ○ 現在の陣形のアクター初期位置を取得
  #--------------------------------------------------------------------------
  def formation_init_pos(id = @battle_formation)
    formation(id)[2]
  end
  #--------------------------------------------------------------------------
  # ○ 現在の陣形のアクター定位置を取得
  #--------------------------------------------------------------------------
  def formation_standard_pos(id = @battle_formation)
    formation(id)[3]
  end
  #--------------------------------------------------------------------------
  # ○ 現在の陣形のカーソル順番を取得
  #--------------------------------------------------------------------------
  def formation_cursor_order(id = @battle_formation)
    formation(id)[4]
  end
  #--------------------------------------------------------------------------
  # ○ 現在の陣形の陣形ボーナスを取得
  #--------------------------------------------------------------------------
  def formation_bonus(id = @battle_formation)
    BATTLE_FORMATION_BONUS[formation_name(id)]
  end
  #--------------------------------------------------------------------------
  # ○ 陣形ボーナス情報を取得
  #--------------------------------------------------------------------------
  def bonus_info(kind)
    BONUS_INFO[kind]
  end
end
#==============================================================================
# ■ Window_BattleActors
#==============================================================================

class Window_BattleActors < Window_Base
  #--------------------------------------------------------------------------
  # ★ ウィンドウ位置の取得(サイドビューバトルの再定義)
  #--------------------------------------------------------------------------
  def window_pos(index)
    $game_party.formation_window_pos[index]
  end
  #--------------------------------------------------------------------------
  # ○ アクターの設定
  #--------------------------------------------------------------------------
  def actor=(actor)
    @actor = actor
  end
end
#==============================================================================
# ■ Window_BattleActor
#------------------------------------------------------------------------------
#  バトル画面で、行動対象のアクターを選択するウィンドウです。
#==============================================================================

class Window_BattleActor < Window_BattleStatus
  #--------------------------------------------------------------------------
  # ○ カーソルの移動処理
  #--------------------------------------------------------------------------
  def process_cursor_move
    return unless cursor_movable?
    last_index = @index
    cursor_next (Input.trigger?(:DOWN))  if Input.repeat?(:DOWN)
    cursor_prev (Input.trigger?(:UP))    if Input.repeat?(:UP)
    cursor_down (Input.trigger?(:RIGHT)) if Input.repeat?(:RIGHT)
    cursor_up   (Input.trigger?(:LEFT))  if Input.repeat?(:LEFT)
    Sound.play_cursor if @index != last_index
  end
  #--------------------------------------------------------------------------
  # ○ 次のカーソル位置
  #--------------------------------------------------------------------------
  def cursor_next(wrap = false)
    return if order.empty?
    next_index = order.index(index) + 1
    index = order[next_index]
    index = order[0] unless index
    select(index)
  end
  #--------------------------------------------------------------------------
  # ○ 前のカーソル位置
  #--------------------------------------------------------------------------
  def cursor_prev(wrap = false)
    return if order.empty?
    prev_index = order.index(index) - 1
    index = order[prev_index]
    index = order[order.size - 1] unless index
    select(index)
  end
  #--------------------------------------------------------------------------
  # ○ カーソル位置情報
  #--------------------------------------------------------------------------
  def order
    $game_party.formation_cursor_order
  end
end
#==============================================================================
# ■ Game_Actor
#------------------------------------------------------------------------------
#  アクターを扱うクラスです。このクラスは Game_Actors クラス($game_actors)
# の内部で使用され、Game_Party クラス($game_party)からも参照されます。
#==============================================================================

class Game_Actor < Game_Battler
  #--------------------------------------------------------------------------
  # ★ 定位置を取得(サイドビューバトルの再定義)
  #--------------------------------------------------------------------------
  def members_standard_pos(index)
    $game_party.formation_standard_pos[index]
  end
end
#==============================================================================
# ■ Scene_Battle
#------------------------------------------------------------------------------
#  バトル画面の処理を行うクラスです。
#==============================================================================

class Scene_Battle < Scene_Base
  #--------------------------------------------------------------------------
  # ☆ 開始処理
  #--------------------------------------------------------------------------
  alias a1_battle_formation_sb_start start
  def start
    define_battle_manager_method
    @formation_bonus = $game_party.formation_bonus
    a1_battle_formation_sb_start
  end
  #--------------------------------------------------------------------------
  # ○ バトルマネージャメソッドの定義
  #--------------------------------------------------------------------------
  alias a1_battle_formation_sb_define_battle_manager_method define_battle_manager_method
  def define_battle_manager_method
    a1_battle_formation_sb_define_battle_manager_method
    BattleManager.define_method(method(:init_formation_bonus), :init_formation_bonus)
    BattleManager.define_method(method(:member_any_dead?),     :member_any_dead?)
  end
  #--------------------------------------------------------------------------
  # ★ アクターの初期位置(サイドビューバトルの再定義)
  #--------------------------------------------------------------------------
  def members_init_pos(index)
    $game_party.formation_init_pos[index]
  end
  #--------------------------------------------------------------------------
  # ☆ 次のコマンド入力へ
  #--------------------------------------------------------------------------
  alias a1_battle_formation_sb_next_command next_command
  def next_command
    index = BattleManager.actor.index if BattleManager.actor
    a1_battle_formation_sb_next_command
    starting_formation_bonus(index, true)
  end
  #--------------------------------------------------------------------------
  # ☆ 前のコマンド入力へ
  #--------------------------------------------------------------------------
  alias a1_battle_formation_sb_prior_command prior_command
  def prior_command
    a1_battle_formation_sb_prior_command
    starting_formation_bonus(BattleManager.actor.index, false) if BattleManager.actor
  end
  #--------------------------------------------------------------------------
  # ○ 陣形ボーナスを取得
  #--------------------------------------------------------------------------
  def bonus_info(bonus)
    $game_party.bonus_info(bonus)
  end
  #--------------------------------------------------------------------------
  # ○ 開始時陣形ボーナス付与/解除
  #--------------------------------------------------------------------------
  def starting_formation_bonus(index, flag)
    return if member_any_dead?
    return unless @formation_bonus[index]
    @formation_bonus[index].each {|bonus| starting_bonus(bonus_info(bonus), index, flag) }
  end
  #--------------------------------------------------------------------------
  # ○ 開始時ボーナス付与/解除
  #--------------------------------------------------------------------------
  def starting_bonus(bonus, index, flag)
    return unless bonus[0] == "開始時"
    return bonus_guard(flag, index)                              if bonus[1] == "防御状態"
    return battle_members[index].formation_tgr = $1.to_i / 100.0 if bonus[1] =~ /狙われ率\[([-]?\d+)\]/
    return battle_members[index].formation_param[0] = $1.to_i    if bonus[1] =~ /最大HP\[([-]?\d+)\]/
    return battle_members[index].formation_param[1] = $1.to_i    if bonus[1] =~ /最大MP\[([-]?\d+)\]/
    return atk_bonus(index, $1.to_i, $2)                         if bonus[1] =~ /攻撃力\[([-]?\d+)[,]?(\S+)?\]/
    return battle_members[index].formation_param[3] = $1.to_i    if bonus[1] =~ /防御力\[([-]?\d+)\]/
    return battle_members[index].formation_param[4] = $1.to_i    if bonus[1] =~ /魔法力\[([-]?\d+)\]/
    return battle_members[index].formation_param[5] = $1.to_i    if bonus[1] =~ /魔法防御\[([-]?\d+)\]/
    return battle_members[index].formation_param[6] = $1.to_i    if bonus[1] =~ /すばやさ\[([-]?\d+)\]/
    return battle_members[index].formation_param[7] = $1.to_i    if bonus[1] =~ /運\[([-]?\d+)\]/
  end
  #--------------------------------------------------------------------------
  # ○ 攻撃力ボーナスの付与/解除
  #--------------------------------------------------------------------------
  def atk_bonus(index, num, kind)
    check_weapon_type(battle_members[index], kind)
    return battle_members[index].formation_param[2] = num unless kind
  end
  #--------------------------------------------------------------------------
  # ○ 武器タイプチェック
  #--------------------------------------------------------------------------
  def check_weapon_type(battler, kind)
    return true if battler.weapons[0] && $data_system.weapon_types[battler.weapons[0].wtype_id] == kind
    return true if battler.weapons[1] && $data_system.weapon_types[battler.weapons[1].wtype_id] == kind
    return false
  end
  #--------------------------------------------------------------------------
  # ○ 陣形防御ボーナスの付与/解除
  #--------------------------------------------------------------------------
  def bonus_guard(flag, index)
    battle_members[index].bounus_guard = flag
    battle_members[index].conv_action("状態[防御待機]") if flag
  end
  #--------------------------------------------------------------------------
  # ○ 行動前陣形ボーナスの解除
  #--------------------------------------------------------------------------
  def remove_before_action_formation_bonus(index)
    return unless @formation_bonus[index]
    @formation_bonus[index].each {|bonus| remove_before_bonus(bonus_info(bonus), index) }
  end
  #--------------------------------------------------------------------------
  # ○ 行動前陣形ボーナス解除
  #--------------------------------------------------------------------------
  def remove_before_bonus(bonus, index)
    return unless bonus[2] == "行動後"
    return bonus_guard(false, index) if bonus[1] == "防御状態"
  end
  #--------------------------------------------------------------------------
  # ○ 行動後陣形ボーナスの付与
  #--------------------------------------------------------------------------
  def add_after_action_formation_bonus(index)
    return if member_any_dead?
    return unless @formation_bonus[index]
    @formation_bonus[index].each {|bonus| add_after_bonus(bonus_info(bonus), index) }
  end
  #--------------------------------------------------------------------------
  # ○ 行動前陣形ボーナス付与
  #--------------------------------------------------------------------------
  def add_after_bonus(bonus, index)
    return unless bonus[0] == "行動後"
    return bonus_guard(true, index) if bonus[1] == "防御状態"
  end
  #--------------------------------------------------------------------------
  # ○ ターン終了時ボーナス検索
  #--------------------------------------------------------------------------
  def search_turn_end_bonus
    return if member_any_dead?
    battle_members.each {|member| turn_end_bonus_list(member, $game_party.formation_bonus[member.index]) }
  end
  #--------------------------------------------------------------------------
  # ○ ターン終了時ボーナスリスト作成
  #--------------------------------------------------------------------------
  def turn_end_bonus_list(member, bonus_key)
    return unless bonus_key
    bonus_key.each {|bonus| proc_turn_end_bonus(member, bonus) }
  end
  #--------------------------------------------------------------------------
  # ○ ターン終了時ボーナス実行
  #--------------------------------------------------------------------------
  def proc_turn_end_bonus(member, bonus_key)
    bonus = $game_party.bonus_info(bonus_key)
    return unless bonus[0] == "ターン終了時"
    return bonus_recovery(member, $1, $2) if bonus[1] =~ /(\S+)回復\[(\S+)\]/
  end
  #--------------------------------------------------------------------------
  # ○ 回復ボーナス
  #--------------------------------------------------------------------------
  def bonus_recovery(member, kind, recovery_num)
    num = (member.mhp * ($1.to_i / 100.0)).to_i if recovery_num =~ /(\d+)%/
    num = recovery_num.to_i                 unless recovery_num =~ /(\d+)%/
    return turn_end_hp_recovery(member, num) if kind == "HP"
    return turn_end_mp_recovery(member, num) if kind == "MP"
    return turn_end_tp_recovery(member, num) if kind == "TP"
  end
  #--------------------------------------------------------------------------
  # ○ ターン終了時HP回復ボーナス
  #--------------------------------------------------------------------------
  def turn_end_hp_recovery(member, num)
    member.hp += num
    return unless $imported["A1_DamagePopUp"]
    member.result.hp_damage = num * -1
    popup_damege(member, Sprite_DamagePop::NOML) if num.abs > 0
  end
  #--------------------------------------------------------------------------
  # ○ ターン終了時MP回復ボーナス
  #--------------------------------------------------------------------------
  def turn_end_mp_recovery(member, num)
    member.mp += num
    return unless $imported["A1_DamagePopUp"]
    member.result.mp_damage = num * -1
    popup_damege(member, Sprite_DamagePop::MPRE) if num > 0
    popup_damege(member, Sprite_DamagePop::MPDA) if num < 0
  end
  #--------------------------------------------------------------------------
  # ○ ターン終了時TP回復ボーナス
  #--------------------------------------------------------------------------
  def turn_end_mp_recovery(member, num)
    member.tp += num
    return unless $imported["A1_DamagePopUp"]
    member.result.tp_damage = num * -1
    popup_damege(member, Sprite_DamagePop::TPRE) if num > 0
    popup_damege(member, Sprite_DamagePop::TPDA) if num < 0
  end
  #--------------------------------------------------------------------------
  # ☆ 戦闘行動の実行
  #--------------------------------------------------------------------------
  alias a1_battle_formation_sb_execute_action execute_action
  def execute_action
    remove_before_action_formation_bonus(@subject.index) if @subject.actor?
    add_after_action_formation_bonus(@subject.index)     if @subject.actor?
    a1_battle_formation_sb_execute_action
    init_formation_bonus if member_any_dead?
  end
  #--------------------------------------------------------------------------
  # ☆ ターン終了
  #--------------------------------------------------------------------------
  alias a1_battle_formation_sb_turn_end turn_end
  def turn_end
    search_turn_end_bonus
    init_formation_bonus
    a1_battle_formation_sb_turn_end
  end
  #--------------------------------------------------------------------------
  # ○ 勝利アクション
  #--------------------------------------------------------------------------
  alias a1_battle_formation_sb_victory_action victory_action
  def victory_action
    init_formation_bonus
    a1_battle_formation_sb_victory_action
  end
  #--------------------------------------------------------------------------
  # ○ 陣形ボーナス初期化
  #--------------------------------------------------------------------------
  def init_formation_bonus
    battle_members.each {|battler| battler.init_formation_bonus }
  end
  #--------------------------------------------------------------------------
  # ○ 誰かが戦闘不能?
  #--------------------------------------------------------------------------
  def member_any_dead?
    battle_members.any? {|member| member.hp <= 0 }
  end
  #--------------------------------------------------------------------------
  # ☆ 個別ステータスウィンドウを再作成する
  #--------------------------------------------------------------------------
  alias a1_battle_formation_sb_recreate_status_windows recreate_status_windows
  def recreate_status_windows(member)
    prev_pos = reserve_before_pos(member) unless member.index == $game_party.new_index
    a1_battle_formation_sb_recreate_status_windows(member)
    proc_change_action(member, prev_pos)
  end
  #--------------------------------------------------------------------------
  # ○ 移動ジャンプ実行
  #--------------------------------------------------------------------------
  def proc_change_action(member, prev_pos)
    return unless prev_pos
    return if member.screen_x == prev_pos[0] && member.screen_y == prev_pos[1]
    member.target_x = member.screen_x
    member.target_y = member.screen_y
    member.screen_x = prev_pos[0]
    member.screen_y = prev_pos[1]
    member.proc_action("戦闘開始の登場")
  end
  #--------------------------------------------------------------------------
  # ○ 移動前の位置を保存
  #--------------------------------------------------------------------------
  def reserve_before_pos(member)
    [member.screen_x, member.screen_y]
  end
  #--------------------------------------------------------------------------
  # ○ バトルメンバーの追加後の処理
  #--------------------------------------------------------------------------
  alias a1_battle_formation_sb_post_add_battler post_add_battler
  def post_add_battler(member)
    a1_battle_formation_sb_post_add_battler(member)
    wait(35)
  end
  #--------------------------------------------------------------------------
  # ☆ バトルメンバーの削除後の処理
  #--------------------------------------------------------------------------
  alias a1_battle_formation_sb_post_remove_battler post_remove_battler
  def post_remove_battler
    a1_battle_formation_sb_post_remove_battler
    proc_change_formation
    init_formation_bonus
  end
  #--------------------------------------------------------------------------
  # ○ 陣形変更の実行
  #--------------------------------------------------------------------------
  def proc_change_formation
    battle_members.each {|actor| actor.setup_standard_pos(actor.index)}
    close_status_windows
    change_formation_action
    @status_windows.each_with_index {|window, i| setup_status_window_pos(window, i) }
  end
  #--------------------------------------------------------------------------
  # ○ 陣形変更アクション
  #--------------------------------------------------------------------------
  def change_formation_action
    battle_members[0].proc_action("陣形変更")
    wait(5)
  end
  #--------------------------------------------------------------------------
  # ○ 個別ステータスウィンドウの位置設定
  #--------------------------------------------------------------------------
  def setup_status_window_pos(window, index)
    pos = window.window_pos(index)
    window.x = pos[0]
    window.y = pos[1]
    window.visible = true
  end
end
#==============================================================================
# ■ Game_BattlerBase
#------------------------------------------------------------------------------
#  バトラーを扱う基本のクラスです。主に能力値計算のメソッドを含んでいます。こ
# のクラスは Game_Battler クラスのスーパークラスとして使用されます。
#==============================================================================

class Game_BattlerBase
  #--------------------------------------------------------------------------
  # ☆ 防御の判定
  #--------------------------------------------------------------------------
  alias a1_battle_formation_gbb_guard? guard?
  def guard?
    a1_battle_formation_gbb_guard? || @bounus_guard && movable?
  end
  #--------------------------------------------------------------------------
  # ☆ 通常能力値の取得
  #--------------------------------------------------------------------------
  alias a1_battle_formation_gbb_param param
  def param(param_id)
    a1_battle_formation_gbb_param(param_id) + @formation_param[param_id]
  end
  #--------------------------------------------------------------------------
  # ☆ 特殊能力値の取得
  #--------------------------------------------------------------------------
  alias a1_battle_formation_gbb_sparam sparam
  def sparam(sparam_id)
    ret = a1_battle_formation_gbb_sparam(sparam_id)
    return ret + @formation_tgr if sparam_id == 0
    return ret
  end
end
#==============================================================================
# ■ Game_Battler
#------------------------------------------------------------------------------
#  スプライトや行動に関するメソッドを追加したバトラーのクラスです。このクラス
# は Game_Actor クラスと Game_Enemy クラスのスーパークラスとして使用されます。
#==============================================================================

class Game_Battler < Game_BattlerBase
  #--------------------------------------------------------------------------
  # ○ 公開インスタンス変数
  #--------------------------------------------------------------------------
  attr_accessor :bounus_guard
  attr_accessor :after_action_guard
  attr_accessor :formation_tgr
  attr_accessor :formation_param
  #--------------------------------------------------------------------------
  # ☆ オブジェクト初期化
  #--------------------------------------------------------------------------
  alias a1_battle_formation_gb_initialize initialize
  def initialize
    init_formation_bonus(false)
    a1_battle_formation_gb_initialize
  end
  #--------------------------------------------------------------------------
  # ○ 陣形ボーナス初期化
  #--------------------------------------------------------------------------
  def init_formation_bonus(flag = true)
    @bounus_guard = false
    @formation_tgr   = 0.0
    @formation_param = [0, 0, 0, 0, 0, 0, 0, 0]
    conv_action("状態") if flag
  end
end
#==============================================================================
# ■ Spriteset_Battle
#------------------------------------------------------------------------------
#  バトル画面のスプライトをまとめたクラスです。このクラスは Scene_Battle クラ
# スの内部で使用されます。
#==============================================================================

class Spriteset_Battle
  #--------------------------------------------------------------------------
  # ☆ カーソルスプライトの作成
  #--------------------------------------------------------------------------
  alias a1_battle_formation_spsb_create_cursor_sprite create_cursor_sprite
  def create_cursor_sprite
    a1_battle_formation_spsb_create_cursor_sprite
    @prev_cursor_sprite = Sprite_BattleCursor.new(Color.new(128,0,128))
    @prev_cursor_sprite.plus_x = -8
    @prev_cursor_sprite.z -= 10
  end
  #--------------------------------------------------------------------------
  # ○ 前カーソルスプライトの取得
  #--------------------------------------------------------------------------
  def prev_cursor
    @prev_cursor_sprite
  end
  #--------------------------------------------------------------------------
  # ☆ カーソルスプライトの更新
  #--------------------------------------------------------------------------
  alias a1_battle_formation_spsb_update_cursor update_cursor
  def update_cursor
    a1_battle_formation_spsb_update_cursor
    @prev_cursor_sprite.update if @prev_cursor_sprite.visible
  end
  #--------------------------------------------------------------------------
  # ☆ カーソルの解放
  #--------------------------------------------------------------------------
  alias a1_battle_formation_spsb_dispose_cursor dispose_cursor
  def dispose_cursor
    a1_battle_formation_spsb_dispose_cursor
    @prev_cursor_sprite.dispose
  end
end
#==============================================================================
# ■ Window_ControlInfo
#==============================================================================

class Window_ControlInfo < Window_Base
  #--------------------------------------------------------------------------
  # ○ オブジェクト初期化
  #--------------------------------------------------------------------------
  def initialize
    super(0, Graphics.height - fitting_height(1), Graphics.width / 2, fitting_height(1))
    self.opacity = 0
    return if $game_party.all_members.size <= $game_party.max_battle_members
    draw_background(Rect.new(0, 0, self.width, self.height))
    draw_text(0, 0, contents.width, line_height, "Xボタン:パーティ入れ替え")
  end
end
#==============================================================================
# ■ Window_FormationName
#==============================================================================

class Window_FormationName < Window_Base
  #--------------------------------------------------------------------------
  # ○ オブジェクト初期化
  #--------------------------------------------------------------------------
  def initialize(window)
    @text = ""
    height = fitting_height(1)
    super(window.x, window.y - height, window.width, height)
    self.openness = 0
  end
  #--------------------------------------------------------------------------
  # ○ テキストの設定
  #--------------------------------------------------------------------------
  def set_text(text, show_num = true)
    @text = text
    @text = "#{$game_party.battle_members.size}人陣形:#{text}" if show_num
    self.width = text_size(@text).width + standard_padding * 3
    create_contents
    refresh
  end
  #--------------------------------------------------------------------------
  # ○ リフレッシュ
  #--------------------------------------------------------------------------
  def refresh
    contents.clear
    draw_text(0, 0, contents.width, line_height, @text)
  end
end
#==============================================================================
# ■ Window_FormationMenu
#==============================================================================

class Window_FormationMenu < Window_Selectable
  #--------------------------------------------------------------------------
  # ○ オブジェクト初期化
  #--------------------------------------------------------------------------
  def initialize
    @data      = $game_party.enable_formation
    @max_width = 0
    @index     = 0
    super(0, 0, 0, fitting_height(@data.size))
    setup_formation_list
    self.index = @index
    self.width = @max_width + standard_padding * 3
    self.x     = 60
    self.y     = Graphics.height / 5
    create_contents
    select(@index)
    refresh
    activate
  end
  #--------------------------------------------------------------------------
  # ○ 陣形リストのセットアップ
  #--------------------------------------------------------------------------
  def setup_formation_list
    @data.each_with_index {|id, i|
      @index = i if id == $game_party.battle_formation
      width = text_size($game_party.formation_name(id)).width
      @max_width = @max_width < width ? width : @max_width
    }
  end
  #--------------------------------------------------------------------------
  # ○ 選択した項目を取得
  #--------------------------------------------------------------------------
  def select_formation
    @data[self.index]
  end
  #--------------------------------------------------------------------------
  # ○ 項目数の取得
  #--------------------------------------------------------------------------
  def item_max
    @data.size
  end
  #--------------------------------------------------------------------------
  # ○ 項目の描画
  #--------------------------------------------------------------------------
  def draw_item(index)
    id = @data[index]
    draw_text(0, line_height * index, contents.width, line_height, $game_party.formation_name(id))
  end
  #--------------------------------------------------------------------------
  # ○ 決定やキャンセルなどのハンドリング処理
  #--------------------------------------------------------------------------
  def process_handling
    super
    return unless open? && active
    return process_member_change if handle?(:member_change) && Input.trigger?(:X)
  end
  #--------------------------------------------------------------------------
  # ○ メンバーチェンジ
  #--------------------------------------------------------------------------
  def process_member_change
    return if $game_party.all_members.size <= $game_party.max_battle_members
    Sound.play_ok
    call_handler(:member_change)
  end
end
#==============================================================================
# ■ Scene_FormationMenu
#==============================================================================

class Scene_FormationMenu < Scene_Battle
  #--------------------------------------------------------------------------
  # ○ 開始処理
  #--------------------------------------------------------------------------
  def start
    @selected = false
    BattleManager.init_members
    define_battle_manager_method
    create_main_viewport
    create_spriteset
    create_all_windows
  end
  #--------------------------------------------------------------------------
  # ○ 開始後処理
  #--------------------------------------------------------------------------
  def post_start
    perform_transition
    Input.update
    move_start_pos
    wait(30)
    @status_windows.each {|window| window.visible = true }
    @control_info = Window_ControlInfo.new
    @window_formation_menu.open
    @formation_name_window.open
  end
  #--------------------------------------------------------------------------
  # ○ 全ウィンドウの作成
  #--------------------------------------------------------------------------
  def create_all_windows
    super
    create_formation_manu_window
    create_fomarion_name_window
  end
  #--------------------------------------------------------------------------
  # ○ 陣形メニューウィンドウの作成
  #--------------------------------------------------------------------------
  def create_formation_manu_window
    @window_formation_menu = Window_FormationMenu.new
    @window_formation_menu.openness = 0
    @window_formation_menu.set_handler(:ok,            method(:on_formation_ok))
    @window_formation_menu.set_handler(:cancel,        method(:on_formation_cancel))
    @window_formation_menu.set_handler(:member_change, method(:command_member_change))
  end
  #--------------------------------------------------------------------------
  # ○ 陣形名ウィンドウの作成
  #--------------------------------------------------------------------------
  def create_fomarion_name_window
    @formation_name_window = Window_FormationName.new(@window_formation_menu)
    @formation_name_window.set_text($game_party.formation_name)
    @formation_name_window.openness = 0
  end
  #--------------------------------------------------------------------------
  # ○ フレーム更新
  #--------------------------------------------------------------------------
  def update
    update_basic
  end
  #--------------------------------------------------------------------------
  # ○ フレーム更新(基本)
  #--------------------------------------------------------------------------
  def update_basic
    Graphics.update
    Input.update
    update_all_windows
    $game_timer.update
    @spriteset.update
    update_info_viewport
    update_message_open
  end
  #--------------------------------------------------------------------------
  # ○ アクター[決定]
  #--------------------------------------------------------------------------
  def on_actor_ok
    return next_select unless @selected
    change_formation_member
  end
  #--------------------------------------------------------------------------
  # ○ メンバー入れ替え
  #--------------------------------------------------------------------------
  def change_formation_member
    return on_actor_cancel if @prev_index == @actor_window.index
    change_formation_pos(@prev_index, @actor_window.index)
    @selected = false
    actor_select_start
  end
  #--------------------------------------------------------------------------
  # ○ 場所の入れ替え
  #--------------------------------------------------------------------------
  def change_formation_pos(prev, now)
    @actor_window.hide
    @spriteset.prev_cursor.visible = false
    $game_party.swap_order(now, prev)
    battle_members.each {|member| recreate_status_windows(member) }
    wait(35)
    @actor_window.refresh
    @party_battle_members = $game_party.battle_members
    battle_members.each {|member| enable_open_status(member.index) }
    @prev_index = -1
  end
  #--------------------------------------------------------------------------
  # ○ 入れ替え先の選択
  #--------------------------------------------------------------------------
  def next_select
    @prev_index = @actor_window.index
    @selected = true
    @spriteset.prev_cursor.target = battle_members[@actor_window.index]
    @spriteset.prev_cursor.visible = true
    actor_select_start
  end
  #--------------------------------------------------------------------------
  # ○ アクター[キャンセル]
  #--------------------------------------------------------------------------
  def on_actor_cancel
    return restart_select_actor if @spriteset.prev_cursor.visible
    @actor_window.hide
    @window_formation_menu.activate
    @window_formation_menu.open
    @formation_name_window.set_text($game_party.formation_name)
    @control_info.open
  end
  #--------------------------------------------------------------------------
  # ○ アクター選択の再開
  #--------------------------------------------------------------------------
  def restart_select_actor
    @actor_window.activate
    @spriteset.prev_cursor.visible = false
    @prev_index = -1
    @selected = false
  end
  #--------------------------------------------------------------------------
  # ○ 陣形[決定]
  #--------------------------------------------------------------------------
  def on_formation_ok
    @control_info.close
    change_formation if $game_party.battle_formation != @window_formation_menu.select_formation
    @actor_window.index = 0 if @actor_window.index < 0
    actor_select_start
  end
  #--------------------------------------------------------------------------
  # ○ 陣形の変更
  #--------------------------------------------------------------------------
  def change_formation
    $game_party.battle_formation = @window_formation_menu.select_formation
    @formation_name_window.close
    @window_formation_menu.close
    proc_change_formation
    @formation_name_window.set_text($game_party.formation_name)
  end
  #--------------------------------------------------------------------------
  # ○ アクター選択の開始
  #--------------------------------------------------------------------------
  def actor_select_start
    index = @actor_window.index
    @actor_window.show.activate
    @actor_window.visible = false
    @actor_window.index = index
    @window_formation_menu.close
    @formation_name_window.set_text($game_party.formation_name, false)
    @formation_name_window.open
    select_actor(index)
  end
  #--------------------------------------------------------------------------
  # ○ 陣形[キャンセル]
  #--------------------------------------------------------------------------
  def on_formation_cancel
    SceneManager.return
  end
  #--------------------------------------------------------------------------
  # ○ 入れ替え
  #--------------------------------------------------------------------------
  def command_member_change
    @window_member_change.setup_members
    super
    @control_info.close
    @window_formation_menu.close
    @formation_name_window.set_text("メンバーチェンジ", false)
  end
  #--------------------------------------------------------------------------
  # ○ メンバーチェンジ[キャンセル]
  #--------------------------------------------------------------------------
  def on_member_change_cancel
    super
    @party_command_window.close
    @control_info.open
    @window_formation_menu.open
    @party_battle_members = $game_party.battle_members
    @formation_name_window.set_text($game_party.formation_name)
    battle_members.each {|member| enable_open_status(member.index) }
  end
end
#==============================================================================
# ■ Window_MenuCommand
#------------------------------------------------------------------------------
#  メニュー画面で表示するコマンドウィンドウです。
#==============================================================================

class Window_MenuCommand < Window_Command
  #--------------------------------------------------------------------------
  # ☆ 独自コマンドの追加用
  #--------------------------------------------------------------------------
  alias a1_battle_formation_wmc_add_original_commands add_original_commands
  def add_original_commands
    a1_battle_formation_wmc_add_original_commands
    add_command(A1_System::BattleFormationConfig::COMMAND_NAME, :battle_formation)
  end
end
#==============================================================================
# ■ Scene_Menu
#------------------------------------------------------------------------------
#  メニュー画面の処理を行うクラスです。
#==============================================================================

class Scene_Menu < Scene_MenuBase
  #--------------------------------------------------------------------------
  # ☆ コマンドウィンドウの作成
  #--------------------------------------------------------------------------
  alias a1_battle_formation_sm_create_command_window create_command_window
  def create_command_window
    a1_battle_formation_sm_create_command_window
    @command_window.set_handler(:battle_formation,    method(:menu_battle_formation))
  end
  #--------------------------------------------------------------------------
  # ○ メニュー[陣形]
  #--------------------------------------------------------------------------
  def menu_battle_formation
    SceneManager.call(Scene_FormationMenu)
  end
end
#==============================================================================
# ■ A1_System::CommonModule
#==============================================================================

class A1_System::CommonModule
  #--------------------------------------------------------------------------
  # ☆ 注釈コマンド定義
  #--------------------------------------------------------------------------
  alias a1_battle_formation_define_command define_command
  def define_command
    a1_battle_formation_define_command
    @cmd_108["陣形メニュー"] = :menu_battle_formation
    @cmd_108["陣形習得"]     = :learn_battle_formation
    @cmd_108["陣形変更"]     = :change_battle_formation
  end
end
#==============================================================================
# ■ Game_Interpreter
#------------------------------------------------------------------------------
#  イベントコマンドを実行するインタプリタです。このクラスは Game_Map クラス、
# Game_Troop クラス、Game_Event クラスの内部で使用されます。
#==============================================================================

class Game_Interpreter
  #--------------------------------------------------------------------------
  # ○ 陣形メニュー
  #--------------------------------------------------------------------------
  def menu_battle_formation(params)
    SceneManager.call(Scene_FormationMenu)
  end
  #--------------------------------------------------------------------------
  # ○ 陣形習得
  #--------------------------------------------------------------------------
  def learn_battle_formation(params)
    $game_party.learned_formation.push(params[1].to_i)   if params[0] == "追加"
    $game_party.learned_formation.delete(params[1].to_i) if params[0] == "削除"
  end
  #--------------------------------------------------------------------------
  # ○ 陣形変更
  #--------------------------------------------------------------------------
  def change_battle_formation(params)
    $game_party.battle_formation = params[0].to_i
  end
end
end[/pre]   

点评

那個沒貼錯...只是我少貼了一個共通腳本,兩個共通腳本都必須使用,否則這個陣型腳本、戰鬥系統會沒有反應  发表于 2016-4-16 00:34
你第一个代码错了  发表于 2016-4-15 07:46
如果你在這邊複製腳本代碼沒辦法使用,只好請閣下自己去日站看看了,抱歉 ( 艸),我在四樓有網址,日站裡面也有說明需要那些腳本才能用  发表于 2016-4-15 00:14
這個日站的陣型腳本只是個額外功能,要使用的話必須他的戰鬥系統 和 他的必須使用的"A1バトル共通スクリプト"腳本  发表于 2016-4-15 00:12
抱歉这些代码好像都没有用啊  发表于 2016-4-14 19:20
回复

使用道具 举报

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

本版积分规则

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

在本版发帖返回顶部