A state that has a percent chance of disappearing?

Joined
Feb 18, 2019
Messages
32
Reaction score
2
First Language
English
Primarily Uses
RMMV
So I want to create a Freeze state like in Pokemon. In Pokemon, the Frozen status effect has a percent chance of thawing out unlike most other status effects like it, which go away after a set amount of turns.

I've been fiddling with Yanfly's Buffs and States Core to create some statuses, and I believe I can use it to create this state. The problem is, whenever I try to do this with the plugin, I get an exception, and the game stops. Can anyone help?
 

Zerothedarklord

Veteran
Veteran
Joined
Jun 25, 2013
Messages
178
Reaction score
31
First Language
English
Primarily Uses
RMMV
Code:
<Custom Apply Effect>
   if (target._stateTurns[13] >= 25) {
     target._stateTurns[13] = 25;
   }
</Custom Apply Effect>
<Custom Apply Effect>

target._mercuryPoison = Math.ceil(origin.atk * 0.5 * target.elementRate(13));
crit = origin.luk / 5
</Custom Apply Effect>

<Custom Remove Effect>

target._mercuryPoison = undefined;

</Custom Remove Effect>

<Custom Regenerate Effect>

target._mercuryPoison = target._mercuryPoison || Math.ceil(origin.atk * 0.5);

// target.startAnimation(12);

v = Math.floor(Math.random()*100)+1
if (v >= crit)
{
target.gainHp(-target._mercuryPoison);
}
else
{
target.gainHp(-target._mercuryPoison * 2);
}

target.startDamagePopup();

if (target.isDead()) {

target.performCollapse();

}

target.clearResult();

</Custom Regenerate Effect>
This is a piece of code I use. This piece of code is on a state designated to a Bleeding effect, which deals damage based on the user's Attack stat. Within this code, you will notice the following line:
v = Math.floor(Math.random()*100)+1
This line is used to run a check, out of 100, to see if the damage dealt by the bleed effect will be critical or not. I believe you could modify this code (not just this 1 line) to do what you want to do.

Code:
v = Math.floor(Math.random()*100)+1

if (v >= crit)

{

target.gainHp(-target._mercuryPoison);

}

else

{

target.gainHp(-target._mercuryPoison * 2);

}
In this section here, it runs a check out of 100, and it checks the value of variable "crit" (which is set earlier to be equal to the user's luck divided by 5, but you would define it as whatever you want the chance to be for the freeze effect to break), then, there is the if statement, which determines what will happen. It states that if V is greater than or equal to Crit, damage will be dealt normally (in your case, the freeze effect would remain), Else, the damage will be critical, and therefore multiplied by 2 (or in your case, the freeze effect would end.

I have not tested it myself, but I've tinkered with lunatic mode codes within states, this should be able to do what you want it to.

If you can't get it figured out, add me on discord and I'll give you a hand tomorrow. This is definitely something I can figure out for you.
Zerothedarklord#8459
 
Last edited:
Joined
Feb 18, 2019
Messages
32
Reaction score
2
First Language
English
Primarily Uses
RMMV
Thanks for replying quickly! After a bit (read: quite a bit) of tweaking, I finally got the State to work properly! Thanks for the help with your code!
 

Zerothedarklord

Veteran
Veteran
Joined
Jun 25, 2013
Messages
178
Reaction score
31
First Language
English
Primarily Uses
RMMV
Thanks for replying quickly! After a bit (read: quite a bit) of tweaking, I finally got the State to work properly! Thanks for the help with your code!
yeah, I knew it'd take a bit, but I knew it would work. glad to hear it!
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

Yo Ho Ho... Time flies when you are having rum...

I'm rewatching Glee, just watched grilled cheesus.
Now I'm not sure if I'm hungry or I want to cry.
I just completed Ara Fell - completing the game unlocks an Epilogue. An interesting thing to possibly consider for my games.
I decided to try to make a mucha-styled artwork, and by now I've sunk more time in studies and sketches than I usually do in the whole thing. Fingers crossed it's worth it!

Forum statistics

Threads
99,451
Messages
965,434
Members
131,067
Latest member
LeoWolf
Top