Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

[FILLED] Show Monster info - script request

I've got a small (I think) request for a script.

I've created a second battle status window that I want to show monster data in.

I want to display the data as follows:

|----------------Window-----------------|
|Monster1 Name: Monster1 HP bar |
|Monster2 Name: Monster2 HP bar |
|Monster3 Name: Monster3 HP bar |
|Monster4 Name: Monster4 HP bar |
|----------------Window-----------------|

I won't ever have more than 4 monsters in a troop.

I can do some spriting (new or edits) title screen, game over, windowskin, etc. as payment. PM me or reply if you are interested.

Here is the current script for the window:


Code:
#==============================================================================
# â–  Window_BattleEnemyStatus
#==============================================================================

class Window_BattleEnemyStatus < Window_Base
  #--------------------------------------------------------------------------
  # Initialize
  #--------------------------------------------------------------------------
  def initialize
    super(320, 320, 320, 160)
    #super (304, 270, 400, 300)
    self.contents = Bitmap.new(width - 32, height - 32)
    self.contents.font.name = "Neuropol"  # "Battle Status" window font
    self.contents.font.size = 18
    self.windowskin = RPG::Cache.windowskin(@windowskin_name)
    #Added to erase window frame
    #self.windowskin = RPG::Cache.windowskin("Empty.png")
    @level_up_flags = [false, false, false, false]
    refresh
  end
  #--------------------------------------------------------------------------
  #--------------------------------------------------------------------------
  def dispose
    super
  end
  #--------------------------------------------------------------------------
  #--------------------------------------------------------------------------
  def level_up(actor_index)
    @level_up_flags[actor_index] = true
  end
  #--------------------------------------------------------------------------
  # Refresh
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
  #monster info would be inserted here as in Window_BattleStatus
  end
  #--------------------------------------------------------------------------
  # Update
  #--------------------------------------------------------------------------
  def update
    super
    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



Thanks!
 
Just place this Script above main.
Code:
#==============================================================================
# Enemy HP Bar
# Version 1.0
# Raziel
#==============================================================================
#==============================================================================
# â–  Window_BattleEnemyStatus
#==============================================================================

class Window_BattleEnemyStatus < Window_Base
  #--------------------------------------------------------------------------
  # Initialize
  #--------------------------------------------------------------------------
  def initialize
    super(0,0, 320,160)#(320, 320, 320, 160)
    self.contents = Bitmap.new(width - 32, height - 32)
    self.contents.font.name = "Arial"#"Neuropol"  # "Battle Status" window font
    self.contents.font.size = 18
    refresh
  end
  #--------------------------------------------------------------------------
  # Refresh
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    for i in 0...$game_troop.enemies.size
      @enemy = $game_troop.enemies[i]
      y = i * 32
      unless @enemy.hp == 0
        self.contents.draw_text(4, y, 80, 32, @enemy.name.to_s)
        draw_slant_bar(100, y + 15, @enemy.hp, @enemy.maxhp, width = 150, height = 6)
      end
    end
  end
  
end

class Window_Base < Window  
  #--------------------------------------------------------------------------
  # * Draw Slant Bar(by SephirothSpawn)
  #--------------------------------------------------------------------------
  def draw_slant_bar(x, y, min, max, width = 152, height = 6,
      bar_color = Color.new(150, 0, 0, 255), end_color = Color.new(255, 255, 60, 255))
    # Draw Border
    for i in 0..height
      self.contents.fill_rect(x + i, y + height - i, width + 1, 1, Color.new(50, 50, 50, 255))
    end
    # Draw Background
    for i in 1..(height - 1)
      r = 100 * (height - i) / height + 0 * i / height
      g = 100 * (height - i) / height + 0 * i / height
      b = 100 * (height - i) / height + 0 * i / height
      a = 255 * (height - i) / height + 255 * i / height
      self.contents.fill_rect(x + i, y + height - i, width, 1, Color.new(r, b, g, a))
    end
    # Draws Bar
    for i in 1..( (min / max.to_f) * width - 1)
      for j in 1..(height - 1)
        r = bar_color.red * (width - i) / width + end_color.red * i / width
        g = bar_color.green * (width - i) / width + end_color.green * i / width
        b = bar_color.blue * (width - i) / width + end_color.blue * i / width
        a = bar_color.alpha * (width - i) / width + end_color.alpha * i / width
        self.contents.fill_rect(x + i + j, y + height - j, 1, 1, Color.new(r, g, b, a))
      end
    end
  end
