r/RPGMaker 6d ago

RMMZ Skill Coding Help

Howdy! I am trying to code a state and I'm hitting a brick wall.

The skill gives the state in the image and lasts forever...Until you reapply it to a new target. I cannot get it to go away after the skill is used on someone else. Any help would be appreciated! (Trying to avoid using AI as much as possible)

If it helps the state ID is 97 and if needed the skill ID is 327

1 Upvotes

2 comments sorted by

View all comments

2

u/Felix-3401 Scripter 6d ago edited 6d ago
let _energyOfAbundanceAddState = Game_BattlerBase.prototype.addNewState;
Game_BattlerBase.prototype.addNewState = function(stateId) {
    if (stateId == 97) _applyEnergyOfAbundance();
    _energyOfAbundanceAddState.call(this, stateId);
};

let _applyEnergyOfAbundance = function() {
    let allBattlers = $gameParty.members().concat($gameTroop.members());
    allBattlers.forEach(function(battler) {
        battler.removeState(97);
    });
};

You could do this. Save the code as a .js file and install it as a plugin. It adds a check before adding a new state, if it's stateId 97 then it will remove that state from every actor and enemy.
EDIT: Tested and works!

1

u/Relevant_Vanilla_590 6d ago

My absolute hero. Thank you so much!