查看: 8293|回复: 3

[已经解决] 请求将这段代码的参数更动一下。

[复制链接]
梦石
0
星屑
208
在线时间
420 小时
注册时间
2020-1-11
回帖
175
发表于 2021-6-23 22:02:54 | 显示全部楼层 |阅读模式
悬赏300星屑已解决
本帖最后由 alianlord 于 2021-6-23 22:02 编辑

[pre lang="ruby"] #--------------------------------------------------------------------------
  # ● [追加]:バトル画面 X 座標の設定
  #  ここで設定した座標は Game_Actor や ステータス表示等で利用されます。
  #--------------------------------------------------------------------------
  def set_screen_x
    @members_screen_x = []
    @members_screen_x_nooffset = []
    padding = LNX11::ACTOR_PADDING[:side]
    if LNX11::ACTOR_CENTERING
      # アクターのセンタリングが有効
      a_spacing = LNX11::ACTOR_SPACING_ADJUST
      padding += (max_battle_members - battle_members.size) * a_spacing
      width = (Graphics.width - padding * 2) / battle_members.size
    else
      # アクターのセンタリングが無効
      width = (Graphics.width - padding * 2) / max_battle_members
    end
    battle_members.each_with_index do |actor, i|
      offset = LNX11::ACTOR_OFFSET[:x]
      @members_screen_x_nooffset = width * i + width / 2 + padding
      @members_screen_x = @members_screen_x_nooffset + offset
      actor.screen_x = @members_screen_x
    end
  end
  #--------------------------------------------------------------------------
  # ● [追加]:バトル画面 Y 座標の設定
  #  ここで設定した座標は Game_Actor や ステータス表示等で利用されます。
  #--------------------------------------------------------------------------
  def set_screen_y
    offset = LNX11::ACTOR_OFFSET[:y]
    ay = Graphics.height - LNX11::ACTOR_PADDING[:bottom] + offset
    @members_screen_y = Array.new(max_battle_members) {ay}
    battle_members.each {|actor| actor.screen_y = ay}
  end[/pre]

这是某个脚本中,在战斗场景下,有关我方X、Y座标的指定。原先的脚本布局是横一列。每个角色的X座标是自动随占宽生成的。
我想改动成------前三人后三人,一共六人的队形。这脚本的结构比较紧骤,使得我想直接填入各个角色的数字座标也不知如何下手。
请求各位高手,不管各种手段。高明的编码还是简单粗暴的直接填写,请给我一个可以解决问题的手段吧。

最佳答案

查看完整内容

直接参看 set_screen_x 最后那部分 i 就对应第 X 个参战角色,所以简单粗暴的改法就是这样

梦石
1
星屑
23236
在线时间
9564 小时
注册时间
2012-6-19
回帖
7018

开拓者短篇九导演组冠军

发表于 2021-6-23 22:02:55 | 显示全部楼层
直接参看 set_screen_x 最后那部分

  1. battle_members.each_with_index do |actor, i|
  2.       offset = LNX11::ACTOR_OFFSET[:x]
  3.       @members_screen_x_nooffset[i] = width * i + width / 2 + padding
  4.       @members_screen_x[i] = @members_screen_x_nooffset[i] + offset
  5.       actor.screen_x = @members_screen_x[i]
  6. end
复制代码


i 就对应第 X 个参战角色,所以简单粗暴的改法就是这样

  1. battle_members.each_with_index do |actor, i|
  2.   if i == 0
  3.     @members_screen_x_nooffset[i] = 1
  4.     @members_screen_x[i] = 1
  5.     actor.screen_x = 1
  6.   elsif i == 1
  7.     @members_screen_x_nooffset[i] = 2
  8.     @members_screen_x[i] = 2
  9.     actor.screen_x = 2
  10.   elsif i == 2
  11.     @members_screen_x_nooffset[i] = 3
  12.     @members_screen_x[i] = 3
  13.     actor.screen_x = 3
  14.   elsif i == 3
  15.     @members_screen_x_nooffset[i] = 4
  16.     @members_screen_x[i] = 4
  17.     actor.screen_x = 4
  18.   elsif i == 4
  19.     @members_screen_x_nooffset[i] = 5
  20.     @members_screen_x[i] = 5
  21.     actor.screen_x = 5
  22.   elsif i == 5
  23.     @members_screen_x_nooffset[i] = 6
  24.     @members_screen_x[i] = 6
  25.     actor.screen_x = 6
  26.   end
  27. end
复制代码
回复

使用道具 举报

梦石
0
星屑
208
在线时间
420 小时
注册时间
2020-1-11
回帖
175
 楼主| 发表于 2021-7-6 22:34:49 | 显示全部楼层
[pre lang="ruby"]#==============================================================================
# ■ 世界樹的迷宮風戦闘画面
#   @version 1.14 10/03/18
#   @author さば缶
#------------------------------------------------------------------------------
#  世界树迷宫风的战斗画面显示的脚本。
#   ■注意
#     这个脚本本体以外还需要有以下的图像文件。
#     ・Graphics/System/ActiveWindow.png
#     ・Graphics/System/Cursor.png
#     ・Graphics/System/Miss.png
#     ・Graphics/Pictures/Actor<<角色的ID>>.png
#     <<角色的ID>> は、1以上的整数。数据库的角色欄的ID请放入。
#     ・Graphics/System/Force.png(气力有效的场合)
#     複数角色使用的場合、请放入複数的画像。
#     初期状態、角色的画像尺寸是 横150 縦230。
#     
#   ■战斗时的面部画像动态的变更、事件的脚本以下记述。
#     change_face(<<角色的ID>>, <<顔的ID>>)
#     <<顔的ID>>10和设定、Actor10.png 被使用。
#   ■KGC Software様的「气力运行脚本」进入的话、气力的量规可被表示。
#   ■KGC Software様的「個別戦闘指令」也对应着。
#     作为扩张、「逃跑」被追加。。
#     ** 対応表 **
#     0..攻撃  1..技能  2..防御  3..物品  4..固有指令  10..逃跑
#   ■ストレイキャット様的STR11d_XP風战斗#伤害弹出同时使用。
#    併用的場合、HIDE_DEFAULT_POPUP_DAMAGE 为 true 请
#   ■ストレイキャット様的STR06_快速战斗 v1.1と併用。
#    併用場合、请下这脚本。
#   ■3D迷宫的脚本和并用的场合、
#     请配置这3D迷宫的脚本。。
#==============================================================================
module Saba
  module Sekaiju
   
    # 窗口尺寸变更的场合,在此设定。
    WINDOW_WIDTH = 544
    WINDOW_HEIGHT = 416
   
    # 文本颜色及hp条彩色 系统彩色的场合、设定true。
    USE_SYSTEM_COLOR = false
   
    # L 键 自动战斗实行的话、设定true。
    AUTO_BATTLE_ENABLED = false
   
    # ストレイキャット様的信息窗口EXT + +同时使用的场合、请设定false。
    # 除此以外  推荐设定为true。
    AUTO_RESIZE_MESSAGE_WINDOW_ENABLED = true
   
    # 前排,后排系统有效的场合 设定为true。
    #   有效的,如果不以下一般显示,前排后排的补正完全没有。
    # ・队友ー人数が 1-2  →全員前列
    # ・队友ー人数が 3  →前列2、後列1
    # ・队友ー人数が 4  →前列2、後列2
    # ・队友ー人数が 5  →前列3、後列2
    # ・队友ー人数が 6  →前列3、後列3
    #
    # 有效的场合,以下的系统适用。。
    # ・前排,后排中被盯上率就会改变
    # ・后排的通常攻击,默认补正
    # ・后排的技能,默认补正用不了
    FORMATION_ENABLED = true
   
    # 前排谁都不在状态如果确认、设定为true。
    ALLOW_EMPTY_FRONTS = false
   
    # 从敌人的攻击对后排的场合,受创点来的值被加上了。
    BACK_ATTACK_DAMAGE_PENALTY_ENEMY = 0.3
   
    # 我方的后排的攻击的场合,受创点来的值被加上了。
    BACK_ATTACK_DAMAGE_PENALTY = 0.1
   
    # 后排的攻击时受惩罚的武器点击,显示标志。。
    # 这文字列为武器的笔记栏里适用。。
    # ※技能记录栏里写入什么也不会发生
    LONG_RANGE_WEAPON_MARKER = "LONG_RANGE"
   
    # 后排的技能使用时,表示受惩罚技能 显示标记。。
    # 这文字列技能笔记栏里适用。。
    # ※武器的笔记栏里写入什么也不会发生
    SHORT_RANGE_SKILL_MARKER = "SHORT_RANGE"
   
    # 前排的角色 袭击率 的值。。
    # 1以上的整数请设定。
    FRONT_TARGET_ODDS = 5
   
    # 后排的角色袭击率 的值。。
    # 1以上的整数请设定。
    BACK_TARGET_ODDS = 1
   
    # 职业的位置设定前卫的场合、TARGET_ODDS 追加值。
    # 请设定为整数。
    TARGET_ODDS_PLUS_AT_CLASS_POSITION_FORWARD = 0
   
    # 职业的位置设定中卫的场合、TARGET_ODDS追加值。
    # 请设定为整数。
    TARGET_ODDS_PLUS_AT_CLASS_POSITION_HALFBACK = 0
   
    # 职业的位置设定后卫的场合、TARGET_ODDS追加值。
    # 请设定为整数。
    TARGET_ODDS_PLUS_AT_CLASS_POSITION_BACK = 0
   
    # 角色指令選択時的信息。
    COMMAND_MESSAGE = "COMMAND ?  ( X: AUTO  R: EQUIP )"
   
   
    # 全员逃走的容易,所以能逃跑的几率比较大。
    ESCAPE_RATIO_PENALTY = 1
   
    # 敌人的敌人登场时名字表示的场合 true 的。但是信息窗口有
    # 只有2行的,三只以后的敌人的名字不被显示。
    SHOW_ENEMY_NAME_WHEN_ENEMY_APPEARS = false
   
    # 敌人单独登场时显示的信息。。
    # SHOW_ENEMY_NAME_WHEN_ENEMY_APPEARS 为 false 的时候被使用。。
    MESSAGE_WHEN_ENEMY_APPEARS = "怪物出現了!"
   
    # 敌人复数登场时显示的信息。。
    # SHOW_ENEMY_NAME_WHEN_ENEMY_APPEARS 为 false 的时候被使用。
    MESSAGE_WHEN_ENEMIES_APPEAR = "怪物成群的出現了!"
   
    # 受创点 值的颜色。
    DAMAGE_COLOR = Color.new(255, 255, 255)
   
    # 回復量 值的颜色。
    RECOVER_COLOR = Color.new(150, 250, 150)
   
    # 受创点 和 回復量的文字的字型尺寸。
    FONT_SIZE = 30
   
    # 受创点动画的表示時間。単位为祯。
    DAMADE_ANIMATIONS_DURATION = 30
   
    # 高扬的小人的颜色。
    BOOST_BORDER_COLOR        = Color.new(0, 0, 0, 150)
   
    # 表示敌人的参数的设定。。
    # 0的場合、看HP的表示。
    # 光标 graphics/system/cursor 被使用。
    #
    # 1的場合、HPとMPを表示します。
    # 光标に raphics/system/cursor_mp.png 被使用。
    #
    # 2的場合、HPとオー条气力量规を表示します。
    # 光标 graphics/system/cursor_od.png 被使用。
    #
    # 3的場合、HPとMPとオー条气力量规を表示します。
    # 光标 graphics/system/cursor_mp_od.png 被使用。
    PARAMETER_TYPE = 1
   
    # MAX MP 为0的敵 対、MP 条描画不做的时候 true 設定。
    NOT_DRAW_MAX_MP_0 = false
   
    # 敵選択图标的背景色です。
    TARGET_BG_COLOR = Color.new(0, 0, 0, 0)
   
    # 敵HP条的背景色。系统色彩使用場合 無視。
    HP_BAR_BG_COLOR      = Color.new(80, 80, 80, 220)
   
    # 敵HP条的边框色。
    HP_BAR_BORDER_COLOR  = Color.new(0, 0, 0, 150)
   
    # 敵HP条的前景色。系统颜色使用场合 无视。
    HP_BAR_FG_COLOR_1    = Color.new(255, 150, 0)
   
    # 敵HP条的前景色。系统颜色使用场合 无视。
    HP_BAR_FG_COLOR_2    = Color.new(255, 250, 0)
   
    # 敵MP条的前景色。系统颜色使用场合 无视。
    MP_BAR_FG_COLOR_1    = Color.new(0, 150, 255)
   
    # 敵MP条的前景色。系统颜色使用场合 无视。
    MP_BAR_FG_COLOR_2    = Color.new(0, 250, 255)
   
    # 敵HP/MP/オー条气力条的边框宽。
    BAR_BORDER_WEIGHT = 1
   
    # 敵HP/MP/オー条气力条的横幅。
    BAR_WIDTH  = 45
   
    # 敵HP条的高。
    HP_BAR_HEIGHT  = 5   
   
    # 敵MP条的高。
    MP_BAR_HEIGHT  = 3
   
    # 敵オー条气力条的高。
    OVERDRIVE_BAR_HEIGHT  = 3
   
    # 敵HP条的 y 座標的微調整。
    HP_BAR_OFFSET_Y = 26
   
    # 敵MP条的 y 座標的微調整。
    MP_BAR_OFFSET_Y = 26
   
    # 敵オー条气力条的 y 座標微調整。
    OVERDRIVE_BAR_OFFSET_Y = 0
   
    # 角色指令菜单 每1 框架移動的距離。必需是可被576整除的数。
    DISTANCE_PER_FRAME = 96
   
     # 目标選択光标的 y 座標。
    TARGET_CURSOR_Y = 90
   
    # 目标的状態图标的敵的 x 座標从的 x 的相対値です。
    TARGET_STATE_OFFSET_X = -30
    # 目标的状態图标的 y 座標。
    TARGET_STATE_Y = 76
    # 目标的状態图标的間隔。
    TARGET_STATE_INTERVAL = 20
   
    # 技能選択窗口的 x 座標。
    SKILL_WINDOW_X = 290
    # 技能選択窗口的 y 座標。
    SKILL_WINDOW_Y = 86
    # 技能選択窗口的宽。
    SKILL_WINDOW_WIDTH = 300
    # 技能選択窗口的高。
    SKILL_WINDOW_HEIGHT = 199
   
    # 物品選択窗口的 x 座標。
    ITEM_WINDOW_X = SKILL_WINDOW_X
    # 物品選択窗口的 x 座標。
    ITEM_WINDOW_Y = SKILL_WINDOW_Y
    # 物品択窗口的横幅。
    ITEM_WINDOW_WIDTH = SKILL_WINDOW_WIDTH
    # 物品選択窗口的高。
    ITEM_WINDOW_HEIGHT = SKILL_WINDOW_HEIGHT
   
    # 脸图像的坐标。。
    FACE_X = 0
    FACE_Y = 288
    # 宽这的幅度被切下。。
    # # 高度性是没有限制。
    FACE_WIDTH = 150
    # 脸图像的Z深度。
    FACE_Z = 200
   
    # 指令選択窗口的 x 座標。
    COMMAND_WINDOW_X = 150
    # 指令選択窗口的 y 座標。
    COMMAND_WINDOW_Y = 122
    # 指令選択窗口的横幅。
    COMMAND_WINDOW_WIDTH = 128
    # 指令的个数。通常设定为5没有问题。、
    # KGC Software 様 的個別戦闘指令使用的場合、
    # COMMAND_WINDOW_Y 和调整。。
    COMMAND_COUNT = 5
   
    # 能力值的窗口的 Z 深度。
    STATUS_WINDOW_Z = 30
   
    # 现在的回合数显示的情况下、设定是true。
    SHOW_TURN_COUNT = false
    # 回合窗口显示的情况下 设定是true。
    SHOW_TURN_WINDOW = false
   
    # 现在的回合数表示设定的场合,果然还是不想显示了
    # 这号码的开关 切 ON 的话;就不显示了。
    HIDE_TURN_COUNT_SWITCH = 120
   
    # 左边的場合设为 0、靠右的場合设为 2 。
    TURN_WINDOW_ALIGN = 0
    TURN_WINDOW_Y = 0
    TURN_WINDOW_WIDTH = 64
    TURN_WINDOW_HEIGHT = 56
   
    # 右边的場合、信息窗口的x的偏移値。
    # 0的话窗口的线重叠。
    MESSAGE_WINDOW_OFFSET_X = 0
   
   
    # 回合数的 x 座標。
    TURN_VALUE_X = 1
    # 回合数的 y 座標。
    TURN_VALUE_Y = 20
    # 回合数的字型尺寸。
    TURN_FONT_SIZE = 25
    # 回合数的色。
    TURN_FONT_COLOR = Color.new(190, 240, 190)
    # 回合数黑体字的場合 设定为true 。
    TURN_FONT_BOLD = true
   
    # 使用的回合图像的名字。
    TURN_IMAGE = "turn"
   
    # 状態画面的模式。
    # 0 無効
    # 1 技能范围领域的表示
    # 2 角色状态的领域中表示
    INFO_TYPE = 2
   
    # 状态画面的上部被表示的文本。。
    # INFO_TYPE 为 1 的时候才有效。。
    INFO_TEXT = "インフォメーション"
   
    # 超级气力槽的文本位置表示微调。
    OVER_DRIVE_VALUE_OFFSET_X = 0
    # 超级气力槽的文本位置表示微调。
    OVER_DRIVE_VALUE_OFFSET_Y = 0   
   
    OVER_DRIVE_X = 0
    OVER_DRIVE_Y = 271
   
    # 在战斗中的角色的图像显示的情况下、设定为true。
    SHOW_ACTOR_IMAGE = false
   
    # 角色能力表窗口的背景画像的文件名。
    # 例) status_bg
    # 通常窗口显示的场合,nil指定。
    ACTOR_STATUS_BG_IMAGE = nil#"status_bg"
   
    # 選択状態的角色能力表窗口的背景画像的文件名。
    # 例) status_active_bg
    # 通常窗口显示的场合,nil指定。
    ACTOR_STATUS_ACTIVE_BG_IMAGE = nil#"status_active_bg"
   
    # 经常6人份的状态窗口显示的情况、设定为true。
    SHOW_EMPTY_ACTOR_STATUS = false
   
    # 角色対応 没有安上能力表 窗口的背景画像。
    # SHOW_EMPTY_ACTOR_STATUS 为 true 的时候才能使用。
    EMPTY_STATUS_BG_IMAGE = "status_empty_bg"
   
    # 角色面对攻击和技能运行时,
    # 动画表示的场合 设定为true。
    DISPLAY_BATTLE_ANIMATION_TO_ACTOR = true
   
    # 对我方位置「画面」有动画的技能使用的場合、
    # 这里Y值方向的中心座标被移动。
    # DISPLAY_BATTLE_ANIMATION_TO_ACTOR 为true 的時候有効。
    DISPLAY_POSITION_ANIMATION_OFFSET_Y = 160
   
    # 预设位置的受创点表示 为 OFF 的場合、
    # 设冗为 true 。
    # ストレイキャット様的XP風战斗的受创点 位置 使用的时候
    # 请使用。
    HIDE_DEFAULT_POPUP_DAMAGE = false
   
    # 勝利時的信息窗口的行数。
    # 2~4
    VICTORY_MESSAGE_LINES = 2
   
    # 行動中的角色的窗口的選択状態
    # 醒目的场合、设定为true 。
    SELECT_ACTIVE_ACTOR = true
   
    # 必要的MP 0的技能,必要MP的表示。。
    NO_COST_SKILL_VIEW = "0"
   
    # 敌人Y坐标配合选择光标的Y坐标调整的场合、
    # 设定为true。
    ADJUST_TARGET_WINDOW_Y = false
   
    # 敌人的位置下有多少、
    # 敌人选择光标的坐标元的坐标比这个以上下降。。
    ENEMY_SELECTION_WINDOW_MAX_Y = 250
   
    # 敌人的位置上,有多少、
    # 敌人选择光标的坐标元的坐标比这个以上没有上升。
    ENEMY_SELECTION_WINDOW_MIN_Y = -30
   