end
 
class Scene_Battle
  
  alias raz_update_phase5 update_phase5
  alias raz_update_phase4_step1 update_phase4_step1
  alias raz_update_phase4_step5 update_phase4_step5
  alias raz_enemy_hp_main main
  
   def main
    @troop_id = $game_temp.battle_troop_id
    $game_troop.setup(@troop_id)
    @enemy_window = Window_BattleEnemyStatus.new
    @enemy_window.z = 95
    raz_enemy_hp_main
    @enemy_window.dispose
  end
  

  def update_phase5
    # If wait count is larger than 0
    if @phase5_wait_count > 0
      # Decrease wait count
      @phase5_wait_count -= 1
      # If wait count reaches 0
      if @phase5_wait_count == 0
        @enemy_window.visible = false
        # Show result window
        @result_window.visible = true
        # Clear main phase flag
        $game_temp.battle_main_phase = false
        # Refresh status window
        @status_window.refresh
        @enemy_window.refresh
      end
      return
    end
   raz_update_phase5
 end

def update_phase4_step1
  raz_update_phase4_step1
  @enemy_window.refresh
end

  def update_phase4_step5
    # Hide help window
    @help_window.visible = false
    # Refresh status window
    @status_window.refresh
    @enemy_window.refresh
    raz_update_phase4_step5 
  end
end
 
I figured it out (which shocks me because I stink at RGSS). You were updating with enemy_window, where I had tried to script it into the Scene_Battle(s) with enemystatus_window.

I renamed what I had done to match yours, and walla! Thanks again. I'd be happy to repay you with graphics if you'd like.

Thanks again!

EDIT: I'll be sure to credit you and SephirothSpawn in my game. Anyone else help with this?
 
Digimon Leader, this is not your request, and asking for a screen is extremely lazy. You could always *gasp* try it out and see how it looks. Like copy and pasting would take more than 20 seconds to do, that includes starting a blank project or adding it to your own.

Code:
|----------------Window-----------------|
|Monster1 Name:         Monster1 HP bar |
|Monster2 Name:         Monster2 HP bar |
|Monster3 Name:         Monster3 HP bar |
|Monster4 Name:         Monster4 HP bar |
|----------------Window-----------------|

@Raziel: Good work my friend.
 
Hey, Raziel and SephirothSpawn. . . question.

I'm not getting an error when the battle is over. It just started happening when I imported this script, so I'm thinking it might be the culprit.

The error is: "Window_Base 30 RGSS error"

"disposed window"

The error takes me to this line in Window_Base in the dispose area:

if self.contents != nil

Any thoughts?
 
Well, it got rid of the error, but now the window (show monster info) stays on screen after the battle is over. . .

I posted it at the end of Window_Base, was that correct?

Thanks again for all the help.
 
My internet is kind of slow, so I don't think a demo would work. Here are the scripts, and I'm using Cybersam. Sorry this way is kind of messy. It would take me forever to upload a demo.

Window_Base
Code:
# â–  Window_Base

