Can't find life-counter script

Power Master

Optimistic Game Designer
Veteran
Joined
Apr 18, 2015
Messages
112
Reaction score
12
First Language
English
Primarily Uses
RMMV
I was thinking of having my game use a "life counter" instead of a health bar. You know, you get hit and your counter goes down by 1 or whatever. (A good example of what I want since I'm terrible with words.)


I kept looking for a script that adds this into the game, but I can't find one. Graphics aren't an issue, I can make those. But can someone point me in the right direction, please?


If such a thing doesn't exist, well... Perhaps someone could make one? :/ This isn't really important to the game, it's just a mechanic I thought I'd try, but I can't find a script for it.
 

Archeia

Level 99 Demi-fiend
Developer
Joined
Mar 1, 2012
Messages
15,144
Reaction score
15,478
First Language
Filipino
Primarily Uses
RMMZ
I've moved this thread to RGSS3 Script Requests. Please be sure to post your threads in the correct forum next time. Thank you.
 

DarkBooDev

Destroyer of Worlds
Veteran
Joined
Mar 25, 2016
Messages
66
Reaction score
37
First Language
English
Primarily Uses
Couldn't you just set a global event that would display the image of your life counter and have it display a new image whenever you get hit/are healed? Correct if I'm wrong, but I think that should work.
 

Power Master

Optimistic Game Designer
Veteran
Joined
Apr 18, 2015
Messages
112
Reaction score
12
First Language
English
Primarily Uses
RMMV
I've moved this thread to RGSS3 Script Requests. Please be sure to post your threads in the correct forum next time. Thank you.
I never really know where to put these types of posts, sorry. This whole setup kinda confuses me, but I'm trying to learn.

Couldn't you just set a global event that would display the image of your life counter and have it display a new image whenever you get hit/are healed? Correct if I'm wrong, but I think that should work.
I tried to see if I could work around scripting by using Common Events and Variables and whatever. But there's no Conditional Branch for "x's HP is lower than 8".


Any suggestions on this, though? I'm pretty sure that, if I can work around scripting, I'm doing something wrong. I need it to show a new pic every time an actor takes damage.
 

Sixth

Veteran
Veteran
Joined
Jul 4, 2014
Messages
2,162
Reaction score
823
First Language
Hungarian
Primarily Uses
RMVXA
$game_actors[ID].hp < value
$game_party.members[index].hp < value


The first checks actors by their database ID, the second checks actors based on their position in the party.


You can use these in scripted conditional branches.


Although, I am pretty sure that I saw a script which does the thing you ask for somewhere.


It also shouldn't be hard to script, so I will try to make one for you tonight.
 

Galactic_Edge

Villager
Member
Joined
Jul 16, 2013
Messages
23
Reaction score
2
First Language
English
Primarily Uses
Did you get what you needed? I made a little sample.





This is just an example. The script would still need a fair amount of work to be fully functional. I'd also need to know if you want to keep tp/mp gauges, or if they would also be counter-style, like health. If so, would they have different icons, or would they all use a generic counter?


There's a bunch of things I can make configurable fairly easily:


1. The maximum number of icons displayed


2. The size of the life icon, so you can display more,or take up less space (this will require you to carefully position a graphic on the iconset and input its exact height and width)


3. Displaying the "HP" text (like it does for "MP" and "TP") and it choosing its location


4. Displaying life as an integer (IE "113") and its horizontal location


5. Displaying half-unit icons, like the broken heart


6. The horizontal position at which the icons begin to draw. IE: how close they start to the end of the character's name


7. The spacing between icons


8. Rounding behavior: If max number of icons for full health is 4, should it round down to 3 as soon as health falls below 99%, or wait until it's 75% or below?


Let me know if you already found a script that does most of this. it would probably be easier to modify or patch than to code it from scratch
 
Last edited by a moderator:

Power Master

Optimistic Game Designer
Veteran
Joined
Apr 18, 2015
Messages
112
Reaction score
12
First Language
English
Primarily Uses
RMMV
I have not found a script yet, no, but what you have there would be perfect! I am planning on keeping the MP, but the TP is not needed in my game. I'm not sure yet if Magic will have it's own counter. If it does, it would need to be small enough so it wouldn't conflict with the Health... perhaps a wheel?


Sorry, were you going to provide me with the script or is what you're showing here an example saying that it can be done?
 

Sixth

Veteran
Veteran
Joined
Jul 4, 2014
Messages
2,162
Reaction score
823
First Language
Hungarian
Primarily Uses
RMVXA
I made a map HUD which shows HP as health icons, but than I realized that there are far too many missing info here...


Than I wanted to ask about these things, but forgot about it. :p


For example:


1. Where do you want to show this new HP display? In all of the menus, in the battle, on the map, somewhere else? 


2. The link you gave leads to a page which shows around a dozens of HP displays from different Mario (?) games. That's not really helpful. You should tell exactly which one you need, or link a direct image showing which type of display you need.


3. You wrote, "you get hit and your counter goes down by 1 or whatever". So, is it 1 health icon per 1 HP or you want it to be counted some other way (based on HP rates, like Galactic_Edge's script, for example)? 


4. Plus the questions Galactid_Edge asked.


And just to note...


Making a "wheel" gauge type is difficult in RPG Maker because the built-in Bitmap class is very limited, to say the least.


You will either need a custom dll to handle these type of gauges or make it using the built-in methods, but that will most probably be very slow, and might decrease your FPS (based on when you update the gauges, how many are there at once, and how frequently).


@Galactic_Edge


That looks nice!


I assume that you work with HP rates (judging from the rounding question), and that makes me wonder.


What happens if the max HP icons displayed is 4, and the HP rate falls below, let's say 20%, but the actor is still alive. Based on how you display these icons, the HP display will either show 0 icons (which would be weird, since the actor is still alive, right?) or it would show 1, but that won't really tell the player how much HP is left either way.


No idea about others, but in an RPG, I like to see my exact HP with either a precise gauge or numbers. Just my thoughts on this.
 

Galactic_Edge

Villager
Member
Joined
Jul 16, 2013
Messages
23
Reaction score
2
First Language
English
Primarily Uses
@Sixth Do you still want to handle this? I didn't really do much yet, and it sounds like you had a plan. I really don't mind either way.


I bumped into exactly that situation you described, and it definitely looked weird to have a guy alive with no hearts. I'm using half-icons instead of showing nothing at the moment. I personally would also keep the integer display, in addition to the life units. I'm using life rate to calculate number of hearts, since that could work for anything, even a "1 hit costs 1 life point" system. I think I would probably implement that by just setting enemy dmg to always be 1 (or to be equal to their attack value, so they could do more). But I don't know if he wants to get rid of explicit HP and variable enemy damage.

Sorry, were you going to provide me with the script or is what you're showing here an example saying that it can be done?


This is just an example. A request involving UI is hard to get exactly right without full, specific requirements, and there usually a bunch of tiny little issues you would never think of until you actually bump into them. So I'd prefer to avoid pulling the trigger on a full script until I have more information. Sixth asked some good questions. Keep in mind that life bars are displayed in more than one menu, and the menus aren't arranged the same way, so they have different size constraints and will need different coding.


I can probably do a script that will allow a lot of control to shrink and enlarge the mp/life counters. The icon size and max number would be configurable too, so you could just use smaller life counters and mp counters if space becomes an issue. You should be able to fit both HP and MP counters in the battle menu at least, especially if you're not using TP. And just to be clear, you can use any images. It doesn't have to be hearts and half hearts.
 
Last edited by a moderator:

Power Master

Optimistic Game Designer
Veteran
Joined
Apr 18, 2015
Messages
112
Reaction score
12
First Language
English
Primarily Uses
RMMV
Alright, let's see if I can explain what I want here...


@Galactic_Edge


1. Maximum number of icons displayed. I'd say 5, hearts and half hearts, in total.


By the way, would temporary Health increasing items/spells work with this or should I avoid those all together to make things easier?


2. Standard height and width (24x24 pixels) should be fine. If needed otherwise, please tell me.


3. Maybe a way to say the actor's name then "Health" afterward, if possible?


Location of the word(s) would be either directly before or above the health meter.


4. I don't think an integer would need to be involved. I'll explain how the health meter works in-game.


5. Yes.


6. If the name is directly above the health meter, then the name would be written out as "<actor>" or "<actor>'s Health" on one line. Font size should probably be small enough that it wouldn't take up too much space, but still be legible... Size 10, maybe? (Is that how that works here?)


If actor's name is to the side, then simply "<actor>:" The name size character limit is 10, so it would need to compensate for that. Either the hearts would be placed accordingly or the name gets "scrunched" like in the menus sometimes.


7. How you have the icons spaced in the example will be fine. :)


8. So the actor has 10 health, so 5 hearts are shown. They take one point of damage, so 4 1/2 hearts are shown. Like Zelda games, if you have played those. Or maybe Minecraft.


@Sixth


1. I was thinking it'd be located at the bottom of the screen, per party member. I was thinking the max HP numbers would be 10 and I'd build the enemies and weapons around that to compensate. Of course, it would have to show up in the field and battle, as well as being shown in the menu in some way next to member. (There maaaaaay be a lot of scripting involved here...)


2. At first, I was thinking the "wheel" or "pie" pattern. But that seems it'll be more difficult to implement, so just simple hearts will do.


Half hearts could be used to take up less space. For example, if the member has 10 HP, 5 hearts would be displayed.


3. Yeah, that's it. 1 half heart would equal 1 HP.


Also, perhaps the Magic meter should be a standard meter placed under the health?


And I'm currently messing with the icons, so could I select or adjust where the script pulls the icon(s) from?


Sorry to have to make you all work on this. I can do some script modifications, but nothing to this great an extent. But if we can get this working, though, I'm sure lots of developers would like to use it :D
 

Galactic_Edge

Villager
Member
Joined
Jul 16, 2013
Messages
23
Reaction score
2
First Language
English
Primarily Uses
Are you thinking the vertical would be like this? It would likely be all in one window though, not individual windows for each actor. This could also use magic icons instead of a magic bar.





And were you picturing the horizontal like this?





Anyway:


1 .There's a problem with using 5 icons and 24x24 images: not enough room. They would need to be smaller icons, or be maybe be stacked in an overlapping 3-2 vertical pattern, like an olympic symbol. Or stacked in two rows. This is only 3 players: 





2.  Health increasing items could be made to work pretty easily, but there are space issues. Additional icons would overflow their space quickly. They may need to be shrunken.


3. I'm not a big fan of adding 'health' over a health bar, since space is already fairly tight and it seems redundant. It could work, but it would cost space, or force text to be shrunken.


4. The system I'd go with for what you want would be to set enemy damage = to attack power. You could set their damage to 1, but it would still give you the flexibility to set their damage higher. This is basically identical to a Zelda hearts system. Or, the engine could just treat all attacks as 1 damage.


Also, the script would pull the icons from whatever icon indexes you give it. To use smaller icons, like a 16x16, you would have to input the height and width of the image and place it in exactly the right spot on the icon index  you want to use. (the origin, shouldnt be hard to find). As for non-battle menus, well, one thing at a time.


I don't mind helping by the way. I felt like scripting
 
Last edited by a moderator:

Power Master

Optimistic Game Designer
Veteran
Joined
Apr 18, 2015
Messages
112
Reaction score
12
First Language
English
Primarily Uses
RMMV
@Galactic_Edge


1. Okay, smaller icons then. Though the properties of the iconset may space them out unneededly, though...


I was thinking the vertical all the way; field, battles, menus, and all.


...Should we use MP icons? It could work... Blue hearts... But that may limit the players' magical ability... But I can build around that as well... *mumble mumble*


Also, three characters will be all the player will have at any given time. That clear up room a bit?


2. Maybe make it so any overlap would add a "+1, +1 1/2, +2, etc." or whatever to the count, then lower and reset once it drops to the appropriate amount. Like it places the number over-top the final heart or something.


3. Yeah, the word "Health" would be redundant since it seems obvious anyway. Maybe just the actor's name then.


4. Yeah, that's what I was going to do. Adjust the enemy attack and player weapons so they can work well with the system. You just leave that part to me. :)


I'll be sure to place them in the correct spot.
 

Galactic_Edge

Villager
Member
Joined
Jul 16, 2013
Messages
23
Reaction score
2
First Language
English
Primarily Uses
I had a chance to work on this a bit today. Here's what it looks like at the moment. Is this roughly what you were looking for?





Script is definitely NOT done. Needs more functionality, aliasing, and better positioning, but if you wanna check it out and see if there are any incompatibilities or other problems, here it is:

module Life_Counter
#The number of icons when at full health
MAX_HP_ICONS = 4;
MAX_MP_ICONS = 4

#The icon index of the file you want to display (visible when selecting icons from the iconset)
FULL_HP_ICON = 122
HALF_HP_ICON = 123
FULL_MP_ICON = 586
HALF_MP_ICON = 589

#The next 4 lines are for the dimensions of the graphic files (24x24 for standard icons).
#If you are using a size other than 24x24, the icon must be placed in exactly the top left corner of the icon index slot you want to use.
HP_ICON_HEIGHT = 24
HP_ICON_WIDTH = 24
MP_ICON_HEIGHT = 24
MP_ICON_WIDTH = 24

#Padding above icons
HP_TOP_SPACING = 2
MP_TOP_SPACING = 2

#Ignore
hp_icon_size = Life_Counter::HP_ICON_HEIGHT
mp_icon_size = Life_Counter::MP_ICON_HEIGHT
MP_Y_START = HP_TOP_SPACING + hp_icon_size + 25
TP_Y_START = MP_Y_START + MP_TOP_SPACING + mp_icon_size - 4
ICON_Y_START = TP_Y_START + 20
end

class Window_BattleStatus < Window_Selectable

def draw_actor_hp(actor, x, y, width = 124)
value_of_counter = 1.0 / Life_Counter::MAX_HP_ICONS
total_icons = (actor.hp_rate / value_of_counter).ceil.to_i
draw_half_icon = actor.hp_rate < 1.0 && actor.hp_rate % value_of_counter <= value_of_counter / 2
size = Life_Counter::HP_ICON_WIDTH

total_icons.times do |i|
if i == total_icons - 1 && draw_half_icon
draw_custom_hp(Life_Counter::HALF_HP_ICON,x + i * size + 4,y)
else
draw_custom_hp(Life_Counter::FULL_HP_ICON,x + i * size + 4,y)
end
end
end

def draw_actor_mp(actor, x, y, width = 124)
value_of_counter = 1 / Life_Counter::MAX_MP_ICONS.to_f
total_icons = (actor.mp_rate / value_of_counter).ceil.to_i
draw_half_icon = actor.mp_rate < 1.0 && actor.mp_rate % value_of_counter <= value_of_counter / 2
size = Life_Counter::HP_ICON_WIDTH

total_icons.times do |i|
if i == total_icons - 1 && draw_half_icon
draw_custom_mp(Life_Counter::HALF_MP_ICON,x + i * size + 6,y)
else
draw_custom_mp(Life_Counter::FULL_MP_ICON,x + i * size + 6,y)
end
end

total_icons.times do |i|
if i == total_icons - 1 && draw_half_icon
draw_custom_mp(Life_Counter::HALF_MP_ICON,x + i * size + 6,y)
else
draw_custom_mp(Life_Counter::FULL_MP_ICON,x + i * size + 6,y)
end
end
end

def draw_item(index)
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)
draw_actor_name(actor, index * 96 + 4, 0, 100)
draw_actor_icons(actor, index * 96 + 4, Life_Counter::ICON_Y_START, 100)
end

