Run Code at the End of Each Action

Hello,

I've only been studying javascript for a combined 20 minutes or so (I'll catch up eventually).
I would like the below lines to 'safely' run at the end of each action.

Code:
$gameTroop.updateRows();
$gameParty.updateRows();

I added this as a plugin initially:

Code:
Game_Battler.prototype.performActionEnd = function() {
    $gameTroop.updateRows();
    $gameParty.updateRows();
    this.setActionState('done');
};

It works, but it feels like an overwrite? Please assist.
If it works then we could end here, but if you wish a more elegant way then I suggest you install Yanfly's plugins:
Buff States Core
Autopassive states and give actors dummy state (Empty, no icons, no effects) - https://prnt.sc/tq9zb3
but put in this passive state following notetag
Code:
<Custom Action End Effect>
$gameTroop.updateRows();
$gameParty.updateRows();
</Custom Action End Effect>
find the battle manager and run them after the turn ends.
this way you're running them after each individual action, including outside of battle, which could lead to problems.

anything involving $gametroop and $gameparty related to battle, should be run through the battle manager
Hi there!
First of all, the safest way is too 'alias' a function whenever it is possible. This is how you do it:

JavaScript:
const alias = BattleManager.endTurn; // Store the default function in a variable.
BattleManager.endTurn = function() {
    // do your code here
    alias.call(this); // call the default function via the variable
    // OR do your code here
};

Then you can put this in a plugin.

I do not look at the battle code too often, but I believe this is the function that you are looking for.
If not, I think someone will come and correct me.
@Soulrender Thanks, I'll consider this. Shouldn't be too hard to setup with base troop events or something.

@gstv87 Thanks for the advice, I poked around and found this:
Code:
BattleManager.endAction = function() {
    this._logWindow.endAction(this._subject);
    this._phase = 'turn';
};

Seems about right...

@Eliaquim This seems to be what I was looking for. I'll see if it works with endAction when I get the chance. Thanks for your help!

I appreciate the response guys. I'll update when I'm off work.
This is working as intended.
JavaScript:
const alias = BattleManager.endAction;
BattleManager.endAction = function() {
    alias.call(this);
    $gameTroop.updateRows();
    $gameParty.updateRows();
};

Thanks again!

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

Original thread: https://forums.rpgmakerweb.com/threads/run-code-at-the-end-of-each-action.124659/