MZ Need to constrict substitute to Single Target physical attacks

I was able to get it down to physical attacks by going to rmmz_managers.js and changing:

Code:
BattleManager.checkSubstitute = function(target) {
    return target.isDying() && !this._action.isCertainHit();
};

to

Code:
BattleManager.checkSubstitute = function(target) {
    return target.isDying() && !this._action.isCertainHit() && !this._action.isMagical();
};

However, I'm trying to further specify that the incoming attack towards the low HP ally must also be single target, AoEs should hit everyone even if substitute is active. Appreciate any help with this.
I was able to get it down to physical attacks by going to rmmz_managers.js and changing:
i suggest changing it to be a plugin just so that you dont forget that youve made that modification and that if you have to update your game's core scripts you dont lose it. its a minor change, but itd be easy to forget if you accidentally wiped it since MZ is still able to get updates

Code:
BattleManager.checkSubstitute = function(target) {
    return target.isDying() && this._action.isPhysical() && this._action.isForOne();
};

Original thread: https://forums.rpgmakerweb.com/threads/need-to-constrict-substitute-to-single-target-physical-attacks.177705/