RMMV Fixed a bug which caused <instant> skills to cancel another skill if that skills atbChargeGauge was ready already.

HornsterLG

Veteran
Veteran
Joined
Dec 19, 2021
Messages
89
Reaction score
24
First Language
german
Primarily Uses
RMMV
The bug: using YEP_BattleSysAtb skills are charging a chargeGauge before they are used. If that charge gauge is filled exactly when someone else casts an instant skill, the skill is cancelled(but still costs mana and full atbgauge), because the rpg maker engine can not process 2 actors/enemies attacking at the same time.

here is the fix

Yep_X_BattleSysATB line 6:
Code:
var Imported = Imported || {};
Imported.YEP_X_BattleSysATB = true;

var Yanfly = Yanfly || {};
Yanfly.ATB = Yanfly.ATB || {};
Yanfly.ATB.version = 1.28;

var stopChargeSkill = false;        // i did this i created this

Yep_X_BattleSysATB line 1230:
Code:
BattleManager.getChargedATBBattler = function() {
    if ($gameParty.aliveMembers() <= 0 || $gameTroop.aliveMembers() <= 0) {
      return false;
    }
    var fastest = false;
    for (var i = 0; i < this.allBattleMembers().length; ++i) {
      var battler = this.allBattleMembers()[i];
      if (!battler) continue;
      if (!this.isBattlerATBCharged(battler)) continue;
      if (!fastest) {
        fastest = battler;
      } else if (battler.atbCharge() > fastest.atbCharge()) {
        fastest = battler;
      }
    }
    stopChargeSkill = false;                                                                             //i did this i created this
    return fastest;
};

BattleManager.isBattlerATBCharged = function(battler) {
    if (stopChargeSkill) return false;                                                               // i did this i created this
    if (!battler.isATBCharging()) return false;
    if (battler.atbChargeRate() < 1) return false;
    if (battler.isConfused()) {
      battler.makeActions();
      if (battler.isActor()) battler.makeConfusionActions();
    }
    return battler.currentAction() && battler.currentAction().item();
};

YEP_InstantCast line 355:
Code:
BattleManager.endActorInstantCast = function() {
    if (Imported.YEP_BattleEngineCore && BattleManager.isDTB()) {
      this._ignoreTurnOrderFirstIndex = false;
    }
    var user = this._subject;
    user._selfTurnCount -= 1;        // i did this i changed this
    stopChargeSkill = true;            //i did this i created this
    if (Imported.YEP_BattleEngineCore) {
      if (this._processingForcedAction) this._phase = this._preForcePhase;
      this._processingForcedAction = false;
    }
    if (this.updateEventMain()) return;
    Yanfly.Instant.BattleManager_endAction.call(this);
    this._subject = user;
    this._instantCasting = undefined;
    user.makeActions();
    if (this.checkBattleEnd()) return;
    this._phase = 'input';
    if (user.canMove() && user.canInput()) {
      user.endInstantCast();
    } else {
      user.makeActions();
      this.selectNextCommand();
    }
    this.refreshStatus();
    if (Imported.YEP_BattleEngineCore && BattleManager.isDTB()) {
      this._subject = undefined;
    }
};

YEP_InstantCast line 385:
Code:
BattleManager.endEnemyInstantCastAction = function() {
    var battler = this._subject;
    if (!battler) return;
    if (battler.isActor()) return;
    var action = this._action;
    if (!action) return;
    var item = action.item();
    if (!item) return;
    if (battler.isInstantCast(item)) {
        this.addInstantCastAction(battler);
        battler._selfTurnCount -= 1;  // i did this i changed this
        stopChargeSkill = true;            // i did this i created this
    }
};
 

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
6,293
Reaction score
4,245
First Language
English
Primarily Uses
RMMV
Thanks for the bugfix! In the future, I'd suggest you use line references instead of posting entire functions, as Yanfly's terms of use prohibit distributing portions of code.
 

Latest Threads

Latest Posts

Latest Profile Posts

KDS
Hey guys! Iam currently updating my free digital art shop , let me know if you need anything done :) https://forums.rpgmakerweb.com/index.php?threads/kds-free-open-digital-art-shop.17097/
Hello! I’d like to ask where is a good place to start logging about my game dev progress as production of my game goes forth
In one of our campus classrooms was a bag full of stuff people forgot there... my bag. That I forgot there xD
You know your room is too tiny for how much stuff you have when it gives you literal insomnia. I just cleared a bunch of stuff out and man it feels good!
1670381555475.png
Meet the Kernel. You encounter him in cyberspace. He's important!

Forum statistics

Threads
127,098
Messages
1,183,961
Members
167,026
Latest member
silverbell
Top