So I've been trying to set it up so that an actor's TP is reset when they're knocked out.
This sounds like it should be simple from a programming perspective, but I tried like 10 different ways, and each time either 1, it doesn't work, or 2, I get a Stack Overflow Error when testing and an ally is KO'd.
An example of one (of many) coding solutions I tried:
I have basic programming knowledge, but just wanting an actor's TP set to 0 on KO seems to be *way more difficult* than I anticipated. Anyone have any idea how to do this?
I will note that I've tried doing this without any plugins enabled (besides my own). With plugins enabled, I also tried using a VisuStella notetag in the Knockout state:
This actually works (the ally is KO'd and their TP resets), but causes the game to freeze up for 2-3 seconds when an ally is KO'd, so this isn't a viable solution either.
This sounds like it should be simple from a programming perspective, but I tried like 10 different ways, and each time either 1, it doesn't work, or 2, I get a Stack Overflow Error when testing and an ally is KO'd.
An example of one (of many) coding solutions I tried:
Code:
Game_Battler.prototype.refresh = function() {
Game_BattlerBase.prototype.refresh.call(this);
if (this.hp === 0) {
this.clearTp(); //this results in a Stack Overflow Error when an ally is KO'd
this.addState(this.deathStateId());
} else {
this.removeState(this.deathStateId());
}
};
Code:
Game_BattlerBase.prototype.addNewState = function(stateId) {
if (stateId === this.deathStateId()) {
this.clearTp(); //this also results in a Stack Overflow Error
this.die();
}
const restricted = this.isRestricted();
this._states.push(stateId);
this.sortStates();
if (!restricted && this.isRestricted()) {
this.onRestrict();
}
};
I have basic programming knowledge, but just wanting an actor's TP set to 0 on KO seems to be *way more difficult* than I anticipated. Anyone have any idea how to do this?
I will note that I've tried doing this without any plugins enabled (besides my own). With plugins enabled, I also tried using a VisuStella notetag in the Knockout state:
Code:
<JS On Add State>
target.clearTp();
</JS On Add State>
This actually works (the ally is KO'd and their TP resets), but causes the game to freeze up for 2-3 seconds when an ally is KO'd, so this isn't a viable solution either.