Submit Your Article


 
RPG Maker

Welcome Guest ( Log In | Register )


  Games Resources RPG Maker VX RPG Maker XP Scripts Tutorials Downloads

> Jens009's Simple HUD, Show HP/SP/State in map
jens009
post Aug 10 2008, 09:05 PM
Post #1


L Did you know? Death gods... only eat apples
Group Icon

Group: +Gold Member
Posts: 2,976
Type: Scripter
RM Skill: Skilled




Simple HUD
Version 2.0
Author Jens009
Release DateAugust 9, 2008

Updated, August 10, 2008
Exclusive Script at RPG RPG Revolution


Introduction
So I was in the RGSS2 Request forum and VerifyedRasta requested for a simple HUD that shows an actor's HP and SP. So I took on the request and here it is.

Features
-Remove HUD with a call script
-Change maximum actors shown in HUD
-Can change update methods This decreases lag and increases performance of script
-Either Always update HUD on map or update the HUD only when necessary

- Less buggy and more flexible.

Script
[Show/Hide] Jens009's Simple HUD version 2.0

CODE
#============================================================================
# Jens009 Simple HP/SP/State HUD
# Version 2.0
# Release Date: August 11,2008
# Description: Display an HP/SP and State HUD information in map.
# Compatibility: Should be compatible with any system
# Configuration:
#   I. Turning off the HUD in game
#       use the call script $game_system.show_hud = true/false
#           true = show HUD, false = disable HUD
#   II. Changing maximum information shown
#        look at SHOW_MAX under JCONFIG, you can change the value to show
#        how many of the actors in the party to display their information
#        by default, it is set to show only 2 actors.
#   III. Changing maximum information shown in game
#        use the call script JCONFIG::SHOW_MAX = *integer*
#        You can change the amount of actors displayed in the HUD in game.
#        simply change integer to the value you want.
#   IV.  Changing Update methods
#        if you want the HUD to always update, set ALWAYS_UPDATE_HUD to true
#        but if you want to only update the HUD whenever you want to, set
#        this to false.
#        When $game_sysyem.always_update is false, you can update the hud
#        manually in game using the call script $game_system.refresh_hud = true.
#        this will refresh the hud information once.
#        However, you can also switch between always updating the HUD and
#        only updating the hud once during in game.
#        Simply use the call script:
#           $game_sysyem.always_update = true/false
#        and to reupdate once
#           $game_system.refresh_hud = true
#
# Optimization to achieve higher FPS
#    1) Set SHOW_MAX to a low value
#    You can also:
#    2) Set $game_sysyem.always_update = false
#      2.1) Use $game_temp.refresh_hud = true to reupdate the hud manually.
#============================================================================
module JCONFIG
  SHOW_MAX = 4 # By default, show 4 actor's information
end

#======================================
# Game_System edit
#=====================================
class Game_System
  # Add new instance
  attr_accessor :refresh_hud
  attr_accessor :show_hud
  attr_accessor :always_update
  alias jens009_initialize_hud initialize
  def initialize
    # Initialize instances
    @show_hud = true
    @always_update = true
    @refresh_hud = false
    # Call default methods
    jens009_initialize_hud
  end
  
end

#=============================================================================
# Window Hud < Window_Base
# Description: Handles Information to be shown in HUD
#=============================================================================

class Window_Hud < Window_Base
#==========================
# Initialize Values
#==========================
  def initialize
    super(0,0,544,110)
    self.opacity = 0
    self.visible = false if $game_system.show_hud == false
    refresh
  end
#=========================
# Create Information
#===========================
   def refresh
    self.contents.clear
    @item_max = JCONFIG::SHOW_MAX
    @party_size = $game_party.members.size
      for actor in $game_party.members
        x = actor.index * 120
        y = 0
        if actor.index < @item_max
          draw_actor_information(actor, x, y)
        end
      end
    end
  
  def draw_actor_information(actor, x, y)
    draw_actor_name(actor,x,y + 0)
    draw_actor_hp(actor, x, y + 16, 96)
    draw_actor_mp(actor, x, y + 32, 96)
    draw_actor_state(actor, x, y + 54)
  end
    
#=================================  
# Define Update
#====================================
  def update
    refresh
  end

