Bugfix: “Cannot move” states with Yanfly’s ATB and Buffs & States Core
I wanted to make a post about a certain problem I encountered recently. It basically took me one day of debugging to find the root cause. Therefore I thought it would be useful to share this information because someone else might also struggle with this. The problem is as follows:
You have a “Cannot move” state which is not removed by damage and it lasts several turns (basically a “stunned” state). If you use Yanfly’s ATB system, the Turn Time parameter in the Yanfly Battle Engine Core plugin will determine how many ticks have to pass by to equal one turn for these kind of states (is there a way to make this turn time based on the respective enemy’s/actor’s agility?). When the “stunned” state is applied to an enemy and an actor attacks this certain enemy, the turn counter of that state gets reduced by 1 turn. To prevent this from happening, you have to make a small modification to the “setStateTurns” method in Yanfly’s plugin file “YEP_BuffsStatesCore.js” . You can copy & paste the following code and replace the corresponding method in your plugin file:
1 2 3 4 5 6 7 |
Game_BattlerBase.prototype.setStateTurns = function(stateId, turns) { if (Imported.YEP_BattleEngineCore && !Yanfly.Param.BECTimeStates && !BattleManager.isATB()) { turns = Math.floor(turns); } this._stateTurns[stateId] = turns; }; |
With this modification the plugin won’t round the current turn count downward to its nearest integer and it will preserve the actual value. That’s it. I hope this is helpful for some of you. If you like what I do, follow me on Twitter and Facebook to stay up to date.
Oh wow! So it’s a simple few lines of code that were causing such a huge problem? I wonder if it can be adapted for YanFly’s CTB Engine? Wouldn’t you just change that from “!BattleManager.isATB()” to “!BattleManager.isCTB()”?
I’ve tried it but unfortunately it doesn’t look like it’s working correctly with CTB.