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

I once thought about a boss gauntled game. I actually did it.
Stream will be live shortly with some Gex 3! Feel free to drop by!
Snippet from a game I'm working on. Not much happening here. Mostly look at atmosphere. May upload a longer version. Still need to make up some enemy arts.
Been slightly struggling with developing the latest chapter, I think I will downscale my ambitions and make it more linear.

Forum statistics

Threads
109,058
Messages
1,041,697
Members
141,544
Latest member
spacewaxamerica
Top