Help with a battle event

Hi guys! Hope you can help me!
Bascially, i want the the hero image to show pain every time he receive damage.
I already have the portraits and was able to make a little step ahead with the script "$gameParty.leader().hp". Now, it kinda works as intended, but when the enemy miss a hit, the game will repeat the event based on how much HP i've.

For example, the hero starts with 10 Hp.

The enemy hit me and i reach 9 Hp. All good! The event where the hero shows pain, works!

Now, if the enemy miss and i'm still at 9 Hp... the hero shows pain again! XD

If we could solve this, it would be great!
Thank you (and sorry for my english!)
Welcome!

(and sorry for my english!)
Just to mention it, you've set your profile up to claim English is your native language:
1718826534068.png

If you edit that (even to leave it blank), you won't have to apologize and people will try to work with understanding you.

I already have the portraits and was able to make a little step ahead...
Now, if the enemy miss and i'm still at 9 Hp... the hero shows pain again! XD
It's hard to give you an answer because you didn't actually show us how the event is set up. Please post a screenshot of the troop event.

It would be helpful if you change your MZ language to English first - in Steam, you can right-click MZ, go to Properties, and there's a language drop-down.

It sounds like you're not comparing the actor's HP to what it was before the enemy attacks.
You're right, sorry! Here a sample of the event and thank you for your time!
Page 3, 4, 5 and so on only change the "$gameParty.leader().hp == x" (Hero only got 10 HP)

PS. I can't find the language preference tab... XD
Cattura.JPG


EDIT: I was able to change my language on the phone, but not on PC... strange!
PS. I can't find the language preference tab... XD
1718899489057.png

index.php


But anyway, as for the event:
1 - There's no real reason for you to be using a script call there. You can use the regular event commands to put the actor's HP in a variable then check that. But if you want to skip using the variable and check it directly, that doesn't hurt anything.

2 - Look at the logic of the event. You're asking "if the leader has 9 HP." You're not doing anything to ask "did the leader get hit this turn?" "Did the leader's HP change?"

What you want to do is, starting at turn 0, set a variable to the actor's HP. Then, at the end of every other round, you look at the actor's HP and if it's less than that saved variable, show your pain face.

Then set the variable to the HP again.
But anyway, as for the event:
1 - There's no real reason for you to be using a script call there. You can use the regular event commands to put the actor's HP in a variable then check that. But if you want to skip using the variable and check it directly, that doesn't hurt anything.

2 - Look at the logic of the event. You're asking "if the leader has 9 HP." You're not doing anything to ask "did the leader get hit this turn?" "Did the leader's HP change?"

What you want to do is, starting at turn 0, set a variable to the actor's HP. Then, at the end of every other round, you look at the actor's HP and if it's less than that saved variable, show your pain face.

Then set the variable to the HP again.

I think i understand what you would like to suggest.
Problem is, at certain percentage of HP, the hero "pain" image will differ (wounds, broken armor, etc.), that's why i need different tabs for different images.

Is it still possible to insert that damage variable you mentioned like this?


PS. Regarding the language, i meant the one in the forum not in Steam. For some reason, i was not able to change it on PC. Well, that's solved now!
Is it still possible to insert that damage variable you mentioned like this?
Have you tried? We're talking about Control Variables and Conditional Branch, two of the most basic event commands.

1718912905294.png


Problem is, at certain percentage of HP, the hero "pain" image will differ (wounds, broken armor, etc.), that's why i need different tabs for different images.
You don't need them, you just have a conditional for each value with the appropriate images and such inside.

You can split them out into different event pages if you really want to, but then you have to be really careful with your logic to make sure you don't get two of them triggering at the same time.
Aaaaaand you're the man!
It works now!

Damn, still have a long way learning, but thanks a lot!
And i don't know why, but now it doesn't work anymore!
immagine_2024-06-22_212735344.png

It was working like a charm.
Now, when the hero evades an attack, it still shows the "pain" image.

Touched nothing and everything was ok, there was no problem before...
Ok, i really need a little hand here, because i don't know how to solve this:
Cattura.JPG

Every page is tied to the hero Hp (From 9 to 1).
For every HP lost, there's a different sound effects\images used. (SE not in the screenshot, but it's just before "Shake Screen").

Like this, it works no problem.
The Hero receives damage, she grunts and shows the "pain" image. Ok, all good.

But not when she evades the attack. It's still showing the damage image.
Tried removing the "Current HP = X", but no luck.
Tried switching Old for New, adding other variables, testing this and that... nothing!
Help...
Are you updating that old HP variable at the end of every turn? I cant see the entire event page and you havent shown page 10. If you arent, then it would make sense that the pain image would show on every turn after damage is taken.
If you use a show text event to show you that variable's value, is it different from what you think it should be?
Are you updating that old HP variable at the end of every turn? I cant see the entire event. If you arent, then it would make sense that the pain image would show on every turn after damage is taken.
If you use a show text event to show you that variable's value, is it different from what you think it should be?
This is the first page if it can help.
immagine_2024-06-25_220622128.png

How should i update the "Old HP"?
Forgive me the question, but even if i've used RPG Maker in the past, there're still tons of things i don't know how to use...
How should i update the "Old HP"?
The same way you did in the second line of that event page

If you start the fight at 10 hp, old hp starts at 10. But if you never update the old HP to the actor's current HP every turn, any turn that ends with your HP less than 10 will show an image. At some point in each turn you need to change the value of old hp
What you want to do is, starting at turn 0, set a variable to the actor's HP. Then, at the end of every other round, you look at the actor's HP and if it's less than that saved variable, show your pain face.

Then set the variable to the HP again.
Logically, if you don't set "Old HP" to the actor's HP at the end of the process, you'll always be comparing to whatever it was at the beginning of the fight, rather than at the end of the previous round.

Right?
You guys know how to make me feel stupid, because now it works...

I will spent ten minutes of shame in a corner!
Ok!
Thanks to your preciuos help, i was able to fix the issue and "clean" the code a bit, because
Regrouped everything in one page instead of nine, everything works fine.

I've only a small issue, let me explain it:

The Heroine is at 3 HP of 10, and her appearance is wounded and tired.
Now, if i fully recover my health with a potion, it still shows the wounded image until she receives damage.

It's like this -> 3 HP (Wounded) -> Recovers everything (HP to 10 but still wounded) -> Receives damage (loads the "pain" image of 9\8 HP of 10, so she returns to a "normal" state).

I'm ready to spend another ten minutes of shame, because i can't find a logical solution to match with previous code...
Just attach a common event to the potion that changes the image to whatever it should be and sets the Old HP variable.
I knew it was an easy one!
Thank you guys! Without your help, i would be lost!

Original thread: https://forums.rpgmakerweb.com/threads/help-with-a-battle-event.169632/