# Need help with a glass cannon skill

#### potato1448

##### Villager
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.
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.
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!

Last edited:

#### Trihan

##### Speedy Scripter
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?

#### Aesica

##### undefined
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.

#### Zarsla

##### Veteran
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();

Last edited:

#### Trihan

##### Speedy Scripter
Those will still present an issue if the game uses auto battle, but will be fine if it doesn't.

### Latest Profile Posts

Anyone going to talk about Chris Pratt Mario?
My friend just gave me chocolate milk at lunch today! My day is now 1000x better. Yay, choco milky!!
I really like your profile picture! Who is that in it? is she an OC?
Making his first game