MaxLionheart

Veteran
Veteran
Joined
Aug 23, 2015
Messages
112
Reaction score
34
First Language
French
Hey everyone!

I'm looking to create a state that grants a character a certain % chance to gain 1 mp after the character ends its turn. For example: everytime Bob does something and its turn is now over, he has 33% chance to regenerate 1 mp.

I'm pretty sure it's not that complicated (maybe I'm wrong!) to create a state like that with Yanfly's BuffsStatesCore, but unfortunately, I lack the ability to code in eval.

I'm using a lot of Yanfly's plugins, and my game is played in ATB mode (thus I can't use battle events to simulate the state I'm looking for, since a character's turn doesn't equal to a real in game turn). I'm also using a lot of instant casts abilities that do not end a character's turn (so I don't want a character recovering mp after a quick cast).

If anyone has an idea, it'd help me a lot.

Thank you in advance :)
 
Last edited:

Johnny_Ray

Also known as Toby Yasha
Veteran
Joined
Sep 11, 2019
Messages
69
Reaction score
39
First Language
English
Primarily Uses
RMMV
Give these a try:

<Custom Turn End Effect>
var chance = 0.33;
if (Math.random() < chance) {
user.gainMp(1);
}
</Custom Turn End Effect>


<Custom Action End Effect>
var chance = 0.33;
if (Math.random() < chance) {
user.gainMp(1);
}
</Custom Action End Effect>
 

Soulrender

Jack Of All Trades
Veteran
Joined
Jan 12, 2019
Messages
994
Reaction score
581
First Language
Poland
Primarily Uses
RMMV
If you use Math.random() then round a result to a flat number, here I've made some improvements:

Code:
<Custom Turn End Effect>
var chance = 3;
var mpGain = 1;
if (Math.floor(Math.random() * 100) < chance) {
    user.gainMp(mpGain);
    }
</Custom Turn End Effect>


<Custom Action End Effect>
var chance = 3;
var mpGain = 1;
if (Math.floor(Math.random() * 100) < chance) {
    user.gainMp(mpGain);
    }
</Custom Action End Effect>
 

MaxLionheart

Veteran
Veteran
Joined
Aug 23, 2015
Messages
112
Reaction score
34
First Language
French
Thanks a bunch you two! It works perfectly! I really appreciate your help!

(Soulrender, I just changed the var chance = 3 since I guess it made a 3% chance)
 

Soulrender

Jack Of All Trades
Veteran
Joined
Jan 12, 2019
Messages
994
Reaction score
581
First Language
Poland
Primarily Uses
RMMV
You can change whatever you like, I changed to regular 3, because flat numbers are more easy to handle :)
 

Latest Threads

Latest Profile Posts

My Game Development Livestream

Of course, so, someone had covid at work today and I was exposed to them, so, I'm stuck at home for...TWO WEEKS!
oh god I'm going to die
AAAAAAAAi.png
Kind of relieved that I had medibang installed when I need to edit Sprite I was about to download gimp but I remember I had medibang installed lol

Forum statistics

Threads
110,368
Messages
1,052,667
Members
143,402
Latest member
IBanana
Top