XP 스크립트

전투
2009.02.22 16:56

ATB전투

조회 수 3370 추천 수 0 댓글 5
흠. 예전께 왜 안되나 밧더니 줄이 짤렷더군요. 음... 그것이 공작소 게시판의 제한된 줄이 있어서 ㅡㅡ;
(그 스크립트 원본이 무지 김) 사설은 집어치우고. 그런 관계로 주석은 모두 삭제했습니다. 힘드네염.
그래도 출처는 남겨 두어야 된다고 생각해서 출처는 그대로 남겼습니다. 글엄 조은게임 잘만드셈
# http://members.jcom.home.ne.jp/cogwheel/
class Scene_Battle
  attr_reader  :status_window            # 긚긡??긚긂귻깛긤긂
  attr_reader  :spriteset                # 긫긣깑긚긵깋귽긣
  attr_reader  :scroll_time              # 긚긏깏?깛댷벍딈?렄듩
  attr_reader  :zoom_rate                # 밎긫긣깋?딈?댧뭫
  attr_reader  :drive                    # 긇긽깋뗭벍
  attr_accessor :force                    # 귺긏긘깈깛떗맕뱗
  attr_accessor :camera                  # 뙸띪궻긇긽깋룋렃롌
 def atb_setup
    speed = 150
    @active = 1
    @action = 2
    @anime_wait = false
    @damage_wait = 10
    @enemy_speed = 40
    @force = 2
    @drive = true
    @scroll_time = 15
    @zoom_rate = [0.2, 1.0]
    @help_time = 40
    @escape == false
    @camera = nil
    @max = 0
    @turn_cnt = 0
    @help_wait = 0
    @action_battlers = []
    @synthe = []
    @spell_p = {}
    @spell_e = {}
    @command_a = false
    @command = []
    @party = false
    for battler in $game_party.actors + $game_troop.enemies
      spell_reset(battler)
      battler.at = battler.agi * rand(speed / 2)
      battler.damage_pop = {}
      battler.damage = {}
      battler.damage_sp = {}
      battler.critical = {}
      battler.recover_hp = {}
      battler.recover_sp = {}
      battler.state_p = {}
      battler.state_m = {}
      battler.animation = []
      if battler.is_a?(Game_Actor)
        @max += battler.agi
      end
    end
    @max *= speed
    @max /= $game_party.actors.size
    for battler in $game_party.actors + $game_troop.enemies
      battler.atp = 100 * battler.at / @max
    end
  end
  #--------------------------------------------------------------------------
  # 걶 AT긒?긙Max렄SE
  #--------------------------------------------------------------------------
  def fullat_se
    Audio.se_play("Audio/SE/033-switch02", 80, 100)
  end
  #--------------------------------------------------------------------------
  # 걶 깒긹깑귺긞긵SE
  #--------------------------------------------------------------------------
  def levelup_se
    Audio.se_play("Audio/SE/056-Right02", 80, 100)
  end
  #--------------------------------------------------------------------------
  # 걶 긚긌깑뢐벦SE
  #--------------------------------------------------------------------------
  def skill_se
    Audio.se_play("Audio/SE/056-Right02", 80, 150)
  end
end

class Window_Base < Window
  #--------------------------------------------------------------------------
  # 걶 ATG 궻?됪
  #    actor : 귺긏??
  #    x    : ?됪먩 X 띆뷭
  #    y    : ?됪먩 Y 띆뷭
  #    width : ?됪먩궻븴
  #--------------------------------------------------------------------------
  def draw_actor_atg(actor, x, y, width = 144)
    if @at_gauge == nil
      @plus_x = 0
      @rate_x = 0
      @plus_y = 16
      @plus_width = 0
      @rate_width = 100
      @width = @plus_width + width * @rate_width / 100
      @height = 16
      @align1 = 0
      @align2 = 1
      @align3 = 0
      grade1 = 1
      grade2 = 0
      color1 = Color.new(0, 0, 0)
      color2 = Color.new(255, 255, 192)
      color3 = Color.new(0, 0, 0, 192)
      color4 = Color.new(0, 0, 64, 192)
      # 긒?긙궻륡먠믦
      # 믅륂렄궻륡먠믦
      color5 = Color.new(0, 64, 80)
      color6 = Color.new(0, 128, 160)
      # 긒?긙궕MAX궻렄궻륡먠믦
      color7 = Color.new(80, 0, 0)
      color8 = Color.new(240, 0, 0)
      # 쁀똤긚긌깑럊뾭렄궻륡먠믦
      color9 = Color.new(80, 64, 32)
      color10 = Color.new(240, 192, 96)
      # 긚긌깑뎣룯렄궻륡먠믦
      color11 = Color.new(80, 0, 64)
      color12 = Color.new(240, 0, 192)
      # 긒?긙궻?됪
      gauge_rect_at(@width, @height, @align3, color1, color2,
                  color3, color4, color5, color6, color7, color8,
                  color9, color10, color11, color12, grade1, grade2)
    end
    # 빾릶at궸?됪궥귡긒?긙궻븴귩묆볺
    if actor.rtp == 0
      at = (width + @plus_width) * actor.atp * @rate_width / 10000
    else
      at = (width + @plus_width) * actor.rt * @rate_width / actor.rtp / 100
    end
    if at > width
      at = width
    end
    # 긒?긙궻뜺땗갋뭷돍?궑뱳궻뺚맫
    case @align1
    when 1
      x += (@rect_width - width) / 2
    when 2
      x += @rect_width - width
    end
    case @align2
    when 1
      y -= @height / 2
    when 2
      y -= @height
    end
    self.contents.blt(x + @plus_x + width * @rate_x / 100, y + @plus_y,
                      @at_gauge, Rect.new(0, 0, @width, @height))
    if @align3 == 0
      rect_x = 0
    else
      x += @width - at - 1
      rect_x = @width - at - 1
    end
    # 긒?긙궻륡먠믦
    if at == width
        # MAX렄궻긒?긙?됪
      self.contents.blt(x + @plus_x + @width * @rate_x / 100, y + @plus_y,
                        @at_gauge, Rect.new(rect_x, @height * 2, at, @height))
    else
      if actor.rtp == 0
        # 믅륂렄궻긒?긙?됪
        self.contents.blt(x + @plus_x + @width * @rate_x / 100, y + @plus_y,
                          @at_gauge, Rect.new(rect_x, @height, at, @height))
      else
        if actor.spell == true
          # 쁀똤긚긌깑럊뾭렄궻긒?긙?됪
          self.contents.blt(x + @plus_x + @width * @rate_x / 100, y + @plus_y,
                        @at_gauge, Rect.new(rect_x, @height * 3, at, @height))
        else
          # 긚긌깑뎣룯렄궻긒?긙?됪
          self.contents.blt(x + @plus_x + @width * @rate_x / 100, y + @plus_y,
                        @at_gauge, Rect.new(rect_x, @height * 4, at, @height))
        end
      end
    end
  end
end
class Scene_Battle
  def main
    $game_temp.in_battle = true
    $game_temp.battle_turn = 0
    $game_temp.battle_event_flags.clear
    $game_temp.battle_abort = false
    $game_temp.battle_main_phase = false
    $game_temp.battleback_name = $game_map.battleback_name
    $game_temp.forcing_battler = nil
    # 긫긣깑귽긹깛긣뾭귽깛?긵깏?귩룊딖돸
    $game_system.battle_interpreter.setup(nil, 0)
    # 긣깑?긵귩?뷈
    @troop_id = $game_temp.battle_troop_id
    $game_troop.setup(@troop_id)
    atb_setup
    # 귺긏??긓?깛긤긂귻깛긤긂귩띿맟
    s1 = $data_system.words.attack
    s2 = $data_system.words.skill
    s3 = $data_system.words.guard
    s4 = $data_system.words.item
    @actor_command_window = Window_Command.new(160, [s1, s2, s3, s4])
    @actor_command_window.y = 160
    @actor_command_window.back_opacity = 160
    @actor_command_window.active = false
    @actor_command_window.visible = false
    # 궩궻뫜궻긂귻깛긤긂귩띿맟
    @party_command_window = Window_PartyCommand.new
    @help_window = Window_Help.new
    @help_window.back_opacity = 160
    @help_window.visible = false
    @status_window = Window_BattleStatus.new
    @message_window = Window_Message.new
    # 긚긵깋귽긣긜긞긣귩띿맟
    @spriteset = Spriteset_Battle.new
    # 긂긃귽긣긇긂깛긣귩룊딖돸
    @wait_count = 0
    # 긣깋깛긙긘깈깛렳뛱
    if $data_system.battle_transition == ""
      Graphics.transition(20)
    else
      Graphics.transition(40, "Graphics/Transitions/" +
        $data_system.battle_transition)
    end
    # 긵깒긫긣깑긲긃?긛둎럑
    start_phase1
    # 긽귽깛깑?긵
    loop do
      # 긒??됪뽋귩뛛륷
      Graphics.update
      # 볺쀍륃뺪귩뛛륷
      Input.update
      # 긲깒??뛛륷
      update
      # 됪뽋궕먛귟뫶귦궯궫귞깑?긵귩뭷뭚
      if $scene != self
        break
      end
    end
    # ?긞긵귩깏긲깒긞긘깄
    $game_map.refresh
    # 긣깋깛긙긘깈깛?뷈
    Graphics.freeze
    # 긂귻깛긤긂귩됶뺳
    @actor_command_window.dispose
    @party_command_window.dispose
    @help_window.dispose
    @status_window.dispose
    @message_window.dispose
    if @skill_window != nil
      @skill_window.dispose
    end
    if @item_window != nil
      @item_window.dispose
    end
    if @result_window != nil
      @result_window.dispose
    end
    # 긚긵깋귽긣긜긞긣귩됶뺳
    @spriteset.dispose
    # ?귽긣깑됪뽋궸먛귟뫶궑뭷궻뤾뜃
    if $scene.is_a?(Scene_Title)
      # 됪뽋귩긲긃?긤귺긂긣
      Graphics.transition
      Graphics.freeze
    end
    # 먰벉긡긚긣궔귞긒??긆?긫?됪뽋댥둖궸먛귟뫶궑뭷궻뤾뜃
    if $BTEST and not $scene.is_a?(Scene_Gameover)
      $scene = nil
    end
  end
  #--------------------------------------------------------------------------
  # 걶 룦봲뵽믦
  #--------------------------------------------------------------------------
  def judge
    # 멣뽅뵽믦궕?갂귏궫궼긬?긡귻릐릶궕 0 릐궻뤾뜃
    if $game_party.all_dead? or $game_party.actors.size == 0
      # 봲뻢됀?궻뤾뜃
      if $game_temp.battle_can_lose
        # 긫긣깑둎럑멟궻 BGM 궸뽣궥
        $game_system.bgm_play($game_temp.map_bgm)
        # 긫긣깑뢎뿹
        battle_end(2)
        # true 귩뺅궥
        return true
      end
      # 긒??긆?긫?긲깋긐귩긜긞긣
      $game_temp.gameover = true
      # true 귩뺅궥
      return true
    end
    # 긄긨??궕 1 뫬궳귖뫔띪궥귢궽 false 귩뺅궥
    for enemy in $game_troop.enemies
      if enemy.exist?
        return false
      end
    end
    # 귺긲??긫긣깑긲긃?긛둎럑 (룦뿕)
    start_phase5
    # true 귩뺅궥
    return true
  end
  #--------------------------------------------------------------------------
  # 걶 긲깒??뛛륷
  #--------------------------------------------------------------------------
  def update
    # 긫긣깑귽x깛긣렳뛱뭷궻뤾뜃
    if $game_system.battle_interpreter.running?
      if @command.size > 0
        @command_a = false
        @command = []
        command_delete
      end
      @status_window.at_refresh
      # 귽깛?긵깏?귩뛛륷
      $game_system.battle_interpreter.update
      # 귺긏긘깈깛귩떗맕궠귢궲궋귡긫긣깋?궕뫔띪궢궶궋뤾뜃
      if $game_temp.forcing_battler == nil
        # 긫긣깑귽긹깛긣궻렳뛱궕뢎귦궯궫뤾뜃
        unless $game_system.battle_interpreter.running?
          # 긫긣깑귽긹깛긣궻긜긞긣귺긞긵귩띋렳뛱
          @status_window.refresh
          setup_battle_event
        end
      end
    end
    # 긘긚긡? (?귽??)갂됪뽋귩뛛륷
    $game_system.update
    $game_screen.update
    # ?귽??궕 0 궸궶궯궫뤾뜃
    if $game_system.timer_working and $game_system.timer == 0
      # 긫긣깑뭷뭚
      $game_temp.battle_abort = true
    end
    # 긂귻깛긤긂귩뛛륷
    @help_window.update
    @party_command_window.update
    @actor_command_window.update
    @status_window.update
    @message_window.update
    # 긚긵깋귽긣긜긞긣귩뛛륷
    @spriteset.update
    # 긣깋깛긙긘깈깛룉뿚뭷궻뤾뜃
    if $game_temp.transition_processing
      # 긣깋깛긙긘깈깛룉뿚뭷긲깋긐귩긏깏귺
      $game_temp.transition_processing = false
      # 긣깋깛긙긘깈깛렳뛱
      if $game_temp.transition_name == ""
        Graphics.transition(20)
      else
        Graphics.transition(40, "Graphics/Transitions/" +
          $game_temp.transition_name)
      end
    end
    # 긽긞긜?긙긂귻깛긤긂?렑뭷궻뤾뜃
    if $game_temp.message_window_showing
      return
    end
    # 긒??긆?긫?궻뤾뜃
    if $game_temp.gameover
      # 긒??긆?긫?됪뽋궸먛귟뫶궑
      $scene = Scene_Gameover.new
      return
    end
    # ?귽긣깑됪뽋궸뽣궥뤾뜃
    if $game_temp.to_title
      # ?귽긣깑됪뽋궸먛귟뫶궑
      $scene = Scene_Title.new
      return
    end
    # 긫긣깑뭷뭚궻뤾뜃
    if $game_temp.battle_abort
      # 긫긣깑둎럑멟궻 BGM 궸뽣궥
      $game_system.bgm_play($game_temp.map_bgm)
      # 긫긣깑뢎뿹
      battle_end(1)
      return
    end
    # 긶깑긵긂귻깛긤긂?렑뭷궻뤾뜃
    if @help_wait > 0
      @help_wait -= 1
      if @help_wait == 0
        # 긶깑긵긂귻깛긤긂귩덨궥
        @help_window.visible = false
      end
    end
    # 긲긃?긛궸귝궯궲빁딌
    case @phase
    when 0  # AT긒?긙뛛륷긲긃?긛
      if anime_wait_return
        update_phase0
      end
    when 1  # 긵깒긫긣깑긲긃?긛
      update_phase1
      return
    when 2  # 긬?긡귻긓?깛긤긲긃?긛
      update_phase2
      return
    when 5  # 귺긲??긫긣깑긲긃?긛
      update_phase5
      return
    end
    if $scene != self
      return
    end
    if @phase == 0
      if @command.size != 0  # 귺긏??긓?깛긤긲긃?긛
        if @command_a == false
          start_phase3
        end
        update_phase3
      end
      # 긂긃귽긣뭷궻뤾뜃
      if @wait_count > 0
        # 긂긃귽긣긇긂깛긣귩뙵귞궥
        @wait_count -= 1
        return
      end
      update_phase4
    end
  end

