Redefining the conditions for the death of enemies and actors?

I used visustella's EnhancedTPSystem to set the special move values for enemies.
I want to set my enemies to die only after their MP, HP, and TP gauges are all depleted to 0, while my actors die when any one of their MP, HP, or TP reaches 100%.
Is there a way to achieve this? It seems like I might need to use a plugin or JS code, but I'm an art worker who doesn't understand code. I'd like to know if there's a way to make this happen.
Thank you in advance for your reply!
this might be tricky. by itself, making your change is easy, but its up in the air whether or not it wont cause an issue with a visustella plugin somewhere.

Spoiler
Code:
Game_Enemy.prototype.refresh = function() {
    Game_BattlerBase.prototype.refresh.call(this);
    if (this.hp === 0 && this.mp === 0 && this.tp === 0) {
        this.addState(this.deathStateId());
    } else {
        this.removeState(this.deathStateId());
    }
};

Game_Actor.prototype.refresh = function() {
    Game_BattlerBase.prototype.refresh.call(this);
    this.releaseUnequippableItems(false);
    if (this.hp === this.mhp || this.mp === this.mmp || this.tp === this.maxTp()) {
        this.addState(this.deathStateId());
    } else {
        this.removeState(this.deathStateId());
    }
};

Game_Actor.prototype.recoverAll = function() {
    this.clearStates();
    this._hp = 0;
    this._mp = 0;
    this._tp = 0;
};
Game_Actor.prototype.die = function() {
    this.clearStates();
    this.clearBuffs();
};

Game_Actor.prototype.isDying = function() {
    return this.isAlive() && (this._hp > this.mhp * .7 || this._mp > this.mmp * .7 || this._tp > this.maxTp() * .7) ;
};
try that, but load it as your first plugin

additional color edit:
digging around led to finding out that theres more stuff to play around with since i cant see exactly what VS is doing. going to have to split the plugin into 2. this is loaded above the VS plugins
Spoiler
Code:
Game_Enemy.prototype.refresh = function() {
    Game_BattlerBase.prototype.refresh.call(this);
    if (this.hp === 0 && this.mp === 0 && this.tp === 0) {
        this.addState(this.deathStateId());
    } else {
        this.removeState(this.deathStateId());
    }
};

Game_Actor.prototype.refresh = function() {
    Game_BattlerBase.prototype.refresh.call(this);
    this.releaseUnequippableItems(false);
    if (this.hp === this.mhp || this.mp === this.mmp || this.tp === this.maxTp()) {
        this.addState(this.deathStateId());
    } else {
        this.removeState(this.deathStateId());
    }
};

Game_BattlerBase.prototype.revive = function() {
    this._hp = 0;
    this._mp = 0;
    this._tp = 0;
};

Game_Actor.prototype.recoverAll = function() {
    this.clearStates();
    this._hp = 0;
    this._mp = 0;
    this._tp = 0;
};
Game_Actor.prototype.die = function() {
    this.clearStates();
    this.clearBuffs();
};

Game_Actor.prototype.isDying = function() {
    return this.isAlive() && (this.isCriticalHp() || this.isCriticalMp() || this.isCriticalTp()) ;
};
Game_Enemy.prototype.isDying = function() {
    return this.isAlive() && this.isCriticalHp() && this.isCriticalMp() && this.isCriticalTp() ;
};

Game_Actor.prototype.isCriticalHp = function() {
    return this._hp > this.mhp * .7;
};
Game_Actor.prototype.isCriticalMp = function() {
    return this._mp > this.mmp * .7;
};
Game_Actor.prototype.isCriticalTp = function() {
    return this._tp > this.maxTp() * .7;
};
Game_Enemy.prototype.isCriticalHp = function() {
    return this._hp < this.mhp/4;
};
Game_Enemy.prototype.isCriticalMp = function() {
    return this._mp < this.mmp/4;
};
Game_Enemy.prototype.isCriticalTp = function() {
    return this._tp < this.maxTp()/4;
};

