All I want is a script call that checks if any actors in the party have less than 40% health. If they don't nothing happens but if they do HP is restored until they are back to 40% of max HP. I plan on putting this at the end of every battle but I may tweak the number. I would do it myself but I don't know how to code.
Healing by percentage in common events (MV)
JS Plugin Requests$gameParty.members().forEach(member => { if(member.hpRate() < 0.4) { member.setHp(Math.floor(member.mhp * 0.4)); }});It's worth noting that you don't need to use code for this.
What AphoticAmaranth gave you is certainly more efficient, but you could've done this with event commands without having to wait for someone else 😉
And then you copy and paste it for each actor.
What AphoticAmaranth gave you is certainly more efficient, but you could've done this with event commands without having to wait for someone else 😉
And then you copy and paste it for each actor.
Thanks so much to both of you. I tested it your solution and it works great. I thought the problem was solved but then I realized that I had no clue how to make it work for random battle encounters. Is there a way to make it work with random encounters too? You know the kind you make with a region ID.
For that, I'd recommend using a plugin to run a common event with the HP recovery at the end of every battle, such as SumRndmDde's Battle End Events or Yanfly's Utility Common Events.
sumrndm.site
www.yanfly.moe
Battle End Events – MV Plugin – RPG Maker MZ Plugins
Utility Common Events (YEP) - Yanfly.moe Wiki
This looks like just the thing I'm looking for thanks again.
Just to note, you don't need a region ID for random encounters. That's just a way to control where on the map specific troops can be encountered.
You can do what @AphoticAmaranth suggested.
You could also do it without plugins by putting an event on the map set to parallel. Do the checks and the healing, then Erase Event at the bottom.
That means the event will only run once each time the map is loaded (e.g. after battles).
I didn't know erased events return after battles?! Good to know! Thanks @ATT_Turan
Yeah - for a battle you literally leave the map and go to Scene_Battle. So afterward you return to Scene_Map and reload it.
I have lots of convoluted ways I do post battle checks and resets. This might make em a bit smoother.
Thx again
Thx again
Original thread: https://forums.rpgmakerweb.com/threads/healing-by-percentage-in-common-events-mv.168665/