#==============================================================================
# 걾 Scene_Battle (빁뒆믦? 2)
#------------------------------------------------------------------------------
# ?긫긣깑됪뽋궻룉뿚귩뛱궎긏깋긚궳궥갃
#==============================================================================

  #--------------------------------------------------------------------------
  # 걶 긲깒??뛛륷 (AT긒?긙뛛륷긲긃?긛)
  #--------------------------------------------------------------------------
  def update_phase0
    if $game_temp.battle_turn == 0
      $game_temp.battle_turn = 1
    end
    # B ??깛궕돓궠귢궫뤾뜃
    if @command_a == false and @party == false
      if Input.trigger?(Input::B)
        # 긌긿깛긜깑 SE 귩뎶몋
        $game_system.se_play($data_system.cancel_se)
        @party = true
      end
    end
    if @party == true and
        ((@action > 0 and @action_battlers.empty?) or (@action == 0 and
        (@action_battlers.empty? or @action_battlers[0].phase == 1)))
      # 긬?긡귻긓?깛긤긲긃?긛귉
      start_phase2
      return
    end
    # AT긒?긙몵돿룉뿚
    cnt = 0
    for battler in $game_party.actors + $game_troop.enemies
      active?(battler)
      if battler.rtp == 0
        if battler.at >= @max
          if battler.is_a?(Game_Actor)
            if battler.inputable?
              unless @action_battlers.include?(battler) or
                  @command.include?(battler) or @escape == true
                if battler.current_action.forcing
                  fullat_se
                  force_action(battler)
                  action_start(battler)
                else
                  fullat_se
                  @command.push(battler)
                end
              end
            else
              unless @action_battlers.include?(battler) or
                      battler == @command[0]
                battler.current_action.clear
                if @command.include?(battler)
                  @command.delete(battler)
                else
                  if battler.movable?
                    fullat_se
                  end
                end
                action_start(battler)
              end
            end
          else
            unless @action_battlers.include?(battler)
              if battler.current_action.forcing
                force_action(battler)
                action_start(battler)
              else
                if @enemy_speed != 0
                  if rand(@enemy_speed) == 0
                    number = cnt - $game_party.actors.size
                    enemy_action(number)
                  end
                else
                  number = cnt - $game_party.actors.size
                  enemy_action(number)
                end
              end
            end
          end
        else
          battler.at += battler.agi
          if battler.guarding?
            battler.at += battler.agi
          end
          if battler.movable?
            battler.atp = 100 * battler.at / @max
          end
        end
      else
        if battler.rt >= battler.rtp
          speller = synthe?(battler)
          if speller != nil
            battler = speller[0]
          end
          unless @action_battlers.include?(battler)
            if battler.is_a?(Game_Actor)
              fullat_se
            end
            battler.rt = battler.rtp
            action_start(battler)
          end
        else
          battler.rt += battler.agi
          speller = synthe?(battler)
          if speller != nil
            for spell in speller
              if spell != battler
                spell.rt += battler.agi
              end
            end
          end
        end
      end
      cnt += 1
    end
    # AT긒?긙귩깏긲깒긞긘깄
    @status_window.at_refresh
    # 벀몪룉뿚
    if @escape == true and
        ((@action > 0 and @action_battlers.empty?) or (@action == 0 and
        (@action_battlers.empty? or @action_battlers[0].phase == 1)))
      temp = false
      for battler in $game_party.actors
        if battler.inputable?
          temp = true
        end
      end
      if temp == true
        for battler in $game_party.actors
          if battler.at < @max and battler.inputable?
            temp = false
            break
          end
        end
        if temp == true
          @escape = false
          for battler in $game_party.actors
            battler.at %= @max
          end
          $game_temp.battle_main_phase = false
          update_phase2_escape
        end
      end
    end
  end
  #--------------------------------------------------------------------------
  # 걶 긬?긡귻긓?깛긤긲긃?긛둎럑
  #--------------------------------------------------------------------------
  def start_phase2
    # 긲긃?긛 2 궸댷뛱
    @phase = 2
    @party = false
    # 긬?긡귻긓?깛긤긂귻깛긤긂귩뾎뚼돸
    @party_command_window.active = true
    @party_command_window.visible = true
    # 귺긏??귩뷄멗묖륉뫴궸먠믦
    @actor_index = -1
    # 귺긏??긓?깛긤긂귻깛긤긂귩뼰뚼돸
    @actor_command_window.active = false
    @actor_command_window.visible = false
    if @command.size != 0
      # 귺긏??궻뼻뽅긄긲긃긏긣 OFF
      if @active_actor != nil
        @active_actor.blink = false
      end
    end
    # 긇긽깋긜긞긣
    @camera == "party"
    @spriteset.screen_target(0, 0, 1)
    # 긽귽깛긲긃?긛긲깋긐귩긏깏귺
    $game_temp.battle_main_phase = false
  end
  #--------------------------------------------------------------------------
  # 걶 긲깒??뛛륷 (긬?긡귻긓?깛긤긲긃?긛)
  #--------------------------------------------------------------------------
  def update_phase2
    # C ??깛궕돓궠귢궫뤾뜃
    if Input.trigger?(Input::C)
      # 긬?긡귻긓?깛긤긂귻깛긤긂궻긇??깑댧뭫궳빁딌
      case @party_command_window.index
      when 0  # 먰궎
        # 긬?긡귻긓?깛긤긂귻깛긤긂귩뼰뚼돸
        @party_command_window.active = false
        @party_command_window.visible = false
        # 뙂믦 SE 귩뎶몋
        $game_system.se_play($data_system.decision_se)
        @escape = false
        @phase = 0
        if $game_temp.battle_turn == 0
          $game_temp.battle_turn = 1
        end
        if @command_a == true
          # 귺긏??긓?깛긤긲긃?긛둎럑
          start_phase3
        else
          $game_temp.battle_main_phase = true
        end
      when 1  # 벀궛귡
        # 벀몪됀?궳궼궶궋뤾뜃
        if $game_temp.battle_can_escape == false
          # 긳긗? SE 귩뎶몋
          $game_system.se_play($data_system.buzzer_se)
          return
        end
        # 뙂믦 SE 귩뎶몋
        $game_system.se_play($data_system.decision_se)
        @phase = 0
        # 긬?긡귻긓?깛긤긂귻깛긤긂귩뼰뚼돸
        @party_command_window.active = false
        @party_command_window.visible = false
        $game_temp.battle_main_phase = true
        if $game_temp.battle_turn == 0
          update_phase2_escape
          $game_temp.battle_turn = 1
          for battler in $game_party.actors
            battler.at -= @max / 2
          end
          return
        end
        # 뙂믦 SE 귩뎶몋
        $game_system.se_play($data_system.decision_se)
        @escape = true
        for battler in $game_party.actors
          @command_a = false
          @command.delete(battler)
          @action_battlers.delete(battler)
          skill_reset(battler)
        end
      end
      return
    end
  end
  #--------------------------------------------------------------------------
  # 걶 귺긲??긫긣깑긲긃?긛둎럑
  #--------------------------------------------------------------------------
  def start_phase5
    # 긲긃?긛 5 궸댷뛱
    @phase = 5
    # 긫긣깑뢎뿹 ME 귩뎶몋
    $game_system.me_play($game_system.battle_end_me)
    # 긫긣깑둎럑멟궻 BGM 궸뽣궥
    $game_system.bgm_play($game_temp.map_bgm)
    # EXP갂긕?깑긤갂긣깒긙긿?귩룊딖돸
    exp = 0
    gold = 0
    treasures = []
    if @active_actor != nil
      @active_actor.blink = false
    end
    # 긽귽깛긲긃?긛긲깋긐귩긜긞긣
    $game_temp.battle_main_phase = true
    # 긬?긡귻긓?깛긤긂귻깛긤긂귩뼰뚼돸
    @party_command_window.active = false
    @party_command_window.visible = false
    # 귺긏??긓?깛긤긂귻깛긤긂귩뼰뚼돸
    @actor_command_window.active = false
    @actor_command_window.visible = false
    if @skill_window != nil
      # 긚긌깑긂귻깛긤긂귩됶뺳
      @skill_window.dispose
      @skill_window = nil
    end
    if @item_window != nil
      # 귺귽긡?긂귻깛긤긂귩됶뺳
      @item_window.dispose
      @item_window = nil
    end
    # 긶깑긵긂귻깛긤긂귩덨궥
    @help_window.visible = false
    # 깑?긵
    for enemy in $game_troop.enemies
      # 긄긨??궕덨귢륉뫴궳궶궋뤾뜃
      unless enemy.hidden
        # 둳벦 EXP갂긕?깑긤귩믁돿
        exp += enemy.exp
        gold += enemy.gold
        # 긣깒긙긿?뢯뙸뵽믦
        if rand(100) < enemy.treasure_prob
          if enemy.item_id > 0
            treasures.push($data_items[enemy.item_id])
          end
          if enemy.weapon_id > 0
            treasures.push($data_weapons[enemy.weapon_id])
          end
          if enemy.armor_id > 0
            treasures.push($data_armors[enemy.armor_id])
          end
        end
      end
    end
    # 긣깒긙긿?궻릶귩 6 뙿귏궳궸뙽믦
    treasures = treasures[0..5]
    # EXP 둳벦
    for i in 0...$game_party.actors.size
      actor = $game_party.actors[i]
      if actor.cant_get_exp? == false
        last_level = actor.level
        actor.exp += exp
        if actor.level > last_level
          @status_window.level_up(i)
          actor.damage[[actor, -1]] = "Level up!"
          actor.up_level = actor.level - last_level
        end
      end
    end
    # 긕?깑긤둳벦
    $game_party.gain_gold(gold)
    # 긣깒긙긿?둳벦
    for item in treasures
      case item
      when RPG::Item
        $game_party.gain_item(item.id, 1)
      when RPG::Weapon
        $game_party.gain_weapon(item.id, 1)
      when RPG::Armor
        $game_party.gain_armor(item.id, 1)
      end
    end
    # 긫긣깑깏긗깑긣긂귻깛긤긂귩띿맟
    @result_window = Window_BattleResult.new(exp, gold, treasures)
    # 긂긃귽긣긇긂깛긣귩먠믦
    @phase5_wait_count = 100
  end
  #--------------------------------------------------------------------------
  # 걶 긲깒??뛛륷 (귺긲??긫긣깑긲긃?긛)
  #--------------------------------------------------------------------------
  def update_phase5
    # 긂긃귽긣긇긂깛긣궕 0 귝귟묈궖궋뤾뜃
    if @phase5_wait_count > 0
      # 긂긃귽긣긇긂깛긣귩뙵귞궥
      @phase5_wait_count -= 1
      # 긂긃귽긣긇긂깛긣궕 0 궸궶궯궫뤾뜃
      if @phase5_wait_count == 0
        # 깏긗깑긣긂귻깛긤긂귩?렑
        @result_window.visible = true
        # 긽귽깛긲긃?긛긲깋긐귩긏깏귺
        $game_temp.battle_main_phase = false
        # 긚긡??긚긂귻깛긤긂귩깏긲깒긞긘깄
        @status_window.refresh
        for actor in $game_party.actors
          if actor.damage.include?([actor, 0])
            @phase5_wait_count = 20
            actor.damage_pop[[actor, 0]] = true
          end
          if actor.damage.include?([actor, -1])
            @phase5_wait_count = 20
            actor.damage_pop[[actor, -1]] = true
            for level in actor.level - actor.up_level + 1..actor.level
              for skill in $data_classes[actor.class_id].learnings
                if level == skill.level and not actor.skill_learn?(skill.id)
                  actor.damage[[actor, 0]] = "New Skill!"
                  break
                end
              end
            end
          end
        end
      end
      return
    end
    # C ??깛궕돓궠귢궫뤾뜃
    if Input.trigger?(Input::C)
      # 긫긣깑뢎뿹
      battle_end(0)
    end
  end

#==============================================================================
# 걾 Scene_Battle (빁뒆믦? 3)
#------------------------------------------------------------------------------
# ?긫긣깑됪뽋궻룉뿚귩뛱궎긏깋긚궳궥갃
#==============================================================================

  #--------------------------------------------------------------------------
  # 걶 귺긏??긓?깛긤긲긃?긛둎럑
  #--------------------------------------------------------------------------
  def start_phase3
    # 긽귽깛긲긃?긛긲깋긐귩긏깏귺
    $game_temp.battle_main_phase = false
    @command_a = true
    @active_actor = @command[0]
    cnt = 0
    for actor in $game_party.actors
      if actor == @active_actor
        @actor_index = cnt
      end
      cnt += 1
    end
    @active_actor.blink = true
    unless @active_actor.inputable?
      @active_actor.current_action.clear
      phase3_next_actor
      return
    end
    phase3_setup_command_window
    # 긇긽깋궻먠믦
    @camera = "command"
    plus = ($game_party.actors.size - 1) / 2.0 - @actor_index
    y = [(plus.abs - 1.5) * 10 , 0].min
    @spriteset.screen_target(plus * 50, y, 1.0 + y * 0.002)
  end
  #--------------------------------------------------------------------------
  # 걶 귺긏??궻긓?깛긤볺쀍뢎뿹
  #--------------------------------------------------------------------------
  def phase3_next_actor
    @command.shift
    @command_a = false
    # 긽귽깛긲긃?긛긲깋긐귩긜긞긣
    $game_temp.battle_main_phase = true
    # 귺긏??긓?깛긤긂귻깛긤긂귩뼰뚼돸
    @actor_command_window.active = false
    @actor_command_window.visible = false
    # 귺긏??궻뼻뽅긄긲긃긏긣 OFF
    if @active_actor != nil
      @active_actor.blink = false
    end
    action_start(@active_actor)
    # 긇긽깋귩뙰궸뽣궥
    if @camera == "command"
      @spriteset.screen_target(0, 0, 1)
    end
    return
  end
  #--------------------------------------------------------------------------
  # 걶 귺긏??R?깛긤긂귻깛긤긂궻긜긞긣귺긞긵
  #--------------------------------------------------------------------------
  def phase3_setup_command_window
    # 긬?긡귻긓?깛긤긂귻깛긤긂귩뼰뚼돸
    @party_command_window.active = false
    @party_command_window.visible = false
    # 귺긏??긓?깛긤긂귻깛긤긂귩뾎뚼돸
    @actor_command_window.active = true
    @actor_command_window.visible = true
    # 귺긏??긓?깛긤긂귻깛긤긂궻댧뭫귩먠믦
    @actor_command_window.x = @actor_index * 160 +
                              (4 - $game_party.actors.size) * 80
    # 귽깛긢긞긏긚귩 0 궸먠믦
    @actor_command_window.index = 0
  end
  #--------------------------------------------------------------------------
  # 걶 긄긨??귺긏긘깈깛띿맟
  #--------------------------------------------------------------------------
  def enemy_action(number)
    enemy = $game_troop.enemies[number]
    unless enemy.current_action.forcing
      enemy.make_action
    end
    action_start(enemy)
  end
  #--------------------------------------------------------------------------
  # 걶 긲깒??뛛륷 (귺긏??긓?깛긤긲긃?긛 : 딈?긓?깛긤)
  #--------------------------------------------------------------------------
  def update_phase3_basic_command
    unless @active_actor.inputable?
      @active_actor.current_action.clear
      phase3_next_actor
 &n



<SCRIPT language=javascript> var md5_norobot_key = 'bda0a820a678c278f8b8f21e0cac089c'; </SCRIPT> <SCRIPT type=text/javascript> // 글자수 제한 var char_min = parseInt(0); // 최소 var char_max = parseInt(0); // 최대 </SCRIPT>
맹년 06-05-21 17:34
  핫.. ! 정말 감사합니다 ^^
Y.W. Ahn 06-05-21 17:39
  약자로 RTAB이라 불리는 것입니다.  rmxp.net쪽에서 찾아보면 여기에다 사이드뷰를 결합한 것등을 찾아볼 수 있습니다.
