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
188
Reaction score
33
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
188
Reaction score
33
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

Government : "Hehehe~ I will spread lies that the earth is round so that I could sell globes~"
Anyone here managed to never burn out on programming? My current limit is 3 months(6-8 hours per day, 7 days per week, 50 hour programming week on average), and then I just have to take a break, sometimes lasting few days(with at most 2 hours on programming per day). I've been always like this so far, so I admire those who can always be so passionate on programming :)
This is starting to become a momochi collection y'all!
Meet Swefo The candy Eater!

Hide your candy... I or I sweefe sweefefooo~~~
Automatic level scaling without an option to turn it off can be a very bad choice for a game. The worst I've ever seen was in Nightmare of Druaga, where if a power outage made your system turn off, the game detects it as an attempted cheat and overwrites your save while taking away your best gear, leaving you unable to progress at the late stages of the game, and unable to recover.

Forum statistics

Threads
99,655
Messages
967,739
Members
131,338
Latest member
Vattitheminish
Top