RMMV Using "Origin" w/o using "Origin"...Possible?

Frostorm

[]D[][]V[][]D aka "Staf00"
Veteran
Joined
Feb 22, 2016
Messages
1,846
Reaction score
1,599
First Language
English
Primarily Uses
RMMV
Ok, I've been plagued w/ compatibility issues due to LTBS, so origin and stateOrigin(), which is from Yanfly's plugins, don't work for me. So I'm looking for an alternative to get the same functionality but w/o using origin. Is this possible? I really need this functionality, or else DoTs don't work, nor would utility scaling of any kind...:kaosigh:

This is what I found in YEP_BuffsStatesCore.js:
JavaScript:
Game_BattlerBase.prototype.stateOrigin = function(stateId) {
    if (this._stateOrigin === undefined) this._stateOrigin = {};
    if (!this._stateOrigin[stateId]) return this;
    var arr = this._stateOrigin[stateId];
    if (arr[0] === 0) return $gameActors.actor(arr[1]);
    if (arr[0] === 1) return $gameTroop.members()[arr[1]];
    return this;
};

Game_BattlerBase.prototype.setStateOrigin = function(stateId, battler) {
    if (this._stateOrigin === undefined) this._stateOrigin = {};
    if (!$gameParty.inBattle()) return;
    if (!battler) {
      var battler = BattleManager._subject;
      if (!battler) return;
    }
    if (battler.isActor()) {
      var arr = [0, battler._actorId];
    } else {
      var arr = [1, battler.index()];
    }
    this._stateOrigin[stateId] = arr;
};

Game_BattlerBase.prototype.clearStateOrigin = function(stateId) {
    if (this._stateOrigin === undefined) this._stateOrigin = {};
    this._stateOrigin[stateId] = undefined;
};

Game_BattlerBase.prototype.clearEnemyStateOrigins = function() {
    var length = $dataStates.length;
    for (var i = 0; i < length; ++i) {
      if (this._stateOrigin === undefined) this._stateOrigin = {};
      if (this._stateOrigin[i] === undefined) continue;
      var data = this._stateOrigin[i];
      if (data[0] === 1) this.clearStateOrigin(i);
    }
};
What could be the reason for LTBS not acknowledging this block of code? I've already played w/ plugin order to no avail. That doesn't seem to be the issue anyway since all other functions of BuffStatesCore work fine. If I can't get LTBS to use Yanfly's origin stuff, I need an alternative to get the same functionality, whether it's by v[ ] or other means. Please let me know if you guys have any ideas, thx!
 
Last edited:

ramza

Lunatic Coder
Veteran
Joined
Jan 28, 2013
Messages
836
Reaction score
528
First Language
English
Primarily Uses
RMMV
Since the origin is not defined, I'd say the problem is that the function to set the origin is never called.

If we look at BuffStatesCore, we can see that it should be set when a state is applied:

Code:
Yanfly.BSC.Game_Battler_addState = Game_Battler.prototype.addState;
Game_Battler.prototype.addState = function(stateId) {
    var addable = this.isStateAddable(stateId);
    Yanfly.BSC.Game_Battler_addState.call(this, stateId);
    if (addable) {
      this.setStateOrigin(stateId);
      this.addStateEffects(stateId);
    }
};
This code is an alias of the addState function, after it adds the state, it sets the origin. I'd say the problem is that LeTBS probably overwrites the addState function, instead of aliasing it, or aliases it without calling the alias, effectively ignoring any changes other plugins have made to it. To correct this, you'd have to search the plugin for Game_Battler.prototype.addState and see exactly what it's doing in there, and then combine that function with the above function from BSC.

Or maybe I'm wrong and the problem is actually the isStateAddable function messing up. You could try setting that to true instead of calling the function and see if that makes a difference too. I'd bet on the first one, though.
 

Frostorm

[]D[][]V[][]D aka "Staf00"
Veteran
Joined
Feb 22, 2016
Messages
1,846
Reaction score
1,599
First Language
English
Primarily Uses
RMMV
Oh, I think your right! At least that's what it seems like:
JavaScript:
Game_Interpreter.prototype.interpretLeTBS_AddState = function (args) {
    var entity = this.readEntityForLeTBS(args[0]);
    var id = Number(args[1]);
    if (entity && id) {
        entity.battler().addState(id);
        if (args.join().toLowerCase().includes("showpopup"))
            entity.addPopup();
    } else {
        return false;
    }
    return {};
};
Lol "addstate" only shows up twice in ~12k lines of code, while "stateadd" isn't found at all (non case-sensitive search).

Edit: I did find this in there though, which is at least part of "Game_Battler":
JavaScript:
Lecode.S_TBS.oldGameBattler_addNewState = Game_Battler.prototype.addNewState;
Game_Battler.prototype.addNewState = function (stateId) {
    Lecode.S_TBS.oldGameBattler_addNewState.call(this, stateId);
    if (LeUtilities.isScene("Scene_Battle") && Lecode.S_TBS.commandOn) {
        var state = $dataStates[stateId];
        var entity = BattleManagerTBS.getEntityByBattler(this);
        if (entity)
            entity.onNewState(state);
    }
};
Should I just stick the following onto it?
if (this.isStateAddable(stateId)) {
this.setStateOrigin(stateId);
this.addStateEffects(stateId);
}

Or maybe just this.setStateOrigin(stateId); since the state's effects are already being applied?
 

Latest Threads

Latest Posts

Latest Profile Posts

I'm moving on from RMXP finally. I've been stuck in a difficult decision between XP and MZ, and I've given up and moved on to MZ. Overall I'm really liking it, I wish tilesets were easier to setup like XP, but it's actually not that bad!
Have you ever gone full 'Ship of Theseus' while frankenspriting? Because I just did.
I saw my new eye doctor today, he reminds me of Satoru Iwata for some reason
I've been using a modified version of a script called Multiple Messages. It makes my text boxes look like a Mario & Luigi game! There is something about it that bothers me a little bit, but I shouldn't worry about that now.

Side note, Mist's walking animation is almost perfectly in sync with Loose Yourself by Eminem.
Starting work on some stuff for the community. Hopefully it will be fun, and useful to somebody.

Forum statistics

Threads
107,773
Messages
1,032,038
Members
139,915
Latest member
nick7626
Top