Window_StatusBase.prototype.drawActorName = function(actor, x, y, width) {
    width = width || 168;
    this.changeTextColor(ColorManager.nameColor(actor));
    this.drawText(actor.name(), x, y, width);
};

and this after
Spoiler
Code:
ColorManager.hpColor = function(actor) {
    if (!actor) {
        return this.normalColor();
    } else if (actor.isDead()) {
        return this.deathColor();
    } else if (actor.isCriticalHp()) {
        return this.crisisColor();
    } else {
        return this.normalColor();
    }
};

ColorManager.mpColor = function(actor) {
    if (!actor) {
        return this.normalColor();
    } else if (actor.isDead()) {
        return this.deathColor();
    } else if (actor.isCriticalMp()) {
        return this.crisisColor();
    } else {
        return this.normalColor();
    }
};

ColorManager.tpColor = function(actor) {
    if (!actor) {
        return this.normalColor();
    } else if (actor.isDead()) {
        return this.deathColor();
    } else if (actor.isCriticalTp()) {
        return this.crisisColor();
    } else {
        return this.normalColor();
    }
};

ColorManager.nameColor = function(actor) {
    if (!actor) {
        return this.normalColor();
    } else if (actor.isDead()) {
        return this.deathColor();
    } else if (actor.isDying()) {
        return this.crisisColor();
    } else {
        return this.normalColor();
    }
};
Hmmm, not sure but I think it needs more modifications. Like when you die/revive it calls changes to your hp.

EDIT: I mean like on add/remove deathState

EDIT2: And maybe something with how your hp colors look etc
this might be tricky. by itself, making your change is easy, but its up in the air whether or not it wont cause an issue with a visustella plugin somewhere.

Spoiler
Code:
Game_Enemy.prototype.refresh = function() {
    Game_BattlerBase.prototype.refresh.call(this);
    if (this.hp === 0 && this.mp === 0 && this.tp === 0) {
        this.addState(this.deathStateId());
    } else {
        this.removeState(this.deathStateId());
    }
};

Game_Actor.prototype.refresh = function() {
    Game_BattlerBase.prototype.refresh.call(this);
    if (this.hp === this.mhp || this.mp === this.mmp || this.tp === this.maxTp()) {
        this.addState(this.deathStateId());
    } else {
        this.removeState(this.deathStateId());
    }
};
try that, but load it as your first plugin
Thanks! I think the other guy is right though. In addition to full recovery also being defined as the actor value becoming 0, maybe add a feature to be able to set the actor value to 0 before running the code. Right now the plugin causes me to gameover as soon as I enter the game.

Edit:Besides, in the original battle, actors with less than 20% HP would show a tired side view of the battle. Can this be changed so that the actor shows the combat side view when hp, mp, and tp are above 70%?
Hmmm, not sure but I think it needs more modifications. Like when you die/revive it calls changes to your hp.
yeah, good call there. maybe revival wont be an issue since by default it puts the battler to 1, but a full recover will just kill the entire party 🤣

Edit:
In addition to full recovery also being defined as the actor value becoming 0, maybe add a feature to be able to set the actor value to 0 before running the code.
ill update the original post with that addition in a second. the second would be a result of the first, as battlers do start with 1 hp, but then are fully recovered afterwards

Right now the plugin causes me to gameover as soon as I enter the game.
theres going to be more considerations made. Bring up anything that comes into question.

also i ran the VS sample project before posting the original just to make sure it wouldnt immediately end the game. it didnt immediately game over, but i knew being at full hp would have been an issue eventually since a refresh like starting battle would immediately kill everyone. i thought you might have had an event set everyone's hp/mp to 50% or some other preventative measure in place already

Edit**2:
Edit:Besides, in the original battle, actors with less than 20% HP would show a tired side view of the battle. Can this be changed so that the actor shows the combat side view when hp, mp, and tp are above 70%?
didnt see your edit, but did you mean the text turning yellow when a battler is at low hp, or did you mean something else? im not sure what youre describing
also slight change to the recover all portion if you already grabbed it
@Robro33
Yeah but I meant like for example, when you add death state, it launches the die function that sets the battler hp to 0 which then makes your modified functions to remove the death state for actors (if they have mp/tp), right?

