Looking for help with State idea. Comparing stats every turn.

Hello. This is my first time posting to the boards. Until now I have gotten by with just searching things. However I have an idea, and I'm not sure how to make it happen. I have a skill named constrict, and a state name constricted. The skill compares the ATK of the user and target in the damage formula, and applies constricted with a bit of randomness. That works fine.

What I need help with is I want it so each turn the state makes the check again. If the target wins the state is removed, otherwise it stays. Also if the caster dies the state is auto removed.

I've seen some plug-ins that I think could help me, but the coding is above it. So if anyone better could help that would be much appreciated.
Yanfly's Buffs & States Core plugin gives you notetags to attach code to particular timings/actions, e.g. <Custom Turn End Effect>. 🙂

Not sure exactly what sort of comparison you've got set up, but you could try something like this:
Code:
<Custom Turn End Effect>
var atkRatio = user.atk / origin.atk;
if (atkRatio > Math.random()) {
  user.removeState(stateId);
}
</Custom Turn End Effect>
Basically:
  • origin is the battler who used the skill that applied the state, and
  • user is the battler currently affected by the state.
Other than that you should be able to just copy the condition you used in your skill's formula~ 😂
It worked great, thank you!

Original thread: https://forums.rpgmakerweb.com/threads/looking-for-help-with-state-idea-comparing-stats-every-turn.105767/