##### FreeWind 様的回合消費技能的表示用。
    # 经常行动可能前的剩下回合表示的场合 设定为true。
    # false 設定的場合、A 键 表示切换。
    DISPLAY_ALWAYS = false
   
    # 表示的座標。
    NOT_ACT_TURN_Y = 100
    NOT_ACT_TURN_WIDTH = 100
    NOT_ACT_TURN_HEIGHT = 32
    NOT_ACT_TURN_BG_COLOR = Color.new(16, 16, 16, 128)
    NOT_ACT_TURN_NORMAL_FONT_COLOR = Color.new(255, 255, 255)
    NOT_ACT_TURN_READY_FONT_COLOR = Color.new(255, 255, 140)
    NOT_ACT_TURN_FONT_SIZE = 18
    GETTING_READY_TEXT = "READY:"
    READY_TEXT = "READY"
    TIRED_TEXT = "TIRED:"
   
    # 画面待机中的技能名表示的场合、设定为true。
    DRAW_WAITING_SKILL_NAME = false
    # 画面技能名表示场合、最大的字节数。。
    # 全角1文字3字节。
    MAX_SKILL_NAME_LENGTH = 15
    # 字型的尺寸。
    WAITING_SKILL_FONT_SIZE = 16
#######
   
   
   
    def self.show_turn_count?
      return $game_switches[HIDE_TURN_COUNT_SWITCH] != true && Saba::Sekaiju::SHOW_TURN_COUNT
    end
  end
  
  module Checker
  
    def self.define?(item, name)
      return false if item == nil
      item.note.split(/[\r\n]+/).each do |line|
        elements = line.split(/\s+/)
        next unless elements.size == 1
        return true if elements[0] == name
      end
      return false
    end
  end
  
end

class FaceSprite
  #--------------------------------------------------------------------------
  # ● 使用的面部画像返回。
  #--------------------------------------------------------------------------
  def face_image(actor)
    # HP很低的时候,其他图片设定的例子
    #if (actor.hp * 100 / actor.maxhp) < 30
    #  return "Actor" + @actor_index.to_s + "_1"
    #end
    return "Actor" + @actor_index.to_s
  end
end

$imported = {} if $imported == nil
$imported["SekaijuBattle"] = true


unless $imported["LargeParty"]
  class Game_Party < Game_Unit
    def battle_members
      return members
    end
  end
end



module ActorStatus
  WLH = Window_Base::WLH
  BASE_Y = Saba::Sekaiju::WINDOW_HEIGHT - 128
  CELL_HEIGHT = 63
  CELL_WIDTH = Saba::Sekaiju::WINDOW_WIDTH / 3
  
  attr_reader :actor
  attr_writer :canvas
  attr_accessor :dummy
  
  def save_parameters
    return if @dummy
    @hp = @actor.hp
    @mp = @actor.mp
  end
  #--------------------------------------------------------------------------
  # ● 状態異常图标的表示的更新。
  #--------------------------------------------------------------------------
  def update_contents
    return if @dummy
    @frame += 1
    if Saba::Sekaiju::DAMADE_ANIMATIONS_DURATION < @frame
      @frame = 0
      next_state
    end
    if @hp != @actor.hp || @mp != @actor.mp
      refresh
      save_parameters
    end
  end
  #--------------------------------------------------------------------------
  # ● 绘制更新。。
  #--------------------------------------------------------------------------
  def refresh
    return if @dummy
    if @display_state_mode
      refresh_states
    else
      refresh_normal
    end
  end
  
  def refresh_states
    @canvas.clear_rect(self.x, self.y, CELL_WIDTH, CELL_HEIGHT)
    x = 10
    y = 7
    count = 0
    for state in @actor.states
      break if count >= 7
      next if state.icon_index == 0
      draw_icon(@canvas, state.icon_index, x, y)
      x += 21
      count += 1
    end
   
    draw_actor_atk(@canvas, 10, 30, 75)
    draw_actor_def(@canvas, 95, 30, 75)
  end
   
  def refresh_normal
    @canvas.clear_rect(self.x, self.y, CELL_WIDTH, CELL_HEIGHT)
    @canvas.font.color = hp_color(@actor)
    @canvas.draw_text(self.x + 40, self.y + 7, 128, WLH, @actor.name)
    @canvas.font.color = normal_color
   
    draw_actor_hp_gauge(@canvas, 10, 30, CELL_WIDTH / 2 - 15)
    draw_actor_mp_gauge(@canvas, CELL_WIDTH / 2 + 4, 30, CELL_WIDTH / 2 - 15)
    draw_actor_hp(@canvas, 10, 30, CELL_WIDTH / 2 - 15)
    draw_actor_mp(@canvas, CELL_WIDTH / 2 + 4, 30, CELL_WIDTH / 2 - 15)
    draw_actor_state(@canvas, 10, 7)
  end
  #--------------------------------------------------------------------------
  # ● 状態異常次项的表示切换进行。
  #--------------------------------------------------------------------------
  def next_state
    return if @display_state_mode
    return if no_visible_state
    @state_index += 1
    @state_index = 0 if @state_index >= actor.states.size
    while @actor.states[@state_index].icon_index == 0
      @state_index += 1
      @state_index = 0 if @state_index >= actor.states.size
    end
    refresh
  end
  def no_visible_state
    for state in @actor.states
      return false unless state.icon_index == 0
    end
    true
  end
  #--------------------------------------------------------------------------
  # ● 攻撃力的描画。
  #--------------------------------------------------------------------------
  def draw_actor_atk(bitmap, x, y, width = 120)
    bitmap.font.color = system_color
    bitmap.draw_text(x + self.x, y + self.y, 40, WLH, Vocab::atk)
    bitmap.font.color = normal_color
    xr = x + width
    bitmap.draw_text(xr - 40 + self.x, y + self.y, 40, WLH, @actor.atk, 2)
  end
  #--------------------------------------------------------------------------
  # ● 防御力的描画。
  #--------------------------------------------------------------------------
  def draw_actor_def(bitmap, x, y, width = 120)
    bitmap.font.color = system_color
    bitmap.draw_text(x + self.x, y + self.y, 40, WLH, Vocab::def)
    bitmap.font.color = normal_color
    xr = x + width
    bitmap.draw_text(xr - 40 + self.x, y + self.y, 40, WLH, @actor.def, 2)
  end
  #--------------------------------------------------------------------------
  # ● 状態異常的描画。
  #--------------------------------------------------------------------------
  def draw_actor_state(bitmap, x, y)
    return if no_visible_state
    return if actor.states.size <= @state_index
    state = @actor.states[@state_index]
    draw_icon(bitmap, state.icon_index, x, y)
  end
  #--------------------------------------------------------------------------
  # ● 状態異常图标的描画。
  #--------------------------------------------------------------------------
  def draw_icon(bitmap, icon_index, x, y, enabled = true)
    icon = Cache.system("Iconset")
    rect = Rect.new(icon_index % 16 * 24, icon_index / 16 * 24, 24, 24)
    bitmap.blt(x + self.x, y + self.y, icon, rect, enabled ? 255 : 128)
  end
  #--------------------------------------------------------------------------
  # ● HP 量规的描画。
  #--------------------------------------------------------------------------
  def draw_actor_hp_gauge(bitmap, x, y, width = 120)
    gw = width * @actor.hp / @actor.maxhp
    gc1 = hp_gauge_color1
    gc2 = hp_gauge_color2
    bitmap.fill_rect(x + self.x, y + WLH - 8 + self.y, width, 6, gauge_back_color)
    bitmap.gradient_fill_rect(x + self.x, y + WLH - 8 + self.y, gw, 6, gc1, gc2)
  end
  #--------------------------------------------------------------------------
  # ● MP 量规的描画。
  #--------------------------------------------------------------------------
  def draw_actor_mp_gauge(bitmap, x, y, width = 120)
    gw = width * @actor.mp / [@actor.maxmp, 1].max
    gc1 = mp_gauge_color1
    gc2 = mp_gauge_color2
    bitmap.fill_rect(x + self.x, y + WLH - 8 + self.y, width, 6, gauge_back_color)
    bitmap.gradient_fill_rect(x + self.x, y + WLH - 8 + self.y, gw, 6, gc1, gc2)
  end
  #--------------------------------------------------------------------------
  # ● HP 的描画。
  #--------------------------------------------------------------------------
  def draw_actor_hp(bitmap, x, y, width = 120)
    bitmap.font.color = system_color
    bitmap.draw_text(x + self.x, y + self.y, 30, WLH, Vocab::hp_a)
    bitmap.font.color = hp_color(@actor)
    xr = x + width
    if width < 120
      bitmap.draw_text(xr - 40 + self.x, y + self.y, 40, WLH, @actor.hp, 2)
    else
      bitmap.draw_text(xr - 90 + self.x, y + self.y, 40, WLH, @actor.hp, 2)
      bitmap.font.color = normal_color
      bitmap.draw_text(xr - 50 + self.x, y + self.y, 10, WLH, "/", 2)
      bitmap.draw_text(xr - 40 + self.x, y + self.y, 40, WLH, @actor.maxhp, 2)
    end
  end
  #--------------------------------------------------------------------------
  # ● MP 的描画
  #     actor : 角色
  #     x     : 描画先 X 座標
  #     y     : 描画先 Y 座標
  #     width : 宽
  #--------------------------------------------------------------------------
  def draw_actor_mp(bitmap, x, y, width = 120)
    bitmap.font.color = system_color
    bitmap.draw_text(x + self.x, y + self.y, 30, WLH, Vocab::mp_a)
    bitmap.font.color = mp_color(@actor)
    xr = x + width
    if width < 120
      bitmap.draw_text(xr - 40 + self.x, y + self.y, 40, WLH, @actor.mp, 2)
    else
      bitmap.draw_text(xr - 90 + self.x, y + self.y, 40, WLH, @actor.mp, 2)
      bitmap.font.color = normal_color
      bitmap.draw_text(xr - 50 + self.x, y + self.y, 10, WLH, "/", 2)
      bitmap.draw_text(xr - 40 + self.x, y + self.y, 40, WLH, @actor.maxmp, 2)
    end
  end
  def show_all_states
    @display_state_mode = true
    refresh
  end
  def hide_all_states
    @display_state_mode = false
    refresh
  end
  #--------------------------------------------------------------------------
  # ● 假人。
  #--------------------------------------------------------------------------
  def active=(value)
  end
  #--------------------------------------------------------------------------
  # ● 这个窗口的 x 座標返回。
  #--------------------------------------------------------------------------
  def window_x
    if front?
      size = $game_party.fronts.size
    else
      size = $game_party.backs.size
    end
    if Saba::Sekaiju::SHOW_EMPTY_ACTOR_STATUS
      return position_in_ranks * CELL_WIDTH
    end
    case size
    when 1
      return (CELL_WIDTH)
    when 2
      return (position_in_ranks + 0.5) * (CELL_WIDTH)
    when 3
      return position_in_ranks * (CELL_WIDTH) + 1 if position_in_ranks == 2
      return position_in_ranks * (CELL_WIDTH)
    end
    return 0
  end
  def front?
    return @actor.front?
  end
  def position_in_ranks
    return @actor.position_in_ranks
  end
  #--------------------------------------------------------------------------
  # ● 这个窗口的横宽的返回。
  #--------------------------------------------------------------------------
  def window_width
    return CELL_WIDTH + 1 if position_in_ranks == 1
    return CELL_WIDTH
  end
end



#==============================================================================
# ■ Game_Actor 的追加
#------------------------------------------------------------------------------
#  角颜色先锋,后卫的参数追加。。
#   职业的先锋,后卫初期化时的参数这些反映。。
#   職業的前衛→       front = true
#   職業的中衛、後衛→ front = false
#==============================================================================
class Game_Actor < Game_Battler
  attr_accessor :position_in_ranks
  attr_accessor :front
  attr_accessor :screen_x
  attr_accessor :screen_y
  attr_accessor :screen_z
  attr_accessor :face_id
  def screen_x
    @screen_x = 0 if @screen_x == nil
    return @screen_x
  end
  def screen_y
    @screen_y = 0 if @screen_y == nil
    return @screen_y
  end
  def screen_z
    @screen_z = 0 if @screen_z == nil
    return @screen_z
  end
  #--------------------------------------------------------------------------
  # ● 这个角色是否是前衛检查。
  #--------------------------------------------------------------------------
  def front?
    return @front
  end
  #--------------------------------------------------------------------------
  # ● 这个角色是否是后衛检查。
  #--------------------------------------------------------------------------
  def back?
    return ! @front
  end
  #--------------------------------------------------------------------------
  # ● 后卫的话攻击范围的返回。
  #--------------------------------------------------------------------------
  def back_attack?
    if Saba::Sekaiju::FORMATION_ENABLED
      return false if front?
      if action.attack?
        for weapon in weapons.compact
          if weapon.long_range?
            return false
          end
        end
        return true
      elsif action.skill?
        return action.skill.short_range?
      else
        return false
      end
    else
      return false
    end
  end
  #--------------------------------------------------------------------------
  # ● 后排 是否 能有效攻击的判定。。
  #--------------------------------------------------------------------------
  def back_attacked?(user, obj = nil)
    return false if front?
    return true if obj == nil
    return obj.short_range?
  end
  #--------------------------------------------------------------------------
  # ● 被瞄上率的取得
  #--------------------------------------------------------------------------
  alias saba_sekaiju_odds odds
  def odds
    if Saba::Sekaiju::FORMATION_ENABLED
      plus = 0
      case self.class.position
      when 0
        # 前衛
        plus = Saba::Sekaiju::TARGET_ODDS_PLUS_AT_CLASS_POSITION_FORWARD
      when 1
        # 中衛
        plus = Saba::Sekaiju::TARGET_ODDS_PLUS_AT_CLASS_POSITION_HALFBACK
      when 2
        # 後衛
        plus = Saba::Sekaiju::TARGET_ODDS_PLUS_AT_CLASS_POSITION_BACK
      end
      if front?
        return Saba::Sekaiju::FRONT_TARGET_ODDS + plus
      else
        return Saba::Sekaiju::BACK_TARGET_ODDS + plus
      end
    else
      return saba_sekaiju_odds
    end
  end
  #--------------------------------------------------------------------------
  # ● 顔画像 ID 的返回。
  #--------------------------------------------------------------------------
  def face_id
    return id if @face_id == nil
    return @face_id
  end
if Saba::Sekaiju::DISPLAY_BATTLE_ANIMATION_TO_ACTOR
  def use_sprite?
    return true
  end
end
end
#==============================================================================
# ■ Window_BattleMessage 再定義
#------------------------------------------------------------------------------
#  战斗中的信息画面上部2行表示出来。。
#==============================================================================
class Window_BattleMessage < Window_Message
  MAX_LINE = 2
if Saba::Sekaiju::AUTO_RESIZE_MESSAGE_WINDOW_ENABLED
  #--------------------------------------------------------------------------
  # ● 对象初期化 ◆◆◆ 改造/角色選択用 ◆◆◆
  #--------------------------------------------------------------------------
  def initialize
    super
    if Saba::Sekaiju::show_turn_count? && Saba::Sekaiju::TURN_WINDOW_ALIGN == 0
      self.x = Saba::Sekaiju::TURN_WINDOW_WIDTH + Saba::Sekaiju::MESSAGE_WINDOW_OFFSET_X
    end
    if Saba::Sekaiju::show_turn_count?
      self.width = Saba::Sekaiju::WINDOW_WIDTH - Saba::Sekaiju::TURN_WINDOW_WIDTH + Saba::Sekaiju::MESSAGE_WINDOW_OFFSET_X
    end
    self.y = 0
    self.height = 80
    self.openness = 255
    @max_line_next = 0
    @max_line = MAX_LINE
    create_contents
    @lines = []
    refresh
  end
  def max_line=(value)
    @max_line_next = value
    update_window_size
  end
  def new_page
    update_window_size
    super
    #◆ 追加 ◆----------------------------------------------------------------
    if @item_max > 4
      @line_count = 4 - @item_max
    end
    #--------------------------------------------------------------------------
  end
  #--------------------------------------------------------------------------
  # ● 窗口尺寸更新。 ◆◆◆ 改造/対悪魔会話用 ◆◆◆
  #--------------------------------------------------------------------------
  def update_window_size
    if ! $game_message.face_name.empty?
      if self.height != 128
        self.height = 128
        create_contents
        @max_line = 4
      end
    #◆ 改造 ◆----------------------------------------------------------------
    elsif $game_switches[96] == true # 会話用框架开关
      self.height = 128
      create_contents
      @max_line = 4
    #--------------------------------------------------------------------------
    elsif @max_line_next > 0
      if self.height != @max_line_next * WLH + 32
        self.height = @max_line_next * WLH + 32
        create_contents
        @max_line = @max_line_next
      end
    else
      if self.height != 80
        self.height = 80
        create_contents
        @max_line = 2
      end
    end
    $game_temp.max_line = @max_line
  end