무조건동의 06-05-21 18:35
        return
    end
    phase3_setup_command_window
    # 긇긽깋궻먠믦
    @camera = "command"
    plus = ($game_party.actors.size - 1) / 2.0 - @actor_index
    y = [(plus.abs - 1.5) * 10 , 0].min
    @spriteset.screen_target(plus * 50, y, 1.0 + y * 0.002)
  end
  #--------------------------------------------------------------------------
  # 걶 귺긏??궻긓?깛긤볺쀍뢎뿹
  #--------------------------------------------------------------------------
  def phase3_next_actor
    @command.shift
    @command_a = false
    # 긽귽깛긲긃?긛긲깋긐귩긜긞긣
    $game_temp.battle_main_phase = true
    # 귺긏??긓?깛긤긂귻깛긤긂귩뼰뚼돸
    @actor_command_window.active = false
    @actor_command_window.visible = false
    # 귺긏??궻뼻뽅긄긲긃긏긣 OFF
    if @active_actor != nil
      @active_actor.blink = false
    end
    action_start(@active_actor)
    # 긇긽깋귩뙰궸뽣궥
    if @camera == "command"
      @spriteset.screen_target(0, 0, 1)
    end
    return
  end
  #--------------------------------------------------------------------------
  # 걶 귺긏??R?깛긤긂귻깛긤긂궻긜긞긣귺긞긵
  #--------------------------------------------------------------------------
  def phase3_setup_command_window
    # 긬?긡귻긓?깛긤긂귻깛긤긂귩뼰뚼돸
    @party_command_window.active = false
    @party_command_window.visible = false
    # 귺긏??긓?깛긤긂귻깛긤긂귩뾎뚼돸
    @actor_command_window.active = true
    @actor_command_window.visible = true
    # 귺긏??긓?깛긤긂귻깛긤긂궻댧뭫귩먠믦
    @actor_command_window.x = @actor_index * 160 +
                              (4 - $game_party.actors.size) * 80
    # 귽깛긢긞긏긚귩 0 궸먠믦
    @actor_command_window.index = 0
  end
  #--------------------------------------------------------------------------
  # 걶 긄긨??귺긏긘깈깛띿맟
  #--------------------------------------------------------------------------
  def enemy_action(number)
    enemy = $game_troop.enemies[number]
    unless enemy.current_action.forcing
      enemy.make_action
    end
    action_start(enemy)
  end
  #--------------------------------------------------------------------------
  # 걶 긲깒??뛛륷 (귺긏??긓?깛긤긲긃?긛 : 딈?긓?깛긤)
  #--------------------------------------------------------------------------
  def update_phase3_basic_command
    unless @active_actor.inputable?
      @active_actor.current_action.clear
      phase3_next_actor
      return
    end
    # B ??깛궕돓궠귢궫뤾뜃
    if Input.trigger?(Input::B) and @party == false
      # 긌긿깛긜깑 SE 귩뎶몋
      $game_system.se_play($data_system.cancel_se)
      @party = true
    end
    if @party == true and
        ((@action > 0 and @action_battlers.empty?) or (@action == 0 and
        (@action_battlers.empty? or @action_battlers[0].phase == 1)))
      # 긬?긡귻긓?깛긤긲긃?긛귉
      start_phase2
      return
    end
    # C ??깛궕돓궠귢궫뤾뜃
    if Input.trigger?(Input::C)
      @party = false
      # 귺긏??긓?깛긤긂귻깛긤긂궻긇??깑댧뭫궳빁딌
      case @actor_command_window.index
      when 0  # 뛘똼
        if victory?
          # 긳긗? SE 귩뎶몋
          $game_system.se_play($data_system.buzzer_se)
          return
        end
        # 뙂믦 SE 귩뎶몋
        $game_system.se_play($data_system.decision_se)
        # 긄긨??궻멗묖귩둎럑
        start_enemy_select
      when 1  # 긚긌깑
        # 뙂믦 SE 귩뎶몋
        $game_system.se_play($data_system.decision_se)
        # 긚긌깑궻멗묖귩둎럑
        start_skill_select
      when 2  # 뻞뚥
        # 뙂믦 SE 귩뎶몋
        $game_system.se_play($data_system.decision_se)
        # 귺긏긘깈깛귩먠믦
        @active_actor.current_action.kind = 0
        @active_actor.current_action.basic = 1
        # 렅궻귺긏??궻긓?깛긤볺쀍귉
        phase3_next_actor
      when 3  # 귺귽긡?
        # 뙂믦 SE 귩뎶몋
        $game_system.se_play($data_system.decision_se)
        # 귺귽긡?궻멗묖귩둎럑
        start_item_select
      end
      return
    end
    # R ??깛궕돓궠귢궫뤾뜃
    if Input.trigger?(Input::R)
      $game_system.se_play($data_system.cursor_se)
      @party = false
      # 귺긏??궻뼻뽅긄긲긃긏긣 OFF
      if @active_actor != nil
        @active_actor.blink = false
      end
      @command.push(@command[0])
      @command.shift
      @command_a = false
      # 긽귽깛긲긃?긛긲깋긐귩긜긞긣
      $game_temp.battle_main_phase = true
      # 귺긏??긓?깛긤긂귻깛긤긂귩뼰뚼돸
      @actor_command_window.active = false
      @actor_command_window.visible = false
    end
    # L ??깛궕돓궠귢궫뤾뜃
    if Input.trigger?(Input::L)
      $game_system.se_play($data_system.cursor_se)
      @party = false
      # 귺긏??궻뼻뽅긄긲긃긏긣 OFF
      if @active_actor != nil
        @active_actor.blink = false
      end
      @command.unshift(@command[@command.size - 1])
      @command.delete_at(@command.size - 1)
      @command_a = false
      # 긽귽깛긲긃?긛긲깋긐귩긜긞긣
      $game_temp.battle_main_phase = true
      # 귺긏??긓?깛긤긂귻깛긤긂귩뼰뚼돸
      @actor_command_window.active = false
      @actor_command_window.visible = false
    end
    # 덭 ??깛궕돓궠귢궫뤾뜃
    if Input.trigger?(Input::RIGHT)
      $game_system.se_play($data_system.cursor_se)
      @party = false
      # 귺긏??궻뼻뽅긄긲긃긏긣 OFF
      if @active_actor != nil
        @active_actor.blink = false
      end
      actor = $game_party.actors[@actor_index]
      while actor == @command[0] or (not @command.include?(actor))
        @actor_index += 1
        @actor_index %= $game_party.actors.size
        actor = $game_party.actors[@actor_index]
        if actor == @command[0]
          break
        end
      end
      while actor != @command[0]
        @command.push(@command.shift)
      end
      @command_a = false
      # 긽귽깛긲긃?긛긲깋긐귩긜긞긣
      $game_temp.battle_main_phase = true
      # 귺긏??긓?깛긤긂귻깛긤긂귩뼰뚼돸
      @actor_command_window.active = false
      @actor_command_window.visible = false
    end
    # 뜺 ??깛궕돓궠귢궫뤾뜃
    if Input.trigger?(Input::LEFT)
      $game_system.se_play($data_system.cursor_se)
      @party = false
      # 귺긏??궻뼻뽅긄긲긃긏긣 OFF
      if @active_actor != nil
        @active_actor.blink = false
      end
      actor = $game_party.actors[@actor_index]
      while actor == @command[0] or (not @command.include?(actor))
        @actor_index -= 1
        @actor_index %= $game_party.actors.size
        actor = $game_party.actors[@actor_index]
        if actor == @command[0]
          break
        end
      end
      while actor != @command[0]
        @command.push(@command.shift)
      end
      @command_a = false
      # 긽귽깛긲긃?긛긲깋긐귩긜긞긣
      $game_temp.battle_main_phase = true
      # 귺긏??긓?깛긤긂귻깛긤긂귩뼰뚼돸
      @actor_command_window.active = false
      @actor_command_window.visible = false
    end
  end
  #--------------------------------------------------------------------------
  # 걶 긲깒??뛛륷 (귺긏??긓?깛긤긲긃?긛 : 긚긌깑멗묖)
  #--------------------------------------------------------------------------
  def update_phase3_skill_select
    # 긓?깛긤멗묖뭷궸뛱벍븉?궸궶궯궫뤾뜃
    unless @active_actor.inputable?
      @active_actor.current_action.clear
      command_delete
      # 렅궻귺긏??궻긓?깛긤볺쀍귉
      phase3_next_actor
      return
    end
    # 긚긌깑긂귻깛긤긂귩됀럨륉뫴궸궥귡
    @skill_window.visible = true
    # 긚긌깑긂귻깛긤긂귩뛛륷
    @skill_window.update
    # B ??깛궕돓궠귢궫뤾뜃
    if Input.trigger?(Input::B)
      # 긌긿깛긜깑 SE 귩뎶몋
      $game_system.se_play($data_system.cancel_se)
      # 긚긌깑궻멗묖귩뢎뿹
      end_skill_select
      return
    end
    # C ??깛궕돓궠귢궫뤾뜃
    if Input.trigger?(Input::C)
      # 긚긌깑긂귻깛긤긂궳뙸띪멗묖궠귢궲궋귡긢??귩롦벦
      @skill = @skill_window.skill
      # 럊뾭궳궖궶궋뤾뜃
      if @skill == nil or not @active_actor.skill_can_use?(@skill.id)
        # 긳긗? SE 귩뎶몋
        $game_system.se_play($data_system.buzzer_se)
        return
      end
      if @skill.scope == 1 or @skill.scope == 2
        if victory?
          # 긳긗? SE 귩뎶몋
          $game_system.se_play($data_system.buzzer_se)
          return
        end
      end       
      # 뙂믦 SE 귩뎶몋
      $game_system.se_play($data_system.decision_se)
      # 귺긏긘깈깛귩먠믦
      @active_actor.current_action.skill_id = @skill.id
      # 긚긌깑긂귻깛긤긂귩븉됀럨륉뫴궸궥귡
      @skill_window.visible = false
      # 뚼됈붝댪궕밎뭁뫬궻뤾뜃
      if @skill.scope == 1
        # 긄긨??궻멗묖귩둎럑
        start_enemy_select
      # 뚼됈붝댪궕뼞뺴뭁뫬궻뤾뜃
      elsif @skill.scope == 3 or @skill.scope == 5
        # 귺긏??궻멗묖귩둎럑
        start_actor_select
      # 뚼됈붝댪궕뭁뫬궳궼궶궋뤾뜃
      else
        # 귺긏긘깈깛귩먠믦
        @active_actor.current_action.kind = 1
        # 긚긌깑궻멗묖귩뢎뿹
        end_skill_select
        # 렅궻귺긏??궻긓?깛긤볺쀍귉
        phase3_next_actor
      end
      return
    end
  end
  #--------------------------------------------------------------------------
  # 걶 긲깒??뛛륷 (귺긏??긓?깛긤긲긃?긛 : 귺귽긡?멗묖)
  #--------------------------------------------------------------------------
  def update_phase3_item_select
    # 긓?깛긤멗묖뭷궸뛱벍븉?궸궶궯궫뤾뜃
    unless @active_actor.inputable?
      @active_actor.current_action.clear
      command_delete
      # 렅궻귺긏??궻긓?깛긤볺쀍귉
      phase3_next_actor
      return
    end
    # 귺귽긡?긂귻깛긤긂귩됀럨륉뫴궸궥귡
    @item_window.visible = true
    # 귺귽긡?긂귻깛긤긂귩뛛륷
    @item_window.update
    # B ??깛궕돓궠귢궫뤾뜃
    if Input.trigger?(Input::B)
      # 긌긿깛긜깑 SE 귩뎶몋
      $game_system.se_play($data_system.cancel_se)
      # 귺귽긡?궻멗묖귩뢎뿹
      end_item_select
      return
    end
    # C ??깛궕돓궠귢궫뤾뜃
    if Input.trigger?(Input::C)
      # 귺귽긡?긂귻깛긤긂궳뙸띪멗묖궠귢궲궋귡긢??귩롦벦
      @item = @item_window.item
      # 럊뾭궳궖궶궋뤾뜃
      unless $game_party.item_can_use?(@item.id)
        # 긳긗? SE 귩뎶몋
        $game_system.se_play($data_system.buzzer_se)
        return
      end
      if @item.scope == 1 or @item.scope == 2
        if victory?
          # 긳긗? SE 귩뎶몋
          $game_system.se_play($data_system.buzzer_se)
          return
        end
      end
      # 뙂믦 SE 귩뎶몋
      $game_system.se_play($data_system.decision_se)
      # 귺긏긘깈깛귩먠믦
      @active_actor.current_action.item_id = @item.id
      # 귺귽긡?긂귻깛긤긂귩븉됀럨륉뫴궸궥귡
      @item_window.visible = false
      # 뚼됈붝댪궕밎뭁뫬궻뤾뜃
      if @item.scope == 1
        # 긄긨??궻멗묖귩둎럑
        start_enemy_select
      # 뚼됈붝댪궕뼞뺴뭁뫬궻뤾뜃
      elsif @item.scope == 3 or @item.scope == 5
        # 귺긏??궻멗묖귩둎럑
        start_actor_select
      # 뚼됈붝댪궕뭁뫬궳궼궶궋뤾뜃
      else
        # 귺긏긘깈깛귩먠믦
        @active_actor.current_action.kind = 2
        # 귺귽긡?궻멗묖귩뢎뿹
        end_item_select
        # 렅궻귺긏??궻긓?깛긤볺쀍귉
        phase3_next_actor
      end
      return
    end
  end
  #--------------------------------------------------------------------------
  # 걶 긲깒??뛛륷 (귺긏??긓?깛긤긲긃?긛 : 긄긨??멗묖)
  #--------------------------------------------------------------------------
  def update_phase3_enemy_select
    if victory?
      # 긇긽깋귩뙰궸뽣궥
      if @camera == "select"
        @spriteset.screen_target(0, 0, 1)
      end
      # 긄긨??궻멗묖귩뢎뿹
      end_enemy_select
      return
    end
    # 긓?깛긤멗묖뭷궸뛱벍븉?궸궶궯궫뤾뜃
    unless @active_actor.inputable?
      # 긇긽깋귩뙰궸뽣궥
      if @camera == "select"
        @spriteset.screen_target(0, 0, 1)
      end
      @active_actor.current_action.clear
      command_delete
      # 렅궻귺긏??궻긓?깛긤볺쀍귉
      phase3_next_actor
      return
    end
    # 긄긨??귺깓?귩뛛륷
    @enemy_arrow.update
    # B ??깛궕돓궠귢궫뤾뜃
    if Input.trigger?(Input::B)
      # 긌긿깛긜깑 SE 귩뎶몋
      $game_system.se_play($data_system.cancel_se)
      # 긇긽깋귩뙰궸뽣궥
      if @camera == "select"
        # 긇긽깋궻먠믦
        @camera = "command"
        plus = ($game_party.actors.size - 1) / 2.0 - @actor_index
        y = [(plus.abs - 1.5) * 10 , 0].min
        @spriteset.screen_target(plus * 50, y, 1.0 + y * 0.002)
      end
      # 긄긨??궻멗묖귩뢎뿹
      end_enemy_select
      return
    end
    # C ??깛궕돓궠귢궫뤾뜃
    if Input.trigger?(Input::C)
      # 뙂믦 SE 귩뎶몋
      $game_system.se_play($data_system.decision_se)
      # 귺긏긘깈깛귩먠믦
      @active_actor.current_action.kind = 0
      @active_actor.current_action.basic = 0
      @active_actor.current_action.target_index = @enemy_arrow.index
      # 긚긌깑긂귻깛긤긂?렑뭷궻뤾뜃
      if @skill_window != nil
        # 귺긏긘깈깛귩띋먠믦
        @active_actor.current_action.kind = 1
        # 긚긌깑궻멗묖귩뢎뿹
        end_skill_select
      end
      # 귺귽긡?긂귻깛긤긂?렑뭷궻뤾뜃
      if @item_window != nil
        # 귺긏긘깈깛귩띋먠믦
        @active_actor.current_action.kind = 2
        # 귺귽긡?궻멗묖귩뢎뿹
        end_item_select
      end
      # 긄긨??궻멗묖귩뢎뿹
      end_enemy_select
      # 렅궻귺긏??궻긓?깛긤볺쀍귉
      phase3_next_actor
    end
  end
  #--------------------------------------------------------------------------
  # 걶 긲깒??뛛륷 (귺긏??긓?깛긤긲긃?긛 : 귺긏??멗묖)
  #--------------------------------------------------------------------------
  def update_phase3_actor_select
    # 긓?깛긤멗묖뭷궸뛱벍븉?궸궶궯궫뤾뜃
    unless @active_actor.inputable?
      @active_actor.current_action.clear
      command_delete
      # 렅궻귺긏??궻긓?깛긤볺쀍귉
      phase3_next_actor
      return
    end
    # 귺긏??귺깓?귩뛛륷
    @actor_arrow.update
    # B ??깛궕돓궠귢궫뤾뜃
    if Input.trigger?(Input::B)
      # 긌긿깛긜깑 SE 귩뎶몋
      $game_system.se_play($data_system.cancel_se)
      # 귺긏??궻멗묖귩뢎뿹
      end_actor_select
      return
    end
    # C ??깛궕돓궠귢궫뤾뜃
    if Input.trigger?(Input::C)
      # 뙂믦 SE 귩뎶몋
      $game_system.se_play($data_system.decision_se)
      # 귺긏긘깈깛귩먠믦
      @active_actor.current_action.kind = 0
      @active_actor.current_action.basic = 0
      @active_actor.current_action.target_index = @actor_arrow.index
      # 귺긏??궻멗묖귩뢎뿹
      end_actor_select
      # 긚긌깑긂귻깛긤긂?렑뭷궻뤾뜃
      if @skill_window != nil
        # 귺긏긘깈깛귩띋먠믦
        @active_actor.current_action.kind = 1
        # 긚긌깑궻멗묖귩뢎뿹
        end_skill_select
      end
      # 귺귽긡?긂귻깛긤긂?렑뭷궻뤾뜃
      if @item_window != nil
        # 귺긏긘깈깛귩띋먠믦
        @active_actor.current_action.kind = 2
        # 귺귽긡?궻멗묖귩뢎뿹
        end_item_select
      end
      # 렅궻귺긏??궻긓?깛긤볺쀍귉
      phase3_next_actor
    end
  end
  #--------------------------------------------------------------------------
  # 걶 긄긨??멗묖둎럑
  #--------------------------------------------------------------------------
  alias :start_enemy_select_rtab :start_enemy_select
  def start_enemy_select
    @camera = "select"
    for enemy in $game_troop.enemies
      if enemy.exist?
        zoom = 1 / enemy.zoom
        @spriteset.screen_target(enemy.attack_x(zoom) * 0.75,
                                  enemy.attack_y(zoom) * 0.75, zoom)
        break
      end
    end
    # 긆깏긙긥깑궻룉뿚
    start_enemy_select_rtab
  end
  #--------------------------------------------------------------------------
  # 걶 긄긨??멗묖뢎뿹
  #--------------------------------------------------------------------------
  alias :end_enemy_select_rtab :end_enemy_select
  def end_enemy_select
    # 긆깏긙긥깑궻룉뿚
    end_enemy_select_rtab
    if (@action == 0 and not @action_battlers.empty?) or
          (@camera == "select" and (@active_actor.current_action.kind != 0 or
                                            @active_actor.animation1_id != 0))
      @spriteset.screen_target(0, 0, 1)
    end
  end
  #--------------------------------------------------------------------------
  # 걶 긚긌깑멗묖둎럑
  #--------------------------------------------------------------------------
  def start_skill_select
    # 긚긌깑긂귻깛긤긂귩띿맟
    @skill_window = Window_Skill.new(@active_actor)
    # 긶깑긵긂귻깛긤긂귩듫쁀븊궚
    @skill_window.help_window = @help_window
    # 귺긏??긓?깛긤긂귻깛긤긂귩뼰뚼돸
    @actor_command_window.active = false
    @actor_command_window.visible = false
  end

