MV Restoring custom window/text after equip change

Hello,

I am using RPG Maker MV with YEP_X_ChangeBattleEquip to allow players to change their equipment mid-battle.

This plugin is working perfectly as it should.

However, I am also using a common event to draw a custom enemy status window on screen at start of battle. This too is working as intended.

Until...

Entering the equipment change screen, and subsequently exiting: this causes the custom status window and text to disappear and I do not know how to get it back / redraw it, etc.

Here is the common event which draws the custom window and text at the start of battle:

Common-Event-61.png


And here is what it looks like in-game:

Custom_Status_Window.png


When the equipment scene is called, it is erased (as desired).

Equip_Screen.png


Upon exiting the equipment scene, and returning to battle, the window is gone.

Custom_Gone.png


I would like for it to be recreated / redrawn somehow.

My first thought was to simply call the common event again, but I don't know how to do that. I took a look at the YEP_X_ChangeBattleEquip.js file but my Javascript is pretty elementary.

I was thinking something like: $gameTemp.reserveCommonEvent(61);

But I'm not sure if that will work or, more importantly, where to call it within Yanfly's plugin script.

Initially, the common event is being run through another common event, which executes at the start of battle, like so:

Start_Of_Battle.png


If anyone is able to direct me to a simple solution, I would greatly appreciate it. I simply haven't been able to figure it out on my own, using Google, search, etc.

Thank you in advance!
The trick is that you're actually moving back and forth between two scenes, and MV's editor has no idea how to account or check for that.

You can try this (untested). Open the Change Battle Equip plugin in a text editor. Go to line 142 and create a new line after it. Paste in:
Code:
      $gameTemp.reserveCommonEvent(61);
save, refresh the plugin in your plugin manager, save your project, start a new play test.

That should do pretty much what you want, I'm not sure what the closest window the engine will have for running the common event, but it should restore the window you made during the rest of the player's turn.
You can try this (untested). Open the Change Battle Equip plugin in a text editor. Go to line 142 and create a new line after it. Paste in:
Code:
      $gameTemp.reserveCommonEvent(61);
save, refresh the plugin in your plugin manager, save your project, start a new play test.

That should do pretty much what you want, I'm not sure what the closest window the engine will have for running the common event, but it should restore the window you made during the rest of the player's turn.
This almost does what I want.

(See edit below...) However, I have the equipment cooldown set to zero, so the same character gets to finish their turn after changing equipment and the status screen does not reappear until *after* they complete their turn now. (It reappears at the start of the next player's turn.)

EDIT: It seems it is not the equipment cooldown (as I tried changing that to '1' and now the 'Gear' option is simply greyed out for the remainder of the character's turn. It must have something to do with my battle system.

I'm using YEP_X_BattleSysSTB for a Standard Turn-based Battle System with YEP_BattleEngineCore.

Perhaps, having an equipment change spend a character's turn would make more sense (mechanically) AND help solve this current issue...

I will keep toying with this; if you have any other suggestions, please let me know.

Thank you!
JavaScript:
    function isPrevScene(classScene) {
        return SceneManager.isPreviousScene(classScene)
    };
    
    let BattleManager_startInput = BattleManager.startInput;
        BattleManager.startInput = function() {
            BBC.BattleManager_startInput.call(this);
                this.runCommmenEvent();
        };
    BattleManager.runCommmenEvent = function() {
        if (SceneManager._scene instanceof Scene_Equip && isPrevScene(Scene_Battle)) {
            $gameTemp.reserveCommonEvent(61);
        }
    };

try this one inside a plugin and run it.

I use this similar for something else, but it might do what you want on turn 0.
this would be plugin and play, but no promises, see if it works out.
try this one inside a plugin and run it.

I use this similar for something else, but it might do what you want on turn 0.
this would be plugin and play, but no promises, see if it works out.
It doesn't seem to work but perhaps I am not using it correctly. I tried adding it into the YEP plugin as well as using it as a standalone plugin but neither seemed to do anything.
it might do what you want on turn 0.
He doesn't want something done on turn 0.

He wants to run the event when returning from the change battle equip scene, which restores you to the input phase in the middle of whatever turn it already was.
He doesn't want something done on turn 0.

He wants to run the event when returning from the change battle equip scene, which restores you to the input phase in the middle of whatever turn it already was.
as the troop is set on turn on, but in the middle of it, it needs a different approach.
but this basicly runs when entering the battle that than runs the common event.

I re-read later and alter the code to see if I can make it work.

Edit:
@DarkGTX88 I update the code, place in a stand alone plugin, and see if it works.
as this should update when you exit the scene, else I need to figure out which
turn it is as most re-direct during input of the turn, see if it works.

maybe we need to target update to make this work as it should be working a refresh
methode inside YEP_X_ChangeBattleEquip on line 150 or 297, but it should work on
the line ATT_Turan said, but I don't use that plugin.
I have mostly given up on the idea that this can be accomplished from within the plugin itself. Instead, I am working out a plan to have the plugin set a switch to ON after the equipment scene is opened and subsequently closed during a battle, and then using a parallel process to check to see if that switch is ON.

If the switch is ON, it will run my common event and turn the switch OFF.

Any thoughts on this approach? I will aim to keep this thread updated with results once I can perform a test using a switch and parallel process. I imagine the parallel process is minimal enough to not impact performance but if I am missing a more elegant or minimalist approach, please let me know.

And thank you once again for your help, everyone!

EDIT: Argh! Why do parallel events not seem to work during battle?! *shakes fist angrily at the heavens*
Why do parallel events not seem to work during battle
they dont seem to work because they dont 😛
youd need a plugin to enable them to work in battle.

Any thoughts on this approach?
at that point, id make the window its own plugin and add it to the list of windows to create at the start of battle. alternatively, you could probably use SRD's HUD plugin to make a HUD element for it and set the condition to being in battle
Well, I have found a workaround that I am satisfied with, at least for the moment.

I found this plugin: https://forums.rpgmakerweb.com/inde...-yep_x-changebattleequip.113932/#post-1008187

Which causes the character to lose the rest of their turn after changing battle equipment. I am using the version that does NOT allow the user to receive the rest of their turn if they do not change equipment. Instead, the character will end their turn after exiting the equipment screen, even if they decided not to make changes.

For now, I am happy with this solution. Since the equipment screen also allows the player to see the exact breakdown of character stats, I have simply renamed the option in battle to "Stats & Gear," and since this game is heavily influenced by stats—and the player cannot see their stats in battle unless pulling up the equipment screen—it feels at least somewhat justifiable to cost them their turn whether they make changes or not.

Ok, enough over-explaining. Thank you all for the help. Thread can be closed if mods desire.
This thread is closed due to being indicated as solved. If you need it reopened, report it to let us know. Thank you!

Original thread: https://forums.rpgmakerweb.com/threads/restoring-custom-window-text-after-equip-change.171813/