#test wider rect in battle out and try shrinking gradient holes
#no_bonus_half_icons is somewhat broken
#do 'HP' half overlaying life? or MP?
#abstract more, like in draw_actor_mp/hp
#add "use life bar" option for mp-only
#per-actor max hp for option #3
#tp icon support
=begin
contact Galactic_Edge @ rpgmaker forums for bugs/requests
There are three ways to use this script, and you can mix any combination of
settings for your hp and mp bar. All 3 styles replace your bars with icons. You
can also use icons for hp bar and use the regular mp gauge.
1. Default: replaces your life bar (and mp bar) with icons. You can set the
maximum number of icons drawn, which is the number shown when you're at
full life/mp. The number of icons shown is proportional to your hp/mp
percentage. If you choose 8 max icons and your character has 75% life, 6
icons will be drawn. When you have less than half of the amount required
for a full icon, a half icon will be drawn (like a half heart) in the last
slot.
2. Zelda-style: The maximum number of icons drawn can change, and will be based
on your max hp/mp and a configurable setting called HP_PER_ICON/MP_PER_ICON.
If you have 10 hp, and HP_PER_ICON is set to 2, you will have 5 icons drawn.
If your health drops to 9, 4 icons and a half icon will be shown. AS your max
life increases, the number of icons drawn will also increase. That means you
have to avoid letting max hp get too high, or you will run out of space to
draw the icons.
3. Unchanging max hp/mp with overflow icons: your maximum hp will not grow
throughout the game, except for temporary bonuses. You set the HP_PER_ICON
and the MAX_HP_ICONS, then set each characters hp based on that (IE 5 max
icons and 3 hp per icon means each character should have 15 hp for the menu
to be accurate). You can still give bonus max hp, which will be represented
by additional icons stacking on top of each other at the end of the bar.
Example: if a character is supposed to have 15 life and HP_PER_ICON is 3,
then if his maximum health increased to 24 he would have 3 bonus icons drawn
(9 additional health / 3 HP_PER_ICON). If each icon looks like "-->", then
his bar will like this: -->-->-->-->-->>>>
Overwrites:
Window_Base.draw_actor_simple_status
Window_Base.draw_actor_hp
Window_Base.draw_actor_mp
Window_BattleStatus.draw_actor_mp
Window_BattleStatus.draw_item
Window_BattleStatus.draw_basic_area
Window_BattleStatus.draw_gauge_area
Window_BattleStatus.draw_gauge_area_with_tp
Window_BattleStatus.draw_gauge_area_without_tp
#Overrides
Window_Base.draw_actor_icons -> Window_BattleStatus.draw_actor_icons
Window_Selectable.col_max -> Window_BattleStatus.col_max
Window_Selectable.item_rect -> Window_BattleStatus.item_rect
Window_Selectable.item_rect_for_text -> Window_BattleStatus.item_rect_for_text
#Aliases
Scene_Map.create_all_windows
Scene_Map.post_transfer
Scene_Map.perform_transition
Game_Actor.execute_floor_damage
=end
#POSSIBLE: Double rows of health/mp
#options for 'mp' vocab and cur/max
#DRAW_HP_LABEL, DRAW_HP_VALUES
#FINAL:
#Remove if actor.absorb from draw_actor_tp.
#examine for efficiency. EX: can i calculate something once instead of doing it
#multiple times?
#Look for stupid stuff like using 'hp' in an mp method.
#set defaults for the guy
#test. does mp_label work? etc.
#mess with battle menu and try putting the gradients slightly closer
#cursor for battle menu?
#fourth option: added hps are distinct from max hp, so you have hps still grow,
#but also detect when bonus hps have been added and draw them stacking.
#for release: split into zelda_growth_style, static_style, and regular_hp_icons
#set defaults for public
module Life_Counter
#STUFF YOU REALLY NEED TO SET, OR VERIFY DEFAULTS ARE CORRECT:
#The icon indexes on your iconset you want to use for each type of icon.
#HALF_HP_ICON is drawn when you don't have enough HP to display a full icon at
#the end of your bar, like half-hearts in zelda. The image is automatically
#detected within the 24x24 icon index, and surrounding space is removed.
FULL_HP_ICON = 122
HALF_HP_ICON = 123
FULL_MP_ICON = 210
HALF_MP_ICON = 209
#This is the number of icons drawn when a character is at full hp/mp. Not used
#for option #2 (zelda-style)
MAX_HP_ICONS = 5
MAX_MP_ICONS = 4
#Use icons instead of the normal mp bar
USE_MP_ICON = true
#Use script option #1 from the descriptions at the top. Default.
#"true" will override ZELDA_STYLE_HP and STATIC_MAX_HP
REGULAR_STYLE_HP = true
REGULAR_STYLE_MP = true
#Zelda-style life, option #2 from top of the script.
ZELDA_STYLE_HP = false #Overrides STATIC_MAX_HP
ZELDA_STYLE_MP = false #Overrides STATIC_MAX_MP. #requires USE_MP_ICON = true,
#else normal mp bar is used
#Unchanging max hp/mp, option #3. The 3 options above must be false
STATIC_MAX_HP = false
STATIC_MAX_MP = false #requires USE_MP_ICON = true, else normal mp bar is used
#Used for options #2 and #3:
#At a default of 2, a character with 10 hp will have 5 icons drawn. one point
#of damage would cause a half icon to be drawn instead of a full icon, and 2
#damage would remove a full icon.
HP_PER_ICON = 10
MP_PER_ICON = 3
#recommended setting for ICON_SET below is 'auto'
#Set to 'manual' if you want more control over your icons, otherwise they'll
#be automatically set up. You can drop a small image, like a 5x5, anywhere in
#its selected icon_index on the Iconset. Its blank space will be removed, and
#its height and width properties set. You should use manual if: you want
#more empty space around the icon, 'auto' is not working, you want icons bigger
#than 24x24. Place the top left corner of your icon in the top left corner of
#its selected icon index and manually input the image's height and width below.
ICON_SET = "auto"
#Set only if using 'manual' above
HP_ICON_HEIGHT = 24
HP_ICON_WIDTH = 24
MP_ICON_HEIGHT = 24
MP_ICON_WIDTH = 24
#Show a field menu that display names and hp. set false to turn off. You must
#also set which maps it should appear on in the MAPS_TO_DISPLAY array below
MAP_DISPLAY = true
#Map ids on which the field menu will be shown. You will probably want the world
#map, and maybe dungeons. If you want to show it in most places, you can invert
#the logic and just add maps where you DON'T want it to be shown. Use ctrl F and
#search for this line (without the '#' at beginning):
# if Life_Counter::MAP_DISPLAY && Life_Counter::MAPS_TO_DISPLAY.include?($game_map.map_id)
#And replace it with this:
# if Life_Counter::MAP_DISPLAY && !Life_Counter::MAPS_TO_DISPLAY.include?($game_map.map_id)
MAPS_TO_DISPLAY = [1,2,3,4,5,6,7,8,9,10,15,27] #sample map id numbers.
#Filename of the window you want to use for field menu. You may want to use an
#invisible window, which just requires erasing all the graphics on the left
#half of the system window and making a new file from that.
#The default system window is typically found in:
#C:\Program Files (x86)\Steam\SteamApps\common\RPGVXAce\rtp\Graphics\System
MAP_WINDOW_NAME = "Window"
#Position of life display on the field menu. If set to nil OR if MAP_WINDOW_X
#or Y is set, this will be ignored. bottom left = "BL", left = "L",
#top left = "TL", top right = "TR", right = "R", bottom right = "BR", bottom = "B"
MAP_WINDOW_POS = "BL"
#YOU MAY WANT TO SET THIS STUFF:
#GLOBAL ----------------------------------------------------------------------
#Use half hp/mp icons to display life more accurately
USE_HALF_HP = true
USE_HALF_MP = true
#-----------------------------------------------------------------------------
#FIELD MENU ------------------------------------------------------------------
#manually set field window position. if x and y are nil they will be ignored
#and MAP_WINDOW_POS will be used. If x and/or y are set as integers, they will
#be used to position the field menu
MAP_WINDOW_Y = nil
MAP_WINDOW_X = nil
#This is the number of pixels of empty space that will be added between your
#your character's names and their hps on the field menu
FIELD_HP_X_PADDING = 6
#This is the vertical space between each party member's section on the field menu
FIELD_HP_Y_PADDING = 2
#Width of field menu. Increase if you need more space for icons
MAP_WINDOW_WIDTH = 180
#-----------------------------------------------------------------------------
#BATTLE MENU -----------------------------------------------------------------
#This will draw a gradient on the background of the battle menu to make clearer
#sections for each actor's information.
USE_GRADIENT = true
#This is the color of the gradient. It requires a number from 0 to 31. You can
#look at the system window to see which color is which. They are in the lower
#right corner, and start at 0 moving across and down. Window should be in:
#C:\Program Files (x86)\Steam\SteamApps\common\RPGVXAce\rtp\Graphics\System
FILL_COLOR = 1
#How far down the gradient begins drawing. May need to adjust if specific parts
#of it are clashing with your icons
GRADIENT_Y_ORIGIN = 0
#controls how much space is above HP and MP bars/icons in the battle window
#only. Adjust if hp/mp icon vertical spacing looks bad
HP_TOP_SPACING = 2
MP_TOP_SPACING = 2
#Length of mp gauge in battle, if not using mp icons
MP_GAUGE_WIDTH = 88
#distance each actor's mp gauge starts from left edge of their info area.
MP_GAUGE_X = 4
#-----------------------------------------------------------------------------
#MENU SCREEN -----------------------------------------------------------------
#Additional vertical space between your mp bar/icons and the hp icons above.
MENU_MP_Y_PADDING = 3
#-----------------------------------------------------------------------------
#SCRIPT OPTION #3: UNCHANGING HEALTH -----------------------------------------
#When 'STATIC_MAX_HP' is true and characters receieve bonuses that increase their
#hp/mp beyond your specified maximum, that extra health will be represented by
#additional icons that stack closely on top of each other at the end of the life
#bar. These settings let you manually control how closely they stack. This is
#automatically set to the icon's width / 3, but you can override that here.
#(examples: BONUS_HP_OVERLAP = HP_ICON_WIDTH / 4 + 2, BONUS_HP_OVERLAP = 8, etc)
BONUS_HP_OVERLAP = nil
BONUS_MP_OVERLAP = nil
#Setting this false will allow half icons to be drawn when a bonus has given you
#more than full life. Bonus life icons overlap, and half icons may may look very
#weird if they are a different size. Best if half icon is close to the same size.
#as regular icon. Can use the settings immediately below this to adjust the half
#icon's x coordinate, to push it farther from the last full icon.
NO_BONUS_HALF_ICONS = true
#If half icons are smaller than regular icons, they may fail to extend past
#regular icons when drawn closely on top of them. Use these to push the the
#icon's x coordinate farther past the last full icon
BONUS_HALF_HP_ICON_X = 0
BONUS_HALF_MP_ICON_X = 0
#-----------------------------------------------------------------------------
#MISC ------------------------------------------------------------------------
#Draw "MP" over your bar as normal. Only valid if not using mp icons
DRAW_MP_LABEL = true
DRAW_MP_VALUE = true #draw current/max mp
#-----------------------------------------------------------------------------
#IGNORE EVERYTHING BELOW
icons = { "full_hp" => FULL_HP_ICON, "half_hp" => HALF_HP_ICON,
"full_mp" => FULL_MP_ICON, "half_mp" => HALF_MP_ICON }
FULL_HP_AUTO_X = 0; HALF_HP_AUTO_X = 0; FULL_MP_AUTO_X = 0; HALF_MP_AUTO_X = 0
#detect icon size and position in Iconset index, set its constants
def self.detect_icon(index, type)
bitmap = Cache.system("Iconset")
i = 0; j = 0; left = 23; right = 0; top = 23; bottom = 0;
while i < 24
j = 0
while j < 24
color = bitmap.get_pixel(index % 16 * 24 + i, index / 16 * 24 + j)
if color.alpha > 0
left = i < left ? i : left
top = j < top ? j : top
right = i > right ? i : right
bottom = j > bottom ? j : bottom
end; j += 1
end; i += 1
end
case type
when "full_hp"
height = bottom - top + 1; const_set("HP_ICON_HEIGHT", height)
width = right - left + 1; const_set("HP_ICON_WIDTH", width)
BONUS_HP_OVERLAP == nil ? const_set("BONUS_HP_OVERLAP", HP_ICON_WIDTH / 3) : nil
const_set("FULL_HP_AUTO_X", left)
const_set("FULL_HP_AUTO_Y", top)
when "half_hp"
const_set("HALF_HP_AUTO_X", left)
const_set("HALF_HP_AUTO_Y", top)
when "full_mp"
height = bottom - top + 1; const_set("MP_ICON_HEIGHT", height)
width = right - left + 1; const_set("MP_ICON_WIDTH", width)
BONUS_MP_OVERLAP == nil ? const_set("BONUS_MP_OVERLAP", MP_ICON_WIDTH / 3) : nil
const_set("FULL_MP_AUTO_X", left)
const_set("FULL_MP_AUTO_Y", top)
when "half_mp"
const_set("HALF_MP_AUTO_X", left)
const_set("HALF_MP_AUTO_Y", top)
end
end
if ICON_SET == "auto"
icons.each_pair do |key, value|
detect_icon(value, key)
end
else
BONUS_HP_OVERLAP == nil ? const_set("BONUS_HP_OVERLAP", HP_ICON_WIDTH / 3) : nil
BONUS_MP_OVERLAP == nil ? const_set("BONUS_MP_OVERLAP", MP_ICON_WIDTH / 3) : nil
end
#override incorrect settings
if ZELDA_STYLE_HP
const_set("STATIC_MAX_HP", false)
end
if ZELDA_STYLE_MP
const_set("STATIC_MAX_MP", false)
end
if REGULAR_STYLE_HP
const_set("ZELDA_STYLE_HP", false)
const_set("STATIC_MAX_HP", false)
end
if REGULAR_STYLE_MP
const_set("ZELDA_STYLE_MP", false)
const_set("STATIC_MAX_MP", false)
end
#set coordinates for menu layout
MP_Y_START = HP_TOP_SPACING + Life_Counter::HP_ICON_HEIGHT + 25
TP_Y_START = MP_Y_START + MP_TOP_SPACING + Life_Counter::MP_ICON_HEIGHT - 4
#store icon_rectangles for drawing from bitmap
mp_size = [MP_ICON_WIDTH, MP_ICON_HEIGHT]
FULL_MP_ICON_RECT = Rect.new(FULL_MP_ICON % 16 * 24 + FULL_MP_AUTO_X, FULL_MP_ICON / 16 * 24 + FULL_MP_AUTO_Y, mp_size[0], mp_size[1])
HALF_MP_ICON_RECT = Rect.new(HALF_MP_ICON % 16 * 24 + HALF_MP_AUTO_X, HALF_MP_ICON / 16 * 24 + HALF_MP_AUTO_Y, mp_size[0], mp_size[1])
hp_size = [HP_ICON_WIDTH, HP_ICON_HEIGHT]
FULL_HP_ICON_RECT = Rect.new(FULL_HP_ICON % 16 * 24 + FULL_HP_AUTO_X, FULL_HP_ICON / 16 * 24 + FULL_HP_AUTO_Y, hp_size[0], hp_size[1])
HALF_HP_ICON_RECT = Rect.new(HALF_HP_ICON % 16 * 24 + HALF_HP_AUTO_X, HALF_HP_ICON / 16 * 24 + HALF_HP_AUTO_Y, hp_size[0], hp_size[1])
#set coordinates for menu layout
ICON_Y_START = TP_Y_START + 20
#map for field life window hardcoded positions
MAP_WINDOW_COORDS = {"BL" => [5,290], "L" => [5,150], "TL" => [5,5], "T" => [195,5],
"TR" => [358,5], "R" => [358,150], "BR" => [358,290], "B" => [195,290]}
end
class Window_BattleStatus < Window_Selectable
alias life_init initialize
def initialize #alias
@party_size_offset = (400 - $game_party.members.length * 100) / 2
life_init
end
def draw_actor_mp(actor, x, y, width = 99) #overwrite
return draw_regular_mp(actor, x, y) if !Life_Counter::USE_MP_ICON
return draw_zelda_mp(actor, x, y) if Life_Counter::ZELDA_STYLE_MP
value_of_counter = 1 / Life_Counter::MAX_MP_ICONS.to_f
total_icons = (actor.mp_rate / value_of_counter).ceil.to_i
if Life_Counter::USE_HALF_MP
draw_half_icon = actor.mp_rate < 1.0 && actor.mp_rate % value_of_counter <= value_of_counter / 2
end
size = Life_Counter::MP_ICON_WIDTH
bitmap = Cache.system("Iconset")
total_icons.times do |i|
if i == total_icons - 1 && draw_half_icon
draw_custom_mp(Life_Counter::HALF_MP_ICON_RECT,x + i * size + 4,y,bitmap)
else
draw_custom_mp(Life_Counter::FULL_MP_ICON_RECT,x + i * size + 4,y,bitmap)
end
end
if Life_Counter::STATIC_MAX_MP
draw_bonus_mp(x,y,size,actor,bitmap)
end
end
def draw_actor_mp(actor, x, y, width = 124) #overwrite
return draw_regular_mp(actor, x, y) if !Life_Counter::USE_MP_ICON
return draw_zelda_mp(actor, x, y) if Life_Counter::ZELDA_STYLE_MP
offset = 0
value_of_counter = 1.0 / Life_Counter::MAX_MP_ICONS
total_icons = (actor.get_rate("mp") / value_of_counter).ceil.to_i
total_icons -= float_fix(actor,value_of_counter,"mp")
total_icons = overmaxed(actor,"mp") ? Life_Counter::MAX_MP_ICONS : total_icons
draw_half_icon = check_half_icon(actor,value_of_counter,"mp")
bitmap = Cache.system("Iconset")
x_coord = x - offset + 4
total_icons.times do |i|
if i == total_icons - 1 && draw_half_icon
draw_custom_mp(Life_Counter::HALF_MP_ICON_RECT,x_coord,y,bitmap)
else
draw_custom_mp(Life_Counter::FULL_MP_ICON_RECT,x_coord,y,bitmap)
end
x_coord += Life_Counter::MP_ICON_WIDTH
end
if Life_Counter::STATIC_MAX_MP
x_coord -= Life_Counter::MP_ICON_WIDTH - Life_Counter::BONUS_MP_OVERLAP
draw_bonus_mp(x_coord,y,actor,bitmap)
end
end
def draw_regular_mp(actor, x, y, width = Life_Counter::MP_GAUGE_WIDTH) #added
draw_regular_gauge(x + Life_Counter::MP_GAUGE_X, y, width, actor.mp_rate, mp_gauge_color1, mp_gauge_color2)
change_color(system_color)
draw_text(x + Life_Counter::MP_GAUGE_X, y, 30, line_height, Vocab::mp_a) if Life_Counter::DRAW_MP_LABEL
draw_current_and_max_values(x, y, width, actor.mp, actor.mmp,
mp_color(actor), normal_color) if Life_Counter::DRAW_MP_VALUE
end
def draw_zelda_mp(actor, x, y, width = 99) #added
total_icons = (actor.mp.to_f / Life_Counter::MP_PER_ICON).ceil.to_i
remainder = (actor.mp % Life_Counter::MP_PER_ICON) / Life_Counter::MP_PER_ICON.to_f
if Life_Counter::USE_HALF_MP
draw_half_icon = remainder > 0 && remainder <= 0.5
end
size = Life_Counter::MP_ICON_WIDTH
bitmap = Cache.system("Iconset")
total_icons.times do |i|
if i == total_icons - 1 && draw_half_icon
draw_custom_mp(Life_Counter::HALF_MP_ICON_RECT,x + i * size + 4,y,bitmap)
else
draw_custom_mp(Life_Counter::FULL_MP_ICON_RECT,x + i * size + 4,y,bitmap)
end
end
end
def draw_item(index) #overwrite
actor = $game_party.battle_members[index]
draw_basic_area(basic_area_rect(index), actor, index)
draw_gauge_area(gauge_area_rect(index), actor, index)
end
def draw_basic_area(rect, actor, index) #overwrite
draw_gradient(index * 99 + @party_size_offset,22,96) if Life_Counter::USE_GRADIENT
draw_actor_name(actor, index * 99 + 4 + @party_size_offset, 0, 99)
draw_actor_icons(actor, index * 99 + 4 + @party_size_offset, Life_Counter::ICON_Y_START, 99)
end
def draw_gauge_area(rect, actor, index) #overwrite
if $data_system.opt_display_tp
draw_gauge_area_with_tp(rect, actor, index)
else
draw_gauge_area_without_tp(rect, actor, index)
end
end
def draw_gauge_area_with_tp(rect, actor, index) #overwrite
draw_actor_hp(actor, index * 99 + @party_size_offset, 22, 100)
draw_actor_mp(actor, index * 99 + @party_size_offset, Life_Counter::MP_Y_START, 99)
draw_actor_tp(actor, index * 99 + @party_size_offset, Life_Counter::TP_Y_START, 99)
end
def draw_gauge_area_without_tp(rect, actor, index) #overwrite
#draw_gauge(index * 100,22,100,100,text_color(1),text_color(2))
draw_actor_hp(actor, index * 99 + @party_size_offset, 22, 99)
draw_actor_mp(actor, index * 99 + @party_size_offset, Life_Counter::MP_Y_START, 99)
end
def draw_gradient(x, y, width) #added
gauge_y = Life_Counter::GRADIENT_Y_ORIGIN
color = Life_Counter::FILL_COLOR
#contents.fill_rect(x, gauge_y + 44 + 8, width, 8, text_color(color))
contents.gradient_fill_rect(x, gauge_y, width, 48, text_color(32), text_color(color),true)
contents.gradient_fill_rect(x, gauge_y + 48, width, 52, text_color(color), text_color(32),true)
end
def draw_regular_gauge(x, y, width, rate, color1, color2) #added
fill_w = (width * rate).to_i
gauge_y = y + line_height - 8
contents.fill_rect(x, gauge_y, width, 6, gauge_back_color)
contents.gradient_fill_rect(x, gauge_y, fill_w, 6, color1, color2)
end
def draw_actor_icons(actor, x, y, width = 99) #override
icons = (actor.state_icons + actor.buff_icons)[0, width / 24] || []
icons.each_with_index {|n, i| draw_icon(n, x + 24 * i, y) }
end
def col_max #override
return 4
end
def item_rect(index) #override
rect = Rect.new
rect.width = 95
rect.height = 96
rect.x = (index % col_max * (item_width + spacing)) - 7 * index + @party_size_offset
rect.y = index / col_max * item_height
rect
end
def item_rect_for_text(index) #override
rect = item_rect(index)
rect.x += 4
rect.width -= 8
rect
end
end
#added
class Window_Life_Counter < Window_Base
def initialize
if Life_Counter::MAP_WINDOW_X.is_a?(Integer) && Life_Counter::MAP_WINDOW_Y.is_a?(Integer)
window_x = Life_Counter::MAP_WINDOW_X
window_y = Life_Counter::MAP_WINDOW_Y
else
window_x = Life_Counter::MAP_WINDOW_COORDS[Life_Counter::MAP_WINDOW_POS][0]
window_y = Life_Counter::MAP_WINDOW_COORDS[Life_Counter::MAP_WINDOW_POS][1]
end
super(window_x, window_y, window_width, fitting_height($game_party.battle_members.length))
self.windowskin = Cache.system(Life_Counter::MAP_WINDOW_NAME)
calc_life_pos
refresh
end
def window_width
return Life_Counter::MAP_WINDOW_WIDTH
end
def refresh
contents.clear
draw_all_actors
end
def open
refresh
super
end
def draw_all_actors
i = 0
while i < 4
draw_actor_info(i)
i += 1
end
end
def calc_life_pos
calc_life_x
calc_life_y
end
def calc_life_x
i = 0; max = 1
while i < 4
actor = $game_party.members[i]
max = text_size($game_party.members[i].name).width.to_i > max ? text_size($game_party.members[i].name).width.to_i : max
i += 1
end
@hp_x = max
end
def calc_life_y
line_center = 12; icon_center = Life_Counter::HP_ICON_HEIGHT / 2
@hp_y = line_center - icon_center
end
def draw_actor_info(index)
actor = $game_party.members[index]
draw_actor_name(actor, 2, index * line_height + 2)
return draw_zelda_hp(index,actor) if Life_Counter::ZELDA_STYLE_HP
value_of_counter = 1.0 / Life_Counter::MAX_HP_ICONS
total_icons = (actor.get_rate("hp") / value_of_counter).ceil.to_i
total_icons -= float_fix(actor,value_of_counter,"hp")
total_icons = overmaxed(actor,"hp") ? Life_Counter::MAX_HP_ICONS : total_icons
draw_half_icon = check_half_icon(actor,value_of_counter, "hp")
size = Life_Counter::HP_ICON_WIDTH
bitmap = Cache.system("Iconset")
x_coord = 0
y_coord = index * line_height + @hp_y + Life_Counter::FIELD_HP_Y_PADDING
total_icons.times do |i|
x_coord = @hp_x + i * size + Life_Counter::FIELD_HP_X_PADDING
if i == total_icons - 1 && draw_half_icon
draw_custom_hp(Life_Counter::HALF_HP_ICON_RECT, x_coord, y_coord, bitmap)
else
draw_custom_hp(Life_Counter::FULL_HP_ICON_RECT, x_coord, y_coord, bitmap)
end
end
if Life_Counter::STATIC_MAX_HP
draw_bonus_hp(x_coord,y_coord,actor,bitmap)
end
end
def draw_bonus_hp(x_coord,y_coord,actor,bitmap)
total_bonus_icons = (actor.hp.to_f - Life_Counter::MAX_HP_ICONS * Life_Counter::HP_PER_ICON) / Life_Counter::HP_PER_ICON
while total_bonus_icons > 0
x_coord += Life_Counter::BONUS_HP_OVERLAP
if total_bonus_icons > 0.5 || !Life_Counter::USE_HALF_HP || Life_Counter::NO_BONUS_HALF_ICONS
draw_custom_hp(Life_Counter::FULL_HP_ICON_RECT,x_coord,y_coord,bitmap)
total_bonus_icons -= 1
else
draw_custom_hp(Life_Counter::HALF_HP_ICON_RECT,x_coord + Life_Counter::BONUS_HALF_HP_ICON_X,y_coord,bitmap)
total_bonus_icons = 0
end
end
end
def draw_zelda_hp(index,actor)
total_icons = (actor.hp.to_f / Life_Counter::HP_PER_ICON).ceil.to_i
remainder = (actor.hp % Life_Counter::HP_PER_ICON) / Life_Counter::HP_PER_ICON.to_f
if Life_Counter::USE_HALF_HP
draw_half_icon = remainder > 0 && remainder <= 0.5
end
offset = $game_party.in_battle ? 1 : 5
size = Life_Counter::HP_ICON_WIDTH
bitmap = Cache.system("Iconset")
x_coord = 0
y_coord = index * line_height + @hp_y + Life_Counter::FIELD_HP_Y_PADDING
total_icons.times do |i|
x_coord = @hp_x + i * size + Life_Counter::FIELD_HP_X_PADDING
if i == total_icons - 1 && draw_half_icon
draw_custom_hp(Life_Counter::HALF_HP_ICON_RECT,x_coord, y_coord,bitmap)
else
draw_custom_hp(Life_Counter::FULL_HP_ICON_RECT,x_coord, y_coord,bitmap)
end
end
end
end
class Scene_Map < Scene_Base
alias add_life_window create_all_windows
alias life_post_transfer post_transfer
alias life_perform_transition perform_transition
attr_accessor :life_window
def create_all_windows #alias
add_life_window
@life_window = Window_Life_Counter.new
end
def post_transfer #alias
choose_life_display
life_post_transfer
end
def perform_transition #alias
choose_life_display
life_perform_transition
end
def choose_life_display #added
if Life_Counter::MAP_DISPLAY && Life_Counter::MAPS_TO_DISPLAY.include?($game_map.map_id)
@life_window.show
else
@life_window.hide
end
end
end
class Window_Base
def draw_actor_simple_status(actor, x, y) #overwrite
draw_actor_name(actor, x, y)
draw_actor_level(actor, x, y + line_height * 1)
draw_actor_icons(actor, x, y + line_height * 2)
draw_actor_class(actor, x + 120, y)
draw_actor_hp(actor, x + 120, y + line_height * 1)
y = y - (24 - Life_Counter::HP_ICON_HEIGHT) + Life_Counter::MENU_MP_Y_PADDING
draw_actor_mp(actor, x + 120, y + line_height * 2)
end
def draw_actor_hp(actor, x, y, width = 99) #overwrite
return draw_zelda_hp(actor, x, y) if Life_Counter::ZELDA_STYLE_HP
value_of_counter = 1.0 / Life_Counter::MAX_HP_ICONS
total_icons = (actor.get_rate("hp") / value_of_counter).ceil.to_i
total_icons -= float_fix(actor,value_of_counter,"hp")
total_icons = overmaxed(actor,"hp") ? Life_Counter::MAX_HP_ICONS : total_icons
draw_half_icon = check_half_icon(actor,value_of_counter,"hp")
offset = $game_party.in_battle ? 1 : 5
bitmap = Cache.system("Iconset")
x_coord = x - offset + 4
total_icons.times do |i|
if i == total_icons - 1 && draw_half_icon
draw_custom_hp(Life_Counter::HALF_HP_ICON_RECT,x_coord,y,bitmap)
else
draw_custom_hp(Life_Counter::FULL_HP_ICON_RECT,x_coord,y,bitmap)
end
x_coord += Life_Counter::HP_ICON_WIDTH
end
if Life_Counter::STATIC_MAX_HP
x_coord -= Life_Counter::HP_ICON_WIDTH - Life_Counter::BONUS_HP_OVERLAP
draw_bonus_hp(x_coord,y,actor,bitmap)
end
end
def draw_bonus_hp(x_coord,y_coord,actor,bitmap)
total_bonus_icons = (actor.hp.to_f - Life_Counter::MAX_HP_ICONS * Life_Counter::HP_PER_ICON) / Life_Counter::HP_PER_ICON
while total_bonus_icons > 0
if total_bonus_icons > 0.5 || !Life_Counter::USE_HALF_HP || Life_Counter::NO_BONUS_HALF_ICONS
draw_custom_hp(Life_Counter::FULL_HP_ICON_RECT,x_coord,y_coord,bitmap)
total_bonus_icons -= 1
else
draw_custom_hp(Life_Counter::HALF_HP_ICON_RECT,x_coord + Life_Counter::BONUS_HALF_HP_ICON_X,y_coord,bitmap)
total_bonus_icons = 0
end
x_coord += Life_Counter::BONUS_HP_OVERLAP
end
end
def draw_regular_mp(actor, x, y, width = 124) #added
draw_gradient(x, y, width, actor.mp_rate, mp_gauge_color1, mp_gauge_color2)
change_color(system_color)
draw_text(x, y, 30, line_height, Vocab::mp_a) if Life_Counter::DRAW_MP_LABEL
draw_current_and_max_values(x, y, width, actor.mp, actor.mmp,
mp_color(actor), normal_color) if Life_Counter::DRAW_MP_VALUE
end
def draw_zelda_hp(actor, x, y, width = 99) #added
total_icons = (actor.hp.to_f / Life_Counter::HP_PER_ICON).ceil.to_i
remainder = (actor.hp % Life_Counter::HP_PER_ICON) / Life_Counter::HP_PER_ICON.to_f
if Life_Counter::USE_HALF_HP
draw_half_icon = remainder > 0 && remainder <= 0.5
end
offset = $game_party.in_battle ? 1 : 5
size = Life_Counter::HP_ICON_WIDTH
bitmap = Cache.system("Iconset")
total_icons.times do |i|
if i == total_icons - 1 && draw_half_icon
draw_custom_mp(Life_Counter::HALF_HP_ICON_RECT,x - offset + i * size + 4,y,bitmap)
else
draw_custom_mp(Life_Counter::FULL_HP_ICON_RECT,x - offset + i * size + 4,y,bitmap)
end
end
end
def draw_zelda_mp(actor, x, y, width = 99) #added
total_icons = (actor.mp.to_f / Life_Counter::MP_PER_ICON).ceil.to_i
remainder = (actor.mp % Life_Counter::MP_PER_ICON) / Life_Counter::MP_PER_ICON.to_f
if Life_Counter::USE_HALF_MP
draw_half_icon = remainder > 0 && remainder <= 0.5
end
offset = $game_party.in_battle ? 0 : 5
size = Life_Counter::MP_ICON_WIDTH
bitmap = Cache.system("Iconset")
total_icons.times do |i|
if i == total_icons - 1 && draw_half_icon
draw_custom_mp(Life_Counter::HALF_MP_ICON_RECT,x - offset + i * size + 4,y,bitmap)
else
draw_custom_mp(Life_Counter::FULL_MP_ICON_RECT,x - offset + i * size + 4,y,bitmap)
end
end
end
def draw_custom_hp(rect, x, y, enabled = true, bitmap) #added
contents.blt(x, y, bitmap, rect, enabled ? 255 : translucent_alpha)
end
alias draw_custom_mp draw_custom_hp
def draw_actor_mp(actor, x, y, width = 124) #overwrite
return draw_regular_mp(actor, x, y) if !Life_Counter::USE_MP_ICON
return draw_zelda_mp(actor, x, y) if Life_Counter::ZELDA_STYLE_MP
offset = 5
value_of_counter = 1.0 / Life_Counter::MAX_MP_ICONS
total_icons = (actor.get_rate("mp") / value_of_counter).ceil.to_i
total_icons -= float_fix(actor,value_of_counter,"mp")
total_icons = overmaxed(actor,"mp") ? Life_Counter::MAX_MP_ICONS : total_icons
draw_half_icon = check_half_icon(actor,value_of_counter,"mp")
bitmap = Cache.system("Iconset")
x_coord = x - offset + 4
total_icons.times do |i|
if i == total_icons - 1 && draw_half_icon
draw_custom_mp(Life_Counter::HALF_MP_ICON_RECT,x_coord,y,bitmap)
else
draw_custom_mp(Life_Counter::FULL_MP_ICON_RECT,x_coord,y,bitmap)
end
x_coord += Life_Counter::MP_ICON_WIDTH
end
if Life_Counter::STATIC_MAX_MP
x_coord -= Life_Counter::MP_ICON_WIDTH - Life_Counter::BONUS_MP_OVERLAP
draw_bonus_mp(x_coord,y,actor,bitmap)
end
end
def draw_bonus_mp(x_coord,y_coord,actor,bitmap) #added
total_bonus_icons = (actor.mp.to_f - Life_Counter::MAX_MP_ICONS * Life_Counter::MP_PER_ICON) / Life_Counter::MP_PER_ICON
while total_bonus_icons > 0
if total_bonus_icons > 0.5 || !Life_Counter::USE_HALF_MP || Life_Counter::NO_BONUS_HALF_ICONS
draw_custom_mp(Life_Counter::FULL_MP_ICON_RECT,x_coord,y_coord,bitmap)
total_bonus_icons -= 1
else
draw_custom_mp(Life_Counter::HALF_MP_ICON_RECT,x_coord + Life_Counter::BONUS_HALF_MP_ICON_X,y_coord,bitmap)
total_bonus_icons = 0
end
x_coord += Life_Counter::BONUS_MP_OVERLAP
end
end
def draw_regular_mp(actor, x, y, width = 124) #added
draw_gauge(x, y, width, actor.mp_rate, mp_gauge_color1, mp_gauge_color2)
change_color(system_color)
draw_text(x, y, 30, line_height, Vocab::mp_a) if Life_Counter::DRAW_MP_LABEL
draw_current_and_max_values(x, y, width, actor.mp, actor.mmp,
mp_color(actor), normal_color) if Life_Counter::DRAW_MP_VALUE
end
def overmaxed(actor,type) #added
if type == "hp"
return Life_Counter::STATIC_MAX_HP && actor.hp >= Life_Counter::MAX_HP_ICONS * Life_Counter::HP_PER_ICON
elsif type == "mp"
return Life_Counter::STATIC_MAX_MP && actor.mp >= Life_Counter::MAX_MP_ICONS * Life_Counter::MP_PER_ICON
end
end
def check_half_icon(actor,value_of_counter,type) #added
case type
when "mp"
icon_type = Life_Counter::USE_HALF_MP
rate = actor.get_rate('mp')
when "hp"
icon_type = Life_Counter::USE_HALF_HP
rate = actor.get_rate('hp')
end
if icon_type
leftover = rate % value_of_counter
final_amount = value_of_counter / 2 - leftover + 0.0001
almost_zero = leftover > -0.0001 && leftover < 0.0001
return rate < 1.0 && final_amount > 0 && !almost_zero
else return false
end
end
def float_fix(actor,value_of_counter,type)
rate = actor.get_rate(type) / value_of_counter
(rate - rate.round) > 0 && (rate - rate.round) < 0.00001 ? 1 : 0
end
end
class Game_Actor
alias refresh_life_window execute_floor_damage
def execute_floor_damage #alias
refresh_life_window
SceneManager.scene.life_window.refresh
end
def get_rate(type) #added
case type
when "hp"
if Life_Counter::STATIC_MAX_HP
return hp.to_f / (Life_Counter::MAX_HP_ICONS * Life_Counter::HP_PER_ICON)
else
return hp_rate
end
when "mp"
if Life_Counter::STATIC_MAX_MP
return mp.to_f / (Life_Counter::MAX_MP_ICONS * Life_Counter::MP_PER_ICON)
else
return mp_rate
end
end
end
end