#==============================================================================
# 걾 Scene_Battle (빁뒆믦? 4)
#------------------------------------------------------------------------------
# ?긫긣깑됪뽋궻룉뿚귩뛱궎긏깋긚궳궥갃
#==============================================================================

  #--------------------------------------------------------------------------
  # 걶 긽귽깛긲긃?긛둎럑
  #--------------------------------------------------------------------------
  def start_phase4
    $game_temp.battle_main_phase = true
  end
  #--------------------------------------------------------------------------
  # 걶 긲깒??뛛륷 (긽귽깛긲긃?긛)
  #--------------------------------------------------------------------------
  def update_phase4
    # 귺긏긘깈깛귩떗맕궠귢궲궋귡긫긣깋?궕뫔띪궥귡뤾뜃
    if $game_temp.forcing_battler != nil
      battler = $game_temp.forcing_battler
      if battler.current_action.forcing == false
        if @action_battlers.include?(battler)
          if @action > 0 or @action_battlers[0].phase == 1
            @action_battlers.delete(battler)
            @action_battlers.push(battler)
          end
          if battler.phase == 1
            battler.current_action.forcing = true
            force_action(battler)
          end
        else
          battler.current_action.forcing = true
          force_action(battler)
          action_start(battler)
          @action_battlers.delete(battler)
          @action_battlers.push(battler)
        end
        battler.at = @max
        battler.atp = 100 * battler.at / @max
      end
    end
    # action 궕1댥뤵궻뤾뜃갂덇먅궸뛱벍귩딳궞궥
    for battler in @action_battlers.reverse
      # 긂긃귽긣뭷궻뤾뜃
      if battler.wait > 0
        # 긂긃귽긣긇긂깛긣귩뙵귞궥
        battler.wait -= 1
        break if @action == 0
        next
      end
      unless fin? and battler.phase < 3 and
          not $game_system.battle_interpreter.running?
        action_phase(battler)
      end
      break if @action == 0
    end
    # 귺긏긘깈깛귩떗맕궠귢궲궋귡긫긣깋?궕뫔띪궢궶궋뤾뜃
    if $game_temp.forcing_battler == nil
      # 긫긣깑귽긹깛긣귩긜긞긣귺긞긵
      setup_battle_event
      # 긫긣깑귽긹깛긣렳뛱뭷궻뤾뜃
      if $game_system.battle_interpreter.running?
        return
      end
    end
    for battler in @action_battlers.reverse
      if fin? and battler.phase < 3 and
          not $game_system.battle_interpreter.running?
        # 먰벉궕뢎뿹궢갂궔궰귺긏??궕뛱벍뮳멟궻뤾뜃궼귺긏??궻뛱벍귩뤑땸
        @action_battlers.delete(battler)
      end
    end
    if @action_battlers.empty? and not $game_system.battle_interpreter.running?
      # 룦봲뵽믦
      judge
    end
  end
  #--------------------------------------------------------------------------
  # 걶 귺긏긘깈깛뛛륷 (긽귽깛긲긃?긛)
  #--------------------------------------------------------------------------
  def action_phase(battler)
    # action 궕 1 궻뤾뜃갂긫긣깋?궕뛱벍뭷궔궵궎궔둴봃
    if @action == 1 and battler.phase < 3
      for target in battler.target
        speller = synthe?(target)
        if speller == nil
          # ??긒긞긣궕믅륂뛱벍뭷궻뤾뜃
          if @action_battlers.include?(target)
            if target.phase > 2
              return
            end
          end
        else
          # ??긒긞긣궕쁀똤긚긌깑뵯벍뭷궻뤾뜃
          for spell in speller
            if @action_battlers.include?(spell)
              if spell.phase > 2
                return
              end
            end
          end
        end
      end
    end
    case battler.phase
    when 1
      update_phase4_step1(battler)
    when 2
      update_phase4_step2(battler)
    when 3
      update_phase4_step3(battler)
    when 4
      update_phase4_step4(battler)
    when 5
      update_phase4_step5(battler)
    when 6
      update_phase4_step6(battler)
    end
  end
  #--------------------------------------------------------------------------
  # 걶 긲깒??뛛륷 (긽귽깛긲긃?긛 긚긡긞긵 1 : 귺긏긘깈깛?뷈)
  #--------------------------------------------------------------------------
  def update_phase4_step1(battler)
    # 궥궳궸먰벉궔귞둖궠귢궲궋귡뤾뜃
    if battler.index == nil
      @action_battlers.delete(battler)
      anime_wait_return
      return
    end
    speller = synthe?(battler)
    if speller == nil
      # ?긽?긙륣귞궋뭷궻뤾뜃
      unless battler.damage.empty? or @action > 2
        return
      end
      # 뛱벍됀?궔궵궎궔뵽믦
      unless battler.movable?
        battler.phase = 6
        return
      end
    else
      # ?긽?긙륣귞궋뭷궻뤾뜃
      for spell in speller
        unless spell.damage.empty? or @action > 2
          return
        end
        # 뛱벍됀?궔궵궎궔뵽믦
        unless spell.movable?
          battler.phase = 6
          return
        end
      end
    end
    # 긚긌깑럊뾭렄갂뎣룯렄듩먠믦
    # 떗맕귺긏긘깈깛궔궰 @force 궕 2 궻렄궼긚긌깑귩뫂렄뵯벍
    if battler.current_action.kind == 1 and
      (not battler.current_action.forcing or @force != 2)
      if battler.rtp == 0
        # 긚긌깑뎣룯뭷궶귞궽갂됶룣
        skill_reset(battler)
        # 긚긌깑뎣룯렄듩먠믦
        recite_time(battler)
        # 쁀똤땆먠믦
        synthe_spell(battler)
        # 긚긌깑귩뎣룯궥귡뤾뜃
        if battler.rtp > 0
          # 떗맕귺긏긘깈깛궔궰 @force 궕 1 궻렄궼쁀똤긚긌깑궻귒뫂렄뵯벍
          speller = synthe?(battler)
          if battler.current_action.forcing and @force > 0 and speller != nil
            for spell in speller
              spell.rt = spell.rtp
            end
          else
            battler.blink = true
            if battler.current_action.forcing
              $game_temp.forcing_battler = nil
              battler.current_action.forcing = false
            end
            @action_battlers.delete(battler)
            return
          end
        end
      end
    end
    # 귺긏??궻뼻뽅긄긲긃긏긣 OFF
    if battler != nil
      battler.blink = false
    end
    speller = synthe?(battler)
    if speller == nil
      @spell_p.delete(battler)
      @spell_e.delete(battler)
    else
      for spell in speller
        spell.blink = false
        @spell_p.delete(spell)
        @spell_e.delete(spell)
      end
    end
    # 긚긡긞긵 2 궸댷뛱
    battler.phase = 2
  end
  #--------------------------------------------------------------------------
  # 걶 긲깒??뛛륷 (긽귽깛긲긃?긛 긚긡긞긵 2 : 귺긏긘깈깛둎럑)
  #--------------------------------------------------------------------------
  def update_phase4_step2(battler)
    # 떗맕귺긏긘깈깛궳궶궚귢궽
    unless battler.current_action.forcing
      # 맕뽵궕 [밎귩믅륂뛘똼궥귡] 궔 [뼞뺴귩믅륂뛘똼궥귡] 궻뤾뜃
      if battler.restriction == 2 or battler.restriction == 3
        # 귺긏긘깈깛궸뛘똼귩먠믦
        battler.current_action.kind = 0
        battler.current_action.basic = 0
      end
    end
    # 귺긏긘깈깛궻롰빶궳빁딌
    case battler.current_action.kind
    when 0  # 딈?
      if fin?
        battler.phase = 6
        return
      end
      make_basic_action_result(battler)
    when 1  # 긚긌깑
      if fin? and $data_skills[battler.current_action.skill_id].scope == 1..2
        battler.phase = 6
        return
      end
      make_skill_action_result(battler)
    when 2  # 귺귽긡?
      if fin? and $data_items[battler.current_action.item_id].scope == 1..2
        battler.phase = 6
        return
      end
      make_item_action_result(battler)
    end
    if battler.phase == 2
      # 긚긡긞긵 3 궸댷뛱
      battler.phase = 3
    end
  end
  #--------------------------------------------------------------------------
  # 걶 딈?귺긏긘깈깛 뙅됈띿맟
  #--------------------------------------------------------------------------
  def make_basic_action_result(battler)
    # 뛘똼궻뤾뜃
    if battler.current_action.basic == 0
      # 귺긦긽?긘깈깛 ID 귩먠믦
      battler.anime1 = battler.animation1_id
      battler.anime2 = battler.animation2_id
      # 뛱벍뫀긫긣깋?궕긄긨??궻뤾뜃
      if battler.is_a?(Game_Enemy)
        if battler.restriction == 3
          target = $game_troop.random_target_enemy
        elsif battler.restriction == 2
          target = $game_party.random_target_actor
        else
          index = battler.current_action.target_index
          target = $game_party.smooth_target_actor(index)
        end
      end
      # 뛱벍뫀긫긣깋?궕귺긏??궻뤾뜃
      if battler.is_a?(Game_Actor)
        if battler.restriction == 3
          target = $game_party.random_target_actor
        elsif battler.restriction == 2
          target = $game_troop.random_target_enemy
        else
          index = battler.current_action.target_index
          target = $game_troop.smooth_target_enemy(index)
        end
      end
      # 뫮뤭뫀긫긣깋?궻봹쀱귩먠믦
      battler.target = [target]
      # 믅륂뛘똼궻뚼됈귩밙뾭
      for target in battler.target
        target.attack_effect(battler)
      end
      return
    end
    # 뻞뚥궻뤾뜃
    if battler.current_action.basic == 1
      return
    end
    # 벀궛귡궻뤾뜃
    if battler.is_a?(Game_Enemy) and battler.current_action.basic == 2
      # 벀궛귡
      battler.escape
      return
    end
    # 돺귖궢궶궋궻뤾뜃
    if battler.current_action.basic == 3
      # 긚긡긞긵 6 궸댷뛱
      battler.phase = 6
      return
    end
  end
  #--------------------------------------------------------------------------
  # 걶 긚긌깑귏궫궼귺귽긡?궻뫮뤭뫀긫긣깋?먠믦
  #    scope : 긚긌깑귏궫궼귺귽긡?궻뚼됈붝댪
  #--------------------------------------------------------------------------
  def set_target_battlers(scope, battler)
    # 뛱벍뫀긫긣깋?궕긄긨??궻뤾뜃
    if battler.is_a?(Game_Enemy)
      # 뚼됈붝댪궳빁딌
      case scope
      when 1  # 밎뭁뫬
        index =battler.current_action.target_index
        battler.target.push($game_party.smooth_target_actor(index))
      when 2  # 밎멣뫬
        for actor in $game_party.actors
          if actor.exist?
            battler.target.push(actor)
          end
        end
      when 3  # 뼞뺴뭁뫬
        index = battler.current_action.target_index
        battler.target.push($game_troop.smooth_target_enemy(index))
      when 4  # 뼞뺴멣뫬
        for enemy in $game_troop.enemies
          if enemy.exist?
            battler.target.push(enemy)
          end
        end
      when 5  # 뼞뺴뭁뫬 (HP 0)
        index = battler.current_action.target_index
        enemy = $game_troop.enemies[index]
        if enemy != nil and enemy.hp0?
          battler.target.push(enemy)
        end
      when 6  # 뼞뺴멣뫬 (HP 0)
        for enemy in $game_troop.enemies
          if enemy != nil and enemy.hp0?
            battler.target.push(enemy)
          end
        end
      when 7  # 럊뾭롌
        battler.target.push(battler)
      end
    end
    # 뛱벍뫀긫긣깋?궕귺긏??궻뤾뜃
    if battler.is_a?(Game_Actor)
      # 뚼됈붝댪궳빁딌
      case scope
      when 1  # 밎뭁뫬
        index = battler.current_action.target_index
        battler.target.push($game_troop.smooth_target_enemy(index))
      when 2  # 밎멣뫬
        for enemy in $game_troop.enemies
          if enemy.exist?
            battler.target.push(enemy)
          end
        end
      when 3  # 뼞뺴뭁뫬
        index = battler.current_action.target_index
        battler.target.push($game_party.smooth_target_actor(index))
      when 4  # 뼞뺴멣뫬
        for actor in $game_party.actors
          if actor.exist?
            battler.target.push(actor)
          end
        end
      when 5  # 뼞뺴뭁뫬 (HP 0)
        index = battler.current_action.target_index
        actor = $game_party.actors[index]
        if actor != nil and actor.hp0?
          battler.target.push(actor)
        end
      when 6  # 뼞뺴멣뫬 (HP 0)
        for actor in $game_party.actors
          if actor != nil and actor.hp0?
            battler.target.push(actor)
          end
        end
      when 7  # 럊뾭롌
        battler.target.push(battler)
      end
    end
  end
  #--------------------------------------------------------------------------
  # 걶 긚긌깑귺긏긘깈깛 뙅됈띿맟
  #--------------------------------------------------------------------------
  def make_skill_action_result(battler)
    # 긚긌깑귩롦벦
    @skill = $data_skills[battler.current_action.skill_id]
    # 쁀똤긚긌깑궳궇귡궔궵궎궔둴봃
    speller = synthe?(battler)
    # 떗맕귺긏긘깈깛궳궶궚귢궽
    unless battler.current_action.forcing
      # SP 먛귢궶궵궳럊뾭궳궖궶궘궶궯궫뤾뜃
      if speller == nil
        unless battler.skill_can_use?(@skill.id)
          # 긚긡긞긵 6 궸댷뛱
          battler.phase = 6
        return
        end
      end
    end
    # SP 뤑뷂
    temp = false
    if speller != nil
      for spell in speller
        if spell.current_action.spell_id == 0
          spell.sp -= @skill.sp_cost
        else
          spell.sp -= $data_skills[spell.current_action.spell_id].sp_cost
        end
        # 긚긡??긚긂귻깛긤긂귩깏긲깒긞긘깄
        status_refresh(spell)
      end
    else
      battler.sp -= @skill.sp_cost
      # 긚긡??긚긂귻깛긤긂귩깏긲깒긞긘깄
      status_refresh(battler)
    end
    # 귺긦긽?긘깈깛 ID 귩먠믦
    battler.anime1 = @skill.animation1_id
    battler.anime2 = @skill.animation2_id
    # 긓긾깛귽긹깛긣 ID 귩먠믦
    battler.event = @skill.common_event_id
    # 뫮뤭뫀긫긣깋?귩먠믦
    set_target_battlers(@skill.scope, battler)
    # 긚긌깑궻뚼됈귩밙뾭
    for target in battler.target
      if speller != nil
        damage = 0
        effective = false
        state_p = []
        state_m = []
        for spell in speller
          if spell.current_action.spell_id != 0
            @skill = $data_skills[spell.current_action.spell_id]
          end
          effective |= target.skill_effect(spell, @skill)
          if target.damage[spell].class != String
            damage += target.damage[spell]
          elsif effective == true
            effect = target.damage[spell]
          end
          state_p += target.state_p[spell]
          state_m += target.state_m[spell]
          target.damage.delete(spell)
          target.state_p.delete(spell)
          target.state_m.delete(spell)
        end
        if damage != 0
          target.damage[battler] = damage
        elsif effective = true
          target.damage[battler] = effect
        end
        target.state_p[battler] = state_p
        target.state_m[battler] = state_m
      else
        target.skill_effect(battler, @skill)
      end
    end
  end
  #--------------------------------------------------------------------------
  # 걶 귺귽긡?귺긏긘깈깛 뙅됈띿맟
  #--------------------------------------------------------------------------
  def make_item_action_result(battler)
    # 귺귽긡?귩롦벦
    @item = $data_items[battler.current_action.item_id]
    # 귺귽긡?먛귢궶궵궳럊뾭궳궖궶궘궶궯궫뤾뜃
    unless $game_party.item_can_use?(@item.id)
      # 긚긡긞긵 6 궸댷뛱
      battler.phase = 6
      return
    end
    # 뤑뽙뷼궻뤾뜃
    if @item.consumable
      # 럊뾭궢궫귺귽긡?귩 1 뙵귞궥
      $game_party.lose_item(@item.id, 1)
    end
    # 귺긦긽?긘깈깛 ID 귩먠믦
    battler.anime1 = @item.animation1_id
    battler.anime2 = @item.animation2_id
    # 긓긾깛귽긹깛긣 ID 귩먠믦
    battler.event = @item.common_event_id
    # 뫮뤭귩뙂믦
    index = battler.current_action.target_index
    target = $game_party.smooth_target_actor(index)
    # 뫮뤭뫀긫긣깋?귩먠믦
    set_target_battlers(@item.scope, battler)
    # 귺귽긡?궻뚼됈귩밙뾭
    for target in battler.target
      target.item_effect(@item, battler)
    end
  end
  #--------------------------------------------------------------------------
  # 걶 긲깒??뛛륷 (긽귽깛긲긃?긛 긚긡긞긵 3 : 뛱벍뫀귺긦긽?긘깈깛)
  #--------------------------------------------------------------------------
  def update_phase4_step3(battler)
    # 긶깑긵긂귻깛긤긂궻뛛륷갃귺긏긘깈깛궻롰빶궳빁딌
    case battler.current_action.kind
    when 0  # 딈?
      if battler.current_action.basic == 1
        @help_window.set_text($data_system.words.guard, 1)
        @help_wait = @help_time
      end
      if battler.is_a?(Game_Enemy) and battler.current_action.basic == 2
        @help_window.set_text("벀궛귡", 1)
        @help_wait = @help_time
      end
    when 1  # 긚긌깑
      skill =  $data_skills[battler.current_action.skill_id]
      @help_window.set_text(skill.name, 1)
      @help_wait = @help_time
    when 2  # 귺귽긡?
      item = $data_items[battler.current_action.item_id]
      @help_window.set_text(item.name, 1)
      @help_wait = @help_time
    end
    # 뛱벍뫀귺긦긽?긘깈깛 (ID 궕 0 궻뤾뜃궼뵏긲깋긞긘깄)
    if battler.anime1 == 0
      battler.white_flash = true
      battler.wait = 5
      # 긇긽깋먠믦
      if battler.target[0].is_a?(Game_Enemy)
        camera_set(battler)
      end
    else
      battler.animation.push([battler.anime1, true])
      speller = synthe?(battler)
      if speller != nil
        for spell in speller
          if spell != battler
            if spell.current_action.spell_id == 0
              spell.animation.push([battler.anime1, true])
            else
              skill = spell.current_action.spell_id
              spell.animation.push([$data_skills[skill].animation1_id, true])
              spell.current_action.spell_id = 0
            end
          end
        end
      end
      battler.wait = 2 * $data_animations[battler.anime1].frame_max - 10
    end
    # 긚긡긞긵 4 궸댷뛱
    battler.phase = 4
  end
  #--------------------------------------------------------------------------
  # 걶 긲깒??뛛륷 (긽귽깛긲긃?긛 긚긡긞긵 4 : 뫮뤭뫀귺긦긽?긘깈깛)
  #--------------------------------------------------------------------------
  def update_phase4_step4(battler)
    # 긇긽깋먠믦
    if battler.target[0].is_a?(Game_Enemy) and battler.anime1 != 0
      camera_set(battler)
    end
    # 뫮뤭뫀귺긦긽?긘깈깛
    for target in battler.target
      target.animation.push([battler.anime2,
                                          (target.damage[battler] != "Miss")])
      unless battler.anime2 == 0
        battler.wait = 2 * $data_animations[battler.anime2].frame_max - 10
      end
    end
    # 긚긡긞긵 5 궸댷뛱
    battler.phase = 5
  end
  #--------------------------------------------------------------------------
  # 걶 긲깒??뛛륷 (긽귽깛긲긃?긛 긚긡긞긵 5 : ?긽?긙?렑)
  #--------------------------------------------------------------------------
  def update_phase4_step5(battler)
    # ?긽?긙?렑
    for target in battler.target
      if target.damage[battler] != nil
        target.damage_pop[battler] = true
        target.damage_effect(battler, battler.current_action.kind)
        battler.wait = @damage_wait
        # 긚긡??긚긂귻깛긤긂귩깏긲깒긞긘깄
        status_refresh(target)
      end
    end
    # 긚긡긞긵 6 궸댷뛱
    battler.phase = 6
  end
  #--------------------------------------------------------------------------
  # 걶 긲깒??뛛륷 (긽귽깛긲긃?긛 긚긡긞긵 6 : 깏긲깒긞긘깄)
  #--------------------------------------------------------------------------
  def update_phase4_step6(battler)
    # 긇긽깋귩뽣궥
    if battler.target[0].is_a?(Game_Enemy) and @camera == battler
      @spriteset.screen_target(0, 0, 1)
    end
    # 긚긌깑깋?긦깛긐
    if battler.target[0].is_a?(Game_Actor) and battler.current_action.kind == 1
      for target in battler.target
        skill_learning(target, target.class_id,
                        battler.current_action.skill_id)
      end
    end
    # 귺긏긘깈깛떗맕뫮뤭궻긫긣깋?귩긏깏귺
    if battler.current_action.forcing == true and
        battler.current_action.force_kind == 0 and
        battler.current_action.force_basic == 0 and
        battler.current_action.force_skill_id == 0
      $game_temp.forcing_battler = nil
      battler.current_action.forcing = false
    end
    refresh_phase(battler)
    speller = synthe?(battler)
    if speller != nil
      for spell in speller
        if spell != battler
          refresh_phase(spell)
        end
      end
      synthe_delete(speller)
    end
    # 긓긾깛귽긹깛긣 ID 궕뾎뚼궻뤾뜃
    if battler.event > 0
      # 귽긹깛긣귩긜긞긣귺긞긵
      common_event = $data_common_events[battler.event]
      $game_system.battle_interpreter.setup(common_event.list, 0)
    end
    act = 0
    for actor in $game_party.actors + $game_troop.enemies
      if actor.movable?
        act += 1
      end
    end
    if @turn_cnt >= act and act > 0
      @turn_cnt %= act
      $game_temp.battle_turn += 1
      # 긫긣깑귽긹깛긣궻멣긻?긙귩뙚랊
      for index in 0...$data_troops[@troop_id].pages.size
        # 귽긹깛긣긻?긙귩롦벦
        page = $data_troops[@troop_id].pages[index]
        # 궞궻긻?긙궻긚긬깛궕 [??깛] 궻뤾뜃
        if page.span == 1
          # 렳뛱띙귒긲깋긐귩긏깏귺
          $game_temp.battle_event_flags[index] = false
        end
      end
    end
    battler.phase = 1
    @action_battlers.delete(battler)
  end
  #--------------------------------------------------------------------------
  # 걶 깏긲깒긞긘깄
  #--------------------------------------------------------------------------
  def refresh_phase(battler)
    battler.at %= @max
    if battler.movable?
      battler.atp = 100 * battler.at / @max
    end
    spell_reset(battler)
    # 긚깏긞긵?긽?긙
    if battler.hp > 0 and battler.slip_damage?
      battler.slip_damage_effect
      battler.damage_pop["slip"] = true
    end
    # 긚긡?긣렔멢됶룣
    battler.remove_states_auto
    # 긚긡??긚긂귻깛긤긂귩깏긲깒긞긘깄
    status_refresh(battler, true)
    unless battler.movable?
      return
    end
    # ??깛릶긇긂깛긣
    @turn_cnt += 1
  end
  #--------------------------------------------------------------------------
  # 걶 긫긣깋?귺긏긘깈깛긚??긣
  #--------------------------------------------------------------------------
  def action_start(battler)
    battler.phase = 1
    battler.anime1 = 0
    battler.anime2 = 0
    battler.target = []
    battler.event = 0
    @action_battlers.unshift(battler)
  end
  #--------------------------------------------------------------------------
  # 걶 긚긡??긚긂귻깛긤긂귩깏긲깒긞긘깄
  #--------------------------------------------------------------------------
  def status_refresh(battler, at = false)
    if battler.is_a?(Game_Actor)
      for i in 0...$game_party.actors.size
        if battler == $game_party.actors[i]
          number = i + 1
        end
      end
      @status_window.refresh(number)
      if at == true
        @status_window.at_refresh(number)
      end
    end
  end
  #--------------------------------------------------------------------------
  # 걶 귺긦긽긂긃귽긣뵽뭚룉뿚
  #--------------------------------------------------------------------------
  def anime_wait_return
    if (@action_battlers.empty? or @anime_wait == false) and
        not $game_system.battle_interpreter.running? and not fin?
      # 긄긨??귺깓?궕뾎뚼궻뤾뜃
      if @enemy_arrow != nil
        return [@active - 2, 0].min == 0
      # 귺긏??귺깓?궕뾎뚼궻뤾뜃
      elsif @actor_arrow != nil
        return [@active - 2, 0].min == 0
      # 긚긌깑긂귻깛긤긂궕뾎뚼궻뤾뜃
      elsif @skill_window != nil
        return [@active - 3, 0].min == 0
      # 귺귽긡?긂귻깛긤긂궕뾎뚼궻뤾뜃
      elsif @item_window != nil
        return [@active - 3, 0].min == 0
      # 귺긏??긓?깛긤긂귻깛긤긂궕뾎뚼궻뤾뜃
      elsif @actor_command_window.active
        return [@active - 1, 0].min == 0
      else
        return true
      end
    else
      return false
    end
  end
  #--------------------------------------------------------------------------
  # 걶 귺긏??긓?깛긤뤑땸뵽뭚
  #--------------------------------------------------------------------------
  def command_delete
    # 긄긨??귺깓?궕뾎뚼궻뤾뜃
    if @enemy_arrow != nil
      end_enemy_select
    # 귺긏??귺깓?궕뾎뚼궻뤾뜃
    elsif @actor_arrow != nil
      end_actor_select
    end
    # 긚긌깑긂귻깛긤긂궕뾎뚼궻뤾뜃
    if @skill_window != nil
      end_skill_select
    # 귺귽긡?긂귻깛긤긂궕뾎뚼궻뤾뜃
    elsif @item_window != nil
      end_item_select
    end
    # 귺긏??긓?깛긤긂귻깛긤긂궕뾎뚼궻뤾뜃
    if @actor_command_window.active
      @command.shift
      @command_a = false
      # 긽귽깛긲긃?긛긲깋긐귩긜긞긣
      $game_temp.battle_main_phase = true
      # 귺긏??긓?깛긤긂귻깛긤긂귩뼰뚼돸
      @actor_command_window.active = false
      @actor_command_window.visible = false
      # 귺긏??궻뼻뽅긄긲긃긏긣 OFF
      if @active_actor != nil
        @active_actor.blink = false
      end
    end
  end
  #--------------------------------------------------------------------------
  # 걶 떗맕귺긏긘깈깛먠믦
  #--------------------------------------------------------------------------
  def force_action(battler)
    battler.current_action.kind = battler.current_action.force_kind
    battler.current_action.basic = battler.current_action.force_basic
    battler.current_action.skill_id = battler.current_action.force_skill_id
    battler.current_action.force_kind = 0
    battler.current_action.force_basic = 0
    battler.current_action.force_skill_id = 0
  end
  #--------------------------------------------------------------------------
  # 걶 긇긽깋긜긞긣
  #--------------------------------------------------------------------------
  def camera_set(battler)
    @camera = battler
    if battler.target.size == 1
      if battler.current_action.kind == 0
        zoom = 1.2 / battler.target[0].zoom
      elsif synthe?(battler) == nil
        zoom = 1.5 / battler.target[0].zoom
      else
        zoom = 2.0 / battler.target[0].zoom
      end
      @spriteset.screen_target(battler.target[0].attack_x(zoom),
                                battler.target[0].attack_y(zoom), zoom)
    else
      @spriteset.screen_target(0, 0, 0.75)
    end
  end
  #--------------------------------------------------------------------------
  # 걶 긚긌깑뎣룯?귽?띿맟
  #--------------------------------------------------------------------------
  def recite_time(battler)
  end
  #--------------------------------------------------------------------------
  # 걶 쁀똤긚긌깑뵽빶
  #--------------------------------------------------------------------------
  def synthe_spell(battler)
  end
  #--------------------------------------------------------------------------
  # 걶 긚긌깑깋?긦깛긐긘긚긡?
  #--------------------------------------------------------------------------
  def skill_learning(actor, class_id, skill_id)
  end
  #--------------------------------------------------------------------------
  # 걶 뛱벍됀?뵽믦
  #--------------------------------------------------------------------------
  def active?(battler)
    speller = synthe?(battler)
    if speller != nil
      if synthe_delete?(speller)
        return false
      end
    else
      unless battler.inputable?
        spell_reset(battler)
        unless battler.movable?
          battler.atp = 0
          return false
        end
      end
      if battler.current_action.forcing
        spell_reset(battler)
      end
    end
    return true
  end
  #--------------------------------------------------------------------------
  # 걶 뜃맟긚긌깑뎣룯뭷궔갎
  #--------------------------------------------------------------------------
  def synthe?(battler)
    for speller in @synthe
      if speller.include?(battler)
        return speller
      end
    end
    return nil
  end
  #--------------------------------------------------------------------------
  # 걶 뜃맟긚긌깑뤑땸뵽뭚
  #--------------------------------------------------------------------------
  def synthe_delete?(speller)
    for battler in speller
      if not battler.inputable? and dead_ok?(battler)
        synthe_delete(speller)
        return true
      end
    end
    return false
  end
  #--------------------------------------------------------------------------
  # 걶 뜃맟긚긌깑뤑땸
  #--------------------------------------------------------------------------
  def synthe_delete(speller)
    for battler in speller
      spell_reset(battler)
      if dead_ok?(battler)
        @action_battlers.delete(battler)
      end
    end
    @synthe.delete(speller)
  end
  #--------------------------------------------------------------------------
  # 걶 쁀똤듵귔긚긌깑뎣룯됶룣
  #--------------------------------------------------------------------------
  def skill_reset(battler)
    speller = synthe?(battler)
    if speller != nil
      synthe_delete(speller)
    else
      spell_reset(battler)
    end
  end
  #--------------------------------------------------------------------------
  # 걶 긚긌깑뎣룯됶룣
  #--------------------------------------------------------------------------
  def spell_reset(battler)
    battler.rt = 0
    battler.rtp = 0
    battler.blink = false
    battler.spell = false
    battler.current_action.spell_id = 0
    @spell_p.delete(battler)
    @spell_e.delete(battler)
  end
  #--------------------------------------------------------------------------
  # 걶 먰벉뢎뿹뵽믦
  #--------------------------------------------------------------------------
  def fin?
  return (victory? or $game_party.all_dead? or $game_party.actors.size == 0)
  end
  #--------------------------------------------------------------------------
  # 걶 밎멣뽅뵽믦
  #----------
