I need help with my show the enemy stats script in battle.

My script works very normally, showing the stats are correct. But, when I started to attack enemies, both sides didn't do anything. Please help me.


Screenshot_39.png
Screenshot_40.png



This is my script
Ruby:
class Window_EnemyStatus < Window_Base
  def initialize(x, y)
    super(x, y, window_width, fitting_height(8))
    @enemy = nil
    refresh
  end

  def window_width
    return 200
  end

  def set_enemy(enemy)
    @enemy = enemy
    refresh
  end

  def refresh
    contents.clear
    return unless @enemy
    draw_enemy_name
    draw_enemy_stats
  end

  def draw_enemy_name
    draw_text(0, 0, contents.width, line_height, @enemy.name)
  end

  def draw_enemy_stats
    draw_text(0, line_height * 1, contents.width, line_height, "HP: #{@enemy.hp}")
    draw_text(0, line_height * 2, contents.width, line_height, "MP: #{@enemy.mp}")
    draw_text(0, line_height * 3, contents.width, line_height, "ATK: #{@enemy.atk}")
    draw_text(0, line_height * 4, contents.width, line_height, "DEF: #{@enemy.def}")
    draw_text(0, line_height * 5, contents.width, line_height, "MAT: #{@enemy.mat}")
    draw_text(0, line_height * 6, contents.width, line_height, "MDF: #{@enemy.mdf}")
    draw_text(0, line_height * 7, contents.width, line_height, "AGI: #{@enemy.agi}")
    draw_text(0, line_height * 8, contents.width, line_height, "LUK: #{@enemy.luk}")
  end
end

#==============================================================================
# ** Scene_Battle
#------------------------------------------------------------------------------
#  This class performs the battle screen processing.
#==============================================================================

class Scene_Battle < Scene_Base
  alias_method :start_with_enemy_status, :start

  def start
    start_with_enemy_status
    create_enemy_status_window
  end

  def create_enemy_status_window
    @enemy_status_window = Window_EnemyStatus.new(Graphics.width - 200, 0)
    @enemy_status_window.openness = 0
    @enemy_status_window.close
    @enemy_status_window.deactivate
    @enemy_status_visible = false
  end

  def update
    super
    update_enemy_status_window if Input.trigger?(Input::SHIFT)
  end

  def update_enemy_status_window
    if @enemy_status_visible
      @enemy_status_window.close
      @enemy_status_window.deactivate
      @enemy_status_visible = false
    else
      if @enemy_window.active && !@enemy_window.enemy.nil?
        @enemy_status_window.open
        @enemy_status_window.activate
        @enemy_status_window.set_enemy($game_troop.alive_members[@enemy_window.index])
        @enemy_status_visible = true
      end
    end
  end

  def terminate
    super
    @enemy_status_window.dispose if @enemy_status_window
  end
end
You overwrote two methods instead of aliasing them
Ruby:
class Window_EnemyStatus < Window_Base
  def initialize(x, y)
    super(x, y, window_width, fitting_height(8))
    @enemy = nil
    refresh
  end

  def window_width
    return 200
  end

  def set_enemy(enemy)
    @enemy = enemy
    refresh
  end

  def refresh
    contents.clear
    return unless @enemy
    draw_enemy_name
    draw_enemy_stats
  end

  def draw_enemy_name
    draw_text(0, 0, contents.width, line_height, @enemy.name)
  end

  def draw_enemy_stats
    draw_text(0, line_height * 1, contents.width, line_height, "HP: #{@enemy.hp}")
    draw_text(0, line_height * 2, contents.width, line_height, "MP: #{@enemy.mp}")
    draw_text(0, line_height * 3, contents.width, line_height, "ATK: #{@enemy.atk}")
    draw_text(0, line_height * 4, contents.width, line_height, "DEF: #{@enemy.def}")
    draw_text(0, line_height * 5, contents.width, line_height, "MAT: #{@enemy.mat}")
    draw_text(0, line_height * 6, contents.width, line_height, "MDF: #{@enemy.mdf}")
    draw_text(0, line_height * 7, contents.width, line_height, "AGI: #{@enemy.agi}")
    draw_text(0, line_height * 8, contents.width, line_height, "LUK: #{@enemy.luk}")
  end
end