def draw_gauge_area(rect, actor, index)
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)
draw_actor_hp(actor, index * 96, 22, 100)
draw_actor_mp(actor, index * 96, Life_Counter::MP_Y_START, 100)
draw_actor_tp(actor, index * 96, Life_Counter::TP_Y_START, 105) if actor.absorb > 0
end

def draw_gauge_area_without_tp(rect, actor, index)
draw_actor_hp(actor, index * 96, 22, 100)
draw_actor_mp(actor, index * 96, Life_Counter::MP_Y_START, 100)
end

def draw_actor_icons(actor, x, y, width = 96)
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
return 4
end

def item_rect(index)
rect = Rect.new
rect.width = 96
rect.height = 96
rect.x = (index % col_max * (item_width + spacing)) - 10 * index
rect.y = index / col_max * item_height
rect
end

def item_rect_for_text(index)
rect = item_rect(index)
rect.x += 4
rect.width -= 8
rect
end

def draw_custom_hp(icon_index, x, y, enabled = true)
size = [Life_Counter::HP_ICON_WIDTH, Life_Counter::HP_ICON_HEIGHT]
bitmap = Cache.system("Iconset")
rect = Rect.new(icon_index % 16 * 24, icon_index / 16 * 24, size[0], size[1])
contents.blt(x, y, bitmap, rect, enabled ? 255 : translucent_alpha)
end