end
#===============================
# Start Scene_Map edit
#===============================
class Scene_Map
  # Alias methods main, update and terminate
  alias jens009_hud_main main
  alias jens009_hud_update update
  alias jens009_hud_terminate terminate
  # Edit Main
  def main
    # Call HUD
    @hud = Window_Hud.new
    # Call previous Methods
    jens009_hud_main
  end

  # Edit Update
  def update
    # Update hud only if $game_system.show_hud is true
    if $game_system.show_hud and $game_system.always_update
      @hud.update
    end
    
    if $game_system.refresh_hud == true
        @hud.update
       $game_system.refresh_hud = false
    end
    
    if $game_system.show_hud == true
      @hud.visible = true
    else
      @hud.visible = false
    end
    # Call previous methods
    jens009_hud_update
  end

  # Edit Terminate
  def terminate
    # Call previous methods, dispose of other windows first before HUD
    jens009_hud_terminate
    # Dispose HUD
    @hud.dispose
  end

#========================
# End of Scene_Map edit
#========================
end


[Show/Hide] Jens009's Simple HUD version 1.0

CODE
#============================================================================
# Jens009 Simple HP/SP/State HUD
# Version 1.0
# Release Date: August 10,2008
# Description: Display an HP/SP and State HUD information in map.
# Compatibility: Should be compatible with any system
# Configuration:
#   I. Turning off the HUD in game
#       use the call script $game_system.show_hud = true/false
#           true = show HUD, false = disable HUD
#   II. Changing maximum information shown
#        look at SHOW_MAX under JCONFIG, you can change the value to show
#        how many of the actors in the party to display their information
#        by default, it is set to show only 2 actors.
#   III. Changing maximum information shown in game
#        use the call script JCONFIG::SHOW_MAX = *integer*
#        You can change the amount of actors displayed in the HUD in game.
#        simply change integer to the value you want.
# Optimization
#   For the sake of simplicity, I made this script as user friendly as
#   much as possible. Because of this, the game map will get laggy if
#   there are a lot of actors are shown in the HUD all at the same time
#   it is recommended that you show only 2 actors or less for a higher FPS.
#  
#   Besides, this HUD was meant to show only one actor at a time.
#============================================================================
module JCONFIG
  SHOW_MAX = 1 # By default, show only 1 actor's information
end

#======================================
# Game_System edit
#=====================================
class Game_System
  # Add new instance
  attr_accessor :show_hud
  alias jens009_initialize_hud initialize
  def initialize
    # Initialize instances
    @show_hud = true
    # Call default methods
    jens009_initialize_hud
  end
  
end

#=============================================================================
# Window Hud < Window_Base
# Description: Handles Information to be shown in HUD
#=============================================================================

class Window_Hud < Window_Base
#==========================
# Initialize Values
#==========================
  def initialize
    super(0,0,544,110)
    self.opacity = 0
    self.visible = false if $game_system.show_hud == false
    refresh
  end
#=========================
# Create Information
#===========================
   def refresh
    self.contents.clear
    @item_max = JCONFIG::SHOW_MAX + 1
    for i in 1...@item_max
      actor = $game_actors[i]
      x = actor.index * 120
      draw_actor_name(actor,x,0)
      draw_actor_hp(actor, x, 16, 96)
      draw_actor_mp(actor, x, 32, 96)
      draw_actor_state(actor, x, 54)
    end
  end
#=================================  
# Define Update
#====================================
  def update
    refresh
  end

end
#===============================
# Start Scene_Map edit
#===============================
class Scene_Map
  # Alias methods main, update and terminate
  alias jens009_hud_main main
  alias jens009_hud_update update
  alias jens009_hud_terminate terminate
  # Edit Main
  def main
    # Call HUD
    @hud = Window_Hud.new
    # Call previous Methods
    jens009_hud_main
  end

  # Edit Update
  def update
    # Update hud only if $game_system.show_hud is true
    @hud.update if $game_system.show_hud
    if $game_system.show_hud == true
      @hud.visible = true
    else
      @hud.visible = false
    end
    # Call previous methods
    jens009_hud_update
  end

  # Edit Terminate
  def terminate
    # Call previous methods, dispose of other windows first before HUD
    jens009_hud_terminate
    # Dispose HUD
    @hud.dispose
  end

#========================
# End of Scene_Map edit
#========================
end



Customization
See Script for info.

Compatibility
Should be compatible with any system. Except if you have another system that also has a HUD which defines the window as Window_Hud.

But high compatibility nonetheless.
Screenshot

This is a sample screenie if you want to show all actors with all 4 states used up for every actor.


DEMO
Uploading version 2.0

