A state that has a percent chance of disappearing?

Joined
Feb 18, 2019
Messages
39
Reaction score
3
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
269
Reaction score
73
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
39
Reaction score
3
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
269
Reaction score
73
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 Profile Posts

Don't forget, aspiring writers: Personality isn't what your characters do, it is WHY they do it.
Hello! I would like to know if there are any pluggings or any way to customize how battles look?
I was thinking that when you start the battle for it to appear the eyes of your characters and opponents sorta like Ace Attorney.
Sadly I don't know how that would be possible so I would be needing help! If you can help me in any way I would really apreciate it!
The biggest debate we need to complete on which is better, Waffles or Pancakes?
rux
How is it going? :D
Day 9 of giveaways! 8 prizes today :D

Forum statistics

Threads
106,049
Messages
1,018,547
Members
137,835
Latest member
yetisteven
Top