def draw_custom_mp(icon_index, x, y, enabled = true)
size = [Life_Counter::MP_ICON_WIDTH, Life_Counter::MP_ICON_HEIGHT]
bitmap = Cache.system("Iconset")
rect = Rect.new(icon_index % 16 * 24, icon_index / 16 * 24, size[0], size[1])
contents.blt(x, y, bitmap, rect, enabled ? 255 : translucent_alpha)
end

end



There's some directions and configurables in the comments at the top.


It uses mp icons, but I'm thinking I'll give the option to draw regular tp/mp bars instead. These are 12x12 icons, so there's a lot of vertical space. Using 24x24 icons would be too big though. That would push statuses halfway off the screen. It should be okay at around 20x20 or 18x18. Since you only have 3 party members, horizontal space will be less of an issue with bigger icons.


It could use some more visible separation between actors, but doing multiple windows may be a bit too much work (lots of places in the engine depend on the assumption that there is only one battle_status window). Idk how it looks to you, but I feel like it could use a bit more visual separation than just the cursor rectangle.


Any thoughts?


As for other menus, are you thinking you want exactly the same display in the field? Like a perfect replica with the same screen positioning? I could also use a layout for what you want the menu screen to look like. There's very little space there, so I'm thinking maybe just display life icons instead of bars and don't add anything or change positioning.
 
