New account registration is temporarily disabled.

(RMXP) DISPLAY CURRENT / MAX VALUES FOR HP/SP ON THE COMBAT SCREEN?

Posts

Pages: 1
I suck at scripting. I've never really worked with a class-based language before, so I really don't know what I'm doing. There's one tiny little modification I'd like to put into my game though, and it seems like it should be a fairly straight-foreward copy+paste sorta deal. As far as I can tell though, it's probably a little more complicated than it seems (big suprise there!).

So basically, what I want is to display both the current and max values for my actors' HP and SP during battle, rather than just current values. The same way it's displayed in the menu.

What I tried doing first was copying the following lines of code from Window_Base:
self.contents.draw_text(hp_x + 48, y, 12, 32, "/", 1)
self.contents.draw_text(hp_x + 60, y, 48, 32, actor.maxhp.to_s)

..and pasting it into Window_BattleStatus like so:
actor = $game_party.actors
actor_x = i * 160 + 4
draw_actor_name(actor, actor_x, 0)
draw_actor_hp(actor, actor_x, 32, 120)
--> self.contents.draw_text(hp_x + 48, y, 12, 32, "/", 1)
--> self.contents.draw_text(hp_x + 60, y, 48, 32, actor.maxhp.to_s)
draw_actor_sp(actor, actor_x, 64, 120)
--> self.contents.draw_text(sp_x + 48, y, 12, 32, "/", 1)
--> self.contents.draw_text(sp_x + 60, y, 48, 32, actor.maxsp.to_s)

When I enter a battle, I get an error saying "Undefined local variable: hp_x".
So I need to define hp_x (and sp_x too I'm assuming) as...something? That's where I'm stumped. I dunno, I'm probably going about this entirely the wrong way. Suggestions, anybody?
RESOLVED!
So the fix is totally simple. Thanks to GreatRedSpirit for showing me the way. The chunk of script in Window_BattleStatus should look like this:

draw_actor_hp(actor, actor_x, 32, 140)
self.contents.draw_text(actor_x + 48, y, 12, 32, "/", 1)
self.contents.draw_text(actor_x + 60, y, 48, 32, actor.maxhp.to_s)
draw_actor_sp(actor, actor_x, 64, 140)
self.contents.draw_text(actor_x + 48, y, 12, 32, "/", 1)
self.contents.draw_text(actor_x + 60, y, 48, 32, actor.maxsp.to_s)

You change "hp_x" and "sp_x" both to "actor_x", and increase the width of the drawing area arguements for draw_actor_hp and draw_actor_sp from 120 to 140. BAM! Max HP and SP in battle!
Pages: 1