RMRK is retiring.
Server is paid up for the rest of 2026, but the forum may go after that. See here for more information. Please archive or save anything you would like to keep before 2027.
Main Menu
  • Welcome to The RPG Maker Resource Kit.

[XP] character hp percentages

Started by czernobog, November 25, 2010, 06:22:20 AM

0 Members and 1 Guest are viewing this topic.

czernobog

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?

Shinami

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.

czernobog

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.

Shinami

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.

czernobog

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.