else
  #--------------------------------------------------------------------------
  # ● 对象初期化
  #--------------------------------------------------------------------------
  def initialize
    super
    if Saba::Sekaiju::show_turn_count? && Saba::Sekaiju::TURN_WINDOW_ALIGN == 0
      self.x = Saba::Sekaiju::TURN_WINDOW_WIDTH + Saba::Sekaiju::MESSAGE_WINDOW_OFFSET_X
    end
    if Saba::Sekaiju::show_turn_count?
      self.width = Saba::Sekaiju::WINDOW_WIDTH - Saba::Sekaiju::TURN_WINDOW_WIDTH + Saba::Sekaiju::MESSAGE_WINDOW_OFFSET_X
    end
    self.y = 0
    self.height = 80
    self.openness = 255
    create_contents
    @max_line = MAX_LINE
    @lines = []
    refresh
  end
  def update_window_size
  end
end
  #--------------------------------------------------------------------------
  # ● 刷新
  #--------------------------------------------------------------------------
  def refresh
    update_window_size
    self.contents.clear
    for i in 0...@lines.size
      if i >= @max_line
        i.times do
          @lines.shift
        end
        refresh
        break
      end
      draw_line(i)
    end
  end
  #--------------------------------------------------------------------------
  # ● 信息的更新 ◆◆◆ 改造 ◆◆◆
  #--------------------------------------------------------------------------
  def update_message
    loop do
      c = @text.slice!(/./m)            # 次的文字を取得
      case c
      when nil                          # 应该没有文字描画
        finish_message                  # 更新終了
        break
      when "\x00"                       # 改行
        new_line
        if @line_count >= @max_line      # 行数最大的时候
          unless @text.empty?            # 并且延续下去就
            self.pause = true            #输入等待中
            break
          end
        end
      when "\x01"                       # \C[n]  (文字色変更)
        @text.sub!(/\[([0-9]+)\]/, "")
        contents.font.color = text_color($1.to_i)
        next
      when "\x02"                       # \G  (所持金表示)
        @gold_window.refresh
        @gold_window.open
      when "\x03"                       # \.  (等待 1/2 秒)
        @wait_count = 30
        break
      when "\x04"                       # \|  (等待 1 秒)
        @wait_count = 60
        break
      when "\x05"                       # \!  (输入等待)
        self.pause = true
        break
      when "\x06"                       # \>  (瞬間表示 ON)
        @line_show_fast = true
      when "\x07"                       # \<  (瞬間表示 OFF)
        @line_show_fast = false
      when "\x08"                       # \^  (输入不等待)
        @pause_skip = true
      when "\x09"                       # \I  (图标表示)
        @text.sub!(/\[([0-9]+)\]/, "")
        draw_icon($1.to_i, @contents_x, @contents_y)
        @contents_x += 24
      else                              # 普通的文字
        contents.draw_text(@contents_x, @contents_y, 40, WLH, c)
        c_width = contents.text_size(c).width
        @contents_x += c_width
      end
      break unless @show_fast or @line_show_fast
    end
  end
  #--------------------------------------------------------------------------
  # ● 文章送的输入処理
  #--------------------------------------------------------------------------
#~   def input_pause
#~     if Input.trigger?(Input::B) or Input.trigger?(Input::C)
#~       self.pause = false
#~       if @text != nil and not @text.empty?
#~         new_page if @line_count >= @max_line
#~       else
#~         terminate_message
#~       end
#~     end
#~   end
end
#==============================================================================
# ■ Game_Message
#------------------------------------------------------------------------------
#  文章和选择项表示的信息窗口的状態处理的类。
# 这个类的实例是隶属于 $game_message 被参考。
#==============================================================================
class Game_Message
  #--------------------------------------------------------------------------
  # ● 改页
  #--------------------------------------------------------------------------
  alias saba_sekaiju_new_page new_page
  def new_page
    if $game_temp.in_battle
      while @texts.size % $game_temp.max_line > 0
        @texts.push("")
      end
    else
      saba_sekaiju_new_page
    end
  end
end
#==============================================================================
# ■ Game_Temp
#------------------------------------------------------------------------------
#  包括保存文件在内、一時的数剧的处理。这个类的指针 $game_temp 被参考。
#==============================================================================
class Game_Temp
  attr_accessor :max_line
end
#==============================================================================
# ■ Window_BattleItem
#------------------------------------------------------------------------------
#  戦闘中所持物品的一覧表示用的窗口。
#==============================================================================
class Window_BattleItem < Window_Selectable
  #--------------------------------------------------------------------------
  # ● 对象初期化
  #     x      : 窗口的 X 座標
  #     y      : 窗口的 Y 座標
  #     width  : 窗口的宽
  #     height : 窗口的高さ
  #--------------------------------------------------------------------------
  def initialize(x, y, width, height)
    super(x, y, width, height)
    @column_max = 1
    self.index = 0
    refresh
  end
  #--------------------------------------------------------------------------
  # ● 物品的取得
  #--------------------------------------------------------------------------
  def item
    return @data[self.index]
  end
  #--------------------------------------------------------------------------
  # ● 物品名单中是否包括
  #     item : 物品
  #--------------------------------------------------------------------------
  def include?(item)
    return false if item == nil
    if $game_temp.in_battle
      return false unless item.is_a?(RPG::Item)
    end
    return true
  end
  #--------------------------------------------------------------------------
  # ● 物品是否许可状态表示
  #     item : 物品
  #--------------------------------------------------------------------------
  def enable?(item)
    return $game_party.item_can_use?(item)
  end
  #--------------------------------------------------------------------------
  # ● 刷新
  #--------------------------------------------------------------------------
  def refresh
    @data = []
    for item in $game_party.items
      next unless include?(item)
      @data.push(item)
      if item.is_a?(RPG::Item) and item.id == $game_party.last_item_id
        self.index = @data.size - 1
      end
    end
    @data.push(nil) if include?(nil)
    @item_max = @data.size
    create_contents
    for i in 0...@item_max
      draw_item(i)
    end
  end
  #--------------------------------------------------------------------------
  # ● 項目的描画
  #     index : 項目番号
  #--------------------------------------------------------------------------
  def draw_item(index)
    rect = item_rect(index)
    self.contents.clear_rect(rect)
    item = @data[index]
    if item != nil
      number = $game_party.item_number(item)
      enabled = enable?(item)
      rect.width -= 4
      draw_item_name(item, rect.x, rect.y, enabled)
      self.contents.draw_text(rect, sprintf(":%2d", number), 2)
    end
  end
  #--------------------------------------------------------------------------
  # ● 帮助文本更新
  #--------------------------------------------------------------------------
  def update_help
    @help_window.set_text(item == nil ? "" : item.description)
  end
  
  
      
end
#==============================================================================
# ■ Window_BattleSkill
#------------------------------------------------------------------------------
# 在战斗中可以使用技能一览表示的窗口。
#==============================================================================
class Window_BattleSkill < Window_Skill
  #--------------------------------------------------------------------------
  # ● 对象初期化
  #     x      : 窗口的 X 座標
  #     y      : 窗口的 Y 座標
  #     width  : 窗口的宽
  #     height : 窗口的高
  #     actor  : 角色
  #--------------------------------------------------------------------------
  def initialize(x, y, width, height, actor)
    super(x, y, width, height, actor)
    @actor = actor
    @column_max = 1
    self.index = 0
    refresh
  end
  #--------------------------------------------------------------------------
  # ● 技能的取得
  #--------------------------------------------------------------------------
  def skill
    return @data[self.index]
  end
  #--------------------------------------------------------------------------
  # ● 刷新
  #--------------------------------------------------------------------------
  def refresh
    @data = []
    for skill in @actor.skills
      if $imported["HiddenSkill"] == true
        next unless include?(skill)
      end
      @data.push(skill)
      if skill.id == @actor.last_skill_id
        self.index = @data.size - 1
      end
    end
    @item_max = @data.size
    create_contents
    for i in 0...@item_max
      draw_item(i)
    end
  end
  #--------------------------------------------------------------------------
  # ● 項目的描画
  #     index : 項目番号
  #--------------------------------------------------------------------------
  def draw_item(index)
    rect = item_rect(index)
    self.contents.clear_rect(rect)
    skill = @data[index]
    if skill != nil
      rect.width -= 4
      enabled = @actor.skill_can_use?(skill)
      draw_item_name(skill, rect.x, rect.y, enabled)
      mp = @actor.calc_mp_cost(skill)
      if mp == 0
        text = Saba::Sekaiju::NO_COST_SKILL_VIEW
        self.contents.draw_text(rect, text, 2)
      else
        self.contents.draw_text(rect, mp, 2)
      end
    end
  end
  #--------------------------------------------------------------------------
  # ● 帮助文本更新
  #--------------------------------------------------------------------------
  def update_help
    @help_window.set_text(skill == nil ? "" : skill.description)
  end
end

class Sprite_Turn < Sprite
  #--------------------------------------------------------------------------
  # ● 对象初期化
  #--------------------------------------------------------------------------
  def initialize(viewport)
    super
    self.bitmap = Bitmap.new(Saba::Sekaiju::TURN_WINDOW_WIDTH, Saba::Sekaiju::TURN_WINDOW_HEIGHT)
    @turn_count = 1
    return unless Saba::Sekaiju::show_turn_count?
    @turn_image = Cache.system(Saba::Sekaiju::TURN_IMAGE)
    if Saba::Sekaiju::TURN_WINDOW_ALIGN == 0
      self.x = 0
    else
      self.x = Saba::Sekaiju::WINDOW_WIDTH - Saba::Sekaiju::TURN_WINDOW_WIDTH
    end
    self.y = Saba::Sekaiju::TURN_WINDOW_Y
    refresh
  end

  def refresh
    return unless Saba::Sekaiju::show_turn_count?
    self.bitmap.clear_rect(0, 0, self.bitmap.width, self.bitmap.height)
    self.bitmap.blt(0, 0, @turn_image, Rect.new(0, 0, @turn_image.width, @turn_image.height))
    self.bitmap.font.size = Saba::Sekaiju::TURN_FONT_SIZE
    self.bitmap.font.color = Saba::Sekaiju::TURN_FONT_COLOR
    self.bitmap.font.bold = Saba::Sekaiju::TURN_FONT_BOLD
    self.bitmap.draw_text(Saba::Sekaiju::TURN_VALUE_X, Saba::Sekaiju::TURN_VALUE_Y, 60, 30, @turn_count.to_s, 1)
  end
  def increase_turn
    @turn_count += 1
    refresh
  end
  #--------------------------------------------------------------------------
  # ● 解放
  #--------------------------------------------------------------------------
  def dispose
    self.bitmap.dispose
    super
  end
end

#==============================================================================
# ■ Sprite_EnemyState
#------------------------------------------------------------------------------
#  敵的状态表示精灵。
#==============================================================================
class Sprite_EnemyState < Sprite
  WIDTH = Saba::Sekaiju::WINDOW_WIDTH
  HEIGHT = 200
  #--------------------------------------------------------------------------
  # ● 对象初期化
  #--------------------------------------------------------------------------
  def initialize(viewport, enemy_sprites)
    super(viewport)
    @enemy_sprites = enemy_sprites.reverse
    @enemies = []
    for enemy in $game_troop.members
      next unless enemy.exist?
      @enemies.push(enemy)
    end
    self.bitmap = Bitmap.new(WIDTH, HEIGHT)
  end
  #--------------------------------------------------------------------------
  # ● 解放
  #--------------------------------------------------------------------------
  def dispose
    self.bitmap.dispose
    super
  end
  def refresh
    return unless defined?($game_party.reduce_consume_turn)
    draw_not_act_turns
  end
  #--------------------------------------------------------------------------
  # ● 更新
  #--------------------------------------------------------------------------
  def update

  end
  def draw_not_act_turns
    self.bitmap.clear_rect(0, 0, WIDTH, HEIGHT)
    for enemy_sprite in @enemy_sprites
      draw_not_act_turn(enemy_sprite) if enemy_sprite.battler.not_act_turn != -1
    end
  end
  def draw_not_act_turn(enemy_sprite)
    return unless enemy_sprite.battler.exist?
    width = Saba::Sekaiju::NOT_ACT_TURN_WIDTH
    height = Saba::Sekaiju::NOT_ACT_TURN_HEIGHT
    x = enemy_sprite.x - width / 2
    y = Saba::Sekaiju::NOT_ACT_TURN_Y
    not_act_turn = enemy_sprite.battler.not_act_turn
   
    if Saba::Sekaiju::DRAW_WAITING_SKILL_NAME &&  not_act_turn >= 0
      y_plus = -20
      height_plus = 20
    else
      y_plus = 0
      height_plus = 0
    end
    self.bitmap.fill_rect(x, y + y_plus, width, height + height_plus, Saba::Sekaiju::NOT_ACT_TURN_BG_COLOR)
   
    old_color = self.bitmap.font.color
    old_size = self.bitmap.font.size
   
   
    self.bitmap.font.size = Saba::Sekaiju::NOT_ACT_TURN_FONT_SIZE
   
   
    if not_act_turn == 0
      self.bitmap.font.color = Saba::Sekaiju::NOT_ACT_TURN_READY_FONT_COLOR
      text = Saba::Sekaiju::READY_TEXT
    elsif not_act_turn > 0
      self.bitmap.font.color = Saba::Sekaiju::NOT_ACT_TURN_NORMAL_FONT_COLOR
      text = Saba::Sekaiju::GETTING_READY_TEXT + (not_act_turn).to_s
    else
      self.bitmap.font.color = Saba::Sekaiju::NOT_ACT_TURN_NORMAL_FONT_COLOR
      text = Saba::Sekaiju::TIRED_TEXT + (not_act_turn * -1 - 1).to_s
    end
    self.bitmap.draw_text(x, y, width, height, text, 1)

    if not_act_turn >= 0
      skill_name = enemy_sprite.battler.action.skill.name
      draw_waiting_skill_name(x, y + y_plus, width, height, skill_name)
    end
    self.bitmap.font.color = old_color
    self.bitmap.font.size = old_size
  end
  
  def draw_waiting_skill_name(x, y, width, height, skill_name)
    return unless Saba::Sekaiju::DRAW_WAITING_SKILL_NAME
   
    self.bitmap.font.color = Color.new(255, 255, 255)
    self.bitmap.font.size = Saba::Sekaiju::WAITING_SKILL_FONT_SIZE
    max = Saba::Sekaiju::MAX_SKILL_NAME_LENGTH
    if max > 0
      skill_name = skill_name[0...max]
    end
   
    self.bitmap.draw_text(x, y, width - 4, height, skill_name, 1)
  end
end

#==============================================================================
# ■ Sprite_EnemyDamage
#------------------------------------------------------------------------------
#  战斗中,敌人给予了的受创点表示精灵。。
#==============================================================================
class Sprite_EnemyDamage < Sprite
  WIDTH = Saba::Sekaiju::WINDOW_WIDTH  # 虽然没有必要这么大的必要。
  HEIGHT = Saba::Sekaiju::WINDOW_HEIGHT
  #--------------------------------------------------------------------------
  # ● 对象初期化
  #--------------------------------------------------------------------------
  def initialize(viewport, enemy_sprites)
    super(viewport)
    @enemy_sprites = enemy_sprites.reverse
    @enemies = []
    for enemy in $game_troop.members
      next unless enemy.exist?
      @enemies.push(enemy)
    end
    @frame = Saba::Sekaiju::DAMADE_ANIMATIONS_DURATION
    @miss = Cache.system("Miss")
    self.bitmap = Bitmap.new(WIDTH, HEIGHT)
  end
  #--------------------------------------------------------------------------
  # ● 解放
  #--------------------------------------------------------------------------
  def dispose
    self.bitmap.dispose
    super
  end
  #--------------------------------------------------------------------------
  # ● 框架更新
  #--------------------------------------------------------------------------
  def update
    return unless animation_visible?
    if animation_finished?
      end_animation
    else
      update_animation
    end
  end
  #--------------------------------------------------------------------------
  # ● 动画表示中 检验返回。
  #--------------------------------------------------------------------------
  def animation_visible?
    return @current_enemy_sprite != nil || @miss_enemy_sprite != nil
  end
  #--------------------------------------------------------------------------
  # ● 动画就结束,判定返回。
  #--------------------------------------------------------------------------
  def animation_finished?
    return @frame >= Saba::Sekaiju::DAMADE_ANIMATIONS_DURATION
  end
  #--------------------------------------------------------------------------
  # ● 动画的描画終了、显示全部的要素删除。
  #--------------------------------------------------------------------------
  def end_animation
    @current_enemy_sprite = nil
    @miss_enemy_sprite = nil
    self.bitmap.clear_rect(0, 0, WIDTH, HEIGHT)
  end
  #--------------------------------------------------------------------------
  # ● 动画的更新。
  #--------------------------------------------------------------------------
  def update_animation
    @frame += 1
    draw_hp_damage unless @current_enemy_sprite == nil
    draw_miss unless @miss_enemy_sprite == nil
  end
  #--------------------------------------------------------------------------
  # ● 落空的表示。
  #--------------------------------------------------------------------------
  def display_miss(target)
    for enemy_sprite in @enemy_sprites
      if enemy_sprite.battler == target
        @miss_enemy_sprite = enemy_sprite
        @frame = 0
        draw_miss
        return
      end
    end
  end
  #--------------------------------------------------------------------------
  # ● 落空的描画。
  #--------------------------------------------------------------------------
  def draw_miss
    self.bitmap.clear_rect(0, 0, WIDTH, HEIGHT)
    x = @miss_enemy_sprite.x
    y = @miss_enemy_sprite.y - @frame - @miss_enemy_sprite.height / 2 - 20
    self.bitmap.blt(x - @miss.width / 2, y, @miss, Rect.new(0, 0, @miss.width, @miss.height))
  end
  #--------------------------------------------------------------------------
  # ● HP受创点表示。
  #--------------------------------------------------------------------------
  def display_hp_damage(target, obj)
    for enemy_sprite in @enemy_sprites
      if enemy_sprite.battler == target
        
        if enemy_sprite.battler.hp_damage == 0
          return if obj != nil && obj.is_a?(RPG::BaseItem) && obj.base_damage == 0
        end

        @current_enemy_sprite = enemy_sprite
        @frame = 0
        draw_hp_damage
        return
      end
    end
  end
  #--------------------------------------------------------------------------
  # ● HP受创点描画。
  #--------------------------------------------------------------------------
  def draw_hp_damage
    self.bitmap.clear_rect(0, 0, WIDTH, HEIGHT)
    damage = @current_enemy_sprite.battler.hp_damage
    x = @current_enemy_sprite.x - 30
    y = @current_enemy_sprite.y - @frame - @current_enemy_sprite.height / 2 - 20
    self.bitmap.font.bold = true
    if damage >= 0
      self.bitmap.font.color = Saba::Sekaiju::DAMAGE_COLOR
    else
      self.bitmap.font.color = Saba::Sekaiju::RECOVER_COLOR
      damage = damage.abs
    end
    self.bitmap.font.size = Saba::Sekaiju::FONT_SIZE
    self.bitmap.draw_text(x, y, 60, 32, damage.to_s, 1)
  end