#==============================================================================
# ** Scene_Battle
#------------------------------------------------------------------------------
#  This class performs the battle screen processing.
#==============================================================================

class Scene_Battle < Scene_Base
  alias_method :start_with_enemy_status, :start
  alias_method :update_with_enemy_status, :update
  alias_method :terminate_with_enemy_status, :terminate

  def start
    start_with_enemy_status
    create_enemy_status_window
  end

  def create_enemy_status_window
    @enemy_status_window = Window_EnemyStatus.new(Graphics.width - 200, 0)
    @enemy_status_window.openness = 0
    @enemy_status_window.close
    @enemy_status_window.deactivate
    @enemy_status_visible = false
  end

  def update
    update_with_enemy_status
    update_enemy_status_window if Input.trigger?(Input::SHIFT)
  end

  def update_enemy_status_window
    if @enemy_status_visible
      @enemy_status_window.close
      @enemy_status_window.deactivate
      @enemy_status_visible = false
    else
      if @enemy_window.active && !@enemy_window.enemy.nil?
        @enemy_status_window.open
        @enemy_status_window.activate
        @enemy_status_window.set_enemy($game_troop.alive_members[@enemy_window.index])
        @enemy_status_visible = true
      end
    end
  end

  def terminate
    terminate_with_enemy_status
    @enemy_status_window.dispose if @enemy_status_window
  end
end
You overwrote two methods instead of aliasing them
Ruby:
class Window_EnemyStatus < Window_Base
  def initialize(x, y)
    super(x, y, window_width, fitting_height(8))
    @enemy = nil
    refresh
  end

  def window_width
    return 200
  end

  def set_enemy(enemy)
    @enemy = enemy
    refresh
  end

  def refresh
    contents.clear
    return unless @enemy
    draw_enemy_name
    draw_enemy_stats
  end

  def draw_enemy_name
    draw_text(0, 0, contents.width, line_height, @enemy.name)
  end

  def draw_enemy_stats
    draw_text(0, line_height * 1, contents.width, line_height, "HP: #{@enemy.hp}")
    draw_text(0, line_height * 2, contents.width, line_height, "MP: #{@enemy.mp}")
    draw_text(0, line_height * 3, contents.width, line_height, "ATK: #{@enemy.atk}")
    draw_text(0, line_height * 4, contents.width, line_height, "DEF: #{@enemy.def}")
    draw_text(0, line_height * 5, contents.width, line_height, "MAT: #{@enemy.mat}")
    draw_text(0, line_height * 6, contents.width, line_height, "MDF: #{@enemy.mdf}")
    draw_text(0, line_height * 7, contents.width, line_height, "AGI: #{@enemy.agi}")
    draw_text(0, line_height * 8, contents.width, line_height, "LUK: #{@enemy.luk}")
  end
end

#==============================================================================
# ** Scene_Battle
#------------------------------------------------------------------------------
#  This class performs the battle screen processing.
#==============================================================================

class Scene_Battle < Scene_Base
  alias_method :start_with_enemy_status, :start
  alias_method :update_with_enemy_status, :update
  alias_method :terminate_with_enemy_status, :terminate

  def start
    start_with_enemy_status
    create_enemy_status_window
  end

  def create_enemy_status_window
    @enemy_status_window = Window_EnemyStatus.new(Graphics.width - 200, 0)
    @enemy_status_window.openness = 0
    @enemy_status_window.close
    @enemy_status_window.deactivate
    @enemy_status_visible = false
  end

  def update
    update_with_enemy_status
    update_enemy_status_window if Input.trigger?(Input::SHIFT)
  end

  def update_enemy_status_window
    if @enemy_status_visible
      @enemy_status_window.close
      @enemy_status_window.deactivate
      @enemy_status_visible = false
    else
      if @enemy_window.active && !@enemy_window.enemy.nil?
        @enemy_status_window.open
        @enemy_status_window.activate
        @enemy_status_window.set_enemy($game_troop.alive_members[@enemy_window.index])
        @enemy_status_visible = true
      end
    end
  end

  def terminate
    terminate_with_enemy_status
    @enemy_status_window.dispose if @enemy_status_window
  end
end
oh thanks🙂

Original thread: https://forums.rpgmakerweb.com/threads/i-need-help-with-my-show-the-enemy-stats-script-in-battle.168755/