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
40
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

I am adamant about not having missable quests, which means having to write entirely new scenes at each plot progression that takes into account that time and events have passed since the quest could first be accepted while still having there be a quest to solve in the first place. It's worth every second.
Surprisingly useful and thought provoking
Working on animation. Trying to see if I can apply it meaningfully to my games!
ddwk.png

working on the sprite for Devali <3
My Game Development Livestream

Forum statistics

Threads
110,377
Messages
1,052,787
Members
143,419
Latest member
haniffauziyatun
Top