Battle HUDs
Version: 3.0
Author: Pacman
Date: January 19th, 2012
Version History
- <Version 3.0> 19.01.2012 - Added enemy HUD, revamped script
- <Version 2.1> 12.08.2011 - Removed the error messages ._.
- <Version 2.0> 12.04.2011 - Added further configuration options concerning the font.
- <Version 1.1> 06.21.2011 - Fixed a minor divzero bug that occurred when a character had 0 max mp.
- <Version 1.0> 04.18.2011 - Original Release
Planned Future Versions
- I'll take any suggestions into consideration at the moment.
Description
There are a lot of battle scripts for VX out there, and they're
mostly fantastic. However, they all require so much configuration. This script
is the ultimate plug-and-play battle HUD: all you have to do is put it in the
editor and alter one thing if you really want to. This script simply puts the
actor's defined face into the battle window along with their HP and MP.
There is now also a HUD for the enemy selection part of battle. It contains
the enemies' names, HPs, MPs and states. You can prevent the HUD from drawing
these values buy placing certain tags in the enemy's notebox.
Features
- Incredibly simple plug-and-play battle HUD.
- Comprehensive display of enemies' stats in-battle.
- Optional configuration for font size, colour and type.
Screenshots
(https://rmrk.net/proxy.php?request=http%3A%2F%2Fi.imgur.com%2FCxQ7Y.jpg&hash=a7743592aa44deb0e31dee5566c57d93368565bf)
From top to bottom: Actor HUD with new colours, Actor HUD with original colours, Enemy HUD.
Instructions
Plug-and-play. You can look at the configuration module if you must.
Script
#===============================================================================
#
# Battler HUD
# Version 3.0
# By Pacman (rmrk.net)
# Description: There are a lot of battle scripts for VX out there, and they're
# mostly fantastic. However, they all require so much configuration. This script
# is the ultimate plug-and-play battle HUD: all you have to do is put it in the
# editor and alter one thing if you really want to. This script simply puts the
# actor's defined face into the battle window along with their HP and MP.
# There is now also a HUD for the enemy selection part of battle. It contains
# the enemies' names, HPs, MPs and states. You can prevent the HUD from drawing
# these values buy placing certain tags in the enemy's notebox:
#
# UNKNOWN_STATUS - Nothing is drawn.
# UNKNOWN_STATE - The states are not drawn.
# UNKNOWN_NAME - The name is not drawn.
# UNKNOWN_HP - The HP is not drawn.
# UNKNOWN_MP - The MP is not drawn.
#
# Instructions: Put this script under materials and above main in the script
# editor. Change CharOpa to the desired opactiy if you wish, and let the
# script do the rest. You can also change the font type, size and colour in the
# configuration.
#
# Support: I reside almost ever-presently at rmrk.net.
#
#===============================================================================
module PacBFH # <- Do not touch
#-------------------------------------------------------------------------------
# EDITING SECTION
#-------------------------------------------------------------------------------
USE_ACTOR = true # Use actor HUD?
USE_ENEMY = true # Use enemy HUD?
CharOpa = 150 # Default 150
ORIG_COLOURS = true # Use original HP/MP colours or my new colours?
Colour = [255, 255, 255] # RGB(A) values, separated by commas.
Size = 17 # Size of the name text
Font = "Verdana" # Font of the name text
HPMP_SIZE = false # Does 'size' apply to the drawing of HP and MP?
#-------------------------------------------------------------------------------
# END EDITING SECTION
#-------------------------------------------------------------------------------
end
if PacBFH::USE_ACTOR
#==============================================================================
# ** Window_BattleStatus
#------------------------------------------------------------------------------
# This window displays the status of all party members on the battle screen.
#==============================================================================
class Window_BattleStatus < Window_Selectable
#--------------------------------------------------------------------------
# Alias listing
#--------------------------------------------------------------------------
alias pacman_WBS_ini initialize
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
super(0, 0, 416, 128, 1)
@column_max = $game_party.members.size
refresh
self.active = false
self.opacity = 255
self.cursor_rect.set(0, self.index * 96, 90, 90)
end
#--------------------------------------------------------------------------
# * Draw Item
# index : Item number
#--------------------------------------------------------------------------
def draw_item(index)
rect = item_rect(index)
rect.x += 4
rect.width -= 8
rect.height = 96
self.contents.clear_rect(rect)
self.contents.font.color = Color.new(*PacBFH::Colour)
self.contents.font.size = PacBFH::Size
self.contents.font.name = PacBFH::Font
actor = $game_party.members[index]
draw_actor_face2(actor, index * 96,0,80)
draw_actor_name(actor, index * 96 + 8, 0)
draw_actor_state(actor, index * 96 + 4, 32, 20)
self.contents.font.size = PacBFH::HPMP_SIZE ? PacBFH::Size : 14
draw_hp_and_mp(actor, index * 96, 50, 90)
self.contents.font.color = Font.default_color
self.contents.font.name = Font.default_name
self.contents.font.size = Font.default_size
end
#--------------------------------------------------------------------------
# * Frame update for cursor
#--------------------------------------------------------------------------
def update_cursor
if @index < 0
self.cursor_rect.empty
else
self.cursor_rect.set(index*96, 0, 90, 96)
end
end
end
#==============================================================================
# ** Window_Base
#------------------------------------------------------------------------------
# This is a superclass of all windows in the game.
#==============================================================================
class Window_Base < Window
#--------------------------------------------------------------------------
# * Secondary Method of drawing actor face
# actor : actor
# x : draw spot x-coordinate
# y : draw spot y-coordinate
# width : width of box
# height: height of box
#--------------------------------------------------------------------------
def draw_actor_face2(actor, x, y, width = 96, height = 96)
draw_face2(actor.face_name, actor.face_index, x, y, width, height)
end
#--------------------------------------------------------------------------
# * Secondary Method of drawing face graphics
# face_name : Face graphic filename
# face_index : Face graphic index
# x : draw spot x-coordinate
# y : draw spot y-coordinate
# width : width of box
# height : height of box
#--------------------------------------------------------------------------
def draw_face2(face_name, face_index, x, y, width = 96, height = 96)
bitmap = Cache.face(face_name)
rect = Rect.new(0, 0, 0, 0)
rect.x = face_index % 4 * 96 + (96 - width) / 2
rect.y = face_index / 4 * 96 + (96 - height) / 2
rect.width = width
rect.height = height -10
self.contents.blt(x + 5, y + 5, bitmap, rect, PacBFH::CharOpa)
bitmap.dispose
end
#--------------------------------------------------------------------------
# * Draw Actor HP and MP
# actor : actor whose stats are to be drawn
# x : draw spot x-coordinate
# y : draw spot y_coordinate
# width : width of draw spot
#--------------------------------------------------------------------------
def draw_hp_and_mp(actor, x, y, width)
if PacBFH::ORIG_COLOURS
back_color = gauge_back_color
hp_color1 = hp_gauge_color1
hp_color2 = hp_gauge_color2
mp_color1 = mp_gauge_color1
mp_color2 = mp_gauge_color2
else
back_color = Color.new(39, 58, 83, 255)
hp_color1 = Color.new(66, 114, 164, 255)
hp_color2 = Color.new(122, 175, 229, 255)
mp_color1 = Color.new(93, 50, 158, 255)
mp_color2 = Color.new(145, 122, 229, 255)
end
self.contents.fill_rect(x + 5, y + 15, width - 10, 7, back_color)
self.contents.gradient_fill_rect(x + 7, y + 17, (width - 14) * actor.hp /
actor.maxhp, 3, hp_color1, hp_color2)
self.contents.draw_text(x + 5, y, width - 10, 20, Vocab::hp, 0)
self.contents.draw_text(x + 5, y, width - 10, 20, actor.hp.to_s + "/" +
actor.maxhp.to_s, 2)
self.contents.fill_rect(x + 5, y + 35, width - 10, 7, back_color)
if actor.maxmp != 0
self.contents.gradient_fill_rect(x + 7, y + 37, (width - 14) * actor.mp /
actor.maxmp, 3, mp_color1, mp_color2)
else
self.contents.gradient_fill_rect(x + 7, y + 37, (width - 14) * actor.mp,
3, mp_color1, mp_color2)
end
self.contents.draw_text(x + 5, y + 20, width - 10, 20, Vocab::mp, 0)
self.contents.draw_text(x + 5, y + 20, width - 10, 20,
actor.mp.to_s + "/" + actor.maxmp.to_s, 2)
end
end
end
if PacBFH::USE_ENEMY
#==============================================================================
# ** Window_TargetEnemy
#------------------------------------------------------------------------------
# Window for selecting the enemy who is the action target on the battle
# screen.
#==============================================================================
class Window_TargetEnemy < Window_Command
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
@enemies = []
commands = []
$game_troop.members.each do |enemy|
next unless enemy.exist?
@enemies.push(enemy)
commands.push(enemy.name)
end
super(416, commands)
self.height = 128
end
#--------------------------------------------------------------------------
# * Get Enemy Object
#--------------------------------------------------------------------------
def enemy
return @enemies[@index]
end
#--------------------------------------------------------------------------
# * Draw Item
# index : item number
#--------------------------------------------------------------------------
def draw_item(index)
rect = item_rect(index)
rect.x += 4
rect.width -= 8
self.contents.clear_rect(rect)
self.contents.font.color = normal_color
actor = @enemies[index]
unless actor.stat_note?('UNKNOWN_STATUS')
draw_actor_name(actor, 4, rect.y) unless actor.stat_note?('UNKNOW_NAME')
unless actor.stat_note?('UNKNOWN_STATUS')
draw_actor_state(actor, 114, rect.y, 48)
end
unless actor.stat_note?('UNKNOWN_HP')
draw_actor_hp(actor, 174, rect.y, 120)
end
unless actor.stat_note?('UNKNOWN_MP')
draw_actor_mp(actor, 310, rect.y, 70)
end
end
end
end
#==============================================================================
# ** Game_Enemy
#------------------------------------------------------------------------------
# This class handles enemy characters. It's used within the Game_Troop class
# ($game_troop).
#==============================================================================
class Game_Enemy < Game_Battler
#--------------------------------------------------------------------------
# Public Instance Variables
#--------------------------------------------------------------------------
attr_reader :status_note
#--------------------------------------------------------------------------
# Alias listing
#--------------------------------------------------------------------------
alias pac_unstat_ini initialize
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize(*args)
pac_unstat_ini(*args)
@status_note = enemy.note
end
#--------------------------------------------------------------------------
# * Get tag from enemy note
#--------------------------------------------------------------------------
def stat_note?(note)
return @status_note.include?(note)
end
end
end
#===============================================================================
#
# END OF SCRIPT
#
#===============================================================================
Credit
Thanks
- Lack of stuff to do that made me bored enough to do this.
- darkecho666, for a bug find.
Support
I live on RMRK.net. Just post here or PM me.
Known Compatibility Issues
Probably will not work with other battle systems, although this only changes Window_BattleStatus, but let me know if you divide by zero or something (this actually happened once!).
Demo
This is far too simple to need a demo.
Author's Notes
On my script writing scale, from inspired to dead bored, this is an incredibly bored script.
Restrictions
Credit me. I exhibit no problem for usage in commercial projects, but please let me know if you are using this in a commercial project.
:ccbysa: :rmvx:
For indie games. :nespad:
this is great thanks!
I forgot about this script XD
Now that I remember, this will work with Tankentai and the other ones... basically all battle systems that don't come with their own HUD. YEM, for example, might not like this script.
is there a way to script it so that instead of the hero's portrait that there Sprite would show up instead, but still have there portrait in the stats screen? Sorry if I wrote this wrong ???
What direction would you want the sprite to face in? Towards the player or the enemies?
well I think, Facing the player. :)
Nice simple script and just letting you know as stated, it does indeed have issues with certain scripts, for example, the ATB gauges will overlap the 2nd player's display, but its compatible with most other battle systems I've tried.
Well, I'd probably be able to write a compatibility version if anyone takes the effort to post here. Thanks for dropping by!
This script is now part of the PAC Build (http://rmrk.net/index.php/topic,42523.0.html), so if you have any issues see if you can't post them there.
I really like this script, thanks Pacman!
I'll be using this for my Game in a Week, nice one, Pacman. And I'm liking the new pic.
Why thank you, it'll be very nice to see my script in a game... for the first time.
I'm looking forward to all of your games.
Quote from: IpickZero on May 07, 2011, 02:54:43 AM
is there a way to script it so that instead of the hero's portrait that there Sprite would show up instead, but still have there portrait in the stats screen? Sorry if I wrote this wrong ???
I would like to see this too pacman!
Any chances?
:3
At the moment, no.
I'll have a crack on it over the weekend though. ;)
Cool then :3
Ill be waiting for it.
Over
;)
I'd like to use this in a game.
However there is a bug.
Some of my characters start with 0 MP and that causes the script to crash.
Here is the error output:
Script 'Battle Face HUD' line 114: ZeroDivisionError occured.
divided by 0
Of course the simple solution would be to give all my characters MP to start with, but in case there is someone else that wants a character with 0 MP somewhere in their games you might want to look over your script.
The refered line 114 is of course:
self.contents.gradient_fill_rect(x+7,y+37,(width-14)*actor.mp/actor.maxmp,3,mp_color1,mp_color2)
Oh, and thanks for the script, it makes battles look much less boring in VX :V
I did not foresee anything like that. Thanks for pointing that out.
Anyhow, replace that line with this code: if actor.maxmp != 0
self.contents.gradient_fill_rect(x+7,y+37,(width-14)*actor.mp/actor.maxmp,3,mp_color1,mp_color2)
else
self.contents.gradient_fill_rect(x+7,y+37,(width-14)*actor.mp,3,mp_color1,mp_color2)
end
And it should just show up as beautiful as you on the day I met you.
Script accordingly updated to cater for this error.
hey :V first off really nice job on this script! I was wondering though, could you tell me what lines im gonna have to mess with if i wanna change the font type, color of the text ext... hope to hear back soon :)
Script updated for more configuration. See OP.
awesome, thx so much Pacman :) :) :D
I have encountered a problem, the game seems insistent on having text-boxes pop up telling me about all the stuff in "EDITING SECTION"! Whenever you get the time it would be awesome if you could fix.
What do the messages say and when do they appear?
Show and tell :P
http://www.youtube.com/watch?v=7kZVlmmfEf4
OH SHIT. THANKS FOR SHOWING ME THAT. Those were lines I had in for testing purposes and forgot to take them out! Aargh! This'll fix it.
#-------------------------------------------------------------------------------
# Battler Face HUD
# Version 2.1
# By Pacman (rmrk.net)
# Description: There are a lot of battle scripts for VX out there, and they're
# mostly fantastic. However, they all require so much configuration. This script
# is the ultimate plug-and-play battle HUD: all you have to do is put it in the
# editor and alter one thing if you really want to. This script simply puts the
# actor's defined face into the battle window along with their HP and MP.
# Instructions: Put this script under materials and above main in the script
# editor. Change CharOpa to the desired opactiy if you wish, and let the
# script do the rest. You can also change the font type, size and colour in the
# configuration.
# Support: I reside almost ever-presently at rmrk.net.
#-------------------------------------------------------------------------------
module PacBFH # <- Do not touch
#-------------------------------------------------------------------------------
# EDITING SECTION
#-------------------------------------------------------------------------------
CharOpa = 150 # Default 150
Colour = [255, 255, 255] # RGB(A) values, separated by commas.
Size = 20
Font = "Verdana"
HPMP_SIZE = false # Does 'size' apply to the drawing of HP and MP?
#-------------------------------------------------------------------------------
# END EDITING SECTION
#-------------------------------------------------------------------------------
end
#==============================================================================
# ** Window_BattleStatus
#------------------------------------------------------------------------------
# This window displays the status of all party members on the battle screen.
#==============================================================================
class Window_BattleStatus < Window_Selectable
alias pacman_WBS_ini initialize
#-------------------------------------------------------------------------------
# Rewriting Initialize
#-------------------------------------------------------------------------------
def initialize
super(0,0,416,128,1)
@column_max = $game_party.members.size
refresh
self.active = false
self.opacity = 255
self.cursor_rect.set(0,self.index * 96, 90, 90)
end
#-------------------------------------------------------------------------------
# Rewriting draw_item
#-------------------------------------------------------------------------------
def draw_item(index)
rect = item_rect(index)
rect.x += 4
rect.width -= 8
rect.height = 96
self.contents.clear_rect(rect)
self.contents.font.color = Color.new(*PacBFH::Colour)
self.contents.font.size = PacBFH::Size
self.contents.font.name = PacBFH::Font
actor = $game_party.members[index]
draw_actor_face2(actor, index * 96,0,80)
draw_actor_name(actor, index * 96 + 8, 0)
draw_actor_state(actor, index * 96 + 4, 32, 20)
self.contents.font.size = PacBFH::HPMP_SIZE ? PacBFH::Size : 14
draw_hp_and_mp(actor, index * 96, 50, 90)
self.contents.font.color = Font.default_color
self.contents.font.name = Font.default_name
self.contents.font.size = Font.default_size
end
#-------------------------------------------------------------------------------
# Rewriting update_cursor
#-------------------------------------------------------------------------------
def update_cursor
if @index < 0
self.cursor_rect.empty
else
self.cursor_rect.set(index*96, 0, 90, 96)
end
end
end
#==============================================================================
# ** Window_Base
#------------------------------------------------------------------------------
# This is a superclass of all windows in the game.
#==============================================================================
class Window_Base < Window
#-------------------------------------------------------------------------------
# Writing draw_actor_face2
#-------------------------------------------------------------------------------
def draw_actor_face2(actor, x, y, width = 96, height = 96)
draw_face2(actor.face_name, actor.face_index, x, y, width, height)
end
#-------------------------------------------------------------------------------
# Once more for good luck!
#-------------------------------------------------------------------------------
def draw_face2(face_name, face_index, x, y, width = 96, height = 96)
bitmap = Cache.face(face_name)
rect = Rect.new(0, 0, 0, 0)
rect.x = face_index % 4 * 96 + (96 - width) / 2
rect.y = face_index / 4 * 96 + (96 - height) / 2
rect.width = width
rect.height = height -10
self.contents.blt(x+5, y+5, bitmap, rect, PacBFH::CharOpa)
bitmap.dispose
end
#-------------------------------------------------------------------------------
# Writing draw_hp_and_mp
#-------------------------------------------------------------------------------
def draw_hp_and_mp(actor,x,y,width)
back_color = Color.new(39, 58, 83, 255)
hp_color1 = Color.new(66, 114, 164, 255)
hp_color2 = Color.new(122, 175, 229, 255)
mp_color1 = Color.new(93, 50, 158, 255)
mp_color2 = Color.new(145, 122, 229, 255)
self.contents.fill_rect(x+5,y+15,width-10,7,back_color)
self.contents.gradient_fill_rect(x+7,y+17,(width-14)*actor.hp/actor.maxhp,3,hp_color1,hp_color2)
self.contents.draw_text(x+5,y,width-10,20,Vocab::hp,0)
self.contents.draw_text(x+5,y,width-10,20,actor.hp.to_s + "/" + actor.maxhp.to_s,2)
self.contents.fill_rect(x+5,y+35,width-10,7,back_color)
if actor.maxmp != 0
self.contents.gradient_fill_rect(x+7,y+37,(width-14)*actor.mp/actor.maxmp,3,mp_color1,mp_color2)
else
self.contents.gradient_fill_rect(x+7,y+37,(width-14)*actor.mp,3,mp_color1,mp_color2)
end
self.contents.draw_text(x+5,y+20,width-10,20,Vocab::mp,0)
self.contents.draw_text(x+5,y+20,width-10,20,actor.mp.to_s + "/" + actor.maxmp.to_s,2)
end
end
#-------------------------------------------------------------------------------
# END
#-------------------------------------------------------------------------------
hi, im new here also new at using RPG maker, im starting a new project and i would like to use this script but it seem to be a problem, im using the script for 6 party members and this one doesnt show all the faces, it cuts all the images, dont know anything about scripting so i dont know if there is a way to configure the size or a scroll down funtion like in the game default menu with more than 4 members, i would appretiate any help i could get :)
At the moment, there is no support for parties with more than 4 members. I'll see if I can get that in, but I guarantee nothing.
is ok, thanks ;)
I've updated this script with the Enemy HUD from PAC Battle Addons. I've also rewritten the script to be more learner-friendly, and added an option to use the original or new colours.
Nice 3.0 keep up the good work :)
Going back on what acuarion said.
I'd appreciate it if the battle HUD would support more than 4 party members as well.
I attempted this a lot. At the moment, I have not been able to make the HUD draw more than 4 members. This is mainly because of the way the actors' selection boxes are handled, the way the actors' faces are drawn and the way command windows slide.
I apologize for not being able to do this as of yet.
I understand, I tried it myself but failed.
Which is why I thought a more experienced ruby scripter could do it.
What I don't understand, is the fact that the default scripts have an option that allow you to have more characters, but fail to draw their windows properly.
I might have a look into rewriting that section of the default script for my own game.
Thanks for trying Pacman :)