Substitute and Counter Compatibility

While messing around with states earlier, I discovered that the functionality of Substitute and any sort of counter-attack are somehow at odds with each other - for example, if a character has a State that causes them to retaliate against enemy attacks as well as a State that causes them to intercept enemy attacks aimed at allies, they will only retaliate if the attack is directed at them (and so covering an ally just results in them taking the hit and nothing else).

I'm using Yanfly's core combat plugins (including Buffs&States and Skills) as well as Counter Control, and a workaround I've found for a self-buffing counter involves using a Custom React Effect, since those are still triggered when an actor takes damage for an ally. I'm thinking this could work for a counter-attack as well, but in this case, having the Custom React Effect cause the origin to use a specific Skill against the attacker. I know this will involve a Force Action call, although I'm not sure how to have this specify the attacker (I just know that -1 is a random target and -2 is the last selected target).

I guess the easiest solution here would be to figure out a way to have counter-attacks also trigger when the user is substituting for an ally, but if that's not possible, is there some way to force an action against an attacking enemy?

Original thread: https://forums.rpgmakerweb.com/threads/substitute-and-counter-compatibility.92318/