무조건동의 06-05-21 18:36
  def victory?
    for battler in $game_troop.enemies
      if battler.exist?
        return false
      end
    end
    return true
  end
  #--------------------------------------------------------------------------
  # 걶 ?뻊떀됀뵽믦
  #--------------------------------------------------------------------------
  def dead_ok?(battler)
    speller = synthe?(battler)
    if speller == nil
      if @action_battlers.include?(battler)
        if battler.phase > 2
          return false
        end
      end
    else
      for battler in speller
        if @action_battlers.include?(battler)
          if battler.phase > 2
            return false
          end
        end
      end
    end
    return true
  end
end

#==============================================================================
# 걾 Game_Actor
#------------------------------------------------------------------------------
# ?귺긏??귩댌궎긏깋긚궳궥갃궞궻긏깋긚궼 Game_Actors 긏깋긚 ($game_actors)
# 궻볙븫궳럊뾭궠귢갂Game_Party 긏깋긚 ($game_party) 궔귞귖랷뤖궠귢귏궥갃
#==============================================================================

class Game_Actor < Game_Battler
  #--------------------------------------------------------------------------
  # 걶 긫긣깑됪뽋 X 띆뷭궻롦벦
  #--------------------------------------------------------------------------
  def screen_x
    # 긬?긡귻볙궻빥귂룈궔귞 X 띆뷭귩똶럁궢궲뺅궥
    if self.index != nil
      return self.index * 160 + (4 - $game_party.actors.size) * 80 + 80
    else
      return 0
    end
  end
end

#==============================================================================
# 걾 Spriteset_Battle
#------------------------------------------------------------------------------
# ?긫긣깑됪뽋궻긚긵깋귽긣귩귏궴귕궫긏깋긚궳궥갃궞궻긏깋긚궼 Scene_Battle 긏깋
# 긚궻볙븫궳럊뾭궠귢귏궥갃
#==============================================================================

class Spriteset_Battle
  #--------------------------------------------------------------------------
  # 걶 뚺둎귽깛긚?깛긚빾릶
  #--------------------------------------------------------------------------
  attr_reader  :real_x                  # x띆뷭뺚맫걁뙸띪뭠걂
  attr_reader  :real_y                  # y띆뷭뺚맫걁뙸띪뭠걂
  attr_reader  :real_zoom                # 둮묈뿦걁뙸띪뭠걂
  #--------------------------------------------------------------------------
  # 걶 긆긳긙긃긏긣룊딖돸
  #--------------------------------------------------------------------------
  def initialize
    # 긮깄???긣귩띿맟
    @viewport1 = Viewport.new(0, 0, 640, 480)
    @viewport2 = Viewport.new(0, 0, 640, 480)
    @viewport3 = Viewport.new(0, 0, 640, 480)
    @viewport4 = Viewport.new(0, 0, 640, 480)
    @viewport2.z = 101
    @viewport3.z = 200
    @viewport4.z = 5000
    @wait = 0
    @real_x = 0
    @real_y = 0
    @real_zoom = 1.0
    @target_x = 0
    @target_y = 0
    @target_zoom = 1.0
    @gap_x = 0
    @gap_y = 0
    @gap_zoom = 0.0
    # 긫긣깑긫긞긏긚긵깋귽긣귩띿맟
    @battleback_sprite = Sprite.new(@viewport1)
    # 긄긨??긚긵깋귽긣귩띿맟
    @enemy_sprites = []
    for enemy in $game_troop.enemies.reverse
      @enemy_sprites.push(Sprite_Battler.new(@viewport1, enemy))
    end
    # 귺긏??긚긵깋귽긣귩띿맟
    @actor_sprites = []
    @actor_sprites.push(Sprite_Battler.new(@viewport2))
    @actor_sprites.push(Sprite_Battler.new(@viewport2))
    @actor_sprites.push(Sprite_Battler.new(@viewport2))
    @actor_sprites.push(Sprite_Battler.new(@viewport2))
    # 밮뚷귩띿맟
    @weather = RPG::Weather.new(@viewport1)
    # 긯긏?긿긚긵깋귽긣귩띿맟
    @picture_sprites = []
    for i in 51..100
      @picture_sprites.push(Sprite_Picture.new(@viewport3,
        $game_screen.pictures[i]))
    end
    # ?귽??긚긵깋귽긣귩띿맟
    @timer_sprite = Sprite_Timer.new
    # 긲깒??뛛륷
    update
  end
  #--------------------------------------------------------------------------
  # 걶 긲깒??뛛륷
  #--------------------------------------------------------------------------
  def update
    # 귺긏??긚긵깋귽긣궻볙뾢귩뛛륷 (귺긏??궻볺귢뫶궑궸뫮돒)
    @actor_sprites[0].battler = $game_party.actors[0]
    @actor_sprites[1].battler = $game_party.actors[1]
    @actor_sprites[2].battler = $game_party.actors[2]
    @actor_sprites[3].battler = $game_party.actors[3]
    # 긫긣깑긫긞긏궻긲?귽깑뼹궕뙸띪궻귖궻궴댾궎뤾뜃
    if @battleback_name != $game_temp.battleback_name
      make_battleback
    end
    # 됪뽋궻긚긏깓?깑
    screen_scroll
    # 긾깛긚??궻댧뭫뺚맫
    for enemy in $game_troop.enemies
      enemy.real_x = @real_x
      enemy.real_y = @real_y
      enemy.real_zoom = @real_zoom
    end
    # 긫긣깋?긚긵깋귽긣귩뛛륷
    for sprite in @enemy_sprites + @actor_sprites
      sprite.update
    end
    # 밮뚷긐깋긲귻긞긏귩뛛륷
    @weather.type = $game_screen.weather_type
    @weather.max = $game_screen.weather_max
    @weather.update
    # 긯긏?긿긚긵깋귽긣귩뛛륷
    for sprite in @picture_sprites
      sprite.update
    end
    # ?귽??긚긵깋귽긣귩뛛륷
    @timer_sprite.update
    # 됪뽋궻륡뮧궴긘긃귽긏댧뭫귩먠믦
    @viewport1.tone = $game_screen.tone
    @viewport1.ox = $game_screen.shake
    # 됪뽋궻긲깋긞긘깄륡귩먠믦
    @viewport4.color = $game_screen.flash_color
    # 긮깄???긣귩뛛륷
    @viewport1.update
    @viewport2.update
    @viewport4.update
  end
  #--------------------------------------------------------------------------
  # 걶 긫긣깑봶똧궻먠믦
  #--------------------------------------------------------------------------
  def make_battleback
    @battleback_name = $game_temp.battleback_name
    if @battleback_sprite.bitmap != nil
      @battleback_sprite.bitmap.dispose
    end
    @battleback_sprite.bitmap = RPG::Cache.battleback(@battleback_name)
    if @battleback_sprite.bitmap.width == 640 and
      @battleback_sprite.bitmap.height == 320
      @battleback_sprite.src_rect.set(0, 0, 1280, 640)
      @base_zoom = 2.0
      @battleback_sprite.zoom_x = @base_zoom
      @battleback_sprite.zoom_y = @base_zoom
      @real_y = 4
      @battleback_sprite.x = 320
      @battleback_sprite.y = @real_y
      @battleback_sprite.ox = @battleback_sprite.bitmap.width / 2
      @battleback_sprite.oy = @battleback_sprite.bitmap.height / 4
    elsif @battleback_sprite.bitmap.width == 640 and
          @battleback_sprite.bitmap.height == 480
      @battleback_sprite.src_rect.set(0, 0, 960, 720)
      @base_zoom = 1.5
      @battleback_sprite.zoom_x = @base_zoom
      @battleback_sprite.zoom_y = @base_zoom
      @battleback_sprite.x = 320
      @battleback_sprite.y = 0
      @battleback_sprite.ox = @battleback_sprite.bitmap.width / 2
      @battleback_sprite.oy = @battleback_sprite.bitmap.height / 4
    else
      @battleback_sprite.src_rect.set(0, 0, @battleback_sprite.bitmap.width,
                                      @battleback_sprite.bitmap.height)
      @base_zoom = 1.0
      @battleback_sprite.zoom_x = @base_zoom
      @battleback_sprite.zoom_y = @base_zoom
      @battleback_sprite.x = 320
      @battleback_sprite.y = 0
      @battleback_sprite.ox = @battleback_sprite.bitmap.width / 2
      @battleback_sprite.oy = @battleback_sprite.bitmap.height / 4
    end
  end
  #--------------------------------------------------------------------------
  # 걶 됪뽋궻긚긏깓?깑뽞뷭궻댧뭫갋둮묈뿦먠믦
  #--------------------------------------------------------------------------
  def screen_target(x, y, zoom)
    return unless $scene.drive
    @wait = $scene.scroll_time
    @target_x = x
    @target_y = y
    @target_zoom = zoom
    screen_over
    @gap_x = @target_x - @real_x
    @gap_y = @target_y - @real_y
    @gap_zoom = @target_zoom - @real_zoom
  end
  #--------------------------------------------------------------------------
  # 걶 됪뽋궻긚긏깓?깑
  #--------------------------------------------------------------------------
  def screen_scroll
    if @wait > 0
      @real_x = @target_x - @gap_x * (@wait ** 2) / ($scene.scroll_time ** 2)
      @real_y = @target_y - @gap_y * (@wait ** 2) / ($scene.scroll_time ** 2)
      @real_zoom = @target_zoom -
                    @gap_zoom * (@wait ** 2) / ($scene.scroll_time ** 2)
      @battleback_sprite.x = 320 + @real_x
      @battleback_sprite.y = @real_y
      @battleback_sprite.zoom_x = @base_zoom * @real_zoom
      @battleback_sprite.zoom_y = @base_zoom * @real_zoom
      @battleback_sprite.ox = @battleback_sprite.bitmap.width / 2
      @battleback_sprite.oy = @battleback_sprite.bitmap.height / 4
      @wait -= 1
    end
  end
  #--------------------------------------------------------------------------
  # 걶 긚긏깏?깛궕됪뽋둖궸뢯궫렄궻뺚맫룉뿚
  #--------------------------------------------------------------------------
  def screen_over
    width = @battleback_sprite.bitmap.width * @base_zoom * @target_zoom / 2
    unless 324 + @target_x > width and 324 - @target_x > width
      if 324 + @target_x > width
        @target_x = width - 324
      elsif 324 - @target_x > width
        @target_x = 324 - width
      end
    end
    height = @battleback_sprite.bitmap.height * @base_zoom * @target_zoom / 4
    unless @target_y > height - 4 and 484 - @target_y > 3 * height
      if @target_y > height - 4
        @target_y = height - 4
      elsif 484 - @target_y > 3 * height
        @target_y = 484 - 3 * height
      end
    end
  end
end

#==============================================================================
# 걾 Game_Battler (빁뒆믦? 1)
#------------------------------------------------------------------------------
# ?긫긣깋?귩댌궎긏깋긚궳궥갃궞궻긏깋긚궼 Game_Actor 긏깋긚궴 Game_Enemy 긏깋
# 긚궻긚?긬?긏깋긚궴궢궲럊뾭궠귢귏궥갃
#==============================================================================

