MaxLionheart

Veteran
Veteran
Joined
Aug 23, 2015
Messages
104
Reaction score
31
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
61
Reaction score
38
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
973
Reaction score
566
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
104
Reaction score
31
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
973
Reaction score
566
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

KenKrath wrote on RPGMakerWeb's profile.
Hi there!! I saw my Valentines Video placed in the contest. I'm wondering if I placed 3rd or 1st though because my video was shown first but my name is shown as the 3rd video. Thanks for the opportunity :)
I found a book about game localization. It costs R$708,00 on Amazon. ;_;
I really wish my game was far enough along for it to be actually playable beyond certain aspects. I think I've crafted a really fun battle system thanks to ATB, fighting game, and Boost point mechanics.
Play test of my current progress on Happy Camper
Cutscene Contest Winners have been announced!

Forum statistics

Threads
109,112
Messages
1,042,192
Members
141,611
Latest member
theNaoya
Top