Installation
Paste below Materials.

FAQ
There's a bug
-Post it up
I have a suggestion
-Post it up

Terms and Conditions
RRR exclusive
Not for commercial use unless I'm contacted.
Credit me


Credits
Jens009


__________________________

My RMXP Project:


Farewell RRR. =]
Go to the top of the page
 
+Quote Post
   
2 Pages V   1 2 >  
Start new topic
Replies (1 - 19)
VerifyedRasta
post Aug 10 2008, 10:11 PM
Post #2


Level 20
Group Icon

Group: Revolutionary
Posts: 407
Type: Musician
RM Skill: Advanced




Great work! Thanks for helping me with my request and so very soon as well!

But i have a problem ...

When i test play the game i get this error:


Here are the scripts i use in my game and "Line 70" of your script which appears to be the problem ...(Or maybe its not.)


EDIT: Tested the script in a new game and it works fine ...
So any idea which script im using that is messing with yours?

This post has been edited by VerifyedRasta: Aug 10 2008, 10:14 PM


__________________________
Go to the top of the page
 
+Quote Post
   
jens009
post Aug 10 2008, 10:22 PM
Post #3


L Did you know? Death gods... only eat apples
Group Icon

Group: +Gold Member
Posts: 2,976
Type: Scripter
RM Skill: Skilled




Odd errror.

Try these:

1) Place my script below materials and above everything else
If problem presists:
2) One by one remove your other scripts(temporarily) and test your game. Carefully deduce which script causes the issue.

3) If you found the script that causes the errors, place my script above that script.

If it still doesn't work tell me. Because that error just doesn't make sense.


__________________________

My RMXP Project:


Farewell RRR. =]
Go to the top of the page
 
+Quote Post
   
Lukedevoux
post Aug 10 2008, 10:34 PM
Post #4


Level 11
Group Icon

Group: Revolutionary
Posts: 181
Type: Developer
RM Skill: Beginner




I figured out the reason why the error is coming up, it's because you're using One character, it's not clashing with any other scripts, i just tried it in a new game an it worked.


__________________________
[Show/Hide] Knights of the old Republic Joke

There are two Mandalorians are out in the woods. One of them collapses. He doesn't seem to be breathing and his eyes are glazed. The other Mandalorian takes out his communicator and contacts his commander. He gasps: "My partner has collapsed! I don't know what to do!" After a moment, the commander responds: "Calm down. I can help. First let's make sure your partner is dead." There is a silence then a blaster shot is heard. Back on the communicator, the Mandalorian says: "Okay, now what?"

Go to the top of the page
 
+Quote Post
   
VerifyedRasta
post Aug 10 2008, 10:35 PM
Post #5


Level 20
Group Icon

Group: Revolutionary
Posts: 407
Type: Musician
RM Skill: Advanced




Ok i did all the steps you mentioned ...

I ended up temporarily removing all of the other scripts just to find that i still get the same error ... Odd i know ...

Then i went back into the new game i started to test your script ... and placed all the scripts i had in my game into that one ... and it worked fine see:


Wtf ...

EDIT:
You are probably right Luke ... so what am i gonna do ... i want it to start with one character only first ... Then as the game progresses, you know *xxxx has joined party*

This post has been edited by VerifyedRasta: Aug 10 2008, 10:38 PM


__________________________
Go to the top of the page
 
+Quote Post
   
Lukedevoux
post Aug 10 2008, 10:37 PM
Post #6


Level 11
Group Icon

Group: Revolutionary
Posts: 181
Type: Developer
RM Skill: Beginner




Ive got it, the answer to solve this problem is to change 'SHOW_MAX = 1' on line 28.


__________________________
[Show/Hide] Knights of the old Republic Joke

There are two Mandalorians are out in the woods. One of them collapses. He doesn't seem to be breathing and his eyes are glazed. The other Mandalorian takes out his communicator and contacts his commander. He gasps: "My partner has collapsed! I don't know what to do!" After a moment, the commander responds: "Calm down. I can help. First let's make sure your partner is dead." There is a silence then a blaster shot is heard. Back on the communicator, the Mandalorian says: "Okay, now what?"

Go to the top of the page
 
+Quote Post
   
VerifyedRasta
post Aug 10 2008, 10:45 PM
Post #7


Level 20
Group Icon

Group: Revolutionary
Posts: 407
Type: Musician
RM Skill: Advanced




