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.

Customizing HP/SP displays

Hey again, this forum helped me out a lot with my last problem so I thought it would be a good place to bring my new one.

For the game I'm making I'd like to have a unique graphic HP/SP display. What I want is for HP and SP to be displayed as percentages of their maximum, not as number values. And alongside that I want there to be a changing visual icon representing the percentage (what I'm imagining is a heart-shaped health meter).

So if my character has max HP 10 and he's at 5 HP, I want the display to read 50% and show a half-full heart icon.

I know this is what I want to do, but I'm not really sure how to go about doing it. Has anyone tried something like this before, or does anyone have any advice?
 
You will need to request a script, or support making a script. But first you will need to provide some more info...
There are already a bunch of 'gradient bar'/'HP-SP bar" scripts that could be modified to meet your needs.

Which game maker? (XP, VX)
There are 7 places where HP, SP are shown. You want them the same everywhere? only in battle?
It would be helpful if you could draw, sketch the display you want, or at the very least describe it in detail.
(What colors?, What the heart looks like, does the gauge empty top to bottom, right to left, what do you see through the empty part?)
Do you only want it to change at 50%? or every 10%, or every 1% (not really possible unless the heart is 100 pixels wide or high. Your heart will probably be about 25 pixels, so every 4% would be the minimum amount of change)

Let us know if you want help writing the script, or if you want someone to do it for you & we'll move it to the correct forum

Be Well
 
Hey Brewmeister! I appreciate you replying so quickly.

To your questions: The program is XP, and yes, I want the meters to look the same everywhere, in battle, on the menu screen, everywhere. I have made the HP display I want to use. I haven't made the SP display yet but I think it'll follow similar guidelines.

Heartlevelbright.png


Here's the display I want to use, as you can see it's 25 distinct images so i suppose it'll need to change every 4%. Hope this is helpful, let me know what you think.

Edit: Also, I'd love help writing the script, if you think it's something a ripe n00b like myself would be capable of scripting. Maybe I'd even learn enough to try scripting other stuff for myself as well.
 
Here ya go... Paste above main

What I did was copy the draw_actor_hp & draw_actor_sp methods from the Window_Base class
into a new script & modified them to draw the appropriate image instead of the max value.
I also moved the numerical value & converted it to a percentage. Let me know if you have questions.
Put your image files in \Graphics\Pictures folder

Code:
class Window_Base

  #--------------------------------------------------------------------------

  # * 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)

    # Draw "HP" text string

    self.contents.font.color = system_color

    self.contents.draw_text(x, y, 32, 32, $data_system.words.hp)

    # Draw HP %

    hp_x = x + width-100

    percent = actor.hp * 100 / actor.maxhp

    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, 64, 32, percent.to_s + "%", 2)

    # Draw Guage

    gage_sheet = RPG::Cache.picture("Heartlevelbright")

    gage_index = [percent / 4 - 1, 0].max

    gage_rect = Rect.new(gage_index % 5 * 36, gage_index / 5 * 35, 36, 35)

    self.contents.blt(width - 30 + x, y, gage_sheet, gage_rect)

  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)

    # Draw "SP" text string

    self.contents.font.color = system_color

    self.contents.draw_text(x, y, 32, 32, $data_system.words.sp)

    # Draw SP %

    sp_x = x + width-100

    percent = actor.sp * 100 / actor.maxsp

    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, 64, 32, percent.to_s + "%", 2)

    # Draw Guage

    gage_sheet = RPG::Cache.picture("Heartlevelbright")

    gage_index = [percent / 4 - 1, 0].max

    gage_rect = Rect.new(gage_index % 5 * 36, gage_index / 5 * 35, 36, 35)

    self.contents.blt(width - 30 + x, y, gage_sheet, gage_rect)

  end

end

Doesn't fit too well with the default menus. I'd make the background of the hearts transparent instead of yellow. Change "Heartlevelbright" in the draw_actor_sp method once you make a new image.

Be Well
 
Wow, thanks Brewmeister. You're right that the yellow background didn't work so well, I took it out and now it looks great. I'm gonna try and adapt the same script for use with some more custom images for the SP bar. Thanks again!
 

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