Need assistance making a "limited" res spell

I want a spell that raises an ally but reduces the caster to 1 hp, how would I go about making that happen? Any advice would be greatly appreciated, thanks!
damage formula coding, there are a few topics about it here on the forum.
It would be something like

a.hp=1; [place regular healing formula here]
That doesn't seem to work, it just damages the dead characters. =P

This is the formula I am using, it's the res from the Octopack Battler sample project.


Math.max(1, b.mhp / 2 * (a.bp + 1))

I will look around in the forums and see what material I can find to read.

Edit: I am asking in the damage forum thread, thanks for pointing me in the right direction.
t just damages the dead characters.
then you messed up either the difference between a and b or the targeting of the skill.

the target of the skill has to be the dead actor, and then you have to damage the skill user (a) in the damage formula.
But I think I remember one difference between Ace and MV - the direct assignment doesn't work in javascript, so you have to use the correct function.

a.gainHP(1-a.hp); regular formula or 0


If that doesn't work, please post a screenshot of the skill you have
Hmm, here is the spell, not sure where exactly to place " a.hp=1;" in the formula. I am relatively new to the damage formula scene... new as in, completely clueless, heh.

Are there any tutorials anywhere on where to get started on making damage formula's? The issue I may be having is that I am using the Octopack Battler setup and the revive looks different form the one that comes in the default MV package. 😳

1.png
Math.max(1, b.mhp / 2 * (a.bp + 1))
what is bp? that is not a default value, it has to have been defined by a script or plugin.
And the problem with that is that if that definition does not work in the damage formula, the entire line will default to undefined.

The damage formula is basically a javascript eval expected to return a number to be used as the damage or healing amount.
Because it is an eval, you can have any javascript code working inside, with the ; separating different commands in the line - that even includes loops or if commands if you know how to do them in a single command line.
However the last number processed will be used as the damage - which means that anything having other effects need to come first.

Code:
a.gainHP(1-a.hp);math.max(1, b.mhp / 2 * (a.bp + 1))
Unfortunately I don't know if the syntax gainHP is correct, you should look up the topics about damage formula for MV to check if that syntax is correct.
BP is boost points, its a feature of the Octopack Battler plugin. I can just use a normal res if that makes things easier. I will use the default formula and try what you mentioned above.

Edit: I tried it like this and it raises them but doesn't reduce the user to 1 hp.


a.hp=1; b.mhp / 10


a.gainHP(1-a.hp); b.mhp / 10 <- this raises them but leaves the target with 1 hp

Edit: Someone helped me with it in the damage formula thread. Thanks for the taking the time to help out, are there official/non-official material around that goes over damage formula basics? Just curious, I plan on doing some reading since I am just now reaching the point where I need to work some of this stuff out in my game.
I believe its gainHp() , and pretty sure its case sensitive.

a.gainHp(1-a.hp); Math.max(1, b.mhp / 2 * (a.bp + 1))
a.gainHp(1-a.hp);math.max(1, b.mhp / 2 * (a.bp + 1))

This worked, thanks!
@Snarkyfork
Glad that it worked.
And to your question regarding damage formula tutorials.

There is one on this forum that touches on basic functionalities and syntax and even goes into more advanced stuff.

Its a great starting point honestly.

Link

Original thread: https://forums.rpgmakerweb.com/threads/need-assistance-making-a-limited-res-spell.130102/