RMRK is retiring.
Registration is disabled. The site will remain online, but eventually become a read-only archive. More information.

RMRK.net has nothing to do with Blockchains, Cryptocurrency or NFTs. We have been around since the early 2000s, but there is a new group using the RMRK name that deals with those things. We have nothing to do with them.
NFTs are a scam, and if somebody is trying to persuade you to buy or invest in crypto/blockchain/NFT content, please turn them down and save your money. See this video for more information.
[RESOLVED] HP Window On-screen

0 Members and 1 Guest are viewing this topic.

**
Zylos' boyfriend. <3
Rep:
Level 84
I am wolf, hear me howl.
Personally, I fail at scripting. So I thought I'd come to y'all to see if you guys can do what I can't (which is very likely, I can't do next to anything with scripting).

Anyway, here's what I'm trying to do. For my game, I want to have a window that's constantly on-screen. It'd be small, compact, and tucked away in the upper-right corner. All that would be in it is an HP display, like so (Pardon the horrible drawing):

-------------------
| HP: XXX/XXX |
| xxxxxxxxxxxxx |
-------------------

Basically? I want an HP count above and the bar graphic below, one that will reflect my current HP, if at all possible. Thanks for your time.
« Last Edit: February 22, 2009, 01:52:26 PM by Zeichwolf »

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Most Mature Member2012 Favorite Staff Member2012 Best RPG Maker User (Scripting)2012 Best MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Use of Avatar and Signature Space2011 Best RPG Maker User (Scripting)2011 Most Mature Member2011 Favourite Staff Member2011 Best Veteran2010 Most Mature Member2010 Favourite Staff Member
Is it OK to have some overlap or do they have to be completely disjoint?
« Last Edit: February 16, 2009, 04:23:49 PM by Modern Algebra »

**
Zylos' boyfriend. <3
Rep:
Level 84
I am wolf, hear me howl.
It's fine to have some overlap, like in the menu.

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Most Mature Member2012 Favorite Staff Member2012 Best RPG Maker User (Scripting)2012 Best MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Use of Avatar and Signature Space2011 Best RPG Maker User (Scripting)2011 Most Mature Member2011 Favourite Staff Member2011 Best Veteran2010 Most Mature Member2010 Favourite Staff Member
You have friends in heart places.


If there is anything you want changed or if something doesn't work, just post and I will try to fix it.

Code: [Select]
#==============================================================================
#  Zeichwolf HUD
#  Version: 1.0
#  Author: modern algebra
#  Date: February 15, 2009
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Description:
#    A simple HUD that just shows the HP of the lead actor.
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Instructions:
#    Paste this script above Main and below Materials in the Script Editor (F11)
#
#    To toggle the HUD on and off, you can use the call script:
#      toggle_hud (x)
#
#      where x is either true or false, where true means the HUD will be shown
#  and false means it won't be. If you do not give any argument, it will just
#  toggle the visibility of the HUD, i.e. turn it on if it is off and off it
#  is on.
#==============================================================================

#==============================================================================
# ** Game Actor
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Summary of Changes:
#    aliased method - hp=
#==============================================================================

class Game_Actor
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Change HP
  #     hp : new HP
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias modalg_zeichwof_hudsply_hpequals_64b6 hp=
  def hp=(hp)
    # Run Original Method
    modalg_zeichwof_hudsply_hpequals_64b6 (hp)
    # If HUD showing self and scene is map
    $scene.refresh_zhud if $game_party.members[0] == self && $scene.is_a? (Scene_Map)
  end
end

#==============================================================================
# ** Game_System
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Summary of Changes:
#    new instance variable - zhud_visible
#    aliased method - initialize
#==============================================================================

class Game_System
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Public Instance Variables
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  attr_accessor :zhud_visible # Boolean determining whether to show HUD or not
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Object Initialization
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias malg_zeichwolf_init_simp_hud_85h6 initialize
  def initialize
    # Run Original Method
    malg_zeichwolf_init_simp_hud_85h6
    # Initialize new variable
    @zhud_visible = true
  end
end

#==============================================================================
# ** Game_Interpreter
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Summary of Changes:
#    new method - toggle_hud
#==============================================================================

class Game_Interpreter
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Toggle HUD
  #    boolean : if desired, set directly to a value
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def toggle_hud (boolean = nil)
    $game_system.zhud_visible = boolean == nil ? !$game_system.zhud_visible : boolean
    $scene.refresh_zhud if $scene.is_a? (Scene_Map)
  end
end

#==============================================================================
# ** Window_ZHUD
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  This window shows a simply HP display
#==============================================================================

class Window_ZHUD < Window_Base
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Object Initialization
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def initialize
    # Run Super method
    super (384, 0, 160, 32 + WLH)
    self.opacity = 160
    refresh
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Refresh
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def refresh
    self.contents.clear
    # Set visibility
    self.visible = $game_system.zhud_visible
    # Do not draw anything if no actors are in the party
    return if $game_party.members.size < 1
    # Draw HP of lead party member
    draw_actor_hp ($game_party.members[0], 0, 0, 128)
  end
end

#==============================================================================
# ** Scene Map
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#  Summary of Changes:
#    aliased methods - start, terminate
#    new methods - refresh_ZHUD
#==============================================================================

class Scene_Map
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Start
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias mornbra_zeic_hud_strt_6w52d start
  def start
    # Run Original Method
    mornbra_zeic_hud_strt_6w52d
    # Create ZHUD window
    @zhud_window = Window_ZHUD.new
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Terminate
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias malg_zechwlf_hedsupdply_trmnte_1hb5 terminate
  def terminate
    # Dispose of HUD window
    @zhud_window.dispose
    # Run Original Method
    malg_zechwlf_hedsupdply_trmnte_1hb5
  end
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Refresh ZHUD
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  def refresh_zhud
    return if @zhud_window.disposed? || @zhud_window == nil
    @zhud_window.refresh
  end
end


I kind of actually posted this yesterday by editing my first post, but I just realized today that you had posted before then so you probably never saw it so I am posting it again.

**
Zylos' boyfriend. <3
Rep:
Level 84
I am wolf, hear me howl.
Heh, yeah. Zylos actually got me into the whole thing, so it's convenient that he happened to be a higher-up too!

But anyway, I stuck the script in, tested it out, everything's working just fine. It's really nicely done, thanks!

...And I'm gonna hate myself for this, but I'm gonna be picky for just a moment. Any way you can make the window say "HP" instead of just "H"? n.n;

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Most Mature Member2012 Favorite Staff Member2012 Best RPG Maker User (Scripting)2012 Best MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Use of Avatar and Signature Space2011 Best RPG Maker User (Scripting)2011 Most Mature Member2011 Favourite Staff Member2011 Best Veteran2010 Most Mature Member2010 Favourite Staff Member
Just change it in the database (F9). The last tab is the Terms tab and one of the entries is HP (abbr.): - change that to HP

**
Zylos' boyfriend. <3
Rep:
Level 84
I am wolf, hear me howl.
Ah, thanks again, I'm still a bit new, so I make mistakes like this.  ;D