class Window_Base < Window
  def initialize(x, y, width, height)
    super()
    @windowskin_name = $game_system.windowskin_name
    self.windowskin = RPG::Cache.windowskin(@windowskin_name)
    self.x = x
    self.y = y
    self.width = width
    self.height = height
    self.z = 100
  end
  
  def dispose
    if self.contents != nil
      self.contents.dispose
    end
    super
  end

  def text_color(n)
    case n
    when 0
      return Color.new(255, 255, 255, 255)
    when 1
      return Color.new(128, 128, 255, 255)
    when 2
      return Color.new(255, 128, 128, 255)
    when 3
      return Color.new(128, 255, 128, 255)
    when 4
      return Color.new(128, 255, 255, 255)
    when 5
      return Color.new(255, 128, 255, 255)
    when 6
      return Color.new(255, 255, 128, 255)
    when 7
      return Color.new(192, 192, 192, 255)
    else
      normal_color
    end
  end

  def normal_color
    return Color.new(255, 255, 255, 255)
  end

  def disabled_color
    return Color.new(255, 255, 255, 128)
  end

  def system_color
    return Color.new(192, 224, 255, 255)
  end

  def crisis_color
    return Color.new(255, 255, 64, 255)
  end

  def knockout_color
    return Color.new(255, 64, 0)
  end

  def update
    super
    if $game_system.windowskin_name != @windowskin_name
      @windowskin_name = $game_system.windowskin_name
      self.windowskin = RPG::Cache.windowskin(@windowskin_name)
    end
  end

  def draw_actor_graphic(actor, x, y)
    bitmap = RPG::Cache.character(actor.character_name, actor.character_hue)
    cw = bitmap.width / 4
    ch = bitmap.height / 4
    src_rect = Rect.new(0, 0, cw, ch)
    self.contents.blt(x - cw / 2, y - ch, bitmap, src_rect)
  end

  def draw_actor_name(actor, x, y)
    self.contents.font.color = normal_color
    self.contents.draw_text(x, y, 120, 32, actor.name)
  end

  def draw_actor_class(actor, x, y)
    self.contents.font.color = normal_color
    self.contents.draw_text(x, y, 236, 32, actor.class_name)
  end

  def draw_actor_level(actor, x, y)
    self.contents.font.color = system_color
    self.contents.draw_text(x, y, 32, 32, "Level")
    self.contents.font.color = normal_color
    self.contents.draw_text(x + 32, y, 24, 32, actor.level.to_s, 2)
  end

  def make_battler_state_text(battler, width, need_normal)
    brackets_width = self.contents.text_size("[]").width
    text = ""
    for i in battler.states
      if $data_states[i].rating >= 1
        if text == ""
          text = $data_states[i].name
        else
          new_text = text + "/" + $data_states[i].name
          text_width = self.contents.text_size(new_text).width
          if text_width > width - brackets_width
            break
          end
          text = new_text
        end
      end
    end
    if text == ""
      if need_normal
        text = "[Normal]"
      end
    else
      text = "[" + text + "]"
    end
    return text
  end

  def draw_actor_state(actor, x, y, width = 120)
    text = make_battler_state_text(actor, width, true)
    self.contents.font.color = actor.hp == 0 ? knockout_color : normal_color
    self.contents.draw_text(x, y, width, 32, text)
  end

  def draw_actor_exp(actor, x, y)
    self.contents.font.color = system_color
    self.contents.draw_text(x, y, 24, 32, "Exp")
    self.contents.font.color = normal_color
    self.contents.draw_text(x + 24, y, 84, 32, actor.exp_s, 2)
    self.contents.draw_text(x + 108, y, 12, 32, "/", 1)
    self.contents.draw_text(x + 120, y, 84, 32, actor.next_exp_s)
  end

  def draw_actor_hp(actor, x, y, width = 144)
    self.contents.font.color = system_color
    self.contents.draw_text(x, y, 32, 32, $data_system.words.hp)
    if width - 32 >= 108
      hp_x = x + width - 108
      flag = true
    elsif width - 32 >= 48
      hp_x = x + width - 48
      flag = false
    end
    self.contents.font.color = actor.hp == 0 ? knockout_color :
      actor.hp <= actor.maxhp / 4 ? crisis_color : normal_color
    self.contents.draw_text(hp_x, y, 48, 32, actor.hp.to_s, 2)
    if flag
      self.contents.font.color = normal_color
      self.contents.draw_text(hp_x + 48, y, 12, 32, "/", 1)
      self.contents.draw_text(hp_x + 60, y, 48, 32, actor.maxhp.to_s)
    end
  end

  def draw_actor_sp(actor, x, y, width = 144)
    self.contents.font.color = system_color
    self.contents.draw_text(x, y, 32, 32, $data_system.words.sp)
    if width - 32 >= 108
      sp_x = x + width - 108
      flag = true
    elsif width - 32 >= 48
      sp_x = x + width - 48
      flag = false
    end
    self.contents.font.color = actor.sp == 0 ? knockout_color :
      actor.sp <= actor.maxsp / 4 ? crisis_color : normal_color
    self.contents.draw_text(sp_x, y, 48, 32, actor.sp.to_s, 2)
    if flag
      self.contents.font.color = normal_color
      self.contents.draw_text(sp_x + 48, y, 12, 32, "/", 1)
      self.contents.draw_text(sp_x + 60, y, 48, 32, actor.maxsp.to_s)
    end
  end

  def draw_actor_parameter(actor, x, y, type)
    case type
    when 0
      parameter_name = $data_system.words.atk
      parameter_value = actor.atk
    when 1
      parameter_name = $data_system.words.pdef
      parameter_value = actor.pdef
    when 2
      parameter_name = $data_system.words.mdef
      parameter_value = actor.mdef
    when 3
      parameter_name = $data_system.words.str
      parameter_value = actor.str
    when 4
      parameter_name = $data_system.words.dex
      parameter_value = actor.dex
    when 5
      parameter_name = $data_system.words.agi
      parameter_value = actor.agi
    when 6
      parameter_name = $data_system.words.int
      parameter_value = actor.int
    end
    self.contents.font.color = system_color
    self.contents.draw_text(x, y, 120, 32, parameter_name)
    self.contents.font.color = normal_color
    self.contents.draw_text(x + 120, y, 36, 32, parameter_value.to_s, 2)
  end

  def draw_item_name(item, x, y)
    if item == nil
      return
    end
    bitmap = RPG::Cache.icon(item.icon_name)
    self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24))
    self.contents.font.color = normal_color
    self.contents.draw_text(x + 28, y, 212, 32, item.name)
  end
