MZ Help with a damage (healing) formula

Hello people who live in my computer!

I need some help with a damage formula for a healing skill. I want to create a heal like the old Final Fantasy staple 'White Wind' and my forum searching abilities appear to be lacking. For those not in the know, it's a simple skill that heals the entire party for an amount equal to the current HP of the user.

One solution I found was to just run a common event with two lines; one to Control Variable : 1 = HP of (Character) and then the second to Change HP : Entire Party, + Variable, but it seems like I could be doing it more simply through the damage formula.

So I tried this:

v[1] = (v[1]||a.hp); v[1]

...and it just kinda spit a random number at me. What's the right way to do this? Thanks in advance!
the simplest way to do this is to use the formula

a.hp

in a skill targeting all allies - no common event, no variable, nothing else is needed.
I tried that first, set the variance to 0% and it always healed way more than the users current HP. I thought maybe it was adding to the users HP first, and then using that number for the rest of the group or something.

edit: Just tested it and it looks like that works for the first person healed, then it it takes the total of their HP and uses that for the rest of the group.
right, but only if the first person healed is the skill user.
and unfortunately the same would happen even if you store the value into a variable, because that variable would be overwritten with every actor the damage formula is executed on.

that only didn't happen with the common event because the common event is used outside the skill.

Sorry, the only way around that are javascript action sequences, with the current HP being stored in a variable before skill execution happens and before the damage formula is processed at all.
And I don't know MZ enough to tell you which plugin to use for those action sequences.
Ah, gotcha gotcha. Thanks for taking a look, I appreciate it!

I'll keep looking into other possibilities.

edit from several hours later:

Ok! I got a really clunky fix working. It ain't much, but it's honest work.

First Skill:
White Wind. Targets the user, only available on the battle screen. All it does is have a simple animation and calls a common event, seen below.

Common Event: White Wind
Control Variables : 0001 White Wind = HP of Bob
Force Action: Bob, White Wind 2, Last Target

Second Skill: White Wind 2
No cost, targets all allies, HP Recover formula is simply v[1] with no variance.

Does it look good? Eh... It's not the worst. But it works as advertised!
You could try the following as your damage formula (which has been working for me!):


this._healAmount ??= a.hp; this._healAmount
this._healAmount ??= a.hp; this._healAmount
Theres an issue with that by itself. youll need to clear that value at some point.
Itll work the first time you use the skill cause the property is set to the user's current hp and wont be changed by later hits, but the value will also persist and will be used on later uses of the skill.

Ok! I got a really clunky fix working. It ain't much, but it's honest work.
You could make it cleaner with notetags from a plugin like Turan's Eval tags and remove the need for the common event and the forced action, but if youre happy with it as it is theres no need to change it.
Theres an issue with that by itself. youll need to clear that value at some point.
Itll work the first time you use the skill cause the property is set to the user's current hp and wont be changed by later hits, but the value will also persist and will be used on later uses of the skill.

I just jumped into my game to check this - it seems to work as excpected on subsequent uses of the skill in the same battle, and also again in the next battle...
I just jumped into my game to check this
oh, my bad. i glanced and thought it was a._healAmount instead of on the action itself. youre right, that should do just fine then
You could try the following as your damage formula (which has been working for me!):


this._healAmount ??= a.hp; this._healAmount

Oh dang, thank you so much! I'll try this later today.

Original thread: https://forums.rpgmakerweb.com/threads/help-with-a-damage-healing-formula.178790/