Face changing CE interfering with other events

I'm making a game in which player's HP level is illustrated with corresponding face picture in the ESC menu. For example, if player's HP is 70/100 there will be a normal protagonist's face in the menu but when HP falls below 30/100 the picture changes and now shows injured protagonist. This was easy to achieve with common event that constantly checks if the player's HP is lower than 30. The "else" branch changes the face back to normal (or, should I say, keeps changing it to normal). So far everything works. The problems starts when during the game I have to change character's menu face (or sprite) independently of that common event because it keeps setting the face back to "normal". What should I do to keep the functionality of the described CE while still being able to change character's menu face or sprite due to other events? Your help would be much appreciated.
When using YEP Message Core, there's a option inside to use the actor's face: \af[x]
Eurritimia, but that's not what I was asking about.
Can you show us Pictures of your involved Eventpages?
Thatway we can see what your approach of creating is and how it relates to the thing you need. And we can maybe provide additional optimization.
If your common event is set up as a parallel process, then yes, it's going to keep changing the face based on the conditions you've set. A parallel process for something like that isn't a good design.

Why do you have to change the face independent of that common event?

Clearly, you've got multiple conditions that give more options for the face than what the common event can handle. So you've either got to incorporate the additional conditions into the common event, or make it stop running when you want to override it for whatever reason. Simply turning off the switch when you want manual control over the face, and turning the switch back on when you want to resume, will take care of that.

But I'd look for a different option that doesn't require a parallel process common event that's always running, for something that might change every now and then. If the face only changes in the menu, then a small plugin that makes the menu show the correct face will remove the need for the CE completely.
Here's how the Common Event looks like in editor:

ztiCmNC.png


Shaz said:
Why do you have to change the face independent of that common event?
Because I wanted to make other events in this game which will allow the character to change the hairstyle (for example) which also results in menu avatar change.

How should I design this to make it better?

Shaz said:
If the face only changes in the menu, then a small plugin that makes the menu show the correct face will remove the need for the CE completely
Could you tell me which one?
I could help make that the command is executed only once when HP changes.

Set Health Var6 = HP of Mako
- If Var6 not equal Var100 (Var100 keeps track of previous/prior HP)
- Set Var100 = Var6
- All following code of your Picture comes in here, thatway the face changes only when the amount of HP changes.

But with your second problem there is the Scripting Way or the Evented Way, if you got many Faces and many chars which use this, the workload increases much when you event it.

if Health <= 30
if Variable101 = 0 - Change Actor Image to Set1 Low Health
if Variable101 = 1 - Change Actor Image to Set2 Low Health
if Variable101 = 2 - Change Actor Image to Set3 Low Health
else
if Variable101 = 0 - Change Actor Image to Set1 Normal Health
if Variable101 = 1 - Change Actor Image to Set2 Normal Health
if Variable101 = 2 - Change Actor Image to Set3 Normal Health
end

Everytime you change your Actors appearance you need to adjust Variable101 accordingly.
This would be one possible solution. I hope this helps you fix your problem.

Extra Info:
The Eventcommand Change Actor Image is one of the few commands which suck the most performance.
A parallel event repeats up to 60 times per second.
Its no problem to set hundrets of variables and have hundrets of conditional branches in a paralell event, but your
code above is a performance overkill.
Bex, thanks so much for your help! You've shed some light on things I have not taken into account before.

Now I'm going back to editor to experiment! 🙂
Depending on your game design, you could avoid the whole parallel process thing.
If the player's HP only changes in battles and defined events (like staying at the inn), you could call your CE only in battles and those events without making it parallel.
If you use some stuff like persistant poison states or map damages, then it won't work but I'd advise to add at least a wait 60 in your event (that way it only runs once every second).
As long as you're using that common event, it's going to override whatever the player wants to use. Anything that changes the face has to take into account ALL the possible images that could be used - not just based on HP, but based on hairstyle or colour or whatever other choices you're giving the player.
TWings said:
If the player's HP only changes in battles and defined events (like staying at the inn), you could call your CE only in battles and those events without making it parallel.
If you use some stuff like persistant poison states or map damages, then it won't work but I'd advise to add at least a wait 60 in your event (that way it only runs once every second).
There are no battles in this game. The only way a character can get HP reduced is when he steps on the damage floor or is poisoned. So I guess I have to stick with parallel event?

Shaz said:
Anything that changes the face has to take into account ALL the possible images that could be used - not just based on HP, but based on hairstyle or colour or whatever other choices you're giving the player.
But how to design this? Tips would be much appreciated.
There are no battles in this game. The only way a character can get HP reduced is when he steps on the damage floor or is poisoned. So I guess I have to stick with parallel event?
In that case, yes. Either keep it parallel or use a plugin (but I don't know of such a plugin). You can still avoid it beeing call too much by adding a wait at the end of the CE. As I was suggesting even a wait 60 would still run it every second, but 60 times less often.


But how to design this? Tips would be much appreciated.
As @Bex was saying use a variable and assign a number for every different "style" (in the event(s) where you change the player look) and put as mani IF statements as you need in your CE to cover every case.

Original thread: https://forums.rpgmakerweb.com/threads/face-changing-ce-interfering-with-other-events.105836/