end

#==============================================================================
# ■ Sprite_TargetEnemySelection
#------------------------------------------------------------------------------
#  战斗中,敌人选择光标表示精灵。。
#==============================================================================
class Sprite_TargetEnemySelection < Sprite
  attr_accessor :help_window
  #--------------------------------------------------------------------------
  # ● 对象初期化
  #--------------------------------------------------------------------------
  def initialize(viewport, enemy_sprites)
    super(viewport)
    @enemy_sprites = enemy_sprites.reverse
    @enemies = []
    for enemy in $game_troop.members
      next unless enemy.exist?
      @enemies.push(enemy)
    end
    self.bitmap = Bitmap.new(Saba::Sekaiju::WINDOW_WIDTH, Saba::Sekaiju::WINDOW_HEIGHT)
    @index = 0
    @item_max = @enemy_sprites.size
    @windowskin = Cache.system("Window")
    @state_mode = false
    refresh
  end
  #--------------------------------------------------------------------------
  # ● 解放
  #--------------------------------------------------------------------------
  def dispose
    self.bitmap.dispose
    super
  end
  #--------------------------------------------------------------------------
  # ● 帮助窗口的設定。
  #--------------------------------------------------------------------------
  def help_window=(value)
    @help_window = value
    refresh
  end
  #--------------------------------------------------------------------------
  # ● 敵角色对象取得
  #--------------------------------------------------------------------------
  def enemy
    return @enemy_sprites[@index].battler
  end
  #--------------------------------------------------------------------------
  # ● 描画的更新。
  #--------------------------------------------------------------------------
  def refresh
    self.bitmap.clear_rect(0, 0, Saba::Sekaiju::WINDOW_WIDTH, 400)
    auto_select
   
    enemy_sprite = @enemy_sprites[@index]
    battler = enemy_sprite.battler
    @help_window.set_text(battler.name) if (@help_window != nil && !@help_window.disposed?)
    load_cursor_image(battler)
    # 順番を逆
    draw_cursor(enemy_sprite.x, Saba::Sekaiju::TARGET_CURSOR_Y + offset_y)
    draw_status(enemy_sprite, enemy_sprite.x + Saba::Sekaiju::TARGET_STATE_OFFSET_X, Saba::Sekaiju::TARGET_STATE_Y)
    draw_bars(enemy_sprite, battler)
  end
  def offset_y
    return 0 unless Saba::Sekaiju::ADJUST_TARGET_WINDOW_Y
    enemy_sprite = @enemy_sprites[@index]

    n = enemy_sprite.y - enemy_sprite.height / 2 - 150
    max_y = Saba::Sekaiju::ENEMY_SELECTION_WINDOW_MAX_Y
    min_y = Saba::Sekaiju::ENEMY_SELECTION_WINDOW_MIN_Y
    n = [[n, max_y].min, min_y].max
    return n
  end
  #--------------------------------------------------------------------------
  # ● 光标的图片读取。。
  #--------------------------------------------------------------------------
  def load_cursor_image(battler)
    case Saba::Sekaiju::PARAMETER_TYPE
    when 0
      @cursor = Cache.system("Cursor")
    when 1
      if Saba::Sekaiju::NOT_DRAW_MAX_MP_0 && battler.maxmp == 0
        @cursor = Cache.system("Cursor")
      else
        @cursor = Cache.system("Cursor_mp")
      end
    when 2
      if battler.use_overdrive_skill?
        @cursor = Cache.system("Cursor_od")
      else
        @cursor = Cache.system("Cursor")
      end
    when 3
      if battler.use_overdrive_skill?
        @cursor = Cache.system("Cursor_mp_od")   
      else
        if Saba::Sekaiju::NOT_DRAW_MAX_MP_0 && battler.maxmp == 0
          @cursor = Cache.system("Cursor")
        else
          @cursor = Cache.system("Cursor_mp")
        end
      end
    end
  end
  #--------------------------------------------------------------------------
  # ● 敌人的参数绘制。。
  #--------------------------------------------------------------------------
  def draw_bars(enemy_sprite, battler)
    case Saba::Sekaiju::PARAMETER_TYPE
    when 0
      draw_only_hp_bar(enemy_sprite, battler)
    when 1
      if Saba::Sekaiju::NOT_DRAW_MAX_MP_0 && battler.maxmp == 0
        draw_only_hp_bar(enemy_sprite, battler)
      else
        draw_hp_and_mp_bar(enemy_sprite, battler)
      end
    when 2
      if battler.use_overdrive_skill?
        draw_hp_and_od_bar(enemy_sprite, battler)
      else
        draw_only_hp_bar(enemy_sprite, battler)
      end
    when 3
      if battler.use_overdrive_skill?
        draw_all_bar(enemy_sprite, battler)
      else
        if Saba::Sekaiju::NOT_DRAW_MAX_MP_0 && battler.maxmp == 0
          draw_only_hp_bar(enemy_sprite, battler)
        else
          draw_hp_and_mp_bar(enemy_sprite, battler)
        end
      end
    end
  end
  #--------------------------------------------------------------------------
  # ● HP条的描画。
  #--------------------------------------------------------------------------
  def draw_only_hp_bar(enemy_sprite, battler)
    x = enemy_sprite.x - 14
    if Saba::Checker::define?(battler.enemy, "HIDE_HP")
      draw_question(enemy_sprite, x, Saba::Sekaiju::TARGET_CURSOR_Y + offset_y)
    else
      draw_hp_bar(enemy_sprite, x, Saba::Sekaiju::TARGET_CURSOR_Y+ offset_y)
    end
  end
  #--------------------------------------------------------------------------
  # ● HP条とMP条的描画。
  #--------------------------------------------------------------------------
  def draw_hp_and_mp_bar(enemy_sprite, battler)
    x = enemy_sprite.x - 14
    if Saba::Checker::define?(battler.enemy, "HIDE_HP")
      draw_question(enemy_sprite, x, Saba::Sekaiju::TARGET_CURSOR_Y - 1+ offset_y)
    else
      draw_hp_bar(enemy_sprite, x, Saba::Sekaiju::TARGET_CURSOR_Y - 1+ offset_y)
    end
    draw_mp_bar(enemy_sprite, x, Saba::Sekaiju::TARGET_CURSOR_Y + 7+ offset_y)
  end
  #--------------------------------------------------------------------------
  # ● HP条和超级气力条的描画。
  #--------------------------------------------------------------------------
  def draw_hp_and_od_bar(enemy_sprite, battler)
    x = enemy_sprite.x - 14
    if Saba::Checker::define?(battler.enemy, "HIDE_HP")
      draw_question(enemy_sprite, x, Saba::Sekaiju::TARGET_CURSOR_Y - 1+ offset_y)
    else
      draw_hp_bar(enemy_sprite, x, Saba::Sekaiju::TARGET_CURSOR_Y - 1+ offset_y)
    end
    draw_od_bar(enemy_sprite, x, Saba::Sekaiju::TARGET_CURSOR_Y + 7+ offset_y)
  end
  #--------------------------------------------------------------------------
  # ● HP条和MP条和超级气力条的描画。
  #--------------------------------------------------------------------------
  def draw_all_bar(enemy_sprite, battler)
    x = enemy_sprite.x - 14
    if Saba::Checker::define?(battler.enemy, "HIDE_HP")
      draw_question(enemy_sprite, x, Saba::Sekaiju::TARGET_CURSOR_Y - 1+ offset_y)
    else
      draw_hp_bar(enemy_sprite, x, Saba::Sekaiju::TARGET_CURSOR_Y - 1+ offset_y)
    end
    draw_mp_bar(enemy_sprite, x, Saba::Sekaiju::TARGET_CURSOR_Y + 7+ offset_y)
    draw_od_bar(enemy_sprite, x, Saba::Sekaiju::TARGET_CURSOR_Y + 15+ offset_y)
  end
  #--------------------------------------------------------------------------
  # ● 敵的状态的描画。
  #--------------------------------------------------------------------------
  def draw_status(enemy_sprite, x, y)
    enemy_battler = enemy_sprite.battler
    count = 0
    for state in enemy_battler.states
      draw_icon(state.icon_index, x + Saba::Sekaiju::TARGET_STATE_INTERVAL * count, y)
      count += 1
    end
  end
  #--------------------------------------------------------------------------
  # ● 图标的描画
  #     icon_index : 图标番号
  #     x          : 描画先 X 座標
  #     y          : 描画先 Y 座標
  #     enabled    : 有効标记。false 的话半透明的描画
  #--------------------------------------------------------------------------
  def draw_icon(icon_index, x, y, enabled = true)
    bitmap = Cache.system("Iconset")
    rect = Rect.new(icon_index % 16 * 24, icon_index / 16 * 24, 24, 24)
    self.bitmap.blt(x, y, bitmap, rect, enabled ? 255 : 128)
  end
  #--------------------------------------------------------------------------
  # ● 光标的描画。
  #--------------------------------------------------------------------------
  def draw_cursor(x, y)
    self.bitmap.fill_rect(x - 36, y - 8, 72, 11, Saba::Sekaiju::TARGET_BG_COLOR)
    self.bitmap.font.size = 12
    #self.bitmap.draw_text(x - 32, y - 10, 108, 15, "HP")
    self.bitmap.blt(x - @cursor.width / 2, y - 14, @cursor, Rect.new(0, 0, @cursor.width, @cursor.height))
  end
  #--------------------------------------------------------------------------
  # ● 敵的HP欄???的描画。
  #--------------------------------------------------------------------------
  def draw_question(enemy_sprite, x, y)
    width = Saba::Sekaiju::BAR_WIDTH
    height = Saba::Sekaiju::HP_BAR_HEIGHT
    y -= height
    color = Saba::Sekaiju::HP_BAR_BG_COLOR
    weight = Saba::Sekaiju::BAR_BORDER_WEIGHT
    self.bitmap.fill_rect(x - weight, y - weight, width + weight * 2, height + weight * 2, Saba::Sekaiju::HP_BAR_BORDER_COLOR)
    self.bitmap.fill_rect(x, y, width, height, color)
    self.bitmap.gradient_fill_rect(x, y, width, height, hp_gauge_color1, hp_gauge_color2)
    q = Cache.system("question")
    self.bitmap.blt(x, y - 4, q, Rect.new(0, 0, q.width, q.height))
  end
  #--------------------------------------------------------------------------
  # ● 敵的HP条的描画。
  #--------------------------------------------------------------------------
  def draw_hp_bar(enemy_sprite, x, y)
    width = Saba::Sekaiju::BAR_WIDTH
    height = Saba::Sekaiju::HP_BAR_HEIGHT
    y -= height
    y += Saba::Sekaiju::HP_BAR_OFFSET_Y
    color = Saba::Sekaiju::HP_BAR_BG_COLOR
    weight = Saba::Sekaiju::BAR_BORDER_WEIGHT
    self.bitmap.fill_rect(x - weight, y - weight, width + weight * 2, height + weight * 2, Saba::Sekaiju::HP_BAR_BORDER_COLOR)
    self.bitmap.fill_rect(x, y, width, height, color)
    enemy_battler = enemy_sprite.battler
    width = width * enemy_battler.hp / enemy_battler.maxhp
   
    self.bitmap.gradient_fill_rect(x, y, width, height, hp_gauge_color1, hp_gauge_color2)
  end
  #--------------------------------------------------------------------------
  # ● HP 量规的色 1 返回。
  #--------------------------------------------------------------------------
  def hp_gauge_color1
    if Saba::Sekaiju::USE_SYSTEM_COLOR
      return text_color(20)
    else
      return Saba::Sekaiju::HP_BAR_FG_COLOR_1
    end
  end
  #--------------------------------------------------------------------------
  # ● HP 量规的色 2 返回。
  #--------------------------------------------------------------------------
  def hp_gauge_color2
    if Saba::Sekaiju::USE_SYSTEM_COLOR
      return text_color(21)
    else
      return Saba::Sekaiju::HP_BAR_FG_COLOR_2
    end
  end
  #--------------------------------------------------------------------------
  # ○ 气力量规的通常時的色 1 的取得
  #--------------------------------------------------------------------------
  def od_gauge_normal_color1
    color = KGC::OverDrive::GAUGE_NORMAL_START_COLOR
    return (color.is_a?(Integer) ? text_color(color) : color)
  end
  #--------------------------------------------------------------------------
  # ○ 气力量规的通常時的色 2 的取得
  #--------------------------------------------------------------------------
  def od_gauge_normal_color2
    color = KGC::OverDrive::GAUGE_NORMAL_END_COLOR
    return (color.is_a?(Integer) ? text_color(color) : color)
  end
  #--------------------------------------------------------------------------
  # ○ 气力量规的最大時的色 1 的取得
  #--------------------------------------------------------------------------
  def od_gauge_max_color1
    color = KGC::OverDrive::GAUGE_MAX_START_COLOR
    return (color.is_a?(Integer) ? text_color(color) : color)
  end
  #--------------------------------------------------------------------------
  # ○ 气力量规的最大時的色 2 的取得
  #--------------------------------------------------------------------------
  def od_gauge_max_color2
    color = KGC::OverDrive::GAUGE_MAX_END_COLOR
    return (color.is_a?(Integer) ? text_color(color) : color)
  end
  #--------------------------------------------------------------------------
  # ● 敵的气力条描画。
  #--------------------------------------------------------------------------
  def draw_od_bar(enemy_sprite, x, y)
    enemy_battler = enemy_sprite.battler

    width = Saba::Sekaiju::BAR_WIDTH
   
    n = enemy_battler.overdrive % KGC::OverDrive::GAUGE_MAX
    n = KGC::OverDrive::GAUGE_MAX if enemy_battler.overdrive == enemy_battler.max_overdrive
    gw = width * n / KGC::OverDrive::GAUGE_MAX
    gc1 = (gw == width ? od_gauge_max_color1 : od_gauge_normal_color1)
    gc2 = (gw == width ? od_gauge_max_color2 : od_gauge_normal_color2)
   
    height = Saba::Sekaiju::OVERDRIVE_BAR_HEIGHT
    y -= height
    y += Saba::Sekaiju::OVERDRIVE_BAR_OFFSET_Y
    color = Saba::Sekaiju::HP_BAR_BG_COLOR
    weight = Saba::Sekaiju::BAR_BORDER_WEIGHT
    self.bitmap.fill_rect(x - weight, y - weight, width + weight * 2, height + weight * 2, Saba::Sekaiju::HP_BAR_BORDER_COLOR)
    self.bitmap.fill_rect(x, y, width, height, color)
    enemy_battler = enemy_sprite.battler
    width = width * enemy_battler.overdrive / enemy_battler.maxhp
   
    self.bitmap.gradient_fill_rect(x, y, gw, height, gc1, gc2)
  end
  #--------------------------------------------------------------------------
  # ● 敵的MP条的描画。
  #--------------------------------------------------------------------------
  def draw_mp_bar(enemy_sprite, x, y)
    width = Saba::Sekaiju::BAR_WIDTH
    height = Saba::Sekaiju::MP_BAR_HEIGHT
    y -= height
    y += Saba::Sekaiju::MP_BAR_OFFSET_Y
    color = Saba::Sekaiju::HP_BAR_BG_COLOR
    weight = Saba::Sekaiju::BAR_BORDER_WEIGHT
    self.bitmap.fill_rect(x - weight, y - weight, width + weight * 2, height + weight * 2, Saba::Sekaiju::HP_BAR_BORDER_COLOR)
    self.bitmap.fill_rect(x, y, width, height, color)
    enemy_battler = enemy_sprite.battler
    if enemy_battler.maxmp == 0
      width = 0
    else
      width = width * enemy_battler.mp / enemy_battler.maxmp
    end
   
    self.bitmap.gradient_fill_rect(x, y, width, height, mp_gauge_color1, mp_gauge_color2)
  end
  #--------------------------------------------------------------------------
  # ● MP 量规的色 1 返回。
  #--------------------------------------------------------------------------
  def mp_gauge_color1
    if Saba::Sekaiju::USE_SYSTEM_COLOR
      return text_color(22)
    else
      return Saba::Sekaiju::MP_BAR_FG_COLOR_1
    end
  end
  #--------------------------------------------------------------------------
  # ● HP 量规的色 2 返回。
  #--------------------------------------------------------------------------
  def mp_gauge_color2
    if Saba::Sekaiju::USE_SYSTEM_COLOR
      return text_color(23)
    else
      return Saba::Sekaiju::MP_BAR_FG_COLOR_2
    end
  end
  #--------------------------------------------------------------------------
  # ● 文字色取得
  #     n : 文字色番号 (0~31)
  #--------------------------------------------------------------------------
  def text_color(n)
    x = 64 + (n % 8) * 8
    y = 96 + (n / 8) * 8
    return @windowskin.get_pixel(x, y)
  end
  #--------------------------------------------------------------------------
  # ● 框架更新
  #--------------------------------------------------------------------------
  def update
    super
    if cursor_movable?
      last_index = @index
      if Input.repeat?(Input::RIGHT)
        cursor_right
      end
      if Input.repeat?(Input::LEFT)
        cursor_left
      end
      if @index != last_index
        Sound.play_cursor
      end
    end
    refresh
  end
  #--------------------------------------------------------------------------
  # ● 光标的移動可能判定
  #--------------------------------------------------------------------------
  def cursor_movable?
    return false if (not visible)
    return true
  end
  #--------------------------------------------------------------------------
  # ● 光标向右移動
  #--------------------------------------------------------------------------
  def cursor_right
    increment
    battler = @enemy_sprites[@index].battler
    while ! (battler.exist? && (! battler.hidden))
      increment
      battler = @enemy_sprites[@index].battler
    end
  end
  
  def increment
    @index = (@index + 1) % @item_max
  end
  #--------------------------------------------------------------------------
  # ● 光标向左移動
  #--------------------------------------------------------------------------
  def cursor_left
    decrement
    battler = @enemy_sprites[@index].battler
    while ! (battler.exist? && (! battler.hidden))
      decrement
      battler = @enemy_sprites[@index].battler
    end
  end
  
  def decrement
    @index = (@index - 1 + @item_max) % @item_max
  end
  
  def auto_select
    battler = @enemy_sprites[@index].battler
    unless battler.exist? && (! battler.hidden)
      cursor_right
    end
  end
