查看: 1269|回复: 2

[已经过期] 有没有战斗中能用的物品分类脚本

[复制链接]
梦石
0
星屑
12161
在线时间
4435 小时
注册时间
2014-4-11
回帖
5616

开拓者

发表于 2014-11-9 10:03:37 | 显示全部楼层 |阅读模式

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

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

×
本帖最后由 yang1zhi 于 2014-11-9 12:08 编辑

或者教我怎么把普通的物品分类脚本改成战斗中也能用。
找到的都是菜单物品分类脚本。
我想要在战斗中也有分类效果。
有些人可能会说:战斗中不能用的物品不是不显示吗。
单单这样是不够的。
还要分:恢复品,战斗品,召唤物品,等等。

我目前没有使用脚本分类。
下面这些是我找到的脚本分类
一、这个是我找到的唯一一个战斗中有分类的物品分类脚本。
不过276行报错。        @item_window.item_class = @command[1][@commanda_window.index]

  1. module Sword
  2. #=======================================
  3. #★ 魔劍工舖 - 物品分類 2.03
  4. # [url]http://blog.yam.com/a870053jjkj/[/url]
  5. #=======================================
  6.   Sword35_ItemClass, Sword35_BattleClass = [], []
  7. #=======================================
  8. #● 使用者自定設置
  9. Sword35_Help = ['物品欄', 1]  # 設定在分類選擇時上方窗口顯示的文字 ['內容', 位置]
  10. Sword35_Gold = true # 是否要在左下方顯示金錢窗口
  11. Sword35_Width = 160 # 設定選項窗口的寬度,物品顯示窗口也會對應的更改
  12. #--------------------------------------------------------------
  13. #○ 物品畫面分類屬性辨識表
  14. # 設置法1:Sword35_ItemClass[第幾個選項] = 屬性編號(顯示該屬性道具)
  15. # 設置法2:Sword35_ItemClass[第幾個選項] = '選項內容'(顯示全部道具)
  16. # 該設置可以全數移除,這樣物品畫面將不會有道具分類效果
  17. Sword35_ItemClass[1] = 17
  18. Sword35_ItemClass[2] = 18
  19. Sword35_ItemClass[3] = 19
  20. Sword35_ItemClass[4] = 20
  21. Sword35_ItemClass[5] = 21
  22. Sword35_ItemClass[6] = 22
  23. Sword35_ItemClass[7] = 23
  24. Sword35_ItemClass[8] = 24
  25. Sword35_ItemClass[9] = 25
  26. Sword35_ItemClass[10] = '全部道具'
  27. #--------------------------------------------------------------
  28. #○ 戰鬥畫面分類屬性辨識表
  29. # 設置法1:Sword35_BattleClass[第幾個選項] = 屬性編號(顯示該屬性道具)
  30. # 設置法2:Sword35_BattleClass[第幾個選項] = '選項內容'(顯示全部道具)
  31. # 設置法3:Sword35_BattleClass = Sword35_ItemClass(照物品畫面,只留這個就好)
  32. # 該設置可以全數移除,這樣戰鬥畫面將不會有道具分類效果
  33. Sword35_BattleClass[1] = 17
  34. Sword35_BattleClass[2] = 19
  35. Sword35_BattleClass[3] = 18
  36. =begin
  37. ========================================
  38. 詳細設置說明請參考:[url]http://blog.yam.com/a870053jjkj/article/24014108[/url]
  39. =end
  40.   $Sword ? $Sword[35] = true : $Sword = {35=>true} # 腳本使用標誌
  41.   ($Sword_VX = false ; RPG::Weather rescue $Sword_VX = true) if $Sword_VX == nil
  42.   elements = load_data("Data/System.r#{$Sword_VX ? 'v' : 'x'}data").elements
  43. (1...Sword35_ItemClass.size).each{|i| next unless Sword35_ItemClass[i].is_a?(Integer)
  44. raise("物品畫面中的道具不存在第#{Sword35_ItemClass[i]}號的屬性
  45. 請添加該屬性或是檢查 Sword35_ItemClass 設置是否正確") unless
  46. elements[Sword35_ItemClass[i]]} unless Sword35_ItemClass.empty? # Error1
  47. (1...Sword35_BattleClass.size).each{|i| next unless Sword35_BattleClass[i].is_a?(Integer)
  48. raise("戰鬥畫面中的道具不存在第#{Sword35_BattleClass[i]}號的屬性
  49. 請添加該屬性或是檢查 Sword35_BattleClass 設置是否正確") unless
  50. elements[Sword35_BattleClass[i]]} unless Sword35_BattleClass.empty? # Error2
  51. end
  52. #=======================================
  53. #■ 擁有游標的移動以及滾動功能的視窗類別
  54. class Window_Selectable < Window_Base
  55.   #-------------------------------------------------------------
  56.   #● 獲取行數
  57.   alias sword35_row_max row_max
  58.   def row_max
  59.     return sword35_row_max if # 不需分類就採用預設頂行
  60.     Sword::Sword35_BattleClass.empty? && $game_temp.in_battle or
  61.     Sword::Sword35_ItemClass.empty? && $scene.is_a?(Scene_Item)
  62.     return @item_max if $scene.is_a?(Scene_Item) ; sword35_row_max
  63.   end
  64. end
  65. #=======================================
  66. #■ 技能及物品的說明、角色的狀態顯示的視窗
  67. class Window_Help < Window_Base
  68.   include Sword # 連接自定設置
  69.   #-------------------------------------------------------------
  70.   #● 初始化物件
  71.   alias sword35_initialize initialize
  72.   def initialize
  73.     sword35_initialize
  74.     set_text(Sword35_Help[0], Sword35_Help[1]) if $scene.is_a?(Scene_Item)
  75.   end
  76. end
  77. #=======================================
  78. #■ 物品畫面、戰鬥畫面、顯示瀏覽物品的視窗
  79. class Window_Item < Window_Selectable
  80.   include Sword # 連接自定設置
  81.   attr_writer     :item_class # 目前的分類
  82.   #-------------------------------------------------------------
  83.   #● 初始化物件(X座標, Y座標, 寬度, 高度)
  84.   alias sword35_initialize initialize
  85.   def initialize(xn = nil, yn = nil, widthn = nil, heightn = nil)
  86.     # [物品窗口高度, 物品窗口寬度, 文字高度, 右邊放置距離, 開頭距離,
  87.     #  冒號顯示框寬度, 數量顯示框寬度, 戰鬥時物品窗口高度]
  88.     [url=home.php?mod=space&uid=280620]@xpvx[/url] = $Sword_VX ? [Graphics.height - WLH - 32,
  89.     Graphics.width - Sword35_Width, 24, 240, 0, 216, 236, 232] :
  90.     [416, 640 - Sword35_Width, 32, 288, 4, 253, 280, 256]
  91.     $Sword_VX ? sword35_initialize(xn, yn, widthn, heightn) : sword35_initialize
  92.     #○ 物品窗口的位置與大小修正
  93.     if $game_temp.in_battle and ! Sword35_BattleClass.empty? # 戰鬥的話就中斷
  94.       self.x = Sword35_Width ; self.height = @xpvx[7] ; self.active = false
  95.       @index = -1 ; @column_max = 1
  96.       $Sword_VX ? update_cursor : update_cursor_rect # 修正為1行一個道具
  97.     elsif $scene.is_a?(Scene_Item) and ! Sword35_ItemClass.empty? # 物品畫面要分類時
  98.       self.x = Sword35_Width ; self.height = @xpvx[0] ; self.active = false
  99.       @index = -1 ; @column_max = 1
  100.       $Sword_VX ? update_cursor : update_cursor_rect # 修正為1行一個道具
  101.     end
  102.   end
  103.   #-------------------------------------------------------------
  104.   #● 更新內容
  105.   alias sword35_refresh refresh
  106.   def refresh
  107.     if $game_temp.in_battle and (not Sword35_BattleClass.empty?) ; self.width = @xpvx[1]
  108.       Sword35_BattleClass.each_index{|index| (@item_class = Sword35_BattleClass[index]
  109.       break) if Sword35_BattleClass[index]} unless @item_class # 起始選項分類
  110.       @item_class = 0 if @item_class.is_a?(String) # 是字符串的場合就設為0
  111.     elsif $game_temp.in_battle or Sword35_ItemClass.empty? or # 不需分類
  112.     $scene.is_a?(Scene_Shop) or $scene.is_a?(Scene_Equip)
  113.       @item_class = 0
  114.     else ; self.width = @xpvx[1] # 非戰鬥時的情況(物品畫面的情況)
  115.       Sword35_ItemClass.each_index{|index| (@item_class = Sword35_ItemClass[index]
  116.       break) if Sword35_ItemClass[index]} unless @item_class # 起始選項分類
  117.       @item_class = 0 if @item_class.is_a?(String) # 是字符串的場合就設為0
  118.     end
  119.     @go_bitmap = true ; sword35_refresh ; self.index = -1 unless sword35_whether?
  120.   end
  121.   #-------------------------------------------------------------
  122.   #● 描繪項目
  123.   alias sword35_draw_item draw_item if $Sword_VX
  124.   def draw_item(index)
  125.     return sword35_draw_item(index) if $scene.is_a?(Scene_Shop) or
  126.     $scene.is_a?(Scene_Equip) if $Sword_VX
  127.     if @item_class > 0 and @go_bitmap ; i = 0 # 重新產生適合的位圖
  128.       @data.each{|data| i += 1 if (data.is_a?(RPG::Armor) and (not $Sword_VX)) ?
  129.       data.guard_element_set.include?(@item_class) : data.element_set.include?(@item_class)}
  130.       i = 1 if i == 0 ; self.contents = Bitmap.new(width - 32, i * 32) ; @go_bitmap = false
  131.     end
  132.     return if (item = @data[index]) == nil # 物品是空就中斷
  133.     number = $game_party.item_number(item) if $Sword_VX
  134.     case item #○ 依據道具種類,獲取道具持有數量即確認是否要顯示該道具
  135.     when RPG::Item ; number = $game_party.item_number(item.id) unless $Sword_VX
  136.       return delete_item_class(index) unless
  137.       (item.element_set.include?(@item_class) or @item_class == 0)
  138.     when RPG::Weapon ; number = $game_party.weapon_number(item.id) unless $Sword_VX
  139.       return delete_item_class(index) unless
  140.       (item.element_set.include?(@item_class) or @item_class == 0)
  141.     when RPG::Armor ; number = $game_party.armor_number(item.id) unless $Sword_VX
  142.       return delete_item_class(index) unless (($Sword_VX ?
  143.       item.element_set.include?(@item_class) :
  144.       item.guard_element_set.include?(@item_class)) or @item_class == 0)
  145.     end
  146.     if item.is_a?(RPG::Item) and $game_party.item_can_use?($Sword_VX ? item : item.id)
  147.       $Sword_VX ? enabled = true : self.contents.font.color = normal_color
  148.     else ; $Sword_VX ? enabled = false : self.contents.font.color = disabled_color
  149.     end
  150.     (self.contents.font.color = normal_color
  151.     self.contents.font.color.alpha = enabled ? 255 : 128) if $Sword_VX
  152.     if sword35_whether?
  153.       x = @xpvx[4] + index % 2 * (@xpvx[3] + 32) ; y = index / 2 * @xpvx[2]
  154.     else ; x = 4 ; y = index * @xpvx[2]
  155.     end
  156.     rect = Rect.new(x, y, self.width / @column_max - 32, 32)
  157.     self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
  158.     (bitmap = RPG::Cache.icon(item.icon_name)
  159.     opacity = self.contents.font.color == normal_color ? 255 : 128) unless $Sword_VX
  160.     if sword35_whether? # 一般模式
  161.       $Sword_VX ? draw_item_name(item, x, y, enabled) : (
  162.       self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
  163.       self.contents.draw_text(x + 28, y, 212, 32, item.name, 0))
  164.       self.contents.draw_text(x, y, @xpvx[5], @xpvx[2], ":", 2)
  165.       self.contents.draw_text(x, y, @xpvx[6], @xpvx[2], number.to_s, 2)
  166.     else # 分類模式
  167.       $Sword_VX ? draw_item_name(item, x, y, enabled) : (
  168.       self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
  169.       self.contents.draw_text(x + 28, y, 212, 32, item.name, 0))
  170.       self.contents.draw_text(x, y, self.width - 64, @xpvx[2], ":", 2)
  171.       self.contents.draw_text(x, y, self.width - 40, @xpvx[2], number.to_s, 2)
  172.     end
  173.   end
  174.   #-------------------------------------------------------------
  175.   #● 忽略道具的方法
  176.   def delete_item_class(index)
  177.     @data.delete_at(index) ; @item_max -= 1 ; draw_item(index)
  178.   end
  179.   #-------------------------------------------------------------
  180.   #● 判斷是否不需要道具分類效果
  181.   def sword35_whether?
  182.     Sword35_BattleClass.empty? && $game_temp.in_battle or
  183.     Sword35_ItemClass.empty? && $scene.is_a?(Scene_Item) or
  184.     $scene.is_a?(Scene_Shop) or $scene.is_a?(Scene_Equip)
  185.   end
  186. end
  187. #=======================================
  188. #■ 處理戰鬥畫面的類別
  189. unless Sword::Sword35_BattleClass.empty? # 無Sword35_BattleClass設置的場合
  190.   class Scene_Battle
  191.     include Sword # 連接自定設置
  192.     #-----------------------------------------------------------
  193.     #● 主處理
  194.     alias sword35_main main unless $Sword_VX
  195.     def main
  196.       @xpvx = $Sword_VX ? [56, 232] : [64, 256] # [選項窗口Y座標, 選項窗口高度]
  197.       (sword35_main ; return) if Sword35_BattleClass.empty? # 有設置的情況下
  198.       @command = [[], []] # 獲取選項名稱和屬性編號
  199.       Sword35_BattleClass.each_index do |index| ; next if Sword35_BattleClass[index] == nil
  200.       unless Sword35_BattleClass[index].is_a?(String) # 不是字符串的場合
  201.         @command[0] += [$data_system.elements[Sword35_BattleClass[index]]]
  202.         @command[1] += [Sword35_BattleClass[index]]
  203.       else ; @command[0] += [Sword35_BattleClass[index]] ; @command[1] += [0] # 字串
  204.       end ; end
  205.       @commanda_window = Window_Command.new(Sword35_Width, @command[0])
  206.       @commanda_window.y, @commanda_window.height = @xpvx[0], @xpvx[1]
  207.       @commanda_window.back_opacity = 160
  208.       @commanda_window.active = false ; @commanda_window.visible = false
  209.       $Sword_VX ? super : sword35_main
  210.       @commanda_window.dispose if @commanda_window
  211.     end
  212.     #-----------------------------------------------------------
  213.     #● 更新角色命令回合 - 選擇物品
  214.     $Sword_VX ? (alias sword35_update_phase3_item_select update_item_selection
  215.     def update_item_selection ; update_phase3_item_select ; end) :
  216.     (alias sword35_update_phase3_item_select update_phase3_item_select)
  217.     def update_phase3_item_select
  218.       @commanda_window.update
  219.       @commanda_window.visible = true
  220.       if @item_window ; if @item_window.active ; if Input.trigger?(Input::B)
  221.         $Sword_VX ? Sound.play_cancel : $game_system.se_play($data_system.cancel_se)
  222.         @commanda_window.active = true ; @item_window.index = -1
  223.         @help_window.set_text(Sword35_Help[0], Sword35_Help[1])
  224.         @item_window.active = false ; return
  225.       elsif Input.trigger?(Input::C) and (not @item_window.item)
  226.         $Sword_VX ? Sound.play_buzzer : $game_system.se_play($data_system.buzzer_se) ; return
  227.       end ; end ; end
  228.       (commanda_update ; return) if @commanda_window.active# 當種類窗口活動的時
  229.       sword35_update_phase3_item_select
  230.     end
  231.     #-----------------------------------------------------------
  232.     #● 開始選擇敵人
  233.   unless $Sword_VX
  234.     alias sword35_start_enemy_select start_enemy_select
  235.     def start_enemy_select
  236.       sword35_start_enemy_select ; @commanda_window.visible = false
  237.     end
  238.     #-----------------------------------------------------------
  239.     #● 開始選擇角色
  240.     alias sword35_start_actor_select start_actor_select
  241.     def start_actor_select
  242.       sword35_start_actor_select ; @commanda_window.visible = false
  243.     end
  244.   end
  245.     #-----------------------------------------------------------
  246.     #● 開始選擇物品
  247.     $Sword_VX ? (alias sword35_start_item_select start_item_selection
  248.     def start_item_selection ; start_item_select ; end) :
  249.     (alias sword35_start_item_select start_item_select)
  250.     def start_item_select
  251.       sword35_start_item_select ; @item_window.active = false
  252.       @help_window.set_text(Sword35_Help[0], Sword35_Help[1])
  253.       @commanda_window.active = true ; @commanda_window.visible = true
  254.     end
  255.     #-----------------------------------------------------------
  256.     #● 結束選擇物品
  257.     $Sword_VX ? (alias sword35_end_item_select end_item_selection
  258.     def end_item_selection ; end_item_select ; end) :
  259.     (alias sword35_end_item_select end_item_select)
  260.     def end_item_select
  261.       sword35_end_item_select
  262.       @commanda_window.active = false ; @commanda_window.visible = false
  263.     end
  264.     #-----------------------------------------------------------
  265.     #● 分類選項更新
  266.     def commanda_update
  267.       if Input.trigger?(Input::B) ; end_item_select
  268.         $Sword_VX ? Sound.play_cancel : $game_system.se_play($data_system.cancel_se)
  269.       elsif Input.trigger?(Input::C)
  270.         $Sword_VX ? Sound.play_decision : $game_system.se_play($data_system.decision_se)
  271.         @item_window.index = 0
  272.         @item_window.active = true ; @commanda_window.active = false
  273.         @help_window.set_text(
  274.         @item_window.item == nil ? '' : @item_window.item.description)
  275.       elsif Input.repeat?(Input::UP) or Input.repeat?(Input::DOWN) # 更新物品
  276.         @item_window.item_class = @command[1][@commanda_window.index]
  277.         @item_window.refresh
  278.       end
  279.     end
  280.   end
  281. end
  282. #=======================================
  283. #■ 處理物品畫面的類別
  284. unless Sword::Sword35_ItemClass.empty? # 無Sword35_ItemClass設置的場合
  285.   class Scene_Item
  286.     include Sword # 連接自定設置
  287.     #-----------------------------------------------------------
  288.     #● 主處理
  289.     alias sword35_main main unless $Sword_VX
  290.     def main
  291.       # [選項窗口高度, 有金錢窗口選項窗口高度, 選項窗口Y座標, 修正]
  292.       @xpvx = $Sword_VX ? [Graphics.height - 56, Graphics.height - 56 * 2,
  293.       56, true] : [416, 352, 64, false]
  294.       @command = [[], []] # 獲取選項名稱和屬性編號
  295.       Sword35_ItemClass.each_index do |index| ; next if Sword35_ItemClass[index] == nil
  296.       unless Sword35_ItemClass[index].is_a?(String) # 不是字符串的場合
  297.         @command[0] += [$data_system.elements[Sword35_ItemClass[index]]]
  298.         @command[1] += [Sword35_ItemClass[index]]
  299.       else ; @command[0] += [Sword35_ItemClass[index]] ; @command[1] += [0] # 字符串
  300.       end ; end
  301.       @commanda_window = Window_Command.new(Sword35_Width, @command[0])
  302.       @commanda_window.y = @xpvx[2]
  303.       unless Sword35_Gold ; @commanda_window.height = @xpvx[0]
  304.       else ; @commanda_window.height = @xpvx[1]
  305.         @gold_window = $Sword_VX ? # 產生金錢窗口
  306.         Window_Gold.new(0, Graphics.height - 56) : Window_Gold.new
  307.         @gold_window.x, @gold_window.y = 0, 416 unless $Sword_VX
  308.       end
  309.       $Sword_VX ? super : sword35_main
  310.       @commanda_window.dispose ; @gold_window.dispose if @gold_window
  311.     end
  312.     #-----------------------------------------------------------
  313.     #● 更新畫面
  314.     alias sword35_update update
  315.     def update
  316.       @commanda_window.update
  317.       @item_window.active, @xpvx[3] = false, false if @xpvx[3] # 修正
  318.       if @item_window.active ; if Input.trigger?(Input::B)
  319.         $Sword_VX ? Sound.play_cancel : $game_system.se_play($data_system.cancel_se)
  320.         @item_window.active = false ; @commanda_window.active = true
  321.         @help_window.set_text(Sword35_Help[0], Sword35_Help[1]) # 更新幫助窗口文字
  322.         @help_wsword.visible = false if $Sword[8] # 隱藏跟隨說明窗口
  323.         @item_window.index = -1 ; return
  324.       end ; end
  325.       (commanda_update ; return) if @commanda_window.active # 當種類窗口活動的時
  326.       sword35_update
  327.     end
  328.     #-----------------------------------------------------------
  329.     #● 分類選項更新
  330.     def commanda_update
  331.       if Input.trigger?(Input::B)
  332.         $Sword_VX ? Sound.play_cancel : $game_system.se_play($data_system.cancel_se)
  333.         $scene = Scene_Menu.new
  334.       elsif Input.trigger?(Input::C)
  335.         $Sword_VX ? Sound.play_decision : $game_system.se_play($data_system.decision_se)
  336.         @item_window.index = 0 ; @help_wsword.visible = true if $Sword[8] # 顯示說明窗口
  337.         @item_window.active = true ; @commanda_window.active = false
  338.         @help_window.set_text(
  339.         @item_window.item == nil ? '' : @item_window.item.description)
  340.       elsif Input.repeat?(Input::UP) or Input.repeat?(Input::DOWN) # 更新物品
  341.         @item_window.item_class = @command[1][@commanda_window.index]
  342.         @item_window.refresh
  343.       end
  344.     end
  345.   end
  346. end
复制代码


二、这个脚本没有战斗分类的效果
  1. #==============================================================================
  2. # ■ 物品分类
  3. #==============================================================================

  4. # 主体窗口透明度
  5. OPACITY_Item = 0
  6. # 使用物品窗口透明度
  7. OPACITY_Target = 200
  8. #==============================================================================
  9. # ■ RPG追加定义
  10. #==============================================================================
  11. module RPG
  12.   #--------------------------------------------------------------------------
  13.   # ● 物品追加
  14.   #--------------------------------------------------------------------------
  15.   class Item
  16.     def description
  17.       description = @description.split(/@/)[0]
  18.       return description != nil ? description : ''
  19.     end
  20.     def desc
  21.       desc = @description.split(/@/)[1]
  22.       return desc != nil ? desc : "恢复物品"
  23.     end
  24.   end
  25.   #--------------------------------------------------------------------------
  26.   # ● 武器追加
  27.   #--------------------------------------------------------------------------
  28.   class Weapon
  29.     def description
  30.       description = @description.split(/@/)[0]
  31.       return description != nil ? description : ''
  32.     end
  33.     def desc
  34.       desc = @description.split(/@/)[1]
  35.       return desc != nil ? desc : "武器装备"
  36.     end
  37.   end
  38.   #--------------------------------------------------------------------------
  39.   # ● 防具追加
  40.   #--------------------------------------------------------------------------
  41.   class Armor
  42.     def description
  43.       description = @description.split(/@/)[0]
  44.       return description != nil ? description : ''
  45.     end
  46.     def desc
  47.       desc = @description.split(/@/)[1]
  48.       return desc != nil ? desc : "防具装备"
  49.     end
  50.   end
  51. end

  52. #==============================================================================
  53. # ■ Window_Target
  54. #------------------------------------------------------------------------------
  55. #  物品画面与特技画面的、使用对像角色选择窗口。
  56. #   修复使用物品时还有跟随帮助窗口....
  57. #==============================================================================

  58. class Window_Target < Window_Selectable
  59.   #--------------------------------------------------------------------------
  60.   # ● 刷新帮助文本
  61.   #--------------------------------------------------------------------------
  62.   def update_help
  63.     @help_window.set_text(item)
  64.     #校正帮助窗口位置
  65.     @help_window.set_pos(self.x,self.y,self.width,self.oy,self.index,@column_max)
  66.   end
  67. end

  68. #==============================================================================
  69. # ■ Window_ItemCommand
  70. #------------------------------------------------------------------------------
  71. #  显示分类的窗口。
  72. #==============================================================================

  73. class Window_ItemCommand < Window_Selectable
  74.   attr_accessor :commands
  75.   #--------------------------------------------------------------------------
  76.   # ● 初始化对像
  77.   #     commands : 命令字符串序列
  78.   #--------------------------------------------------------------------------
  79.   def initialize
  80.     super(0, 0, 160, 416)
  81.     self.opacity = OPACITY_Item
  82.     @commands = []
  83.     # 获取物品
  84.     for i in 1...$data_items.size
  85.       if $game_party.item_number(i) > 0
  86.         push = true
  87.         for com in @commands
  88.           if com == $data_items[i].desc
  89.             push = false
  90.           end
  91.         end
  92.         if push == true
  93.           @commands.push($data_items[i].desc)
  94.         end
  95.       end
  96.     end
  97.     # 获取武器
  98.     for i in 1...$data_weapons.size
  99.       if $game_party.weapon_number(i) > 0
  100.         push = true
  101.         for com in @commands
  102.           if com == $data_weapons[i].desc
  103.             push = false
  104.           end
  105.         end
  106.         if push == true
  107.           @commands.push($data_weapons[i].desc)
  108.         end
  109.       end
  110.     end
  111.     # 获取防具
  112.     for i in 1...$data_armors.size
  113.       if $game_party.armor_number(i) > 0
  114.         push = true
  115.         for com in @commands
  116.           if com == $data_armors[i].desc
  117.             push = false
  118.           end
  119.         end
  120.         if push == true
  121.           @commands.push($data_armors[i].desc)
  122.         end
  123.       end
  124.     end
  125.     if @commands == []
  126.       @commands.push("普通物品")
  127.     end
  128.     @item_max = @commands.size
  129.     self.contents = Bitmap.new(width - 32, @item_max * 32)
  130.     refresh
  131.     self.index = 0
  132.   end
  133.   #--------------------------------------------------------------------------
  134.   # ● 刷新
  135.   #--------------------------------------------------------------------------
  136.   def refresh
  137.     self.contents.clear
  138.     for i in 0...@item_max
  139.       draw_item(i, normal_color)
  140.     end
  141.   end
  142.   #--------------------------------------------------------------------------
  143.   # ● 描绘项目
  144.   #     index : 项目编号
  145.   #     color : 文字色
  146.   #--------------------------------------------------------------------------
  147.   def draw_item(index, color)
  148.     self.contents.font.color = color
  149.     y = index * 32
  150.     self.contents.draw_text(4, y, 128, 32, @commands[index])
  151.   end
  152.   #--------------------------------------------------------------------------
  153.   # ● 刷新帮助文本
  154.   #--------------------------------------------------------------------------
  155.   def update_help
  156.     @help_window.set_text(item)
  157.     #校正帮助窗口位置
  158.     @help_window.set_pos(self.x,self.y,32,self.oy,self.index,@column_max)
  159.   end
  160. end

  161. #==============================================================================
  162. # ■ Window_Item
  163. #------------------------------------------------------------------------------
  164. #  物品画面、战斗画面、显示浏览物品的窗口。
  165. #==============================================================================

  166. class Window_ItemList < Window_Selectable
  167.   #--------------------------------------------------------------------------
  168.   # ● 初始化对像
  169.   #--------------------------------------------------------------------------
  170.   def initialize
  171.     super(160, 0, 480, 480)
  172.     self.opacity = OPACITY_Item
  173.     @column_max = 2
  174.     refresh
  175.     self.index = 0
  176.   end
  177.   #--------------------------------------------------------------------------
  178.   # ● 获取物品
  179.   #--------------------------------------------------------------------------
  180.   def item
  181.     return @data[self.index]
  182.   end
  183.   #--------------------------------------------------------------------------
  184.   # ● 刷新
  185.   #--------------------------------------------------------------------------
  186.   def refresh
  187.     if self.contents != nil
  188.       self.contents.dispose
  189.       self.contents = nil
  190.     end
  191.     @data = []
  192.   end
  193.   #--------------------------------------------------------------------------
  194.   # ● 分类
  195.   #     command : 类别名称
  196.   #--------------------------------------------------------------------------
  197.   def set_item(command)
  198.     refresh
  199.     if $game_temp.in_battle
  200.       # 添加物品
  201.       for i in 1...$data_items.size
  202.         if $game_party.item_number(i) > 0
  203.           @data.push($data_items[i])
  204.         end
  205.       end
  206.     end
  207.     for i in 1...$data_items.size
  208.       if $game_party.item_number(i) > 0 and $data_items[i].desc == command
  209.         @data.push($data_items[i])
  210.       end
  211.     end
  212.     for i in 1...$data_weapons.size
  213.       if $game_party.weapon_number(i) > 0 and $data_weapons[i].desc == command
  214.         @data.push($data_weapons[i])
  215.       end
  216.     end
  217.     for i in 1...$data_armors.size
  218.       if $game_party.armor_number(i) > 0 and $data_armors[i].desc == command
  219.         @data.push($data_armors[i])
  220.       end
  221.     end
  222.     # 如果项目数不是 0 就生成位图、重新描绘全部项目
  223.     @item_max = @data.size
  224.     if @item_max > 0
  225.       self.contents = Bitmap.new(width - 32, row_max * 32)
  226.       self.contents.clear
  227.       for i in 0...@item_max
  228.         draw_item(i)
  229.       end
  230.     end
  231.   end
  232.   #--------------------------------------------------------------------------
  233.   # ● 获取物品的所持数
  234.   #--------------------------------------------------------------------------
  235.   def item_number
  236.     return @item_max
  237.   end
  238.   #--------------------------------------------------------------------------
  239.   # ● 描绘项目
  240.   #     index : 项目编号
  241.   #--------------------------------------------------------------------------
  242.   def draw_item(index)
  243.     item = @data[index]
  244.     case item
  245.     when RPG::Item
  246.       number = $game_party.item_number(item.id)
  247.     when RPG::Weapon
  248.       number = $game_party.weapon_number(item.id)
  249.     when RPG::Armor
  250.       number = $game_party.armor_number(item.id)
  251.     end
  252.     if item.is_a?(RPG::Item) and
  253.       $game_party.item_can_use?(item.id)
  254.       self.contents.font.color = normal_color
  255.     else
  256.       self.contents.font.color = disabled_color
  257.     end
  258.     x = 4 + index % 2 * (208 + 32)
  259.     y = index / 2 * 32
  260.     rect = Rect.new(x, y, self.width / @column_max - 32, 32)
  261.     self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
  262.     bitmap = RPG::Cache.icon(item.icon_name)
  263.     opacity = self.contents.font.color == normal_color ? 255 : 128
  264.     self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
  265.     self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)
  266.     self.contents.draw_text(x + 170, y, 16, 32, ":", 1)
  267.     self.contents.draw_text(x + 176, y, 24, 32, number.to_s, 2)
  268.   end
  269.   #--------------------------------------------------------------------------
  270.   # ● 刷新帮助文本
  271.   #--------------------------------------------------------------------------
  272.   def update_help
  273.     @help_window.set_text(item)
  274.     #校正帮助窗口位置
  275.     @help_window.set_pos(self.x,self.y,self.width,self.oy,self.index,@column_max)
  276.   end
  277. end

  278. #==============================================================================
  279. # ■ Scene_Item
  280. #------------------------------------------------------------------------------
  281. #  处理物品画面的类。
  282. #==============================================================================

  283. class Scene_Item
  284.   #--------------------------------------------------------------------------
  285.   # ● 主处理
  286.   #--------------------------------------------------------------------------
  287.   def main
  288.     # 创建背景图
  289.     @itemmenu = Sprite.new
  290.     @itemmenu.bitmap = RPG::Cache.picture("物品背景.png")
  291.     # 生成帮助窗口、物品窗口
  292.     @itemcommand_window = Window_ItemCommand.new
  293.     @command_index = @itemcommand_window.index
  294.     @itemlist_window = Window_ItemList.new
  295.     @itemlist_window.active = false
  296.     @help_window = Window_Help.new
  297.     # 生成金钱窗口
  298.     @gold_window = Window_Gold.new
  299.     @gold_window.y = 416
  300.     @gold_window.opacity = OPACITY_Item
  301.     # 关联帮助窗口
  302.     @itemcommand_window.help_window = @help_window
  303.     @itemlist_window.help_window = @help_window
  304.     # 生成目标窗口 (设置为不可见・不活动)
  305.     @target_window = Window_Target.new
  306.     # 关联帮助窗口
  307.     @target_window.help_window = @help_window
  308.     @target_window.opacity = OPACITY_Target
  309.     @target_window.visible = false
  310.     @target_window.active = false
  311.     @itemlist_window.set_item(@itemcommand_window.commands[@command_index])
  312.     # 执行过度
  313.     Graphics.transition
  314.     # 主循环
  315.     loop do
  316.       # 刷新游戏画面
  317.       Graphics.update
  318.       # 刷新输入信息
  319.       Input.update
  320.       # 刷新画面
  321.       update
  322.       # 如果画面切换就中断循环
  323.       if $scene != self
  324.         break
  325.       end
  326.     end
  327.     # 装备过渡
  328.     Graphics.freeze
  329.     # 释放窗口
  330.     @itemmenu.dispose
  331.     @itemcommand_window.dispose
  332.     @itemlist_window.dispose
  333.     @gold_window.dispose
  334.     @help_window.dispose
  335.     @target_window.dispose
  336.   end
  337.   #--------------------------------------------------------------------------
  338.   # ● 刷新画面
  339.   #--------------------------------------------------------------------------
  340.   def update
  341.     # 刷新窗口
  342.     @help_window.update
  343.     @gold_window.update
  344.     @itemlist_window.update
  345.     @itemcommand_window.update
  346.     @target_window.update
  347.     if @command_index != @itemcommand_window.index
  348.       @command_index = @itemcommand_window.index
  349.       @itemlist_window.set_item(@itemcommand_window.commands[@command_index])
  350.     end
  351.     # 分类窗口被激活的情况下: 调用 update_itemcommand
  352.     if @itemcommand_window.active
  353.       update_itemcommand
  354.       return
  355.     end
  356.     # 物品窗口被激活的情况下: 调用 update_itemlist
  357.     if @itemlist_window.active
  358.       update_itemlist
  359.       return
  360.     end
  361.     # 目标窗口被激活的情况下: 调用 update_target
  362.     if @target_window.active
  363.       update_target
  364.       return
  365.     end
  366.   end
  367.   #--------------------------------------------------------------------------
  368.   # ● 刷新画面 (分类窗口被激活的情况下)
  369.   #--------------------------------------------------------------------------
  370.   def update_itemcommand
  371.     # 按下 B 键的情况下
  372.     if Input.trigger?(Input::B)
  373.       # 演奏取消 SE
  374.       $game_system.se_play($data_system.cancel_se)
  375.       # 切换到菜单画面
  376.       $scene = Scene_Menu.new(0)
  377.       return
  378.     end
  379.     if Input.trigger?(Input::C)
  380.       # 按下 C 键的情况下
  381.       if @itemlist_window.item_number == 0
  382.         # 演奏冻结 SE
  383.         $game_system.se_play($data_system.buzzer_se)
  384.         return
  385.       end
  386.       # 演奏确定 SE
  387.       $game_system.se_play($data_system.decision_se)
  388.       # 激活目标窗口
  389.       @itemcommand_window.active = false
  390.       @itemlist_window.active = true
  391.       @itemlist_window.index = 0
  392.       return
  393.     end
  394.   end
  395.   #--------------------------------------------------------------------------
  396.   # ● 刷新画面 (物品窗口被激活的情况下)
  397.   #--------------------------------------------------------------------------
  398.   def update_itemlist
  399.     # 按下 B 键的情况下
  400.     if Input.trigger?(Input::B)
  401.       # 演奏取消 SE
  402.       $game_system.se_play($data_system.cancel_se)
  403.       @itemcommand_window.active = true
  404.       @itemlist_window.active = false
  405.       @itemlist_window.index = 0
  406.       # 切换到分类窗口
  407.       @itemcommand_window.index = @command_index
  408.       return
  409.     end
  410.     if Input.trigger?(Input::C)
  411.       # 获取物品窗口当前选中的物品数据
  412.       @item = @itemlist_window.item
  413.       # 不使用物品的情况下
  414.       unless @item.is_a?(RPG::Item)
  415.         # 演奏冻结 SE
  416.         $game_system.se_play($data_system.buzzer_se)
  417.         return
  418.       end
  419.       # 不能使用的情况下
  420.       unless $game_party.item_can_use?(@item.id)
  421.         # 演奏冻结 SE
  422.         $game_system.se_play($data_system.buzzer_se)
  423.         return
  424.       end
  425.       # 演奏确定 SE
  426.       $game_system.se_play($data_system.decision_se)
  427.       # 效果范围是我方的情况下
  428.       if @item.scope >= 3
  429.         # 激活目标窗口
  430.         @itemlist_window.active = false
  431.         @target_window.x = 304
  432.         @target_window.visible = true
  433.         @target_window.active = true
  434.         # 设置效果范围 (单体/全体) 的对应光标位置
  435.         if @item.scope == 4 || @item.scope == 6
  436.           @target_window.index = -1
  437.         else
  438.           @target_window.index = 0
  439.         end
  440.         # 效果在我方以外的情况下
  441.       else
  442.         # 公共事件 ID 有效的情况下
  443.         if @item.common_event_id > 0
  444.           # 预约调用公共事件
  445.           $game_temp.common_event_id = @item.common_event_id
  446.           # 演奏物品使用时的 SE
  447.           $game_system.se_play(@item.menu_se)
  448.           # 消耗品的情况下
  449.           if @item.consumable
  450.             # 使用的物品数减 1
  451.             $game_party.lose_item(@item.id, 1)
  452.             # 再描绘物品窗口的项目
  453.             @itemlist_window.draw_item(@itemlist_window.index)
  454.           end
  455.           # 切换到地图画面
  456.           $scene = Scene_Map.new
  457.           return
  458.         end
  459.       end
  460.       return
  461.     end
  462.   end
  463.   #--------------------------------------------------------------------------
  464.   # ● 刷新画面 (目标窗口被激活的情况下)
  465.   #--------------------------------------------------------------------------
  466.   def update_target
  467.     # 按下 B 键的情况下
  468.     if Input.trigger?(Input::B)
  469.       # 演奏取消 SE
  470.       $game_system.se_play($data_system.cancel_se)
  471.       # 由于物品用完而不能使用的场合
  472.       unless $game_party.item_can_use?(@item.id)
  473.         # 再次生成物品窗口的内容
  474.         @itemlist_window.refresh
  475.       end
  476.       # 删除目标窗口
  477.       @itemlist_window.active = true
  478.       @target_window.visible = false
  479.       @target_window.active = false
  480.       @itemlist_window.set_item(@itemcommand_window.commands[@command_index])
  481.       return
  482.     end
  483.     # 按下 C 键的情况下
  484.     if Input.trigger?(Input::C)
  485.       # 如果物品用完的情况下
  486.       if $game_party.item_number(@item.id) == 0
  487.         # 演奏冻结 SE
  488.         $game_system.se_play($data_system.buzzer_se)
  489.         return
  490.       end
  491.       # 目标是全体的情况下
  492.       if @target_window.index == -1
  493.         used = false
  494.         for i in $game_party.actors
  495.           used |= i.item_effect(@item)
  496.         end
  497.       end
  498.       # 目标是单体的情况下
  499.       if @target_window.index >= 0
  500.         # 对目标角色应用物品的使用效果
  501.         target = $game_party.actors[@target_window.index]
  502.         used = target.item_effect(@item)
  503.       end
  504.       # 使用物品的情况下
  505.       if used
  506.         # 演奏物品使用时的 SE
  507.         $game_system.se_play(@item.menu_se)
  508.         # 使用的物品数减 1
  509.         if @item.consumable
  510.           $game_party.lose_item(@item.id, 1)
  511.           # 再描绘物品窗口的项目
  512.           @itemlist_window.draw_item(@itemlist_window.index)
  513.           @itemlist_window.set_item(@itemcommand_window.commands[@command_index])
  514.         end
  515.         # 再生成目标窗口的内容
  516.         @target_window.refresh
  517.         # 全灭的情况下
  518.         if $game_party.all_dead?
  519.           # 切换到游戏结束画面
  520.           $scene = Scene_Gameover.new
  521.           return
  522.         end
  523.         # 公共事件 ID 有效的情况下
  524.         if @item.common_event_id > 0
  525.           # 预约调用公共事件
  526.           $game_temp.common_event_id = @item.common_event_id
  527.           # 切换到地图画面
  528.           $scene = Scene_Map.new
  529.           return
  530.         end
  531.       end
  532.       # 无法使用物品的情况下
  533.       unless used
  534.         # 演奏冻结 SE
  535.         $game_system.se_play($data_system.buzzer_se)
  536.       end
  537.     return
  538.     end
  539.   end
  540. end
复制代码

点评

但是至少需要把你用的分类脚本贴出来。  发表于 2014-11-9 10:05
梦石
0
星屑
12161
在线时间
4435 小时
注册时间
2014-4-11
回帖
5616

开拓者

 楼主| 发表于 2014-11-9 12:20:51 | 显示全部楼层
@芯☆淡茹水 脚本给出来了,帮忙看看{:2_264:}

点评

第一个脚本,在菜单和战斗里都试了下,没有报错咯~!(σ゚д゚)σ  发表于 2014-11-9 13:24
回复

使用道具 举报

梦石
0
星屑
12161
在线时间
4435 小时
注册时间
2014-4-11
回帖
5616

开拓者

 楼主| 发表于 2014-11-9 13:45:59 | 显示全部楼层
@芯☆淡茹水  第一个我试了下下。是和RTAB战斗系统冲突了。

  1. # リアルタイム・アクティブバトル(RTAB) Ver 1.16
  2. # 配布元・サポートURL
  3. # [url]http://members.jcom.home.ne.jp/cogwheel/[/url]

  4. class Scene_Battle
  5.   #--------------------------------------------------------------------------
  6.   # ● 公開インスタンス変数
  7.   #--------------------------------------------------------------------------
  8.   attr_reader   :status_window            # ステータスウィンドウ
  9.   attr_reader   :spriteset                # バトルスプライト
  10.   attr_reader   :scroll_time              # スクリーン移動基本時間
  11.   attr_reader   :zoom_rate                # 敵バトラー基本位置
  12.   attr_reader   :drive                    # カメラ駆動
  13.   attr_accessor :force                    # アクション強制度
  14.   attr_accessor :camera                   # 現在のカメラ所持者
  15.   #--------------------------------------------------------------------------
  16.   # ● ATB基礎セットアップ
  17.   #--------------------------------------------------------------------------
  18.   def atb_setup
  19.     # ATB初期化
  20.     # speed   : バトルスピード決定。値が小さいほど早い
  21.     # @active : アクティブ度設定
  22.     #           3 : 常にアクティブ状態
  23.     #           2 : スキル・アイテム選択中のみアクティブゲージが止まる
  24.     #           1 : 2の状態に加え、ターゲット選択時もウェイトが掛かる
  25.     #           0 : 1の状態に加え、コマンド入力時にもウェイトが掛かる
  26.     # @action : 他人が行動中に自分も行動を起こすことを許すか
  27.     #           3 : 自分が行動不能でない限り限り許す
  28.     #           2 : 自分がダメージを受けていない限り許す
  29.     #           1 : 2の状態に加え、ターゲットが行動していない限り許す
  30.     #           0 : 行動を許さない。順番に行動し終えるまで待つ
  31.     # @anime_wait : trueにするとバトルアニメ・ダメージ表示中はウェイトが掛かる
  32.     # @damage_wait : ダメージ表示待ち時間(単位はフレーム)
  33.     # @after_wait : 味方・敵全滅時、次の処理に移るまでの待ち時間
  34.     #               [a, b] a は味方全滅時、b は敵全滅時(単位はフレーム)
  35.     # @enemy_speed : 敵の思考速度。1なら即時行動。
  36.     #                1フレーム毎に、1/@enemy_speedの確率で行動を起こす
  37.     # [url=home.php?mod=space&uid=316545]@force[/url] : 強制アクションでスキル使用時の強制具合
  38.     #          2:スキルは全て詠唱せず、必ず即時実行
  39.     #          1:単独スキルは詠唱し、連携スキルのみ即時実行
  40.     #          0:全スキル詠唱を行うだけ
  41.     # ($scene.force = x とすることにより、通常イベントのスクリプトから変更可能)
  42.     # @drive : カメラ駆動ON/OFF。trueで駆動ON、falseで駆動OFF
  43.     # @scroll_time : スクリーン移動に要する基本時間
  44.     # @zoom_rate = [i, j] : エネミーのズーム率
  45.     #                       i が画面最上部に配置した時の拡大率
  46.     #                       j が画面最下部に配置した時の拡大率
  47.     #                       1 倍としたいときも、1.0 と必ず小数で設定すること
  48.     speed = 100
  49.     @active = 1
  50.     @action = 0
  51.     @anime_wait = false
  52.     @damage_wait = 10
  53.     @after_wait = [80, 0]
  54.     @enemy_speed = 40
  55.     @force = 2
  56.     @drive = true
  57.     @scroll_time = 15
  58.     @zoom_rate = [0.2, 1.0]
  59.     @help_time = 40
  60.     @escape == false
  61.     @camera = nil
  62.     [url=home.php?mod=space&uid=25307]@Max[/url] = 0
  63.     @turn_cnt = 0
  64.     @help_wait = 0
  65.     @action_battlers = []
  66.     @synthe = []
  67.     @spell_p = {}
  68.     @spell_e = {}
  69.     @command_a = false
  70.     @command = []
  71. #------------------------------------------------------------------------------   
  72. #RTAB观光游第一站,去除“战斗/逃跑”选项部分   
  73. #    @party = false
  74. #------------------------------------------------------------------------------
  75.     for battler in $game_party.actors + $game_troop.enemies
  76.       spell_reset(battler)
  77.       battler.at = battler.agi * rand(speed / 2)
  78.       battler.damage_pop = {}
  79.       battler.damage = {}
  80.       battler.damage_sp = {}
  81.       battler.critical = {}
  82.       battler.recover_hp = {}
  83.       battler.recover_sp = {}
  84.       battler.state_p = {}
  85.       battler.state_m = {}
  86.       battler.animation = []
  87.       if battler.is_a?(Game_Actor)
  88.         @max += battler.agi
  89.       end
  90.     end
  91.     @max *= speed
  92.     @max /= $game_party.actors.size
  93.     for battler in $game_party.actors + $game_troop.enemies
  94.       battler.atp = 100 * battler.at / @max
  95.     end
  96.   end
  97.   #--------------------------------------------------------------------------
  98.   # ● ATゲージMax時SE
  99.   #--------------------------------------------------------------------------
  100.   def fullat_se
  101.     Audio.se_play("Audio/SE/033-switch02", 80, 100)
  102.   end
  103.   #--------------------------------------------------------------------------
  104.   # ● レベルアップSE
  105.   #--------------------------------------------------------------------------
  106.   def levelup_se
  107.     Audio.se_play("Audio/SE/056-Right02", 80, 100)
  108.   end
  109.   #--------------------------------------------------------------------------
  110.   # ● スキル習得SE
  111.   #--------------------------------------------------------------------------
  112.   def skill_se
  113.     Audio.se_play("Audio/SE/056-Right02", 80, 150)
  114.   end
  115. end

  116. class Window_Base < Window
  117.   #--------------------------------------------------------------------------
  118.   # ● ATG の描画
  119.   #     actor : アクター
  120.   #     x     : 描画先 X 座標
  121.   #     y     : 描画先 Y 座標
  122.   #     width : 描画先の幅
  123.   #--------------------------------------------------------------------------
  124.   def draw_actor_atg(actor, x, y, width = 144)
  125.     if @at_gauge == nil
  126.       # plus_x:X座標の位置補正 rate_x:X座標の位置補正(%) plus_y:Y座標の位置補正
  127.       # plus_width:幅の補正 rate_width:幅の補正(%) height:縦幅
  128.       # align1:描画タイプ1 0:左詰め 1:中央揃え 2:右詰め
  129.       # align2:描画タイプ2 0:上詰め 1:中央揃え 2:下詰め
  130.       # align3:ゲージタイプ 0:左詰め 1:右詰め
  131.       @plus_x = 0
  132.       @rate_x = 0
  133.       @plus_y = 16
  134.       @plus_width = 0
  135.       @rate_width = 100
  136.       @width = @plus_width + width * @rate_width / 100
  137.       [url=home.php?mod=space&uid=291977]@height[/url] = 16
  138.       @align1 = 0
  139.       @align2 = 1
  140.       @align3 = 0
  141.       # グラデーション設定 grade1:空ゲージ grade2:実ゲージ
  142.       # (0:横にグラデーション 1:縦にグラデーション 2:斜めにグラデーション)
  143.       grade1 = 1
  144.       grade2 = 0
  145.       # 色設定。color1:最外枠,color2:中枠
  146.       # color3:空枠ダークカラー,color4:空枠ライトカラー
  147.       color1 = Color.new(0, 0, 0)
  148.       color2 = Color.new(255, 255, 192)
  149.       color3 = Color.new(0, 0, 0, 192)
  150.       color4 = Color.new(0, 0, 64, 192)
  151.       # ゲージの色設定
  152.       # 通常時の色設定
  153.       color5 = Color.new(0, 64, 80)
  154.       color6 = Color.new(0, 128, 160)
  155.       # ゲージがMAXの時の色設定
  156.       color7 = Color.new(80, 0, 0)
  157.       color8 = Color.new(240, 0, 0)
  158.       # 連携スキル使用時の色設定
  159.       color9 = Color.new(80, 64, 32)
  160.       color10 = Color.new(240, 192, 96)
  161.       # スキル詠唱時の色設定
  162.       color11 = Color.new(80, 0, 64)
  163.       color12 = Color.new(240, 0, 192)
  164.       # ゲージの描画
  165.       gauge_rect_at(@width, @height, @align3, color1, color2,
  166.                   color3, color4, color5, color6, color7, color8,
  167.                   color9, color10, color11, color12, grade1, grade2)
  168.     end
  169.     # 変数atに描画するゲージの幅を代入
  170.     if actor.rtp == 0
  171.       at = (width + @plus_width) * actor.atp * @rate_width / 10000
  172.     else
  173.       at = (width + @plus_width) * actor.rt * @rate_width / actor.rtp / 100
  174.     end
  175.     if at > width
  176.       at = width
  177.     end
  178.     # ゲージの左詰・中央構え等の補正
  179.     case @align1
  180.     when 1
  181.       x += (@rect_width - width) / 2
  182.     when 2
  183.       x += @rect_width - width
  184.     end
  185.     case @align2
  186.     when 1
  187.       y -= @height / 2
  188.     when 2
  189.       y -= @height
  190.     end
  191.     self.contents.blt(x + @plus_x + width * @rate_x / 100, y + @plus_y,
  192.                       @at_gauge, Rect.new(0, 0, @width, @height))
  193.     if @align3 == 0
  194.       rect_x = 0
  195.     else
  196.       x += @width - at - 1
  197.       rect_x = @width - at - 1
  198.     end
  199.     # ゲージの色設定
  200.     if at == width
  201.         # MAX時のゲージ描画
  202.       self.contents.blt(x + @plus_x + @width * @rate_x / 100, y + @plus_y,
  203.                         @at_gauge, Rect.new(rect_x, @height * 2, at, @height))
  204.     else
  205.       if actor.rtp == 0
  206.         # 通常時のゲージ描画
  207.         self.contents.blt(x + @plus_x + @width * @rate_x / 100, y + @plus_y,
  208.                           @at_gauge, Rect.new(rect_x, @height, at, @height))
  209.       else
  210.         if actor.spell == true
  211.           # 連携スキル使用時のゲージ描画
  212.           self.contents.blt(x + @plus_x + @width * @rate_x / 100, y + @plus_y,
  213.                         @at_gauge, Rect.new(rect_x, @height * 3, at, @height))
  214.         else
  215.           # スキル詠唱時のゲージ描画
  216.           self.contents.blt(x + @plus_x + @width * @rate_x / 100, y + @plus_y,
  217.                         @at_gauge, Rect.new(rect_x, @height * 4, at, @height))
  218.         end
  219.       end
  220.     end
  221.   end
  222. end

  223. #==============================================================================
  224. # ■ Scene_Battle (分割定義 1)
  225. #------------------------------------------------------------------------------
  226. #  バトル画面の処理を行うクラスです。
  227. #==============================================================================

  228. class Scene_Battle
  229.   #--------------------------------------------------------------------------
  230.   # ● メイン処理
  231.   #--------------------------------------------------------------------------
  232.   def main
  233.     # 戦闘用の各種一時データを初期化
  234.    # Graphics.frame_rate = 60
  235.     $game_temp.in_battle = true
  236.     $game_temp.battle_turn = 0
  237.     $game_temp.battle_event_flags.clear
  238.     $game_temp.battle_abort = false
  239.     $game_temp.battle_main_phase = false
  240.     $game_temp.battleback_name = $game_map.battleback_name
  241.     $game_temp.forcing_battler = nil
  242.     # バトルイベント用インタプリタを初期化
  243.     $game_system.battle_interpreter.setup(nil, 0)
  244.     # トループを準備
  245.     @troop_id = $game_temp.battle_troop_id
  246.     $game_troop.setup(@troop_id)
  247.     atb_setup
  248.     # アクターコマンドウィンドウを作成
  249. #==============================================================================
  250. #RTAB观光游第三站,战斗菜单增加逃跑选项
  251. #==============================================================================   
  252.     s1 = $data_system.words.attack
  253.     s2 = $data_system.words.skill
  254.     s3 = $data_system.words.guard
  255.     s4 = $data_system.words.item
  256.     s5 = "逃跑"
  257.     @actor_command_window = Window_Command.new(160, [s1, s2, s3, s4,s5])   
  258. #   @actor_command_window.y = 160
  259.     @actor_command_window.y = 128
  260.     @actor_command_window.back_opacity = 160
  261.     @actor_command_window.active = false
  262.     @actor_command_window.visible = false
  263. #==============================================================================   
  264.     # その他のウィンドウを作成
  265. #------------------------------------------------------------------------------
  266. #RTAB观光游第一站,去除“战斗/逃跑”选项部分   
  267. #    @party_command_window = Window_PartyCommand.new
  268. #------------------------------------------------------------------------------   
  269.     @help_window = Window_Help.new
  270.     @help_window.back_opacity = 160
  271.     @help_window.visible = false
  272.     @status_window = Window_BattleStatus.new
  273.     @message_window = Window_Message.new
  274.     # スプライトセットを作成
  275.     @spriteset = Spriteset_Battle.new
  276.     # ウェイトカウントを初期化
  277.     @wait_count = 0
  278.     # トランジション実行
  279.     if $data_system.battle_transition == ""
  280.       Graphics.transition(20)
  281.     else
  282.       Graphics.transition(40, "Graphics/Transitions/" +
  283.         $data_system.battle_transition)
  284.     end
  285.     # プレバトルフェーズ開始
  286.     start_phase1
  287.     # メインループ
  288.     loop do
  289.       # ゲーム画面を更新
  290.       Graphics.update
  291.       # 入力情報を更新
  292.       Input.update
  293.       # フレーム更新
  294.       update
  295.       # 画面が切り替わったらループを中断
  296.       if $scene != self
  297.         break
  298.       end
  299.     end
  300.     # マップをリフレッシュ
  301.     $game_map.refresh
  302.     # トランジション準備
  303.     Graphics.freeze
  304.     # ウィンドウを解放
  305.     @actor_command_window.dispose
  306. #------------------------------------------------------------------------------
  307. #RTAB观光游第一站,去除“战斗/逃跑”选项部分   
  308. #    @party_command_window.dispose
  309. #------------------------------------------------------------------------------   
  310.     @help_window.dispose
  311.     @status_window.dispose
  312.     @message_window.dispose
  313.     if @skill_window != nil
  314.       @skill_window.dispose
  315.     end
  316.     if @item_window != nil
  317.       @item_window.dispose
  318.     end
  319.     if @result_window != nil
  320.       @result_window.dispose
  321.     end
  322.     # スプライトセットを解放
  323.     @spriteset.dispose
  324.     # タイトル画面に切り替え中の場合
  325.     if $scene.is_a?(Scene_Title)
  326.       # 画面をフェードアウト
  327.       Graphics.transition
  328.       Graphics.freeze
  329.     end
  330.     # 戦闘テストからゲームオーバー画面以外に切り替え中の場合
  331.     if $BTEST and not $scene.is_a?(Scene_Gameover)
  332.       $scene = nil
  333.     end
  334.   end
  335.   #--------------------------------------------------------------------------
  336.   # ● 勝敗判定
  337.   #--------------------------------------------------------------------------
  338.   def judge
  339.     # 全滅判定が真、またはパーティ人数が 0 人の場合
  340.     if $game_party.all_dead? or $game_party.actors.size == 0
  341.       # 敗北可能の場合
  342.       if $game_temp.battle_can_lose
  343.         # バトル開始前の BGM に戻す
  344.         $game_system.bgm_play($game_temp.map_bgm)
  345.         # バトル終了
  346.         battle_end(2)
  347.         # true を返す
  348.         return true
  349.       end
  350.       # ゲームオーバーフラグをセット
  351.       $game_temp.gameover = true
  352.       # true を返す
  353.       return true
  354.     end
  355.     # エネミーが 1 体でも存在すれば false を返す
  356.     for enemy in $game_troop.enemies
  357.       if enemy.exist?
  358.         return false
  359.       end
  360.     end
  361.     # アフターバトルフェーズ開始 (勝利)
  362.     start_phase5
  363.     # true を返す
  364.     return true
  365.   end
  366.   #--------------------------------------------------------------------------
  367.   # ● フレーム更新
  368.   #--------------------------------------------------------------------------
  369.   def update
  370.     # バトルイベント実行中の場合
  371.     if $game_system.battle_interpreter.running?
  372.       if @command.size > 0
  373.         @command_a = false
  374.         @command = []
  375.         command_delete
  376.       end
  377.       @status_window.at_refresh
  378.       # インタプリタを更新
  379.       $game_system.battle_interpreter.update
  380.       # アクションを強制されているバトラーが存在しない場合
  381.       if $game_temp.forcing_battler == nil
  382.         # バトルイベントの実行が終わった場合
  383.         unless $game_system.battle_interpreter.running?
  384.           # バトルイベントのセットアップを再実行
  385.           @status_window.refresh
  386.           setup_battle_event
  387.         end
  388.       end
  389.     end
  390.     # システム (タイマー)、画面を更新
  391.     $game_system.update
  392.     $game_screen.update
  393.     # タイマーが 0 になった場合
  394.     if $game_system.timer_working and $game_system.timer == 0
  395.       # バトル中断
  396.       $game_temp.battle_abort = true
  397.     end
  398.     # ウィンドウを更新
  399.     @help_window.update
  400. #------------------------------------------------------------------------------
  401. #RTAB观光游第一站,去除“战斗/逃跑”选项部分   
  402. #    @party_command_window.update
  403. #------------------------------------------------------------------------------
  404.     @actor_command_window.update
  405.     @status_window.update
  406.     @message_window.update
  407.     # スプライトセットを更新
  408.     @spriteset.update
  409.     # トランジション処理中の場合
  410.     if $game_temp.transition_processing
  411.       # トランジション処理中フラグをクリア
  412.       $game_temp.transition_processing = false
  413.       # トランジション実行
  414.       if $game_temp.transition_name == ""
  415.         Graphics.transition(20)
  416.       else
  417.         Graphics.transition(40, "Graphics/Transitions/" +
  418.           $game_temp.transition_name)
  419.       end
  420.     end
  421.     # メッセージウィンドウ表示中の場合
  422.     if $game_temp.message_window_showing
  423.       return
  424.     end
  425.     # ゲームオーバーの場合
  426.     if $game_temp.gameover
  427.       # ゲームオーバー画面に切り替え
  428.       $scene = Scene_Gameover.new
  429.       return
  430.     end
  431.     # タイトル画面に戻す場合
  432.     if $game_temp.to_title
  433.       # タイトル画面に切り替え
  434.       $scene = Scene_Title.new
  435.       return
  436.     end
  437.     # バトル中断の場合
  438.     if $game_temp.battle_abort
  439.       # バトル開始前の BGM に戻す
  440.       $game_system.bgm_play($game_temp.map_bgm)
  441.       # バトル終了
  442.       battle_end(1)
  443.       return
  444.     end
  445.     # ヘルプウィンドウ表示中の場合
  446.     if @help_wait > 0
  447.       @help_wait -= 1
  448.       if @help_wait == 0
  449.         # ヘルプウィンドウを隠す
  450.         @help_window.visible = false
  451.       end
  452.     end
  453.     # アクションを強制されているバトラーが存在せず、
  454.     # かつバトルイベントが実行中の場合
  455.     if $game_temp.forcing_battler == nil and
  456.        $game_system.battle_interpreter.running?
  457.       return
  458.     end
  459.     # フェーズによって分岐
  460.     case @phase
  461.     when 0  # ATゲージ更新フェーズ
  462.       if anime_wait_return
  463.         update_phase0
  464.       end
  465.     when 1  # プレバトルフェーズ
  466.       update_phase1
  467.       return
  468.     when 2  # パーティコマンドフェーズ
  469.       update_phase2
  470.       return
  471.     when 5  # アフターバトルフェーズ
  472.       update_phase5
  473.       return
  474.     end
  475.     if $scene != self
  476.       return
  477.     end
  478.     if @phase == 0
  479.       if @command.size != 0  # アクターコマンドフェーズ
  480.         if @command_a == false
  481.           start_phase3
  482.         end
  483.         update_phase3
  484.       end
  485.       # ウェイト中の場合
  486.       if @wait_count > 0
  487.         # ウェイトカウントを減らす
  488.         @wait_count -= 1
  489.         return
  490.       end
  491.       update_phase4
  492.     end
  493.   end

  494. #==============================================================================
  495. # ■ Scene_Battle (分割定義 2)
  496. #------------------------------------------------------------------------------
  497. #  バトル画面の処理を行うクラスです。
  498. #==============================================================================

  499.   #--------------------------------------------------------------------------
  500.   # ● フレーム更新 (ATゲージ更新フェーズ)
  501.   #--------------------------------------------------------------------------
  502.   def update_phase0
  503.     if $game_temp.battle_turn == 0
  504.       $game_temp.battle_turn = 1
  505.     end
  506.     # B ボタンが押された場合
  507.   #  if @command_a == false and @party == false
  508.    #   if Input.trigger?(Input::B)
  509.         # キャンセル SE を演奏
  510.    #     $game_system.se_play($data_system.cancel_se)
  511.    #     @party = true
  512.    #   end
  513.    # end
  514.    # if @party == true and
  515.    #     ((@action > 0 and @action_battlers.empty?) or (@action == 0 and
  516.    #     (@action_battlers.empty? or @action_battlers[0].phase == 1)))
  517.       # パーティコマンドフェーズへ
  518.    #   start_phase2
  519.    #   return
  520.    # end
  521.     # ATゲージ増加処理
  522.     cnt = 0
  523.     for battler in $game_party.actors + $game_troop.enemies
  524.       active?(battler)
  525.       if battler.rtp == 0
  526.         if battler.at >= @max
  527.           if battler.is_a?(Game_Actor)
  528.             if battler.inputable?
  529.               unless @action_battlers.include?(battler) or
  530.                   @command.include?(battler) or @escape == true
  531.                 if battler.current_action.forcing
  532.                   fullat_se
  533.                   force_action(battler)
  534.                   action_start(battler)
  535.                 else
  536.                   fullat_se
  537.                   @command.push(battler)
  538.                 end
  539.               end
  540.             else
  541.               unless @action_battlers.include?(battler) or
  542.                       battler == @command[0]
  543.                 battler.current_action.clear
  544.                 if @command.include?(battler)
  545.                   @command.delete(battler)
  546.                 else
  547.                   if battler.movable?
  548.                     fullat_se
  549.                   end
  550.                 end
  551.                 action_start(battler)
  552.               end
  553.             end
  554.           else
  555.             unless @action_battlers.include?(battler)
  556.               if battler.current_action.forcing
  557.                 force_action(battler)
  558.                 action_start(battler)
  559.               else
  560.                 if @enemy_speed != 0
  561.                   if rand(@enemy_speed) == 0
  562.                     number = cnt - $game_party.actors.size
  563.                     enemy_action(number)
  564.                   end
  565.                 else
  566.                   number = cnt - $game_party.actors.size
  567.                   enemy_action(number)
  568.                 end
  569.               end
  570.             end
  571.           end
  572.         else
  573.           battler.at += battler.agi
  574.           if battler.guarding?
  575.             battler.at += battler.agi
  576.           end
  577.           if battler.movable?
  578.             battler.atp = 100 * battler.at / @max
  579.           end
  580.         end
  581.       else
  582.         if battler.rt >= battler.rtp
  583.           speller = synthe?(battler)
  584.           if speller != nil
  585.             battler = speller[0]
  586.           end
  587.           unless @action_battlers.include?(battler)
  588.             if battler.is_a?(Game_Actor)
  589.               fullat_se
  590.             end
  591.             battler.rt = battler.rtp
  592.             action_start(battler)
  593.           end
  594.         else
  595.           battler.rt += battler.agi
  596.           speller = synthe?(battler)
  597.           if speller != nil
  598.             for spell in speller
  599.               if spell != battler
  600.                 spell.rt += battler.agi
  601.               end
  602.             end
  603.           end
  604.         end
  605.       end
  606.       cnt += 1
  607.     end
  608.     # ATゲージをリフレッシュ
  609.     @status_window.at_refresh
  610.     # 逃走処理
  611.     if @escape == true and
  612.         ((@action > 0 and @action_battlers.empty?) or (@action == 0 and
  613.         (@action_battlers.empty? or @action_battlers[0].phase == 1)))
  614.       temp = false
  615.       for battler in $game_party.actors
  616.         if battler.inputable?
  617.           temp = true
  618.         end
  619.       end
  620.       if temp == true
  621.         for battler in $game_party.actors
  622.           if battler.at < @max and battler.inputable?
  623.             temp = false
  624.             break
  625.           end
  626.         end
  627.         if temp == true
  628.           @escape = false
  629.           for battler in $game_party.actors
  630.             battler.at %= @max
  631.           end
  632.           $game_temp.battle_main_phase = false
  633.           update_phase2_escape
  634.         end
  635.       end
  636.     end
  637.   end
  638. #------------------------------------------------------------------------------
  639. #RTAB观光游第一站,去除“战斗/逃跑”选项部分  
  640.   #--------------------------------------------------------------------------
  641.   # ● パーティコマンドフェーズ開始
  642.   #--------------------------------------------------------------------------
  643. #  def start_phase2
  644.     # フェーズ 2 に移行
  645. #    @phase = 2
  646. #    @party = false
  647.     # パーティコマンドウィンドウを有効化
  648. #    @party_command_window.active = true
  649. #    @party_command_window.visible = true
  650.     # アクターを非選択状態に設定
  651. #    @actor_index = -1
  652.     # アクターコマンドウィンドウを無効化
  653. #    @actor_command_window.active = false
  654. #    @actor_command_window.visible = false
  655. #    if @command.size != 0
  656.       # アクターの明滅エフェクト OFF
  657. #      if @active_actor != nil
  658. #        @active_actor.blink = false
  659. #      end
  660. #    end
  661.     # カメラセット
  662. #    @camera == "party"
  663. #    @spriteset.screen_target(0, 0, 1)
  664.     # メインフェーズフラグをクリア
  665. #    $game_temp.battle_main_phase = false
  666. #  end
  667. #------------------------------------------------------------------------------
  668.   #--------------------------------------------------------------------------
  669.   # ● フレーム更新 (パーティコマンドフェーズ)
  670.   #--------------------------------------------------------------------------
  671.   def update_phase2
  672. #------------------------------------------------------------------------------
  673. #RTAB观光游第一站,去除“战斗/逃跑”选项部分  
  674.     # C ボタンが押された場合
  675.    # 去掉“战斗/逃跑”选项
  676. #    if Input.trigger?(Input::C)
  677.       # パーティコマンドウィンドウのカーソル位置で分岐
  678. #      case @party_command_window.index
  679. #      when 0  # 戦う
  680.         # パーティコマンドウィンドウを無効化
  681. #        @party_command_window.active = false
  682. #        @party_command_window.visible = false
  683.         # 決定 SE を演奏
  684. #        $game_system.se_play($data_system.decision_se)
  685. #------------------------------------------------------------------------------
  686.         @escape = false
  687.         @phase = 0
  688.         if $game_temp.battle_turn == 0
  689.           $game_temp.battle_turn = 1
  690.         end
  691.         if @command_a == true
  692.           # アクターコマンドフェーズ開始
  693.           start_phase3
  694.         else
  695.           $game_temp.battle_main_phase = true
  696.         end
  697. end         
  698. #------------------------------------------------------------------------------
  699. #RTAB观光游第一站,去除“战斗/逃跑”选项部分         
  700. #      when 1  # 逃げる
  701.         # 逃走可能ではない場合
  702. #        if $game_temp.battle_can_escape == false
  703.           # ブザー SE を演奏
  704. #          $game_system.se_play($data_system.buzzer_se)
  705. #          return
  706. #        end
  707.         # 決定 SE を演奏
  708. #        $game_system.se_play($data_system.decision_se)
  709. #        @phase = 0
  710.         # パーティコマンドウィンドウを無効化
  711. #        @party_command_window.active = false
  712. #        @party_command_window.visible = false
  713. #        $game_temp.battle_main_phase = true
  714. #        if $game_temp.battle_turn == 0
  715. #          update_phase2_escape
  716. #          $game_temp.battle_turn = 1
  717. #        for battler in $game_party.actors
  718. #           battler.at -= @max / 2
  719. #         end
  720. #         return
  721. #      end
  722.         # 決定 SE を演奏
  723. #       $game_system.se_play($data_system.decision_se)
  724. #       @escape = true
  725. #       for battler in $game_party.actors
  726. #         @command_a = false
  727. #         @command.delete(battler)
  728. #         @action_battlers.delete(battler)
  729. #         skill_reset(battler)
  730. #       end
  731. #     end
  732. #     return
  733. #   end
  734. #end
  735. #------------------------------------------------------------------------------
  736.   #--------------------------------------------------------------------------
  737.   # ● フレーム更新 (パーティコマンドフェーズ : 逃げる)
  738.   #--------------------------------------------------------------------------
  739.   def update_phase2_escape
  740.     # エネミーの素早さ平均値を計算
  741.     enemies_agi = 0
  742.     enemies_number = 0
  743.     for enemy in $game_troop.enemies
  744.       if enemy.exist?
  745.         enemies_agi += enemy.agi
  746.         enemies_number += 1
  747.       end
  748.     end
  749.     if enemies_number > 0
  750.       enemies_agi /= enemies_number
  751.     end
  752.     # アクターの素早さ平均値を計算
  753.     actors_agi = 0
  754.     actors_number = 0
  755.     for actor in $game_party.actors
  756.       if actor.exist?
  757.         actors_agi += actor.agi
  758.         actors_number += 1
  759.       end
  760.     end
  761.     if actors_number > 0
  762.       actors_agi /= actors_number
  763.     end
  764.     # 逃走成功判定
  765.     success = rand(100) < 50 * actors_agi / enemies_agi
  766.     # 逃走成功の場合
  767.     if success
  768.       # 逃走 SE を演奏
  769.       $game_system.se_play($data_system.escape_se)
  770.       # バトル開始前の BGM に戻す
  771.       $game_system.bgm_play($game_temp.map_bgm)
  772.       # バトル終了
  773.       battle_end(1)
  774.     # 逃走失敗の場合
  775.     else
  776.       @help_window.set_text("逃走失敗", 1)
  777.       @help_wait = @help_time
  778.       # パーティ全員のアクションをクリア
  779.       $game_party.clear_actions
  780.       # メインフェーズ開始
  781.       start_phase4
  782.     end
  783.   end
  784.   #--------------------------------------------------------------------------
  785.   # ● アフターバトルフェーズ開始
  786.   #--------------------------------------------------------------------------
  787.   def start_phase5
  788.     # フェーズ 5 に移行
  789.     @phase = 5
  790.     # バトル終了 ME を演奏
  791.     $game_system.me_play($game_system.battle_end_me)
  792.     # バトル開始前の BGM に戻す
  793.     $game_system.bgm_play($game_temp.map_bgm)
  794.     # EXP、ゴールド、トレジャーを初期化
  795.     exp = 0
  796.     gold = 0
  797.     treasures = []
  798.     if @active_actor != nil
  799.       @active_actor.blink = false
  800.     end
  801.     # メインフェーズフラグをセット
  802.     $game_temp.battle_main_phase = true
  803. #------------------------------------------------------------------------------
  804. #RTAB观光游第一站,去除“战斗/逃跑”选项部分   
  805.     # パーティコマンドウィンドウを無効化
  806. #    @party_command_window.active = false
  807. #    @party_command_window.visible = false
  808. #------------------------------------------------------------------------------
  809.     # アクターコマンドウィンドウを無効化
  810.     @actor_command_window.active = false
  811.     @actor_command_window.visible = false
  812.     if @skill_window != nil
  813.       # スキルウィンドウを解放
  814.       @skill_window.dispose
  815.       @skill_window = nil
  816.     end
  817.     if @item_window != nil
  818.       # アイテムウィンドウを解放
  819.       @item_window.dispose
  820.       @item_window = nil
  821.     end
  822.     # ヘルプウィンドウを隠す
  823.     @help_window.visible = false
  824.     # ループ
  825.     for enemy in $game_troop.enemies
  826.       # エネミーが隠れ状態でない場合
  827.       unless enemy.hidden
  828.         # 獲得 EXP、ゴールドを追加
  829.         exp += enemy.exp
  830.         gold += enemy.gold
  831.         # トレジャー出現判定
  832.         if rand(100) < enemy.treasure_prob
  833.           if enemy.item_id > 0
  834.             treasures.push($data_items[enemy.item_id])
  835.           end
  836.           if enemy.weapon_id > 0
  837.             treasures.push($data_weapons[enemy.weapon_id])
  838.           end
  839.           if enemy.armor_id > 0
  840.             treasures.push($data_armors[enemy.armor_id])
  841.           end
  842.         end
  843.       end
  844.     end
  845.     # トレジャーの数を 6 個までに限定
  846.     treasures = treasures[0..5]
  847.     # EXP 獲得
  848.     for i in 0...$game_party.actors.size
  849.       actor = $game_party.actors[i]
  850.       if actor.cant_get_exp? == false
  851.         last_level = actor.level
  852.         actor.exp += exp
  853.         if actor.level > last_level
  854.           @status_window.level_up(i)
  855.           actor.damage[[actor, -1]] = "Level up!"
  856.           actor.up_level = actor.level - last_level
  857.         end
  858.       end
  859.     end
  860.     # ゴールド獲得
  861.     $game_party.gain_gold(gold)
  862.     # トレジャー獲得
  863.     for item in treasures
  864.       case item
  865.       when RPG::Item
  866.         $game_party.gain_item(item.id, 1)
  867.       when RPG::Weapon
  868.         $game_party.gain_weapon(item.id, 1)
  869.       when RPG::Armor
  870.         $game_party.gain_armor(item.id, 1)
  871.       end
  872.     end
  873.     # バトルリザルトウィンドウを作成
  874.     @result_window = Window_BattleResult.new(exp, gold, treasures)
  875.     # ウェイトカウントを設定
  876.     @phase5_wait_count = 100
  877.   end
  878.   #--------------------------------------------------------------------------
  879.   # ● フレーム更新 (アフターバトルフェーズ)
  880.   #--------------------------------------------------------------------------
  881.   def update_phase5
  882.     # ウェイトカウントが 0 より大きい場合
  883.     if @phase5_wait_count > 0
  884.       # ウェイトカウントを減らす
  885.       @phase5_wait_count -= 1
  886.       # ウェイトカウントが 0 になった場合
  887.       if @phase5_wait_count == 0
  888.         # リザルトウィンドウを表示
  889.         @result_window.visible = true
  890.         # メインフェーズフラグをクリア
  891.         $game_temp.battle_main_phase = false
  892.         # ステータスウィンドウをリフレッシュ
  893.         @status_window.refresh
  894.         for actor in $game_party.actors
  895.           if actor.damage.include?([actor, 0])
  896.             @phase5_wait_count = 20
  897.             actor.damage_pop[[actor, 0]] = true
  898.           end
  899.           if actor.damage.include?([actor, -1])
  900.             @phase5_wait_count = 20
  901.             actor.damage_pop[[actor, -1]] = true
  902.             for level in actor.level - actor.up_level + 1..actor.level
  903.               for skill in $data_classes[actor.class_id].learnings
  904.                 if level == skill.level and not actor.skill_learn?(skill.id)
  905.                   actor.damage[[actor, 0]] = "New Skill!"
  906.                   break
  907.                 end
  908.               end
  909.             end
  910.           end
  911.         end
  912.       end
  913.       return
  914.     end
  915.     # C ボタンが押された場合
  916.     if Input.trigger?(Input::C)
  917.       # バトル終了
  918.       battle_end(0)
  919.     end
  920.   end

  921. #==============================================================================
  922. # ■ Scene_Battle (分割定義 3)
  923. #------------------------------------------------------------------------------
  924. #  バトル画面の処理を行うクラスです。
  925. #==============================================================================

  926.   #--------------------------------------------------------------------------
  927.   # ● アクターコマンドフェーズ開始
  928.   #--------------------------------------------------------------------------
  929.   def start_phase3
  930.     if victory?
  931.       return
  932.     end
  933.     # メインフェーズフラグをクリア
  934.     $game_temp.battle_main_phase = false
  935.     @command_a = true
  936.     @active_actor = @command[0]
  937.     cnt = 0
  938.     for actor in $game_party.actors
  939.       if actor == @active_actor
  940.         @actor_index = cnt
  941.       end
  942.       cnt += 1
  943.     end
  944.     @active_actor.blink = true
  945.     unless @active_actor.inputable?
  946.       @active_actor.current_action.clear
  947.       phase3_next_actor
  948.       return
  949.     end
  950.     phase3_setup_command_window
  951.     # カメラの設定
  952.     @camera = "command"
  953.     plus = ($game_party.actors.size - 1) / 2.0 - @actor_index
  954.     y = [(plus.abs - 1.5) * 10 , 0].min
  955.     @spriteset.screen_target(plus * 50, y, 1.0 + y * 0.002)
  956.   end
  957.   #--------------------------------------------------------------------------
  958.   # ● アクターのコマンド入力終了
  959.   #--------------------------------------------------------------------------
  960.   def phase3_next_actor
  961.     @command.shift
  962.     @command_a = false
  963.     # メインフェーズフラグをセット
  964.     $game_temp.battle_main_phase = true
  965.     # アクターコマンドウィンドウを無効化
  966.     @actor_command_window.active = false
  967.     @actor_command_window.visible = false
  968.     # アクターの明滅エフェクト OFF
  969.     if @active_actor != nil
  970.       @active_actor.blink = false
  971.     end
  972.     action_start(@active_actor)
  973.     # カメラを元に戻す
  974.     if @camera == "command"
  975.       @spriteset.screen_target(0, 0, 1)
  976.     end
  977.     return
  978.   end
  979.   #--------------------------------------------------------------------------
  980.   # ● アクターコマンドウィンドウのセットアップ
  981.   #--------------------------------------------------------------------------
  982.   def phase3_setup_command_window
  983. #------------------------------------------------------------------------------
  984. #RTAB观光游第一站,去除“战斗/逃跑”选项部分   
  985.     # パーティコマンドウィンドウを無効化
  986. #    @party_command_window.active = false
  987. #    @party_command_window.visible = false
  988. #------------------------------------------------------------------------------  
  989.     # アクターコマンドウィンドウを有効化
  990.     @actor_command_window.active = true
  991.     @actor_command_window.visible = true
  992.     # アクターコマンドウィンドウの位置を設定
  993.     @actor_command_window.x = @actor_index * 160 +
  994.                               (4 - $game_party.actors.size) * 80
  995.     # インデックスを 0 に設定
  996.     @actor_command_window.index = 0
  997.   end
  998.   #--------------------------------------------------------------------------
  999.   # ● エネミーアクション作成
  1000.   #--------------------------------------------------------------------------
  1001.   def enemy_action(number)
  1002.     enemy = $game_troop.enemies[number]
  1003.     unless enemy.current_action.forcing
  1004.       enemy.make_action
  1005.     end
  1006.     action_start(enemy)
  1007.   end
  1008.   #--------------------------------------------------------------------------
  1009.   # ● フレーム更新 (アクターコマンドフェーズ)
  1010.   #--------------------------------------------------------------------------
  1011.   def update_phase3
  1012.     if victory? and @command_a
  1013.       command_delete
  1014.       @command.push(@active_actor)
  1015.       return
  1016.     end
  1017.     # エネミーアローが有効の場合
  1018.     if @enemy_arrow != nil
  1019.       update_phase3_enemy_select
  1020.     # アクターアローが有効の場合
  1021.     elsif @actor_arrow != nil
  1022.       update_phase3_actor_select
  1023.     # スキルウィンドウが有効の場合
  1024.     elsif @skill_window != nil
  1025.       update_phase3_skill_select
  1026.     # アイテムウィンドウが有効の場合
  1027.     elsif @item_window != nil
  1028.       update_phase3_item_select
  1029.     # アクターコマンドウィンドウが有効の場合
  1030.     elsif @actor_command_window.active
  1031.       update_phase3_basic_command
  1032.     end
  1033.   end
  1034.   #--------------------------------------------------------------------------
  1035.   # ● フレーム更新 (アクターコマンドフェーズ : 基本コマンド)
  1036.   #--------------------------------------------------------------------------
  1037.   def update_phase3_basic_command
  1038.     unless @active_actor.inputable?
  1039.       @active_actor.current_action.clear
  1040.       phase3_next_actor
  1041.       return
  1042.     end
  1043. #--------------------------------------------------------------------------
  1044. #RTAB观光游第一站,去除“战斗/逃跑”选项部分
  1045. # B ボタンが押された場合
  1046. #   if Input.trigger?(Input::B) and @party == false
  1047.       # キャンセル SE を演奏
  1048. #     $game_system.se_play($data_system.cancel_se)
  1049. #     @party = true
  1050. #   end
  1051. #   if @party == true and
  1052. #       ((@action > 0 and @action_battlers.empty?) or (@action == 0 and
  1053. #       (@action_battlers.empty? or @action_battlers[0].phase == 1)))
  1054.       # パーティコマンドフェーズへ
  1055. #     start_phase2
  1056. #     return
  1057. #   end
  1058. #==============================================================================
  1059. #RTAB观光游第二站,增加战斗快捷键ASD                      这段是官方增加的脚本
  1060. #==============================================================================
  1061.     # A : SKILL
  1062.     if Input.trigger?(Input::X)
  1063.       # 決定 SE を演奏
  1064.       $game_system.se_play($data_system.decision_se)
  1065.       # スキルの選択を開始
  1066.       start_skill_select
  1067.       return
  1068.     end
  1069.     # S : 防御
  1070.     if Input.trigger?(Input::Y)
  1071.       # 決定 SE を演奏
  1072.       $game_system.se_play($data_system.decision_se)
  1073.       # アクションを設定
  1074.       @active_actor.current_action.kind = 0
  1075.       @active_actor.current_action.basic = 1
  1076.       # 次のアクターのコマンド入力へ
  1077.       phase3_next_actor
  1078.       return
  1079.     end
  1080.     # D : ITEM
  1081.     if Input.trigger?(Input::Z)
  1082.       # 決定 SE を演奏
  1083.       $game_system.se_play($data_system.decision_se)
  1084.       # アイテムの選択を開始
  1085.       start_item_select
  1086.       return
  1087.     end
  1088. #==============================================================================
  1089.     # C ボタンが押された場合
  1090.     if Input.trigger?(Input::C)
  1091. #------------------------------------------------------------------------------
  1092. #RTAB观光游第一站,去除“战斗/逃跑”选项部分      
  1093. #      @party = false
  1094. #------------------------------------------------------------------------------
  1095.       # アクターコマンドウィンドウのカーソル位置で分岐
  1096.       case @actor_command_window.index
  1097.       when 0  # 攻撃
  1098. #==============================================================================
  1099. #RTAB观光游第二站,增加战斗快捷键ASD                      这段是官方增加的脚本
  1100. #==============================================================================        
  1101.         if victory?
  1102.           # ブザー SE を演奏
  1103.           $game_system.se_play($data_system.buzzer_se)
  1104.           return
  1105.         end
  1106. #==============================================================================        
  1107.         # 決定 SE を演奏
  1108.         $game_system.se_play($data_system.decision_se)
  1109.         # エネミーの選択を開始
  1110.         start_enemy_select
  1111.       when 1  # スキル
  1112.         # 決定 SE を演奏
  1113.         $game_system.se_play($data_system.decision_se)
  1114.         # スキルの選択を開始
  1115.         start_skill_select
  1116.       when 2  # 防御
  1117.         # 決定 SE を演奏
  1118.         $game_system.se_play($data_system.decision_se)
  1119.         # アクションを設定
  1120.         @active_actor.current_action.kind = 0
  1121.         @active_actor.current_action.basic = 1
  1122.         # 次のアクターのコマンド入力へ
  1123.         phase3_next_actor
  1124.       when 3  # アイテム
  1125.         # 決定 SE を演奏
  1126.         $game_system.se_play($data_system.decision_se)
  1127.         # アイテムの選択を開始
  1128.         start_item_select
  1129. #==============================================================================
  1130. #RTAB观光游第三站,战斗菜单增加逃跑选项
  1131. #==============================================================================
  1132.       when 4 #逃跑(添加内容)
  1133.         if $game_temp.battle_can_escape == false
  1134.           # ブザー SE を演奏
  1135.           $game_system.se_play($data_system.buzzer_se)
  1136.           return
  1137.        end
  1138.         # 決定 SE を演奏
  1139.         $game_system.se_play($data_system.decision_se)
  1140.        @phase = 0
  1141.         # パーティコマンドウィンドウを無効化
  1142.         @actor_command_window.active = false
  1143.         @actor_command_window.visible = false
  1144.         $game_temp.battle_main_phase = true
  1145.         if $game_temp.battle_turn == 0
  1146.           update_phase2_escape
  1147.          $game_temp.battle_turn = 1
  1148.          for battler in $game_party.actors
  1149.             battler.at -= @max / 2
  1150.           end
  1151.           return
  1152.        end
  1153.        # 決定 SE を演奏
  1154.         $game_system.se_play($data_system.decision_se)
  1155.         @escape = true
  1156.         for battler in $game_party.actors
  1157.           @command_a = false
  1158.           @command.delete(battler)
  1159.           @action_battlers.delete(battler)
  1160.           skill_reset(battler)
  1161.         end
  1162. #==============================================================================        
  1163.       end
  1164.       return
  1165.     end
  1166.     # キャラチェンジ
  1167.     if @command.size > 1
  1168.       # R ボタンが押された場合
  1169.       if Input.trigger?(Input::L)
  1170.         $game_system.se_play($data_system.cursor_se)
  1171. #------------------------------------------------------------------------------
  1172. #RTAB观光游第一站,去除“战斗/逃跑”选项部分        
  1173.        # @party = false
  1174. #------------------------------------------------------------------------------      
  1175.         # アクターの明滅エフェクト OFF
  1176.         if @active_actor != nil
  1177.           @active_actor.blink = false
  1178.         end
  1179.         @command.push(@command[0])
  1180.         @command.shift
  1181.         @command_a = false
  1182.         # 新たなコマンドウィンドウの立ち上げ
  1183.         start_phase3
  1184.       end
  1185.       # L ボタンが押された場合
  1186.       if Input.trigger?(Input::R)
  1187.         $game_system.se_play($data_system.cursor_se)
  1188. #------------------------------------------------------------------------------
  1189. #RTAB观光游第一站,去除“战斗/逃跑”选项部分      
  1190.      #   @party = false
  1191. #------------------------------------------------------------------------------      
  1192.         # アクターの明滅エフェクト OFF
  1193.         if @active_actor != nil
  1194.           @active_actor.blink = false
  1195.         end
  1196.         @command.unshift(@command[@command.size - 1])
  1197.         @command.delete_at(@command.size - 1)
  1198.         @command_a = false
  1199.         # 新たなコマンドウィンドウの立ち上げ
  1200.         start_phase3
  1201.       end
  1202.       # 右 ボタンが押された場合
  1203.       if Input.trigger?(Input::RIGHT)
  1204.         $game_system.se_play($data_system.cursor_se)
  1205. #------------------------------------------------------------------------------
  1206. #RTAB观光游第一站,去除“战斗/逃跑”选项部分        
  1207.    #     @party = false
  1208. #------------------------------------------------------------------------------      
  1209.         # アクターの明滅エフェクト OFF
  1210.         if @active_actor != nil
  1211.           @active_actor.blink = false
  1212.         end
  1213.         actor = $game_party.actors[@actor_index]
  1214.         while actor == @command[0] or (not @command.include?(actor))
  1215.           @actor_index += 1
  1216.           @actor_index %= $game_party.actors.size
  1217.           actor = $game_party.actors[@actor_index]
  1218.           if actor == @command[0]
  1219.             break
  1220.           end
  1221.         end
  1222.         while actor != @command[0]
  1223.           @command.push(@command.shift)
  1224.         end
  1225.         @command_a = false
  1226.         # 新たなコマンドウィンドウの立ち上げ
  1227.         start_phase3
  1228.       end
  1229.       # 左 ボタンが押された場合
  1230.       if Input.trigger?(Input::LEFT)
  1231.         $game_system.se_play($data_system.cursor_se)
  1232. #------------------------------------------------------------------------------
  1233. #RTAB观光游第一站,去除“战斗/逃跑”选项部分        
  1234.    #     @party = false
  1235. #------------------------------------------------------------------------------
  1236.         # アクターの明滅エフェクト OFF
  1237.         if @active_actor != nil
  1238.           @active_actor.blink = false
  1239.         end
  1240.         actor = $game_party.actors[@actor_index]
  1241.         while actor == @command[0] or (not @command.include?(actor))
  1242.           @actor_index -= 1
  1243.           @actor_index %= $game_party.actors.size
  1244.           actor = $game_party.actors[@actor_index]
  1245.           if actor == @command[0]
  1246.             break
  1247.           end
  1248.         end
  1249.         while actor != @command[0]
  1250.           @command.push(@command.shift)
  1251.         end
  1252.         @command_a = false
  1253.         # 新たなコマンドウィンドウの立ち上げ
  1254.         start_phase3
  1255.       end
  1256.     end
  1257.   end
  1258.   #--------------------------------------------------------------------------
  1259.   # ● フレーム更新 (アクターコマンドフェーズ : スキル選択)
  1260.   #--------------------------------------------------------------------------
  1261.   def update_phase3_skill_select
  1262.     # コマンド選択中に行動不能になった場合
  1263.     unless @active_actor.inputable?
  1264.       @active_actor.current_action.clear
  1265.       command_delete
  1266.       # 次のアクターのコマンド入力へ
  1267.       phase3_next_actor
  1268.       return
  1269.     end
  1270.     # スキルウィンドウを可視状態にする
  1271.     @skill_window.visible = true
  1272.     # スキルウィンドウを更新
  1273.     @skill_window.update
  1274.     # B ボタンが押された場合
  1275.     if Input.trigger?(Input::B)
  1276.       # キャンセル SE を演奏
  1277.       $game_system.se_play($data_system.cancel_se)
  1278.       # スキルの選択を終了
  1279.       end_skill_select
  1280.       return
  1281.     end
  1282.     # C ボタンが押された場合
  1283.     if Input.trigger?(Input::C)
  1284.       # スキルウィンドウで現在選択されているデータを取得
  1285.       @skill = @skill_window.skill
  1286.       # 使用できない場合
  1287.       if @skill == nil or not @active_actor.skill_can_use?(@skill.id)
  1288.         # ブザー SE を演奏
  1289.         $game_system.se_play($data_system.buzzer_se)
  1290.         return
  1291.       end
  1292.       # 決定 SE を演奏
  1293.       $game_system.se_play($data_system.decision_se)
  1294.       # アクションを設定
  1295.       @active_actor.current_action.skill_id = @skill.id
  1296.       # スキルウィンドウを不可視状態にする
  1297.       @skill_window.visible = false
  1298.       # 効果範囲が敵単体の場合
  1299.       if @skill.scope == 1
  1300.         # エネミーの選択を開始
  1301.         start_enemy_select
  1302.       # 効果範囲が味方単体の場合
  1303.       elsif @skill.scope == 3 or @skill.scope == 5
  1304.         # アクターの選択を開始
  1305.         start_actor_select
  1306.       # 効果範囲が単体ではない場合
  1307.       else
  1308.         # アクションを設定
  1309.         @active_actor.current_action.kind = 1
  1310.         # スキルの選択を終了
  1311.         end_skill_select
  1312.         # 次のアクターのコマンド入力へ
  1313.         phase3_next_actor
  1314.       end
  1315.       return
  1316.     end
  1317.   end
  1318.   #--------------------------------------------------------------------------
  1319.   # ● フレーム更新 (アクターコマンドフェーズ : アイテム選択)
  1320.   #--------------------------------------------------------------------------
  1321.   def update_phase3_item_select
  1322.     # コマンド選択中に行動不能になった場合
  1323.     unless @active_actor.inputable?
  1324.       @active_actor.current_action.clear
  1325.       command_delete
  1326.       # 次のアクターのコマンド入力へ
  1327.       phase3_next_actor
  1328.       return
  1329.     end
  1330.     # アイテムウィンドウを可視状態にする
  1331.     @item_window.visible = true
  1332.     # アイテムウィンドウを更新
  1333.     @item_window.update
  1334.     # B ボタンが押された場合
  1335.     if Input.trigger?(Input::B)
  1336.       # キャンセル SE を演奏
  1337.       $game_system.se_play($data_system.cancel_se)
  1338.       # アイテムの選択を終了
  1339.       end_item_select
  1340.       return
  1341.     end
  1342.     # C ボタンが押された場合
  1343.     if Input.trigger?(Input::C)
  1344.       # アイテムウィンドウで現在選択されているデータを取得
  1345.       @item = @item_window.item
  1346.       # 使用できない場合
  1347.       unless $game_party.item_can_use?(@item.id)
  1348.         # ブザー SE を演奏
  1349.         $game_system.se_play($data_system.buzzer_se)
  1350.         return
  1351.       end
  1352.       # 決定 SE を演奏
  1353.       $game_system.se_play($data_system.decision_se)
  1354.       # アクションを設定
  1355.       @active_actor.current_action.item_id = @item.id
  1356.       # アイテムウィンドウを不可視状態にする
  1357.       @item_window.visible = false
  1358.       # 効果範囲が敵単体の場合
  1359.       if @item.scope == 1
  1360.         # エネミーの選択を開始
  1361.         start_enemy_select
  1362.       # 効果範囲が味方単体の場合
  1363.       elsif @item.scope == 3 or @item.scope == 5
  1364.         # アクターの選択を開始
  1365.         start_actor_select
  1366.       # 効果範囲が単体ではない場合
  1367.       else
  1368.         # アクションを設定
  1369.         @active_actor.current_action.kind = 2
  1370.         # アイテムの選択を終了
  1371.         end_item_select
  1372.         # 次のアクターのコマンド入力へ
  1373.         phase3_next_actor
  1374.       end
  1375.       return
  1376.     end
  1377.   end
  1378.   #--------------------------------------------------------------------------
  1379.   # ● フレーム更新 (アクターコマンドフェーズ : エネミー選択)
  1380.   #--------------------------------------------------------------------------
  1381.   def update_phase3_enemy_select
  1382.     # コマンド選択中に行動不能になった場合
  1383.     unless @active_actor.inputable?
  1384.       # カメラを元に戻す
  1385.       if @camera == "select"
  1386.         @spriteset.screen_target(0, 0, 1)
  1387.       end
  1388.       @active_actor.current_action.clear
  1389.       command_delete
  1390.       # 次のアクターのコマンド入力へ
  1391.       phase3_next_actor
  1392.       return
  1393.     end
  1394.     # エネミーアローを更新
  1395.     @enemy_arrow.update
  1396.     # B ボタンが押された場合
  1397.     if Input.trigger?(Input::B)
  1398.       # キャンセル SE を演奏
  1399.       $game_system.se_play($data_system.cancel_se)
  1400.       # カメラを元に戻す
  1401.       if @camera == "select"
  1402.         # カメラの設定
  1403.         @camera = "command"
  1404.         plus = ($game_party.actors.size - 1) / 2.0 - @actor_index
  1405.         y = [(plus.abs - 1.5) * 10 , 0].min
  1406.         @spriteset.screen_target(plus * 50, y, 1.0 + y * 0.002)
  1407.       end
  1408.       # エネミーの選択を終了
  1409.       end_enemy_select
  1410.       return
  1411.     end
  1412.     # C ボタンが押された場合
  1413.     if Input.trigger?(Input::C)
  1414.       # 決定 SE を演奏
  1415.       $game_system.se_play($data_system.decision_se)
  1416.       # アクションを設定
  1417.       @active_actor.current_action.kind = 0
  1418.       @active_actor.current_action.basic = 0
  1419.       @active_actor.current_action.target_index = @enemy_arrow.index
  1420.       # スキルウィンドウ表示中の場合
  1421.       if @skill_window != nil
  1422.         # アクションを再設定
  1423.         @active_actor.current_action.kind = 1
  1424.         # スキルの選択を終了
  1425.         end_skill_select
  1426.       end
  1427.       # アイテムウィンドウ表示中の場合
  1428.       if @item_window != nil
  1429.         # アクションを再設定
  1430.         @active_actor.current_action.kind = 2
  1431.         # アイテムの選択を終了
  1432.         end_item_select
  1433.       end
  1434.       # エネミーの選択を終了
  1435.       end_enemy_select
  1436.       # 次のアクターのコマンド入力へ
  1437.       phase3_next_actor
  1438.     end
  1439.   end
  1440.   #--------------------------------------------------------------------------
  1441.   # ● フレーム更新 (アクターコマンドフェーズ : アクター選択)
  1442.   #--------------------------------------------------------------------------
  1443.   def update_phase3_actor_select
  1444.     # コマンド選択中に行動不能になった場合
  1445.     unless @active_actor.inputable?
  1446.       @active_actor.current_action.clear
  1447.       command_delete
  1448.       # 次のアクターのコマンド入力へ
  1449.       phase3_next_actor
  1450.       return
  1451.     end
  1452.     # アクターアローを更新
  1453.     @actor_arrow.update
  1454.     # B ボタンが押された場合
  1455.     if Input.trigger?(Input::B)
  1456.       # キャンセル SE を演奏
  1457.       $game_system.se_play($data_system.cancel_se)
  1458.       # アクターの選択を終了
  1459.       end_actor_select
  1460.       return
  1461.     end
  1462.     # C ボタンが押された場合
  1463.     if Input.trigger?(Input::C)
  1464.       # 決定 SE を演奏
  1465.       $game_system.se_play($data_system.decision_se)
  1466.       # アクションを設定
  1467.       @active_actor.current_action.kind = 0
  1468.       @active_actor.current_action.basic = 0
  1469.       @active_actor.current_action.target_index = @actor_arrow.index
  1470.       # アクターの選択を終了
  1471.       end_actor_select
  1472.       # スキルウィンドウ表示中の場合
  1473.       if @skill_window != nil
  1474.         # アクションを再設定
  1475.         @active_actor.current_action.kind = 1
  1476.         # スキルの選択を終了
  1477.         end_skill_select
  1478.       end
  1479.       # アイテムウィンドウ表示中の場合
  1480.       if @item_window != nil
  1481.         # アクションを再設定
  1482.         @active_actor.current_action.kind = 2
  1483.         # アイテムの選択を終了
  1484.         end_item_select
  1485.       end
  1486.       # 次のアクターのコマンド入力へ
  1487.       phase3_next_actor
  1488.     end
  1489.   end
  1490.   #--------------------------------------------------------------------------
  1491.   # ● エネミー選択開始
  1492.   #--------------------------------------------------------------------------
  1493.   alias :start_enemy_select_rtab :start_enemy_select
  1494.   def start_enemy_select
  1495.     @camera = "select"
  1496.     for enemy in $game_troop.enemies
  1497.       if enemy.exist?
  1498.         zoom = 1 / enemy.zoom
  1499.         @spriteset.screen_target(enemy.attack_x(zoom) * 0.75,
  1500.                                   enemy.attack_y(zoom) * 0.75, zoom)
  1501.         break
  1502.       end
  1503.     end
  1504.     # オリジナルの処理
  1505.     start_enemy_select_rtab
  1506.   end
  1507.   #--------------------------------------------------------------------------
  1508.   # ● エネミー選択終了
  1509.   #--------------------------------------------------------------------------
  1510.   alias :end_enemy_select_rtab :end_enemy_select
  1511.   def end_enemy_select
  1512.     # オリジナルの処理
  1513.     end_enemy_select_rtab
  1514.     if (@action == 0 and not @action_battlers.empty?) or
  1515.           (@camera == "select" and (@active_actor.current_action.kind != 0 or
  1516.                                             @active_actor.animation1_id != 0))
  1517.       @spriteset.screen_target(0, 0, 1)
  1518.     end
  1519.   end
  1520.   #--------------------------------------------------------------------------
  1521.   # ● スキル選択開始
  1522.   #--------------------------------------------------------------------------
  1523.   def start_skill_select
  1524.     # スキルウィンドウを作成
  1525.     @skill_window = Window_Skill.new(@active_actor)
  1526.     # ヘルプウィンドウを関連付け
  1527.     @skill_window.help_window = @help_window
  1528.     # アクターコマンドウィンドウを無効化
  1529.     @actor_command_window.active = false
  1530.     @actor_command_window.visible = false
  1531.   end

  1532. #==============================================================================
  1533. # ■ Scene_Battle (分割定義 4)
  1534. #------------------------------------------------------------------------------
  1535. #  バトル画面の処理を行うクラスです。
  1536. #==============================================================================

  1537.   #--------------------------------------------------------------------------
  1538.   # ● メインフェーズ開始
  1539.   #--------------------------------------------------------------------------
  1540.   def start_phase4
  1541.     $game_temp.battle_main_phase = true
  1542.   end
  1543.   #--------------------------------------------------------------------------
  1544.   # ● フレーム更新 (メインフェーズ)
  1545.   #--------------------------------------------------------------------------
  1546.   def update_phase4
  1547.     # アクションを強制されているバトラーが存在する場合
  1548.     if $game_temp.forcing_battler != nil
  1549.       battler = $game_temp.forcing_battler
  1550.       if battler.current_action.forcing == false
  1551.         if @action_battlers.include?(battler)
  1552.           if @action > 0 or @action_battlers[0].phase == 1
  1553.             @action_battlers.delete(battler)
  1554.             @action_battlers.push(battler)
  1555.           end
  1556.           if battler.phase == 1
  1557.             battler.current_action.forcing = true
  1558.             force_action(battler)
  1559.           end
  1560.         else
  1561.           battler.current_action.forcing = true
  1562.           force_action(battler)
  1563.           action_start(battler)
  1564.           @action_battlers.delete(battler)
  1565.           @action_battlers.push(battler)
  1566.         end
  1567.         battler.at = @max
  1568.         battler.atp = 100 * battler.at / @max
  1569.       end
  1570.     end
  1571.     # action が1以上の場合、一斉に行動を起こす
  1572.     for battler in @action_battlers.reverse
  1573.       # ウェイト中の場合
  1574.       if battler.wait > 0
  1575.         # ウェイトカウントを減らす
  1576.         battler.wait -= 1
  1577.         break if @action == 0
  1578.         next
  1579.       end
  1580.       unless fin? and battler.phase < 3 and
  1581.           not $game_system.battle_interpreter.running?
  1582.         action_phase(battler)
  1583.       end
  1584.       break if @action == 0
  1585.     end
  1586.     # アクションを強制されているバトラーが存在しない場合
  1587.     if $game_temp.forcing_battler == nil
  1588.       # バトルイベントをセットアップ
  1589.       setup_battle_event
  1590.       # バトルイベント実行中の場合
  1591.       if $game_system.battle_interpreter.running?
  1592.         return
  1593.       end
  1594.     end
  1595.     # 勝敗を決した際の処理
  1596.     if fin?
  1597.       # 敗北時、指定時間ウェイト
  1598.       if $game_party.all_dead? and @after_wait[0] > 0
  1599.         @after_wait[0] -= 1
  1600.         return
  1601.       end
  1602.       # 勝利時、指定時間ウェイト
  1603.       if victory? and @after_wait[1] > 0
  1604.         @after_wait[1] -= 1
  1605.         return
  1606.       end
  1607.       # 戦闘が終了し、かつアクターが行動直前の場合はアクターの行動を消去
  1608.       for battler in @action_battlers.reverse
  1609.         if battler.phase < 3 and not $game_system.battle_interpreter.running?
  1610.           @action_battlers.delete(battler)
  1611.         end
  1612.       end
  1613.       # 勝敗判定
  1614.       if @action_battlers.empty? and
  1615.           not $game_system.battle_interpreter.running?
  1616.         judge
  1617.       end
  1618.     end
  1619.   end
  1620.   #--------------------------------------------------------------------------
  1621.   # ● アクション更新 (メインフェーズ)
  1622.   #--------------------------------------------------------------------------
  1623.   def action_phase(battler)
  1624.     # action が 1 の場合、バトラーが行動中かどうか確認
  1625.     if @action == 1 and battler.phase <= 3
  1626.       for target in battler.target
  1627.         speller = synthe?(target)
  1628.         if speller == nil
  1629.           # ターゲットが通常行動中の場合
  1630.           if @action_battlers.include?(target)
  1631.             if target.phase > 2
  1632.               return
  1633.             end
  1634.           end
  1635.         else
  1636.           # ターゲットが連携スキル発動中の場合
  1637.           for spell in speller
  1638.             if @action_battlers.include?(spell)
  1639.               if spell.phase > 2
  1640.                 return
  1641.               end
  1642.             end
  1643.           end
  1644.         end
  1645.       end
  1646.     end
  1647.     case battler.phase
  1648.     when 1
  1649.       update_phase4_step1(battler)
  1650.     when 2
  1651.       update_phase4_step2(battler)
  1652.     when 3
  1653.       update_phase4_step3(battler)
  1654.     when 4
  1655.       update_phase4_step4(battler)
  1656.     when 5
  1657.       update_phase4_step5(battler)
  1658.     when 6
  1659.       update_phase4_step6(battler)
  1660.     end
  1661.   end
  1662.   #--------------------------------------------------------------------------
  1663.   # ● フレーム更新 (メインフェーズ ステップ 1 : アクション準備)
  1664.   #--------------------------------------------------------------------------
  1665.   def update_phase4_step1(battler)
  1666.     # すでに戦闘から外されている場合
  1667.     if battler.index == nil
  1668.       @action_battlers.delete(battler)
  1669.       anime_wait_return
  1670.       return
  1671.     end
  1672.     speller = synthe?(battler)
  1673.     if speller == nil
  1674.       # ダメージ食らい中の場合
  1675.       unless battler.damage.empty? or @action > 2
  1676.         return
  1677.       end
  1678.       # 行動可能かどうか判定
  1679.       unless battler.movable?
  1680.         battler.phase = 6
  1681.         return
  1682.       end
  1683.     else
  1684.       # ダメージ食らい中の場合
  1685.       for spell in speller
  1686.         unless spell.damage.empty? or @action > 2
  1687.           return
  1688.         end
  1689.         # 行動可能かどうか判定
  1690.         unless spell.movable?
  1691.           battler.phase = 6
  1692.           return
  1693.         end
  1694.       end
  1695.     end
  1696.     # スキル使用時、詠唱時間設定
  1697.     # 強制アクションかつ @force が 2 の時はスキルを即時発動
  1698.     if battler.current_action.kind == 1 and
  1699.       (not battler.current_action.forcing or @force != 2)
  1700.       if battler.rtp == 0
  1701.         # スキル詠唱中ならば、解除
  1702.         skill_reset(battler)
  1703.         # スキル詠唱時間設定
  1704.         recite_time(battler)
  1705.         # 連携技設定
  1706.         synthe_spell(battler)
  1707.         # スキルを詠唱する場合
  1708.         if battler.rtp > 0
  1709.           # 強制アクションかつ @force が 1 の時は連携スキルのみ即時発動
  1710.           speller = synthe?(battler)
  1711.           if battler.current_action.forcing and @force > 0 and speller != nil
  1712.             for spell in speller
  1713.               spell.rt = spell.rtp
  1714.             end
  1715.           else
  1716.             battler.blink = true
  1717.             if battler.current_action.forcing
  1718.               $game_temp.forcing_battler = nil
  1719.               battler.current_action.forcing = false
  1720.             end
  1721.             @action_battlers.delete(battler)
  1722.             return
  1723.           end
  1724.         end
  1725.       end
  1726.     end
  1727.     # アクターの明滅エフェクト OFF
  1728.     if battler != nil
  1729.       battler.blink = false
  1730.     end
  1731.     speller = synthe?(battler)
  1732.     if speller == nil
  1733.       @spell_p.delete(battler)
  1734.       @spell_e.delete(battler)
  1735.     else
  1736.       for spell in speller
  1737.         spell.blink = false
  1738.         @spell_p.delete(spell)
  1739.         @spell_e.delete(spell)
  1740.       end
  1741.     end
  1742.     # ステップ 2 に移行
  1743.     battler.phase = 2
  1744.   end
  1745.   #--------------------------------------------------------------------------
  1746.   # ● フレーム更新 (メインフェーズ ステップ 2 : アクション開始)
  1747.   #--------------------------------------------------------------------------
  1748.   def update_phase4_step2(battler)
  1749.     # 強制アクションでなければ
  1750.     unless battler.current_action.forcing
  1751.       # 制約が [敵を通常攻撃する] か [味方を通常攻撃する] の場合
  1752.       if battler.restriction == 2 or battler.restriction == 3
  1753.         # アクションに攻撃を設定
  1754.         battler.current_action.kind = 0
  1755.         battler.current_action.basic = 0
  1756.       end
  1757.     end
  1758.     # アクションの種別で分岐
  1759.     case battler.current_action.kind
  1760.     when 0  # 基本
  1761.       if fin?
  1762.         battler.phase = 6
  1763.         return
  1764.       end
  1765.       make_basic_action_result(battler)
  1766.     when 1  # スキル
  1767.       if fin? and $data_skills[battler.current_action.skill_id].scope == 1..2
  1768.         battler.phase = 6
  1769.         return
  1770.       end
  1771.       make_skill_action_result(battler)
  1772.     when 2  # アイテム
  1773.       if fin? and $data_items[battler.current_action.item_id].scope == 1..2
  1774.         battler.phase = 6
  1775.         return
  1776.       end
  1777.       make_item_action_result(battler)
  1778.     end
  1779.     if battler.phase == 2
  1780.       # ステップ 3 に移行
  1781.       battler.phase = 3
  1782.     end
  1783.   end
  1784.   #--------------------------------------------------------------------------
  1785.   # ● 基本アクション 結果作成
  1786.   #--------------------------------------------------------------------------
  1787.   def make_basic_action_result(battler)
  1788.     # 攻撃の場合
  1789.     if battler.current_action.basic == 0
  1790.       # アニメーション ID を設定
  1791.       battler.anime1 = battler.animation1_id
  1792.       battler.anime2 = battler.animation2_id
  1793.       # 行動側バトラーがエネミーの場合
  1794.       if battler.is_a?(Game_Enemy)
  1795.         if battler.restriction == 3
  1796.           target = $game_troop.random_target_enemy
  1797.         elsif battler.restriction == 2
  1798.           target = $game_party.random_target_actor
  1799.         else
  1800.           index = battler.current_action.target_index
  1801.           target = $game_party.smooth_target_actor(index)
  1802.         end
  1803.       end
  1804.       # 行動側バトラーがアクターの場合
  1805.       if battler.is_a?(Game_Actor)
  1806.         if battler.restriction == 3
  1807.           target = $game_party.random_target_actor
  1808.         elsif battler.restriction == 2
  1809.           target = $game_troop.random_target_enemy
  1810.         else
  1811.           index = battler.current_action.target_index
  1812.           target = $game_troop.smooth_target_enemy(index)
  1813.         end
  1814.       end
  1815.       # 対象側バトラーの配列を設定
  1816.       battler.target = [target]
  1817.       # 通常攻撃の効果を適用
  1818.       for target in battler.target
  1819.         target.attack_effect(battler)
  1820.       end
  1821.       return
  1822.     end
  1823.     # 防御の場合
  1824.     if battler.current_action.basic == 1
  1825.       return
  1826.     end
  1827.     # 逃げるの場合
  1828. #    if battler.is_a?(Game_Enemy) and battler.current_action.basic == 2
  1829.       # 逃げる
  1830. #      @help_window.set_text("逃げる", 1)
  1831. #      @help_wait = @help_time
  1832. #      battler.escape
  1833. #      return
  1834. #    end
  1835. #========RTAB 1.16=====================================================   
  1836.     # 逃げるの場合
  1837.     if battler.is_a?(Game_Enemy) and battler.current_action.basic == 2
  1838.       return
  1839.     end
  1840. #======================================================================
  1841.     # 何もしないの場合
  1842.     if battler.current_action.basic == 3
  1843.       # ステップ 6 に移行
  1844.       battler.phase = 6
  1845.       return
  1846.     end
  1847.   end
  1848.   #--------------------------------------------------------------------------
  1849.   # ● スキルまたはアイテムの対象側バトラー設定
  1850.   #     scope : スキルまたはアイテムの効果範囲
  1851.   #--------------------------------------------------------------------------
  1852.   def set_target_battlers(scope, battler)
  1853.     # 行動側バトラーがエネミーの場合
  1854.     if battler.is_a?(Game_Enemy)
  1855.       # 効果範囲で分岐
  1856.       case scope
  1857.       when 1  # 敵単体
  1858.         index =battler.current_action.target_index
  1859.         battler.target.push($game_party.smooth_target_actor(index))
  1860.       when 2  # 敵全体
  1861.         for actor in $game_party.actors
  1862.           if actor.exist?
  1863.             battler.target.push(actor)
  1864.           end
  1865.         end
  1866.       when 3  # 味方単体
  1867.         index = battler.current_action.target_index
  1868.         battler.target.push($game_troop.smooth_target_enemy(index))
  1869.       when 4  # 味方全体
  1870.         for enemy in $game_troop.enemies
  1871.           if enemy.exist?
  1872.             battler.target.push(enemy)
  1873.           end
  1874.         end
  1875.       when 5  # 味方単体 (HP 0)
  1876.         index = battler.current_action.target_index
  1877.         enemy = $game_troop.enemies[index]
  1878.         if enemy != nil and enemy.hp0?
  1879.           battler.target.push(enemy)
  1880.         end
  1881.       when 6  # 味方全体 (HP 0)
  1882.         for enemy in $game_troop.enemies
  1883.           if enemy != nil and enemy.hp0?
  1884.             battler.target.push(enemy)
  1885.           end
  1886.         end
  1887.       when 7  # 使用者
  1888.         battler.target.push(battler)
  1889.       end
  1890.     end
  1891.     # 行動側バトラーがアクターの場合
  1892.     if battler.is_a?(Game_Actor)
  1893.       # 効果範囲で分岐
  1894.       case scope
  1895.       when 1  # 敵単体
  1896.         index = battler.current_action.target_index
  1897.         battler.target.push($game_troop.smooth_target_enemy(index))
  1898.       when 2  # 敵全体
  1899.         for enemy in $game_troop.enemies
  1900.           if enemy.exist?
  1901.             battler.target.push(enemy)
  1902.           end
  1903.         end
  1904.       when 3  # 味方単体
  1905.         index = battler.current_action.target_index
  1906.         battler.target.push($game_party.smooth_target_actor(index))
  1907.       when 4  # 味方全体
  1908.         for actor in $game_party.actors
  1909.           if actor.exist?
  1910.             battler.target.push(actor)
  1911.           end
  1912.         end
  1913.       when 5  # 味方単体 (HP 0)
  1914.         index = battler.current_action.target_index
  1915.         actor = $game_party.actors[index]
  1916.         if actor != nil and actor.hp0?
  1917.           battler.target.push(actor)
  1918.         end
  1919.       when 6  # 味方全体 (HP 0)
  1920.         for actor in $game_party.actors
  1921.           if actor != nil and actor.hp0?
  1922.             battler.target.push(actor)
  1923.           end
  1924.         end
  1925.       when 7  # 使用者
  1926.         battler.target.push(battler)
  1927.       end
  1928.     end
  1929.   end
  1930.   #--------------------------------------------------------------------------
  1931.   # ● スキルアクション 結果作成
  1932.   #--------------------------------------------------------------------------
  1933.   def make_skill_action_result(battler)
  1934.     # スキルを取得
  1935.     @skill = $data_skills[battler.current_action.skill_id]
  1936.     # 連携スキルであるかどうか確認
  1937.     speller = synthe?(battler)
  1938.     # 強制アクションでなければ
  1939.     unless battler.current_action.forcing
  1940.       # SP 切れなどで使用できなくなった場合
  1941.       if speller == nil
  1942.         unless battler.skill_can_use?(@skill.id)
  1943.           # ステップ 6 に移行
  1944.           battler.phase = 6
  1945.          return
  1946.         end
  1947.       end
  1948.     end
  1949.     # SP 消費
  1950.     temp = false
  1951.     if speller != nil
  1952.       for spell in speller
  1953.         if spell.current_action.spell_id == 0
  1954.           spell.sp -= @skill.sp_cost
  1955.         else
  1956.           spell.sp -= $data_skills[spell.current_action.spell_id].sp_cost
  1957.         end
  1958.         # ステータスウィンドウをリフレッシュ
  1959.         status_refresh(spell)
  1960.       end
  1961.     else
  1962.       battler.sp -= @skill.sp_cost
  1963.       # ステータスウィンドウをリフレッシュ
  1964.       status_refresh(battler)
  1965.     end
  1966.     # アニメーション ID を設定
  1967.     battler.anime1 = @skill.animation1_id
  1968.     battler.anime2 = @skill.animation2_id
  1969.     # コモンイベント ID を設定
  1970.     battler.event = @skill.common_event_id
  1971.     # 対象側バトラーを設定
  1972.     set_target_battlers(@skill.scope, battler)
  1973.     # スキルの効果を適用
  1974.     for target in battler.target
  1975.       if speller != nil
  1976.         damage = 0
  1977.         d_result = false
  1978.         effective = false
  1979.         state_p = []
  1980.         state_m = []
  1981.         for spell in speller
  1982.           if spell.current_action.spell_id != 0
  1983.             @skill = $data_skills[spell.current_action.spell_id]
  1984.           end
  1985.           effective |= target.skill_effect(spell, @skill)
  1986.           if target.damage[spell].class != String
  1987.             d_result = true
  1988.             damage += target.damage[spell]
  1989.           elsif effective
  1990.             effect = target.damage[spell]
  1991.           end
  1992.           state_p += target.state_p[spell]
  1993.           state_m += target.state_m[spell]
  1994.           target.damage.delete(spell)
  1995.           target.state_p.delete(spell)
  1996.           target.state_m.delete(spell)
  1997.         end
  1998.         if d_result
  1999.           target.damage[battler] = damage
  2000.         elsif effective
  2001.           target.damage[battler] = effect
  2002.         else
  2003.           target.damage[battler] = 0
  2004.         end
  2005.         target.state_p[battler] = state_p
  2006.         target.state_m[battler] = state_m
  2007.       else
  2008.         target.skill_effect(battler, @skill)
  2009.       end
  2010.     end
  2011.   end
  2012.   #--------------------------------------------------------------------------
  2013.   # ● アイテムアクション 結果作成
  2014.   #--------------------------------------------------------------------------
  2015.   def make_item_action_result(battler)
  2016.     # アイテムを取得
  2017.     @item = $data_items[battler.current_action.item_id]
  2018.     # アイテム切れなどで使用できなくなった場合
  2019.     unless $game_party.item_can_use?(@item.id)
  2020.       # ステップ 6 に移行
  2021.       battler.phase = 6
  2022.       return
  2023.     end
  2024.     # 消耗品の場合
  2025.     if @item.consumable
  2026.       # 使用したアイテムを 1 減らす
  2027.       $game_party.lose_item(@item.id, 1)
  2028.     end
  2029.     # アニメーション ID を設定
  2030.     battler.anime1 = @item.animation1_id
  2031.     battler.anime2 = @item.animation2_id
  2032.     # コモンイベント ID を設定
  2033.     battler.event = @item.common_event_id
  2034.     # 対象を決定
  2035.     index = battler.current_action.target_index
  2036.     target = $game_party.smooth_target_actor(index)
  2037.     # 対象側バトラーを設定
  2038.     set_target_battlers(@item.scope, battler)
  2039.     # アイテムの効果を適用
  2040.     for target in battler.target
  2041.       target.item_effect(@item, battler)
  2042.     end
  2043.   end
  2044.   #--------------------------------------------------------------------------
  2045.   # ● フレーム更新 (メインフェーズ ステップ 3 : 行動側アニメーション)
  2046.   #--------------------------------------------------------------------------
  2047.   def update_phase4_step3(battler)
  2048.     # ヘルプウィンドウの更新。アクションの種別で分岐
  2049.     case battler.current_action.kind
  2050.     when 0  # 基本
  2051.       if battler.current_action.basic == 1
  2052.         @help_window.set_text($data_system.words.guard, 1)
  2053.         @help_wait = @help_time
  2054.       end
  2055. #========RTAB 1.16==================================      
  2056.       if battler.current_action.basic == 2
  2057.         # 逃げる
  2058.         @help_window.set_text("逃げる", 1)
  2059.         @help_wait = @help_time
  2060.         battler.escape
  2061.         battler.phase = 4
  2062.         return
  2063.       end
  2064. #===================================================        
  2065.     when 1  # スキル
  2066.       skill =  $data_skills[battler.current_action.skill_id]
  2067.       @help_window.set_text(skill.name, 1)
  2068.       @help_wait = @help_time
  2069.     when 2  # アイテム
  2070.       item = $data_items[battler.current_action.item_id]
  2071.       @help_window.set_text(item.name, 1)
  2072.       @help_wait = @help_time
  2073.     end
  2074.     # 行動側アニメーション (ID が 0 の場合は白フラッシュ)
  2075.     if battler.anime1 == 0
  2076.       battler.white_flash = true
  2077.       battler.wait = 5
  2078.       # カメラ設定
  2079.       if battler.target[0].is_a?(Game_Enemy)
  2080.         camera_set(battler)
  2081.       end
  2082.     else
  2083.       battler.animation.push([battler.anime1, true])
  2084.       speller = synthe?(battler)
  2085.       if speller != nil
  2086.         for spell in speller
  2087.           if spell != battler
  2088.             if spell.current_action.spell_id == 0
  2089.               spell.animation.push([battler.anime1, true])
  2090.             else
  2091.               skill = spell.current_action.spell_id
  2092.               spell.animation.push([$data_skills[skill].animation1_id, true])
  2093.               spell.current_action.spell_id = 0
  2094.             end
  2095.           end
  2096.         end
  2097.       end
  2098.       battler.wait = 2 * $data_animations[battler.anime1].frame_max - 10
  2099.     end
  2100.     # ステップ 4 に移行
  2101.     battler.phase = 4
  2102.   end
  2103.   #--------------------------------------------------------------------------
  2104.   # ● フレーム更新 (メインフェーズ ステップ 4 : 対象側アニメーション)
  2105.   #--------------------------------------------------------------------------
  2106.   def update_phase4_step4(battler)
  2107.     # カメラ設定
  2108.     if battler.target[0].is_a?(Game_Enemy) and battler.anime1 != 0
  2109.        camera_set(battler)
  2110.     end
  2111.     # 対象側アニメーション
  2112.     for target in battler.target
  2113.       target.animation.push([battler.anime2,
  2114.                                           (target.damage[battler] != "Miss")])
  2115.       unless battler.anime2 == 0
  2116.         battler.wait = 2 * $data_animations[battler.anime2].frame_max - 10
  2117.       end
  2118.     end
  2119.     # ステップ 5 に移行
  2120.     battler.phase = 5
  2121.   end
  2122.   #--------------------------------------------------------------------------
  2123.   # ● フレーム更新 (メインフェーズ ステップ 5 : ダメージ表示)
  2124.   #--------------------------------------------------------------------------
  2125.   def update_phase4_step5(battler)
  2126.     # ダメージ表示
  2127.     for target in battler.target
  2128.       if target.damage[battler] != nil
  2129.         target.damage_pop[battler] = true
  2130.         target.damage_effect(battler, battler.current_action.kind)
  2131.         battler.wait = @damage_wait
  2132.         # ステータスウィンドウをリフレッシュ
  2133.         status_refresh(target)
  2134.       end
  2135.     end
  2136.     # ステップ 6 に移行
  2137.     battler.phase = 6
  2138.   end
  2139.   #--------------------------------------------------------------------------
  2140.   # ● フレーム更新 (メインフェーズ ステップ 6 : リフレッシュ)
  2141.   #--------------------------------------------------------------------------
  2142.   def update_phase4_step6(battler)
  2143.     # カメラを戻す
  2144.     if battler.target[0].is_a?(Game_Enemy) and @camera == battler
  2145.       @spriteset.screen_target(0, 0, 1)
  2146.     end
  2147.     # スキルラーニング
  2148.     if battler.target[0].is_a?(Game_Actor) and battler.current_action.kind == 1
  2149.       for target in battler.target
  2150.         skill_learning(target, target.class_id,
  2151.                         battler.current_action.skill_id)
  2152.       end
  2153.     end
  2154.     # アクション強制対象のバトラーをクリア
  2155.     if battler.current_action.forcing == true and
  2156.         battler.current_action.force_kind == 0 and
  2157.         battler.current_action.force_basic == 0 and
  2158.         battler.current_action.force_skill_id == 0
  2159.       $game_temp.forcing_battler = nil
  2160.       battler.current_action.forcing = false
  2161.     end
  2162.     refresh_phase(battler)
  2163.     speller = synthe?(battler)
  2164.     if speller != nil
  2165.       for spell in speller
  2166.         if spell != battler
  2167.           refresh_phase(spell)
  2168.         end
  2169.       end
  2170.       synthe_delete(speller)
  2171.     end
  2172.     # コモンイベント ID が有効の場合
  2173.     if battler.event > 0
  2174.       # イベントをセットアップ
  2175.       common_event = $data_common_events[battler.event]
  2176.       $game_system.battle_interpreter.setup(common_event.list, 0)
  2177.     end
  2178.     act = 0
  2179.     for actor in $game_party.actors + $game_troop.enemies
  2180.       if actor.movable?
  2181.         act += 1
  2182.       end
  2183.     end
  2184.     if @turn_cnt >= act and act > 0
  2185.       @turn_cnt %= act
  2186.       $game_temp.battle_turn += 1
  2187.       # バトルイベントの全ページを検索
  2188.       for index in 0...$data_troops[@troop_id].pages.size
  2189.         # イベントページを取得
  2190.         page = $data_troops[@troop_id].pages[index]
  2191.         # このページのスパンが [ターン] の場合
  2192.         if page.span == 1
  2193.           # 実行済みフラグをクリア
  2194.           $game_temp.battle_event_flags[index] = false
  2195.         end
  2196.       end
  2197.     end
  2198.     battler.phase = 1
  2199.     @action_battlers.delete(battler)
  2200.   end
  2201.   #--------------------------------------------------------------------------
  2202.   # ● リフレッシュ
  2203.   #--------------------------------------------------------------------------
  2204.   def refresh_phase(battler)
  2205.     battler.at -= @max
  2206.     if battler.movable?
  2207.       battler.atp = 100 * battler.at / @max
  2208.     end
  2209.     spell_reset(battler)
  2210.     # スリップダメージ
  2211.     if battler.hp > 0 and battler.slip_damage?
  2212.       battler.slip_damage_effect
  2213.       battler.damage_pop["slip"] = true
  2214.     end
  2215.     # ステート自然解除
  2216.     battler.remove_states_auto
  2217.     # ステータスウィンドウをリフレッシュ
  2218.     status_refresh(battler, true)
  2219.     unless battler.movable?
  2220.       return
  2221.     end
  2222.     # ターン数カウント
  2223.     @turn_cnt += 1
  2224.   end
  2225.   #--------------------------------------------------------------------------
  2226.   # ● バトラーアクションスタート
  2227.   #--------------------------------------------------------------------------
  2228.   def action_start(battler)
  2229.     battler.phase = 1
  2230.     battler.anime1 = 0
  2231.     battler.anime2 = 0
  2232.     battler.target = []
  2233.     battler.event = 0
  2234.     @action_battlers.unshift(battler)
  2235.   end
  2236.   #--------------------------------------------------------------------------
  2237.   # ● ステータスウィンドウをリフレッシュ
  2238.   #--------------------------------------------------------------------------
  2239.   def status_refresh(battler, at = false)
  2240.     if battler.is_a?(Game_Actor)
  2241.       for i in 0...$game_party.actors.size
  2242.         if battler == $game_party.actors[i]
  2243.           number = i + 1
  2244.         end
  2245.       end
  2246.       @status_window.refresh(number)
  2247.       if at == true
  2248.         @status_window.at_refresh(number)
  2249.       end
  2250.     end
  2251.   end
  2252.   #--------------------------------------------------------------------------
  2253.   # ● アニメウェイト判断処理
  2254.   #--------------------------------------------------------------------------
  2255.   def anime_wait_return
  2256.     if (@action_battlers.empty? or @anime_wait == false) and
  2257.         not $game_system.battle_interpreter.running?
  2258.       # エネミーアローが有効の場合
  2259.       if @enemy_arrow != nil
  2260.         return [@active - 2, 0].min == 0
  2261.       # アクターアローが有効の場合
  2262.       elsif @actor_arrow != nil
  2263.         return [@active - 2, 0].min == 0
  2264.       # スキルウィンドウが有効の場合
  2265.       elsif @skill_window != nil
  2266.         return [@active - 3, 0].min == 0
  2267.       # アイテムウィンドウが有効の場合
  2268.       elsif @item_window != nil
  2269.         return [@active - 3, 0].min == 0
  2270.       # アクターコマンドウィンドウが有効の場合
  2271.       elsif @actor_command_window.active
  2272.         return [@active - 1, 0].min == 0
  2273.       else
  2274.         return true
  2275.       end
  2276.     else
  2277.       return false
  2278.     end
  2279.   end
  2280.   #--------------------------------------------------------------------------
  2281.   # ● アクターコマンド消去判断
  2282.   #--------------------------------------------------------------------------
  2283.   def command_delete
  2284.     # エネミーアローが有効の場合
  2285.     if @enemy_arrow != nil
  2286.       end_enemy_select
  2287.     # アクターアローが有効の場合
  2288.     elsif @actor_arrow != nil
  2289.       end_actor_select
  2290.     end
  2291.     # スキルウィンドウが有効の場合
  2292.     if @skill_window != nil
  2293.       end_skill_select
  2294.     # アイテムウィンドウが有効の場合
  2295.     elsif @item_window != nil
  2296.       end_item_select
  2297.     end
  2298.     # アクターコマンドウィンドウが有効の場合
  2299.     if @actor_command_window.active
  2300.       @command.shift
  2301.       @command_a = false
  2302.       # メインフェーズフラグをセット
  2303.       $game_temp.battle_main_phase = true
  2304.       # アクターコマンドウィンドウを無効化
  2305.       @actor_command_window.active = false
  2306.       @actor_command_window.visible = false
  2307.       # アクターの明滅エフェクト OFF
  2308.       if @active_actor != nil
  2309.         @active_actor.blink = false
  2310.       end
  2311.     end
  2312.   end
  2313.   #--------------------------------------------------------------------------
  2314.   # ● 強制アクション設定
  2315.   #--------------------------------------------------------------------------
  2316.   def force_action(battler)
  2317.     battler.current_action.kind = battler.current_action.force_kind
  2318.     battler.current_action.basic = battler.current_action.force_basic
  2319.     battler.current_action.skill_id = battler.current_action.force_skill_id
  2320.     battler.current_action.force_kind = 0
  2321.     battler.current_action.force_basic = 0
  2322.     battler.current_action.force_skill_id = 0
  2323.   end
  2324.   #--------------------------------------------------------------------------
  2325.   # ● カメラセット
  2326.   #--------------------------------------------------------------------------
  2327.   def camera_set(battler)
  2328.     @camera = battler
  2329.     if battler.target.size == 1
  2330.       if battler.current_action.kind == 0
  2331.         zoom = 1.2 / battler.target[0].zoom
  2332.       elsif synthe?(battler) == nil
  2333.         zoom = 1.5 / battler.target[0].zoom
  2334.       else
  2335.         zoom = 2.0 / battler.target[0].zoom
  2336.       end
  2337.       @spriteset.screen_target(battler.target[0].attack_x(zoom),
  2338.                                 battler.target[0].attack_y(zoom), zoom)
  2339.     else
  2340.       @spriteset.screen_target(0, 0, 0.75)
  2341.     end
  2342.   end
  2343.   #--------------------------------------------------------------------------
  2344.   # ● スキル詠唱タイム作成
  2345.   #--------------------------------------------------------------------------
  2346.   def recite_time(battler)
  2347.   end
  2348.   #--------------------------------------------------------------------------
  2349.   # ● 連携スキル判別
  2350.   #--------------------------------------------------------------------------
  2351.   def synthe_spell(battler)
  2352.   end
  2353.   #--------------------------------------------------------------------------
  2354.   # ● スキルラーニングシステム
  2355.   #--------------------------------------------------------------------------
  2356.   def skill_learning(actor, class_id, skill_id)
  2357.   end
  2358.   #--------------------------------------------------------------------------
  2359.   # ● 行動可能判定
  2360.   #--------------------------------------------------------------------------
  2361.   def active?(battler)
  2362.     speller = synthe?(battler)
  2363.     if speller != nil
  2364.       if synthe_delete?(speller)
  2365.         return false
  2366.       end
  2367.     else
  2368.       unless battler.inputable?
  2369.         spell_reset(battler)
  2370.         unless battler.movable?
  2371.           battler.atp = 0
  2372.           return false
  2373.         end
  2374.       end
  2375.       if battler.current_action.forcing
  2376.         spell_reset(battler)
  2377.       end
  2378.     end
  2379.     return true
  2380.   end
  2381.   #--------------------------------------------------------------------------
  2382.   # ● 合成スキル詠唱中か?
  2383.   #--------------------------------------------------------------------------
  2384.   def synthe?(battler)
  2385.     for speller in @synthe
  2386.       if speller.include?(battler)
  2387.         return speller
  2388.       end
  2389.     end
  2390.     return nil
  2391.   end
  2392.   #--------------------------------------------------------------------------
  2393.   # ● 合成スキル消去判断
  2394.   #--------------------------------------------------------------------------
  2395.   def synthe_delete?(speller)
  2396.     for battler in speller
  2397.       if not battler.inputable? and dead_ok?(battler)
  2398.         synthe_delete(speller)
  2399.         return true
  2400.       end
  2401.     end
  2402.     return false
  2403.   end
  2404.   #--------------------------------------------------------------------------
  2405.   # ● 合成スキル消去
  2406.   #--------------------------------------------------------------------------
  2407.   def synthe_delete(speller)
  2408.     for battler in speller
  2409.       spell_reset(battler)
  2410.       if dead_ok?(battler)
  2411.         @action_battlers.delete(battler)
  2412.       end
  2413.     end
  2414.     @synthe.delete(speller)
  2415.   end
  2416.   #--------------------------------------------------------------------------
  2417.   # ● 連携含むスキル詠唱解除
  2418.   #--------------------------------------------------------------------------
  2419.   def skill_reset(battler)
  2420.     speller = synthe?(battler)
  2421.     if speller != nil
  2422.       synthe_delete(speller)
  2423.     else
  2424.       spell_reset(battler)
  2425.     end
  2426.   end
  2427.   #--------------------------------------------------------------------------
  2428.   # ● スキル詠唱解除
  2429.   #--------------------------------------------------------------------------
  2430.   def spell_reset(battler)
  2431.     battler.rt = 0
  2432.     battler.rtp = 0
  2433.     battler.blink = false
  2434.     battler.spell = false
  2435.     battler.current_action.spell_id = 0
  2436.     @spell_p.delete(battler)
  2437.     @spell_e.delete(battler)
  2438.   end
  2439.   #--------------------------------------------------------------------------
  2440.   # ● 戦闘終了判定
  2441.   #--------------------------------------------------------------------------
  2442.   def fin?
  2443.    return (victory? or $game_party.all_dead? or $game_party.actors.size == 0)
  2444.   end
  2445.   #--------------------------------------------------------------------------
  2446.   # ● 敵全滅判定
  2447.   #--------------------------------------------------------------------------
  2448.   def victory?
  2449.     for battler in $game_troop.enemies
  2450.       if not battler.hidden and (battler.rest_hp > 0 or
  2451.           battler.immortal or battler.damage_pop.size > 0)
  2452.         return false
  2453.       end
  2454.     end
  2455.     return true
  2456.   end
  2457.   #--------------------------------------------------------------------------
  2458.   # ● 死亡許可判定
  2459.   #--------------------------------------------------------------------------
  2460.   def dead_ok?(battler)
  2461.     speller = synthe?(battler)
  2462.     if speller == nil
  2463.       if @action_battlers.include?(battler)
  2464.         if battler.phase > 2
  2465.           return false
  2466.         end
  2467.       end
  2468.     else
  2469.       for battler in speller
  2470.         if @action_battlers.include?(battler)
  2471.           if battler.phase > 2
  2472.             return false
  2473.           end
  2474.         end
  2475.       end
  2476.     end
  2477.     return true
  2478.   end
  2479. end

  2480. #==============================================================================
  2481. # ■ Game_Actor
  2482. #------------------------------------------------------------------------------
  2483. #  アクターを扱うクラスです。このクラスは Game_Actors クラス ($game_actors)
  2484. # の内部で使用され、Game_Party クラス ($game_party) からも参照されます。
  2485. #==============================================================================

  2486. class Game_Actor < Game_Battler
  2487.   #--------------------------------------------------------------------------
  2488.   # ● バトル画面 X 座標の取得
  2489.   #--------------------------------------------------------------------------
  2490.   def screen_x
  2491.     # パーティ内の並び順から X 座標を計算して返す
  2492.     if self.index != nil
  2493.       return self.index * 160 + (4 - $game_party.actors.size) * 80 + 80
  2494.     else
  2495.       return 0
  2496.     end
  2497.   end
  2498. end

  2499. #==============================================================================
  2500. # ■ Spriteset_Battle
  2501. #------------------------------------------------------------------------------
  2502. #  バトル画面のスプライトをまとめたクラスです。このクラスは Scene_Battle クラ
  2503. # スの内部で使用されます。
  2504. #==============================================================================

  2505. class Spriteset_Battle
  2506.   #--------------------------------------------------------------------------
  2507.   # ● 公開インスタンス変数
  2508.   #--------------------------------------------------------------------------
  2509.   attr_reader   :real_x                   # x座標補正(現在値)
  2510.   attr_reader   :real_y                   # y座標補正(現在値)
  2511.   attr_reader   :real_zoom                # 拡大率(現在値)
  2512.   #--------------------------------------------------------------------------
  2513.   # ● オブジェクト初期化
  2514.   #--------------------------------------------------------------------------
  2515.   def initialize
  2516.     # ビューポートを作成
  2517.     @viewport1 = Viewport.new(0, 0, 640, 480)
  2518.     @viewport2 = Viewport.new(0, 0, 640, 480)
  2519.     @viewport3 = Viewport.new(0, 0, 640, 480)
  2520.     @viewport4 = Viewport.new(0, 0, 640, 480)
  2521.     @viewport2.z = 101
  2522.     @viewport3.z = 200
  2523.     @viewport4.z = 5000
  2524.     @wait = 0
  2525.     @real_x = 0
  2526.     @real_y = 0
  2527.     @real_zoom = 1.0
  2528.     @target_x = 0
  2529.     @target_y = 0
  2530.     @target_zoom = 1.0
  2531.     @gap_x = 0
  2532.     @gap_y = 0
  2533.     @gap_zoom = 0.0
  2534.     # バトルバックスプライトを作成
  2535.     @battleback_sprite = Sprite.new(@viewport1)
  2536.     # エネミースプライトを作成
  2537.     @enemy_sprites = []
  2538.     for enemy in $game_troop.enemies.reverse
  2539.       @enemy_sprites.push(Sprite_Battler.new(@viewport1, enemy))
  2540.     end
  2541.     # アクタースプライトを作成
  2542.     @actor_sprites = []
  2543.     @actor_sprites.push(Sprite_Battler.new(@viewport2))
  2544.     @actor_sprites.push(Sprite_Battler.new(@viewport2))
  2545.     @actor_sprites.push(Sprite_Battler.new(@viewport2))
  2546.     @actor_sprites.push(Sprite_Battler.new(@viewport2))
  2547.     # 天候を作成
  2548.     @weather = RPG::Weather.new(@viewport1)
  2549.     # ピクチャスプライトを作成
  2550.     @picture_sprites = []
  2551.     for i in 51..100
  2552.       @picture_sprites.push(Sprite_Picture.new(@viewport3,
  2553.         $game_screen.pictures[i]))
  2554.     end
  2555.     # タイマースプライトを作成
  2556.     @timer_sprite = Sprite_Timer.new
  2557.     # フレーム更新
  2558.     update
  2559.   end
  2560.   #--------------------------------------------------------------------------
  2561.   # ● フレーム更新
  2562.   #--------------------------------------------------------------------------
  2563.   def update
  2564.     # アクタースプライトの内容を更新 (アクターの入れ替えに対応)
  2565.     @actor_sprites[0].battler = $game_party.actors[0]
  2566.     @actor_sprites[1].battler = $game_party.actors[1]
  2567.     @actor_sprites[2].battler = $game_party.actors[2]
  2568.     @actor_sprites[3].battler = $game_party.actors[3]
  2569.     # バトルバックのファイル名が現在のものと違う場合
  2570.     if @battleback_name != $game_temp.battleback_name
  2571.       make_battleback
  2572.     end
  2573.     # 画面のスクロール
  2574.     screen_scroll
  2575.     # モンスターの位置補正
  2576.     for enemy in $game_troop.enemies
  2577.       enemy.real_x = @real_x
  2578.       enemy.real_y = @real_y
  2579.       enemy.real_zoom = @real_zoom
  2580.     end
  2581.     # バトラースプライトを更新
  2582.     for sprite in @enemy_sprites + @actor_sprites
  2583.       sprite.update
  2584.     end
  2585.     # 天候グラフィックを更新
  2586.     @weather.type = $game_screen.weather_type
  2587.     @weather.max = $game_screen.weather_max
  2588.     @weather.update
  2589.     # ピクチャスプライトを更新
  2590.     for sprite in @picture_sprites
  2591.       sprite.update
  2592.     end
  2593.     # タイマースプライトを更新
  2594.     @timer_sprite.update
  2595.     # 画面の色調とシェイク位置を設定
  2596.     @viewport1.tone = $game_screen.tone
  2597.     @viewport1.ox = $game_screen.shake
  2598.     # 画面のフラッシュ色を設定
  2599.     @viewport4.color = $game_screen.flash_color
  2600.     # ビューポートを更新
  2601.     @viewport1.update
  2602.     @viewport2.update
  2603.     @viewport4.update
  2604.   end
  2605.   #--------------------------------------------------------------------------
  2606.   # ● バトル背景の設定
  2607.   #--------------------------------------------------------------------------
  2608.   def make_battleback
  2609.     @battleback_name = $game_temp.battleback_name
  2610.     if @battleback_sprite.bitmap != nil
  2611.       @battleback_sprite.bitmap.dispose
  2612.     end
  2613.     @battleback_sprite.bitmap = RPG::Cache.battleback(@battleback_name)
  2614.     if @battleback_sprite.bitmap.width == 640 and
  2615.        @battleback_sprite.bitmap.height == 320
  2616.       @battleback_sprite.src_rect.set(0, 0, 1280, 640)
  2617.       @base_zoom = 2.0
  2618.       @battleback_sprite.zoom_x = @base_zoom
  2619.       @battleback_sprite.zoom_y = @base_zoom
  2620.       @real_y = 4
  2621.       @battleback_sprite.x = 320
  2622.       @battleback_sprite.y = @real_y
  2623.       @battleback_sprite.ox = @battleback_sprite.bitmap.width / 2
  2624.       @battleback_sprite.oy = @battleback_sprite.bitmap.height / 4
  2625.     elsif @battleback_sprite.bitmap.width == 640 and
  2626.           @battleback_sprite.bitmap.height == 480
  2627.       @battleback_sprite.src_rect.set(0, 0, 960, 720)
  2628.       @base_zoom = 1.5
  2629.       @battleback_sprite.zoom_x = @base_zoom
  2630.       @battleback_sprite.zoom_y = @base_zoom
  2631.       @battleback_sprite.x = 320
  2632.       @battleback_sprite.y = 0
  2633.       @battleback_sprite.ox = @battleback_sprite.bitmap.width / 2
  2634.       @battleback_sprite.oy = @battleback_sprite.bitmap.height / 4
  2635.     else
  2636.       @battleback_sprite.src_rect.set(0, 0, @battleback_sprite.bitmap.width,
  2637.                                       @battleback_sprite.bitmap.height)
  2638.       @base_zoom = 1.0
  2639.       @battleback_sprite.zoom_x = @base_zoom
  2640.       @battleback_sprite.zoom_y = @base_zoom
  2641.       @battleback_sprite.x = 320
  2642.       @battleback_sprite.y = 0
  2643.       @battleback_sprite.ox = @battleback_sprite.bitmap.width / 2
  2644.       @battleback_sprite.oy = @battleback_sprite.bitmap.height / 4
  2645.     end
  2646.   end
  2647.   #--------------------------------------------------------------------------
  2648.   # ● 画面のスクロール目標の位置・拡大率設定
  2649.   #--------------------------------------------------------------------------
  2650.   def screen_target(x, y, zoom)
  2651.     return unless $scene.drive
  2652.     @wait = $scene.scroll_time
  2653.     @target_x = x
  2654.     @target_y = y
  2655.     @target_zoom = zoom
  2656.     screen_over
  2657.     @gap_x = @target_x - @real_x
  2658.     @gap_y = @target_y - @real_y
  2659.     @gap_zoom = @target_zoom - @real_zoom
  2660.   end
  2661.   #--------------------------------------------------------------------------
  2662.   # ● 画面のスクロール
  2663.   #--------------------------------------------------------------------------
  2664.   def screen_scroll
  2665.     if @wait > 0
  2666.       @real_x = @target_x - @gap_x * (@wait ** 2) / ($scene.scroll_time ** 2)
  2667.       @real_y = @target_y - @gap_y * (@wait ** 2) / ($scene.scroll_time ** 2)
  2668.       @real_zoom = @target_zoom -
  2669.                     @gap_zoom * (@wait ** 2) / ($scene.scroll_time ** 2)
  2670.       @battleback_sprite.x = 320 + @real_x
  2671.       @battleback_sprite.y = @real_y
  2672.       @battleback_sprite.zoom_x = @base_zoom * @real_zoom
  2673.       @battleback_sprite.zoom_y = @base_zoom * @real_zoom
  2674.       @battleback_sprite.ox = @battleback_sprite.bitmap.width / 2
  2675.       @battleback_sprite.oy = @battleback_sprite.bitmap.height / 4
  2676.       @wait -= 1
  2677.     end
  2678.   end
  2679.   #--------------------------------------------------------------------------
  2680.   # ● スクリーンが画面外に出た時の補正処理
  2681.   #--------------------------------------------------------------------------
  2682.   def screen_over
  2683.     width = @battleback_sprite.bitmap.width * @base_zoom * @target_zoom / 2
  2684.     unless 324 + @target_x > width and 324 - @target_x > width
  2685.       if 324 + @target_x > width
  2686.         @target_x = width - 324
  2687.       elsif 324 - @target_x > width
  2688.         @target_x = 324 - width
  2689.       end
  2690.     end
  2691.     height = @battleback_sprite.bitmap.height * @base_zoom * @target_zoom / 4
  2692.     unless @target_y > height - 4 and 484 - @target_y > 3 * height
  2693.       if @target_y > height - 4
  2694.         @target_y = height - 4
  2695.       elsif 484 - @target_y > 3 * height
  2696.         @target_y = 484 - 3 * height
  2697.       end
  2698.     end
  2699.   end
  2700. end

  2701. #==============================================================================
  2702. # ■ Game_Battler (分割定義 1)
  2703. #------------------------------------------------------------------------------
  2704. #  バトラーを扱うクラスです。このクラスは Game_Actor クラスと Game_Enemy クラ
  2705. # スのスーパークラスとして使用されます。
  2706. #==============================================================================

  2707. class Game_Battler
  2708.   #--------------------------------------------------------------------------
  2709.   # ● 公開インスタンス変数追加
  2710.   #--------------------------------------------------------------------------
  2711.   attr_accessor :up_level                  # レベルアップ数
  2712.   attr_accessor :at                        # AT(タイムゲージ)
  2713.   attr_accessor :atp                       # AT(表示用)
  2714.   attr_accessor :rt                        # RP(詠唱ゲージ)
  2715.   attr_accessor :rtp                       # RP(詠唱必要量)
  2716.   attr_accessor :spell                     # 合成スキル発動中
  2717.   attr_accessor :recover_hp                # HP回復量
  2718.   attr_accessor :recover_sp                # SP回復量
  2719.   attr_accessor :state_p                   # ステータス異常配列
  2720.   attr_accessor :state_m                   # ステータス異常配列
  2721.   attr_accessor :damage_sp                 # SPダメージ表示フラグ
  2722.   attr_accessor :animation                 # アニメーション ID, Hitの配列
  2723.   attr_accessor :phase
  2724.   attr_accessor :wait
  2725.   attr_accessor :target
  2726.   attr_accessor :anime1
  2727.   attr_accessor :anime2
  2728.   attr_accessor :event
  2729.   #--------------------------------------------------------------------------
  2730.   # ● オブジェクト初期化
  2731.   #--------------------------------------------------------------------------
  2732.   alias :initialize_rtab :initialize
  2733.   def initialize
  2734.     initialize_rtab
  2735.     @damage_pop = {}
  2736.     @damage = {}
  2737.     @damage_sp = {}
  2738.     @critical = {}
  2739.     @recover_hp = {}
  2740.     @recover_sp = {}
  2741.     @state_p = {}
  2742.     @state_m = {}
  2743.     @animation = []
  2744.     @phase = 1
  2745.     @wait = 0
  2746.     @target = []
  2747.     @anime1 = 0
  2748.     @anime2 = 0
  2749.     @event = 0
  2750.   end
  2751.   #--------------------------------------------------------------------------
  2752.   # ● 存在判定
  2753.   #--------------------------------------------------------------------------
  2754.   def exist?
  2755.     return (not @hidden and (@hp > 0 or @immortal or @damage.size > 0))
  2756.   end
  2757.   #--------------------------------------------------------------------------
  2758.   # ● 残HP予測
  2759.   #--------------------------------------------------------------------------
  2760.   def rest_hp
  2761.     # rest_hp に現HPを代入
  2762.     rest_hp = @hp
  2763.     # バトラーが受ける全ダメージをrest_hpに反映させる
  2764.     for pre_damage in @damage
  2765.       if pre_damage[1].is_a?(Numeric)
  2766.         rest_hp -= pre_damage[1]
  2767.       end
  2768.     end
  2769.     return rest_hp
  2770.   end
  2771.   #--------------------------------------------------------------------------
  2772.   # ● ステートの解除
  2773.   #     state_id : ステート ID
  2774.   #     force    : 強制解除フラグ (オートステートの処理で使用)
  2775.   #--------------------------------------------------------------------------
  2776.   def remove_state(state_id, force = false)
  2777.     # このステートが付加されている場合
  2778.     if state?(state_id)
  2779.       # 強制付加されたステートで、かつ解除が強制ではない場合
  2780.       if @states_turn[state_id] == -1 and not force
  2781.         # メソッド終了
  2782.         return
  2783.       end
  2784.       # 現在の HP が 0 かつ オプション [HP 0 の状態とみなす] が有効の場合
  2785.       if @hp == 0 and $data_states[state_id].zero_hp
  2786.         # ほかに [HP 0 の状態とみなす] ステートがあるかどうか判定
  2787.         zero_hp = false
  2788.         for i in @states
  2789.           if i != state_id and $data_states[i].zero_hp
  2790.             zero_hp = true
  2791.           end
  2792.         end
  2793.         # 戦闘不能を解除してよければ、HP を 1 に変更
  2794.         if zero_hp == false
  2795.           @hp = 1
  2796.         end
  2797.       end
  2798.       unless self.movable?
  2799.         # ステート ID を @states 配列および @states_turn ハッシュから削除
  2800.         @states.delete(state_id)
  2801.         @states_turn.delete(state_id)
  2802.         if self.movable?
  2803.           self.at = 0
  2804.         end
  2805.       else
  2806.         # ステート ID を @states 配列および @states_turn ハッシュから削除
  2807.         @states.delete(state_id)
  2808.         @states_turn.delete(state_id)
  2809.       end
  2810.     end
  2811.     # HP および SP の最大値チェック
  2812.     @hp = [@hp, self.maxhp].min
  2813.     @sp = [@sp, self.maxsp].min
  2814.   end
  2815.   #--------------------------------------------------------------------------
  2816.   # ● 通常攻撃の効果適用
  2817.   #     attacker : 攻撃者 (バトラー)
  2818.   #--------------------------------------------------------------------------
  2819.   def attack_effect(attacker)
  2820.     # クリティカルフラグをクリア
  2821.     self.critical[attacker] = false
  2822.     state_p[attacker] = []
  2823.     state_m[attacker] = []
  2824.     # 第一命中判定
  2825.     hit_result = (rand(100) < attacker.hit)
  2826.     # 命中の場合
  2827.     if hit_result == true
  2828.       # 基本ダメージを計算
  2829.       atk = [attacker.atk - self.pdef / 2, 0].max
  2830.       self.damage[attacker] = atk * (20 + attacker.str) / 20
  2831.       # 属性修正
  2832.       self.damage[attacker] *= elements_correct(attacker.element_set)
  2833.       self.damage[attacker] /= 100
  2834.       # ダメージの符号が正の場合
  2835.       if self.damage[attacker] > 0
  2836.         # クリティカル修正
  2837.         if rand(100) < 4 * attacker.dex / self.agi
  2838.           self.damage[attacker] *= 2
  2839.           self.critical[attacker] = true
  2840.         end
  2841.         # 防御修正
  2842.         if self.guarding?
  2843.           self.damage[attacker] /= 2
  2844.         end
  2845.       end
  2846.       # 分散
  2847.       if self.damage[attacker].abs > 0
  2848.         amp = [self.damage[attacker].abs * 15 / 100, 1].max
  2849.         self.damage[attacker] += rand(amp+1) + rand(amp+1) - amp
  2850.       end
  2851.       # 第二命中判定
  2852.       eva = 8 * self.agi / attacker.dex + self.eva
  2853.       hit = self.damage[attacker] < 0 ? 100 : 100 - eva
  2854.       hit = self.cant_evade? ? 100 : hit
  2855.       hit_result = (rand(100) < hit)
  2856.     end
  2857.     # 命中の場合
  2858.     if hit_result == true
  2859.       # ステート衝撃解除
  2860.       remove_states_shock
  2861.       # HP からダメージを減算
  2862.       # ステート変化
  2863.       @state_changed = false
  2864.       states_plus(attacker, attacker.plus_state_set)
  2865.       states_minus(attacker, attacker.minus_state_set)
  2866.     # ミスの場合
  2867.     else
  2868.       # ダメージに "Miss" を設定
  2869.       self.damage[attacker] = "Miss"
  2870.       # クリティカルフラグをクリア
  2871.       self.critical[attacker] = false
  2872.     end
  2873.     # メソッド終了
  2874.     return true
  2875.   end
  2876.   #--------------------------------------------------------------------------
  2877.   # ● スキルの効果適用
  2878.   #     user  : スキルの使用者 (バトラー)
  2879.   #     skill : スキル
  2880.   #--------------------------------------------------------------------------
  2881.   def skill_effect(user, skill)
  2882.     # クリティカルフラグをクリア
  2883.     self.critical[user] = false
  2884.     state_p[user] = []
  2885.     state_m[user] = []
  2886.     # スキルの効果範囲が HP 1 以上の味方で、自分の HP が 0、
  2887.     # またはスキルの効果範囲が HP 0 の味方で、自分の HP が 1 以上の場合
  2888.     if ((skill.scope == 3 or skill.scope == 4) and self.hp == 0)# or
  2889.   #     ((skill.scope == 5 or skill.scope == 6) and self.hp >= 1)
  2890.       # メソッド終了
  2891.       return false
  2892.     end
  2893.     # 有効フラグをクリア
  2894.     effective = false
  2895.     # コモンイベント ID が有効の場合は有効フラグをセット
  2896.     effective |= skill.common_event_id > 0
  2897.     # 第一命中判定
  2898.     hit = skill.hit
  2899.     if skill.atk_f > 0
  2900.       hit *= user.hit / 100
  2901.     end
  2902.     hit_result = (rand(100) < hit)
  2903.     # 不確実なスキルの場合は有効フラグをセット
  2904.     effective |= hit < 100
  2905.     # 命中の場合
  2906.     if hit_result == true
  2907.       # 威力を計算
  2908.       power = skill.power + user.atk * skill.atk_f / 100
  2909.       if power > 0
  2910.         power -= self.pdef * skill.pdef_f / 200
  2911.         power -= self.mdef * skill.mdef_f / 200
  2912.         power = [power, 0].max
  2913.       end
  2914.       # 倍率を計算
  2915.       rate = 20
  2916.       rate += (user.str * skill.str_f / 100)
  2917.       rate += (user.dex * skill.dex_f / 100)
  2918.       rate += (user.agi * skill.agi_f / 100)
  2919.       rate += (user.int * skill.int_f / 100)
  2920.       # 基本ダメージを計算
  2921.       self.damage[user] = power * rate / 20
  2922.       # 属性修正
  2923.       self.damage[user] *= elements_correct(skill.element_set)
  2924.       self.damage[user] /= 100
  2925.       # ダメージの符号が正の場合
  2926.       if self.damage[user] > 0
  2927.         # 防御修正
  2928.         if self.guarding?
  2929.           self.damage[user] /= 2
  2930.         end
  2931.       end
  2932.       # 分散
  2933.       if skill.variance > 0 and self.damage[user].abs > 0
  2934.         amp = [self.damage[user].abs * skill.variance / 100, 1].max
  2935.         self.damage[user] += rand(amp+1) + rand(amp+1) - amp
  2936.       end
  2937.       # 第二命中判定
  2938.       eva = 8 * self.agi / user.dex + self.eva
  2939.       hit = self.damage[user] < 0 ? 100 : 100 - eva * skill.eva_f / 100
  2940.       hit = self.cant_evade? ? 100 : hit
  2941.       hit_result = (rand(100) < hit)
  2942.       # 不確実なスキルの場合は有効フラグをセット
  2943.       effective |= hit < 100
  2944.     end
  2945.     # 命中の場合
  2946.     if hit_result == true
  2947.       # 威力 0 以外の物理攻撃の場合
  2948.       if skill.power != 0 and skill.atk_f > 0
  2949.         # ステート衝撃解除
  2950.         remove_states_shock
  2951.         # 有効フラグをセット
  2952.         effective = true
  2953.       end
  2954.       # HP の変動判定
  2955.       last_hp = [[self.hp - self.damage[user], self.maxhp].min, 0].max
  2956.       # 効果判定
  2957.       effective |= self.hp != last_hp
  2958.       # ステート変化
  2959.       @state_changed = false
  2960.       effective |= states_plus(user, skill.plus_state_set)
  2961.       effective |= states_minus(user, skill.minus_state_set)
  2962.       unless $game_temp.in_battle
  2963.         self.damage_effect(user,1 )
  2964.       end
  2965.       # 威力が 0 の場合
  2966.       if skill.power == 0
  2967.         # ダメージに空文字列を設定
  2968.         self.damage[user] = ""
  2969.         # ステートに変化がない場合
  2970.         unless @state_changed
  2971.           # ダメージに "Miss" を設定
  2972.           self.damage[user] = "Miss"
  2973.         end
  2974.       end
  2975.     # ミスの場合
  2976.     else
  2977.       # ダメージに "Miss" を設定
  2978.       self.damage[user] = "Miss"
  2979.     end
  2980.     # 戦闘中でない場合
  2981.     unless $game_temp.in_battle
  2982.       # ダメージに nil を設定
  2983.       self.damage[user] = nil
  2984.     end
  2985.     # メソッド終了
  2986.     return effective
  2987.   end
  2988.   #--------------------------------------------------------------------------
  2989.   # ● アイテムの効果適用
  2990.   #     item : アイテム
  2991.   #--------------------------------------------------------------------------
  2992.   def item_effect(item, user = $game_party.actors[0])
  2993.     # クリティカルフラグをクリア
  2994.     self.critical[user] = false
  2995.     state_p[user] = []
  2996.     state_m[user] = []
  2997.     self.recover_hp[user] = 0
  2998.     self.recover_sp[user] = 0
  2999.     # アイテムの効果範囲が HP 1 以上の味方で、自分の HP が 0、
  3000.     # またはアイテムの効果範囲が HP 0 の味方で、自分の HP が 1 以上の場合
  3001.     if ((item.scope == 3 or item.scope == 4) and self.hp == 0)# or
  3002.     #   ((item.scope == 5 or item.scope == 6) and self.hp >= 1)
  3003.       # メソッド終了
  3004.       return false
  3005.     end
  3006.     # 有効フラグをクリア
  3007.     effective = false
  3008.     # コモンイベント ID が有効の場合は有効フラグをセット
  3009.     effective |= item.common_event_id > 0
  3010.     # 命中判定
  3011.     hit_result = (rand(100) < item.hit)
  3012.     # 不確実なスキルの場合は有効フラグをセット
  3013.     effective |= item.hit < 100
  3014.     # 命中の場合
  3015.     if hit_result == true
  3016.       # 回復量を計算
  3017.       self.recover_hp[user] = maxhp * item.recover_hp_rate / 100 +
  3018.                               item.recover_hp
  3019.       self.recover_sp[user] = maxsp * item.recover_sp_rate / 100 +
  3020.                               item.recover_sp
  3021.       if self.recover_hp[user] < 0
  3022.         self.recover_hp[user] += self.pdef * item.pdef_f / 20
  3023.         self.recover_hp[user] += self.mdef * item.mdef_f / 20
  3024.         self.recover_hp[user] = [self.recover_hp[user], 0].min
  3025.       end
  3026.       # 属性修正
  3027.       self.recover_hp[user] *= elements_correct(item.element_set)
  3028.       self.recover_hp[user] /= 100
  3029.       self.recover_sp[user] *= elements_correct(item.element_set)
  3030.       self.recover_sp[user] /= 100
  3031.       # 分散
  3032.       if item.variance > 0 and self.recover_hp[user].abs > 0
  3033.         amp = [self.recover_hp[user].abs * item.variance / 100, 1].max
  3034.         self.recover_hp[user] += rand(amp+1) + rand(amp+1) - amp
  3035.       end
  3036.       if item.variance > 0 and self.recover_sp[user].abs > 0
  3037.         amp = [self.recover_sp[user].abs * item.variance / 100, 1].max
  3038.         self.recover_sp[user] += rand(amp+1) + rand(amp+1) - amp
  3039.       end
  3040.       # 回復量の符号が負の場合
  3041.       if self.recover_hp[user] < 0
  3042.         # 防御修正
  3043.         if self.guarding?
  3044.           self.recover_hp[user] /= 2
  3045.         end
  3046.       end
  3047.       # HP 回復量の符号を反転し、ダメージの値に設定
  3048.       self.damage[user] = -self.recover_hp[user]
  3049.       # HP および SP の変動判定
  3050.       last_hp = [[self.hp + self.recover_hp[user], self.maxhp].min, 0].max
  3051.       last_sp = [[self.sp + self.recover_sp[user], self.maxsp].min, 0].max
  3052.       effective |= self.hp != last_hp
  3053.       effective |= self.sp != last_sp
  3054.       # ステート変化
  3055.       @state_changed = false
  3056.       effective |= states_plus(user, item.plus_state_set)
  3057.       effective |= states_minus(user, item.minus_state_set)
  3058.       unless $game_temp.in_battle
  3059.         self.damage_effect(user, 2)
  3060.       end
  3061.       # パラメータ上昇値が有効の場合
  3062.       if item.parameter_type > 0 and item.parameter_points != 0
  3063.         # パラメータで分岐
  3064.         case item.parameter_type
  3065.         when 1  # MaxHP
  3066.           @maxhp_plus += item.parameter_points
  3067.         when 2  # MaxSP
  3068.           @maxsp_plus += item.parameter_points
  3069.         when 3  # 腕力
  3070.           @str_plus += item.parameter_points
  3071.         when 4  # 器用さ
  3072.           @dex_plus += item.parameter_points
  3073.         when 5  # 素早さ
  3074.           @agi_plus += item.parameter_points
  3075.         when 6  # 魔力
  3076.           @int_plus += item.parameter_points
  3077.         end
  3078.         # 有効フラグをセット
  3079.         effective = true
  3080.       end
  3081.       # HP 回復率と回復量が 0 の場合
  3082.       if item.recover_hp_rate == 0 and item.recover_hp == 0
  3083.         # ダメージに空文字列を設定
  3084.         self.damage[user] = ""
  3085.         # SP 回復率と回復量が 0、パラメータ上昇値が無効の場合
  3086.         if item.recover_sp_rate == 0 and item.recover_sp == 0 and
  3087.            (item.parameter_type == 0 or item.parameter_points == 0)
  3088.           # ステートに変化がない場合
  3089.           unless @state_changed
  3090.             # ダメージに "Miss" を設定
  3091.             self.damage[user] = "Miss"
  3092.           end
  3093.         end
  3094.       end
  3095.     # ミスの場合
  3096.     else
  3097.       # ダメージに "Miss" を設定
  3098.       self.damage[user] = "Miss"
  3099.     end
  3100.     # 戦闘中でない場合
  3101.     unless $game_temp.in_battle
  3102.       # ダメージに nil を設定
  3103.       self.damage[user] = nil
  3104.     end
  3105.     # メソッド終了
  3106.     return effective
  3107.   end
  3108.   #--------------------------------------------------------------------------
  3109.   # ● ステート変化 (+) の適用
  3110.   #     plus_state_set  : ステート変化 (+)
  3111.   #--------------------------------------------------------------------------
  3112.   def states_plus(battler, plus_state_set)
  3113.     # 有効フラグをクリア
  3114.     effective = false
  3115.     # ループ (付加するステート)
  3116.     for i in plus_state_set
  3117.       # このステートが防御されていない場合
  3118.       unless self.state_guard?(i)
  3119.         # このステートがフルでなければ有効フラグをセット
  3120.         effective |= self.state_full?(i) == false
  3121.         # ステートが [抵抗しない] の場合
  3122.         if $data_states[i].nonresistance
  3123.           # ステート変化フラグをセット
  3124.           @state_changed = true
  3125.           # ステートを付加
  3126.           self.state_p[battler].push(i)
  3127.         # このステートがフルではない場合
  3128.         elsif self.state_full?(i) == false
  3129.           # ステート有効度を確率に変換し、乱数と比較
  3130.           if rand(100) < [0,100,80,60,40,20,0][self.state_ranks[i]]
  3131.             # ステート変化フラグをセット
  3132.             @state_changed = true
  3133.             # ステートを付加
  3134.             self.state_p[battler].push(i)
  3135.           end
  3136.         end
  3137.       end
  3138.     end
  3139.     # メソッド終了
  3140.     return effective
  3141.   end
  3142.   #--------------------------------------------------------------------------
  3143.   # ● ステート変化 (-) の適用
  3144.   #     minus_state_set : ステート変化 (-)
  3145.   #--------------------------------------------------------------------------
  3146.   def states_minus(battler, minus_state_set)
  3147.     # 有効フラグをクリア
  3148.     effective = false
  3149.     # ループ (解除するステート)
  3150.     for i in minus_state_set
  3151.       # このステートが付加されていれば有効フラグをセット
  3152.       effective |= self.state?(i)
  3153.       # ステート変化フラグをセット
  3154.       @state_changed = true
  3155.       # ステートを解除
  3156.       self.state_m[battler].push(i)
  3157.     end
  3158.     # メソッド終了
  3159.     return effective
  3160.   end
  3161.   #--------------------------------------------------------------------------
  3162.   # ● ダメージ演算
  3163.   #--------------------------------------------------------------------------
  3164.   def damage_effect(battler, item)
  3165.     if item == 2
  3166.       self.hp += self.recover_hp[battler]
  3167.       self.sp += self.recover_sp[battler]
  3168.       if self.recover_sp[battler] != 0
  3169.         self.damage_sp[battler] = -self.recover_sp[battler]
  3170.       end
  3171.       self.recover_hp.delete(battler)
  3172.       self.recover_sp.delete(battler)
  3173.     else
  3174.       if self.damage[battler].class != String
  3175.         self.hp -= self.damage[battler]
  3176.       end
  3177.     end
  3178.     for i in self.state_p[battler]
  3179.       add_state(i)
  3180.     end
  3181.     for i in self.state_m[battler]
  3182.       remove_state(i)
  3183.     end
  3184.   end
  3185.   #--------------------------------------------------------------------------
  3186.   # ● スリップダメージの効果適用
  3187.   #--------------------------------------------------------------------------
  3188. # 3=>毒
  3189. # 24=>回血
  3190. # 32=>烧伤
  3191. # 45=>回蓝
  3192. def slip_damage_effect
  3193.   hp_v = {3 => self.maxhp / 30, 24 => -self.hp / 20, 32 => self.maxhp / 10}
  3194.   sp_v = {45 => -self.maxsp / 20}
  3195.   hp_damage = 0
  3196.   sp_damage = 0
  3197.   hp_v.keys.each do |id|
  3198.     hp_damage += hp_v[id] if self.state?(id)
  3199.   end
  3200.   sp_v.keys.each do |id|
  3201.     sp_damage += sp_v[id] if self.state?(id)
  3202.   end
  3203.   self.damage["slip"] = hp_damage if hp_damage != 0
  3204.   self.hp -= hp_damage
  3205.   self.damage_sp["slip"] = sp_damage if sp_damage != 0
  3206.   self.sp -= sp_damage
  3207. end
  3208. end
  3209. #######################################
  3210. #==============================================================================
  3211. # ■ Game_BattleAction
  3212. #------------------------------------------------------------------------------
  3213. #  アクション (戦闘中の行動) を扱うクラスです。このクラスは Game_Battler クラ
  3214. # スの内部で使用されます。
  3215. #==============================================================================

  3216. class Game_BattleAction
  3217.   #--------------------------------------------------------------------------
  3218.   # ● 公開インスタンス変数
  3219.   #--------------------------------------------------------------------------
  3220.   attr_accessor :spell_id                 # 合体魔法用スキル ID
  3221.   attr_accessor :force_kind               # 種別 (基本 / スキル / アイテム)
  3222.   attr_accessor :force_basic              # 基本 (攻撃 / 防御 / 逃げる)
  3223.   attr_accessor :force_skill_id           # スキル ID
  3224.   #--------------------------------------------------------------------------
  3225.   # ● 有効判定
  3226.   #--------------------------------------------------------------------------
  3227.   def valid?
  3228.     return (not (@force_kind == 0 and @force_basic == 3))
  3229.   end
  3230. end

  3231. #==============================================================================
  3232. # ■ Game_Actor
  3233. #------------------------------------------------------------------------------
  3234. #  アクターを扱うクラスです。このクラスは Game_Actors クラス ($game_actors)
  3235. # の内部で使用され、Game_Party クラス ($game_party) からも参照されます。
  3236. #==============================================================================

  3237. class Game_Actor < Game_Battler
  3238.   def skill_can_use?(skill_id)
  3239.     return super
  3240.   end
  3241. end

  3242. #==============================================================================
  3243. # ■ Game_Enemy
  3244. #------------------------------------------------------------------------------
  3245. #  エネミーを扱うクラスです。このクラスは Game_Troop クラス ($game_troop) の
  3246. # 内部で使用されます。
  3247. #==============================================================================

  3248. class Game_Enemy < Game_Battler
  3249.   #--------------------------------------------------------------------------
  3250.   # ● 公開インスタンス変数
  3251.   #--------------------------------------------------------------------------
  3252.   attr_accessor :height                  # 画像の高さ
  3253.   attr_accessor :real_x                  # X座標補正
  3254.   attr_accessor :real_y                  # Y座標補正
  3255.   attr_accessor :real_zoom               # 拡大率
  3256.   #--------------------------------------------------------------------------
  3257.   # ● オブジェクト初期化
  3258.   #     troop_id     : トループ ID
  3259.   #     member_index : トループメンバーのインデックス
  3260.   #--------------------------------------------------------------------------
  3261.   def initialize(troop_id, member_index)
  3262.     super()
  3263.     @troop_id = troop_id
  3264.     @member_index = member_index
  3265.     troop = $data_troops[@troop_id]
  3266.     @enemy_id = troop.members[@member_index].enemy_id
  3267.     enemy = $data_enemies[@enemy_id]
  3268.     @battler_name = enemy.battler_name
  3269.     @battler_hue = enemy.battler_hue
  3270.     @hp = maxhp
  3271.     @sp = maxsp
  3272.     @real_x = 0
  3273.     @real_y = 0
  3274.     @real_zoom = 1.0
  3275.     @fly = 0
  3276.     enemy.name.sub(/\\[Ff]\[([0-9]+)\]/) {@fly = $1.to_i}
  3277.     @hidden = troop.members[@member_index].hidden
  3278.     @immortal = troop.members[@member_index].immortal
  3279.   end
  3280.   alias :true_x :screen_x
  3281.   alias :true_y :screen_y
  3282.   #--------------------------------------------------------------------------
  3283.   # ● バトル画面 X 座標の取得
  3284.   #--------------------------------------------------------------------------
  3285.   def screen_x
  3286.     return 320 + (true_x - 320) * @real_zoom + @real_x
  3287.   end
  3288.   #--------------------------------------------------------------------------
  3289.   # ● バトル画面 Y 座標の取得
  3290.   #--------------------------------------------------------------------------
  3291.   def screen_y
  3292.     return true_y * @real_zoom + @real_y
  3293.   end
  3294.   #--------------------------------------------------------------------------
  3295.   # ● バトル画面 Z 座標の取得
  3296.   #--------------------------------------------------------------------------
  3297.   def screen_z
  3298.     return true_y + @fly
  3299.   end
  3300.   #--------------------------------------------------------------------------
  3301.   # ● バトル画面 拡大率の取得
  3302.   #--------------------------------------------------------------------------
  3303.   def zoom
  3304.     return ($scene.zoom_rate[1] - $scene.zoom_rate[0]) *
  3305.                           (true_y + @fly) / 320 + $scene.zoom_rate[0]
  3306.   end
  3307.   #--------------------------------------------------------------------------
  3308.   # ● 攻撃用、バトル画面 X 座標の取得
  3309.   #--------------------------------------------------------------------------
  3310.   def attack_x(z)
  3311.     return (320 - true_x) * z * 0.75
  3312.   end
  3313.   #--------------------------------------------------------------------------
  3314.   # ● 攻撃用、バトル画面 Y 座標の取得
  3315.   #--------------------------------------------------------------------------
  3316.   def attack_y(z)
  3317.     return (160 - (true_y + @fly / 4) * z + @height * zoom * z / 2) * 0.75
  3318.   end
  3319.   #--------------------------------------------------------------------------
  3320.   # ● アクション作成
  3321.   #--------------------------------------------------------------------------
  3322.   def make_action
  3323.     # カレントアクションをクリア
  3324.     self.current_action.clear
  3325.     # 動けない場合
  3326.     unless self.inputable?
  3327.       # メソッド終了
  3328.       return
  3329.     end
  3330.     # 現在有効なアクションを抽出
  3331.     available_actions = []
  3332.     rating_max = 0
  3333.     for action in self.actions
  3334.       # ターン 条件確認
  3335.       n = $game_temp.battle_turn
  3336.       a = action.condition_turn_a
  3337.       b = action.condition_turn_b
  3338.       if (b == 0 and n != a) or
  3339.          (b > 0 and (n < 1 or n < a or n % b != a % b))
  3340.         next
  3341.       end
  3342.       # HP 条件確認
  3343.       if self.hp * 100.0 / self.maxhp > action.condition_hp
  3344.         next
  3345.       end
  3346.       # レベル 条件確認
  3347.       if $game_party.max_level < action.condition_level
  3348.         next
  3349.       end
  3350.       # スイッチ 条件確認
  3351.       switch_id = action.condition_switch_id
  3352.       if switch_id > 0 and $game_switches[switch_id] == false
  3353.         next
  3354.       end
  3355.       # スキル使用可能 条件確認
  3356.       if action.kind == 1
  3357.         unless self.skill_can_use?(action.skill_id)
  3358.           next
  3359.         end
  3360.       end
  3361.       # 条件に該当 : このアクションを追加
  3362.       available_actions.push(action)
  3363.       if action.rating > rating_max
  3364.         rating_max = action.rating
  3365.       end
  3366.     end
  3367.     # 最大のレーティング値を 3 として合計を計算 (0 以下は除外)
  3368.     ratings_total = 0
  3369.     for action in available_actions
  3370.       if action.rating > rating_max - 3
  3371.         ratings_total += action.rating - (rating_max - 3)
  3372.       end
  3373.     end
  3374.     # レーティングの合計が 0 ではない場合
  3375.     if ratings_total > 0
  3376.       # 乱数を作成
  3377.       value = rand(ratings_total)
  3378.       # 作成した乱数に対応するものをカレントアクションに設定
  3379.       for action in available_actions
  3380.         if action.rating > rating_max - 3
  3381.           if value < action.rating - (rating_max - 3)
  3382.             self.current_action.kind = action.kind
  3383.             self.current_action.basic = action.basic
  3384.             self.current_action.skill_id = action.skill_id
  3385.             self.current_action.decide_random_target_for_enemy
  3386.             return
  3387.           else
  3388.             value -= action.rating - (rating_max - 3)
  3389.           end
  3390.         end
  3391.       end
  3392.     end
  3393.   end
  3394. end

  3395. #==============================================================================
  3396. # ■ Game_Party
  3397. #------------------------------------------------------------------------------
  3398. #  パーティを扱うクラスです。ゴールドやアイテムなどの情報が含まれます。このク
  3399. # ラスのインスタンスは $game_party で参照されます。
  3400. #==============================================================================

  3401. class Game_Party
  3402.   #--------------------------------------------------------------------------
  3403.   # ● 全滅判定
  3404.   #--------------------------------------------------------------------------
  3405.   def all_dead?
  3406.     # パーティ人数が 0 人の場合
  3407.     if $game_party.actors.size == 0
  3408.       return false
  3409.     end
  3410.     # HP 0 以上のアクターがパーティにいる場合
  3411.     for actor in @actors
  3412.       if actor.rest_hp > 0
  3413.         return false
  3414.       end
  3415.     end
  3416.     # 全滅
  3417.     return true
  3418.   end
  3419.   #--------------------------------------------------------------------------
  3420.   # ● 対象アクターのランダムな決定
  3421.   #     hp0 : HP 0 のアクターに限る
  3422.   #--------------------------------------------------------------------------
  3423.   # オリジナルのターゲット決定ルーチンを smooth_target_actor_rtab と名前変更
  3424.   alias :random_target_actor_rtab :random_target_actor
  3425.   def random_target_actor(hp0 = false)
  3426.     # ルーレットを初期化
  3427.     roulette = []
  3428.     # ループ
  3429.     for actor in @actors
  3430.       # 条件に該当する場合
  3431.       if (not hp0 and actor.exist? and actor.rest_hp > 0) or
  3432.           (hp0 and actor.hp0?)
  3433.         # アクターのクラスの [位置] を取得
  3434.         position = $data_classes[actor.class_id].position
  3435.         # 前衛のとき n = 4、中衛のとき n = 3、後衛のとき n = 2
  3436.         n = 4 - position
  3437.         # ルーレットにアクターを n 回追加
  3438.         n.times do
  3439.           roulette.push(actor)
  3440.         end
  3441.       end
  3442.     end
  3443.     # ルーレットのサイズが 0 の場合
  3444.     if roulette.size == 0
  3445.       return random_target_actor_rtab(hp0)
  3446.     end
  3447.     # ルーレットを回し、アクターを決定
  3448.     return roulette[rand(roulette.size)]
  3449.   end
  3450.   #--------------------------------------------------------------------------
  3451.   # ● 対象アクターのスムーズな決定
  3452.   #     actor_index : アクターインデックス
  3453.   #--------------------------------------------------------------------------
  3454.   # オリジナルのターゲット決定ルーチンを smooth_target_actor_rtab と名前変更
  3455.   alias :smooth_target_actor_rtab :smooth_target_actor
  3456.   def smooth_target_actor(actor_index)
  3457.     # アクターを取得
  3458.     actor = @actors[actor_index]
  3459.     # アクターが存在する場合
  3460.     if actor != nil and actor.exist? and actor.rest_hp > 0
  3461.       return actor
  3462.     end
  3463.     # ループ
  3464.     for actor in @actors
  3465.       # アクターが存在する場合
  3466.       if actor.exist? and actor.rest_hp > 0
  3467.         return actor
  3468.       end
  3469.     end
  3470.     # 味方が全滅している場合、オリジナルのターゲット決定ルーチンを実行する
  3471.     return smooth_target_actor_rtab(actor_index)
  3472.   end
  3473. end

  3474. #==============================================================================
  3475. # ■ Game_Troop
  3476. #------------------------------------------------------------------------------
  3477. #  トループを扱うクラスです。このクラスのインスタンスは $game_troop で参照さ
  3478. # れます。
  3479. #==============================================================================

  3480. class Game_Troop
  3481.   #--------------------------------------------------------------------------
  3482.   # ● 対象エネミーのランダムな決定
  3483.   #     hp0 : HP 0 のエネミーに限る
  3484.   #--------------------------------------------------------------------------
  3485.   # オリジナルのターゲット決定ルーチンを random_target_enemy_rtab と名前変更
  3486.   alias :random_target_enemy_rtab :random_target_enemy
  3487.   def random_target_enemy(hp0 = false)
  3488.     # ルーレットを初期化
  3489.     roulette = []
  3490.     # ループ
  3491.     for enemy in @enemies
  3492.       # 条件に該当する場合
  3493.       if (not hp0 and enemy.exist? and enemy.rest_hp > 0) or
  3494.           (hp0 and enemy.hp0?)
  3495.         # ルーレットにエネミーを追加
  3496.         roulette.push(enemy)
  3497.       end
  3498.     end
  3499.     # ルーレットのサイズが 0 の場合
  3500.     if roulette.size == 0
  3501.       return random_target_enemy_rtab(hp0)
  3502.     end
  3503.     # ルーレットを回し、エネミーを決定
  3504.     return roulette[rand(roulette.size)]
  3505.   end
  3506.   #--------------------------------------------------------------------------
  3507.   # ● 対象エネミーのスムーズな決定
  3508.   #     enemy_index : エネミーインデックス
  3509.   #--------------------------------------------------------------------------
  3510.   # オリジナルのターゲット決定ルーチンを smooth_target_enemy_rtab と名前変更
  3511.   alias :smooth_target_enemy_rtab :smooth_target_enemy
  3512.   def smooth_target_enemy(enemy_index)
  3513.     # エネミーを取得
  3514.     enemy = @enemies[enemy_index]
  3515.     # エネミーが存在する場合
  3516.     if enemy != nil and enemy.exist? and enemy.rest_hp > 0
  3517.       return enemy
  3518.     end
  3519.     # ループ
  3520.     for enemy in @enemies
  3521.       # エネミーが存在する場合
  3522.       if enemy.exist? and enemy.rest_hp > 0
  3523.         return enemy
  3524.       end
  3525.     end
  3526.     # 敵が全滅している場合、再度敵の検索を行う
  3527.     return smooth_target_enemy_rtab(enemy_index)
  3528.   end
  3529. end

  3530. #==============================================================================
  3531. # ■ Sprite_Battler
  3532. #------------------------------------------------------------------------------
  3533. #  バトラー表示用のスプライトです。Game_Battler クラスのインスタンスを監視し、
  3534. # スプライトの状態を自動的に変化させます。
  3535. #==============================================================================

  3536. class Sprite_Battler < RPG::Sprite
  3537.   #--------------------------------------------------------------------------
  3538.   # ● フレーム更新
  3539.   #--------------------------------------------------------------------------
  3540.   def update
  3541.     super
  3542.     # バトラーが nil の場合
  3543.     if @battler == nil
  3544.       self.bitmap = nil
  3545.       loop_animation(nil)
  3546.       return
  3547.     end
  3548.     # ファイル名か色相が現在のものと異なる場合
  3549.     if @battler.battler_name != @battler_name or
  3550.        @battler.battler_hue != @battler_hue
  3551.       # ビットマップを取得、設定
  3552.       @battler_name = @battler.battler_name
  3553.       @battler_hue = @battler.battler_hue
  3554.       self.bitmap = RPG::Cache.battler(@battler_name, @battler_hue)
  3555.       @width = bitmap.width
  3556.       @height = bitmap.height
  3557.       self.ox = @width / 2
  3558.       self.oy = @height
  3559.       if @battler.is_a?(Game_Enemy)
  3560.         @battler.height = @height
  3561.       end
  3562.       # 戦闘不能または隠れ状態なら不透明度を 0 にする
  3563.       if @battler.dead? or @battler.hidden
  3564.         self.opacity = 0
  3565.       end
  3566.     end
  3567.     # アニメーション ID が現在のものと異なる場合
  3568.     if @battler.state_animation_id != @state_animation_id
  3569.       @state_animation_id = @battler.state_animation_id
  3570.       loop_animation($data_animations[@state_animation_id])
  3571.     end
  3572.     # 表示されるべきアクターの場合
  3573.     if @battler.is_a?(Game_Actor) and @battler_visible
  3574.       # メインフェーズでないときは不透明度をやや下げる
  3575.       if $game_temp.battle_main_phase
  3576.         self.opacity += 3 if self.opacity < 255
  3577.       else
  3578.         self.opacity -= 3 if self.opacity > 207
  3579.       end
  3580.     end
  3581.     # 明滅
  3582.     if @battler.blink
  3583.       blink_on
  3584.     else
  3585.       blink_off
  3586.     end
  3587.     # 不可視の場合
  3588.     unless @battler_visible
  3589.       # 出現
  3590.       if not @battler.hidden and not @battler.dead? and
  3591.          (@battler.damage.size < 2 or @battler.damage_pop.size < 2)
  3592.         appear
  3593.         @battler_visible = true
  3594.       end
  3595.     end
  3596.     # ダメージ
  3597.     for battler in @battler.damage_pop
  3598.       if battler[0].class == Array
  3599.         if battler[0][1] >= 0
  3600.           $scene.skill_se
  3601.         else
  3602.           $scene.levelup_se
  3603.         end
  3604.         damage(@battler.damage[battler[0]], false, 2)
  3605.       else
  3606.         damage(@battler.damage[battler[0]], @battler.critical[battler[0]])
  3607.       end
  3608.       if @battler.damage_sp.include?(battler[0])
  3609.         damage(@battler.damage_sp[battler[0]],
  3610.                 @battler.critical[battler[0]], 1)
  3611.         @battler.damage_sp.delete(battler[0])
  3612.       end
  3613.       @battler.damage_pop.delete(battler[0])
  3614.       @battler.damage.delete(battler[0])
  3615.       @battler.critical.delete(battler[0])
  3616.     end
  3617.     # 可視の場合
  3618.     if @battler_visible
  3619.       # 逃走
  3620.       if @battler.hidden
  3621.         $game_system.se_play($data_system.escape_se)
  3622.         escape
  3623.         @battler_visible = false
  3624.       end
  3625.       # 白フラッシュ
  3626.       if @battler.white_flash
  3627.         whiten
  3628.         @battler.white_flash = false
  3629.       end
  3630.       # アニメーション
  3631.       unless @battler.animation.empty?
  3632.         for animation in @battler.animation.reverse
  3633.           animation($data_animations[animation[0]], animation[1])
  3634.           @battler.animation.delete(animation)
  3635.         end
  3636.       end
  3637.       # コラプス
  3638.       if @battler.damage.empty? and @battler.dead?
  3639.         if $scene.dead_ok?(@battler)
  3640.           if @battler.is_a?(Game_Enemy)
  3641.             $game_system.se_play($data_system.enemy_collapse_se)
  3642.           else
  3643.             $game_system.se_play($data_system.actor_collapse_se)
  3644.           end
  3645.           collapse
  3646.           @battler_visible = false
  3647.         end
  3648.       end
  3649.     end
  3650.     # スプライトの座標を設定
  3651.     self.x = @battler.screen_x
  3652.     self.y = @battler.screen_y
  3653.     self.z = @battler.screen_z
  3654.     if @battler.is_a?(Game_Enemy)
  3655.       self.zoom_x = @battler.real_zoom * @battler.zoom
  3656.       self.zoom_y = @battler.real_zoom * @battler.zoom
  3657.     end
  3658.   end
  3659. end

  3660. #==============================================================================
  3661. # ■ Window_Base
  3662. #------------------------------------------------------------------------------
  3663. #  ゲーム中のすべてのウィンドウのスーパークラスです。
  3664. #==============================================================================

  3665. class Window_Base < Window
  3666.   #--------------------------------------------------------------------------
  3667.   # ● ゲージの描画
  3668.   #--------------------------------------------------------------------------
  3669.   def gauge_rect_at(width, height, align3,
  3670.                     color1, color2, color3, color4, color5, color6, color7,
  3671.                     color8, color9, color10, color11, color12, grade1, grade2)
  3672.     # 枠描画
  3673.     @at_gauge = Bitmap.new(width, height * 5)
  3674.     @at_gauge.fill_rect(0, 0, width, height, color1)
  3675.     @at_gauge.fill_rect(1, 1, width - 2, height - 2, color2)
  3676.     if (align3 == 1 and grade1 == 0) or grade1 > 0
  3677.       color = color3
  3678.       color3 = color4
  3679.       color4 = color
  3680.     end
  3681.     if (align3 == 1 and grade2 == 0) or grade2 > 0
  3682.       color = color5
  3683.       color5 = color6
  3684.       color6 = color
  3685.       color = color7
  3686.       color7 = color8
  3687.       color8 = color
  3688.       color = color9
  3689.       color9 = color10
  3690.       color10 = color
  3691.       color = color11
  3692.       color11 = color12
  3693.       color12 = color
  3694.     end
  3695.     if align3 == 0
  3696.       if grade1 == 2
  3697.         grade1 = 3
  3698.       end
  3699.       if grade2 == 2
  3700.         grade2 = 3
  3701.       end
  3702.     end
  3703.     # 空ゲージの描画 縦にグラデーション表示
  3704.     @at_gauge.gradation_rect(2, 2, width - 4, height - 4,
  3705.                                   color3, color4, grade1)
  3706.     # 実ゲージの描画
  3707.     @at_gauge.gradation_rect(2, height + 2, width- 4, height - 4,
  3708.                                   color5, color6, grade2)
  3709.     @at_gauge.gradation_rect(2, height * 2 + 2, width- 4, height - 4,
  3710.                                   color7, color8, grade2)
  3711.     @at_gauge.gradation_rect(2, height * 3 + 2, width- 4, height - 4,
  3712.                                   color9, color10, grade2)
  3713.     @at_gauge.gradation_rect(2, height * 4 + 2, width- 4, height - 4,
  3714.                                   color11, color12, grade2)
  3715.   end
  3716. end

  3717. #==============================================================================
  3718. # ■ Window_Help
  3719. #------------------------------------------------------------------------------
  3720. #  スキルやアイテムの説明、アクターのステータスなどを表示するウィンドウです。
  3721. #==============================================================================

  3722. class Window_Help < Window_Base
  3723.   #--------------------------------------------------------------------------
  3724.   # ● エネミー設定
  3725.   #     enemy : 名前とステートを表示するエネミー
  3726.   #--------------------------------------------------------------------------
  3727.   def set_enemy(enemy)
  3728.     text = enemy.name.sub(/\\[Ff]\[([0-9]+)\]/) {""}
  3729.     state_text = make_battler_state_text(enemy, 112, false)
  3730.     if state_text != ""
  3731.       text += "  " + state_text
  3732.     end
  3733.     set_text(text, 1)
  3734.   end
  3735. end

  3736. #==============================================================================
  3737. # ■ Window_BattleStatus
  3738. #------------------------------------------------------------------------------
  3739. #  バトル画面でパーティメンバーのステータスを表示するウィンドウです。
  3740. #==============================================================================

  3741. class Window_BattleStatus < Window_Base
  3742.   #--------------------------------------------------------------------------
  3743.   # ● オブジェクト初期化
  3744.   #--------------------------------------------------------------------------
  3745.   def initialize
  3746.     x = (4 - $game_party.actors.size) * 80
  3747.     width = $game_party.actors.size * 160
  3748.     super(x, 320, width, 160)
  3749.     self.back_opacity = 160
  3750.     @actor_window = []
  3751.     for i in 0...$game_party.actors.size
  3752.       @actor_window.push(Window_ActorStatus.new(i, x + i * 160))
  3753.     end
  3754.     @level_up_flags = [false, false, false, false]
  3755.     refresh
  3756.   end
  3757.   #--------------------------------------------------------------------------
  3758.   # ● 解放
  3759.   #--------------------------------------------------------------------------
  3760.   def dispose
  3761.     for window in @actor_window
  3762.       window.dispose
  3763.     end
  3764.     super
  3765.   end
  3766.   #--------------------------------------------------------------------------
  3767.   # ● リフレッシュ
  3768.   #--------------------------------------------------------------------------
  3769.   def refresh(number = 0)
  3770.     if number == 0
  3771.       cnt = 0
  3772.       for window in @actor_window
  3773.         window.refresh(@level_up_flags[cnt])
  3774.         cnt += 1
  3775.       end
  3776.     else
  3777.       @actor_window[number - 1].refresh(@level_up_flags[number - 1])
  3778.     end
  3779.   end
  3780.   #--------------------------------------------------------------------------
  3781.   # ● ATゲージリフレッシュ
  3782.   #--------------------------------------------------------------------------
  3783.   def at_refresh(number = 0)
  3784.     if number == 0
  3785.       for window in @actor_window
  3786.         window.at_refresh
  3787.       end
  3788.     else
  3789.       @actor_window[number - 1].at_refresh
  3790.     end
  3791.   end
  3792.   #--------------------------------------------------------------------------
  3793.   # ● フレーム更新
  3794.   #--------------------------------------------------------------------------
  3795.   def update
  3796.     super
  3797.     if self.x != (4 - $game_party.actors.size) * 80
  3798.       self.x = (4 - $game_party.actors.size) * 80
  3799.       self.width = $game_party.actors.size * 160
  3800.       for window in @actor_window
  3801.         window.dispose
  3802.       end
  3803.       @actor_window = []
  3804.       for i in 0...$game_party.actors.size
  3805.         @actor_window.push(Window_ActorStatus.new(i, x + i * 160))
  3806.       end
  3807.       refresh
  3808.     end
  3809.     for window in @actor_window
  3810.       window.update
  3811.     end
  3812.   end
  3813. end

  3814. #==============================================================================
  3815. # ■ Window_ActorStatus
  3816. #------------------------------------------------------------------------------
  3817. #  バトル画面でパーティメンバーのステータスをそれぞれ表示するウィンドウです。
  3818. #==============================================================================

  3819. class Window_ActorStatus < Window_Base
  3820.   #--------------------------------------------------------------------------
  3821.   # ● オブジェクト初期化
  3822.   #--------------------------------------------------------------------------
  3823.   def initialize(id, x)
  3824.     @actor_num = id
  3825.     super(x, 320, 160, 160)
  3826.     self.contents = Bitmap.new(width - 32, height - 32)
  3827.     self.opacity = 0
  3828.     self.back_opacity = 0
  3829.     actor = $game_party.actors[@actor_num]
  3830.     @actor_nm = actor.name
  3831.     @actor_mhp = actor.maxhp
  3832.     @actor_msp = actor.maxsp
  3833.     @actor_hp = actor.hp
  3834.     @actor_sp = actor.sp
  3835.     @actor_st = make_battler_state_text(actor, 120, true)
  3836.     @status_window = []
  3837.     for i in 0...5
  3838.       @status_window.push(Window_DetailsStatus.new(actor, i, x))
  3839.     end
  3840.     refresh(false)
  3841.   end
  3842.   #--------------------------------------------------------------------------
  3843.   # ● 解放
  3844.   #--------------------------------------------------------------------------
  3845.   def dispose
  3846.     for i in 0...5
  3847.       @status_window[i].dispose
  3848.     end
  3849.     super
  3850.   end
  3851.   #--------------------------------------------------------------------------
  3852.   # ● リフレッシュ
  3853.   #--------------------------------------------------------------------------
  3854.   def refresh(level_up_flags)
  3855.     self.contents.clear
  3856.     actor = $game_party.actors[@actor_num]
  3857.     @status_window[0].refresh(actor) if @actor_nm != actor.name
  3858.     @status_window[1].refresh(actor) if
  3859.       @actor_mhp != actor.maxhp or @actor_hp != actor.hp
  3860.     @status_window[2].refresh(actor) if
  3861.       @actor_msp != actor.maxsp or @actor_sp != actor.sp
  3862.     @status_window[3].refresh(actor, level_up_flags) if
  3863.       @actor_st != make_battler_state_text(actor, 120, true) or level_up_flags
  3864.     @actor_nm = actor.name
  3865.     @actor_mhp = actor.maxhp
  3866.     @actor_msp = actor.maxsp
  3867.     @actor_hp = actor.hp
  3868.     @actor_sp = actor.sp
  3869.     @actor_st = make_battler_state_text(actor, 120, true)
  3870.   end
  3871.   #--------------------------------------------------------------------------
  3872.   # ● ATゲージリフレッシュ
  3873.   #--------------------------------------------------------------------------
  3874.   def at_refresh
  3875.     @status_window[4].refresh($game_party.actors[@actor_num])
  3876.   end
  3877.   #--------------------------------------------------------------------------
  3878.   # ● フレーム更新
  3879.   #--------------------------------------------------------------------------
  3880.   def update
  3881.     for window in @status_window
  3882.       window.update
  3883.     end
  3884.   end
  3885. end

  3886. #==============================================================================
  3887. # ■ Window_DetailsStatus
  3888. #------------------------------------------------------------------------------
  3889. #  バトル画面でアクターのステータスを個々に表示するウィンドウです。
  3890. #==============================================================================

  3891. class Window_DetailsStatus < Window_Base
  3892.   #--------------------------------------------------------------------------
  3893.   # ● オブジェクト初期化
  3894.   #--------------------------------------------------------------------------
  3895.   def initialize(actor, id, x)
  3896.     @status_id = id
  3897.     super(x, 320 + id * 26, 160, 64)
  3898.     self.contents = Bitmap.new(width - 32, height - 32)
  3899.     self.opacity = 0
  3900.     self.back_opacity = 0
  3901.     refresh(actor, false)
  3902.   end
  3903.   #--------------------------------------------------------------------------
  3904.   # ● 解放
  3905.   #--------------------------------------------------------------------------
  3906.   def dispose
  3907.     super
  3908.   end
  3909.   #--------------------------------------------------------------------------
  3910.   # ● リフレッシュ
  3911.   #--------------------------------------------------------------------------
  3912.   def refresh(actor, level_up_flags = false)
  3913.     self.contents.clear
  3914.     case @status_id
  3915.     when 0
  3916.       draw_actor_name(actor, 4, 0)
  3917.     when 1
  3918.       draw_actor_hp(actor, 4, 0, 120)
  3919.     when 2
  3920.       draw_actor_sp(actor, 4, 0, 120)
  3921.     when 3
  3922.       if level_up_flags
  3923.         self.contents.font.color = normal_color
  3924.         self.contents.draw_text(4, 0, 120, 32, "LEVEL UP!")
  3925.       else
  3926.         draw_actor_state(actor, 4, 0)
  3927.       end
  3928.     when 4
  3929.       draw_actor_atg(actor, 4, 0, 120)
  3930.     end
  3931.   end
  3932.   #--------------------------------------------------------------------------
  3933.   # ● フレーム更新
  3934.   #--------------------------------------------------------------------------
  3935.   def update
  3936.     # メインフェーズのときは不透明度をやや下げる
  3937.     if $game_temp.battle_main_phase
  3938.       self.contents_opacity -= 4 if self.contents_opacity > 191
  3939.     else
  3940.       self.contents_opacity += 4 if self.contents_opacity < 255
  3941.     end
  3942.   end
  3943. end

  3944. #==============================================================================
  3945. # ■ Arrow_Base
  3946. #------------------------------------------------------------------------------
  3947. #  バトル画面で使用するアローカーソル表示用のスプライトです。このクラスは
  3948. # Arrow_Enemy クラスと Arrow_Actor クラスのスーパークラスとして使用されます。
  3949. #==============================================================================

  3950. class Arrow_Base < Sprite
  3951.   #--------------------------------------------------------------------------
  3952.   # ● オブジェクト初期化
  3953.   #     viewport : ビューポート
  3954.   #--------------------------------------------------------------------------
  3955.   def initialize(viewport)
  3956.     super(viewport)
  3957.     self.bitmap = RPG::Cache.windowskin($game_system.windowskin_name)
  3958.     self.ox = 16
  3959.     self.oy = 32
  3960.     self.z = 2500
  3961.     @blink_count = 0
  3962.     @index = 0
  3963.     @help_window = nil
  3964.     update
  3965.   end
  3966. end

  3967. #==============================================================================
  3968. # ■ Arrow_Enemy
  3969. #------------------------------------------------------------------------------
  3970. #  エネミーを選択させるためのアローカーソルです。このクラスは Arrow_Base クラ
  3971. # スを継承します。
  3972. #==============================================================================

  3973. class Arrow_Enemy < Arrow_Base
  3974.   #--------------------------------------------------------------------------
  3975.   # ● フレーム更新
  3976.   #--------------------------------------------------------------------------
  3977.   def update
  3978.     super
  3979.     # 存在しないエネミーを指していたら飛ばす
  3980.     $game_troop.enemies.size.times do
  3981.       break if self.enemy.exist?
  3982.       @index += 1
  3983.       @index %= $game_troop.enemies.size
  3984.     end
  3985.     # カーソル右
  3986.     if Input.repeat?(Input::RIGHT)
  3987.       $game_system.se_play($data_system.cursor_se)
  3988.       $game_troop.enemies.size.times do
  3989.         @index += 1
  3990.         @index %= $game_troop.enemies.size
  3991.         break if self.enemy.exist?
  3992.       end
  3993.       $scene.camera = "select"
  3994.       zoom = 1 / self.enemy.zoom
  3995.       $scene.spriteset.screen_target(self.enemy.attack_x(zoom) * 0.75,
  3996.                                       self.enemy.attack_y(zoom) * 0.75, zoom)
  3997.     end
  3998.     # カーソル左
  3999.     if Input.repeat?(Input::LEFT)
  4000.       $game_system.se_play($data_system.cursor_se)
  4001.       $game_troop.enemies.size.times do
  4002.         @index += $game_troop.enemies.size - 1
  4003.         @index %= $game_troop.enemies.size
  4004.         break if self.enemy.exist?
  4005.       end
  4006.       $scene.camera = "select"
  4007.       zoom = 1 / self.enemy.zoom
  4008.       $scene.spriteset.screen_target(self.enemy.attack_x(zoom) * 0.75,
  4009.                                       self.enemy.attack_y(zoom) * 0.75, zoom)
  4010.     end
  4011.     # スプライトの座標を設定
  4012.     if self.enemy != nil
  4013.       self.x = self.enemy.screen_x
  4014.       self.y = self.enemy.screen_y
  4015.     end
  4016.   end
  4017. end

  4018. #==============================================================================
  4019. # ■ Interpreter
  4020. #------------------------------------------------------------------------------
  4021. #  イベントコマンドを実行するインタプリタです。このクラスは Game_System クラ
  4022. # スや Game_Event クラスの内部で使用されます。
  4023. #==============================================================================

  4024. class Interpreter
  4025.   #--------------------------------------------------------------------------
  4026.   # ● アクターの入れ替え
  4027.   #--------------------------------------------------------------------------
  4028.   def command_129
  4029.     # アクターを取得
  4030.     actor = $game_actors[@parameters[0]]
  4031.     # アクターが有効の場合
  4032.     if actor != nil
  4033.       # 操作で分岐
  4034.       if @parameters[1] == 0
  4035.         if @parameters[2] == 1
  4036.           $game_actors[@parameters[0]].setup(@parameters[0])
  4037.         end
  4038.         $game_party.add_actor(@parameters[0])
  4039.         if $game_temp.in_battle
  4040.           $game_actors[@parameters[0]].at = 0
  4041.           $game_actors[@parameters[0]].atp = 0
  4042.           $scene.spell_reset($game_actors[@parameters[0]])
  4043.           $game_actors[@parameters[0]].damage_pop = {}
  4044.           $game_actors[@parameters[0]].damage = {}
  4045.           $game_actors[@parameters[0]].damage_sp = {}
  4046.           $game_actors[@parameters[0]].critical = {}
  4047.           $game_actors[@parameters[0]].recover_hp = {}
  4048.           $game_actors[@parameters[0]].recover_sp = {}
  4049.           $game_actors[@parameters[0]].state_p = {}
  4050.           $game_actors[@parameters[0]].state_m = {}
  4051.           $game_actors[@parameters[0]].animation = []
  4052.         end
  4053.       else
  4054.         $game_party.remove_actor(@parameters[0])
  4055.       end
  4056.     end
  4057.     if $game_temp.in_battle
  4058.       $scene.status_window.update
  4059.     end
  4060.     # 継続
  4061.     return true
  4062.   end
  4063.   #--------------------------------------------------------------------------
  4064.   # ● HP の増減
  4065.   #--------------------------------------------------------------------------
  4066.   alias :command_311_rtab :command_311
  4067.   def command_311
  4068.     command_311_rtab
  4069.     if $game_temp.in_battle
  4070.       $scene.status_window.refresh
  4071.     end
  4072.   end
  4073.   #--------------------------------------------------------------------------
  4074.   # ● SP の増減
  4075.   #--------------------------------------------------------------------------
  4076.   alias :command_312_rtab :command_312
  4077.   def command_312
  4078.     command_312_rtab
  4079.     if $game_temp.in_battle
  4080.       $scene.status_window.refresh
  4081.     end
  4082.   end
  4083.   #--------------------------------------------------------------------------
  4084.   # ● ステートの変更
  4085.   #--------------------------------------------------------------------------
  4086.   alias :command_313_rtab :command_313
  4087.   def command_313
  4088.     command_313_rtab
  4089.     if $game_temp.in_battle
  4090.       $scene.status_window.refresh
  4091.     end
  4092.   end
  4093.   #--------------------------------------------------------------------------
  4094.   # ● 全回復
  4095.   #--------------------------------------------------------------------------
  4096.   alias :command_314_rtab :command_314
  4097.   def command_314
  4098.     command_314_rtab
  4099.     if $game_temp.in_battle
  4100.       $scene.status_window.refresh
  4101.     end
  4102.   end
  4103.   #--------------------------------------------------------------------------
  4104.   # ● EXP の増減
  4105.   #--------------------------------------------------------------------------
  4106.   alias :command_315_rtab :command_315
  4107.   def command_315
  4108.     command_315_rtab
  4109.     if $game_temp.in_battle
  4110.       $scene.status_window.refresh
  4111.     end
  4112.   end
  4113.   #--------------------------------------------------------------------------
  4114.   # ● レベルの増減
  4115.   #--------------------------------------------------------------------------
  4116.   alias :command_316_rtab :command_316
  4117.   def command_316
  4118.     command_316_rtab
  4119.     if $game_temp.in_battle
  4120.       $scene.status_window.refresh
  4121.     end
  4122.   end
  4123.   #--------------------------------------------------------------------------
  4124.   # ● パラメータの増減
  4125.   #--------------------------------------------------------------------------
  4126.   alias :command_317_rtab :command_317
  4127.   def command_317
  4128.     command_317_rtab
  4129.     if $game_temp.in_battle
  4130.       $scene.status_window.refresh
  4131.     end
  4132.   end
  4133.   #--------------------------------------------------------------------------
  4134.   # ● 装備の変更
  4135.   #--------------------------------------------------------------------------
  4136.   alias :command_319_rtab :command_319
  4137.   def command_319
  4138.     command_319_rtab
  4139.     if $game_temp.in_battle
  4140.       $scene.status_window.refresh
  4141.     end
  4142.   end
  4143.   #--------------------------------------------------------------------------
  4144.   # ● アクターの名前変更
  4145.   #--------------------------------------------------------------------------
  4146.   alias :command_320_rtab :command_320
  4147.   def command_320
  4148.     command_320_rtab
  4149.     if $game_temp.in_battle
  4150.       $scene.status_window.refresh
  4151.     end
  4152.   end
  4153.   #--------------------------------------------------------------------------
  4154.   # ● アクターのクラス変更
  4155.   #--------------------------------------------------------------------------
  4156.   alias :command_321_rtab :command_321
  4157.   def command_321
  4158.     command_321_rtab
  4159.     if $game_temp.in_battle
  4160.       $scene.status_window.refresh
  4161.     end
  4162.   end
  4163.   #--------------------------------------------------------------------------
  4164.   # ● アニメーションの表示
  4165.   #--------------------------------------------------------------------------
  4166.   def command_337
  4167.     # イテレータで処理
  4168.     iterate_battler(@parameters[0], @parameters[1]) do |battler|
  4169.       # バトラーが存在する場合
  4170.       if battler.exist?
  4171.         # アニメーション ID を設定
  4172.         battler.animation.push([@parameters[2], true])
  4173.       end
  4174.     end
  4175.     # 継続
  4176.     return true
  4177.   end
  4178.   #--------------------------------------------------------------------------
  4179.   # ● ダメージの処理
  4180.   #--------------------------------------------------------------------------
  4181.   def command_338
  4182.     # 操作する値を取得
  4183.     value = operate_value(0, @parameters[2], @parameters[3])
  4184.     # イテレータで処理
  4185.     iterate_battler(@parameters[0], @parameters[1]) do |battler|
  4186.       # バトラーが存在する場合
  4187.       if battler.exist?
  4188.         # HP を変更
  4189.         battler.hp -= value
  4190.         # 戦闘中なら
  4191.         if $game_temp.in_battle
  4192.           # ダメージを設定
  4193.           battler.damage["event"] = value
  4194.           battler.damage_pop["event"] = true
  4195.         end
  4196.       end
  4197.     end
  4198.     if $game_temp.in_battle
  4199.       $scene.status_window.refresh
  4200.     end
  4201.     # 継続
  4202.     return true
  4203.   end
  4204.   #--------------------------------------------------------------------------
  4205.   # ● アクションの強制
  4206.   #--------------------------------------------------------------------------
  4207.   def command_339
  4208.     # 戦闘中でなければ無視
  4209.     unless $game_temp.in_battle
  4210.       return true
  4211.     end
  4212.     # ターン数が 0 なら無視
  4213.     if $game_temp.battle_turn == 0
  4214.       return true
  4215.     end
  4216.     # イテレータで処理 (便宜的なもので、複数になることはない)
  4217.     iterate_battler(@parameters[0], @parameters[1]) do |battler|
  4218.       # バトラーが存在する場合
  4219.       if battler.exist?
  4220.         # アクションを設定
  4221.         battler.current_action.force_kind = @parameters[2]
  4222.         if battler.current_action.force_kind == 0
  4223.           battler.current_action.force_basic = @parameters[3]
  4224.         else
  4225.           battler.current_action.force_skill_id = @parameters[3]
  4226.         end
  4227.         # 行動対象を設定
  4228.         if @parameters[4] == -2
  4229.           if battler.is_a?(Game_Enemy)
  4230.             battler.current_action.decide_last_target_for_enemy
  4231.           else
  4232.             battler.current_action.decide_last_target_for_actor
  4233.           end
  4234.         elsif @parameters[4] == -1
  4235.           if battler.is_a?(Game_Enemy)
  4236.             battler.current_action.decide_random_target_for_enemy
  4237.           else
  4238.             battler.current_action.decide_random_target_for_actor
  4239.           end
  4240.         elsif @parameters[4] >= 0
  4241.           battler.current_action.target_index = @parameters[4]
  4242.         end
  4243.         # アクションが有効かつ [すぐに実行] の場合
  4244.         if battler.current_action.valid? and @parameters[5] == 1
  4245.           # 強制対象のバトラーを設定
  4246.           $game_temp.forcing_battler = battler
  4247.           # インデックスを進める
  4248.           @index += 1
  4249.           # 終了
  4250.           return false
  4251.         elsif battler.current_action.valid? and @parameters[5] == 0
  4252.           battler.current_action.forcing = true
  4253.         end
  4254.       end
  4255.     end
  4256.     # 継続
  4257.     return true
  4258.   end
  4259. end

  4260. #==============================================================================
  4261. # ■ Spriteモジュール
  4262. #------------------------------------------------------------------------------
  4263. #  アニメーションの管理を行うモジュールです。
  4264. #==============================================================================

  4265. module RPG
  4266.   class Sprite < ::Sprite
  4267.     def initialize(viewport = nil)
  4268.       super(viewport)
  4269.       @_whiten_duration = 0
  4270.       @_appear_duration = 0
  4271.       @_escape_duration = 0
  4272.       @_collapse_duration = 0
  4273.       @_damage = []
  4274.       @_animation = []
  4275.       @_animation_duration = 0
  4276.       @_blink = false
  4277.     end
  4278.     def damage(value, critical, type = 0)
  4279.       if value.is_a?(Numeric)
  4280.         damage_string = value.abs.to_s
  4281.       else
  4282.         damage_string = value.to_s
  4283.       end
  4284.       bitmap = Bitmap.new(160, 48)
  4285.       bitmap.font.name = "Arial Black"
  4286.       bitmap.font.size = 32
  4287.       bitmap.font.color.set(0, 0, 0)
  4288.       bitmap.draw_text(-1, 12-1, 160, 36, damage_string, 1)
  4289.       bitmap.draw_text(+1, 12-1, 160, 36, damage_string, 1)
  4290.       bitmap.draw_text(-1, 12+1, 160, 36, damage_string, 1)
  4291.       bitmap.draw_text(+1, 12+1, 160, 36, damage_string, 1)
  4292.       if value.is_a?(Numeric) and value < 0
  4293.         if type == 0
  4294.           bitmap.font.color.set(176, 255, 144)
  4295.         else
  4296.           bitmap.font.color.set(176, 144, 255)
  4297.         end
  4298.       else
  4299.         if type == 0
  4300.           bitmap.font.color.set(255, 255, 255)
  4301.         else
  4302.           bitmap.font.color.set(255, 176, 144)
  4303.         end
  4304.       end
  4305.       if type == 2
  4306.         bitmap.font.color.set(255, 224, 128)
  4307.       end
  4308.       bitmap.draw_text(0, 12, 160, 36, damage_string, 1)
  4309.       if critical
  4310.         string = "CRITICAL"
  4311.         bitmap.font.size = 20
  4312.         bitmap.font.color.set(0, 0, 0)
  4313.         bitmap.draw_text(-1, -1, 160, 20, string, 1)
  4314.         bitmap.draw_text(+1, -1, 160, 20, string, 1)
  4315.         bitmap.draw_text(-1, +1, 160, 20, string, 1)
  4316.         bitmap.draw_text(+1, +1, 160, 20, string, 1)
  4317.         bitmap.font.color.set(255, 255, 255)
  4318.         bitmap.draw_text(0, 0, 160, 20, string, 1)
  4319.       end
  4320.       num = @_damage.size
  4321.       if type != 2
  4322.         @_damage.push([::Sprite.new, 40, 0, rand(40) - 20, rand(30) + 50])
  4323.       else
  4324.         @_damage.push([::Sprite.new, 40, 0, rand(20) - 10, rand(20) + 60])
  4325.       end
  4326.       @_damage[num][0].bitmap = bitmap
  4327.       @_damage[num][0].ox = 80 + self.viewport.ox
  4328.       @_damage[num][0].oy = 20 + self.viewport.oy
  4329.       if self.battler.is_a?(Game_Actor)
  4330.         @_damage[num][0].x = self.x
  4331.         @_damage[num][0].y = self.y - self.oy / 2
  4332.       else
  4333.         @_damage[num][0].x = self.x + self.viewport.rect.x -
  4334.                             self.ox + self.src_rect.width / 2
  4335.         @_damage[num][0].y = self.y - self.oy * self.zoom_y / 2 +
  4336.                             self.viewport.rect.y
  4337.         @_damage[num][0].zoom_x = self.zoom_x
  4338.         @_damage[num][0].zoom_y = self.zoom_y
  4339.         @_damage[num][0].z = 3000
  4340.       end
  4341.     end
  4342.     def animation(animation, hit)
  4343.       return if animation == nil
  4344.       num = @_animation.size
  4345.       @_animation.push([animation, hit, animation.frame_max, []])
  4346.       bitmap = RPG::Cache.animation(animation.animation_name,
  4347.                                     animation.animation_hue)
  4348.       if @@_reference_count.include?(bitmap)
  4349.         @@_reference_count[bitmap] += 1
  4350.       else
  4351.         @@_reference_count[bitmap] = 1
  4352.       end
  4353.       if @_animation[num][0].position != 3 or
  4354.           not @@_animations.include?(animation)
  4355.         for i in 0..15
  4356.           sprite = ::Sprite.new
  4357.           sprite.bitmap = bitmap
  4358.           sprite.visible = false
  4359.           @_animation[num][3].push(sprite)
  4360.         end
  4361.         unless @@_animations.include?(animation)
  4362.           @@_animations.push(animation)
  4363.         end
  4364.       end
  4365.       update_animation(@_animation[num])
  4366.     end
  4367.     def loop_animation(animation)
  4368.       return if animation == @_loop_animation
  4369.       dispose_loop_animation
  4370.       @_loop_animation = animation
  4371.       return if @_loop_animation == nil
  4372.       @_loop_animation_index = 0
  4373.       animation_name = @_loop_animation.animation_name
  4374.       animation_hue = @_loop_animation.animation_hue
  4375.       bitmap = RPG::Cache.animation(animation_name, animation_hue)
  4376.       if @@_reference_count.include?(bitmap)
  4377.         @@_reference_count[bitmap] += 1
  4378.       else
  4379.         @@_reference_count[bitmap] = 1
  4380.       end
  4381.       @_loop_animation_sprites = []
  4382.       for i in 0..15
  4383.         sprite = ::Sprite.new
  4384.         sprite.bitmap = bitmap
  4385.         sprite.visible = false
  4386.         @_loop_animation_sprites.push(sprite)
  4387.       end
  4388.       # update_loop_animation
  4389.     end
  4390.     def dispose_damage
  4391.       for damage in @_damage.reverse
  4392.         damage[0].bitmap.dispose
  4393.         damage[0].dispose
  4394.         @_damage.delete(damage)
  4395.       end
  4396.     end
  4397.     def dispose_animation
  4398.       for anime in @_animation.reverse
  4399.         sprite = anime[3][0]
  4400.         if sprite != nil
  4401.           @@_reference_count[sprite.bitmap] -= 1
  4402.           if @@_reference_count[sprite.bitmap] == 0
  4403.             sprite.bitmap.dispose
  4404.           end
  4405.         end
  4406.         for sprite in anime[3]
  4407.           sprite.dispose
  4408.         end
  4409.         @_animation.delete(anime)
  4410.       end
  4411.     end
  4412.     def effect?
  4413.       @_whiten_duration > 0 or
  4414.       @_appear_duration > 0 or
  4415.       @_escape_duration > 0 or
  4416.       @_collapse_duration > 0 or
  4417.       @_damage.size == 0 or
  4418.       @_animation.size == 0
  4419.     end
  4420.     def update
  4421.       super
  4422.       if @_whiten_duration > 0
  4423.         @_whiten_duration -= 1
  4424.         self.color.alpha = 128 - (16 - @_whiten_duration) * 10
  4425.       end
  4426.       if @_appear_duration > 0
  4427.         @_appear_duration -= 1
  4428.         self.opacity = (16 - @_appear_duration) * 16
  4429.       end
  4430.       if @_escape_duration > 0
  4431.         @_escape_duration -= 1
  4432.         self.opacity = 256 - (32 - @_escape_duration) * 10
  4433.       end
  4434.       if @_collapse_duration > 0
  4435.         @_collapse_duration -= 1
  4436.         self.opacity = 256 - (48 - @_collapse_duration) * 6
  4437.       end
  4438.       for damage in @_damage
  4439.         if damage[1] > 0
  4440.           damage[1] -= 1
  4441.           damage[4] -= 3
  4442.           damage[2] -= damage[4]
  4443.           if self.battler.is_a?(Game_Actor)
  4444.             damage[0].x = self.x + (40 - damage[1]) * damage[3] / 10
  4445.             damage[0].y = self.y - self.oy / 2 + damage[2] / 10
  4446.           else
  4447.             damage[0].x = self.x + self.viewport.rect.x -
  4448.                           self.ox + self.src_rect.width / 2 +
  4449.                           (40 - damage[1]) * damage[3] / 10
  4450.             damage[0].y = self.y - self.oy * self.zoom_y / 2 +
  4451.                           self.viewport.rect.y + damage[2] / 10
  4452.             damage[0].zoom_x = self.zoom_x
  4453.             damage[0].zoom_y = self.zoom_y
  4454.           end
  4455.           damage[0].z = 2960 + damage[1]
  4456.           damage[0].opacity = 256 - (12 - damage[1]) * 32
  4457.           if damage[1] == 0
  4458.             damage[0].bitmap.dispose
  4459.             damage[0].dispose
  4460.             @_damage.delete(damage)
  4461.           end
  4462.         end
  4463.       end
  4464.       for anime in @_animation
  4465.         if (Graphics.frame_count % 2 == 0)
  4466.           anime[2] -= 1
  4467.           update_animation(anime)
  4468.         end
  4469.       end
  4470.       if @_loop_animation != nil and (Graphics.frame_count % 2 == 0)
  4471.         update_loop_animation
  4472.         @_loop_animation_index += 1
  4473.         @_loop_animation_index %= @_loop_animation.frame_max
  4474.       end
  4475.       if @_blink
  4476.         @_blink_count = (@_blink_count + 1) % 32
  4477.         if @_blink_count < 16
  4478.           alpha = (16 - @_blink_count) * 6
  4479.         else
  4480.           alpha = (@_blink_count - 16) * 6
  4481.         end
  4482.         self.color.set(255, 255, 255, alpha)
  4483.       end
  4484.       @@_animations.clear
  4485.     end
  4486.     def update_animation(anime)
  4487.       if anime[2] > 0
  4488.         frame_index = anime[0].frame_max - anime[2]
  4489.         cell_data = anime[0].frames[frame_index].cell_data
  4490.         position = anime[0].position
  4491.         animation_set_sprites(anime[3], cell_data, position)
  4492.         for timing in anime[0].timings
  4493.           if timing.frame == frame_index
  4494.             animation_process_timing(timing, anime[1])
  4495.           end
  4496.         end
  4497.       else
  4498.         @@_reference_count[anime[3][0].bitmap] -= 1
  4499.         if @@_reference_count[anime[3][0].bitmap] == 0
  4500.             anime[3][0].bitmap.dispose
  4501.         end
  4502.         for sprite in anime[3]
  4503.           sprite.dispose
  4504.         end
  4505.         @_animation.delete(anime)
  4506.       end
  4507.     end
  4508.     def animation_set_sprites(sprites, cell_data, position)
  4509.       for i in 0..15
  4510.         sprite = sprites[i]
  4511.         pattern = cell_data[i, 0]
  4512.         if sprite == nil or pattern == nil or pattern == -1
  4513.           sprite.visible = false if sprite != nil
  4514.           next
  4515.         end
  4516.         sprite.visible = true
  4517.         sprite.src_rect.set(pattern % 5 * 192, pattern / 5 * 192, 192, 192)
  4518.         if position == 3
  4519.           if self.viewport != nil
  4520.             sprite.x = self.viewport.rect.width / 2
  4521.             if $game_temp.in_battle and self.battler.is_a?(Game_Enemy)
  4522.               sprite.y = self.viewport.rect.height - 320
  4523.             else
  4524.               sprite.y = self.viewport.rect.height - 160
  4525.             end
  4526.           else
  4527.             sprite.x = 320
  4528.             sprite.y = 240
  4529.           end
  4530.         else
  4531.           sprite.x = self.x + self.viewport.rect.x -
  4532.                       self.ox + self.src_rect.width / 2
  4533.           if $game_temp.in_battle and self.battler.is_a?(Game_Enemy)
  4534.             sprite.y = self.y - self.oy * self.zoom_y / 2 +
  4535.                         self.viewport.rect.y
  4536.             if position == 0
  4537.               sprite.y -= self.src_rect.height * self.zoom_y / 4
  4538.             elsif position == 2
  4539.               sprite.y += self.src_rect.height * self.zoom_y / 4
  4540.             end
  4541.           else
  4542.             sprite.y = self.y + self.viewport.rect.y -
  4543.                         self.oy + self.src_rect.height / 2
  4544.             sprite.y -= self.src_rect.height / 4 if position == 0
  4545.             sprite.y += self.src_rect.height / 4 if position == 2
  4546.           end
  4547.         end
  4548.         sprite.x += cell_data[i, 1]
  4549.         sprite.y += cell_data[i, 2]
  4550.         sprite.z = 2000
  4551.         sprite.ox = 96
  4552.         sprite.oy = 96
  4553.         sprite.zoom_x = cell_data[i, 3] / 100.0
  4554.         sprite.zoom_y = cell_data[i, 3] / 100.0
  4555.         if position != 3
  4556.           sprite.zoom_x *= self.zoom_x
  4557.           sprite.zoom_y *= self.zoom_y
  4558.         end
  4559.         sprite.angle = cell_data[i, 4]
  4560.         sprite.mirror = (cell_data[i, 5] == 1)
  4561.         sprite.opacity = cell_data[i, 6] * self.opacity / 255.0
  4562.         sprite.blend_type = cell_data[i, 7]
  4563.       end
  4564.     end
  4565.     def x=(x)
  4566.       sx = x - self.x
  4567.       if sx != 0
  4568.         for anime in @_animation
  4569.           if anime[3] != nil
  4570.             for i in 0..15
  4571.               anime[3][i].x += sx
  4572.             end
  4573.           end
  4574.         end
  4575.         if @_loop_animation_sprites != nil
  4576.           for i in 0..15
  4577.             @_loop_animation_sprites[i].x += sx
  4578.           end
  4579.         end
  4580.       end
  4581.       super
  4582.     end
  4583.     def y=(y)
  4584.       sy = y - self.y
  4585.       if sy != 0
  4586.         for anime in @_animation
  4587.           if anime[3] != nil
  4588.             for i in 0..15
  4589.               anime[3][i].y += sy
  4590.             end
  4591.           end
  4592.         end
  4593.         if @_loop_animation_sprites != nil
  4594.           for i in 0..15
  4595.             @_loop_animation_sprites[i].y += sy
  4596.           end
  4597.         end
  4598.       end
  4599.       super
  4600.     end
  4601.   end
  4602. end

  4603. #------------------------------------------------------------------------------
  4604. #  Bitmapクラスに新たな機能を追加します。
  4605. #==============================================================================

  4606. class Bitmap
  4607.   #--------------------------------------------------------------------------
  4608.   # ● 矩形をグラデーション表示
  4609.   #     color1 : スタートカラー
  4610.   #     color2 : エンドカラー
  4611.   #     align  :  0:横にグラデーション
  4612.   #               1:縦にグラデーション
  4613.   #               2:斜めにグラデーション(激重につき注意)
  4614.   #--------------------------------------------------------------------------
  4615.   def gradation_rect(x, y, width, height, color1, color2, align = 0)
  4616.     if align == 0
  4617.       for i in x...x + width
  4618.         red   = color1.red + (color2.red - color1.red) * (i - x) / (width - 1)
  4619.         green = color1.green +
  4620.                 (color2.green - color1.green) * (i - x) / (width - 1)
  4621.         blue  = color1.blue +
  4622.                 (color2.blue - color1.blue) * (i - x) / (width - 1)
  4623.         alpha = color1.alpha +
  4624.                 (color2.alpha - color1.alpha) * (i - x) / (width - 1)
  4625.         color = Color.new(red, green, blue, alpha)
  4626.         fill_rect(i, y, 1, height, color)
  4627.       end
  4628.     elsif align == 1
  4629.       for i in y...y + height
  4630.         red   = color1.red +
  4631.                 (color2.red - color1.red) * (i - y) / (height - 1)
  4632.         green = color1.green +
  4633.                 (color2.green - color1.green) * (i - y) / (height - 1)
  4634.         blue  = color1.blue +
  4635.                 (color2.blue - color1.blue) * (i - y) / (height - 1)
  4636.         alpha = color1.alpha +
  4637.                 (color2.alpha - color1.alpha) * (i - y) / (height - 1)
  4638.         color = Color.new(red, green, blue, alpha)
  4639.         fill_rect(x, i, width, 1, color)
  4640.       end
  4641.     elsif align == 2
  4642.       for i in x...x + width
  4643.         for j in y...y + height
  4644.           red   = color1.red + (color2.red - color1.red) *
  4645.                   ((i - x) / (width - 1.0) + (j - y) / (height - 1.0)) / 2
  4646.           green = color1.green + (color2.green - color1.green) *
  4647.                   ((i - x) / (width - 1.0) + (j - y) / (height - 1.0)) / 2
  4648.           blue  = color1.blue + (color2.blue - color1.blue) *
  4649.                   ((i - x) / (width - 1.0) + (j - y) / (height - 1.0)) / 2
  4650.           alpha = color1.alpha + (color2.alpha - color1.alpha) *
  4651.                   ((i - x) / (width - 1.0) + (j - y) / (height - 1.0)) / 2
  4652.           color = Color.new(red, green, blue, alpha)
  4653.           set_pixel(i, j, color)
  4654.         end
  4655.       end
  4656.     elsif align == 3
  4657.       for i in x...x + width
  4658.         for j in y...y + height
  4659.           red   = color1.red + (color2.red - color1.red) *
  4660.               ((x + width - i) / (width - 1.0) + (j - y) / (height - 1.0)) / 2
  4661.           green = color1.green + (color2.green - color1.green) *
  4662.               ((x + width - i) / (width - 1.0) + (j - y) / (height - 1.0)) / 2
  4663.           blue  = color1.blue + (color2.blue - color1.blue) *
  4664.               ((x + width - i) / (width - 1.0) + (j - y) / (height - 1.0)) / 2
  4665.           alpha = color1.alpha + (color2.alpha - color1.alpha) *
  4666.               ((x + width - i) / (width - 1.0) + (j - y) / (height - 1.0)) / 2
  4667.           color = Color.new(red, green, blue, alpha)
  4668.           set_pixel(i, j, color)
  4669.         end
  4670.       end
  4671.     end
  4672.     end
  4673.       end
复制代码
回复

使用道具 举报

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

本版积分规则

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

在本版发帖返回顶部