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

Me Being Dumb spending hrs trying to figure out Irenas Visual Novel busts plugin..lol. I'm probably missing something stupid and obvious xDD

let the journey begin >w>
X.X ok... I guess I'll just have to think about 48x48 a little differently. Its not "room for more work"..."its room for more detail!...yay"
Alexa, play Buck-Tick - Dress
Worst part about doing a plugin based on an existing system: figuring out the best way for developers to set up the data.
Right now, my free time is less when Covid 19 in my country.
Begin to reduce the number of daily infections to 0.

Forum statistics

Threads
99,216
Messages
963,130
Members
130,804
Latest member
oleran
Top