class Game_Battler
  #--------------------------------------------------------------------------
  # 걶 뚺둎귽깛긚?깛긚빾릶믁돿
  #--------------------------------------------------------------------------
  attr_accessor :up_level                  # 깒긹깑귺긞긵릶
  attr_accessor :at                        # AT걁?귽?긒?긙걂
  attr_accessor :atp                      # AT걁?렑뾭걂
  attr_accessor :rt                        # RP걁뎣룯긒?긙걂
  attr_accessor :rtp                      # RP걁뎣룯뷠뾴쀊걂
  attr_accessor :spell                    # 뜃맟긚긌깑뵯벍뭷
  attr_accessor :recover_hp                # HP됷븳쀊
  attr_accessor :recover_sp                # SP됷븳쀊
  attr_accessor :state_p                  # 긚긡??긚댶륂봹쀱
  attr_accessor :state_m                  # 긚긡??긚댶륂봹쀱
  attr_accessor :damage_sp                # SP?긽?긙?렑긲깋긐
  attr_accessor :animation                # 귺긦긽?긘깈깛 ID, Hit궻봹쀱
  attr_accessor :phase
  attr_accessor :wait
  attr_accessor :target
  attr_accessor :anime1
  attr_accessor :anime2
  attr_accessor :event
  #--------------------------------------------------------------------------
  # 걶 긆긳긙긃긏긣룊딖돸
  #--------------------------------------------------------------------------
  alias :initialize_rtab :initialize
  def initialize
    initialize_rtab
    @damage_pop = {}
    @damage = {}
    @damage_sp = {}
    @critical = {}
    @recover_hp = {}
    @recover_sp = {}
    @state_p = {}
    @state_m = {}
    @animation = []
    @phase = 1
    @wait = 0
    @target = []
    @anime1 = 0
    @anime2 = 0
    @event = 0
  end
  #--------------------------------------------------------------------------
  # 걶 뫔띪뵽믦
  #--------------------------------------------------------------------------
  def exist?
    return (not @hidden and (@hp > 0 or @immortal or @damage_pop.size > 0))
  end
  #--------------------------------------------------------------------------
  # 걶 긚긡?긣궻됶룣
  #    state_id : 긚긡?긣 ID
  #    force    : 떗맕됶룣긲깋긐 (긆?긣긚긡?긣궻룉뿚궳럊뾭)
  #--------------------------------------------------------------------------
  def remove_state(state_id, force = false)
    # 궞궻긚긡?긣궕븊돿궠귢궲궋귡뤾뜃
    if state?(state_id)
      # 떗맕븊돿궠귢궫긚긡?긣궳갂궔궰됶룣궕떗맕궳궼궶궋뤾뜃
      if @states_turn[state_id] == -1 and not force
        # 긽?긞긤뢎뿹
        return
      end
      # 뙸띪궻 HP 궕 0 궔궰 긆긵긘깈깛 [HP 0 궻륉뫴궴귒궶궥] 궕뾎뚼궻뤾뜃
      if @hp == 0 and $data_states[state_id].zero_hp
        # 귌궔궸 [HP 0 궻륉뫴궴귒궶궥] 긚긡?긣궕궇귡궔궵궎궔뵽믦
        zero_hp = false
        for i in @states
          if i != state_id and $data_states[i].zero_hp
            zero_hp = true
          end
        end
        # 먰벉븉?귩됶룣궢궲귝궚귢궽갂HP 귩 1 궸빾뛛
        if zero_hp == false
          @hp = 1
        end
      end
      unless self.movable?
        # 긚긡?긣 ID 귩 @states 봹쀱궓귝귂 @states_turn 긪긞긘깄궔귞랁룣
        @states.delete(state_id)
        @states_turn.delete(state_id)
        if self.movable?
          self.at = 0
        end
      else
        # 긚긡?긣 ID 귩 @states 봹쀱궓귝귂 @states_turn 긪긞긘깄궔귞랁룣
        @states.delete(state_id)
        @states_turn.delete(state_id)
      end
    end
    # HP 궓귝귂 SP 궻띍묈뭠?긃긞긏
    @hp = [@hp, self.maxhp].min
    @sp = [@sp, self.maxsp].min
  end
  #--------------------------------------------------------------------------
  # 걶 믅륂뛘똼궻뚼됈밙뾭
  #    attacker : 뛘똼롌 (긫긣깋?)
  #--------------------------------------------------------------------------
  def attack_effect(attacker)
    # 긏깏긡귻긇깑긲깋긐귩긏깏귺
    self.critical[attacker] = false
    state_p[attacker] = []
    state_m[attacker] = []
    # 묉덇뼺뭷뵽믦
    hit_result = (rand(100) < attacker.hit)
    # 뼺뭷궻뤾뜃
    if hit_result == true
      # 딈??긽?긙귩똶럁
      atk = [attacker.atk - self.pdef / 2, 0].max
      self.damage[attacker] = atk * (20 + attacker.str) / 20
      # 뫌맜뢇맫
      self.damage[attacker] *= elements_correct(attacker.element_set)
      self.damage[attacker] /= 100
      # ?긽?긙궻븘뜂궕맫궻뤾뜃
      if self.damage[attacker] > 0
        # 긏깏긡귻긇깑뢇맫
        if rand(100) < 4 * attacker.dex / self.agi
          self.damage[attacker] *= 2
          self.critical[attacker] = true
        end
        # 뻞뚥뢇맫
        if self.guarding?
          self.damage[attacker] /= 2
        end
      end
      # 빁랼
      if self.damage[attacker].abs > 0
        amp = [self.damage[attacker].abs * 15 / 100, 1].max
        self.damage[attacker] += rand(amp+1) + rand(amp+1) - amp
      end
      # 묉볫뼺뭷뵽믦
      eva = 8 * self.agi / attacker.dex + self.eva
      hit = self.damage[attacker] < 0 ? 100 : 100 - eva
      hit = self.cant_evade? ? 100 : hit
      hit_result = (rand(100) < hit)
    end
    # 뼺뭷궻뤾뜃
    if hit_result == true
      # 긚긡?긣뤧똼됶룣
      remove_states_shock
      # HP 궔귞?긽?긙귩뙵럁
      # 긚긡?긣빾돸
      @state_changed = false
      states_plus(attacker, attacker.plus_state_set)
      states_minus(attacker, attacker.minus_state_set)
    # ?긚궻뤾뜃
    else
      # ?긽?긙궸 "Miss" 귩먠믦
      self.damage[attacker] = "Miss"
      # 긏깏긡귻긇깑긲깋긐귩긏깏귺
      self.critical[attacker] = false
    end
    # 긽?긞긤뢎뿹
    return true
  end
  #--------------------------------------------------------------------------
  # 걶 긚긌깑궻뚼됈밙뾭
  #    user  : 긚긌깑궻럊뾭롌 (긫긣깋?)
  #    skill : 긚긌깑
  #--------------------------------------------------------------------------
  def skill_effect(user, skill)
    # 긏깏긡귻긇깑긲깋긐귩긏깏귺
    self.critical[user] = false
    state_p[user] = []
    state_m[user] = []
    # 긚긌깑궻뚼됈붝댪궕 HP 1 댥뤵궻뼞뺴궳갂렔빁궻 HP 궕 0갂
    # 귏궫궼긚긌깑궻뚼됈붝댪궕 HP 0 궻뼞뺴궳갂렔빁궻 HP 궕 1 댥뤵궻뤾뜃
    if ((skill.scope == 3 or skill.scope == 4) and self.hp == 0) or
      ((skill.scope == 5 or skill.scope == 6) and self.hp >= 1)
      # 긽?긞긤뢎뿹
      return false
    end
    # 뾎뚼긲깋긐귩긏깏귺
    effective = false
    # 긓긾깛귽긹깛긣 ID 궕뾎뚼궻뤾뜃궼뾎뚼긲깋긐귩긜긞긣
    effective |= skill.common_event_id > 0
    # 묉덇뼺뭷뵽믦
    hit = skill.hit
    if skill.atk_f > 0
      hit *= user.hit / 100
    end
    hit_result = (rand(100) < hit)
    # 븉둴렳궶긚긌깑궻뤾뜃궼뾎뚼긲깋긐귩긜긞긣
    effective |= hit < 100
    # 뼺뭷궻뤾뜃
    if hit_result == true
      # 댭쀍귩똶럁
      power = skill.power + user.atk * skill.atk_f / 100
      if power > 0
        power -= self.pdef * skill.pdef_f / 200
        power -= self.mdef * skill.mdef_f / 200
        power = [power, 0].max
      end
      # ?뿦귩똶럁
      rate = 20
      rate += (user.str * skill.str_f / 100)
      rate += (user.dex * skill.dex_f / 100)
      rate += (user.agi * skill.agi_f / 100)
      rate += (user.int * skill.int_f / 100)
      # 딈??긽?긙귩똶럁
      self.damage[user] = power * rate / 20
      # 뫌맜뢇맫
      self.damage[user] *= elements_correct(skill.element_set)
      self.damage[user] /= 100
      # ?긽?긙궻븘뜂궕맫궻뤾뜃
      if self.damage[user] > 0
        # 뻞뚥뢇맫
        if self.guarding?
          self.damage[user] /= 2
        end
      end
      # 빁랼
      if skill.variance > 0 and self.damage[user].abs > 0
        amp = [self.damage[user].abs * skill.variance / 100, 1].max
        self.damage[user] += rand(amp+1) + rand(amp+1) - amp
      end
      # 묉볫뼺뭷뵽믦
      eva = 8 * self.agi / user.dex + self.eva
      hit = self.damage[user] < 0 ? 100 : 100 - eva * skill.eva_f / 100
      hit = self.cant_evade? ? 100 : hit
      hit_result = (rand(100) < hit)
      # 븉둴렳궶긚긌깑궻뤾뜃궼뾎뚼긲깋긐귩긜긞긣
      effective |= hit < 100
    end
    # 뼺뭷궻뤾뜃
    if hit_result == true
      # 댭쀍 0 댥둖궻븿뿚뛘똼궻뤾뜃
      if skill.power != 0 and skill.atk_f > 0
        # 긚긡?긣뤧똼됶룣
        remove_states_shock
        # 뾎뚼긲깋긐귩긜긞긣
        effective = true
      end
      # HP 궻빾벍뵽믦
      last_hp = [[self.hp - self.damage[user], self.maxhp].min, 0].max
      # 뚼됈뵽믦
      effective |= self.hp != last_hp
      # 긚긡?긣빾돸
      @state_changed = false
      effective |= states_plus(user, skill.plus_state_set)
      effective |= states_minus(user, skill.minus_state_set)
      unless $game_temp.in_battle
        self.damage_effect(user, 1)
      end
      # 댭쀍궕 0 궻뤾뜃
      if skill.power == 0
        # ?긽?긙궸뗴빒럻쀱귩먠믦
        self.damage[user] = ""
        # 긚긡?긣궸빾돸궕궶궋뤾뜃
        unless @state_changed
          # ?긽?긙궸 "Miss" 귩먠믦
          self.damage[user] = "Miss"
        end
      end
    # ?긚궻뤾뜃
    else
      # ?긽?긙궸 "Miss" 귩먠믦
      self.damage[user] = "Miss"
    end
    # 먰벉뭷궳궶궋뤾뜃
    unless $game_temp.in_battle
      # ?긽?긙궸 nil 귩먠믦
      self.damage[user] = nil
    end
    # 긽?긞긤뢎뿹
    return effective
  end
  #--------------------------------------------------------------------------
  # 걶 귺귽긡?궻뚼됈밙뾭
  #    item : 귺귽긡?
  #--------------------------------------------------------------------------
  def item_effect(item, user = $game_party.actors[0])
    # 긏깏긡귻긇깑긲깋긐귩긏깏귺
    self.critical[user] = false
    state_p[user] = []
    state_m[user] = []
    self.recover_hp[user] = 0
    self.recover_sp[user] = 0
    # 귺귽긡?궻뚼됈붝댪궕 HP 1 댥뤵궻뼞뺴궳갂렔빁궻 HP 궕 0갂
    # 귏궫궼귺귽긡?궻뚼됈붝댪궕 HP 0 궻뼞뺴궳갂렔빁궻 HP 궕 1 댥뤵궻뤾뜃
    if ((item.scope == 3 or item.scope == 4) and self.hp == 0) or
      ((item.scope == 5 or item.scope == 6) and self.hp >= 1)
      # 긽?긞긤뢎뿹
      return false
    end
    # 뾎뚼긲깋긐귩긏깏귺
    effective = false
    # 긓긾깛귽긹깛긣 ID 궕뾎뚼궻뤾뜃궼뾎뚼긲깋긐귩긜긞긣
    effective |= item.common_event_id > 0
    # 뼺뭷뵽믦
    hit_result = (rand(100) < item.hit)
    # 븉둴렳궶긚긌깑궻뤾뜃궼뾎뚼긲깋긐귩긜긞긣
    effective |= item.hit < 100
    # 뼺뭷궻뤾뜃
    if hit_result == true
      # 됷븳쀊귩똶럁
      self.recover_hp[user] = maxhp * item.recover_hp_rate / 100 +
                              item.recover_hp
      self.recover_sp[user] = maxsp * item.recover_sp_rate / 100 +
                              item.recover_sp
      if self.recover_hp[user] < 0
        self.recover_hp[user] += self.pdef * item.pdef_f / 20
        self.recover_hp[user] += self.mdef * item.mdef_f / 20
        self.recover_hp[user] = [self.recover_hp[user], 0].min
      end
      # 뫌맜뢇맫
      self.recover_hp[user] *= elements_correct(item.element_set)
      self.recover_hp[user] /= 100
      self.recover_sp[user] *= elements_correct(item.element_set)
      self.recover_sp[user] /= 100
      # 빁랼
      if item.variance > 0 and self.recover_hp[user].abs > 0
        amp = [self.recover_hp[user].abs * item.variance / 100, 1].max
        self.recover_hp[user] += rand(amp+1) + rand(amp+1) - amp
      end
      if item.variance > 0 and self.recover_sp[user].abs > 0
        amp = [self.recover_sp[user].abs * item.variance / 100, 1].max
        self.recover_sp[user] += rand(amp+1) + rand(amp+1) - amp
      end
      # 됷븳쀊궻븘뜂궕븠궻뤾뜃
      if self.recover_hp[user] < 0
        # 뻞뚥뢇맫
        if self.guarding?
          self.recover_hp[user] /= 2
        end
      end
      # HP 됷븳쀊궻븘뜂귩뵿?궢갂?긽?긙궻뭠궸먠믦
      self.damage[user] = -self.recover_hp[user]
      # HP 궓귝귂 SP 궻빾벍뵽믦
      last_hp = [[self.hp + self.recover_hp[user], self.maxhp].min, 0].max
      last_sp = [[self.sp + self.recover_sp[user], self.maxsp].min, 0].max
      effective |= self.hp != last_hp
      effective |= self.sp != last_sp
      # 긚긡?긣빾돸
      @state_changed = false
      effective |= states_plus(user, item.plus_state_set)
      effective |= states_minus(user, item.minus_state_set)
      unless $game_temp.in_battle
        self.damage_effect(user, 2)
      end
      # 긬깋긽??뤵뤈뭠궕뾎뚼궻뤾뜃
      if item.parameter_type > 0 and item.parameter_points != 0
        # 긬깋긽??궳빁딌
        case item.parameter_type
        when 1  # MaxHP
          @maxhp_plus += item.parameter_points
        when 2  # MaxSP
          @maxsp_plus += item.parameter_points
        when 3  # 쁱쀍
          @str_plus += item.parameter_points
        when 4  # 딇뾭궠
          @dex_plus += item.parameter_points
        when 5  # f몓궠
          @agi_plus += item.parameter_points
        when 6  # 뻷쀍
          @int_plus += item.parameter_points
        end
        # 뾎뚼긲깋긐귩긜긞긣
        effective = true
      end
      # HP 됷븳뿦궴됷븳쀊궕 0 궻뤾뜃
      if item.recover_hp_rate == 0 and item.recover_hp == 0
        # ?긽?긙궸뗴빒럻쀱귩먠믦
        self.damage[user] = ""
        # SP 됷븳뿦궴됷븳쀊궕 0갂긬깋긽??뤵뤈뭠궕뼰뚼궻뤾뜃
        if item.recover_sp_rate == 0 and item.recover_sp == 0 and
          (item.parameter_type == 0 or item.parameter_points == 0)
          # 긚긡?긣궸빾돸궕궶궋뤾뜃
          unless @state_changed
            # ?긽?긙궸 "Miss" 귩먠믦
            self.damage[user] = "Miss"
          end
        end
      end
    # ?긚궻뤾뜃
    else
      # ?긽?긙궸 "Miss" 귩먠믦
      self.damage[user] = "Miss"
    end
    # 먰벉뭷궳궶궋뤾뜃
    unless $game_temp.in_battle
      # ?긽?긙궸 nil 귩먠믦
      self.damage[user] = nil
    end
    # 긽?긞긤뢎뿹
    return effective
  end
  #--------------------------------------------------------------------------
  # 걶 긚긡?긣빾돸 (+) 궻밙뾭
  #    plus_state_set  : 긚긡?긣빾돸 (+)
  #--------------------------------------------------------------------------
  def states_plus(battler, plus_state_set)
    # 뾎뚼긲깋긐귩긏깏귺
    effective = false
    # 깑?긵 (븊돿궥귡긚긡?긣)
    for i in plus_state_set
      # 궞궻긚긡?긣궕뻞뚥궠귢궲궋궶궋뤾뜃
      unless self.state_guard?(i)
        # 궞궻긚긡?긣궕긲깑궳궶궚귢궽뾎뚼긲깋긐귩긜긞긣
        effective |= self.state_full?(i) == false
        # 긚긡?긣궕 [믭뛕궢궶궋] 궻뤾뜃
        if $data_states[i].nonresistance
          # 긚긡?긣빾돸긲깋긐귩긜긞긣
          @state_changed = true
          # 긚긡?긣귩븊돿
          add_state(i)
        # 궞궻긚긡?긣궕긲깑궳궼궶궋뤾뜃
        elsif self.state_full?(i) == false
          # 긚긡?긣뾎뚼뱗귩둴뿦궸빾듂궢갂뿉릶궴붶둹
          if rand(100) < [0,100,80,60,40,20,0][self.state_ranks[i]]
            # 긚긡?긣빾돸긲깋긐귩긜긞긣
            @state_changed = true
            # 긚긡?긣귩븊돿
            self.state_p[battler].push(i)
          end
        end
      end
    end
    # 긽?긞긤뢎뿹
    return effective
  end
  #--------------------------------------------------------------------------
  # 걶 긚긡?긣빾돸 (-) 궻밙뾭
  #    minus_state_set : 긚긡?긣빾돸 (-)
  #--------------------------------------------------------------------------
  def states_minus(battler, minus_state_set)
    # 뾎뚼긲깋긐귩긏깏귺
    effective = false
    # 깑?긵 (됶룣궥귡긚긡?긣)
    for i in minus_state_set
      # 궞궻긚긡?긣궕븊돿궠귢궲궋귢궽뾎뚼긲깋긐귩긜긞긣
      effective |= self.state?(i)
      # 긚긡?긣빾돸긲깋긐귩긜긞긣
      @state_changed = true
      # 긚긡?긣귩됶룣
      self.state_m[battler].push(i)
    end
    # 긽?긞긤뢎뿹
    return effective
  end
  #--------------------------------------------------------------------------
  # 걶 ?긽?긙뎶럁
  #--------------------------------------------------------------------------
  def damage_effect(battler, item)
    if item == 2
      self.hp += self.recover_hp[battler]
      self.sp += self.recover_sp[battler]
      if self.recover_sp[battler] != 0
        self.damage_sp[battler] = -self.recover_sp[battler]
      end
      self.recover_hp.delete(battler)
      self.recover_sp.delete(battler)
    else
      if self.damage[battler].class != String
        self.hp -= self.damage[battler]
      end
    end
    for i in self.state_p[battler]
      add_state(i)
    end
    for i in self.state_m[battler]
      remove_state(i)
    end
  end
  #--------------------------------------------------------------------------
  # 걶 긚깏긞긵?긽?긙궻뚼됈밙뾭
  #--------------------------------------------------------------------------
  def slip_damage_effect
    # ?긽?긙귩먠믦
    self.damage["slip"] = self.maxhp / 10
    # 빁랼
    if self.damage["slip"].abs > 0
      amp = [self.damage["slip"].abs * 15 / 100, 1].max
      self.damage["slip"] += rand(amp+1) + rand(amp+1) - amp
    end
    # HP 궔귞?긽?긙귩뙵럁
    self.hp -= self.damage["slip"]
    # 긽?긞긤뢎뿹
    return true
  end
end

#==============================================================================
# 걾 Game_BattleAction
#------------------------------------------------------------------------------
# ?귺긏긘깈깛 (먰벉뭷궻뛱벍) 귩댌궎긏깋긚궳궥갃궞궻긏깋긚궼 Game_Battler 긏깋
# 긚궻볙븫궳럊뾭궠귢귏궥갃
#==============================================================================

class Game_BattleAction
  #--------------------------------------------------------------------------
  # 걶 뚺둎귽깛긚?깛긚빾릶
  #--------------------------------------------------------------------------
  attr_accessor :spell_id                # 뜃뫬뻷?뾭긚긌깑 ID
  attr_accessor :force_kind              # 롰빶 (딈? / 긚긌깑 / 귺귽긡?)
  attr_accessor :force_basic              # 딈? (뛘똼 / 뻞뚥 / 벀궛귡)
  attr_accessor :force_skill_id          # 긚긌깑 ID
  #--------------------------------------------------------------------------
  # 걶 뾎뚼뵽믦
  #--------------------------------------------------------------------------
  def valid?
    return (not (@force_kind == 0 and @force_basic == 3))
  end
end

#==============================================================================
# 걾 Game_Actor
#------------------------------------------------------------------------------
# ?귺긏??귩댌궎긏깋긚궳궥갃궞궻긏깋긚궼 Game_Actors 긏깋긚 ($game_actors)
# 궻볙븫궳럊뾭궠귢갂Game_Party 긏깋긚 ($game_party) 궔귞귖랷뤖궠귢귏궥갃
#==============================================================================

class Game_Actor < Game_Battler
  def skill_can_use?(skill_id)
    return super
  end
end

#==============================================================================
# 걾 Game_Enemy
#------------------------------------------------------------------------------
# ?긄긨??귩댌궎긏깋긚궳궥갃궞궻긏깋긚궼 Game_Troop 긏깋긚 ($game_troop) 궻
# 볙븫궳럊뾭궠귢귏궥갃
#==============================================================================

class Game_Enemy < Game_Battler
  #--------------------------------------------------------------------------
  # 걶 뚺둎귽깛긚?깛긚빾릶
  #--------------------------------------------------------------------------
  attr_accessor :height                  # 됪몴궻뛼궠
  attr_accessor :real_x                  # X띆뷭뺚맫
  attr_accessor :real_y                  # Y띆뷭뺚맫
  attr_accessor :real_zoom              # 둮묈뿦
  #--------------------------------------------------------------------------
  # 걶 긆긳긙긃긏긣룊딖돸
  #    troop_id    : 긣깑?긵 ID
  #    member_index : 긣깑?긵긽깛긫?궻귽깛긢긞긏긚
  #--------------------------------------------------------------------------
  def initialize(troop_id, member_index)
    super()
    @troop_id = troop_id
    @member_index = member_index
    troop = $data_troops[@troop_id]
    @enemy_id = troop.members[@member_index].enemy_id
    enemy = $data_enemies[@enemy_id]
    @battler_name = enemy.battler_name
    @battler_hue = enemy.battler_hue
    @hp = maxhp
    @sp = maxsp
    @real_x = 0
    @real_y = 0
    @real_zoom = 1.0
    @fly = 0
    enemy.name.sub(/\[Ff][([0-9]+)]/) {@fly = $1.to_i}
    @hidden = troop.members[@member_index].hidden
    @immortal = troop.members[@member_index].immortal
  end
  alias :true_x :screen_x
  alias :true_y :screen_y
  #--------------------------------------------------------------------------
  # 걶 긫긣깑됪뽋 X 띆뷭궻롦벦
  #--------------------------------------------------------------------------
  def screen_x
    return 320 + (true_x - 320) * @real_zoom + @real_x
  end
  #--------------------------------------------------------------------------
  # 걶 긫긣깑됪뽋 Y 띆뷭궻롦벦
  #--------------------------------------------------------------------------
  def screen_y
    return true_y * @real_zoom + @real_y
  end
  #--------------------------------------------------------------------------
  # 걶 긫긣깑됪뽋 Z 띆뷭궻롦벦
  #--------------------------------------------------------------------------
  def screen_z
    return true_y + @fly
  end
  #--------------------------------------------------------------------------
  # 걶 긫긣깑됪뽋 둮묈뿦궻롦벦
  #--------------------------------------------------------------------------
  def zoom
    return ($scene.zoom_rate[1] - $scene.zoom_rate[0]) *
                          (true_y + @fly) / 320 + $scene.zoom_rate[0]
  end
  #--------------------------------------------------------------------------
  # 걶 뛘똼뾭갂긫긣깑됪뽋 X 띆뷭궻롦벦
  #--------------------------------------------------------------------------
  def attack_x(z)
    return (320 - true_x) * z * 0.75
  end
  #--------------------------------------------------------------------------
  # 걶 뛘똼뾭갂긫긣깑됪뽋 Y 띆뷭궻롦벦
  #--------------------------------------------------------------------------
  def attack_y(z)
    return (160 - (true_y + @fly / 4) * z + @height * zoom * z / 2) * 0.75
  end
  #--------------------------------------------------------------------------
  # 걶 귺긏긘깈깛띿맟
  #--------------------------------------------------------------------------
  def make_action
    # 긇깒깛긣귺긏긘깈깛귩긏깏귺
    self.current_action.clear
    # 벍궚궶궋뤾뜃
    unless self.inputable?
      # 긽?긞긤뢎뿹
      return
    end
    # 뙸띪뾎뚼궶귺긏긘깈깛귩뭻뢯
    available_actions = []
    rating_max = 0
    for action in self.actions
      # ??깛 륆뙊둴봃
      n = $game_temp.battle_turn
      a = action.condition_turn_a
      b = action.condition_turn_b
      if (b == 0 and n != a) or
        (b > 0 and (n < 1 or n < a or n % b != a % b))
        next
      end
      # HP 륆뙊둴봃
      if self.hp * 100.0 / self.maxhp > action.condition_hp
        next
      end
      # 깒긹깑 륆뙊둴봃
      if $game_party.max_level < action.condition_level
        next
      end
      # 긚귽긞? 륆뙊둴봃
      switch_id = action.condition_switch_id
      if switch_id > 0 and $game_switches[switch_id] == false
        next
      end
      # 긚긌깑럊뾭됀? 륆뙊둴봃
      if action.kind == 1
        unless self.skill_can_use?(action.skill_id)
          next
        end
      end
      # 륆뙊궸둤뱰 : 궞궻귺긏긘깈깛귩믁돿
      available_actions.push(action)
      if action.rating > rating_max
        rating_max = action.rating
      end
    end
    # 띍묈궻깒?긡귻깛긐뭠귩 3 궴궢궲뜃똶귩똶럁 (0 댥돷궼룣둖)
    ratings_total = 0
    for action in available_actions
      if action.rating > rating_max - 3
        ratings_total += action.rating - (rating_max - 3)
      end
    end
    # 깒?긡귻깛긐궻뜃똶궕 0 궳궼궶궋뤾뜃
    if ratings_total > 0
      # 뿉릶귩띿맟
      value = rand(ratings_total)
      # 띿맟궢궫뿉릶궸뫮돒궥귡귖궻귩긇깒깛긣귺긏긘깈깛궸먠믦
      for action in available_actions
        if action.rating > rating_max - 3
          if value < action.rating - (rating_max - 3)
            self.current_action.kind = action.kind
            self.current_action.basic = action.basic
            self.current_action.skill_id = action.skill_id
            self.current_action.decide_random_target_for_enemy
            return
          else
            value -= action.rating - (rating_max - 3)
          end
        end
      end
    end
  end
end

#==============================================================================
# 걾 Game_Party
#------------------------------------------------------------------------------
# ?긬?긡귻귩댌궎긏깋긚궳궥갃긕?깑긤귘귺귽긡?궶궵궻륃뺪궕듵귏귢귏궥갃궞궻긏
# 깋긚궻귽깛긚?깛긚궼 $game_party 궳랷뤖궠귢귏궥갃
#==============================================================================

class Game_Party
  #--------------------------------------------------------------------------
  # 걶 멣뽅뵽믦
  #--------------------------------------------------------------------------
  def all_dead?
    # 긬?긡귻릐릶궕 0 릐궻뤾뜃
    if $game_party.actors.size == 0
      return false
    end
    # HP 0 댥뤵궻귺긏??궕긬?긡귻궸궋귡뤾뜃
    for actor in @actors
      if actor.hp > 0 or actor.damage.size > 0
        return false
      end
    end
    # 멣뽅
    return true
  end
end

#==============================================================================
# 걾 Sprite_Battler
#------------------------------------------------------------------------------
# ?긫긣깋??렑뾭궻긚긵깋귽긣궳궥갃Game_Battler 긏깋긚궻귽깛긚?깛긚귩듒럨궢갂
# 긚긵깋귽긣궻륉뫴귩렔벍밒궸빾돸궠궧귏궥갃
#==============================================================================

