Custom Side View Battle system

Hello! I am new to the forums. I have a script request, and I hope I'm posting in the right forum.

So, I would gladly appreciate a simple side view battle system. I know making these things takes lots of time, and effort. But I'd give you cookies! :3

Basically, I want the battle system to be semi animated. Only the main characters in the party are animated, and only then when they are either casting a spell, or attacking. MOSTLY like FF6 (http://www.youtube.com/watch?v=_dwADEGl-uc)

I don't want anything fancy, just something simple. I would love you for ever who-ever does the script for me!
Thank you!
Content Hidden Spoiler
  1.  class Bitmap
  2. if not method_defined?('original_draw_text')
  3. alias original_draw_text draw_text
  4. def draw_text(*arg)
  5.  
  6.    original_color = self.font.color.dup
  7.    self.font.color = Color.new(0, 0, 0, 128)
  8.  
  9.    if arg[0].is_a?(Rect)
  10.      arg[0].x += 2
  11.      arg[0].y += 2
  12.      self.original_draw_text(*arg)
  13.      arg[0].x -= 2
  14.      arg[0].y -= 2
  15.    else
  16.      arg[0] += 2
  17.      arg[1] += 2
  18.      self.original_draw_text(*arg)
  19.      arg[0] -= 2
  20.      arg[1] -= 2
  21.    end
  22.  
  23.    self.font.color = original_color
  24.    self.original_draw_text(*arg)
  25.  
  26. end
  27. end
  28. def gradation_rect(x, y, width, height, color1, color2, align = 0)
  29. if align == 0
  30.    for i in x...x + width
  31.      red   = color1.red + (color2.red - color1.red) * (i - x) / (width - 1)
  32.      green = color1.green +
  33.              (color2.green - color1.green) * (i - x) / (width - 1)
  34.      blue  = color1.blue +
  35.              (color2.blue - color1.blue) * (i - x) / (width - 1)
  36.      alpha = color1.alpha +
  37.              (color2.alpha - color1.alpha) * (i - x) / (width - 1)
  38.      color = Color.new(red, green, blue, alpha)
  39.      fill_rect(i, y, 1, height, color)
  40.    end
  41. elsif align == 1
  42.    for i in y...y + height
  43.      red   = color1.red +
  44.              (color2.red - color1.red) * (i - y) / (height - 1)
  45.      green = color1.green +
  46.              (color2.green - color1.green) * (i - y) / (height - 1)
  47.      blue  = color1.blue +
  48.              (color2.blue - color1.blue) * (i - y) / (height - 1)
  49.      alpha = color1.alpha +
  50.              (color2.alpha - color1.alpha) * (i - y) / (height - 1)
  51.      color = Color.new(red, green, blue, alpha)
  52.      fill_rect(x, i, width, 1, color)
  53.    end
  54. elsif align == 2
  55.    for i in x...x + width
  56.      for j in y...y + height
  57.        red   = color1.red + (color2.red - color1.red) *
  58.                ((i - x) / (width - 1.0) + (j - y) / (height - 1.0)) / 2
  59.        green = color1.green + (color2.green - color1.green) *
  60.                ((i - x) / (width - 1.0) + (j - y) / (height - 1.0)) / 2
  61.        blue  = color1.blue + (color2.blue - color1.blue) *
  62.                ((i - x) / (width - 1.0) + (j - y) / (height - 1.0)) / 2
  63.        alpha = color1.alpha + (color2.alpha - color1.alpha) *
  64.                ((i - x) / (width - 1.0) + (j - y) / (height - 1.0)) / 2
  65.        color = Color.new(red, green, blue, alpha)
  66.        set_pixel(i, j, color)
  67.      end
  68.    end
  69. elsif align == 3
  70.    for i in x...x + width
  71.      for j in y...y + height
  72.        red   = color1.red + (color2.red - color1.red) *
  73.              ((x + width - i) / (width - 1.0) + (j - y) / (height - 1.0)) / 2
  74.        green = color1.green + (color2.green - color1.green) *
  75.              ((x + width - i) / (width - 1.0) + (j - y) / (height - 1.0)) / 2
  76.        blue  = color1.blue + (color2.blue - color1.blue) *
  77.              ((x + width - i) / (width - 1.0) + (j - y) / (height - 1.0)) / 2
  78.        alpha = color1.alpha + (color2.alpha - color1.alpha) *
  79.              ((x + width - i) / (width - 1.0) + (j - y) / (height - 1.0)) / 2
  80.        color = Color.new(red, green, blue, alpha)
  81.        set_pixel(i, j, color)
  82.      end
  83.    end
  84. end
  85. end
  86. end
  87.  
  88. module RPG
  89. class Sprite < ::Sprite
  90. def damage(value, critical)
  91.    dispose_damage
  92.    if value.is_a?(Numeric)
  93.      damage_string = value.abs.to_s
  94.    else
  95.      damage_string = value.to_s
  96.    end
  97.    bitmap = Bitmap.new(160, 48)
  98.    bitmap.font.name = "Arial Black"
  99.    bitmap.font.size = 32
  100.    bitmap.font.color.set(0, 0, 0)
  101.    bitmap.draw_text(-1, 12-1, 160, 36, damage_string, 1)
  102.    bitmap.draw_text(+1, 12-1, 160, 36, damage_string, 1)
  103.    bitmap.draw_text(-1, 12+1, 160, 36, damage_string, 1)
  104.    bitmap.draw_text(+1, 12+1, 160, 36, damage_string, 1)
  105.    if value.is_a?(Numeric) and value < 0
  106.      bitmap.font.color.set(176, 255, 144)
  107.    else
  108.      bitmap.font.color.set(255, 255, 255)
  109.    end
  110.    bitmap.draw_text(0, 12, 160, 36, damage_string, 1)
  111.    if critical
  112.      bitmap.font.size = 20
  113.      bitmap.font.color.set(0, 0, 0)
  114.      bitmap.draw_text(-1, -1, 160, 20, "CRITICAL", 1)
  115.      bitmap.draw_text(+1, -1, 160, 20, "CRITICAL", 1)
  116.      bitmap.draw_text(-1, +1, 160, 20, "CRITICAL", 1)
  117.      bitmap.draw_text(+1, +1, 160, 20, "CRITICAL", 1)
  118.      bitmap.font.color.set(255, 255, 255)
  119.      bitmap.draw_text(0, 0, 160, 20, "CRITICAL", 1)
  120.    end
  121.    @_damage_sprite = ::Sprite.new
  122.    @_damage_sprite.bitmap = bitmap
  123.    @_damage_sprite.ox = 80 + self.viewport.ox
  124.    @_damage_sprite.oy = 20 + self.viewport.oy
  125.    @_damage_sprite.x = self.x + self.viewport.rect.x
  126.    @_damage_sprite.y = self.y - self.oy / 2 + self.viewport.rect.y
  127.    @_damage_sprite.z = 3000
  128.    @_damage_duration = 40
  129. end
  130. def animation(animation, hit)
  131.    dispose_animation
  132.    @_animation = animation
  133.    return if @_animation == nil
  134.    @_animation_hit = hit
  135.    @_animation_duration = @_animation.frame_max
  136.    animation_name = @_animation.animation_name
  137.    animation_hue = @_animation.animation_hue
  138.    bitmap = RPG::Cache.animation(animation_name, animation_hue)
  139.    if @@_reference_count.include?(bitmap)
  140.      @@_reference_count[bitmap] += 1
  141.    else
  142.      @@_reference_count[bitmap] = 1
  143.    end
  144.    @_animation_sprites = []
  145.    if @_animation.position != 3 or not @@_animations.include?(animation)
  146.      for i in 0..15
  147.        sprite = ::Sprite.new
  148.        sprite.bitmap = bitmap
  149.        sprite.visible = false
  150.        @_animation_sprites.push(sprite)
  151.      end
  152.      unless @@_animations.include?(animation)
  153.        @@_animations.push(animation)
  154.      end
  155.    end
  156.    update_animation
  157. end
  158. def loop_animation(animation)
  159.    return if animation == @_loop_animation
  160.    dispose_loop_animation
  161.    @_loop_animation = animation
  162.    return if @_loop_animation == nil
  163.    @_loop_animation_index = 0
  164.    animation_name = @_loop_animation.animation_name
  165.    animation_hue = @_loop_animation.animation_hue
  166.    bitmap = RPG::Cache.animation(animation_name, animation_hue)
  167.    if @@_reference_count.include?(bitmap)
  168.      @@_reference_count[bitmap] += 1
  169.    else
  170.      @@_reference_count[bitmap] = 1
  171.    end
  172.    @_loop_animation_sprites = []
  173.    for i in 0..15
  174.      sprite = ::Sprite.new
  175.      sprite.bitmap = bitmap
  176.      sprite.visible = false
  177.      @_loop_animation_sprites.push(sprite)
  178.    end
  179.    update_loop_animation
  180. end
  181. def animation_set_sprites(sprites, cell_data, position)
  182.    for i in 0..15
  183.      sprite = sprites[i]
  184.      pattern = cell_data[i, 0]
  185.      if sprite == nil or pattern == nil or pattern == -1
  186.        sprite.visible = false if sprite != nil
  187.        next
  188.      end
  189.      sprite.visible = true
  190.      sprite.src_rect.set(pattern % 5 * 192, pattern / 5 * 192, 192, 192)
  191.      if position == 3
  192.        if self.viewport != nil
  193.          sprite.x = self.viewport.rect.width / 2
  194.          sprite.y = self.viewport.rect.height - 160
  195.        else
  196.          sprite.x = 320
  197.          sprite.y = 240
  198.        end
  199.      else
  200.        sprite.x = self.x + self.viewport.rect.x -
  201.                    self.ox + self.src_rect.width / 2
  202.        sprite.y = self.y + self.viewport.rect.y -
  203.                    self.oy + self.src_rect.height / 2
  204.        sprite.y -= self.src_rect.height / 4 if position == 0
  205.        sprite.y += self.src_rect.height / 4 if position == 2
  206.      end
  207.      sprite.x += cell_data[i, 1]
  208.      sprite.y += cell_data[i, 2]
  209.      sprite.z = 2000
  210.      sprite.ox = 96
  211.      sprite.oy = 96
  212.      sprite.zoom_x = cell_data[i, 3] / 100.0
  213.      sprite.zoom_y = cell_data[i, 3] / 100.0
  214.      sprite.angle = cell_data[i, 4]
  215.      sprite.mirror = (cell_data[i, 5] == 1)
  216.      sprite.opacity = cell_data[i, 6] * self.opacity / 255.0
  217.      sprite.blend_type = cell_data[i, 7]
  218.    end
  219. end
  220. end
  221. end
  222.  
  223. class Game_Actor < Game_Battler
  224. def screen_x
  225.    if self.index != nil
  226.    n_split = [($game_party.actors.length * 0.5).ceil, 4].min
  227.    case n_split
  228.    when 1
  229.      n_index = self.index * 2
  230.    when 2
  231.      if self.index < ($game_party.actors.length - 2)
  232.        n_index = 0.5 + (2 * self.index)
  233.      else
  234.        if $game_party.actors.length == 3 then
  235.          n_index = (self.index * 2) + 2
  236.        elsif $game_party.actors.length == 4 then
  237.          n_index = self.index * 2
  238.        end
  239.      end
  240.    when 3
  241.        n_index = self.index + (0.25 * (self.index + 1))
  242.      if $game_party.actors.length == 5
  243.      if self.index < 2
  244.        n_index = self.index + (0.25 * (self.index + 1))
  245.      else
  246.        n_index = self.index + (0.25 * (self.index + 2)) + 1
  247.      end
  248.      end
  249.    when 4
  250.      n_index = self.index
  251.      if $game_party.actors.length == 7
  252.      if self.index < 3
  253.        n_index = self.index
  254.      else
  255.        n_index = self.index + 1
  256.      end
  257.      end
  258.    end
  259.      return (n_index - ((n_index / 4).floor) * 4) * ((160 / (4)) / 5) + 480 + ((n_index / 4).floor * 60)
  260.    else
  261.      return 0
  262.    end
  263. end
  264. #--------------------------------------------------------------------------
  265. # ? ????? Y ?????
  266. #--------------------------------------------------------------------------
  267. def screen_y
  268.    n_split = [($game_party.actors.length * 0.5).ceil, 4].min
  269.    case n_split
  270.    when 1
  271.      n_index = self.index * 2
  272.    when 2
  273.      if self.index < ($game_party.actors.length - 2)
  274.        n_index = 0.5 + (2 * self.index)
  275.      else
  276.        if $game_party.actors.length == 3 then
  277.          n_index = (self.index * 2) + 2
  278.        elsif $game_party.actors.length == 4 then
  279.          n_index = self.index * 2
  280.        end
  281.      end
  282.    when 3
  283.        n_index = self.index + (0.25 * (self.index + 1))
  284.      if $game_party.actors.length == 5
  285.      if self.index < 2
  286.        n_index = self.index + (0.25 * (self.index + 1))
  287.      else
  288.        n_index = self.index + (0.25 * (self.index + 2)) + 1
  289.      end
  290.      end
  291.    when 4
  292.      n_index = self.index
  293.      if $game_party.actors.length == 7
  294.      if self.index < 3
  295.        n_index = self.index
  296.      else
  297.        n_index = self.index + 1
  298.      end
  299.      end
  300.    end
  301.    return (n_index - ((n_index / 4).floor) * 4) * ((160 / (4)) * 1.6) + 270 - ((n_index / 4).floor * (110 - (4 * 20)))
  302. end
  303. #--------------------------------------------------------------------------
  304. # ? ????? Z ?????
  305. #--------------------------------------------------------------------------
  306. def screen_z
  307.    # ??????????? Z ?????????
  308.    if self.index != nil
  309.      return self.index
  310.    else
  311.      return 0
  312.    end
  313. end
  314. end
  315.  
  316. class Game_Enemy < Game_Battler
  317. def screen_x
  318.    n_split = [($game_troop.enemies.length * 0.5).ceil, 4].min
  319.    case n_split
  320.    when 1
  321.      n_index = self.index * 2
  322.    when 2
  323.      if self.index < ($game_troop.enemies.length - 2)
  324.        n_index = 0.5 + (2 * self.index)
  325.      else
  326.        if $game_troop.enemies.length == 3 then
  327.          n_index = (self.index * 2) + 2
  328.        elsif $game_troop.enemies.length == 4 then
  329.          n_index = self.index * 2
  330.        end
  331.      end
  332.    when 3
  333.        n_index = self.index + (0.25 * (self.index + 1))
  334.      if $game_troop.enemies.length == 5
  335.      if self.index < 2
  336.        n_index = self.index + (0.25 * (self.index + 1))
  337.      else
  338.        n_index = self.index + (0.25 * (self.index + 2)) + 2
  339.      end
  340.      end
  341.    when 4
  342.      n_index = self.index
  343.      if $game_troop.enemies.length == 7
  344.      if self.index < 3
  345.        n_index = self.index
  346.      else
  347.        n_index = self.index + 1
  348.      end
  349.      end
  350.    end
  351.    return (n_index - ((n_index / 4).floor) * 4) * ((-160 / (4)) / 5) + 160 - ((n_index / 4).floor * 60)
  352. end
  353. #--------------------------------------------------------------------------
  354. # ? ????? Y ?????
  355. #--------------------------------------------------------------------------
  356. def screen_y
  357.    n_split = [($game_troop.enemies.length * 0.5).ceil, 4].min
  358.    case n_split
  359.    when 1
  360.      n_index = self.index * 2
  361.    when 2
  362.      if self.index < ($game_troop.enemies.length - 2)
  363.        n_index = 0.5 + (2 * self.index)
  364.      else
  365.        if $game_troop.enemies.length == 3 then
  366.          n_index = (self.index * 2) + 2
  367.        elsif $game_troop.enemies.length == 4 then
  368.          n_index = self.index * 2
  369.        end
  370.      end
  371.    when 3
  372.        n_index = self.index + (0.25 * (self.index + 1))
  373.      if $game_troop.enemies.length == 5
  374.      if self.index < 2
  375.        n_index = self.index + (0.25 * (self.index + 1))
  376.      else
  377.        n_index = self.index + (0.25 * (self.index + 2)) + 1
  378.      end
  379.      end
  380.    when 4
  381.      n_index = self.index
  382.      if $game_troop.enemies.length == 7
  383.      if self.index < 3
  384.        n_index = self.index
  385.      else
  386.        n_index = self.index + 1
  387.      end
  388.      end
  389.    end
  390.    return (n_index - ((n_index / 4).floor) * 4) * ((160 / (4)) * 1.6) + 270 - ((n_index / 4).floor * (110 - (4 * 20)))
  391. end
  392. #--------------------------------------------------------------------------
  393. # ? ????? Z ?????
  394. #--------------------------------------------------------------------------
  395. def screen_z
  396.    return @member_index + 1
  397. end
  398. end
  399.  
  400. #==============================================================================
  401. # ¦ Sprite_Battler
  402. #------------------------------------------------------------------------------
  403. #  ????????????????Game_Battler ???????????????
  404. # ????????????????????
  405. #==============================================================================
  406.  
  407. class Sprite_Battler < RPG::Sprite
  408. #--------------------------------------------------------------------------
  409. # ? ??????????
  410. #--------------------------------------------------------------------------
  411. attr_accessor :battler                  # ????
  412. attr_accessor :moving        # Is the sprite moving?
  413. attr_reader   :index
  414. attr_accessor :target_index
  415. attr_accessor :direction
  416. attr_accessor :pattern
  417. #--------------------------------------------------------------------------
  418. # ? ?????????
  419. #     viewport : ??????
  420. #     battler  : ???? (Game_Battler)
  421. #--------------------------------------------------------------------------
  422. def initialize(viewport, battler = nil)
  423.    super(viewport)
  424.    change
  425.    @old = Graphics.frame_count  # For the delay method
  426.    @goingup = true    # Increasing animation? (if @rm2k_mode is true)
  427.    @once = false      # Is the animation only played once?
  428.    @animated = true   # Used to stop animation when @once is true
  429.    self.opacity = 0
  430.    @index = 0
  431.    @pattern_b = 0
  432.    @counter_b = 0
  433.    @trans_sprite = Sprite.new
  434.    @trans_sprite.opacity = 0
  435.    @bar_hp_sprite = Sprite.new
  436.    @bar_hp_sprite.bitmap = Bitmap.new(64, 10)
  437.    @bar_sp_sprite = Sprite.new
  438.    @bar_sp_sprite.bitmap = Bitmap.new(64, 10)
  439.    @color1 = Color.new(0, 0, 0, 192)
  440.    @color2 = Color.new(255, 255, 192, 192)
  441.    @color3 = Color.new(0, 0, 0, 192)
  442.    @color4 = Color.new(64, 0, 0, 192)
  443.    @old_hp = -1
  444.    @old_sp = -1
  445.    @battler = battler
  446.    @battler_visible = false
  447.    @first = true
  448.    @pattern = 0
  449.    if $target_index == nil
  450.      $target_index = 0
  451.    end
  452.    @battler.is_a?(Game_Enemy) ? enemy_pose(0, 1) : pose(0, 1)
  453. end
  454. #--------------------------------------------------------------------------
  455. # ? ??
  456. #--------------------------------------------------------------------------
  457. def dispose
  458.    if self.bitmap != nil
  459.      self.bitmap.dispose
  460.    end
  461.    if @trans_sprite.bitmap != nil
  462.      @trans_sprite.bitmap.dispose
  463.    end
  464.    @trans_sprite.dispose
  465.    @bar_hp_sprite.bitmap.dispose
  466.    @bar_hp_sprite.dispose
  467.    @bar_sp_sprite.bitmap.dispose
  468.    @bar_sp_sprite.dispose
  469.    super
  470. end
  471.  
  472. def change(frames = 0, delay = 0, offx = 0, offy = 0, startf = 0, once = false)
  473.    @frames = frames
  474.    @delay = delay
  475.    @offset_x, @offset_y = offx, offy
  476.    @current_frame = startf
  477.    @once = once
  478.    @goingup = true
  479.    @animated = true
  480. end
  481. #--------------------------------------------------------------------------
  482. # ? ??????
  483. #--------------------------------------------------------------------------
  484. def update
  485.    bar_check = true if @_damage_duration == 1
  486.    super
  487.    @trans_sprite.blend_type = self.blend_type
  488.    @trans_sprite.color = self.color
  489.    if @_collapse_duration > 0
  490.      @trans_sprite.opacity = self.opacity
  491.    else
  492.      @trans_sprite.opacity = [self.opacity, 160].min
  493.    end
  494.    if (@_damage_duration == 0 and bar_check == true) or @first == true
  495.      @first = false if @first == true
  496.      bar_check = false
  497.      @bar_must_change = true
  498.    end
  499.    @bar_hp_sprite.opacity = self.opacity
  500.    @bar_sp_sprite.opacity = self.opacity
  501.    # ????? nil ???
  502.    if @battler == nil
  503.      self.bitmap = nil
  504.      @trans_sprite.bitmap = nil
  505.      loop_animation(nil)
  506.      return
  507.    end
  508.    # ????????????????????
  509.    if @battler.battler_name != @battler_name or
  510.       @battler.battler_hue != @battler_hue
  511.      # ????????????
  512.      @battler_name = @battler.battler_name
  513.      @battler_hue = @battler.battler_hue
  514.      if @battler.is_a?(Game_Actor)
  515.        @battler_name = @battler.character_name
  516.        @battler_hue = @battler.character_hue
  517.        @direction = 4
  518.      else
  519.        @direction = 6
  520.      end
  521.        self.bitmap = RPG::Cache.character(@battler_name, @battler_hue)
  522.        @width = bitmap.width / 4
  523.        @height = bitmap.height / 4
  524.        @frame_width = @width
  525.        @frame_height = @height
  526.        self.ox = @width / 2
  527.        self.oy = @height
  528.        @pattern = @current_frame
  529.        @direction = @offset_y
  530.        sx = @pattern * @width
  531.        sy = (@direction - 2) / 2 * @height
  532.        self.src_rect.set(sx, sy, @width, @height)
  533.        @current_frame = (@current_frame + 1) unless @frames == 0
  534.        @animated = false if @current_frame == @frames and @once
  535.        @current_frame %= @frames
  536.        @trans_sprite.bitmap = self.bitmap
  537.        @trans_sprite.ox = self.ox
  538.        @trans_sprite.oy = self.oy
  539.        @trans_sprite.src_rect.set(sx, sy, @width, @height)
  540.      # ?????????????????? 0 ???
  541.      if @battler.dead? or @battler.hidden
  542.        self.opacity = 0
  543.        @trans_sprite.opacity = 0
  544.        @bar_hp_sprite.opacity = 0
  545.        @bar_sp_sprite.opacity = 0
  546.      end
  547.    self.x = @battler.screen_x
  548.    self.y = @battler.screen_y
  549.    self.z = @battler.screen_z
  550. end
  551. change_sp_bar if @old_sp != @battler.sp
  552. if delay(@delay) and @animated
  553.      @pattern = @current_frame
  554.      @direction = @offset_y
  555.      sx = @pattern * @width
  556.      sy = (@direction - 2) / 2 * @height
  557.      self.src_rect.set(sx, sy, @width, @height)
  558.      @current_frame = (@current_frame + 1) unless @frames == 0
  559.      @animated = false if @current_frame == @frames and @once
  560.      @current_frame %= @frames
  561.      @trans_sprite.ox = self.ox
  562.      @trans_sprite.oy = self.oy
  563.      @trans_sprite.src_rect.set(sx, sy, @width, @height)
  564.    end
  565.    # ??????? ID ????????????
  566.    if @battler.damage == nil and
  567.       @battler.state_animation_id != @state_animation_id
  568.      @state_animation_id = @battler.state_animation_id
  569.      loop_animation($data_animations[@state_animation_id])
  570.    end
  571.    # ??????????????
  572.    #if @battler.is_a?(Game_Actor) and @battler_visible
  573.      # ???????????????????????
  574.      #if $game_temp.battle_main_phase
  575.        #self.opacity += 3 if self.opacity < 255
  576.      #else
  577.        #self.opacity -= 3 if self.opacity > 207
  578.      #end
  579.    #end
  580.    # ??
  581.    if @battler.blink
  582.      blink_on
  583.    else
  584.      blink_off
  585.    end
  586.    # ??????
  587.    unless @battler_visible
  588.      # ??
  589.      if not @battler.hidden and not @battler.dead? and
  590.         (@battler.damage == nil or @battler.damage_pop)
  591.        appear
  592.        @battler_visible = true
  593.      end
  594.    end
  595.    # ?????
  596.    if @battler_visible
  597.      # ??
  598.      if @battler.hidden
  599.        $game_system.se_play($data_system.escape_se)
  600.        escape
  601.        @trans_sprite.opacity = 0
  602.        @battler_visible = false
  603.      end
  604.      # ??????
  605.      if @battler.white_flash
  606.        whiten
  607.        @battler.white_flash = false
  608.      end
  609.      # ???????
  610.      if @battler.animation_id != 0
  611.        animation = $data_animations[@battler.animation_id]
  612.        animation(animation, @battler.animation_hit)
  613.        @battler.animation_id = 0
  614.      end
  615.      # ????
  616.      if @battler.damage_pop
  617.        damage(@battler.damage, @battler.critical)
  618.        @battler.damage = nil
  619.        @battler.critical = false
  620.        @battler.damage_pop = false
  621.      end
  622.      if @bar_must_change == true
  623.        @bar_must_change = false
  624.        if @old_hp != @battler.hp
  625.          change_hp_bar
  626.        end
  627.        if @battler.damage == nil and @battler.dead?
  628.          if @battler.is_a?(Game_Enemy)
  629.            $game_system.se_play($data_system.enemy_collapse_se)
  630.          else
  631.            $game_system.se_play($data_system.actor_collapse_se)
  632.          end
  633.          collapse
  634.          @battler_visible = false
  635.        end
  636.      end
  637.    end
  638.    # ???????????
  639.    @trans_sprite.x = self.x
  640.    @trans_sprite.y = self.y
  641.    @trans_sprite.z = self.z
  642.    @bar_hp_sprite.x = @battler.screen_x - 32
  643.    @bar_hp_sprite.y = @battler.screen_y - (@height +18) if @height != nil
  644.    @bar_hp_sprite.z = 100
  645.    @bar_sp_sprite.x = @battler.screen_x - 32
  646.    @bar_sp_sprite.y = @battler.screen_y - (@height + 8) if @height != nil
  647.    @bar_sp_sprite.z = 100
  648. end
  649.  
  650. #--------------------------------------------------------------------------
  651. # - Move the sprite
  652. #   x : X coordinate of the destination point
  653. #   y : Y coordinate of the destination point
  654. #   speed : Speed of movement (0 = delayed, 1+ = faster)
  655. #   delay : Movement delay if speed is at 0
  656. #--------------------------------------------------------------------------
  657. def move(x, y, speed = 1, delay = 0)
  658.    @destx = x
  659.    @desty = y
  660.    @move_speed = speed
  661.    @move_delay = delay
  662.    @move_old = Graphics.frame_count
  663.    @moving = true
  664. end
  665.  
  666. #--------------------------------------------------------------------------
  667. # - Move sprite to destx and desty
  668. #--------------------------------------------------------------------------
  669. def update_move
  670.    return unless @moving
  671.    movinc = @move_speed == 0 ? 1 : @move_speed
  672.    if Graphics.frame_count - @move_old > @move_delay or @move_speed != 0
  673.      self.x += movinc if self.x < @destx
  674.      self.x -= movinc if self.x > @destx
  675.      self.y += movinc if self.y < @desty
  676.      self.y -= movinc if self.y > @desty
  677.      @move_old = Graphics.frame_count
  678.    end
  679.    if @move_speed > 1  # Check if sprite can't reach that point
  680.      self.x = @destx if (@destx - self.x).abs % @move_speed != 0 and
  681.                         (@destx - self.x).abs <= @move_speed
  682.      self.y = @desty if (@desty - self.y).abs % @move_speed != 0 and
  683.                         (@desty - self.y).abs <= @move_speed
  684.    end
  685.    if self.x == @destx and self.y == @desty
  686.      @moving = false
  687.    end
  688. end
  689.  
  690. #--------------------------------------------------------------------------
  691. # - Pause animation, but still updates movement
  692. #   frames : Number of frames
  693. #--------------------------------------------------------------------------
  694. def delay(frames)
  695.    update_move
  696.    if (Graphics.frame_count - @old >= frames)
  697.      @old = Graphics.frame_count
  698.      return true
  699.    end
  700.    return false
  701. end
  702.  
  703. def change_hp_bar
  704.    j = false
  705.   @old_hp = @battler.hp if @old_hp == -1
  706.    i = @old_hp
  707.    loop do
  708.      i -= 10
  709.      if i < @battler.hp
  710.        i = @battler.hp
  711.        j = true
  712.      end
  713.      rate = i.to_f / @battler.maxhp
  714.      @color5 = Color.new(80 - 24 * rate, 80 * rate, 14 * rate, 192)
  715.      @color6 = Color.new(240 - 72 * rate, 240 * rate, 62 * rate, 192)
  716.      @bar_hp_sprite.bitmap.clear
  717.      @bar_hp_sprite.bitmap.fill_rect(0, 0, 64, 10, @color1)
  718.      @bar_hp_sprite.bitmap.fill_rect(1, 1, 62, 8, @color2)
  719.      @bar_hp_sprite.bitmap.gradation_rect(2, 2, 60, 6, @color3, @color4, 1)
  720.      #@bar_hp_sprite.bitmap.fill_rect(2, 2, 60, 6, @color3)
  721.      @bar_hp_sprite.bitmap.gradation_rect(2, 2, 64 * rate - 4, 6, @color5, @color6, 2)
  722.      #@bar_hp_sprite.bitmap.fill_rect(2, 2, 64 * rate - 4, 6, @color5)
  723.      @bar_hp_sprite.opacity = self.opacity
  724.      Graphics.update
  725.      if j == true
  726.        j = false
  727.        break
  728.      end
  729.    end
  730.    @old_hp = @battler.hp
  731. end
  732.  
  733. def change_sp_bar
  734.    j = false
  735.   @old_sp = @battler.sp if @old_sp == -1
  736.    i = @old_sp
  737.    loop do
  738.      i -= 10
  739.      if i < @battler.sp
  740.        i = @battler.sp
  741.        j = true
  742.      end
  743.      rate = i.to_f / @battler.maxsp
  744.      @color7 = Color.new(14 * rate, 80 - 24 * rate, 80 * rate, 192)
  745.      @color8 = Color.new(62 * rate, 240 - 72 * rate, 240 * rate, 192)
  746.      @bar_sp_sprite.bitmap.clear
  747.      @bar_sp_sprite.bitmap.fill_rect(0, 0, 64, 10, @color1)
  748.      @bar_sp_sprite.bitmap.fill_rect(1, 1, 62, 8, @color2)
  749.      @bar_sp_sprite.bitmap.gradation_rect(2, 2, 60, 6, @color3, @color4, 1)
  750.      #@bar_hp_sprite.bitmap.fill_rect(2, 2, 60, 6, @color3)
  751.      @bar_sp_sprite.bitmap.gradation_rect(2, 2, 64 * rate - 4, 6, @color7, @color8, 0)
  752.      #@bar_hp_sprite.bitmap.fill_rect(2, 2, 64 * rate - 4, 6, @color5)
  753.      @bar_sp_sprite.opacity = self.opacity
  754.      Graphics.update
  755.      if j == true
  756.        j = false
  757.        break
  758.      end
  759.    end
  760.    @old_sp = @battler.sp
  761. end
  762.  
  763. def enemy                                             #
  764.    $target_index += $game_troop.enemies.size
  765.    $target_index %= $game_troop.enemies.size
  766.    return $game_troop.enemies[$target_index]           #
  767. end                                                   #
  768.  
  769. def actor                                             #
  770.    $target_index += $game_party.actors.size
  771.    $target_index %= $game_party.actors.size
  772.    return $game_party.actors[$target_index]            #
  773. end
  774.  
  775. def index=(index)
  776.    @index = index
  777.    update
  778. end
  779.  
  780.    def pose(number, frames = 4)
  781.    case number
  782.    when 0
  783.      change(frames, 4, 0, 4, 0)
  784.    when 1
  785.      change(frames, 4, 0, 4)
  786.    when 2
  787.      change(frames, 4, 0, 6)
  788.    else
  789.      change(frames, 4, 0, 0, 0)
  790.    end
  791. end
  792.  
  793.    def enemy_pose(number ,enemy_frames = 4)
  794.    case number
  795.    when 0
  796.      change(enemy_frames, 4, 0, 6, 0)
  797.    when 1
  798.      change(enemy_frames, 4, 0, 4)
  799.    when 2
  800.      change(enemy_frames, 4, 0, 6)
  801.    else
  802.      change(enemy_frames, 4, 0, 0, 0)
  803.    end
  804. end
  805.  
  806. def default_pose
  807.    pose(0, 1)
  808. end
  809. end
  810.  
  811. #==============================================================================
  812. # ¦ Spriteset_Battle
  813. #------------------------------------------------------------------------------
  814. #  ???????????????????????????? Scene_Battle ??
  815. # ????????????
  816. #==============================================================================
  817.  
  818. class Spriteset_Battle
  819. #--------------------------------------------------------------------------
  820. # ? ??????????
  821. #--------------------------------------------------------------------------
  822. attr_reader   :viewport1                # ????????????
  823. attr_reader   :viewport2                # ????????????
  824. attr_accessor :actor_sprites
  825. attr_accessor :enemy_sprites
  826. #--------------------------------------------------------------------------
  827. # ? ?????????
  828. #--------------------------------------------------------------------------
  829. def initialize
  830.    # ?????????
  831.    @viewport1 = Viewport.new(0, 0, 640, 480)
  832.    @viewport2 = Viewport.new(0, 0, 640, 480)
  833.    @viewport3 = Viewport.new(0, 0, 640, 480)
  834.    @viewport4 = Viewport.new(0, 0, 640, 480)
  835.    @viewport2.z = 101
  836.    @viewport3.z = 200
  837.    @viewport4.z = 5000
  838.    if $game_temp.battleback_name == ""
  839.    @battleback_sprite = nil
  840.    @tilemap = Tilemap.new(@viewport1)
  841.    @tilemap.tileset = RPG::Cache.tileset($game_map.tileset_name)
  842.    for i in 0..6
  843.      autotile_name = $game_map.autotile_names[i]
  844.      @tilemap.autotiles[i] = RPG::Cache.autotile(autotile_name)
  845.    end
  846.    @tilemap.map_data = $game_map.data
  847.    @tilemap.priorities = $game_map.priorities
  848.    else
  849.    # ??????????????
  850.    @tilemap = nil
  851.    @battleback_sprite = Sprite.new(@viewport1)
  852.    end
  853.    # ????????????
  854.    @enemy_sprites = []
  855.    for enemy in $game_troop.enemies#.reverse
  856.      @enemy_sprites.push(Sprite_Battler.new(@viewport1, enemy))
  857.    end
  858.    # ????????????
  859.    @actor_sprites = []
  860.    for j in 0..7
  861.        # ƒAƒNƒ^[ƒXƒvƒ‰ƒCƒg‚ð’ljÁ
  862.        @actor_sprites.push(Sprite_Battler.new(@viewport1, $game_party.actors[j]))
  863.    end
  864.    # ?????
  865.    @weather = RPG::Weather.new(@viewport1)
  866.    # ????????????
  867.    @picture_sprites = []
  868.    for i in 51..100
  869.      @picture_sprites.push(Sprite_Picture.new(@viewport3,
  870.        $game_screen.pictures[i]))
  871.    end
  872.    # ????????????
  873.    @timer_sprite = Sprite_Timer.new
  874.    # ??????
  875.    update
  876. end
  877. #--------------------------------------------------------------------------
  878. # ? ??
  879. #--------------------------------------------------------------------------
  880. def dispose
  881.    if @tilemap != nil
  882.    # ?????????
  883.    @tilemap.tileset.dispose
  884.    for i in 0..6
  885.      @tilemap.autotiles[i].dispose
  886.    end
  887.    @tilemap.dispose
  888.    end
  889.    # ??????????????
  890.    if @battleback_sprite != nil
  891.    # ??????????????????????
  892.    if @battleback_sprite.bitmap != nil
  893.      @battleback_sprite.bitmap.dispose
  894.    end
  895.    @battleback_sprite.dispose
  896.    end
  897.    # ??????????????????????
  898.    for sprite in @enemy_sprites + @actor_sprites
  899.      sprite.dispose
  900.    end
  901.    # ?????
  902.    @weather.dispose
  903.    # ????????????
  904.    for sprite in @picture_sprites
  905.      sprite.dispose
  906.    end
  907.    # ????????????
  908.    @timer_sprite.dispose
  909.    # ?????????
  910.    @viewport1.dispose
  911.    @viewport2.dispose
  912.    @viewport3.dispose
  913.    @viewport4.dispose
  914. end
  915. #--------------------------------------------------------------------------
  916. # ? ??????????
  917. #--------------------------------------------------------------------------
  918. def effect?
  919.    # ??????????????? true ???
  920.    for sprite in @enemy_sprites + @actor_sprites
  921.      return true if sprite.effect?
  922.    end
  923.    return false
  924. end
  925. #--------------------------------------------------------------------------
  926. # ? ??????
  927. #--------------------------------------------------------------------------
  928. def update
  929.    # ???????????????????????
  930.    if @battleback_sprite != nil
  931.    if @battleback_name != $game_temp.battleback_name
  932.      @battleback_name = $game_temp.battleback_name
  933.      if @battleback_sprite.bitmap != nil
  934.        @battleback_sprite.bitmap.dispose
  935.      end
  936.      bg_bitmap = RPG::Cache.battleback(@battleback_name)
  937.      bg_bitmap_stretch = Bitmap.new(640, 480)
  938.      bg_bitmap_stretch.stretch_blt(Rect.new(0, 0, 640, 480), bg_bitmap, bg_bitmap.rect)
  939.      @battleback_sprite.bitmap = bg_bitmap_stretch
  940.    end
  941.    end
  942.    if @tilemap != nil
  943.    @tilemap.ox = $game_map.display_x / 4
  944.    @tilemap.oy = $game_map.display_y / 4
  945.    @tilemap.update
  946.    end
  947.    # ????????????
  948.    for sprite in @enemy_sprites + @actor_sprites
  949.      sprite.update
  950.    end
  951.    # ???????????
  952.    @weather.type = $game_screen.weather_type
  953.    @weather.max = $game_screen.weather_max
  954.    @weather.update
  955.    # ????????????
  956.    for sprite in @picture_sprites
  957.      sprite.update
  958.    end
  959.    # ????????????
  960.    @timer_sprite.update
  961.    # ???????????????
  962.    @viewport1.tone = $game_screen.tone
  963.    @viewport1.ox = $game_screen.shake
  964.    # ????????????
  965.    @viewport4.color = $game_screen.flash_color
  966.    # ?????????
  967.    @viewport1.update
  968.    @viewport2.update
  969.    @viewport4.update
  970. end
  971. end
  972.  
  973. #==============================================================================
  974. # ¦ Window_Command
  975. #------------------------------------------------------------------------------
  976. #  ?????????????????????
  977. #==============================================================================
  978.  
  979. class Window_Command < Window_Selectable
  980. #--------------------------------------------------------------------------
  981. # ? ?????????
  982. #     width    : ???????
  983. #     commands : ??????????
  984. #--------------------------------------------------------------------------
  985. def initialize(width, commands, column_max = 1, style = 0, inf_scroll = 1)
  986.    # ????????????????????
  987.    super(0, 0, width, (commands.size * 1.0 / column_max).ceil * 32 + 32)
  988.    @inf_scroll = inf_scroll
  989.    @item_max = commands.size
  990.    @commands = commands
  991.    @column_max = column_max
  992.    @style = style
  993.    self.contents = Bitmap.new(width - 32, (@item_max * 1.0 / @column_max).ceil * 32)
  994.    self.contents.font.name = "Tahoma"
  995.    self.contents.font.size = 22
  996.    refresh
  997.    self.index = 0
  998. end
  999. #--------------------------------------------------------------------------
  1000. # ? ??????
  1001. #--------------------------------------------------------------------------
  1002. def refresh
  1003.    self.contents.clear
  1004.    for i in 0...@item_max
  1005.      draw_item(i, normal_color)
  1006.    end
  1007. end
  1008. #--------------------------------------------------------------------------
  1009. # ? ?????
  1010. #     index : ????
  1011. #     color : ???
  1012. #--------------------------------------------------------------------------
  1013. def draw_item(index, color)
  1014.    self.contents.font.color = color
  1015.    rect = Rect.new(index%@column_max * (self.width / @column_max) + 4, 32 * (index/@column_max), self.width / @column_max - 40, 32)
  1016.    self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
  1017.    self.contents.draw_text(rect, @commands[index], @style)
  1018. end
  1019. #--------------------------------------------------------------------------
  1020. # ? ??????
  1021. #     index : ????
  1022. #--------------------------------------------------------------------------
  1023. def disable_item(index)
  1024.    draw_item(index, disabled_color)
  1025. end
  1026.  
  1027. def update_help
  1028.    @help_window.set_actor($game_party.actors[$scene.actor_index])
  1029. end
  1030. end
  1031.  
  1032. #==============================================================================
  1033. # ¦ Arrow_Enemy
  1034. #------------------------------------------------------------------------------
  1035. #  ????????????????????????????? Arrow_Base ??
  1036. # ????????
  1037. #==============================================================================
  1038.  
  1039. class Arrow_Enemy < Arrow_Base
  1040. #--------------------------------------------------------------------------
  1041. # ? ?????????????????
  1042. #--------------------------------------------------------------------------
  1043. def enemy
  1044.    return $game_troop.enemies[@index]
  1045. end
  1046. #--------------------------------------------------------------------------
  1047. # ? ??????
  1048. #--------------------------------------------------------------------------
  1049. def update
  1050.    super
  1051.    # ???????????????????
  1052.    $game_troop.enemies.size.times do
  1053.      break if self.enemy.exist?
  1054.      @index += 1
  1055.      @index %= $game_troop.enemies.size
  1056.    end
  1057.    # ?????
  1058.    if Input.repeat?(Input::DOWN)
  1059.      $game_system.se_play($data_system.cursor_se)
  1060.      $game_troop.enemies.size.times do
  1061.        @index += 1
  1062.        @index %= $game_troop.enemies.size
  1063.        break if self.enemy.exist?
  1064.      end
  1065.    end
  1066.    # ?????
  1067.    if Input.repeat?(Input::UP)
  1068.      $game_system.se_play($data_system.cursor_se)
  1069.      $game_troop.enemies.size.times do
  1070.        @index += $game_troop.enemies.size - 1
  1071.        @index %= $game_troop.enemies.size
  1072.        break if self.enemy.exist?
  1073.      end
  1074.    end
  1075.    if Input.repeat?(Input::RIGHT)
  1076.      $game_system.se_play($data_system.cursor_se)
  1077.      $game_troop.enemies.size.times do
  1078.        @index += ((($game_troop.enemies.length) * 0.5).ceil)
  1079.        @index %= $game_troop.enemies.size
  1080.        break if self.enemy.exist?
  1081.      end
  1082.    end
  1083.    if Input.repeat?(Input::LEFT)
  1084.      $game_system.se_play($data_system.cursor_se)
  1085.      $game_troop.enemies.size.times do
  1086.        @index += $game_troop.enemies.size - ((($game_troop.enemies.length) * 0.5).ceil)
  1087.        @index %= $game_troop.enemies.size
  1088.        break if self.enemy.exist?
  1089.      end
  1090.    end
  1091.    # ???????????
  1092.    if self.enemy != nil
  1093.      self.x = self.enemy.screen_x + 4
  1094.      self.y = self.enemy.screen_y + 36
  1095.      self.z = self.enemy.screen_z + 1
  1096.    end
  1097. end
  1098. #--------------------------------------------------------------------------
  1099. # ? ?????????
  1100. #--------------------------------------------------------------------------
  1101. def update_help
  1102.    # ????????????????????????
  1103.    @help_window.set_enemy(self.enemy)
  1104. end
  1105. end
  1106.  
  1107. #==============================================================================
  1108. # ¦ Arrow_Actor
  1109. #------------------------------------------------------------------------------
  1110. #  ????????????????????????????? Arrow_Base ??
  1111. # ????????
  1112. #==============================================================================
  1113.  
  1114. class Arrow_Actor < Arrow_Base
  1115. #--------------------------------------------------------------------------
  1116. # ? ?????????????????
  1117. #--------------------------------------------------------------------------
  1118. def actor
  1119.    return $game_party.actors[@index]
  1120. end
  1121. #--------------------------------------------------------------------------
  1122. # ? ??????
  1123. #--------------------------------------------------------------------------
  1124. def update
  1125.    super
  1126.    # ?????
  1127.    if Input.repeat?(Input::DOWN)
  1128.      $game_system.se_play($data_system.cursor_se)
  1129.      @index += 1
  1130.      @index %= $game_party.actors.size
  1131.    end
  1132.    # ?????
  1133.    if Input.repeat?(Input::UP)
  1134.      $game_system.se_play($data_system.cursor_se)
  1135.      @index += $game_party.actors.size - 1
  1136.      @index %= $game_party.actors.size
  1137.    end
  1138.    if Input.repeat?(Input::RIGHT)
  1139.      $game_system.se_play($data_system.cursor_se)
  1140.      @index += ($game_party.actors.length * 0.5).ceil
  1141.      @index %= $game_party.actors.size
  1142.    end
  1143.    # ?????
  1144.    if Input.repeat?(Input::LEFT)
  1145.      $game_system.se_play($data_system.cursor_se)
  1146.      @index += $game_party.actors.size - (($game_party.actors.length * 0.5).ceil)
  1147.      @index %= $game_party.actors.size
  1148.    end
  1149.    # ???????????
  1150.    if self.actor != nil
  1151.      self.x = self.actor.screen_x
  1152.      self.y = self.actor.screen_y + 36
  1153.      self.z = self.actor.screen_z + 1
  1154.    end
  1155. end
  1156. #--------------------------------------------------------------------------
  1157. # ? ?????????
  1158. #--------------------------------------------------------------------------
  1159. def update_help
  1160.    # ??????????????????????
  1161.    @help_window.set_actor(self.actor)
  1162. end
  1163. end
  1164.  
  1165. class Scene_Battle
  1166. attr_accessor :actor_index
  1167. def main
  1168.    # ???????????????
  1169.    $game_temp.in_battle = true
  1170.    $game_temp.battle_turn = 0
  1171.    $game_temp.battle_event_flags.clear
  1172.    $game_temp.battle_abort = false
  1173.    $game_temp.battle_main_phase = false
  1174.    $game_temp.battleback_name = $game_map.battleback_name
  1175.    $game_temp.forcing_battler = nil
  1176.    # ??????????????????
  1177.    $game_system.battle_interpreter.setup(nil, 0)
  1178.    # ???????
  1179.    @troop_id = $game_temp.battle_troop_id
  1180.    $game_troop.setup(@troop_id)
  1181.    # ????????????????
  1182.    s1 = $data_system.words.attack
  1183.       s1 = $data_system.words.attack
  1184.    s2 = $data_system.words.skill
  1185.    s3 = $data_system.words.guard
  1186.    s4 = $data_system.words.item
  1187.    @actor_command_window = Window_Command.new(640, [s1, s2, s3, s4], 4)
  1188.    @actor_command_window.y = 64
  1189.    @actor_command_window.back_opacity = 160
  1190.    @actor_command_window.active = false
  1191.    @actor_command_window.visible = false
  1192.    # ????????????
  1193.    @party_command_window = Window_PartyCommand.new
  1194.    @help_window = Window_Help.new
  1195.    @help_window.back_opacity = 160
  1196.    @help_window.visible = false
  1197.    #@status_window = Window_BattleStatus.new
  1198.    @message_window = Window_Message.new
  1199.    # ???????????
  1200.    @spriteset = Spriteset_Battle.new
  1201.    # ????????????
  1202.    @wait_count = 0
  1203.    # ?????????
  1204.    if $data_system.battle_transition == ""
  1205.      Graphics.transition(20)
  1206.    else
  1207.      Graphics.transition(40, "Graphics/Transitions/" +
  1208.        $data_system.battle_transition)
  1209.    end
  1210.    # ???????????
  1211.    start_phase1
  1212.    # ??????
  1213.    loop do
  1214.      # ????????
  1215.      Graphics.update
  1216.      # ???????
  1217.      Input.update
  1218.      # ??????
  1219.      update
  1220.      # ????????????????
  1221.      if $scene != self
  1222.        break
  1223.      end
  1224.    end
  1225.    # ??????????
  1226. $game_map.refresh
  1227.    # ?????????
  1228.    Graphics.freeze
  1229.    # ????????
  1230.    @actor_command_window.dispose
  1231.    @party_command_window.dispose
  1232.    @help_window.dispose
  1233.    #@status_window.dispose
  1234.    @message_window.dispose
  1235.    if @skill_window != nil
  1236.      @skill_window.dispose
  1237.    end
  1238.    if @item_window != nil
  1239.      @item_window.dispose
  1240.    end
  1241.    if @result_window != nil
  1242.      @result_window.dispose
  1243.    end
  1244.    # ???????????
  1245.    @spriteset.dispose
  1246.    # ???????????????
  1247.    if $scene.is_a?(Scene_Title)
  1248.      # ??????????
  1249.      Graphics.transition
  1250.      Graphics.freeze
  1251.    end
  1252.    # ???????????????????????????
  1253.    if $BTEST and not $scene.is_a?(Scene_Gameover)
  1254.      $scene = nil
  1255.    end
  1256. end
  1257.  
  1258. def update
  1259.    # ?????????????
  1260.    if $game_system.battle_interpreter.running?
  1261.      # ?????????
  1262.      $game_system.battle_interpreter.update
  1263.      # ?????????????????????????
  1264.      if $game_temp.forcing_battler == nil
  1265.        # ?????????????????
  1266.        unless $game_system.battle_interpreter.running?
  1267.          # ??????????????????????????
  1268.          unless judge
  1269.            setup_battle_event
  1270.          end
  1271.        end
  1272.        # ????????????????
  1273.        if @phase != 5
  1274.          # ?????????????????
  1275.          #@status_window.refresh
  1276.        end
  1277.      end
  1278.    end
  1279.    # ???? (????)??????
  1280.    $game_system.update
  1281.    $game_screen.update
  1282.    # ????? 0 ??????
  1283.    if $game_system.timer_working and $game_system.timer == 0
  1284.      # ?????
  1285.      $game_temp.battle_abort = true
  1286.    end
  1287.    # ????????
  1288.    @help_window.update
  1289.    @party_command_window.update
  1290.    @actor_command_window.update
  1291.    #@status_window.update
  1292.    @message_window.update
  1293.    # ???????????
  1294.    @spriteset.update
  1295.    # ?????????????
  1296.    if $game_temp.transition_processing
  1297.      # ?????????????????
  1298.      $game_temp.transition_processing = false
  1299.      # ?????????
  1300.      if $game_temp.transition_name == ""
  1301.        Graphics.transition(20)
  1302.      else
  1303.        Graphics.transition(40, "Graphics/Transitions/" +
  1304.          $game_temp.transition_name)
  1305.      end
  1306.    end
  1307.    # ????????????????
  1308.    if $game_temp.message_window_showing
  1309.      return
  1310.    end
  1311.    # ???????????
  1312.    if @spriteset.effect?
  1313.      return
  1314.    end
  1315.    # ??????????
  1316.    if $game_temp.gameover
  1317.      # ??????????????
  1318.      $scene = Scene_Gameover.new
  1319.      return
  1320.    end
  1321.    # ???????????
  1322.    if $game_temp.to_title
  1323.      # ???????????
  1324.      $scene = Scene_Title.new
  1325.      return
  1326.    end
  1327.    # ????????
  1328.    if $game_temp.battle_abort
  1329.      # ??????? BGM ???
  1330.      $game_system.bgm_play($game_temp.map_bgm)
  1331.      # ?????
  1332.      battle_end(1)
  1333.      return
  1334.    end
  1335.    # ????????
  1336.    if @wait_count > 0
  1337.      # ????????????
  1338.      @wait_count -= 1
  1339.      return
  1340.    end
  1341.  
  1342.    # this one holds the battle while the player moves
  1343.    for actor in @spriteset.actor_sprites
  1344.      if actor.moving
  1345.        return
  1346.      end
  1347.    end
  1348.    # and this one is for the enemy...
  1349.    for enemy in @spriteset.enemy_sprites
  1350.      if enemy.moving# and $game_system.animated_enemy
  1351.        return
  1352.      end
  1353.    end
  1354.    # ???????????????????????
  1355.    # ????????????????
  1356.    if $game_temp.forcing_battler == nil and
  1357.       $game_system.battle_interpreter.running?
  1358.      return
  1359.    end
  1360.    # ??????????
  1361.    case @phase
  1362.    when 1  # ?????????
  1363.      update_phase1
  1364.    when 2  # ????????????
  1365.      update_phase2
  1366.    when 3  # ????????????
  1367.      update_phase3
  1368.    when 4  # ???????
  1369.      update_phase4
  1370.    when 5  # ???????????
  1371.      update_phase5
  1372.    end
  1373. end
  1374.  
  1375. def start_phase2
  1376.    # ???? 2 ???
  1377.    @phase = 2
  1378.    # ?????????????
  1379.    @actor_index = -1
  1380.    @active_battler = nil
  1381.    # ?????????????????
  1382.    @party_command_window.active = true
  1383.    @party_command_window.visible = true
  1384.    # ?????????????????
  1385.    @actor_command_window.active = false
  1386.    @actor_command_window.visible = false
  1387.    @help_window.visible = false
  1388.    # ??????????????
  1389.    $game_temp.battle_main_phase = false
  1390.    # ????????????????
  1391.    $game_party.clear_actions
  1392.    # ????????????
  1393.    unless $game_party.inputable?
  1394.      # ?????????
  1395.      start_phase4
  1396.    end
  1397. end
  1398.  
  1399. def update_phase2_escape
  1400.    # ??????????????
  1401.    enemies_agi = 0
  1402.    enemies_number = 0
  1403.    for enemy in $game_troop.enemies
  1404.      if enemy.exist?
  1405.        enemies_agi += enemy.agi
  1406.        enemies_number += 1
  1407.      end
  1408.    end
  1409.    if enemies_number > 0
  1410.      enemies_agi /= enemies_number
  1411.    end
  1412.    # ??????????????
  1413.    actors_agi = 0
  1414.    actors_number = 0
  1415.    for actor in $game_party.actors
  1416.      if actor.exist?
  1417.        actors_agi += actor.agi
  1418.        actors_number += 1
  1419.      end
  1420.    end
  1421.    if actors_number > 0
  1422.      actors_agi /= actors_number
  1423.    end
  1424.    # ??????
  1425.    success = rand(100) < 50 * actors_agi / enemies_agi
  1426.    # ???????
  1427.    if success
  1428.      # ?? SE ???
  1429.      $game_system.se_play($data_system.escape_se)
  1430.        for actor in $game_party.actors
  1431.          @spriteset.actor_sprites[actor.index].pose(2)
  1432.          @spriteset.actor_sprites[actor.index].move(660, actor.screen_y, 10)
  1433.        end
  1434.        check = escape_move
  1435.      until check == false
  1436.        @spriteset.update
  1437.        Graphics.update
  1438.        check = escape_move
  1439.      end
  1440.      # ??????? BGM ???
  1441.      $game_system.bgm_play($game_temp.map_bgm)
  1442.      # ?????
  1443.      battle_end(1)
  1444.    # ???????
  1445.    else
  1446.      # ????????????????
  1447.      $game_party.clear_actions
  1448.      # ?????????
  1449.      start_phase4
  1450.    end
  1451. end
  1452.  
  1453. def escape_move
  1454.    for actor in @spriteset.actor_sprites
  1455.      if actor.moving
  1456.        return true
  1457.      end
  1458.    end
  1459.    return false
  1460. end
  1461.  
  1462. def start_phase5
  1463.    # ???? 5 ???
  1464.    @phase = 5
  1465.    # ????? ME ???
  1466.    $game_system.me_play($game_system.battle_end_me)
  1467.    # ??????? BGM ???
  1468.    $game_system.bgm_play($game_temp.map_bgm)
  1469.    # EXP???????????????
  1470.    exp = 0
  1471.    gold = 0
  1472.    treasures = []
  1473.    # ???
  1474.    for enemy in $game_troop.enemies
  1475.      # ??????????????
  1476.      unless enemy.hidden
  1477.        # ?? EXP????????
  1478.        exp += enemy.exp
  1479.        gold += enemy.gold
  1480.        # ?????????
  1481.        if rand(100) < enemy.treasure_prob
  1482.          if enemy.item_id > 0
  1483.            treasures.push($data_items[enemy.item_id])
  1484.          end
  1485.          if enemy.weapon_id > 0
  1486.            treasures.push($data_weapons[enemy.weapon_id])
  1487.          end
  1488.          if enemy.armor_id > 0
  1489.            treasures.push($data_armors[enemy.armor_id])
  1490.          end
  1491.        end
  1492.      end
  1493.    end
  1494.    # ???????? 6 ??????
  1495.    treasures = treasures[0..5]
  1496.    # EXP ??
  1497.    for i in 0...$game_party.actors.size
  1498.      actor = $game_party.actors[i]
  1499.      if actor.cant_get_exp? == false
  1500.        last_level = actor.level
  1501.        actor.exp += exp
  1502.        if actor.level > last_level
  1503.          #@status_window.level_up(i)
  1504.        end
  1505.      end
  1506.    end
  1507.    # ??????
  1508.    $game_party.gain_gold(gold)
  1509.    # ???????
  1510.    for item in treasures
  1511.      case item
  1512.      when RPG::Item
  1513.        $game_party.gain_item(item.id, 1)
  1514.      when RPG::Weapon
  1515.        $game_party.gain_weapon(item.id, 1)
  1516.      when RPG::Armor
  1517.        $game_party.gain_armor(item.id, 1)
  1518.      end
  1519.    end
  1520.    # ???????????????
  1521.    @result_window = Window_BattleResult.new(exp, gold, treasures)
  1522.    # ???????????
  1523.    @phase5_wait_count = 100
  1524. end
  1525.  
  1526. #--------------------------------------------------------------------------
  1527. # ? ?????? (???????????)
  1528. #--------------------------------------------------------------------------
  1529. def update_phase5
  1530.    # ????????? 0 ???????
  1531.    if @phase5_wait_count > 0
  1532.      # ????????????
  1533.      @phase5_wait_count -= 1
  1534.      # ????????? 0 ??????
  1535.      if @phase5_wait_count == 0
  1536.        # ????????????
  1537.        @result_window.visible = true
  1538.        # ??????????????
  1539.        $game_temp.battle_main_phase = false
  1540.        # ?????????????????
  1541.        #@status_window.refresh
  1542.      end
  1543.      return
  1544.    end
  1545.    # C ??????????
  1546.    if Input.trigger?(Input::C)
  1547.      # ?????
  1548.      battle_end(0)
  1549.    end
  1550. end
  1551.  
  1552. def phase3_setup_command_window
  1553.    # ?????????????????
  1554.    @party_command_window.active = false
  1555.    @party_command_window.visible = false
  1556.    # ?????????????????
  1557.    @actor_command_window.active = true
  1558.    @actor_command_window.visible = true
  1559.    @help_window.visible = true
  1560.    # ???????????????????
  1561.    if @actor_command_window.help_window == nil
  1562.      @actor_command_window.help_window = @help_window
  1563.    end
  1564.    @actor_command_window.update_help    
  1565.    #@actor_command_window.x = @actor_index * 160
  1566.    # ??????? 0 ???
  1567.    @actor_command_window.index = 0
  1568. end
  1569. def start_enemy_select
  1570.    # ??????????
  1571.    @enemy_arrow = Arrow_Enemy.new(@spriteset.viewport2)
  1572.    # ?????????????
  1573.    @enemy_arrow.help_window = @help_window
  1574.    # ?????????????????
  1575.    @actor_command_window.active = false
  1576.    @actor_command_window.visible = false
  1577. end
  1578.  
  1579. def update_phase4
  1580.    case @phase4_step
  1581.    when 1
  1582.      update_phase4_step1
  1583.    when 2
  1584.      update_phase4_step2
  1585.    when 3
  1586.      update_phase4_step3
  1587.    when 4
  1588.      update_phase4_step4
  1589.    when 5
  1590.      update_phase4_step5
  1591.    when 6
  1592.      update_phase4_step6
  1593.    when 7
  1594.      update_phase4_step7
  1595.    end    
  1596. end
  1597.  
  1598. def update_phase4_step1
  1599.  
  1600.    # Change actor poses to default
  1601.    #if @active_battler.is_a?(Game_Actor)
  1602.    #  @spriteset.actor_sprites[@active_battler.index].default_pose
  1603.    #end
  1604.    for i in 0...$game_party.actors.size
  1605.      actor = $game_party.actors[i]
  1606.      @spriteset.actor_sprites[i].default_pose
  1607.    end
  1608.  
  1609.    @help_window.visible = false
  1610.    if judge
  1611.      return
  1612.    end
  1613.    if $game_temp.forcing_battler == nil
  1614.      setup_battle_event
  1615.      if $game_system.battle_interpreter.running?
  1616.        return
  1617.      end
  1618.    end
  1619.    if $game_temp.forcing_battler != nil
  1620.      @action_battlers.delete($game_temp.forcing_battler)
  1621.      @action_battlers.unshift($game_temp.forcing_battler)
  1622.    end
  1623.    if @action_battlers.size == 0
  1624.      start_phase2
  1625.      return
  1626.    end
  1627.    @animation1_id = 0
  1628.    @animation2_id = 0
  1629.    @common_event_id = 0
  1630.    @active_battler = @action_battlers.shift
  1631.    if @active_battler.index == nil
  1632.      return
  1633.    end
  1634.    if @active_battler.hp > 0 and @active_battler.slip_damage?
  1635.      @active_battler.slip_damage_effect
  1636.      @active_battler.damage_pop = true
  1637.    end
  1638.    @active_battler.remove_states_auto
  1639.    #@status_window.refresh
  1640.    @phase4_step = 2
  1641. end
  1642.  
  1643. def make_basic_action_result
  1644.  
  1645.    if @active_battler.is_a?(Game_Actor)
  1646.      $actor_on_top = true
  1647.    elsif @active_battler.is_a?(Game_Enemy)
  1648.      $actor_on_top = false
  1649.    end
  1650.    if @active_battler.current_action.basic == 0
  1651.      @animation1_id = @active_battler.animation1_id
  1652.      @animation2_id = @active_battler.animation2_id
  1653.      if @active_battler.is_a?(Game_Enemy)
  1654.        if @active_battler.restriction == 3
  1655.          target = $game_troop.random_target_enemy
  1656.        elsif @active_battler.restriction == 2
  1657.          target = $game_party.random_target_actor
  1658.        else
  1659.          index = @active_battler.current_action.target_index
  1660.          target = $game_party.smooth_target_actor(index)
  1661.        end
  1662. #======== here is the setting for the movement & animation...
  1663.          x = target.screen_x - 32
  1664.          @spriteset.enemy_sprites[@active_battler.index].enemy_pose(2)
  1665.          @spriteset.enemy_sprites[@active_battler.index].move(x, target.screen_y, 10)
  1666. #========= here if you look at the RPG's movement settings you'll see
  1667. #========= that he takes the number 40 for the speed of the animation...
  1668. #========= i thing thats too fast so i settet it down to 10 so looks smoother...
  1669.      end
  1670.      if @active_battler.is_a?(Game_Actor)
  1671.        weapon = $data_weapons[@active_battler.weapon_id]
  1672.        range = false
  1673.        if weapon != nil
  1674.          for id in weapon.element_set
  1675.            if $data_system.elements[23] == "Range"
  1676.              range = true
  1677.              break
  1678.            end
  1679.          end
  1680.        end
  1681.        if @active_battler.restriction == 3
  1682.          target = $game_party.random_target_actor
  1683.        elsif @active_battler.restriction == 2
  1684.          target = $game_troop.random_target_enemy
  1685.        else
  1686.          index = @active_battler.current_action.target_index
  1687.          target = $game_troop.smooth_target_enemy(index)
  1688.        end
  1689. #======= the same thing for the player... ^-^
  1690.        x = target.screen_x + 32
  1691.        @spriteset.actor_sprites[@active_battler.index].pose(1)
  1692.        @spriteset.actor_sprites[@active_battler.index].move(x * (range ? 2 : 1), target.screen_y, 10)
  1693.        range = false
  1694.      end
  1695.      @target_battlers = [target]
  1696.      for target in @target_battlers
  1697.        target.attack_effect(@active_battler)
  1698.      end
  1699.      return
  1700.    end
  1701.    if @active_battler.current_action.basic == 1
  1702.      if @active_battler.is_a?(Game_Actor)
  1703.        @spriteset.actor_sprites[@active_battler.index].pose(0, 1) #defence
  1704.      else
  1705.        @spriteset.enemy_sprites[@active_battler.index].enemy_pose(0, 1) #defence
  1706.      end
  1707.      @help_window.set_text($data_system.words.guard, 1)
  1708.      return
  1709.    end
  1710.    if @active_battler.is_a?(Game_Enemy) and
  1711.       @active_battler.current_action.basic == 2
  1712.      @help_window.set_text("Escape", 1)
  1713.      @active_battler.escape
  1714.      return
  1715.    end
  1716.    if @active_battler.current_action.basic == 3
  1717.      $game_temp.forcing_battler = nil
  1718.      @phase4_step = 1
  1719.      return
  1720.    end
  1721.  
  1722.    if @active_battler.current_action.basic == 4
  1723.      if $game_temp.battle_can_escape == false
  1724.        $game_system.se_play($data_system.buzzer_se)
  1725.        return
  1726.      end
  1727.      $game_system.se_play($data_system.decision_se)
  1728.      update_phase2_escape
  1729.      return
  1730.    end
  1731. end
  1732.  
  1733. def make_skill_action_result
  1734.  
  1735.    @skill = $data_skills[@active_battler.current_action.skill_id]
  1736.    unless @active_battler.current_action.forcing
  1737.      unless @active_battler.skill_can_use?(@skill.id)
  1738.        $game_temp.forcing_battler = nil
  1739.        @phase4_step = 1
  1740.        return
  1741.      end
  1742.    end
  1743.    @active_battler.sp -= @skill.sp_cost
  1744.    #@status_window.refresh
  1745.    @help_window.set_text(@skill.name, 1)
  1746.    @animation1_id = @skill.animation1_id
  1747.    @animation2_id = @skill.animation2_id
  1748.      if @active_battler.is_a?(Game_Enemy)
  1749.          #@spriteset.enemy_sprites[@active_battler.index].change_sp_bar
  1750.           x = @active_battler.screen_x + 48
  1751.          @spriteset.enemy_sprites[@active_battler.index].enemy_pose(2)
  1752.          @spriteset.enemy_sprites[@active_battler.index].move(x, @active_battler.screen_y, 5)
  1753.          @spriteset.enemy_sprites[@active_battler.index].enemy_pose(0, 1)
  1754.      end
  1755.      if @active_battler.is_a?(Game_Actor)
  1756.        #@spriteset.actor_sprites[@active_battler.index].change_sp_bar
  1757.        x = @active_battler.screen_x - 48
  1758.        @spriteset.actor_sprites[@active_battler.index].pose(1)
  1759.        @spriteset.actor_sprites[@active_battler.index].move(x, @active_battler.screen_y, 5)
  1760.        @spriteset.actor_sprites[@active_battler.index].pose(0, 1)
  1761.      end
  1762.    @common_event_id = @skill.common_event_id
  1763.    set_target_battlers(@skill.scope)
  1764.    for target in @target_battlers
  1765.      target.skill_effect(@active_battler, @skill)
  1766.    end
  1767. end
  1768.  
  1769.    def make_item_action_result
  1770.  
  1771.    # sorry i didnt work on this...
  1772.    # couse i dont have a sprite that uses items....
  1773.    # so i just added the standby sprite here...
  1774.    # when i get more time for this i'll try what i can do for this one... ^-^
  1775.    # its the same as the ones above...
  1776.    if @active_battler.is_a?(Game_Actor)
  1777.      @spriteset.actor_sprites[@active_battler.index].pose(0, 1)
  1778.    else
  1779.      @spriteset.enemy_sprites[@active_battler.index].enemy_pose(0, 1)
  1780.    end
  1781.  
  1782.    @item = $data_items[@active_battler.current_action.item_id]
  1783.    unless $game_party.item_can_use?(@item.id)
  1784.      @phase4_step = 1
  1785.      return
  1786.    end
  1787.    if @item.consumable
  1788.      $game_party.lose_item(@item.id, 1)
  1789.    end
  1790.    @help_window.set_text(@item.name, 1)
  1791.    @animation1_id = @item.animation1_id
  1792.    @animation2_id = @item.animation2_id
  1793.    @common_event_id = @item.common_event_id
  1794.    index = @active_battler.current_action.target_index
  1795.    target = $game_party.smooth_target_actor(index)
  1796.    set_target_battlers(@item.scope)
  1797.    for target in @target_battlers
  1798.      target.item_effect(@item)
  1799.    end
  1800. end
  1801.  
  1802. def update_phase4_step3
  1803.    if @active_battler.current_action.kind == 0 and
  1804.       @active_battler.current_action.basic == 0
  1805.       # in this one... we have our weapon animations... for player and monster
  1806.      if @active_battler.is_a?(Game_Actor)
  1807.        @spriteset.actor_sprites[@active_battler.index].pose(0,1)
  1808.      elsif @active_battler.is_a?(Game_Enemy)
  1809.        @spriteset.enemy_sprites[@active_battler.index].enemy_pose(0,1)
  1810.      end
  1811.    end
  1812.    if @animation1_id == 1
  1813.      @active_battler.white_flash = true
  1814.    else
  1815.      @active_battler.animation_id = @animation1_id
  1816.      @active_battler.animation_hit = true
  1817.    end
  1818.    @phase4_step = 4
  1819. end
  1820.  
  1821. def update_phase4_step4
  1822.    # this here is for the hit animation...
  1823.    for target in @target_battlers
  1824.      target.animation_id = @animation2_id
  1825.      target.animation_hit = (target.damage != "Miss")
  1826.    end
  1827.    @wait_count = 8
  1828.    @phase4_step = 5
  1829. end
  1830.  
  1831. def update_phase4_step5
  1832.    if @active_battler.hp > 0 and @active_battler.slip_damage?
  1833.      @active_battler.slip_damage_effect
  1834.      @active_battler.damage_pop = true
  1835.    end
  1836.    # ???????????
  1837.    @help_window.visible = false
  1838.    # ?????????????????
  1839.    #@status_window.refresh
  1840.    # ??????
  1841.  
  1842.    if @active_battler.is_a?(Game_Actor)
  1843.      @spriteset.actor_sprites[@active_battler.index].pose(0, 1)
  1844.    else
  1845.      @spriteset.enemy_sprites[@active_battler.index].enemy_pose(0, 1)
  1846.    end
  1847.    for target in @target_battlers
  1848.      if target.damage != nil
  1849.        target.damage_pop = true
  1850.        if @active_battler.is_a?(Game_Actor)
  1851.          @spriteset.actor_sprites[@active_battler.index].pose(0, 1)
  1852.        else
  1853.          @spriteset.enemy_sprites[@active_battler.index].enemy_pose(0, 1)
  1854.        end
  1855.      end
  1856.    end
  1857.    # ???? 6 ???
  1858.    @phase4_step = 6
  1859. end
  1860.  
  1861. def update_phase4_step6
  1862.  
  1863.    # here we are asking if the player is dead and is a player or an enemy...
  1864.    # these lines are for the running back and standby animation....
  1865.    if @active_battler.is_a?(Game_Actor)
  1866.      if @active_battler.current_action.basic == 1
  1867.        @spriteset.actor_sprites[@active_battler.index].pose(0, 1)
  1868.      else
  1869.        @spriteset.actor_sprites[@active_battler.index].move(@active_battler.screen_x, @active_battler.screen_y, 20)
  1870.        @spriteset.actor_sprites[@active_battler.index].pose(2)
  1871.      end
  1872.    else
  1873.      if @active_battler.current_action.basic == 1
  1874.        @spriteset.enemy_sprites[@active_battler.index].enemy_pose(0, 1)
  1875.      else
  1876.        @spriteset.enemy_sprites[@active_battler.index].move(@active_battler.screen_x, @active_battler.screen_y, 20)
  1877.        @spriteset.enemy_sprites[@active_battler.index].enemy_pose(1)
  1878.      end
  1879.    end
  1880.    for target in @target_battlers
  1881.      if target.is_a?(Game_Actor)
  1882.          @spriteset.actor_sprites[target.index].pose(0, 1)
  1883.        else
  1884.          @spriteset.enemy_sprites[target.index].enemy_pose(0, 1)
  1885.      end
  1886.    end
  1887.    $game_temp.forcing_battler = nil
  1888.    if @common_event_id > 0
  1889.      common_event = $data_common_events[@common_event_id]
  1890.      $game_system.battle_interpreter.setup(common_event.list, 0)
  1891.    end
  1892.    @phase4_step = 7
  1893. end
  1894.  
  1895. def update_phase4_step7
  1896.  
  1897.    # here we are asking if the player is dead and is a player or an enemy...
  1898.    # these lines are for the running back and standby animation....
  1899.    if @active_battler.is_a?(Game_Actor)
  1900.      @spriteset.actor_sprites[@active_battler.index].pose(0, 1)
  1901.    else
  1902.      @spriteset.enemy_sprites[@active_battler.index].enemy_pose(0, 1)
  1903.    end
  1904.  
  1905.    $game_temp.forcing_battler = nil
  1906.    if @common_event_id > 0
  1907.      common_event = $data_common_events[@common_event_id]
  1908.      $game_system.battle_interpreter.setup(common_event.list, 0)
  1909.    end
  1910.    @phase4_step = 1
  1911. end
  1912. end
Expand to see the code.

Original thread: https://www.hbgames.org/forums/viewtopic.php?t=76768