EDIT: or to clarify like if their mp/tp isn't causing them to die
also i ran the VS sample project before posting the original just to make sure it wouldnt immediately end the game. it didnt immediately game over, but i knew being at full hp would have been an issue eventually since a refresh like starting battle would immediately kill everyone. i thought you might have had an event set everyone's hp/mp to 50% or some other preventative measure in place already
Before I get your help, I run a common event before the fight starts that sets the actor to immortal then deducts all their HP, MP and TP. So when I started the game and entered the map (not a fight test), my full HP made me GAME OVER.;_;
Since entering the map just now causes death, I scripted your code to run in a public event. So far it's not having problems, great. I wanted to ask if it's possible to modify the side view combat map display for exhaustion? I just added it to my last reply.
Yeah but I meant like for example, when you add death state, it launches the die function that sets the battler hp to 0 which then makes your modified functions to remove the death state for actors (if they have mp/tp), right?
i didnt think it was an issue initially since i didnt think dead battlers got refreshed in battle unless they got targeted by an action (which would have to be an action that specifically targets the dead and would most likely be a revive which sets battlers to 1 hp), but youre right. that its a measure that should be added nonetheless. thered be issues elsewhere if i didnt.

Before I get your help, I run a common event before the fight starts that sets the actor to immortal then deducts all their HP, MP and TP. So when I started the game and entered the map (not a fight test), my full HP made me GAME OVER.;_;
theres been a couple edits we've made past eachother, but one of them at one point was to make actors start at 0 hp to avoid that. as of right now, can you try what you see in the first post?

I wanted to ask if it's possible to modify the side view combat map display for exhaustion? I just added it to my last reply.
yeah, just need a clarification, you mean the text becoming yellow when the values are low, right?
1749292812926.png
theres been a couple edits we've made past eachother, but one of them at one point was to make actors start at 0 hp to avoid that. as of right now, can you try what you see in the first post?
It works! I am trying to test in more situation.
yeah, just need a clarification, you mean the text becoming yellow when the values are low, right?
1749292812926.png
Yellow and red texts are needs to be addressed as well.
But I mean like something about actor's sprite like this.
QQ_1749293733186.png
But I mean like something about actor's sprite like this.
i somehow missed that the other actors were doing the dying motion the entire time 🤣

once more, ive updated the first post so that actors only count as dying if any of their bars are above 70%. that being said, ill have to look a bit into fixing (or probably just redo) the colors for the status windows. Visustella makes a few changes to the colors and obfuscates them, so im not entirely sure if anything happening there is actually important or not
i somehow missed that the other actors were doing the dying motion the entire time 🤣

once more, ive updated the first post so that actors only count as dying if any of their bars are above 70%. that being said, ill have to look a bit into fixing (or probably just redo) the colors for the status windows. Visustella makes a few changes to the colors and obfuscates them, so im not entirely sure if anything happening there is actually important or not
I think the code is good enough now! I think it has accomplished exactly what I wanted to achieve with this thread.
Now I'm thinking about other things, such as if there is a way to be able to set the amount of blood monsters have when they log off? For example, I don't really want them to always be 100%. An enemy might have a maximum of 10hp, 10mp, but at the start of the fight it only has 6hp, 8mp?
An enemy might have a maximum of 10hp, 10mp, but at the start of the fight it only has 6hp, 8mp?
that can be done, but how will the starting value be chosen? do you want it to be random between some two points? always 75%? should different enemies use different percentages?
you could also use troop events to set enemy hp, but it could get tedious if you have many troops

also added the color stuff to the first post, but i think that's all thats needed? the name bit doesnt actually change anything on my end, but poking around obfuscated plugins is... annoying.
admittedly, i didnt look too closely into the color manager is used either as thats new to MZ, bit i think it looks fine as is
这是可以做到的,但如何选择起始值呢?您希望它在两个点之间随机吗?总是 75%?不同的敌人应该使用不同的百分比吗?