end

#==============================================================================
# ■ Scene_Battle
#------------------------------------------------------------------------------
#  世界树的迷宫的战斗场面。。
#==============================================================================
class Scene_Battle < Scene_Base

  #--------------------------------------------------------------------------
  # ● 戦闘開始的処理
  #--------------------------------------------------------------------------
  def process_battle_start
    @waiting = false
    @message_window.clear
    wait(10)
    if Saba::Sekaiju::SHOW_ENEMY_NAME_WHEN_ENEMY_APPEARS
      for name in $game_troop.enemy_names
        text = sprintf(Vocab::Emerge, name)
        $game_message.texts.push(text)
      end
    else
      if enemy_count <= 1
        text = Saba::Sekaiju::MESSAGE_WHEN_ENEMY_APPEARS
      else
        text = Saba::Sekaiju::MESSAGE_WHEN_ENEMIES_APPEAR
      end
      $game_message.texts.push(text)
    end
    if $game_troop.preemptive
      text = sprintf(Vocab::Preemptive, $game_party.name)
      $game_message.texts.push(text)
    elsif $game_troop.surprise
      text = sprintf(Vocab::Surprise, $game_party.name)
      $game_message.texts.push(text)
    end
    wait_for_message
    @message_window.clear
    make_escape_ratio
    process_battle_event
    start_party_command_selection
  end
  def enemy_count
    n = 0
    for enemy in $game_troop.members
      n += 1 unless enemy.hidden
    end
    return n
  end
  #--------------------------------------------------------------------------
  # ● 戦闘行動的処理
  #--------------------------------------------------------------------------
  alias saba_sekaiju_process_action process_action
  def process_action
    saba_sekaiju_process_action
    @enemy_state_sprite.refresh
  end
  #--------------------------------------------------------------------------
  # ● 勝利的処理 ◆◆◆ 改造 ◆◆◆
  #--------------------------------------------------------------------------
  def process_victory
    @message_window.visible = true
    RPG::BGM.stop
#~     $game_system.battle_end_me.play
    unless $BTEST
      Audio.bgm_play("Audio/BGM/DDS1_12", 80, 100)
#~       $game_temp.map_bgm.play
#~       $game_temp.map_bgs.play
    end
    @message_window.max_line = Saba::Sekaiju::VICTORY_MESSAGE_LINES
    display_exp_and_gold
    # 虚拟战斗如果不是
    unless $game_switches[105]
      display_mag           # MAG取得表示
      display_drop_items
      #display_level_up     # 「角色毎にレベルアップ対策」と的連携
      RPG::BGM.stop
    end
    battle_end(0)
  end
  
  alias saba_sekai_dispose_info_viewport dispose_info_viewport
  def dispose_info_viewport
    @enemy_damage_sprite.dispose
    @enemy_state_sprite.dispose
    @actor_viewport.dispose
    @face_sprite.dispose
    @help_window.dispose unless @help_window == nil
    @turn_sprite.dispose
    @turn_window.dispose
    saba_sekai_dispose_info_viewport
  end
  #--------------------------------------------------------------------------
  # ● 獲得的 経験値 和 所持金 的表示
  # 信息行两行的,胜利信息被删除, 只表示EXP画面和金钱,。
  #--------------------------------------------------------------------------
  def display_exp_and_gold
    exp = $game_troop.exp_total
    gold = $game_troop.gold_total
    $game_party.gain_gold(gold)
    text = sprintf(Vocab::Victory, $game_party.name)
    if exp > 0
      text = sprintf(Vocab::ObtainExp, exp)
      $game_message.texts.push('\.' + text)
    end
    if gold > 0
      text = sprintf(Vocab::ObtainGold, gold, Vocab::gold)
      $game_message.texts.push('\.' + text)
    end
    wait_for_message
  end

  #--------------------------------------------------------------------------
  # ● 角色指令選択的更新
  #--------------------------------------------------------------------------
#~   alias saba_sekai_update_actor_command_selection update_actor_command_selection
#~   def update_actor_command_selection
#~     if Saba::Sekaiju::INFO_TYPE == 1
#~       return if update_state_window_visible_type1
#~     end

#~     
#~     if Input.trigger?(Input::B)
#~       return if @actor_index == 0
#~     end
#~     if Input.trigger?(Input::L)
#~       if Saba::Sekaiju::AUTO_BATTLE_ENABLED
#~         Sound.play_decision
#~         auto_battle
#~         return
#~       end
#~     end
#~     
#~     if $imported["SeparationCommand"]
#~       if Input.trigger?(Input::C)
#~         index = @actor_command_window.index
#~         case index
#~         when @actor_command_window.escape_index     # 逃走
#~           set_escape_action
#~           return
#~         when @actor_command_window.guard_index      # 防御
#~           set_guard_action
#~           return
#~         end
#~       end
#~     else
#~       if Input.trigger?(Input::C)
#~         case @actor_command_window.index
#~         when 2  # 防御  wait放入只是为了想重新定义。。
#~           set_guard_action
#~           return
#~         when 4  # 逃走
#~           set_escape_action
#~           return
#~         end
#~       end
#~     end
#~     saba_sekai_update_actor_command_selection
#~   end

  
  def update_state_window_visible_type1
    if @state_mode
      if Input.trigger?(Input::A) || Input.trigger?(Input::B) || Input.trigger?(Input::C)
        close_state_window
        return true
      end
    else
      if Input.trigger?(Input::A)
        start_state_mode
        return true
      end
    end
    return false
  end
  
  def start_state_mode
    case Saba::Sekaiju::INFO_TYPE
      when 0
        return
      when 1
        @state_window = Window_State.new
        @state_mode = true
      when 2
        @state_mode = true
        @status_window.show_all_states
        @enemy_state_sprite.visible = true
    end
  end
  
  def update_state_window

    if Input.trigger?(Input::B)
      close_state_window
    end
    if Input.trigger?(Input::C)
      close_state_window
    end
  end
  
  def close_state_window
    return unless @state_mode
   
    case Saba::Sekaiju::INFO_TYPE
      when 1
        if @state_window != nil
           @state_window.dispose
           @state_window = nil
        end
        @state_mode = false
      when 2
        @state_mode = false
        @status_window.hide_all_states
        @enemy_state_sprite.visible = false
    end
   
  end
  
  def set_escape_action
#~     if $game_troop.can_escape
    if $game_troop.can_escape || @active_battler.id >= 10 # ◆ 改造 仲魔的话就一定实行
      Sound.play_decision
      @active_battler.action.set_escape
      wait(10)
      next_actor
    else
      Sound.play_buzzer
    end
  end
  
  def set_guard_action
    Sound.play_decision
    @active_battler.action.set_guard
    wait(10)
    next_actor
  end
  
  #--------------------------------------------------------------------------
  # ● 回合終了
  #--------------------------------------------------------------------------
  alias saba_sekaiju_turn_end turn_end
  def turn_end
    saba_sekaiju_turn_end
    @turn_sprite.increase_turn
  end
  
  def auto_battle
    for actor in $game_party.members
      actor.make_action
    end
    if Saba::Sekaiju::INFO_TYPE == 1
      close_state_window
    end
    start_main
  end
  #--------------------------------------------------------------------------
  # ● 情報表示视窗口的作成 ◆◆◆ 改造 ◆◆◆
  #--------------------------------------------------------------------------
  def create_info_viewport
    @info_viewport = Viewport.new(0, 0, Saba::Sekaiju::WINDOW_WIDTH, Saba::Sekaiju::WINDOW_HEIGHT)
    @info_viewport.z = Saba::Sekaiju::STATUS_WINDOW_Z
   
    @actor_command_window = Window_ActorCommand.new
   
    @actor_viewport = Viewport.new(0, 0, Saba::Sekaiju::WINDOW_WIDTH, Saba::Sekaiju::WINDOW_HEIGHT)
    @actor_viewport.ox = 576
    @actor_viewport.z = Saba::Sekaiju::FACE_Z
    @actor_command_window.viewport = @actor_viewport
    @face_sprite = FaceSprite.new(@actor_viewport)
    @status_window = ActorWindowSet.new(@face_sprite)
    @status_window.viewport = @info_viewport
    @status_window.show_face = true
    @actor_command_window.x = Saba::Sekaiju::COMMAND_WINDOW_X
    @actor_command_window.y = Saba::Sekaiju::COMMAND_WINDOW_Y
    @actor_command_window.visible = false
    @info_viewport.visible = true
    #◆ 改造 ◆----------------------------------------------------------------
    @message_window.y = 288   # 信息窗口位置
    @message_window.z = 400   # 信息窗口最前面
    #--------------------------------------------------------------------------
    @party_command_window = Window_Base.new(-100, 0, 36, 33)
    @party_command_window.active = false
    @enemy_state_sprite = Sprite_EnemyState.new(@info_viewport, @spriteset.enemy_sprites)
    @enemy_damage_sprite = Sprite_EnemyDamage.new(@info_viewport, @spriteset.enemy_sprites)
    @enemy_state_sprite.visible = Saba::Sekaiju::DISPLAY_ALWAYS
    @turn_sprite = Sprite_Turn.new(@info_viewport)
    @turn_sprite.visible = Saba::Sekaiju::show_turn_count?
    if Saba::Sekaiju::TURN_WINDOW_ALIGN == 0
      @turn_window = Window_Base.new(0, Saba::Sekaiju::TURN_WINDOW_Y, Saba::Sekaiju::TURN_WINDOW_WIDTH, Saba::Sekaiju::TURN_WINDOW_HEIGHT)
    else
      @turn_window = Window_Base.new(Saba::Sekaiju::WINDOW_WIDTH - Saba::Sekaiju::TURN_WINDOW_WIDTH, Saba::Sekaiju::TURN_WINDOW_Y, Saba::Sekaiju::TURN_WINDOW_WIDTH, Saba::Sekaiju::TURN_WINDOW_HEIGHT)
    end
    @turn_window.visible = Saba::Sekaiju::SHOW_TURN_WINDOW && Saba::Sekaiju::show_turn_count?
    @turn_window.viewport = @info_viewport
    @turn_sprite.z = 380
  end
  #--------------------------------------------------------------------------
  # ● 状态変化的表示
  #     target : 対象者
  #     obj    : 技能或物品
  #--------------------------------------------------------------------------
  def display_state_changes(target, obj = nil)
    return if target.missed or target.evaded
    return unless target.states_active?
    if @message_window.line_number < 2
      @message_window.add_instant_text("")
    end
    display_added_states(target, obj)
    display_removed_states(target, obj)
    display_remained_states(target, obj)
    if @message_window.last_instant_text.empty?
      @message_window.back_one
    else
      wait(10)
    end
    @status_window.refresh
  end
  #--------------------------------------------------------------------------
  # ● 落空的表示
  #     target : 対象者
  #     obj    : 技能或物品
  #--------------------------------------------------------------------------
  alias saba_sekaju_display_miss display_miss
  def display_miss(target, obj = nil)
    if target.actor?
      @status_window.display_miss(target)
    else
      @enemy_damage_sprite.display_miss(target)
    end
    saba_sekaju_display_miss(target, obj)
  end
  #--------------------------------------------------------------------------
  # ● 回避的表示
  #     target : 対象者
  #     obj    : 技能或物品
  #--------------------------------------------------------------------------
  alias saba_sekaju_display_evasion display_evasion
  def display_evasion(target, obj = nil)
    if target.actor?
      @status_window.display_miss(target)
    else
      @enemy_damage_sprite.display_miss(target)
    end
    saba_sekaju_display_evasion(target, obj)
  end
  #--------------------------------------------------------------------------
  # ● 失敗的表示
  #     target : 対象者 (角色)
  #     obj    : 技能或物品
  #--------------------------------------------------------------------------
  alias saba_sekaju_display_failure display_failure
  def display_failure(target, obj)
    return if @show_damage
    if target.actor?
      @status_window.display_miss(target)
    else
      @enemy_damage_sprite.display_miss(target)
    end
    saba_sekaju_display_failure(target, obj)
  end
  #--------------------------------------------------------------------------
  # ● HP 受创点表示
  #     target : 対象者
  #     obj    : 技能或物品
  #--------------------------------------------------------------------------
  alias saba_sekaju_display_hp_damage display_hp_damage
  def display_hp_damage(target, obj = nil)
    @show_damage = true unless target.hp_damage == 0
    if target.actor?
      @status_window.display_hp_damage(target)
    else
      @enemy_damage_sprite.display_hp_damage(target, obj)
    end
    saba_sekaju_display_hp_damage(target, obj)
  end
  #--------------------------------------------------------------------------
  # ● 技能選択的開始
  #--------------------------------------------------------------------------
  def start_skill_selection
    @skill_window = Window_BattleSkill.new(Saba::Sekaiju::SKILL_WINDOW_X, Saba::Sekaiju::SKILL_WINDOW_Y, Saba::Sekaiju::SKILL_WINDOW_WIDTH, Saba::Sekaiju::SKILL_WINDOW_HEIGHT, @active_battler)
    @skill_window.help_window = @help_window
    @skill_window.viewport = @actor_viewport
    @actor_command_window.active = false
    adjust_skill_window_size if $imported["HelpExtension"] == true
  end
  #--------------------------------------------------------------------------
  # ● 戦闘処理的実行開始
  #--------------------------------------------------------------------------
  def start_main
    $game_troop.increase_turn
    unless @help_window == nil
      @help_window.dispose
      @help_window = nil
    end
    @message_window.visible = true
    @actor_command_window.active = false
    @actor_command_window.visible = false
    @status_window.index = @actor_index = -1
    @active_battler = nil
    @message_window.clear
    @show_damage = false
    $game_troop.make_actions
    make_action_orders
    wait(20)
  end
  #--------------------------------------------------------------------------
  # ● 队友指令選択的開始
  #--------------------------------------------------------------------------
  def start_party_command_selection
    return if judge_win_loss
    if $game_temp.in_battle
      @status_window.refresh
      @status_window.index = @actor_index = -1
      @active_battler = nil
      @info_viewport.visible = true
      @message_window.visible = false
      @actor_command_window.active = true
      @actor_command_window.visible = true
      @help_window = Window_TargetName.new if @help_window == nil
      @help_window.set_text(Saba::Sekaiju::COMMAND_MESSAGE)
      $game_party.clear_actions
      if $game_troop.surprise or not $game_party.inputable?
        start_main
      else
        @status_window.index = @actor_index = -1
        next_actor
      end
    end
  end
  #--------------------------------------------------------------------------
  # ● 技能選択的終了
  #--------------------------------------------------------------------------
  alias saba_sekaiju_end_skill_selection end_skill_selection
  def end_skill_selection
    saba_sekaiju_end_skill_selection
    @help_window = Window_TargetName.new if @help_window == nil
    @help_window.set_text(Saba::Sekaiju::COMMAND_MESSAGE) unless @actor_index == $game_party.members.size-1
  end
  #--------------------------------------------------------------------------
  # ● 物品選択的終了
  #--------------------------------------------------------------------------
  alias saba_sekaiju_end_item_selection end_item_selection
  def end_item_selection
    saba_sekaiju_end_item_selection
    @help_window = Window_TargetName.new if @help_window == nil
    @help_window.set_text(Saba::Sekaiju::COMMAND_MESSAGE) unless @actor_index == $game_party.members.size-1
  end
  #--------------------------------------------------------------------------
  # ● 角色指令選択的開始
  #--------------------------------------------------------------------------
  alias saba_sekaiju_start_actor_command_selection start_actor_command_selection
  def start_actor_command_selection
    saba_sekaiju_start_actor_command_selection
    @help_window.set_text(Saba::Sekaiju::COMMAND_MESSAGE)
  end
  #--------------------------------------------------------------------------
  # ● 物品選択的開始
  #--------------------------------------------------------------------------
  def start_item_selection
    @item_window = Window_BattleItem.new(Saba::Sekaiju::ITEM_WINDOW_X, Saba::Sekaiju::ITEM_WINDOW_Y, Saba::Sekaiju::ITEM_WINDOW_WIDTH, Saba::Sekaiju::ITEM_WINDOW_HEIGHT)
    @item_window.help_window = @help_window
    @item_window.viewport = @actor_viewport
    @actor_command_window.active = false
    adjust_item_window_size if $imported["HelpExtension"] == true
  end
  #--------------------------------------------------------------------------
  # ● 戦闘行動的実行 : 攻撃
  #--------------------------------------------------------------------------
  alias saba_sekaiju_execute_action execute_action
  def execute_action
    select_active_actor
   
    @show_damage = false
    saba_sekaiju_execute_action
  end
  #--------------------------------------------------------------------------
  # ● 行動中的战斗選択状態。
  #--------------------------------------------------------------------------
  def select_active_actor
    return unless Saba::Sekaiju::SELECT_ACTIVE_ACTOR
    unless @active_battler.actor?
      @status_window.index = -1
      return
    end
    @status_window.index = $game_party.battle_members.index(@active_battler)
    @face_sprite.appear = false
  end
  def prior_actor
    loop do
      if @actor_index == 0
        break
      end
      @actor_index -= 1
      @active_battler = $game_party.members[@actor_index]
      next if @active_battler.auto_battle
      break if @active_battler.inputable?
    end
    next_actor unless @active_battler.inputable?
    @status_window.index = @actor_index
    start_actor_command_selection
  end
  #--------------------------------------------------------------------------
  # ● 対象角色対象選択的開始
  #--------------------------------------------------------------------------
  def start_target_actor_selection
    wait(8)
    @face_sprite.hide = true
    @target_actor_window = @status_window
    @status_window.show_face = false
    @status_window.index = 0
    @status_window.active = true
    @actor_command_window.active = false
  end
  #--------------------------------------------------------------------------
  # ● 対象角色選択的終了
  #--------------------------------------------------------------------------
  def end_target_actor_selection(update_index = false)
    @face_sprite.appear = true
    @target_actor_window = nil
    @status_window.show_face = true
    if update_index
      @status_window.index = @actor_index
    end
    @status_window.active = false
    @wait_for_actor = false
  end
  #--------------------------------------------------------------------------
  # ● 対象角色選択的更新
  #--------------------------------------------------------------------------
  def update_target_actor_selection
    #@status_window.update
    if Input.trigger?(Input::B)
      Sound.play_cancel
      end_target_actor_selection(true)
    elsif Input.trigger?(Input::C)
      Sound.play_decision
      @active_battler.action.target_index = @status_window.index
      end_skill_selection
      end_item_selection
      end_target_actor_selection
      @help_window.set_text("") if @actor_index == $game_party.members.size-1
      next_actor
   
    end
  end
  #--------------------------------------------------------------------------
  # ● 一定時間等待 ◆◆◆ 改造 ◆◆◆
  #     duration : 等待時間 (框架数)
  #     no_fast  : 早送無効
  #    场景类的 update 処理的中等待为了挂的方法。
  #    update は 1 框架に 1 回呼暴露的原则,但战斗中处理的流动
  #    难以把握。因此,例外的使用方法。。
  #--------------------------------------------------------------------------
  def wait(duration, no_fast = false)
    @waiting = true
    duration /= 30 if Input.press?(Input::L)# || Input.press?(Input::B) # ◆時間短縮
    for i in 0...duration
      update_basic
      update_info_viewport
      break if not no_fast and i >= duration / 2 and show_fast?
    end
    @waiting = false