class Sprite_Battler < RPG::Sprite
  #--------------------------------------------------------------------------
  # 걶 긲깒??뛛륷
  #--------------------------------------------------------------------------
  def update
    super
    # 긫긣깋?궕 nil 궻뤾뜃
    if @battler == nil
      self.bitmap = nil
      loop_animation(nil)
      return
    end
    # 긲?귽깑뼹궔륡몜궕뙸띪궻귖궻궴댶궶귡뤾뜃
    if @battler.battler_name != @battler_name or
      @battler.battler_hue != @battler_hue
      # 긮긞긣?긞긵귩롦벦갂먠믦
      @battler_name = @battler.battler_name
      @battler_hue = @battler.battler_hue
      self.bitmap = RPG::Cache.battler(@battler_name, @battler_hue)
      @width = bitmap.width
      @height = bitmap.height
      self.ox = @width / 2
      self.oy = @height
      if @battler.is_a?(Game_Enemy)
        @battler.height = @height
      end
      # 먰벉븉?귏궫궼덨귢륉뫴궶귞븉벁뼻뱗귩 0 궸궥귡
      if @battler.dead? or @battler.hidden
        self.opacity = 0
      end
    end
    # 귺긦긽?긘깈깛 ID 궕뙸띪궻귖궻궴댶궶귡뤾뜃
    if @battler.state_animation_id != @state_animation_id
      @state_animation_id = @battler.state_animation_id
      loop_animation($data_animations[@state_animation_id])
    end
    # ?렑궠귢귡귊궖귺긏??궻뤾뜃
    if @battler.is_a?(Game_Actor) and @battler_visible
      # 긽귽깛긲긃?긛궳궶궋궴궖궼븉벁뼻뱗귩귘귘돷궛귡
      if $game_temp.battle_main_phase
        self.opacity += 3 if self.opacity < 255
      else
        self.opacity -= 3 if self.opacity > 207
      end
    end
    # 뼻뽅
    if @battler.blink
      blink_on
    else
      blink_off
    end
    # 븉됀럨궻뤾뜃
    unless @battler_visible
      # 뢯뙸
      if not @battler.hidden and not @battler.dead? and
        (@battler.damage.size < 2 or @battler.damage_pop.size < 2)
        appear
        @battler_visible = true
      end
    end
    # ?긽?긙
    for battler in @battler.damage_pop
      if battler[0].class == Array
        if battler[0][1] >= 0
          $scene.skill_se
        else
          $scene.levelup_se
        end
        damage(@battler.damage[battler[0]], false, 2)
      else
        damage(@battler.damage[battler[0]], @battler.critical[battler[0]])
      end
      if @battler.damage_sp.include?(battler[0])
        damage(@battler.damage_sp[battler[0]],
                @battler.critical[battler[0]], 1)
        @battler.damage_sp.delete(battler[0])
      end
      @battler.damage_pop.delete(battler[0])
      @battler.damage.delete(battler[0])
      @battler.critical.delete(battler[0])
    end
    # 됀럨궻뤾뜃
    if @battler_visible
      # 벀몪
      if @battler.hidden
        $game_system.se_play($data_system.escape_se)
        escape
        @battler_visible = false
      end
      # 뵏긲깋긞긘깄
      if @battler.white_flash
        whiten
        @battler.white_flash = false
      end
      # 귺긦긽?긘깈깛
      unless @battler.animation.empty?
        for animation in @battler.animation.reverse
          animation($data_animations[animation[0]], animation[1])
          @battler.animation.delete(animation)
        end
      end
      # 긓깋긵긚
      if @battler.damage.empty? and @battler.dead?
        if $scene.dead_ok?(@battler)
          if @battler.is_a?(Game_Enemy)
            $game_system.se_play($data_system.enemy_collapse_se)
          else
            $game_system.se_play($data_system.actor_collapse_se)
          end
          collapse
          @battler_visible = false
        end
      end
    end
    # 긚긵깋귽긣궻띆뷭귩먠믦
    self.x = @battler.screen_x
    self.y = @battler.screen_y
    self.z = @battler.screen_z
    if @battler.is_a?(Game_Enemy)
      self.zoom_x = @battler.real_zoom * @battler.zoom
      self.zoom_y = @battler.real_zoom * @battler.zoom
    end
  end
end

#==============================================================================
# 걾 Window_Base
#------------------------------------------------------------------------------
# ?긒??뭷궻궥귊궲궻긂귻깛긤긂궻긚?긬?긏깋긚궳궥갃
#==============================================================================

class Window_Base < Window
  #--------------------------------------------------------------------------
  # 걶 긒?긙궻?됪
  #--------------------------------------------------------------------------
  def gauge_rect_at(width, height, align3,
                    color1, color2, color3, color4, color5, color6, color7,
                    color8, color9, color10, color11, color12, grade1, grade2)
    # 쁤?됪
    @at_gauge = Bitmap.new(width, height * 5)
    @at_gauge.fill_rect(0, 0, width, height, color1)
    @at_gauge.fill_rect(1, 1, width - 2, height - 2, color2)
    if (align3 == 1 and grade1 == 0) or grade1 > 0
      color = color3
      color3 = color4
      color4 = color
    end
    if (align3 == 1 and grade2 == 0) or grade2 > 0
      color = color5
      color5 = color6
      color6 = color
      color = color7
      color7 = color8
      color8 = color
      color = color9
      color9 = color10
      color10 = color
      color = color11
      color11 = color12
      color12 = color
    end
    if align3 == 0
      if grade1 == 2
        grade1 = 3
      end
      if grade2 == 2
        grade2 = 3
      end
    end
    # 뗴긒?긙궻?됪 뢢궸긐깋긢?긘깈깛?렑
    @at_gauge.gradation_rect(2, 2, width - 4, height - 4,
                                  color3, color4, grade1)
    # 렳긒?긙궻?됪
    @at_gauge.gradation_rect(2, height + 2, width- 4, height - 4,
                                  color5, color6, grade2)
    @at_gauge.gradation_rect(2, height * 2 + 2, width- 4, height - 4,
                                  color7, color8, grade2)
    @at_gauge.gradation_rect(2, height * 3 + 2, width- 4, height - 4,
                                  color9, color10, grade2)
    @at_gauge.gradation_rect(2, height * 4 + 2, width- 4, height - 4,
                                  color11, color12, grade2)
  end
end

#==============================================================================
# 걾 Window_Help
#------------------------------------------------------------------------------
# ?긚긌깑귘귺귽긡?궻먣뼻갂귺긏??궻긚긡??긚궶궵귩?렑궥귡긂귻깛긤긂궳궥갃
#==============================================================================

class Window_Help < Window_Base
  #--------------------------------------------------------------------------
  # 걶 긄긨??먠믦
  #    enemy : 뼹멟궴긚긡?긣귩?렑궥귡긄긨??
  #--------------------------------------------------------------------------
  def set_enemy(enemy)
    text = enemy.name.sub(/\[Ff][([0-9]+)]/) {""}
    state_text = make_battler_state_text(enemy, 112, false)
    if state_text != ""
      text += "  " + state_text
    end
    set_text(text, 1)
  end
end

#==============================================================================
# 걾 Window_BattleStatus
#------------------------------------------------------------------------------
# ?긫긣깑됪뽋궳긬?긡귻긽깛긫?궻긚긡??긚귩?렑궥귡긂귻깛긤긂궳궥갃
#==============================================================================

class Window_BattleStatus < Window_Base
  #--------------------------------------------------------------------------
  # 걶 긆긳긙긃긏긣룊딖돸
  #--------------------------------------------------------------------------
  def initialize
    x = (4 - $game_party.actors.size) * 80
    width = $game_party.actors.size * 160
    super(x, 320, width, 160)
    self.back_opacity = 160
    @actor_window = []
    for i in 0...$game_party.actors.size
      @actor_window.push(Window_ActorStatus.new(i, x + i * 160))
    end
    @level_up_flags = [false, false, false, false]
    refresh
  end
  #--------------------------------------------------------------------------
  # 걶 됶뺳
  #--------------------------------------------------------------------------
  def dispose
    for window in @actor_window
      window.dispose
    end
    super
  end
  #--------------------------------------------------------------------------
  # 걶 깏긲깒긞긘깄
  #--------------------------------------------------------------------------
  def refresh(number = 0)
    if number == 0
      cnt = 0
      for window in @actor_window
        window.refresh(@level_up_flags[cnt])
        cnt += 1
      end
    else
      @actor_window[number - 1].refresh(@level_up_flags[number - 1])
    end
  end
  #--------------------------------------------------------------------------
  # 걶 AT긒?긙깏긲깒긞긘깄
  #--------------------------------------------------------------------------
  def at_refresh(number = 0)
    if number == 0
      for window in @actor_window
        window.at_refresh
      end
    else
      @actor_window[number - 1].at_refresh
    end
  end
  #--------------------------------------------------------------------------
  # 걶 긲깒??뛛륷
  #--------------------------------------------------------------------------
  def update
    super
    if self.x != (4 - $game_party.actors.size) * 80
      self.x = (4 - $game_party.actors.size) * 80
      self.width = $game_party.actors.size * 160
      for window in @actor_window
        window.dispose
      end
      @actor_window = []
      for i in 0...$game_party.actors.size
        @actor_window.push(Window_ActorStatus.new(i, x + i * 160))
      end
      refresh
    end
    for window in @actor_window
      window.update
    end
  end
end

#==============================================================================
# 걾 Window_ActorStatus
#------------------------------------------------------------------------------
# ?긫긣깑됪뽋궳긬?긡귻긽깛긫?궻긚긡??긚귩궩귢궪귢?렑궥귡긂귻깛긤긂궳궥갃
#==============================================================================

class Window_ActorStatus < Window_Base
  #--------------------------------------------------------------------------
  # 걶 긆긳긙긃긏긣룊딖돸
  #--------------------------------------------------------------------------
  def initialize(id, x)
    @actor_num = id
    super(x, 320, 160, 160)
    self.contents = Bitmap.new(width - 32, height - 32)
    self.opacity = 0
    self.back_opacity = 0
    actor = $game_party.actors[@actor_num]
    @actor_nm = actor.name
    @actor_mhp = actor.maxhp
    @actor_msp = actor.maxsp
    @actor_hp = actor.hp
    @actor_sp = actor.sp
    @actor_st = make_battler_state_text(actor, 120, true)
    @status_window = []
    for i in 0...5
      @status_window.push(Window_DetailsStatus.new(actor, i, x))
    end
    refresh(false)
  end
  #--------------------------------------------------------------------------
  # 걶 됶뺳
  #--------------------------------------------------------------------------
  def dispose
    for i in 0...5
      @status_window[i].dispose
    end
    super
  end
  #--------------------------------------------------------------------------
  # 걶 깏긲깒긞긘깄
  #--------------------------------------------------------------------------
  def refresh(level_up_flags)
    self.contents.clear
    actor = $game_party.actors[@actor_num]
    @status_window[0].refresh(actor) if @actor_nm != actor.name
    @status_window[1].refresh(actor) if
      @actor_mhp != actor.maxhp or @actor_hp != actor.hp
    @status_window[2].refresh(actor) if
      @actor_msp != actor.maxsp or @actor_sp != actor.sp
    @status_window[3].refresh(actor, level_up_flags) if
      @actor_st != make_battler_state_text(actor, 120, true) or level_up_flags
    @actor_nm = actor.name
    @actor_mhp = actor.maxhp
    @actor_msp = actor.maxsp
    @actor_hp = actor.hp
    @actor_sp = actor.sp
    @actor_st = make_battler_state_text(actor, 120, true)
  end
  #--------------------------------------------------------------------------
  # 걶 AT긒?긙깏긲깒긞긘깄
  #--------------------------------------------------------------------------
  def at_refresh
    @status_window[4].refresh($game_party.actors[@actor_num])
  end
  #--------------------------------------------------------------------------
  # 걶 긲깒??뛛륷
  #--------------------------------------------------------------------------
  def update
    for window in @status_window
      window.update
    end
  end
end

#==============================================================================
# 걾 Window_DetailsStatus
#------------------------------------------------------------------------------
# ?긫긣깑됪뽋궳귺긏??궻긚긡??긚귩뙿갲궸?렑궥귡긂귻깛긤긂궳궥갃
#==============================================================================

class Window_DetailsStatus < Window_Base
  #--------------------------------------------------------------------------
  # 걶 긆ᅫ
무조건동의 06-05-21 18:37
  def initialize(actor, id, x)
    @status_id = id
    super(x, 320 + id * 26, 160, 64)
    self.contents = Bitmap.new(width - 32, height - 32)
    self.opacity = 0
    self.back_opacity = 0
    refresh(actor, false)
  end
  #--------------------------------------------------------------------------
  # 걶 됶뺳
  #--------------------------------------------------------------------------
  def dispose
    super
  end
  #--------------------------------------------------------------------------
  # 걶 깏긲깒긞긘깄
  #--------------------------------------------------------------------------
  def refresh(actor, level_up_flags = false)
    self.contents.clear
    case @status_id
    when 0
      draw_actor_name(actor, 4, 0)
    when 1
      draw_actor_hp(actor, 4, 0, 120)
    when 2
      draw_actor_sp(actor, 4, 0, 120)
    when 3
      if level_up_flags
        self.contents.font.color = normal_color
        self.contents.draw_text(4, 0, 120, 32, "LEVEL UP!")
      else
        draw_actor_state(actor, 4, 0)
      end
    when 4
      draw_actor_atg(actor, 4, 0, 120)
    end
  end
  #--------------------------------------------------------------------------
  # 걶 긲깒??뛛륷
  #--------------------------------------------------------------------------
  def update
    # 긽귽깛긲긃?긛궻궴궖궼븉벁뼻뱗귩귘귘돷궛귡
    if $game_temp.battle_main_phase
      self.contents_opacity -= 4 if self.contents_opacity > 191
    else
      self.contents_opacity += 4 if self.contents_opacity < 255
    end
  end
end

#==============================================================================
# 걾 Arrow_Base
#------------------------------------------------------------------------------
# ?긫긣깑됪뽋궳럊뾭궥귡귺깓?긇??깑?렑뾭궻긚긵깋귽긣궳궥갃궞궻긏깋긚궼
# Arrow_Enemy 긏깋긚궴 Arrow_Actor 긏깋긚궻긚?긬?긏깋긚궴궢궲럊뾭궠귢귏궥갃
#==============================================================================

class Arrow_Base < Sprite
  #--------------------------------------------------------------------------
  # 걶 긆긳긙긃긏긣룊딖돸
  #    viewport : 긮깄???긣
  #--------------------------------------------------------------------------
  def initialize(viewport)
    super(viewport)
    self.bitmap = RPG::Cache.windowskin($game_system.windowskin_name)
    self.ox = 16
    self.oy = 32
    self.z = 2500
    @blink_count = 0
    @index = 0
    @help_window = nil
    update
  end
end

#==============================================================================
# 걾 Arrow_Enemy
#------------------------------------------------------------------------------
# ?긄긨??귩멗묖궠궧귡궫귕궻귺깓?긇??깑궳궥갃궞궻긏깋긚궼 Arrow_Base 긏깋
# 긚귩똯뤂궢귏궥갃
#==============================================================================

class Arrow_Enemy < Arrow_Base
  #--------------------------------------------------------------------------
  # 걶 긲깒??뛛륷
  #--------------------------------------------------------------------------
  def update
    super
    # 뫔띪궢궶궋긄긨??귩럚궢궲궋궫귞뷅궽궥
    $game_troop.enemies.size.times do
      break if self.enemy.exist?
      @index += 1
      @index %= $game_troop.enemies.size
    end
    # 긇??깑덭
    if Input.repeat?(Input::RIGHT)
      $game_system.se_play($data_system.cursor_se)
      $game_troop.enemies.size.times do
        @index += 1
        @index %= $game_troop.enemies.size
        break if self.enemy.exist?
      end
      $scene.camera = "select"
      zoom = 1 / self.enemy.zoom
      $scene.spriteset.screen_target(self.enemy.attack_x(zoom) * 0.75,
                                      self.enemy.attack_y(zoom) * 0.75, zoom)
    end
    # 긇??깑뜺
    if Input.repeat?(Input::LEFT)
      $game_system.se_play($data_system.cursor_se)
      $game_troop.enemies.size.times do
        @index += $game_troop.enemies.size - 1
        @index %= $game_troop.enemies.size
        break if self.enemy.exist?
      end
      $scene.camera = "select"
      zoom = 1 / self.enemy.zoom
      $scene.spriteset.screen_target(self.enemy.attack_x(zoom) * 0.75,
                                      self.enemy.attack_y(zoom) * 0.75, zoom)
    end
    # 긚긵깋귽긣궻띆뷭귩먠믦
    if self.enemy != nil
      self.x = self.enemy.screen_x
      self.y = self.enemy.screen_y
    end
  end
end

#==============================================================================
# 걾 Interpreter
#------------------------------------------------------------------------------
# ?귽긹깛긣긓?깛긤귩렳뛱궥귡귽깛?긵깏?궳궥갃궞궻긏깋긚궼 Game_System 긏깋
# 긚귘 Game_Event 긏깋긚궻볙븫궳럊뾭궠귢귏궥갃
#==============================================================================

class Interpreter
  #--------------------------------------------------------------------------
  # 걶 귺긏??궻볺귢뫶궑
  #--------------------------------------------------------------------------
  def command_129
    # 귺긏??귩롦벦
    actor = $game_actors[@parameters[0]]
    # 귺긏??궕뾎뚼궻뤾뜃
    if actor != nil
      # ?띿궳빁딌
      if @parameters[1] == 0
        if @parameters[2] == 1
          $game_actors[@parameters[0]].setup(@parameters[0])
        end
        $game_party.add_actor(@parameters[0])
        if $game_temp.in_battle
          $game_actors[@parameters[0]].at = 0
          $game_actors[@parameters[0]].atp = 0
          $scene.spell_reset($game_actors[@parameters[0]])
          $game_actors[@parameters[0]].damage_pop = {}
          $game_actors[@parameters[0]].damage = {}
          $game_actors[@parameters[0]].damage_sp = {}
          $game_actors[@parameters[0]].critical = {}
          $game_actors[@parameters[0]].recover_hp = {}
          $game_actors[@parameters[0]].recover_sp = {}
          $game_actors[@parameters[0]].state_p = {}
          $game_actors[@parameters[0]].state_m = {}
          $game_actors[@parameters[0]].animation = []
        end
      else
        $game_party.remove_actor(@parameters[0])
      end
    end
    if $game_temp.in_battle
      $scene.status_window.update
    end
    # 똯뫏
    return true
  end
  #--------------------------------------------------------------------------
  # 걶 HP 궻몵뙵
  #--------------------------------------------------------------------------
  alias :command_311_rtab :command_311
  def command_311
    command_311_rtab
    if $game_temp.in_battle
      $scene.status_window.refresh
    end
  end
  #--------------------------------------------------------------------------
  # 걶 SP 궻몵뙵
  #--------------------------------------------------------------------------
  alias :command_312_rtab :command_312
  def command_312
    command_312_rtab
    if $game_temp.in_battle
      $scene.status_window.refresh
    end
  end
  #--------------------------------------------------------------------------
  # 걶 긚긡?긣궻빾뛛
  #--------------------------------------------------------------------------
  alias :command_313_rtab :command_313
  def command_313
    command_313_rtab
    if $game_temp.in_battle
      $scene.status_window.refresh
    end
  end
  #--------------------------------------------------------------------------
  # 걶 멣됷븳
  #--------------------------------------------------------------------------
  alias :command_314_rtab :command_314
  def command_314
    command_314_rtab
    if $game_temp.in_battle
      $scene.status_window.refresh
    end
  end
  #--------------------------------------------------------------------------
  # 걶 EXP 궻몵뙵
  #--------------------------------------------------------------------------
  alias :command_315_rtab :command_315
  def command_315
    command_315_rtab
    if $game_temp.in_battle
      $scene.status_window.refresh
    end
  end
  #--------------------------------------------------------------------------
  # 걶 깒긹깑궻몵뙵
  #--------------------------------------------------------------------------
  alias :command_316_rtab :command_316
  def command_316
    command_316_rtab
    if $game_temp.in_battle
      $scene.status_window.refresh
    end
  end
  #--------------------------------------------------------------------------
  # 걶 긬깋긽??궻몵뙵
  #--------------------------------------------------------------------------
  alias :command_317_rtab :command_317
  def command_317
    command_317_rtab
    if $game_temp.in_battle
      $scene.status_window.refresh
    end
  end
  #--------------------------------------------------------------------------
  # 걶 몧뷈궻빾뛛
  #--------------------------------------------------------------------------
  alias :command_319_rtab :command_319
  def command_319
    command_319_rtab
    if $game_temp.in_battle
      $scene.status_window.refresh
    end
  end
  #--------------------------------------------------------------------------
  # 걶 귺긏??궻뼹멟빾뛛
  #--------------------------------------------------------------------------
  alias :command_320_rtab :command_320
  def command_320
    command_320_rtab
    if $game_temp.in_battle
      $scene.status_window.refresh
    end
  end
  #--------------------------------------------------------------------------
  # 걶 귺긏??궻긏깋긚빾뛛
  #--------------------------------------------------------------------------
  alias :command_321_rtab :command_321
  def command_321
    command_321_rtab
    if $game_temp.in_battle
      $scene.status_window.refresh
    end
  end
  #--------------------------------------------------------------------------
  # 걶 귺긦긽?긘깈깛궻?렑
  #--------------------------------------------------------------------------
  def command_337
    # 귽긡깒??궳룉뿚
    iterate_battler(@parameters[0], @parameters[1]) do |battler|
      # 긫긣깋?궕뫔띪궥귡뤾뜃
      if battler.exist?
        # 귺긦긽?긘깈깛 ID 귩먠믦
        battler.animation.push([@parameters[2], true])
      end
    end
    # 똯뫏
    return true
  end
  #--------------------------------------------------------------------------
  # 걶 ?긽?긙궻룉뿚
  #--------------------------------------------------------------------------
  def command_338
    # ?띿궥귡뭠귩롦벦
    value = operate_value(0, @parameters[2], @parameters[3])
    # 귽긡깒??궳룉뿚
    iterate_battler(@parameters[0], @parameters[1]) do |battler|
      # 긫긣깋?궕뫔띪궥귡뤾뜃
      if battler.exist?
        # HP 귩빾뛛
        battler.hp -= value
        # 먰벉뭷궶귞
        if $game_temp.in_battle
          # ?긽?긙귩먠믦
          battler.damage["event"] = value
          battler.damage_pop["event"] = true
        end
      end
    end
    if $game_temp.in_battle
      $scene.status_window.refresh
    end
    # 똯뫏
    return true
  end
  #--------------------------------------------------------------------------
  # 걶 귺긏긘깈깛궻떗맕
  #--------------------------------------------------------------------------
  def command_339
    # 먰벉뭷궳궶궚귢궽뼰럨
    unless $game_temp.in_battle
      return true
    end
    # ??깛릶궕 0 궶귞뼰럨
    if $game_temp.battle_turn == 0
      return true
    end
    # 귽긡깒??궳룉뿚 (뺇딿밒궶귖궻궳갂븸릶궸궶귡궞궴궼궶궋)
    iterate_battler(@parameters[0], @parameters[1]) do |battler|
      # 긫긣깋?궕뫔띪궥귡뤾뜃
      if battler.exist?
        # 귺긏긘깈깛귩먠믦
        battler.current_action.force_kind = @parameters[2]
        if battler.current_action.force_kind == 0
          battler.current_action.force_basic = @parameters[3]
        else
          battler.current_action.force_skill_id = @parameters[3]
        end
        # 뛱벍뫮뤭귩먠믦
        if @parameters[4] == -2
          if battler.is_a?(Game_Enemy)
            battler.current_action.decide_last_target_for_enemy
          else
            battler.current_action.decide_last_target_for_actor
          end
        elsif @parameters[4] == -1
          if battler.is_a?(Game_Enemy)
            battler.current_action.decide_random_target_for_enemy
          else
            battler.current_action.decide_random_target_for_actor
          end
        elsif @parameters[4] >= 0
          battler.current_action.target_index = @parameters[4]
        end
        # 귺긏긘깈깛궕뾎뚼궔궰 [궥궙궸렳뛱] 궻뤾뜃
        if battler.current_action.valid? and @parameters[5] == 1
          # 떗맕뫮뤭궻긫긣깋?귩먠믦
          $game_temp.forcing_battler = battler
          # 귽깛긢긞긏긚귩릋귕귡
          @index += 1
          # 뢎뿹
          return false
        elsif battler.current_action.valid? and @parameters[5] == 0
          battler.current_action.forcing = true
        end
      end
    end
    # 똯뫏
    return true
  end