Last edited by a moderator:

Power Master

Optimistic Game Designer
Veteran
Joined
Apr 18, 2015
Messages
112
Reaction score
12
First Language
English
Primarily Uses
RMMV
Looks good to me :) . If you want to use a different cursor option, I'll come up with something. I'm still working on how I want the menus to look.


If you think a Magic bar would work better, then go for that instead. Honestly, it would make more sense that way.


For the field HUD... having the actors' hearts stacked on top of each other could work. If players realize their health is low, they can go to the Inn, rest up, and everything else will be fixed anyway. Though maybe a percent of Magic at the end of the Health meter? Maybe?


EDIT: Tested it out for battle and it seems to work fine. Need to resize the icons, but I'll do that.


(When I started it up, it was set to another icon in it's place, which, in my game, was a bunch of :( )
 
Last edited by a moderator:

Galactic_Edge

Villager
Member
Joined
Jul 16, 2013
Messages
23
Reaction score
2
First Language
English
Primarily Uses
Where are you thinking the field info should be displayed? I was thinking a window, maybe top left. I could possibly make it a transparent display of just icons with no window, so you can see as much of the map as possible. But a translucent window or even a regular one could be okay too.


When you said stacked on top of  each other, were you thinking something like this?





I added a gradient option to the window, since I'm not crazy about the last version. You can turn it off, change the color, and adjust its y-origin with some simple options. Still needs a bit of adjustment, especially that big space after the 4th character


 
Last edited by a moderator:

Power Master

Optimistic Game Designer
Veteran
Joined
Apr 18, 2015
Messages
112
Reaction score
12
First Language
English
Primarily Uses
RMMV
I was thinking the field HUD would be on the bottom, but maybe make it in a way that's adjustable for other developers? Though, it's a script so it's adjustable anyway :p


And, yeah, that's what I meant by stacked up. Having a transparent window (like for the dialogue) or no window at all, either one works.


For the battle menu, is it possible to center the info and have it "push" itself to the sides based on the number of players are in the team?


Like, for one member, the info would be in the center. Two, they'd be in the center and next to each other, etc. Having it centered would make that space after the fourth player not look too bad and make the presentation look a bit cleaner.
 

Galactic_Edge

Villager
Member
Joined
Jul 16, 2013
Messages
23
Reaction score
2
First Language
English
Primarily Uses
Alright, I got a chance to mostly finish this over the weekend. I wouldn't say it's 100% done, and it could use some testing. But it's usable, and you can give me some feedback if there are some changes you want to make. I'm probably releasing it to the public, so I made it very configurable.


There's three basic ways to draw hp/mp bars. You can use each style separately on hp and mp bars. With Default style you set a maximum number of icons that represent full health, and the number of icons drawn will always be proportional to that based on your health percentage. For "Zelda-style," you set a constant called "HP_PER_ICON", and then it just keeps drawing icons based on how much life you have. EX: 5 HP per icon means that with 50 health, 10 icons would be drawn.


The third option allows stacking hp icons at the end of the bar when you have bonus health (like you mentioned in one your above posts). It requires your max hp to stay the same throughout the game. The reason is that I don't have any information to know when hp is 'bonus' and when it's just part of your regular hp. If max hp suddenly increases from 100 to 120, the normal response in Default mode is just to see that you still have the same percentage of health and make no change. In zelda-style, the icons will simply be drawn regularly, because I can't know where 'regular' maximum hps end and 'bonus' hps begin.


If you DO want to have increasing maximum health in addition to items that provide bonus health and are drawn differently than regular icons, we could possibly coordinate something like that. If hp-bonus items and skills gave a state or something, I could detect the condition and treat it accordingly. Off the top of my head, I'd say an item that increases max hp directly, and also increases a dud parameter by the same amount could be used to tell me how much of their life is bonus.


Anyway, instructions in the script. It's configurable, so if something looks bad, see if there's an option to adjust it. If you want to use a smaller icon, just drop it in the right icon index on the iconset and it'll find it automatically and cut out the surrounding space. The Field map works, but you will'll have to find the MAPS_TO_DISPLAY setting and add map ids where you want it to show. There's instruction to invert the logic if you want to just add maps that don't show it. I think the field menu looks best with a transparent window, but you'll have to make one and set its name in the MAP_WINDOW_NAME setting

Code:
#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 bar support
#Double rows of health/mp
#options for 'mp' vocab and cur/max, (DRAW_HP_LABEL)


=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


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 = 6
  MAX_MP_ICONS = 6
  
  #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 or MP and STATIC_MAX_HP or MP
  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 should 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 = 4
  
  #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 displays 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 may want the world
  #map and dungeons, for example. 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 = 1; max = 1
    while i <  5
      max = text_size($game_actors[i].name).width.to_i > max ? text_size($game_actors[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_actors[index + 1]
    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")
    msgbox 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_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 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
 
Last edited by a moderator:

Power Master

Optimistic Game Designer
Veteran
Joined
Apr 18, 2015
Messages
112
Reaction score
12
First Language
English
Primarily Uses
RMMV
Daaaaaang! Well done! :)


I will go over this, testing out every option and possibility, then tell you what problems I find, if any.
 

Power Master

Optimistic Game Designer
Veteran
Joined
Apr 18, 2015
Messages
112
Reaction score
12
First Language
English
Primarily Uses
RMMV
@Galactic_Edge


Alright, these are the problems I have run into for now. Let me know if any are easily corrected or if they do need to be fixed.

- Standard Heart System errors



- Zelda Heart System errors



- Static Heart System errors


- All


* Message containing


    "Script '<name>' line 814: NoMethodError occurred.


    undefined method 'draw_gradient' for
    #<Window_MenuStatus:0x75241d8>


appears when you try to open the menu. Game crashes.
Removing the specified line fixes the problem, simply displaying a counter instead of a counter+gauge


* For the field menu, it does not specify the correct actors. For example, Actors 1, 2, 4 & 5 are in the party, but the field menu shows the info for actors 1, 2, 3, & 4.


* Setting the field menu position to nil will crash the game.


* Status ailments on the battle menu are placed too low, being cut off at the bottom, using standard 24x24. 16x16 is recommended, even without buffers, but I know others will want to use the standard icons.

I have tried modifying some of them, like the "draw_gradient" error where I simply removed the line.


I have also modified some other scripts, such as getting rid of the EXP in the menus, if those may effect this at all.


I'll continue going through the script, testing out everything. Will update.
 

Galactic_Edge

Villager
Member
Joined
Jul 16, 2013
Messages
23
Reaction score
2
First Language
English
Primarily Uses
Ok, here's a fix for the crash and the incorrect actor display. don't set FIELD_MENU_POS to anything other than the listed settings. That settings will be overridden if you set MAP_WINDOW_X and/or MAP_WINDOW_Y. You can also manually edit the values for the string settings like "BL" down in the MAP_WINDOW_COORDS section. As for status ailments, I'm still working out how to handle the space. I also have to plan for people who want tp bars. You can adjust the positions of those things, and work around it with smaller icons. But at the end of the day, there's only so much space. I may allow for customization of the overall window height/wdith to add more room.

Code:
#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
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Profile Posts

Don't forget, aspiring writers: Personality isn't what your characters do, it is WHY they do it.
Hello! I would like to know if there are any pluggings or any way to customize how battles look?
I was thinking that when you start the battle for it to appear the eyes of your characters and opponents sorta like Ace Attorney.
Sadly I don't know how that would be possible so I would be needing help! If you can help me in any way I would really apreciate it!
The biggest debate we need to complete on which is better, Waffles or Pancakes?
rux
How is it going? :D
Day 9 of giveaways! 8 prizes today :D

Forum statistics

Threads
106,048
Messages
1,018,545
Members
137,834
Latest member
EverNoir
Top