I have this code here:
I want to change each battler's state duration based on the notes in their traits (armors, states, etc.) This code does do it, but it changes every battler affected by this state by every battler's note that affects this state. The turns become part of the class here rather than part of each specific battler object. How can I fix this?
JavaScript:
var _Add_State = Game_Battler.prototype.addState;
Game_Battler.prototype.addState = function (stateId) {
_Add_State.call(this, stateId);
//this.states(stateId)[0].minTurns += 2;
//this.states(stateId).maxTurns += 5;
console.log(this.states(stateId));
console.log("STATE ID " + stateId)
let regexMatch = /(?:<State\s* Duration\s* (\d+):\s* ([\-\+]\d+)>)/i
console.log(this.traitObjects())
this.traitObjects().forEach((element) => {
let skillMeta = element.note.split(/[\r\n]+/);
for (let a = 0; a < skillMeta.length; a++)
if (regexMatch.test(skillMeta[a]))
if (RegExp.$1 == stateId) {
for (let i = 0; i < this.states().length; i++)
if (this.states()[i].id == RegExp.$1) {
console.log("ID " + this.states()[i].id)
this.states()[i].minTurns += Number(RegExp.$2);
this.states()[i].maxTurns += Number(RegExp.$2)
this.resetStateCounts(stateId);
}
}
})
}
I want to change each battler's state duration based on the notes in their traits (armors, states, etc.) This code does do it, but it changes every battler affected by this state by every battler's note that affects this state. The turns become part of the class here rather than part of each specific battler object. How can I fix this?