#~     @waiting = true
#~     duration_for_loop = duration
#~     duration_for_loop /= 2 if Scene_Battle.method_defined?("show_fasteststr06?")
#~     for i in 0...duration_for_loop
#~       update_basic
#~       update_info_viewport
#~       if Scene_Battle.method_defined?("show_fasteststr06?")
#~         break if not no_fast and i >= duration / STRRGSS2::STR06FAST and show_fast?
#~         break if show_fasteststr06?
#~       else
#~         break if not no_fast and i >= duration / 2 and show_fast?
#~       end
#~     end
#~     @waiting = false
#~     if $imported["AdjustBattleWait"] == true
#~       for sprite in @spriteset.enemy_sprites
#~         sprite.clear_animation if sprite.effect_type == 2
#~       end
#~     end
  end
  #--------------------------------------------------------------------------
  # ● 信息表示结束前等待
  #--------------------------------------------------------------------------
  def wait_for_message
    @message_window.update
    while $game_message.visible
      update_basic
      update_info_viewport
    end
  end
  #--------------------------------------------------------------------------
  # ● 动画表示结束前等待
  #--------------------------------------------------------------------------
  def wait_for_animation
    while @spriteset.animation?
      update_basic
      update_info_viewport
      if Scene_Battle.method_defined?("show_fasteststr06?")
        break if show_fasteststr06?
      end
    end
  end
  #--------------------------------------------------------------------------
  # ● 情報表示视窗口的更新
  #--------------------------------------------------------------------------
  def update_info_viewport
    unless @state_mode && (Saba::Sekaiju::INFO_TYPE == 1)
      @actor_command_window.update unless @waiting
    end
    if Saba::Sekaiju::INFO_TYPE == 2
      unless Saba::Sekaiju::DISPLAY_ALWAYS
        @enemy_state_sprite.visible = @status_window.state_mode
      end
    end
    @status_window.update
    @enemy_damage_sprite.update
    @enemy_state_sprite.update
    if @face_sprite.hide
      if @actor_viewport.ox < 576
        @actor_viewport.ox += Saba::Sekaiju::DISTANCE_PER_FRAME
      else
        @face_sprite.hide = false
      end
    elsif @face_sprite.appear
      if @actor_viewport.ox > 0
        @actor_viewport.ox -= Saba::Sekaiju::DISTANCE_PER_FRAME
      else
        @face_sprite.appear = false
      end
    end
  end
  #--------------------------------------------------------------------------
  # ● 物品的決定 ◆◆◆ 改造 ◆◆◆
  #--------------------------------------------------------------------------
  def determine_item
    @active_battler.action.set_item(@item.id)
    @item_window.active = false
    if @item.need_selection?
      if @item.for_opponent?
        start_target_enemy_selection
      else
        start_target_actor_selection
      end
    else
      wait(8)
      end_item_selection
      end_target_actor_selection(true) # 光标消失
      next_actor
    end
  end
  #--------------------------------------------------------------------------
  # ● 技能的決定
  #--------------------------------------------------------------------------
  def determine_skill
    @active_battler.action.set_skill(@skill.id)
    @skill_window.active = false
    if @skill.need_selection?
      if @skill.for_opponent?
        start_target_enemy_selection
      else
        start_target_actor_selection
      end
    else
      wait(8)
      end_skill_selection
      next_actor
    end
  end
  #--------------------------------------------------------------------------
  # ● 対象敵角色選択的開始
  #--------------------------------------------------------------------------
  def start_target_enemy_selection
    wait(8)
    @target_enemy_window = Sprite_TargetEnemySelection.new(@info_viewport, @spriteset.enemy_sprites)
    @target_enemy_window.y = @info_viewport.rect.y
    @help_window = Window_TargetName.new if @help_window == nil
    if $imported["HelpExtension"] == true
      @help_window.height = Window_Base::WLH + 32
      @help_window.create_contents
    end
    @target_enemy_window.help_window = @help_window
    @actor_command_window.active = false
    @face_sprite.hide = true
  end
  #--------------------------------------------------------------------------
  # ● 対象敵角色選択的更新
  #--------------------------------------------------------------------------
  def update_target_enemy_selection
    @target_enemy_window.update
    if Input.trigger?(Input::B)
      Sound.play_cancel
      end_target_enemy_selection
    elsif Input.trigger?(Input::C)
      Sound.play_decision
      @active_battler.action.target_index = @target_enemy_window.enemy.index
      end_skill_selection
      end_item_selection
      end_target_enemy_selection(@actor_index == $game_party.members.size-1)
      next_actor
    end
  end
  #--------------------------------------------------------------------------
  # ● 対象敵角色選択的終了
  #--------------------------------------------------------------------------
  def end_target_enemy_selection(hide_command = false)
    @target_enemy_window.dispose
    @target_enemy_window = nil
   
    activate_actor_command_wiondow
   
    unless @item_window == nil
      adjust_item_window_size if $imported["HelpExtension"] == true
    end
    unless @skill_window == nil
      adjust_skill_window_size if $imported["HelpExtension"] == true
    end

    unless hide_command
     
      @face_sprite.appear = true
      @help_window.set_text(Saba::Sekaiju::COMMAND_MESSAGE)
    else
      
      @help_window.set_text("")
    end
    @wait_for_actor = false
  end
  #--------------------------------------------------------------------------
  # ● 角色指令窗口的選択状態。
  #--------------------------------------------------------------------------
  def activate_actor_command_wiondow
    if $imported["SeparationCommand"]
      if @actor_command_window.index == @actor_command_window.attack_index
        @actor_command_window.active = true
      end
      if @actor_command_window.own_index_range == nil
        return
      end
      if @actor_command_window.own_index_range.include?(@actor_command_window.index)
        own_index = @actor_command_window.index - @actor_command_window.own_start_index
        command = @active_battler.own_commands[own_index]
        unless command == nil
          case command.kind
            when Game_OwnCommand::KIND_SKILL  # 技能
            skill = command.skill
            @actor_command_window.active = true if skill.need_selection?
          end
        end
      end
    else
      if @actor_command_window.index == 0
        @actor_command_window.active = true
      end
    end
  end
  #--------------------------------------------------------------------------
  # ● 戦闘行動的実行 : 逃走
  #--------------------------------------------------------------------------
  alias saba_sekaiju_execute_action_escape execute_action_escape
  def execute_action_escape
    if @active_battler.actor?
      text = sprintf(Vocab::EscapeStart, @active_battler.name)
      @message_window.add_instant_text(text)
      Sound.play_escape
      if $game_troop.preemptive
        success = true
      else
        success = (rand(100) < @escape_ratio / Saba::Sekaiju::ESCAPE_RATIO_PENALTY)
      end
      wait(45)
      if success
        battle_end(1)
      else
        @escape_ratio += 10
        @message_window.add_instant_text(Vocab::EscapeFailure)
        wait(45)
      end
    else
      saba_sekaiju_execute_action_escape
    end
  end
  def refresh_status_window
    @status_window.dispose
    @status_window = ActorWindowSet.new(@face_sprite)
    @status_window.viewport = @info_viewport
    @status_window.show_face = true
  end
  #--------------------------------------------------------------------------
  # ○ 固有指令処理 KGC Software様的個別戦闘指令的競合回避
  #     index : 指令 index
  #--------------------------------------------------------------------------
  def process_own_command(index)
    command = @active_battler.own_commands[index]
    if command == nil
      Sound.play_buzzer
      return
    end

    # 指令性种类对应的处理
    case command.kind
    when Game_OwnCommand::KIND_SKILL  # 技能
      @input_own_command = true
      # 假人的窗口作成
      #@help_window = Window_Help.new
      #@help_window.visible = false
      @skill_window = Window_Skill.new(0, 0, 64, 64, @active_battler)
      @skill_window.active = false
      @skill_window.visible = false
      # 技能选择的可见
      @skill = command.skill
      if @active_battler.skill_can_use?(@skill)
        Sound.play_decision
        determine_skill
      else
        Sound.play_buzzer
      end
      # 假勿的窗口的破棄
      #@help_window.dispose  if @help_window != nil
      @skill_window.dispose if @skill_window != nil
      #@help_window = nil
      @skill_window = nil
    else                              # 不明的指令
      Sound.play_buzzer
    end
    @input_own_command = false
  end
  #--------------------------------------------------------------------------
  # ● 物品窗口的尺寸調整
  #--------------------------------------------------------------------------
  def adjust_item_window_size
    @help_window.row_max = KGC::HelpExtension::ROW_MAX
    @item_window.y = @help_window.height
    @item_window.height = Graphics.height -
      (@help_window.height + @status_window.height)
      @item_window.y += 4
    @item_window.refresh
  end
  #--------------------------------------------------------------------------
  # ● 技能窗口的尺寸調整
  #--------------------------------------------------------------------------
  def adjust_skill_window_size
    @help_window.row_max = KGC::HelpExtension::ROW_MAX
    @skill_window.y = @help_window.height
    @skill_window.height = Graphics.height -
      (@help_window.height + @status_window.height)
      @skill_window.y += 4
    @skill_window.refresh
  end
end


class Sprite_Battler < Sprite_Base
  attr_accessor :effect_type
  def clear_animation
    @effect_type = 0
    @effect_duration = 0
    update_blink
  end
end
#==============================================================================
# ■ Game_BattleAction
#------------------------------------------------------------------------------
#  角色逃走用的。
#==============================================================================
class Game_BattleAction
  def set_escape
    @kind = 0
    @basic = 2
  end
end

#==============================================================================
# ■ Spriteset_Battle
#------------------------------------------------------------------------------
#  敌人精灵取得。
#==============================================================================
class Spriteset_Battle
  attr_accessor :enemy_sprites
  #--------------------------------------------------------------------------
  # ● 角色精灵的更新 ◆◆◆ 改造 ◆◆◆
  #--------------------------------------------------------------------------
  alias saba_sekai_update_actors update_actors
  def update_actors
    @actor_sprites[4].battler = $game_party.members[4]
    @actor_sprites[5].battler = $game_party.members[5]
    saba_sekai_update_actors
  end
  alias saba_sekai_create_actors create_actors
  def create_actors
    saba_sekai_create_actors
    @actor_sprites.push(Sprite_Battler.new(@viewport8))
    @actor_sprites.push(Sprite_Battler.new(@viewport8))
  end
end

#==============================================================================
# ■ Game_Party
#------------------------------------------------------------------------------
#  
#==============================================================================
class Game_Party < Game_Unit
  
  MAX_MEMBERS = 6 unless $imported["LargeParty"]
  
  MAX_LINES = 3
  attr_accessor :fronts
  attr_accessor :backs
  
  alias saba_ranks_setup_starting_members setup_starting_members
  def setup_starting_members
    saba_ranks_setup_starting_members
    auto_arrange
    update_formation
  end
  #--------------------------------------------------------------------------
  # ● 前列、後列的メン条を全部初期化。
  #--------------------------------------------------------------------------
  def clear_formation
    @fronts = []
    @backs = []
  end
  #--------------------------------------------------------------------------
  # ● 前列的メン条追加。
  #--------------------------------------------------------------------------
  def add_front(actor)
    return if @fronts.include?(actor)
    if @fronts.size == 3
      add_back(actor)
      return
    end
    actor.position_in_ranks = @fronts.size
    actor.front = true
    @fronts.push(actor)
  end
  #--------------------------------------------------------------------------
  # ● 後列的メン条追加。
  #--------------------------------------------------------------------------
  def add_back(actor)
    return if @backs.include?(actor)
    if @backs.size == 3
      add_front(actor)
      return
    end
    actor.position_in_ranks = @backs.size
    actor.front = false
    @backs.push(actor)
  end
  #--------------------------------------------------------------------------
  # ● メン条を前排,后排的顺序交换。
  #--------------------------------------------------------------------------
  def update_actors
    @fronts = []
    @backs = []
    for actor in battle_members
      if actor.front?
        actor.position_in_ranks = @fronts.size
        @fronts.push(actor)
      else
        actor.position_in_ranks = @backs.size
        @backs.push(actor)
      end
    end

    $game_player.refresh
  end
  
  def update_formation
    @actors = []
    for actor in @fronts
      @actors.push(actor.id)
    end
    for actor in @backs
      @actors.push(actor.id)
    end
    pack
    $game_player.refresh
  end
  #--------------------------------------------------------------------------
  # ● メン条职业配合的自动配置。
  #--------------------------------------------------------------------------
  def auto_arrange
    @fronts = []
    @backs = []
   
    if Saba::Sekaiju::FORMATION_ENABLED
      for actor in members
        add_front(actor) if actor.class.position == 0
        add_back(actor) unless actor.class.position == 0
      end
    else
      size = members.size
      if size > 0
        add_front(members[0])
      end
      if size > 1
        add_front(members[1])
      end
      case size
      when 3
        add_back(members[2])
      when 4
        add_back(members[2])
        add_back(members[3])
      when 5
        add_front(members[2])
        add_back(members[3])
        add_back(members[4])
      when 6
        add_front(members[2])
        add_back(members[3])
        add_back(members[4])
        add_back(members[5])
      end
    end
  end
  #--------------------------------------------------------------------------
  # ● 如果没有前排,后排的人前排移动。
  #--------------------------------------------------------------------------
  def pack
    return if Saba::Sekaiju::ALLOW_EMPTY_FRONTS
    return unless @fronts.empty?
    for actor in @backs
      add_front(actor)
    end
    @backs = []
  end
  #--------------------------------------------------------------------------
  # ● メン条が全部前列、後列的任何配置是否被归还。
  #--------------------------------------------------------------------------
  def arranged?
    if @fronts == nil
      auto_arrange
    end
    return @fronts.size + @backs.size == members.size
  end
  #--------------------------------------------------------------------------
  # ● 角色追加。同时职业的位置决定自动前列,后排配置。 ◆ 改造 ◆ nil対策
  #--------------------------------------------------------------------------
  alias saba_sekaiju_add_actor add_actor
  def add_actor(actor_id)
    return if (@actors.size >= MAX_MEMBERS) || (@actors.include?(actor_id))
    saba_sekaiju_add_actor(actor_id)
    actor = $game_actors[actor_id]
    if Saba::Sekaiju::FORMATION_ENABLED
      if actor.class.position == nil
        add_back(actor)
      elsif actor.class.position == 0
        add_front(actor)
      else
        add_back(actor)
      end
      update_formation
    else
      auto_arrange
    end
    if $game_temp.in_battle
      $game_party.update_formation
      $scene.refresh_status_window
    end
  end
  
  #--------------------------------------------------------------------------
  # ● 角色离开 ◆◆◆ 改造 ◆◆◆ nil対策
  #     actor_id : 角色 ID
  #--------------------------------------------------------------------------
  alias saba_sekaiju_remove_actor remove_actor
  def remove_actor(actor_id)
    saba_sekaiju_remove_actor(actor_id)
    actor = $game_actors[actor_id]
    if Saba::Sekaiju::FORMATION_ENABLED
      if actor.class.position == nil
        @backs.delete(actor)
      elsif actor.class.position == 0
        @fronts.delete(actor)
      else
        @backs.delete(actor)
      end
      update_actors
    else
      auto_arrange
    end
    if $game_temp.in_battle
      $scene.refresh_status_window
    end
  end