你也可以使用部队事件来设置敌人的 HP,但如果你有很多部队,这可能会很烦人
I think it would be interesting to follow the opportunity between the two points!

For example, if the maximum is 10mp and 10hp enemies, it would be nice to start with 6~8mp or 6~8hp. That means there could be 6mp, 7hp enemies or 8mp, 8hp enemies. (Not percentages, but numbers)

You are right.Now my concern is that I have a variety of enemies. Maybe it would be nice to be able to use notetag to define the hp, mp, and tp it has at the start of the fight.
For example, if the maximum is 10mp and 10hp enemies, it would be nice to start with 6~8mp or 6~8hp. That means there could be 6mp, 7hp enemies or 8mp, 8hp enemies. (Not percentages, but numbers)
this seems to work in the sample project, so give this a run when you can. Since you wanted to use the vales instead of the percentages, itll use values. Load it after your VS plugins to be safe.
Spoiler
Code:
(() => {
    var setup = Game_Enemy.prototype.setup
    Game_Enemy.prototype.setup = function(enemyId, x, y) {
        setup.call(this, enemyId, x, y);
        if (this.enemy().meta.StartingHp){
            var range = this.enemy().meta.StartingHp.split(",").map(Number)
            if (range.length)
                this._hp = range[0] + Math.randomInt(1+range[1]-range[0])
        }
    
        if (this.enemy().meta.StartingMp){
            var range = this.enemy().meta.StartingMp.split(",").map(Number)
            if (range.length)
                this._mp = range[0] + Math.randomInt(1+range[1]-range[0])
        }
    
        if (this.enemy().meta.StartingMp){
            var range = this.enemy().meta.StartingTp.split(",").map(Number)
            if (range.length){
                this._tp = range[0] + Math.randomInt(1+range[1]-range[0])
            }
        }
    };
})();
use the notetags <StartingHp: x,y>, <StartingMp: x,y>, and <StartingTp: x,y> to set a range that an enemy should start at. so <StartingHp: 3,6> makes them start at either 3,4,5 or 6 hp. if you dont use a notetag, the value will be whatever happens normally
this seems to work in the sample project, so give this a run when you can. Since you wanted to use the vales instead of the percentages, itll use values. Load it after your VS plugins to be safe.
Spoiler
Code:
(() => {
    var setup = Game_Enemy.prototype.setup
    Game_Enemy.prototype.setup = function(enemyId, x, y) {
        setup.call(this, enemyId, x, y);
        if (this.enemy().meta.StartingHp){
            var range = this.enemy().meta.StartingHp.split(",").map(Number)
            if (range.length)
                this._hp = range[0] + Math.randomInt(1+range[1]-range[0])
        }
   
        if (this.enemy().meta.StartingMp){
            var range = this.enemy().meta.StartingMp.split(",").map(Number)
            if (range.length)
                this._mp = range[0] + Math.randomInt(1+range[1]-range[0])
        }
   
        if (this.enemy().meta.StartingMp){
            var range = this.enemy().meta.StartingTp.split(",").map(Number)
            if (range.length){
                this._tp = range[0] + Math.randomInt(1+range[1]-range[0])
            }
        }
    };
})();
use the notetags <StartingHp: x,y>, <StartingMp: x,y>, and <StartingTp: x,y> to set a range that an enemy should start at. so <StartingHp: 3,6> makes them start at either 3,4,5 or 6 hp. if you dont use a notetag, the value will be whatever happens normally
It works!Thanks a lot.🤣
Can I add your name to the credits at the end of the game? Like your ID.
Can I add your name to the credits at the end of the game? Like your ID.
Sure, go right ahead

ill be closing the thread now. if you need it reopened, report the thread.

Original thread: https://forums.rpgmakerweb.com/threads/redefining-the-conditions-for-the-death-of-enemies-and-actors.178159/