potato1448

Villager
Member
Joined
Mar 29, 2021
Messages
13
Reaction score
2
First Language
English
Primarily Uses
RMMV
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!
 
Last edited:

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
3,756
Reaction score
2,849
First Language
English
Primarily Uses
RMMZ
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
Veteran
Joined
May 12, 2018
Messages
1,823
Reaction score
1,729
First Language
English
Primarily Uses
RMMV
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
Veteran
Joined
Jan 23, 2015
Messages
712
Reaction score
231
First Language
English
Primarily Uses
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
Veteran
Joined
Apr 12, 2012
Messages
3,756
Reaction score
2,849
First Language
English
Primarily Uses
RMMZ
Those will still present an issue if the game uses auto battle, but will be fine if it doesn't.
 

Latest Threads

Latest Posts

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!! :kaojoy:
RivalRamen_Games wrote on jacobv1014's profile.
I really like your profile picture! Who is that in it? is she an OC?
Making his first game

Forum statistics

Threads
115,331
Messages
1,089,069
Members
149,999
Latest member
Nasciturus
Top