end

#==============================================================================
# 걾 Sprite긾긙깄?깑
#------------------------------------------------------------------------------
# ?귺긦긽?긘깈깛궻듖뿚귩뛱궎긾긙깄?깑궳궥갃
#==============================================================================

module RPG
  class Sprite < ::Sprite
    def initialize(viewport = nil)
      super(viewport)
      @_whiten_duration = 0
      @_appear_duration = 0
      @_escape_duration = 0
      @_collapse_duration = 0
      @_damage = []
      @_animation = []
      @_animation_duration = 0
      @_blink = false
    end
    def damage(value, critical, type = 0)
      if value.is_a?(Numeric)
        damage_string = value.abs.to_s
      else
        damage_string = value.to_s
      end
      bitmap = Bitmap.new(160, 48)
      bitmap.font.name = "Arial Black"
      bitmap.font.size = 32
      bitmap.font.color.set(0, 0, 0)
      bitmap.draw_text(-1, 12-1, 160, 36, damage_string, 1)
      bitmap.draw_text(+1, 12-1, 160, 36, damage_string, 1)
      bitmap.draw_text(-1, 12+1, 160, 36, damage_string, 1)
      bitmap.draw_text(+1, 12+1, 160, 36, damage_string, 1)
      if value.is_a?(Numeric) and value < 0
        if type == 0
          bitmap.font.color.set(176, 255, 144)
        else
          bitmap.font.color.set(176, 144, 255)
        end
      else
        if type == 0
          bitmap.font.color.set(255, 255, 255)
        else
          bitmap.font.color.set(255, 176, 144)
        end
      end
      if type == 2
        bitmap.font.color.set(255, 224, 128)
      end
      bitmap.draw_text(0, 12, 160, 36, damage_string, 1)
      if critical
        string = "CRITICAL"
        bitmap.font.size = 20
        bitmap.font.color.set(0, 0, 0)
        bitmap.draw_text(-1, -1, 160, 20, string, 1)
        bitmap.draw_text(+1, -1, 160, 20, string, 1)
        bitmap.draw_text(-1, +1, 160, 20, string, 1)
        bitmap.draw_text(+1, +1, 160, 20, string, 1)
        bitmap.font.color.set(255, 255, 255)
        bitmap.draw_text(0, 0, 160, 20, string, 1)
      end
      num = @_damage.size
      if type != 2
        @_damage.push([::Sprite.new, 40, 0, rand(40) - 20, rand(30) + 50])
      else
        @_damage.push([::Sprite.new, 40, 0, rand(20) - 10, rand(20) + 60])
      end
      @_damage[num][0].bitmap = bitmap
      @_damage[num][0].ox = 80 + self.viewport.ox
      @_damage[num][0].oy = 20 + self.viewport.oy
      if self.battler.is_a?(Game_Actor)
        @_damage[num][0].x = self.x
        @_damage[num][0].y = self.y - self.oy / 2
      else
        @_damage[num][0].x = self.x + self.viewport.rect.x -
                            self.ox + self.src_rect.width / 2
        @_damage[num][0].y = self.y - self.oy * self.zoom_y / 2 +
                            self.viewport.rect.y
        @_damage[num][0].zoom_x = self.zoom_x
        @_damage[num][0].zoom_y = self.zoom_y
        @_damage[num][0].z = 3000
      end
    end
    def animation(animation, hit)
      return if animation == nil
      num = @_animation.size
      @_animation.push([animation, hit, animation.frame_max, []])
      bitmap = RPG::Cache.animation(animation.animation_name,
                                    animation.animation_hue)
      if @@_reference_count.include?(bitmap)
        @@_reference_count[bitmap] += 1
      else
        @@_reference_count[bitmap] = 1
      end
      if @_animation[num][0] != 3 or not @@_animations.include?(animation)
        for i in 0..15
          sprite = ::Sprite.new
          sprite.bitmap = bitmap
          sprite.visible = false
          @_animation[num][3].push(sprite)
        end
        unless @@_animations.include?(animation)
          @@_animations.push(animation)
        end
      end
      update_animation(@_animation[num])
    end
    def loop_animation(animation)
      return if animation == @_loop_animation
      dispose_loop_animation
      @_loop_animation = animation
      return if @_loop_animation == nil
      @_loop_animation_index = 0
      animation_name = @_loop_animation.animation_name
      animation_hue = @_loop_animation.animation_hue
      bitmap = RPG::Cache.animation(animation_name, animation_hue)
      if @@_reference_count.include?(bitmap)
        @@_reference_count[bitmap] += 1
      else
        @@_reference_count[bitmap] = 1
      end
      @_loop_animation_sprites = []
      for i in 0..15
        sprite = ::Sprite.new
        sprite.bitmap = bitmap
        sprite.visible = false
        @_loop_animation_sprites.push(sprite)
      end
      update_loop_animation
    end
    def dispose_damage
      for damage in @_damage.reverse
        damage[0].bitmap.dispose
        damage[0].dispose
        @_damage.delete(damage)
      end
    end
    def dispose_animation
      for anime in @_animation.reverse
        sprite = anime[3][0]
        if sprite != nil
          @@_reference_count[sprite.bitmap] -= 1
          if @@_reference_count[sprite.bitmap] == 0
            sprite.bitmap.dispose
          end
        end
        for sprite in anime[3]
          sprite.dispose
        end
        @_animation.delete(anime)
      end
    end
    def effect?
      @_whiten_duration > 0 or
      @_appear_duration > 0 or
      @_escape_duration > 0 or
      @_collapse_duration > 0 or
      @_damage.size == 0 or
      @_animation.size == 0
    end
    def update
      super
      if @_whiten_duration > 0
        @_whiten_duration -= 1
        self.color.alpha = 128 - (16 - @_whiten_duration) * 10
      end
      if @_appear_duration > 0
        @_appear_duration -= 1
        self.opacity = (16 - @_appear_duration) * 16
      end
      if @_escape_duration > 0
        @_escape_duration -= 1
        self.opacity = 256 - (32 - @_escape_duration) * 10
      end
      if @_collapse_duration > 0
        @_collapse_duration -= 1
        self.opacity = 256 - (48 - @_collapse_duration) * 6
      end
      for damage in @_damage
        if damage[1] > 0
          damage[1] -= 1
          damage[4] -= 3
          damage[2] -= damage[4]
          if self.battler.is_a?(Game_Actor)
            damage[0].x = self.x + (40 - damage[1]) * damage[3] / 10
            damage[0].y = self.y - self.oy / 2 + damage[2] / 10
          else
            damage[0].x = self.x + self.viewport.rect.x -
                          self.ox + self.src_rect.width / 2 +
                          (40 - damage[1]) * damage[3] / 10
            damage[0].y = self.y - self.oy * self.zoom_y / 2 +
                          self.viewport.rect.y + damage[2] / 10
            damage[0].zoom_x = self.zoom_x
            damage[0].zoom_y = self.zoom_y
          end
          damage[0].z = 2960 + damage[1]
          damage[0].opacity = 256 - (12 - damage[1]) * 32
          if damage[1] == 0
            damage[0].bitmap.dispose
            damage[0].dispose
            @_damage.delete(damage)
          end
        end
      end
      for anime in @_animation
        if (Graphics.frame_count % 2 == 0)
          anime[2] -= 1
          update_animation(anime)
        end
      end
      if @_loop_animation != nil and (Graphics.frame_count % 2 == 0)
        update_loop_animation
        @_loop_animation_index += 1
        @_loop_animation_index %= @_loop_animation.frame_max
      end
      if @_blink
        @_blink_count = (@_blink_count + 1) % 32
        if @_blink_count < 16
          alpha = (16 - @_blink_count) * 6
        else
          alpha = (@_blink_count - 16) * 6
        end
        self.color.set(255, 255, 255, alpha)
      end
      @@_animations.clear
    end
    def update_animation(anime)
      if anime[2] > 0
        frame_index = anime[0].frame_max - anime[2]
        cell_data = anime[0].frames[frame_index].cell_data
        position = anime[0].position
        animation_set_sprites(anime[3], cell_data, position)
        for timing in anime[0].timings
          if timing.frame == frame_index
            animation_process_timing(timing, anime[1])
          end
        end
      else
        @@_reference_count[anime[3][0].bitmap] -= 1
        if @@_reference_count[anime[3][0].bitmap] == 0
            anime[3][0].bitmap.dispose
        end
        for sprite in anime[3]
          sprite.dispose
        end
        @_animation.delete(anime)
      end
    end
    def animation_set_sprites(sprites, cell_data, position)
      for i in 0..15
        sprite = sprites[i]
        pattern = cell_data[i, 0]
        if sprite == nil or pattern == nil or pattern == -1
          sprite.visible = false if sprite != nil
          next
        end
        sprite.visible = true
        sprite.src_rect.set(pattern % 5 * 192, pattern / 5 * 192, 192, 192)
        if position == 3
          if self.viewport != nil
            sprite.x = self.viewport.rect.width / 2
            if $game_temp.in_battle and self.battler.is_a?(Game_Enemy)
              sprite.y = self.viewport.rect.height - 320
            else
              sprite.y = self.viewport.rect.height - 160
            end
          else
            sprite.x = 320
            sprite.y = 240
          end
        else
          sprite.x = self.x + self.viewport.rect.x -
                      self.ox + self.src_rect.width / 2
          if $game_temp.in_battle and self.battler.is_a?(Game_Enemy)
            sprite.y = self.y - self.oy * self.zoom_y / 2 +
                        self.viewport.rect.y
            if position == 0
              sprite.y -= self.src_rect.height * self.zoom_y / 4
            elsif position == 2
              sprite.y += self.src_rect.height * self.zoom_y / 4
            end
          else
            sprite.y = self.y + self.viewport.rect.y -
                        self.oy + self.src_rect.height / 2
            sprite.y -= self.src_rect.height / 4 if position == 0
            sprite.y += self.src_rect.height / 4 if position == 2
          end
        end
        sprite.x += cell_data[i, 1]
        sprite.y += cell_data[i, 2]
        sprite.z = 2000
        sprite.ox = 96
        sprite.oy = 96
        sprite.zoom_x = cell_data[i, 3] / 100.0
        sprite.zoom_y = cell_data[i, 3] / 100.0
        if position != 3
          sprite.zoom_x *= self.zoom_x
          sprite.zoom_y *= self.zoom_y
        end
        sprite.angle = cell_data[i, 4]
        sprite.mirror = (cell_data[i, 5] == 1)
        sprite.opacity = cell_data[i, 6] * self.opacity / 255.0
        sprite.blend_type = cell_data[i, 7]
      end
    end
    def x=(x)
      sx = x - self.x
      if sx != 0
        for anime in @_animation
          if anime[3] != nil
            for i in 0..15
              anime[3][i].x += sx
            end
          end
        end
        if @_loop_animation_sprites != nil
          for i in 0..15
            @_loop_animation_sprites[i].x += sx
          end
        end
      end
      super
    end
    def y=(y)
      sy = y - self.y
      if sy != 0
        for anime in @_animation
          if anime[3] != nil
            for i in 0..15
              anime[3][i].y += sy
            end
          end
        end
        if @_loop_animation_sprites != nil
          for i in 0..15
            @_loop_animation_sprites[i].y += sy
          end
        end
      end
      super
    end
  end
end

#------------------------------------------------------------------------------
# ?Bitmap긏깋긚궸륷궫궶??귩믁돿궢귏궥갃
#==============================================================================

class Bitmap
  #--------------------------------------------------------------------------
  # 걶 뗩?귩긐깋긢?긘깈깛?렑
  #    color1 : 긚??긣긇깋?
  #    color2 : 긄깛긤긇깋?
  #    align  :  0:돘궸긐깋긢?긘깈깛
  #              1:뢢궸긐깋긢?긘깈깛
  #              2:롈귕궸긐깋긢?긘깈깛걁똽뢣궸궰궖뭾댰걂
  #--------------------------------------------------------------------------
  def gradation_rect(x, y, width, height, color1, color2, align = 0)
    if align == 0
      for i in x...x + width
        red  = color1.red + (color2.red - color1.red) * (i - x) / (width - 1)
        green = color1.green +
                (color2.green - color1.green) * (i - x) / (width - 1)
        blue  = color1.blue +
                (color2.blue - color1.blue) * (i - x) / (width - 1)
        alpha = color1.alpha +
                (color2.alpha - color1.alpha) * (i - x) / (width - 1)
        color = Color.new(red, green, blue, alpha)
        fill_rect(i, y, 1, height, color)
      end
    elsif align == 1
      for i in y...y + height
        red  = color1.red +
                (color2.red - color1.red) * (i - y) / (height - 1)
        green = color1.green +
                (color2.green - color1.green) * (i - y) / (height - 1)
        blue  = color1.blue +
                (color2.blue - color1.blue) * (i - y) / (height - 1)
        alpha = color1.alpha +
                (color2.alpha - color1.alpha) * (i - y) / (height - 1)
        color = Color.new(red, green, blue, alpha)
        fill_rect(x, i, width, 1, color)
      end
    elsif align == 2
      for i in x...x + width
        for j in y...y + height
          red  = color1.red + (color2.red - color1.red) *
                  ((i - x) / (width - 1.0) + (j - y) / (height - 1.0)) / 2
          green = color1.green + (color2.green - color1.green) *
                  ((i - x) / (width - 1.0) + (j - y) / (height - 1.0)) / 2
          blue  = color1.blue + (color2.blue - color1.blue) *
                  ((i - x) / (width - 1.0) + (j - y) / (height - 1.0)) / 2
          alpha = color1.alpha + (color2.alpha - color1.alpha) *
                  ((i - x) / (width - 1.0) + (j - y) / (height - 1.0)) / 2
          color = Color.new(red, green, blue, alpha)
          set_pixel(i, j, color)
        end
      end
    elsif align == 3
      for i in x...x + width
        for j in y...y + height
          red  = color1.red + (color2.red - color1.red) *
              ((x + width - i) / (width - 1.0) + (j - y) / (height - 1.0)) / 2
          green = color1.green + (color2.green - color1.green) *
              ((x + width - i) / (width - 1.0) + (j - y) / (height - 1.0)) / 2
          blue  = color1.blue + (color2.blue - color1.blue) *
              ((x + width - i) / (width - 1.0) + (j - y) / (height - 1.0)) / 2
          alpha = color1.alpha + (color2.alpha - color1.alpha) *
              ((x + width - i) / (width - 1.0) + (j - y) / (height - 1.0)) / 2
          color = Color.new(red, green, blue, alpha)
          set_pixel(i, j, color)
        end
      end
    end
  end
end

Who's 백호

?

이상혁입니다.

http://elab.kr

Comment '5'

List of Articles
번호 분류 제목 글쓴이 날짜 조회 수
공지 스크립트 자료 게시물 작성시 주의사항 습작 2012.12.24 6317
501 스킬 SG_Skill Invoking Battle Items by sandgolem (SDK호환) 백호 2009.02.22 895
500 저장 세이브 슬롯 갯수 증가와 세이브 덮어씌울 때 확인 by RPG Advocate 5 백호 2009.02.22 1511
499 기타 스크린샷 찍는 스크립트 9 file 백호 2009.02.22 1364
498 스킬 Skill Shop by Trickster@rmxp.org file 백호 2009.02.22 1073
497 기타 데미지 출력 스크립트 예제 9 file 백호 2009.02.22 1560
496 메뉴 수정, 추가 링메뉴 10 file 백호 2009.02.22 2916
495 전투 데미지 출력 스크립트 6 백호 2009.02.22 1810
494 기타 Economy System by Nick@Creation Asylum 1 file 백호 2009.02.22 934
493 이동 및 탈것 3D 캐릭 스크립트 7 백호 2009.02.22 3444
492 키입력 텍스트입력 이벤트명령 2.0 by wachunga@rmxp.org (SDK호환) file 백호 2009.02.22 1827
491 전투 RPG Advocate의 데모에서 발췌한 사이드뷰용 전투상태창 4 file 백호 2009.02.22 3600
490 변수/스위치 SG_Self Variables by sandgolem 백호 2009.02.22 1275
489 기타 SG_Settings Control by sandgolem 백호 2009.02.22 884
488 메뉴 SG_Hide zero SP cost by sandgolem (SDK호환) 백호 2009.02.22 1066
487 아이템 SG_Hide free item cose by sandgolem (SDK호환) 백호 2009.02.22 941
486 메뉴 SG_Artifact Colors by sandgolem (SDK 호환) 1 백호 2009.02.22 1003
485 상태/속성 SG_State Immunity Message by sandgolem (SDK 호환) 백호 2009.02.22 1057
484 전투 보행그래픽으로 싸우는 턴알 17 백호 2009.02.22 3783
» 전투 ATB전투 5 백호 2009.02.22 3370
482 기타 어디에 쓰이는지 불확실한 스크립트 1 백호 2009.02.22 1063
Board Pagination Prev 1 ... 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 ... 52 Next
/ 52