A state counter crashes the game

Hello,

I am actually on the creation of a state based on a counter which is supposed to do the following:

- When the one under the effect of the state does a basic attack, the counter rises by 1. Else, it lowers by 1.
- When the one under the effect of the state is attacked and take direct damage from it, it is healed by a set purcentage of the damage taken depending on the counter.

My problem is in the second part of the state. Indeed, starting from the moment the character is supposed to take damages from an attack, the game crashes showing the following message:

crash_eta.png


Removing the influence of the counter in the heal calculation doesn't cause the game to crash anymore. The problem surely comes from there. Even while deactivating all plugins (except Yanfly's "Buffs & States Core"), the problem remains.

I wanted to know if the problem comes from my code and if yes, where I've been mistaken. Here is the full code:

Code:
<Custom Apply Effect>
user._ours = user._ours || 0;
user.setStateCounter(stateId, user._ours);
</Custom Apply Effect>

<Custom Confirm Effect>
if (this.isAttack()) {
  user._ours += 1;
  user._ours = Math.min(user._ours, 5);
  user.setStateCounter(stateId, user._ours);
}
</Custom Confirm Effect>

<Custom Respond Effect>
target.startDamagePopup();
target.clearResult();
if (this.isHpEffect() && value > 0) {
  this._soinOurs = Math.trunc(value * (0.16 * user._ours));
  target.gainHp(this._soinOurs);
  target.startDamagePopup();
  target.clearResult();
}
</Custom Respond Effect>

<Custom Conclude Effect>
if (!this.isAttack()) {
  user._ours -= 1;
  user._ours = Math.max(user._ours, 0);
  user.setStateCounter(stateId, user._ours);
}
</Custom Conclude Effect>

<Custom Remove Effect>
user._ours = 0;
user.setStateCounter(stateId, user._ours);
</Custom Remove Effect>

Interesting fact: the state doesn't crash when the enemy is the one to be healed or if the enemy have the same state than the actor.

My version of Yanfly's "Buffs & States Core" is 1.14 and my version of RPG Maker MV is 1.5.1.

Thank you by advance. 🙂
When the game crashes, can you open the console (press F8) and take a screenshot of the full error message?
There you go!

1518732279-screen-log-avec-censure.png
can you give us a screenshot of your plugin manager?
and have you checked if your yanfly plugins are in the correct order?
additionally, please open your project's rpg_core.js file with a text editor and tell us the version number in its title line (no number = 1.0)
Everything should be in order but if you see anything wrong, don't hesitate to tell me.

plugin list.png


I have the version 1.5.1 of the "rpg_core.js" file.
Due to having no answers for some time, I allow myself to bump up that topic a little, adding a few more infos in the process:

- I talked about a situation in the first message where the game doesn't crash. After a few tests, I realized that if not all the enemies are affected by the state, the crash still occurs.
- I have created a blank project so you will be able to test out the crash on your own but I can't upload it due to its size (about 380 Mo, compressed). Sorry about that.

Original thread: https://forums.rpgmakerweb.com/threads/a-state-counter-crashes-the-game.91370/