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.

in battle, change HP and SP to red and blue?

someone gave me a simple little script for this awhile aog, but i loat it, stupid me.

what i need is a little script that will, in battle, change the HP and the value of your HP to red, all the time. and SP and its value to blue all the time.
 
Insert in a new script above main (preferably above all custom scripts)

Code:
class Window_Base
  #--------------------------------------------------------------------------
  # * Constants
  #--------------------------------------------------------------------------
  Hp_Text_Colors = Color.new(255, 32, 32), Color.new(255, 64, 64)
  Sp_Text_Colors = Color.new(32, 32, 255), Color.new(64, 64, 255)
  #--------------------------------------------------------------------------
  # * Draw HP
  #     actor : actor
  #     x     : draw spot x-coordinate
  #     y     : draw spot y-coordinate
  #     width : draw spot width
  #--------------------------------------------------------------------------
  def draw_actor_hp(actor, x, y, width = 144)
    # Get Color
    color = $game_temp.in_battle ? Hp_Text_Colors[0] : system_color
    # Draw "HP" text string
    self.contents.font.color = color
    self.contents.draw_text(x, y, 32, 32, $data_system.words.hp)
    # Calculate if there is draw space for MaxHP
    if width - 32 >= 108
      hp_x = x + width - 108
      flag = true
    elsif width - 32 >= 48
      hp_x = x + width - 48
      flag = false
    end
    # If In Battle
    if $game_temp.in_battle
      # Get Color
      color = Hp_Text_Colors[1]
    else
      # Get Color
      color = actor.hp == 0 ? knockout_color : actor.hp <= actor.maxhp / 4 ? 
        crisis_color : normal_color
    end
    # Set Color
    self.contents.font.color = color
    # Draw HP
    self.contents.font.color = Hp_Text_Colors[1]
    self.contents.draw_text(hp_x, y, 48, 32, actor.hp.to_s, 2)
    # Draw MaxHP
    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
  #--------------------------------------------------------------------------
  # * Draw SP
  #     actor : actor
  #     x     : draw spot x-coordinate
  #     y     : draw spot y-coordinate
  #     width : draw spot width
  #--------------------------------------------------------------------------
  def draw_actor_sp(actor, x, y, width = 144)
    # Get Color
    color = $game_temp.in_battle ? Sp_Text_Colors[0] : system_color
    # Draw "SP" text string
    self.contents.font.color = color
    self.contents.draw_text(x, y, 32, 32, $data_system.words.sp)
    # Calculate if there is draw space for MaxHP
    if width - 32 >= 108
      sp_x = x + width - 108
      flag = true
    elsif width - 32 >= 48
      sp_x = x + width - 48
      flag = false
    end
    # If In Battle
    if $game_temp.in_battle
      # Get Color
      color = Sp_Text_Colors[1]
    else
      # Get Color
      color = actor.sp == 0 ? knockout_color : actor.sp <= actor.maxsp / 4 ? 
        crisis_color : normal_color
    end
    # Set Color
    self.contents.font.color = color
    self.contents.draw_text(sp_x, y, 48, 32, actor.sp.to_s, 2)
    # Draw MaxSP
    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
end

If the Colors I've choosen aren't to your liking you can change the constants Hp_Text_Colors and Sp_Text_Colors the first color is what color the text Hp or Sp is drawn and the other is the color the value is drawn in
 
small bug with my above code and I have that fixed below

Code:
class Window_Base
  #--------------------------------------------------------------------------
  # * Constants
  #--------------------------------------------------------------------------
  Hp_Text_Colors = Color.new(255, 32, 32), Color.new(255, 64, 64)
  Sp_Text_Colors = Color.new(32, 32, 255), Color.new(64, 64, 255)
  #--------------------------------------------------------------------------
  # * Draw HP
  #     actor : actor
  #     x     : draw spot x-coordinate
  #     y     : draw spot y-coordinate
  #     width : draw spot width
  #--------------------------------------------------------------------------
  def draw_actor_hp(actor, x, y, width = 144)
    # Get Color
    color = $game_temp.in_battle ? Hp_Text_Colors[0] : system_color
    # Draw "HP" text string
    self.contents.font.color = color
    self.contents.draw_text(x, y, 32, 32, $data_system.words.hp)
    # Calculate if there is draw space for MaxHP
    if width - 32 >= 108
      hp_x = x + width - 108
      flag = true
    elsif width - 32 >= 48
      hp_x = x + width - 48
      flag = false
    end
    # If In Battle
    if $game_temp.in_battle
      # Get Color
      color = Hp_Text_Colors[1]
    else
      # Get Color
      color = actor.hp == 0 ? knockout_color : actor.hp <= actor.maxhp / 4 ? 
        crisis_color : normal_color
    end
    # Set Color
    self.contents.font.color = color
    self.contents.draw_text(hp_x, y, 48, 32, actor.hp.to_s, 2)
    # Draw MaxHP
    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
  #--------------------------------------------------------------------------
  # * Draw SP
  #     actor : actor
  #     x     : draw spot x-coordinate
  #     y     : draw spot y-coordinate
  #     width : draw spot width
  #--------------------------------------------------------------------------
  def draw_actor_sp(actor, x, y, width = 144)
    # Get Color
    color = $game_temp.in_battle ? Sp_Text_Colors[0] : system_color
    # Draw "SP" text string
    self.contents.font.color = color
    self.contents.draw_text(x, y, 32, 32, $data_system.words.sp)
    # Calculate if there is draw space for MaxHP
    if width - 32 >= 108
      sp_x = x + width - 108
      flag = true
    elsif width - 32 >= 48
      sp_x = x + width - 48
      flag = false
    end
    # If In Battle
    if $game_temp.in_battle
      # Get Color
      color = Sp_Text_Colors[1]
    else
      # Get Color
      color = actor.sp == 0 ? knockout_color : actor.sp <= actor.maxsp / 4 ? 
        crisis_color : normal_color
    end
    # Set Color
    self.contents.font.color = color
    self.contents.draw_text(sp_x, y, 48, 32, actor.sp.to_s, 2)
    # Draw MaxSP
    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
end
 

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