Surviving Death

Hi! I'm using this plugin with my game http://mvplugins.com/plugin/Moogle_X/Moogle_X%20-%20Die%20At%200%20MP


In essence what I want is for either reaching 0 HP or MP to induce a 'loss' state, but not for the player to reach game over. Instead I've been ticking the box which lets a player lose to a battle in order to trigger a chain of events, but sadly I noticed just recently that this plugin is not compatible with this option and just sends the player directly to the death screen. Another unfortunate drawback is that consuming items or otherwise reaching 0 HP/MP outside of battle always leads to the game over screen as well, but optimally I'd like to not have any game over states in the game at all!


Any tips to how I can solve this?
Don't know if this will help you, but this plugin prevents death (and the game over screen) by "raising" a player if they hit 0 Life.


http://forums.rpgmakerweb.com/index.php?/topic/48847-special-state-autolife/#comment-484686
That adds a state which is intended to be used like an ability, which isn't quite what I'm looking for. I'd optimally want some kind of way to avoid the game over screen, or possibly to have the MP plugin modified so it induces loss rather than gives the death state.
You could use Tsukihime's gameover script?


But it sends the player to a map where everything will be evented...
You could use Tsukihime's gameover script?


But it sends the player to a map where everything will be evented...

It's important that I'm able to continue the events that would happen when the 'can lose' option is checked. Enemies will have effects on the party that isn't just a flat game over.
Well, I think I found the problem...


In the script, it makes so that even when revived the character is killed again if mp is 0. And the secret of "canLose" not dealing Gameover is because it revives everyone with 1HP.


But not 1MP.


I made a quick fix, try adding it as a new .js plugin:


Game_Party.prototype.reviveBattleMembers = function() {
this.battleMembers().forEach(function(actor) {
if (actor.isDead()) {
actor.setHp(1);
if (actor._mp === 0 && actor.canDieAtZeroMp()) {
actor.setMP(1);
}
}
});
};


I didn't test, though.
Thanks for taking the time to try working out a specific fix for my problem! Unfortunately I get an error, when the party (single actor) dies due to reaching 0 mana, the battle starts to fade and I get this error:
"TypeError


undefined is not a function"
What does the console (f8) say? it usually gives more info about errors
TypeError: undefined is not a function
    at file ..../js/plugins/ManaDeath_Fix.js:6:23
    at Array.forEach (native)
    at Game_Party.reviveBattleMembers (file:.../js/plugins/ManDeath_Fix.js:2:26)
    at Function.BattleManager.updateBattleEnd (file.../js/rpg_managers.js:2326:24)
    at Function.BattleManager.update (.../js/plugins/YEP_BattleEngineCore.js:1624:18)
    at Scene_Battle.updateBattleProcess (.../js/rpg_scenes.js:2050:23)
    at Scene_Battle.update (file:.../js/rpg_scenes.js:2042:14)
    at Scene_Battle.update (file:.../js/plugins/YEP_BattleEngineCore.js:4138:36)
    at Function.SceneManager.updateScene (file:.../js/rpg_managers.js:1673:25)
    at Function.SceneManager.updateMain (file:.../js/rpg_managers.js:1641:10)
Ok, there is a chance the problem is that the revival happens before the hp recovery...


Try this instead:


Game_Party.prototype.reviveBattleMembers = function() {
this.battleMembers().forEach(function(actor) {
if (actor.isDead()) {
if (actor._mp === 0 && actor.canDieAtZeroMp()) {
actor.setMP(1);
}
actor.setHp(1);
}
});
};


If this one doesn't work, I'll have to take a look at the plugin while it is working on my own project...
Sadly, it still doesn't work >:


EDIT:


Also, I'm by no means no coder, but isn't there a symbol missing there?


this.battleMembers().forEach(function(actor) {




Could it be "this.battleMembers().forEach(function(actor)) {" ?


EDIT 2:


I made that change, and there's no longer any error, however the game over still triggers.
Nope. that closing parenthesis is there, but later. Putting one earlier, you made the program ignore the plugin.


No, I found the error. It is kinda a stupid one on my part.


Javascript is case-sensitive.


I used Ruby in the previous versions of RPG Maker, so I'm not used to it.


So, if you were writing, for example, actor.setMP(1) instead of actor.setMp(1) it can't recognize the function.


So, this one should work, it did when I tested:

Code:
Game_Party.prototype.reviveBattleMembers = function() {
    this.battleMembers().forEach(function(actor) {
        if (actor.isDead()) {
            if (actor._mp === 0 && actor.canDieAtZeroMp()) {
                actor.setMp(1);
            }
            actor.setHp(1);
        }
    });
};
That seems to have worked perfectly, thank you very much!
No problem.

Original thread: https://forums.rpgmakerweb.com/threads/surviving-death.70401/