Sooo, I got it working, I guess? I split it into two separate statements within the statement; gave an enemy 100% counter, he countered non-ranged weapons, did not counter ranged weapons. And regular attacks from the actor or enemy did not cause crashes.
Using Yanfly's Battle Engine, I used subject.isEnemy and subject.isActor rather than user.is...
For posterity, this is what the resulting code looks like (again, using YEP_BattleEngineCore, although RTP js should handle it fairly similarly):
Spoiler: CODE (note weapon TYPES 18, 19, and 20 are my ranged ones)
BattleManager.invokeAction = function(subject, target) {
if (!Yanfly.Param.BECOptSpeed) this._logWindow.push('pushBaseLine');
var normal = true;
if (Math.random() < this._action.itemMrf(target)) {
this.invokeMagicReflection(subject, target);
} else if ((subject.isEnemy()) && ((Math.random()) < this._action.itemCnt(target))) {
this.invokeCounterAttack(subject, target);
} else if (Math.random() < this._action.itemMrf(target)) {
this.invokeMagicReflection(subject, target);
} else if ((subject.isActor()) && (!(BattleManager.actor().isWtypeEquipped(20))) && (!(BattleManager.actor().isWtypeEquipped(19))) && (!(BattleManager.actor().isWtypeEquipped(18))) && (Math.random() < this._action.itemCnt(target))) {
this.invokeCounterAttack(subject, target);
} else {
this.invokeNormalAction(subject, target);
}
if (subject) subject.setLastTarget(target);
if (!Yanfly.Param.BECOptSpeed) this._logWindow.push('popBaseLine');
};
But thank you very much for taking the time to read and make suggestions. (Will be contacting you, soonish, Hime as my project uses several of your scripts!
😉 - I just want something a little more substantial before I start showing it off).
Going to report this thread for solved. Still have a nagging feeling something will come back to bite me for this.
EDIT: Double checked magic and magic reflection as well as player counterattack and everything is going perfectly... too perfectly. BUT, I wanted to note for people who might find this useful, this is not designed to determine if enemies are using ranged weapons! Just the player. If you want your enemies to have attacks that ignore player counterattack, the solution SHOULD be to just set the attack to certain hit. At least it will be for me. I hope this helps some people down the road.
Thanks again, folks!