end

#==============================================================================
# ■ Window_ActorCommand
#------------------------------------------------------------------------------
#  战斗画面,战斗和逃跑的选择窗口。逃跑指令追加。
#==============================================================================
class Window_ActorCommand < Window_Command
  #--------------------------------------------------------------------------
  # ● 对象初期化
  #--------------------------------------------------------------------------
  def initialize
    super(Saba::Sekaiju::COMMAND_WINDOW_WIDTH, [], 1, Saba::Sekaiju::COMMAND_COUNT)
    self.active = false
  end
if $imported["SeparationCommand"]
  #--------------------------------------------------------------------------
  # ○ 指令を作成
  #     actor : 角色
  #--------------------------------------------------------------------------
  alias saba_sekaiju_create_commands create_commands
  def create_commands
    saba_sekaiju_create_commands
    @actor.actor_commands.each { |c|
    case c
    when 10  # 逃走
        @command_index[:escape_command] = @commands.size
        @command_enabled[:escape_command] = $game_troop.can_escape
        @commands << Vocab.escape
    end
    }
    @item_max = @commands.size
  end
  #--------------------------------------------------------------------------
  # ○ 「逃走」的開始指针
  #--------------------------------------------------------------------------
  def escape_index
    return @command_index[:escape_command]
  end

else

  #--------------------------------------------------------------------------
  # ● 刷新
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    for i in 0...@item_max - 1
      draw_item(i)
    end
    draw_item(@item_max - 1, $game_troop.can_escape)
  end
  #--------------------------------------------------------------------------
  # ● 设置。逃走 的追加。
  #     actor : 角色
  #--------------------------------------------------------------------------
  def setup(actor)
    s1 = Vocab::attack
    s2 = Vocab::skill
    s3 = Vocab::guard
    s4 = Vocab::item
    s5 = Vocab::escape
    if actor.class.skill_name_valid     # 技能的指令名有効?
      s2 = actor.class.skill_name       # 指令名取代
    end
    @commands = [s1, s2, s3, s4, s5]
    @item_max = 5
    refresh
    self.index = 0
  end
end
end

class FaceSprite
  
  attr_accessor :hide
  attr_accessor :appear
  
  def initialize(viewport)
    @windowskin = Cache.system("Window")
    od_y = 0
    if $imported["OverDrive"]
      @force_image = Cache.system("Force")
      od_y = Saba::Sekaiju::OVER_DRIVE_Y + @force_image.height
    end
    @sprite = Sprite.new(viewport)
    @sprite.y = 0
    face_y = Saba::Sekaiju::FACE_Y
    @sprite.bitmap = Bitmap.new(Saba::Sekaiju::FACE_X + Saba::Sekaiju::FACE_WIDTH, [face_y + od_y].max)
    @hide = false
    @appear = false
    @update_flag = false
    @actor_index = -1
  end
  #--------------------------------------------------------------------------
  # ○ 资源解放。
  #--------------------------------------------------------------------------
  def dispose
    @sprite.bitmap.dispose
    @sprite.dispose
  end
  #--------------------------------------------------------------------------
  # ○ 表示角色隐藏的指针番号設定。(番译存疑)
  #--------------------------------------------------------------------------
  def index=(value)
    if value == -1
      @hide = true
      @appear = false
      return
    end
    @hide = true
    @appear = true
    @actor_index = value
    @update_flag = true
  end
  #--------------------------------------------------------------------------
  # ○ 角色隐藏不显示。
  #--------------------------------------------------------------------------  
  def hide=(value)
    @hide = value
    draw if @update_flag
  end
  #--------------------------------------------------------------------------
  # ○ 描画。
  #--------------------------------------------------------------------------
  def draw
    @update_flag = false
    actor = $game_actors[@actor_index]
    draw_face(Cache.picture(face_image(actor))) if Saba::Sekaiju::SHOW_ACTOR_IMAGE
    if $imported["OverDrive"]  
      draw_actor_od(actor, Saba::Sekaiju::OVER_DRIVE_X, Saba::Sekaiju::OVER_DRIVE_Y)
    end
  end
  #--------------------------------------------------------------------------
  # ○ 顔图像的描画。
  #--------------------------------------------------------------------------
  def draw_face(actor_graphic)
    @sprite.bitmap.clear_rect(Rect.new(Saba::Sekaiju::FACE_X, 0, Saba::Sekaiju::FACE_WIDTH, Saba::Sekaiju::FACE_Y))
    @sprite.bitmap.blt(Saba::Sekaiju::FACE_X, Saba::Sekaiju::FACE_Y - actor_graphic.height, actor_graphic, Rect.new(0, 0, Saba::Sekaiju::FACE_WIDTH, actor_graphic.height))
    @sprite.z = 0
  end
  #--------------------------------------------------------------------------
  # ○ 气力量规的通常時的色 1 的取得
  #--------------------------------------------------------------------------
  def od_gauge_normal_color1
    color = KGC::OverDrive::GAUGE_NORMAL_START_COLOR
    return (color.is_a?(Integer) ? text_color(color) : color)
  end
  #--------------------------------------------------------------------------
  # ○ 气力量规的通常時的色 2 的取得
  #--------------------------------------------------------------------------
  def od_gauge_normal_color2
    color = KGC::OverDrive::GAUGE_NORMAL_END_COLOR
    return (color.is_a?(Integer) ? text_color(color) : color)
  end
  #--------------------------------------------------------------------------
  # ○ 气力量规的最大時的色 1 的取得
  #--------------------------------------------------------------------------
  def od_gauge_max_color1
    color = KGC::OverDrive::GAUGE_MAX_START_COLOR
    return (color.is_a?(Integer) ? text_color(color) : color)
  end
  #--------------------------------------------------------------------------
  # ○ 气力量规的最大時的色 2 的取得
  #--------------------------------------------------------------------------
  def od_gauge_max_color2
    color = KGC::OverDrive::GAUGE_MAX_END_COLOR
    return (color.is_a?(Integer) ? text_color(color) : color)
  end
  #--------------------------------------------------------------------------
  # ● 文字色取得
  #     n : 文字色番号 (0~31)
  #--------------------------------------------------------------------------
  def text_color(n)
    x = 64 + (n % 8) * 8
    y = 96 + (n / 8) * 8
    return @windowskin.get_pixel(x, y)
  end
  #--------------------------------------------------------------------------
  # ● 量规背景色的取得
  #--------------------------------------------------------------------------
  def gauge_back_color
    return text_color(19)
  end
  #--------------------------------------------------------------------------
  # ○ 气力量规的描画。
  #--------------------------------------------------------------------------
  def draw_actor_od(actor, x, y, width = 72, height = 6)
    return unless actor.od_gauge_visible?
    draw_actor_od_gauge(actor, x, y, width, height)
    draw_actor_od_gauge_value(actor, x - 6, y - 7)
  end
  #--------------------------------------------------------------------------
  # ○ 气力量规的条部分的描画。
  #--------------------------------------------------------------------------
  def draw_actor_od_gauge(actor, x, y, width = 72, height = 6)
    @sprite.bitmap.clear_rect(x, y, @force_image.width, @force_image.height)
    color = Saba::Sekaiju::TARGET_BG_COLOR
    @sprite.bitmap.fill_rect(x + 1, y + 1, @force_image.width - 2, @force_image.height - 2, color)
    @sprite.bitmap.blt(x, y, @force_image, Rect.new(0, 0, @force_image.width, @force_image.height))
   
    n = actor.overdrive % KGC::OverDrive::GAUGE_MAX
    n = KGC::OverDrive::GAUGE_MAX if actor.overdrive == actor.max_overdrive
    gw = (width - 2) * n / KGC::OverDrive::GAUGE_MAX
   
    gc1 = (actor.overdrive == actor.max_overdrive ? od_gauge_max_color1 : od_gauge_normal_color1)
    gc2 = (actor.overdrive == actor.max_overdrive ? od_gauge_max_color2 : od_gauge_normal_color2)
    color = Saba::Sekaiju::BOOST_BORDER_COLOR
    offset_x = 44
    offset_y = 7
    @sprite.bitmap.fill_rect(x + offset_x, y + offset_y, width, height, color)
    @sprite.bitmap.fill_rect(x + offset_x + 1, y + offset_y + 1, width - 2, height - 2, gauge_back_color)
    @sprite.bitmap.gradient_fill_rect(x + offset_x + 1, y + offset_y + 1, gw, height - 2, gc1, gc2)
  end
  #--------------------------------------------------------------------------
  # ○ 气力量规的値的描画。
  #--------------------------------------------------------------------------
  def draw_actor_od_gauge_value(actor, x, y, width = 120)
    text = ""
    value = actor.overdrive * 100.0 / KGC::OverDrive::GAUGE_MAX
    case KGC::OverDrive::GAUGE_VALUE_STYLE
    when KGC::OverDrive::ValueStyle::IMMEDIATE
      text = actor.overdrive.to_s
    when KGC::OverDrive::ValueStyle::RATE
      text = sprintf("%d%%", actor.overdrive * 100 / KGC::OverDrive::GAUGE_MAX)
    when KGC::OverDrive::ValueStyle::RATE_DETAIL1
      text = sprintf("%0.1f%%", value)
    when KGC::OverDrive::ValueStyle::RATE_DETAIL2
      text = sprintf("%0.2f%%", value)
    when KGC::OverDrive::ValueStyle::NUMBER
      text = "#{actor.overdrive / KGC::OverDrive::GAUGE_MAX}"
    else
      return
    end
   
    x += Saba::Sekaiju::OVER_DRIVE_VALUE_OFFSET_X
    y += Saba::Sekaiju::OVER_DRIVE_VALUE_OFFSET_Y

    last_font_size = @sprite.bitmap.font.size
    new_font_size = KGC::OverDrive::GAUGE_VALUE_FONT_SIZE
    @sprite.bitmap.font.size = new_font_size
    @sprite.bitmap.draw_text(
      x, y + Window_Base::WLH + KGC::OverDrive::GAUGE_OFFSET_Y - new_font_size / 2,
      width, new_font_size, text, 2)
    @sprite.bitmap.font.size = last_font_size
  end
end

class StatusBackground
  include ActorStatus
  attr_accessor :x
  attr_accessor :y
  attr_accessor :width
  attr_accessor :height
  attr_accessor :visible
  def initialize(actor, image)
    @display_state_mode = false
    @actor = actor
    if front?
      y = BASE_Y
    else
      y = CELL_HEIGHT + BASE_Y
    end
   
    @x = window_x
    @y = y
    @width = window_width
    @height = CELL_HEIGHT

    @image = image
    @frame = 0
    @state_index = 0
    @visible = true
    if actor != nil
      actor.screen_x = x + CELL_WIDTH / 2
      actor.screen_y = y + CELL_HEIGHT / 2 + 20
    end
    save_parameters
  end
  def dispose
    @sprite.dispose
  end
  def viewport=(arg)
    @viewport = arg
    @sprite = Sprite.new(@viewport)
    @bitmap = Cache.system(@image)
    @sprite.bitmap = @bitmap
    @sprite.x = @x
    @sprite.y = @y
    @sprite.visible = @visible
  end
  def update
    update_contents
    @sprite.update
  end
  def visible=(value)
    @visible = value
    @sprite.visible = value if @sprite != nil
  end
  #--------------------------------------------------------------------------
  # ● 通常文字色的取得
  #--------------------------------------------------------------------------
  def normal_color
    return text_color(0)
  end
  #--------------------------------------------------------------------------
  # ● HP 的文字色を取得
  #     actor : 角色
  #--------------------------------------------------------------------------
  def hp_color(actor)
    return knockout_color if actor.hp == 0
    return crisis_color if actor.hp < actor.maxhp / 4
    return normal_color
  end
  #--------------------------------------------------------------------------
  # ● MP 的文字色を取得
  #     actor : 角色
  #--------------------------------------------------------------------------
  def mp_color(actor)
    return crisis_color if actor.mp < actor.maxmp / 4
    return normal_color
  end
  #--------------------------------------------------------------------------
  # ● 文字色取得
  #     n : 文字色番号 (0~31)
  #--------------------------------------------------------------------------
  def text_color(n)
    x = 64 + (n % 8) * 8
    y = 96 + (n / 8) * 8
    windowskin = Cache.system("Window")
    return windowskin.get_pixel(x, y)
  end
  #--------------------------------------------------------------------------
  # ● HP 量规的色 1 的取得
  #--------------------------------------------------------------------------
  def hp_gauge_color1
    return text_color(20)
  end
  #--------------------------------------------------------------------------
  # ● HP 量规的色 2 的取得
  #--------------------------------------------------------------------------
  def hp_gauge_color2
    return text_color(21)
  end
  #--------------------------------------------------------------------------
  # ● MP 量规的色 1 的取得
  #--------------------------------------------------------------------------
  def mp_gauge_color1
    return text_color(22)
  end
  #--------------------------------------------------------------------------
  # ● MP 量规的色 2 的取得
  #--------------------------------------------------------------------------
  def mp_gauge_color2
    return text_color(23)
  end
  #--------------------------------------------------------------------------
  # ● 量规背景色的取得
  #--------------------------------------------------------------------------
  def gauge_back_color
    return text_color(19)
  end
  #--------------------------------------------------------------------------
  # ● 系统文字色的取得
  #--------------------------------------------------------------------------
  def system_color
    return text_color(16)
  end
  #--------------------------------------------------------------------------
  # ● 危机文字色的取得
  #--------------------------------------------------------------------------
  def crisis_color
    return text_color(17)
  end
  #--------------------------------------------------------------------------
  # ● 戦闘不能文字色的取得
  #--------------------------------------------------------------------------
  def knockout_color
    return text_color(18)
  end
end

class DummyStatusBackground < StatusBackground
  include ActorStatus
  def initialize(front, position_in_ranks, image)
    @dummy = true
    @front = front
    @position_in_ranks = position_in_ranks
    super(nil, image)
  end
  def front?
    return @front
  end
  def position_in_ranks
    return @position_in_ranks
  end
end

