Need help with a glass cannon skill

I'm trying to make a skill where it's a 50/50 chance either the attacker dies or the defender dies. it's supposed to be a last stand/hail mary option.
1617150525588.png

I set up a common event to determine whether the attacker or defender is picked but the problem rises where the only option for changing health is either for a certain character or the entire party. I just want the attacker or defender to be effected not the entire party.
1617150682842.png

I saw some similar posts recommending calling the variable or event in the damage formula but I'm not familiar with it enough to know what and how to write a formula to call the event! Thanks a million in advance!

[EDIT1] Thanks to the awesome help of everyone I was able to get the skill working! Aesiea's code was a perfect fit!
Code:
Math.random() < 0.5 ? a.gainHp(-999) : b.gainHp(-9999); 0

Thanks again everyone for help! Appreciate it tons!
Doing it in the damage formula can work, but there's one very important proviso to make sure of first: does your game use "auto battle" at all?
Don't bother with a common event. Use the damage formula box instead. Set the damage type to MP (even though you'll be doing HP damage) so that when it damages the user, it won't pop up anything for the target.

Code:
Math.random() < 0.5 ? a.gainHp(-999) : b.gainHp(-9999); 0

Not tested, but will probably work. 😉
It's not going to work like that.
For lots if reasons
1. You're code in the damage formula is wrong, like with what's written doesn't make sense.

2.Common event always happens after the damage formula.

If I understand what you want,
There's a 50/50 chance the user dies or the target dies.

What you want is in the damage formula is this:

var dmf = a.atk * 2 - b.def; Math.randomInt(100) < 50 ? a.gainHp(-dmf); : dmf;

And make the skill hp damage and remove the common event.

If you want it where it's an instant kill skill:
Math.randomInt(100) < 50 ? a.dies(); : b.dies();
Those will still present an issue if the game uses auto battle, but will be fine if it doesn't.

Original thread: https://forums.rpgmakerweb.com/threads/need-help-with-a-glass-cannon-skill.134938/