Why is my Bestiary removing status effects in battle?



These are the plugins I'm using together to add a party command that allows the player to open the bestiary during a battle. I was able to resolve a problem with the bestiary backgrounds during battle. Unfortunately, it causes some other unexpected problems, one minor, one major. The minor issue is that enemies that are set to appear halfway will appear no matter what when you close the bestiary. Thankfully I've only use this in 4 places in my game and I've already worked around the issue in those places. The major issue is that status effects all completely disappear when the bestiary is opened and closed. HP is still saved somehow. I'm not at all sure how to fix this, if anyone has some advice that would be very appreciated!

Too elaborate: the main reason I’m not simply cutting the feature is because I want players to be able to read about a boss while fighting it. An alternative solution then would to be able to cut the bestiary from the battle screen and have discovered creatures stay between saves, since the bestiary is also an item that can be accessed out of battle, but I also don’t know how to do that.
By default, the game will interpret leaving the battle screen for any reason (like switching to the bestiary menu) as the end of a battle and reentrance as the start of a new one, which removes battle-only states and makes escaped (hidden) characters reappear.

You could use a plugin to add additional checks to only run the start/end procedures if the BattleManager is in the right state (which would be a given under default circumstances).
At least that would be what I would try (might not work for all battle systems out of the box):
Spoiler
Code:
// ==========================================================================
//  Prolonged Battle
// --------------------------------------------------------------------------
/*:
 * @plugindesc
 * Prevent battle end effects when temporarily leaving the battle screen
 *
 * @help
 * Allows to switch scenes during battle without causing battle end/start
 * effects (unless the battle has concluded/was newly set up)
 *
 * - While the game is in battle state the behaviour of certain actions (like
 * event commands, item/skill use or character damage) might be affected even
 * outside the battle screen.
 * - The plugin does NOT support saving/loading battle progress.
 * - This plugin might not work properly with certain battle systems. Make
 *   sure battles are properly ended when using a non-standard battle system.
 *
 * Compatibility notes:
 * This plugin might need to be placed above other battle related plugins.
 */
// ==========================================================================

(function() {
  
    BattleManager.isNewBattle = function() {
        return this._phase === 'init';
    };
  
    BattleManager.isBattleConcluded = function() {
        return this._phase === null;
    };
  
    Scene_Battle.prototype.start = function() {
        Scene_Base.prototype.start.call(this);
        this.startFadeIn(this.fadeSpeed(), false);
        BattleManager.playBattleBgm();
        if (BattleManager.isNewBattle()) {
            BattleManager.startBattle();
        }
    };
  
    Scene_Battle.prototype.terminate = function() {
        Scene_Base.prototype.terminate.call(this);
        if (BattleManager.isBattleConcluded()) {
            $gameParty.onBattleEnd();
            $gameTroop.onBattleEnd();
            AudioManager.stopMe();
            ImageManager.clearRequest();
        }
    };
  
})();
Edit: Small Fix to the plugin
I won't be able to test this for a while, but this sounds like exactly what I needed. Thanks for the insight! I sure wish I started using these forums wayy earlier than I did.
It seems to have fixed the status effect resetting, but now it makes opening the bestiary count as the players turn, even though the party command plugin has an option to turn that off. I've tried moving around the plugin priority but that doesn't seem to help. Any idea what to do?

Edit: I'm completely and utterly baffled, but for some reason, turning the count as turn function in the party command plugin ON makes it so that it DOESN'T with your scene plugin. I can't even begin to understand why this is the case, but what is important is that it's finally working. Thanks for all the help!
The parameter description might be a bit confusing there, but this sounds like it should be the expected behavior:
Do you want this event to count as your party's turn
ON = Continue As Normal, OFF = Only Enemies Attack

This hopefully will not matter, but in case things go wrong with the plugin in the future:
the battle end prevention plugin does not have any checks in place to detect if it isn't working properly, but if you experience a lot of event commands not working and battle-only skills being usable from the menu after a fight, that probably means that something went wrong and the battle was not correctly ended (if some other plugin does not play well with mine for example). ^^

Glad to hear it worked though.

Original thread: https://forums.rpgmakerweb.com/threads/why-is-my-bestiary-removing-status-effects-in-battle.149759/