end
class Window_Base < Window
  alias seph_disposefix_wndbs_dispose dispose
  def dispose
    return if self.disposed?
    seph_disposefix_wndbs_dispose
  end
end

Window_MenuStatus
Code:
#==============================================================================
# â–  Window_MenuStatus

class Window_MenuStatus < Window_Selectable
  def initialize
    super(0, 0, 480, 240)
    self.contents = Bitmap.new(width - 32, height - 32)
    self.contents.font.name = $defaultfonttype  # "Main" window font
    self.contents.font.size = $defaultfontsize
    refresh
    self.active = false
    self.index = -1
  end
  #-----Show Face in Menu instead of Charaset
  def draw_actor_face(actor, x, y)
    face = RPG::Cache.character("Faces/" + actor.character_name, actor.character_hue)
    fw = face.width
    fh = face.height
    src_rect = Rect.new (3, -1, fw, fh)
  self.contents.blt(x - fw / 23, y - fh, face, src_rect)
  end

  def refresh
    self.contents.clear
    @item_max = $game_party.actors.size
    for i in 0...$game_party.actors.size
      x = 64
      y = i * 116
      actor = $game_party.actors[i]
      draw_actor_graphic(actor, x - 40, y + 80)
      draw_actor_name(actor, x, y)
      draw_actor_class(actor, x + 144, y)
      draw_actor_level(actor, x, y + 32)
      draw_actor_state(actor, x + 90, y + 32)
      draw_actor_exp(actor, x, y + 64)
      draw_actor_hp(actor, x + 236, y + 32)
      draw_actor_sp(actor, x + 236, y + 64)
    end
  end

  def update_cursor_rect
    if @index < 0
      self.cursor_rect.empty
    else
      self.cursor_rect.set(0, @index * 116, self.width - 32, 96)
    end
  end
end