Thanks alot Luke! And Jens for making the script!! It works fine now!!



Also i notice lag when i use this script ...
I'm using a temporary computer, which has 480mb of RAM LOL (i know it sucks) ... but does it lag with any of your comps or is it indeed just my comp.

This post has been edited by VerifyedRasta: Aug 10 2008, 10:48 PM


__________________________
Go to the top of the page
 
+Quote Post
   
jens009
post Aug 10 2008, 11:03 PM
Post #8


L Did you know? Death gods... only eat apples
Group Icon

Group: +Gold Member
Posts: 2,976
Type: Scripter
RM Skill: Skilled




QUOTE (Lukedevoux @ Aug 10 2008, 10:56 PM) *
I figured out the reason why the error is coming up, it's because you're using One character, it's not clashing with any other scripts, i just tried it in a new game an it worked.

Ah this makes sense.

When I was testing the game, I always had 4 characters in my party. So I never got an index error. But now that you pointed it out, I have to make a bug fix for this.

Well, I'll fix it in the next version. XD

QUOTE
I'm using a temporary computer, which has 480mb of RAM LOL (i know it sucks) ... but does it lag with any of your comps or is it indeed just my comp.

It lags if you use a lot of characters. But it shouldn't if you just have one character.
The lag occurs because the script constantly updates. I have a fix for this but it's not going to be user friendly if I do that. In any case, I'll fix everything up in the next version.


__________________________

My RMXP Project:


Farewell RRR. =]
Go to the top of the page
 
+Quote Post
   
VerifyedRasta
post Aug 10 2008, 11:19 PM
Post #9


Level 20
Group Icon

Group: Revolutionary
Posts: 407
Type: Musician
RM Skill: Advanced




lol k

Well user friendly or not, it should be plug and play right? So i can still use it without knowing what im doinging lol (yn) am i right??or no? tongue.gif


__________________________
Go to the top of the page
 
+Quote Post
   
jens009
post Aug 10 2008, 11:25 PM
Post #10


L Did you know? Death gods... only eat apples
Group Icon

Group: +Gold Member
Posts: 2,976
Type: Scripter
RM Skill: Skilled




QUOTE (VerifyedRasta @ Aug 10 2008, 11:41 PM) *
lol k

Well user friendly or not, it should be plug and play right? So i can still use it without knowing what im doinging lol (yn) am i right??or no? tongue.gif

Lol. well the thing is, to remove the lag issue, I have to remove the update command.
When I do that, the hp and sp won't update say when you take a damage in map or you heal in map.

Now, what's the fix so that it reupdates again? Well, you just have to make sure that when you decrease the actor's hp or call any eventing command in game, that we tell the HUD to reupdate. To do this, you would do something like:

CODE
$game_map.hud_refresh = true


And you would have to place that line of code every time you do something that messes up the HP/SP of the characters.


__________________________

My RMXP Project:


Farewell RRR. =]
Go to the top of the page
 
+Quote Post
   
VerifyedRasta
post Aug 10 2008, 11:42 PM
Post #11


Level 20
Group Icon

Group: Revolutionary
Posts: 407
Type: Musician
RM Skill: Advanced




Lol as i said i am a fast learner ...

Sounds easy enough ... anytime the enemies hurt my hero ... i will have to re-update the HUD ... and if i wanna use a potion or some other form of healing just:
Script:$game_map.hud_refresh = true

Ok well im gonna go hit the sack now, in the new version it should have no lag because its not constantly updating, is what ur trying to tell me ... which makes sence.
Nite everyone!

And thanks again!


__________________________
Go to the top of the page
 
+Quote Post
   
Lukedevoux
post Aug 11 2008, 09:37 AM
Post #12


Level 11
Group Icon

Group: Revolutionary
Posts: 181
Type: Developer
RM Skill: Beginner




Instead of posting the many errors you can get from doing this. So Jen, Test Play your game with this script an either right from the Start menu or in the game press F12, an go to New Game.


__________________________
[Show/Hide] Knights of the old Republic Joke

There are two Mandalorians are out in the woods. One of them collapses. He doesn't seem to be breathing and his eyes are glazed. The other Mandalorian takes out his communicator and contacts his commander. He gasps: "My partner has collapsed! I don't know what to do!" After a moment, the commander responds: "Calm down. I can help. First let's make sure your partner is dead." There is a silence then a blaster shot is heard. Back on the communicator, the Mandalorian says: "Okay, now what?"

