The RPG Maker Resource Kit

RMRK RPG Maker Creation => RPG Maker General => General Scripting => Topic started by: czernobog on November 25, 2010, 06:22:20 AM

Title: [XP] character hp percentages
Post by: czernobog on November 25, 2010, 06:22:20 AM
I am new to ruby, but I am working on a cbs. I have read through tutorials and posts and maybe I've missed something obvious, but I can't seem to find my answer.

I want to display percentage bars for the characters' hp, mp, and ammo stats. Ammo will be my own thing, but i figure hp and mp should already be in the default system. I have replaced the default battle system script with my own, but otherwise I haven't changed anything. Is there a simple way that is already in the scripts to figure a characters hp percentage? How can I access the current and max hp of a character?
Title: Re: [XP] character hp percentages
Post by: Shinami on November 25, 2010, 11:50:53 PM
try something like $game_actors. That's the global variable that contains all of the actor stats. =) As for percentages...I never was any good at remembering how to do them but I believe it's something like Integer(current hp / max hp") to avoid getting a floating(decimal) number.
Title: Re: [XP] character hp percentages
Post by: czernobog on November 26, 2010, 12:18:27 AM
I will look into $game_actors, thank you.
I understand the math of the percentages. I was just hoping the hp and mp values were already in a variable from the default scripts. If they are in $game_actors I will try to find them, but I don't know all the tricks with ruby.
Title: Re: [XP] character hp percentages
Post by: Shinami on November 26, 2010, 12:36:14 AM
In $game_actors, you'll find the hp/sp variables. It's up to you to make the percentage formula using the functions from the $game_actors variables.
Title: Re: [XP] character hp percentages
Post by: czernobog on November 26, 2010, 07:16:23 AM
Awesome! Thanks for the hint. I am making progress, but I am still figuring out how to access all the information I need from the different variables and such.
I can now calculate the hp percentage for each character in my party and I will be able to put that info into graphics form.