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

Long time no see. Is “put on and take off my hat readily” right or natural?
My English teacher said the "readily" is used wrongly here. But I am not sure. Thank you very much for answering my small question.
More: The context is: The hat was too tight to wear originally and modified to suit the head and now I'm trying on it.
Ami
--- Difficulty Affect: Price ---

(Very Easy Difficulty)
Merchant: This HP Bottle just cost 5G per item
M.Archer: How much i sell it?
Merchant: It cost 50G per item
M.Archer: Alright,i buy 50
(Very Hard Difficulty)
Merchant: This HP Bottle cost 100G per item
M.Archer: How much i sell it?
Merchant: 5G
M.Archer: (Mouth Bleeding)
Finding synonyms for 'Crystal' is a bit awkward, because the thesaurus occasionally thinks I'm talking about drugs.
"Today I will totally open up RPG Maker and work on my game. I have lots of ideas!"

End of day spoiler: It didn't happen.
years later and I still couldn't get over the fact that Konami killed P.T. and Silent Hills. Oh so much potential for a new modern classic horror.

Forum statistics

Threads
109,138
Messages
1,042,453
Members
141,637
Latest member
liaoxiaodou
Top