So I have a script that changes MHP and HP based on a variable. I finally got it to where if the variable goes up or down the HP and MHP will both respond however the HP bar in the menu doesn't seem to update.
If the stats are raised ( 707/707 HP )
the bar shows partially empty
If the stats are lowered ( 408/408 HP )
the bar appears longer than usual
how do I set up a method to update these to the proper "full" setting under the above situations?
I'm working in Game_Actor by the way.
Help Updating Health Bar
● ARCHIVED · READ-ONLY
-
-
I've moved this thread to RGSSx Script Support. Please be sure to post your threads in the correct forum next time. Thank you.
er ... showing us the script might be helpful. Wrap it in code tags, and if it's a big script (more than a page long) put the whole thing into spoiler tags.
I don't think Game_Actor is the place to put it either. -
I'm not sure where to put the update, but all the rest of my script is under Game_Actor.
Sorry for the wrong section by the way. Wasn't quite sure where to put this.
Here's my script:
class Game_Actor < Game_Battler attr_reader :mood alias euphoria_moodeffects_gameactor_initialize_5 initialize def initialize(actor_id) @mood = 50 euphoria_moodeffects_gameactor_initialize_5(actor_id) end alias euphoria_moodeffects_gameactor_mhp_5 mhp def mhp euphoria_moodeffects_gameactor_mhp_5 if @mood == 100 (euphoria_moodeffects_gameactor_mhp_5 * 1.25).to_i elsif @mood >= 75 (euphoria_moodeffects_gameactor_mhp_5 * 1.10).to_i elsif @mood >= 55 (euphoria_moodeffects_gameactor_mhp_5 * 1.05).to_i elsif @mood == 50 (euphoria_moodeffects_gameactor_mhp_5 * 1.00).to_i elsif @mood == 0 (euphoria_moodeffects_gameactor_mhp_5 * 0.75).to_i elsif @mood <= 25 (euphoria_moodeffects_gameactor_mhp_5 * 0.90).to_i elsif @mood <= 45 (euphoria_moodeffects_gameactor_mhp_5 * 0.95).to_i else (euphoria_moodeffects_gameactor_mhp_5 * 1.00).to_i end end alias euphoria_moodeffects_gameactor_hp_5 hp def hp euphoria_moodeffects_gameactor_hp_5 if @mood == 100 (euphoria_moodeffects_gameactor_hp_5 * 1.25).to_i elsif @mood >= 75 (euphoria_moodeffects_gameactor_hp_5 * 1.10).to_i elsif @mood >= 55 (euphoria_moodeffects_gameactor_hp_5 * 1.05).to_i elsif @mood == 50 (euphoria_moodeffects_gameactor_hp_5 * 1.00).to_i elsif @mood == 0 (euphoria_moodeffects_gameactor_hp_5 * 0.75).to_i elsif @mood <= 25 (euphoria_moodeffects_gameactor_hp_5 * 0.90).to_i elsif @mood <= 45 (euphoria_moodeffects_gameactor_hp_5 * 0.95).to_i else (euphoria_moodeffects_gameactor_hp_5 * 1.00).to_i end end end
There's an example, how do I update the health bar to show it's full in this case, or in the case that mhp and hp decrease make the bar normal sized. -
Bump.
-
Euphoria, please do not bump your topic unless it has been 72 hours later since your last post. You can review our forum rules here. Thank you.
The first command of each of your methods is to call (and I suspect return) the aliased method. There's no need to do that - just put the aliased method where you need to use it (ie - get rid of the first line after the def statements). -
I'll try that, sorry I thought it was 48 hours for some reason...
-
You have made the attr_reader method for hp(there is no need to alias it), but the hp rate is calculated with this method:
def hp_rate @hp.to_f / mhpendYou will need to change the @hp to take the value from the reader method:
def hp_rate hp.to_f / mhp endI just would think of maybe solving this with an alternative way.
And one tip, if you use so many elseif statements it would be better to switch to case. -
Haha I was originally going to use case but was advised to use elsif's I'm new to scripting so i don't know what to do with some things, thanks for your reply. I'll check it out.
Edit: Worked perfectly thanks! This can be closed. Who thought a simple "@" would make all the difference...