class ActorWindowSet
  attr_accessor :active
  attr_accessor :show_face
  attr_accessor :state_mode
  attr_accessor :window_size
  
  def initialize(face_sprite)
    @face_sprite = face_sprite
    @index = 0
    @window_size = 0
    @state_mode = false
    @windows = []
    @active_windows = []
    $game_party.auto_arrange unless $game_party.arranged?
    members = $game_party.battle_members
   
    for actor in members   
      @windows.push(window_actor(actor, false))
      @active_windows.push(window_actor(actor, true))
      @window_size += 1
    end
    initialize_dummy_windows
    @all_windows = @windows + @active_windows
    @frame = 30
    @miss = Cache.system("Miss")
   
  end
  def auto_select(value)
    return value unless Saba::Sekaiju::SHOW_EMPTY_ACTOR_STATUS
    return 0 if value >= $game_party.battle_members.size
    return value
  end
  def initialize_dummy_windows
    return unless Saba::Sekaiju::SHOW_EMPTY_ACTOR_STATUS
    (3 - $game_party.fronts.size).times do |i|
      @windows.push(window_dummy_actor(true, i + $game_party.fronts.size))
    end
    (3 - $game_party.backs.size).times do |i|
      @windows.push(window_dummy_actor(false, i + $game_party.backs.size))
    end
  end
  def window_dummy_actor(front, position_in_ranks)
    if Saba::Sekaiju::ACTOR_STATUS_BG_IMAGE == nil
      window = DummyWindow_Actor.new(front, position_in_ranks)
      return window
    else
      image = Saba::Sekaiju::EMPTY_STATUS_BG_IMAGE
      window = DummyStatusBackground.new(front, position_in_ranks, image)
      window.visible = true
      return window
    end
  end
  
  def window_actor(actor, active)
    if Saba::Sekaiju::ACTOR_STATUS_BG_IMAGE == nil
      return Window_Actor.new(actor, active)
    else
      if active
        image = Saba::Sekaiju::ACTOR_STATUS_ACTIVE_BG_IMAGE
      else
        image = Saba::Sekaiju::ACTOR_STATUS_BG_IMAGE
      end
      window = StatusBackground.new(actor, image)
      window.visible = ! active
      return window
    end
  end
  
  def item_max
    return @windows.size
  end
  
  def viewport=(v)
    for window in @all_windows
      window.viewport = v
    end
    @sprite = Sprite.new(v)
    @sprite.bitmap = Bitmap.new(Saba::Sekaiju::WINDOW_WIDTH, Saba::Sekaiju::WINDOW_HEIGHT)
    @sprite.z = 130
    @damage_sprite = Sprite.new(v)
    @damage_sprite.bitmap = Bitmap.new(Saba::Sekaiju::WINDOW_WIDTH, Saba::Sekaiju::WINDOW_HEIGHT)
    @damage_sprite.z = 150
    for window in @all_windows
      window.canvas = @sprite.bitmap
    end
   
    refresh
  end
  #--------------------------------------------------------------------------
  # ● 描画的更新。
  #--------------------------------------------------------------------------
  def refresh
    for window in @all_windows
      window.refresh
    end
  end
  #--------------------------------------------------------------------------
  # ● 状態異常的表示。
  #--------------------------------------------------------------------------
  def show_all_states
    for window in @all_windows
      window.show_all_states
    end
  end
  #--------------------------------------------------------------------------
  # ● 状態異常的隠藏。
  #--------------------------------------------------------------------------
  def hide_all_states
    for window in @all_windows
      window.hide_all_states
    end
  end
  #--------------------------------------------------------------------------
  # ● 现在被选择的角色的指针返回。
  #--------------------------------------------------------------------------
  def index
    return @index
  end
  #--------------------------------------------------------------------------
  # ● 指定的指针的角色的選択。
  #--------------------------------------------------------------------------
  def index=(value)
    value = auto_select(value)
    @index = value
    if @index == 99
      select_all
      return
    end
    value -= 100 if @index >= 100 # 使用者的場合
    @windows.size.times do |i|
      window = @windows
      window.visible = (i != value)
    end
    @active_windows.size.times do |i|
      window = @active_windows
      if i == value
        window.visible = true
        if @show_face
          @face_sprite.index = window.actor.face_id
        end
      else
        window.visible = false
      end
    end
    if value < 0 && @face_sprite != nil
      @face_sprite.index = -1
    end
    refresh
  end
  #--------------------------------------------------------------------------
  # ● 全部的角色的選択。
  #--------------------------------------------------------------------------
  def select_all
    @active_windows.size.times do |i|
      window = @active_windows
      window.visible = true
      if @show_face
        @face_sprite.index = window.actor.face_id
      end
    end
  end
  #--------------------------------------------------------------------------
  # ● 资源的破棄。
  #--------------------------------------------------------------------------
  def dispose
    for window in @all_windows
      window.dispose
    end
    @sprite.bitmap.dispose
    @sprite.dispose
    @damage_sprite.bitmap.dispose
    @damage_sprite.dispose
  end
  #--------------------------------------------------------------------------
  # ● 框架的更新処理实行。
  #--------------------------------------------------------------------------
  def update
    update_selection
    update_state_mode
    for window in @all_windows
      window.update
    end
    @sprite.update
    update_damage
  end
  #--------------------------------------------------------------------------
  # ● 状態表示模式的更新。
  #--------------------------------------------------------------------------
  def update_state_mode
    return unless Saba::Sekaiju::INFO_TYPE == 2
    return unless Input.trigger?(Input::A)
    if @state_mode
      hide_all_states
      @state_mode = false
    else
      show_all_states
      @state_mode = true
    end
  end
  #--------------------------------------------------------------------------
  # ● 選択状態的更新。
  #--------------------------------------------------------------------------
  def update_selection
    return unless active
    return if @index == 99 # 全選択的場合
    return if @index >= 100 # 使用者的場合
    if Input.trigger?(Input::RIGHT)
      Sound.play_cursor
      @index += 1
      @index = 0 if $game_party.fronts.size == @index
      @index = $game_party.fronts.size if $game_party.battle_members.size == @index
      self.index = @index
    elsif Input.trigger?(Input::LEFT)
      Sound.play_cursor
      @index -= 1
     
      if -1 == @index
        if $game_party.fronts.size == 0
          @index = $game_party.backs.size - 1
        else
          @index = $game_party.fronts.size - 1
        end
      elsif $game_party.fronts.size - 1 == @index
        @index = $game_party.battle_members.size - 1
      end
      self.index = @index
    elsif Input.trigger?(Input::DOWN) || Input.trigger?(Input::UP)
      return if $game_party.fronts.empty? || $game_party.backs.empty?
      Sound.play_cursor
      if $game_party.fronts.size > @index
        @index += $game_party.fronts.size
        @index = $game_party.battle_members.size - 1 if @index >= $game_party.battle_members.size
        unless Saba::Sekaiju::SHOW_EMPTY_ACTOR_STATUS
          @index = 2 if $game_party.backs.size == 3 && $game_party.fronts.size == 1
        end
      else
        @index -= $game_party.fronts.size
        @index = 0 if @index < 0
        @index = $game_party.fronts.size - 1 if @index >= $game_party.fronts.size
        unless Saba::Sekaiju::SHOW_EMPTY_ACTOR_STATUS
          @index = 1 if $game_party.backs.size == 1 && $game_party.fronts.size == 3
        end
      end
      self.index = @index
    end
   
  end
  #--------------------------------------------------------------------------
  # ● 受创点的表示的更新。
  #--------------------------------------------------------------------------
  def update_damage
    return if @current_actor_window == nil && @miss_actor_window == nil
    if @frame >= Saba::Sekaiju::DAMADE_ANIMATIONS_DURATION
      @current_actor_window = nil
      @miss_actor_window = nil
      @damage_sprite.bitmap.clear_rect(0, 0, Saba::Sekaiju::WINDOW_WIDTH, Saba::Sekaiju::WINDOW_HEIGHT)
      return
    end
    @frame += 1
    draw_hp_damage unless @current_actor_window == nil
    draw_miss unless @miss_actor_window == nil
  end
  #--------------------------------------------------------------------------
  # ● 落空的表示。
  #--------------------------------------------------------------------------
  def display_miss(target)
    return unless @damage_sprite.visible
    for window in @windows
      if window.actor == target
        @miss_actor_window = window
        @frame = 0
        refresh
        draw_miss
        return
      end
    end
  end
  #--------------------------------------------------------------------------
  # ● 落空的描画。
  #--------------------------------------------------------------------------
  def draw_miss
    @damage_sprite.bitmap.clear_rect(0, 0, Saba::Sekaiju::WINDOW_WIDTH, Saba::Sekaiju::WINDOW_HEIGHT)
    x = @miss_actor_window.x + @miss_actor_window.width / 2
    y = @miss_actor_window.y - @frame + 5
    @damage_sprite.bitmap.blt(x - @miss.width / 2, y, @miss, Rect.new(0, 0, @miss.width, @miss.height))
  end
  #--------------------------------------------------------------------------
  # ● HP受创点的表示。
  #--------------------------------------------------------------------------
  def display_hp_damage(target)
    return unless @damage_sprite.visible
    return if target.hp_damage == 0
    for window in @windows
      if window.actor == target
        @current_actor_window = window
        @frame = 0
        refresh
        draw_hp_damage
        return
      end
    end
  end
  #--------------------------------------------------------------------------
  # ● HP受创点的描画。
  #--------------------------------------------------------------------------
  def draw_hp_damage
    @damage_sprite.bitmap.clear_rect(0, 0, Saba::Sekaiju::WINDOW_WIDTH, Saba::Sekaiju::WINDOW_HEIGHT)
    damage = @current_actor_window.actor.hp_damage
    x = @current_actor_window.x + @current_actor_window.width / 2 - 30
    y = @current_actor_window.y - @frame + 5
    @damage_sprite.bitmap.font.bold = true
    if damage >= 0
      @damage_sprite.bitmap.font.color = Saba::Sekaiju::DAMAGE_COLOR
    else
      @damage_sprite.bitmap.font.color = Saba::Sekaiju::RECOVER_COLOR
      damage = damage.abs
    end
    @damage_sprite.bitmap.font.size = Saba::Sekaiju::FONT_SIZE
    @damage_sprite.bitmap.draw_text(x, y, 60, 32, damage.to_s, 1)
  end
  #--------------------------------------------------------------------------
  # ● 可視性的設定しますが、true什么也没有发生的场合、false,选择被解除。
  #--------------------------------------------------------------------------
  def visible=(value)
    self.index = -1 unless value
  end
  #--------------------------------------------------------------------------
  # ● 假人。
  #--------------------------------------------------------------------------
  def width
    return 0
  end
  def height
    return 136
  end
  #--------------------------------------------------------------------------
  # ● 假人。
  #--------------------------------------------------------------------------
  def x=(value)
  end
  def actor
    $game_party.members[@index]
  end
end

#==============================================================================
# ■ Game_Battler
#------------------------------------------------------------------------------
#  後列的場合的受创点修正实行。
#==============================================================================
class Game_Battler
  #--------------------------------------------------------------------------
  # ● 通常攻击而受创点计算。后排攻击的场合,受创点修正。。
  #     attacker : 攻撃者
  #    結果は @hp_damage 代入。
  #--------------------------------------------------------------------------
  alias saba_sekaiju_make_attack_damage_value make_attack_damage_value
  def make_attack_damage_value(attacker)
    saba_sekaiju_make_attack_damage_value(attacker)
    if attacker.back_attack?
      @hp_damage = (@hp_damage * Saba::Sekaiju::BACK_ATTACK_DAMAGE_PENALTY).round   # HP 受创点にペナルティ
      @mp_damage = (@mp_damage * Saba::Sekaiju::BACK_ATTACK_DAMAGE_PENALTY).round   # MP 受创点にペナルティ
    end
    if back_attacked?(attacker)
      @hp_damage = (@hp_damage * Saba::Sekaiju::BACK_ATTACK_DAMAGE_PENALTY_ENEMY).round   # HP 受创点にペナルティ
      @mp_damage = (@mp_damage * Saba::Sekaiju::BACK_ATTACK_DAMAGE_PENALTY_ENEMY).round   # MP 受创点にペナルティ
    end
  end
  #--------------------------------------------------------------------------
  # ● 技能的受创点计算。后排攻击的场合,受创点修正。。
  #     user : 攻撃者
  #    結果は @hp_damage 代入。
  #--------------------------------------------------------------------------
  alias saba_sekaiju_make_obj_damage_value make_obj_damage_value
  def make_obj_damage_value(user, obj)
    saba_sekaiju_make_obj_damage_value(user, obj)
    if user.back_attack?
      @hp_damage = (@hp_damage * Saba::Sekaiju::BACK_ATTACK_DAMAGE_PENALTY).round   # HP 受创点にペナルティ
      @mp_damage = (@mp_damage * Saba::Sekaiju::BACK_ATTACK_DAMAGE_PENALTY).round   # MP 受创点にペナルティ
    end
    if back_attacked?(user, obj)
      @hp_damage = (@hp_damage * Saba::Sekaiju::BACK_ATTACK_DAMAGE_PENALTY_ENEMY).round   # HP 受创点にペナルティ
      @mp_damage = (@mp_damage * Saba::Sekaiju::BACK_ATTACK_DAMAGE_PENALTY_ENEMY).round   # MP 受创点にペナルティ
    end
  end
  #--------------------------------------------------------------------------
  # ● 从后排的攻击判定是否有效。
  #--------------------------------------------------------------------------
  def back_attack?
    return false
  end
  #--------------------------------------------------------------------------
  # ● 对后排是否有效的攻击判定。。
  #--------------------------------------------------------------------------
  def back_attacked?(user, obj = nil)
    return false
  end
end

if $imported["OverDrive"]
class Game_Enemy
  #--------------------------------------------------------------------------
  # ○ 气力技能已習得的判定
  #--------------------------------------------------------------------------
  def use_overdrive_skill?
    return Saba::Checker::define?(self.enemy, "<オー条气力>")
  end
end
end


#==============================================================================
# ■ Window_TargetName
#------------------------------------------------------------------------------
#  敵名を表示窗口。
#==============================================================================
class Window_TargetName < Window_Help
  #--------------------------------------------------------------------------
  # ● 对象初期化 ◆◆◆ 改造 ◆◆◆
  #--------------------------------------------------------------------------
  def initialize
    super
#~     if Saba::Sekaiju::show_turn_count? && (Saba::Sekaiju::TURN_WINDOW_ALIGN == 0)
#~       x = Saba::Sekaiju::TURN_WINDOW_WIDTH + Saba::Sekaiju::MESSAGE_WINDOW_OFFSET_X
#~     else
#~       x = 0
#~     end
#~     if Saba::Sekaiju::show_turn_count?
#~       width = Saba::Sekaiju::WINDOW_WIDTH - Saba::Sekaiju::TURN_WINDOW_WIDTH + Saba::Sekaiju::MESSAGE_WINDOW_OFFSET_X
#~     else
#~       width = Saba::Sekaiju::WINDOW_WIDTH
#~     end
   
#~     self.x = x
    self.x = 128
#~     self.width = width
    self.width = 416
    self.z = 350
    create_contents
  end
end

#==============================================================================
# ■ Window_Actor に追加
#------------------------------------------------------------------------------
#  队友ーメン条每一个对应各自的窗口。
#==============================================================================
class Window_Actor < Window_Base
  include ActorStatus
  def initialize(actor, active_window = false)
    @display_state_mode = false
    @actor = actor
    if front?
      y = BASE_Y
    else
      y = CELL_HEIGHT + BASE_Y
    end
   
    super(window_x, y, window_width, CELL_HEIGHT)
    if active_window
      self.windowskin = Cache.system("ActiveWindow")
      create_contents
    end
   
    self.visible = ! active_window
    @frame = 0
    @state_index = 0
    self.z = 30
    if actor != nil
      actor.screen_x = x + CELL_WIDTH / 2
      actor.screen_y = y + CELL_HEIGHT / 2 + 20
    end
    save_parameters
  end
  def update
    super
    update_contents
  end
end

class DummyWindow_Actor < Window_Actor
  include ActorStatus
  def initialize(front, position_in_ranks)
    @dummy = true
    @front = front
    @position_in_ranks = position_in_ranks
    super(nil, false)
  end
  def front?
    return @front
  end
  def position_in_ranks
    return @position_in_ranks
  end
end

class RPG::Weapon < RPG::BaseItem
  def long_range?
    return Saba::Checker::define?(self, Saba::Sekaiju::LONG_RANGE_WEAPON_MARKER)
  end
end

class RPG::Skill < RPG::UsableItem
  def short_range?
    return Saba::Checker::define?(self, Saba::Sekaiju::SHORT_RANGE_SKILL_MARKER)
  end
end

class RPG::Item
  def short_range?
    return false
  end
end

class Window_State < Window_Base
  def initialize
    super(285, 70 ,250, 210)
    draw_title
    self.contents.font.color = Color.new(255, 255, 255)
    self.contents.font.bold = false
    draw_fronts
    draw_backs
  end
  def draw_title
    self.contents.font.color = Color.new(255, 220, 210)
    self.contents.draw_text(0, 0, 218, WLH, Saba::Sekaiju::INFO_TEXT, 1)
  end
  def draw_fronts
    y = WLH + 5
    for actor in $game_party.fronts
      draw_name(actor, 0, y)
      x = 112
      for state in actor.states
        next if state.icon_index == 0
        draw_icon(state.icon_index, x, y)
        x += 21
      end
      y += WLH
    end
  end
  def draw_backs
    y = WLH * 4 + 5
    for actor in $game_party.backs
      draw_name(actor, 0, y)
      x = 112
      for state in actor.states
        next if state.icon_index == 0
        draw_icon(state.icon_index, x, y)
        x += 21
      end
      y += WLH
    end
  end
  def draw_name(actor, x, y)
    self.contents.font.color = hp_color(actor)
    self.contents.draw_text(x, y, 108, WLH, actor.name)
  end
  #--------------------------------------------------------------------------
  # ● 状態異常图标的描画。
  #--------------------------------------------------------------------------
  def draw_icon(icon_index, x, y, enabled = true)
    icon = Cache.system("Iconset")
    rect = Rect.new(icon_index % 16 * 24, icon_index / 16 * 24, 24, 24)
    self.contents.blt(x, y, icon, rect, enabled ? 255 : 128)
  end
end

class Scene_File
  #--------------------------------------------------------------------------
  # ● 存档数据的読取
  #     file : 読取用的文件对象 (开放完毕)
  #--------------------------------------------------------------------------
  alias saba_sekaiju_read_save_data read_save_data
  def read_save_data(file)
    saba_sekaiju_read_save_data(file)
    $game_party.update_actors
  end
end

class Game_Interpreter
  def change_face(actor_id, face_id)
    actor = $game_actors[actor_id]
    actor.face_id = face_id
  end
end

#--------------------------------------------------------------------------
# ● 味方的战动画表示用 ◆◆◆ 改造 ◆◆◆ @viewport1 > @viewport8
#--------------------------------------------------------------------------
if Saba::Sekaiju::DISPLAY_BATTLE_ANIMATION_TO_ACTOR
class Spriteset_Battle
  def create_actors
    @actor_sprites = []
    6.times do
      @actor_sprites.push(Sprite_Battler.new(@viewport8)) # ◆
    end
  end
  #--------------------------------------------------------------------------
  # ● 视窗口的作成 ◆◆◆ 改造 ◆◆◆ @viewport1 > @viewport8
  #--------------------------------------------------------------------------
  alias saba_sekaiju_create_viewports create_viewports
  def create_viewports
    saba_sekaiju_create_viewports
    @viewport8.rect.height += Saba::Sekaiju::DISPLAY_POSITION_ANIMATION_OFFSET_Y * 2
  end
end
end

#--------------------------------------------------------------------------
# ● 受创点范围非表示用
#--------------------------------------------------------------------------
if Saba::Sekaiju::HIDE_DEFAULT_POPUP_DAMAGE
class ActorWindowSet
  alias saba_popup_viewport viewport=
  def viewport=(v)
    saba_popup_viewport(v)
    @damage_sprite.visible = false
  end
end
class Sprite_EnemyDamage
  def display_miss(target)
  end
  def display_hp_damage(target, obj)
  end
end
end

#--------------------------------------------------------------------------
# ● 回合消費技能用
#--------------------------------------------------------------------------
if defined?(Game_Unit.new.reduce_consume_turn)
class Game_Enemy
  #--------------------------------------------------------------------------
  # ● 戦闘行動的作成
  #--------------------------------------------------------------------------
  alias saba_sekaiju_make_action make_action
  def make_action
    return if @not_act_turn != -1
    saba_sekaiju_make_action
  end
end
class Game_Unit
  #--------------------------------------------------------------------------
  # ● 不能行动残余回合数的减少
  #--------------------------------------------------------------------------
  def reduce_consume_turn
    for member in members
      turn = member.not_act_turn
      member.not_act_turn = turn - 1 if turn > -1
      member.not_act_turn = turn + 1 if turn < -1
      if turn == -1
        member.no_damage_flag = false
        next
      end
      skill = member.action.skill
      unless member.skill_can_use?(skill)
        member.not_act_turn = -1 if turn > -1
      end
    end
  end
end
end[/pre]
回复

使用道具 举报

梦石
0
星屑
208
在线时间
420 小时
注册时间
2020-1-11
回帖
175
 楼主| 发表于 2021-7-11 20:38:15 | 显示全部楼层
喵呜喵5 发表于 2021-7-11 02:49
直接参看 set_screen_x 最后那部分

我就是喜欢简单直接。
回复

使用道具 举报

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

本版积分规则

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

在本版发帖返回顶部