Window_BattleEnemyStatus
Code:
#==============================================================================
# Enemy HP Bar
# Version 1.0
# Raziel
#==============================================================================
#==============================================================================
# â–  Window_BattleEnemyStatus
#==============================================================================

class Window_BattleEnemyStatus < Window_Base
  #--------------------------------------------------------------------------
  # Initialize
  #--------------------------------------------------------------------------
  def initialize
    super(320, 320, 320,160)#(320, 320, 320, 160)
    self.contents = Bitmap.new(width - 32, height - 32)
    self.contents.font.name = "Neuropol"  # "Battle Status" window font
    self.contents.font.size = 18
    refresh
  end
  #--------------------------------------------------------------------------
  # Refresh
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    for i in 0...$game_troop.enemies.size
      @enemy = $game_troop.enemies[i]
      y = i * 32
      unless @enemy.hp == 0
        self.contents.draw_text(4, y, 80, 32, @enemy.name.to_s)
        draw_slant_bar(100, y + 15, @enemy.hp, @enemy.maxhp, width = 150, height = 6)
      end
    end
  end
  
end

class Window_Base < Window  
  #--------------------------------------------------------------------------
  # * Draw Slant Bar(by SephirothSpawn)
  #--------------------------------------------------------------------------
  def draw_slant_bar(x, y, min, max, width = 152, height = 6,
      bar_color = Color.new(150, 0, 0, 255), end_color = Color.new(255, 255, 60, 255))
    # Draw Border
    for i in 0..height
      self.contents.fill_rect(x + i, y + height - i, width + 1, 1, Color.new(50, 50, 50, 255))
    end
    # Draw Background
    for i in 1..(height - 1)
      r = 100 * (height - i) / height + 0 * i / height
      g = 100 * (height - i) / height + 0 * i / height
      b = 100 * (height - i) / height + 0 * i / height
      a = 255 * (height - i) / height + 255 * i / height
      self.contents.fill_rect(x + i, y + height - i, width, 1, Color.new(r, b, g, a))
    end
    # Draws Bar
    for i in 1..( (min / max.to_f) * width - 1)
      for j in 1..(height - 1)
        r = bar_color.red * (width - i) / width + end_color.red * i / width
        g = bar_color.green * (width - i) / width + end_color.green * i / width
        b = bar_color.blue * (width - i) / width + end_color.blue * i / width
        a = bar_color.alpha * (width - i) / width + end_color.alpha * i / width
        self.contents.fill_rect(x + i + j, y + height - j, 1, 1, Color.new(r, g, b, a))
      end
    end
  end
end
 
class Scene_Battle
  
  alias raz_update_phase5 update_phase5
  alias raz_update_phase4_step1 update_phase4_step1
  alias raz_update_phase4_step5 update_phase4_step5
  alias raz_enemy_hp_main main
  
   def main
    @troop_id = $game_temp.battle_troop_id
    $game_troop.setup(@troop_id)
    @enemy_window = Window_BattleEnemyStatus.new
    @enemy_window.z = 95
    raz_enemy_hp_main
    @enemy_window.dispose
  end
  

  def update_phase5
    # If wait count is larger than 0
    if @phase5_wait_count > 0
      # Decrease wait count
      @phase5_wait_count -= 1
      # If wait count reaches 0
      if @phase5_wait_count == 0
        @enemy_window.visible = false
        # Show result window
        @result_window.visible = true
        # Clear main phase flag
        $game_temp.battle_main_phase = false
        # Refresh status window
        @status_window.refresh
        @enemy_window.refresh
      end
      return
    end
   raz_update_phase5
 end

def update_phase4_step1
  raz_update_phase4_step1
  @enemy_window.refresh
end

  def update_phase4_step5
    # Hide help window
    @help_window.visible = false
    # Refresh status window
    @status_window.refresh
    @enemy_window.refresh
    raz_update_phase4_step5 
  end
end

I also added all of the "@enemy_window" to the Scene_Battle(s). They were working fine until I actually started playing the game, then I got the error, and now the window won't disappear. Sorry for the mess!
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top