Go to the top of the page
 
+Quote Post
   
jens009
post Aug 11 2008, 11:30 AM
Post #13


L Did you know? Death gods... only eat apples
Group Icon

Group: +Gold Member
Posts: 2,976
Type: Scripter
RM Skill: Skilled




@Luke: Version 2.0 tested and posted

This time, I spent more time testing the system. The reason it was buggy in the first version was because I scripted this one hastily. In this new version, I can confidently say that it won't cause any bugs regarding the actor size/information.

New features have been added to:

- Option of either always updating the HUD or refreshing the HUD only when necessary

The new feature is useful for decreasing lags in game. You can either switch to always updating the HUD or just updating it when necessary.

The scripts' methods were completely changed. It was stupid of me to use $game_actors[index] as an indicator of which actor to draw. So instead, I used $game_party.members to find out who's in the party and which actor to draw.

I'm also uploading a demo to show you the flexibility of the script.


__________________________

My RMXP Project:


Farewell RRR. =]
Go to the top of the page
 
+Quote Post
   
VerifyedRasta
post Aug 11 2008, 12:00 PM
Post #14


Level 20
Group Icon

Group: Revolutionary
Posts: 407
Type: Musician
RM Skill: Advanced




It works great now!! And updating the HUD manually is not a hassle at all, so it works out fine with the battle

Thanks again Jens009

This post has been edited by VerifyedRasta: Aug 11 2008, 12:00 PM


__________________________
Go to the top of the page
 
+Quote Post
   
kreytor
post Aug 11 2008, 02:33 PM
Post #15


Level 1
Group Icon

Group: Member
Posts: 8
Type: Event Designer
RM Skill: Beginner




This works better than I hoped it would. Now I just have to move it to the bottom of my screen smile.gif Shouldn't be to hard.
Go to the top of the page
 
+Quote Post
   
gamox1
post Aug 12 2008, 07:34 AM
Post #16


Level 2
Group Icon

Group: Member
Posts: 25
Type: Event Designer
RM Skill: Skilled




I don't need an mp bar for my game how do you remove it?


__________________________
FINAL FINALE XVII is here. - Updated November 21, 2011
Go to the top of the page
 
+Quote Post
   
VerifyedRasta
post Aug 12 2008, 10:01 AM
Post #17


Level 20
Group Icon

Group: Revolutionary
Posts: 407
Type: Musician
RM Skill: Advanced




QUOTE (gamox1 @ Aug 12 2008, 07:56 AM) *
I don't need an mp bar for my game how do you remove it?


Go to line 97 and remove this:
"draw_actor_mp(actor, x, y + 32, 96)"


__________________________
Go to the top of the page
 
+Quote Post
   
JoRu
post Aug 12 2008, 11:34 AM
Post #18


The 15-year old Swedish Meatball
Group Icon

Group: Revolutionary
Posts: 280
Type: Developer
RM Skill: Advanced




I don't know if this is the right place to ask this, it's not a question about the script itself but anyway: I only want the HUD to be displayed if you press a button. I've tried doing this with a common event, but it seems like I do it wrong. Does someone know a way to make something like that work?


__________________________


Stay tuned for more information about Fairytale. To stay updated on all my project videos, visit my YouTube page!

QUOTE (JoRu)
Life is a game!
Go to the top of the page
 
+Quote Post
   
VerifyedRasta
post Aug 12 2008, 12:34 PM
Post #19


Level 20
Group Icon

Group: Revolutionary
Posts: 407
Type: Musician
RM Skill: Advanced




Heres an extremely easy common event i just whipped up, that will allow you to Display/ Hide your HUD when you press the "D" button on your Keyboard:


__________________________
Go to the top of the page
 
+Quote Post
   
JoRu
post Aug 12 2008, 01:38 PM
Post #20


The 15-year old Swedish Meatball
Group Icon

Group: Revolutionary
Posts: 280
Type: Developer
RM Skill: Advanced




Thanks, VerifyedRasta! This will come in handy. smile.gif


__________________________


Stay tuned for more information about Fairytale. To stay updated on all my project videos, visit my YouTube page!

QUOTE (JoRu)
Life is a game!
Go to the top of the page
 
+Quote Post
   

2 Pages V   1 2 >
Closed TopicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 

Lo-Fi Version Time is now: 22nd May 2013 - 09:36 PM
RPG RPG Revolution is an Privacy Policy and Legal
eXTReMe Tracker