How can I make a skill that displays a target's remaining HP?

I want a party member to have a skill that just informs the user how much HP an enemy has left.

I want to have a character have a skill (lets call it 'Health Check' for now until I come up with a better name) that the user targets an enemy and it will tell the user how much HP the enemy has remaining. This would be helpful for long boss fights (like the ones that are crucial to the story, not just weaker area bosses).

I do not need it to do damage or anything, just display how much HP the boss has remaining.


Is there a way to do this?

A lot of console RPGs have something like this.
enemy hp scripts exists and can show the hp all the time or when you hit the enemy.
So my first question is do you want this to show and stay on the screen or only show for a second or two? Second will it display on the battler or in the battle log? Is it just the numbers or a health bar?
I just need it to display when the user has the character select the move, target the enemy, and then just use a "display message" command to say something like "Bridge Dragon's remaining HP is x" X being the remaining HP.

Basically it will display until the user hits a button to clear it like normal dialogue.
So then it uses a turn for the actor? not display the hp when selecting the skill and you can back out to select another skill.
1683295851720.png

1683295870975.png
Can you put those script calls so I can copy and paste them? Please and thanks
Can you put those script calls so I can copy and paste them? Please and thanks
I pondered over this for a while.
My first impression "Seriously, you can't read and/or type?"
My current thought, "I guess so, you did say please."

$game_variables[1] = b.index; 0

$game_variables[2] = $game_troop.members[$game_variables[1]].name
$game_variables[3] = $game_troop.members[$game_variables[1]].hp
Just copy and paste this scriptlet in a new section and follow the embedded instructions.

EDIT: Go to my next post to grab the updated scriptlet.
Embedded instructions? I do not copy.

I do not see any instructions in the comments of the code. Either that or I do not understand the instructions
UPDATED SCRIPT & Instructions

EDIT: I had to correct the example I had provided you in the comments.

Ruby:
# * Instructions * #
# First type this line of code in the Skill's Damage Formula Box as Ron had suggested:
# Let us say that it will be Game Variable #1...
# $game_variables[1] = b.index; 0

# * Script Call * #
# store_enemy_name_hp(EnemyVarID, NameVarID, HPVarID)
# Example: store_enemy_name_hp(1, 2, 3)

class Game_Interpreter
  def store_enemy_name_hp(enemy_var, name_var, hp_var)
    return if enemy_var == 0
    index = $game_variables[enemy_var]
    enemy = $game_troop.members[index]
    return unless enemy
    $game_variables[name_var] = enemy.name
    $game_variables[hp_var] = enemy.hp
  end
end

You know what a script call is, you open the call script event command window and type something like this:

Ruby:
store_enemy_name_hp(1, 2, 3)

I had to change the code because there was something missing. 😛
follow the embedded instructions.
I actually don't follow this.
Is the script call to be in a Common Event command from the skill?
Actor varid -> the variable you want to use for saving the actor data? But I assume you mean the enemy data. But you use $game_variables to get the value for the enemy?

Is this intended to work with the solution I provided?

As it stands it looks like you would do that command and you would get an error.
"undefined method name for 0"
Since variable 1 would have a value of 0 and then your trying to get the name of 0.

Can you elaborate?
OK, I fixed that by making a clear statement of what's needed for it to work as intended, avoiding the (Enemy's Variable ID) Index 0 error message.

Final Edited Version
Yes it makes sense now. Your second edit made sense except where to put it, now it all looks good, except I think index 0 is still a valid index for the enemy troop.
Yes it makes sense now. Your second edit made sense except where to put it, now it all looks good, except I think index 0 is still a valid index for the enemy troop.

Nah, what I meant was that there can't be a Game Variable #0 at all, but I fixed that as well.
UPDATED SCRIPT & Instructions

EDIT: I had to correct the example I had provided you in the comments.

Ruby:
# * Instructions * #
# First type this line of code in the Skill's Damage Formula Box as Ron had suggested:
# $game_variables[1] = b.index; 0

# * Script Call * #
# store_enemy_name_hp(EnemyVarID, NameVarID, HPVarID)
# Example: store_enemy_name_hp(1, 2, 3)

class Game_Interpreter
  def store_enemy_name_hp(enemy_var, name_var, hp_var)
    return if enemy_var == 0
    index = $game_variables[enemy_var]
    enemy = $game_troop.members[index]
    $game_variables[name_var] = enemy.name
    $game_variables[hp_var] = enemy.hp
  end
end

You know what a script call is, you open the call script event command window and type something like this:

Ruby:
store_enemy_name_hp(1, 2, 3)

I had to change the code because there was something missing. 😛
Do I replace $game_variables[1] = b.index; 0
with another variable like $game_variables[22] = b.index; 0

If variable #1 is already keeping track of something important?

Is that the same for @Roninator2 's method?
Like:
$game_variables[23] = $game_troop.members[$game_variables[1]].name
$game_variables[24] = $game_troop.members[$game_variables[1]].hp

?
Yes the variable in the skill can be whatever you want.
Just remember that you need to update the variables[1] as well in the code line.

Using kyonides script will give you the same effect and from what I can tell you will still use the text message box I showed.
Do I replace $game_variables[1] = b.index; 0
with another variable like $game_variables[22] = b.index; 0

If variable #1 is already keeping track of something important?

Is that the same for @Roninator2 's method?
Like:
$game_variables[23] = $game_troop.members[$game_variables[1]].name
$game_variables[24] = $game_troop.members[$game_variables[1]].hp

?

It can be any given Game Variable ID.

The reason why I provided everyone with a script is to allow people to get 2 checks that might prevent the call from causing a game crash. (I just added the 2nd check. 😛 )
Neither @kyonides nor @Roninator2 method works! 🙁

Both crash with this error message:

Capture.JPG

The error message is the same with either method.
First of all, it's totally unclear why it points to line 1409 of Game_Interpreter script when any of our options are extremely short. My option includes 2 checks to prevent such things from ever happening. We need more screenshots here to see what you actually did to be able to solve that problem you're currently having.
For @Roninator2 's methodI have this setup
Capture.JPG

Capture 2.JPG

For @kyonides method, I have this
Capture 3.JPG


Edit: At least for, @Roninator2 's method, the problem could extend from the fact that RPG Maker automatically line breaks the code when I enter it into a script command even though they are just two one-lined script calls. RPG Maker is automatically diving them into four lines. But I am not sure if the error is from that.
At least for, @Roninator2 's method, the problem could extend from the fact that RPG Maker automatically line breaks the code when I enter it into a script command even though they are just two one-lined script calls. RPG Maker is automatically diving them into four lines. But I am not sure if the error is from that.
Yes. I don't know why you're getting line breaks.
But if it doesn't fit on one line then press enter after the equals sign and hopefully there is enough room, but still, why is your rpgmaker vx ace not doing a full script command?
1683334324409.png

I can add on 20 more characters on the first line before it drops down
but try breaking after the equal sign.

*edit. I think I see the problem. You're using a japanese version, so you're either using a pirated copy of rpg maker or your using a japanese project to build your game.

Original thread: https://forums.rpgmakerweb.com/threads/how-can-i-make-a-skill-that-displays-a-targets-remaining-hp.157248/