YEP_SelectionControl interacts weirdly with my plugin.

Discussion in 'Javascript/Plugin Support' started by MysteryMan23, Oct 2, 2019.

  1. MysteryMan23

    MysteryMan23 Veteran Veteran

    Messages:
    101
    Likes Received:
    27
    First Language:
    English
    Primarily Uses:
    RMMV
    Okay, so, I created a plugin primarily for internal use. It essentially allows states to reverse battlers' friends and opponent units, causing them to fight to the other side. However, there is a strange glitch: when Yanfly's Selection Control is turned on, a battler under a "reverse" state can not be targeted by their opponents. This applies to both actors and enemies, and does not happen if Yanfly's Selection Control is turned off.

    Here is my plugin:

    Code:
    var Imported = Imported || {};
    Imported.NW_ReverseAllyEnemy = true;
    
    var NewWorld = NewWorld || {};
    NewWorld.RAE = NewWorld.RAE || {};
    NewWorld.RAE.version = 1.00;
    
    
    NewWorld.RAE.DataManager_isDatabaseLoaded = DataManager.isDatabaseLoaded;
    DataManager.isDatabaseLoaded = function() {
      if(!NewWorld.RAE.DataManager_isDatabaseLoaded.call(this)) return false;
      if(!NewWorld._loaded_NW_ReverseAllyEnemy) {
        this.processRAENotetag($dataStates);
        NewWorld._loaded_NW_ReverseAllyEnemy = true;
      }
      return true;
    };
    
    DataManager.processRAENotetag = function(group) {
      for (var n = 1; n < group.length; n++) {
        var obj = group[n];
        var notedata = obj.note.split(/[\r\n]+/);
       
        obj.reverse = false;
    
        for (var i = 0; i < notedata.length; i++) {
          var line = notedata[i];
          if (line.match(/<(?:ALLY ENEMY REVERSAL)>/i)) {
            obj.reverse = true;
          }
        }
      }
    };
    
    Game_BattlerBase.prototype.isReverse = function() {
      return this._states.some(function(id) {return $dataStates[id].reverse}, this);
    };
    
    Game_Actor.prototype.friendsUnit = function() {
      if (this.isReverse()) {
        return $gameTroop;
      } else {
        return $gameParty;
      }
    };
    
    Game_Actor.prototype.opponentsUnit = function() {
      if (this.isReverse()) {
        return $gameParty;
      } else {
        return $gameTroop;
      }
    };
    
    Game_Enemy.prototype.friendsUnit = function() {
      if (this.isReverse()) {
        return $gameParty;
      } else {
        return $gameTroop;
      }
    };
    
    
    Game_Enemy.prototype.opponentsUnit = function() {
      if (this.isReverse()) {
        return $gameTroop;
      } else {
        return $gameParty;
      }
    };
    What should I change to fix this bug?

    EDIT: Turns out, another plugin was playing a role in the bug. However, I have since decided said plugin no longer fits my game, and have removed it. Now, everything works as it's supposed to, so could someone close this for me? Thank you.
     
    Last edited: Oct 3, 2019
    #1

Share This Page