I'd do something like this:
def draw_generic_bar(x, y, current, max) bitmap = Cache.system("Bar") rect = Rect.new(0, 0, bitmap.width * current / max, bitmap.height) contents.blt(x, y, bitmap, rect) bitmap.disposeendA gradient bar requires TWO values - the current and the maximum. For an actor's hp, that calculation is done inside the hp_rate method.So you need to replicate that, by sending in the current value and the maximum value. This may require two variables, or a variable and a constant.
The only slight issue I see with this is that the variable is chosen at random and therefore the max and current value would be different every time. Reason backing this is because I was planning on doing a evented battle type game which this bar would define the enemy's health and the random number would depend on difficulty. I can do it easily with the numbers but was hoping to draw it via a graphic or a regular gradient.
If you can figure out the numbers, you know what to send in to the method.
How are you choosing "the variable" at random, and why?
These Variables are for the A.I actor
All stats are designed by variables
1 Variable is the health
When starting a new game it can range depending on difficulty
when easy
100...250
when normal
250...400
when hard
400...1000
This was all set up with a event which works really good. If you were to write this out in a message window it would work out correctly, You can even script the variable on screen if you wanted to without any problems. Doing a graphic bar is more of a eye candy to the user and it would look nicer then 4 sets of numbers.
(However on a small note I might be able to get away with setting up all the actors in the database but this method allows me to randomize it more.)
Well, you still know, at the time you're battling a monster, what the HP and MAXHP are going to be, aren't you? Otherwise what use is the bar if you don't know what the maximum is, or what % they have remaining?
Idk if you were wondering about scene switching. It happens all on the map in case you were wondering.
As soon as I call the random number that's when I will have the value for the max life.
That's exactly where I stopped scripting it because there's is no way to determine the bar really, as where actor.hp_rate is hard coded in more.
Hence why I had to bring up this question.
If you call a random number to get the value for max life, save that into one variable. Use another variable to keep track of current life (HP).
There are the two values you pass into the method. I assume you determine the max life before you make the bar appear.
Ah that's something to look into however how am I gonna tell var 2 to check var 1.
Var 1 is the life itself. Well now Max what am I using for var 2? Like the operation of that.
I know it has to operand var 1
The operation is =.
If you have your random number in var1 (current life), set var2 to be equal to var1 at the start. Then as the battle goes on, var1 will decrease, but var2 will stay the same.
And then put the var id's in the current/max slots. Thanks Shaz I'll try it out. Seems like that method will work so you can lock this thread. 🙂
You would just do
draw_generic_bar(x, y, $game_variables[1], $game_variables[2])
However, I'm not sure where you want to PUT that script. The original one is in Window_Base. But if your battles are on the map, there IS no reference there to Window_Base. And I don't think Game_Map or Scene_Map have a "contents" to blt to. So there's still a bit of playing around for you to figure out where that script should go, and how to modify it, if necessary, based on where it is.
I could build a child class from window_base
and
alias scene_base's start and update and create the window if the scene is on the map
that's how I design all my huds unless that's not a appropriate way?
It would be Scene_Map's, not Scene_Base's, because you only want these showing on the map, don't you? No need to have them defined in any other scene, then.
Your right but I use scene base for quick access to other scenes just in case
I don't think either method hurts really being they are both aliased.