Attack of opportunity using rows

Not sure if this goes here or plugin support but I thought here because I might need another plugin all together. I was wondering if it was possible by using Yanfly Row Formation http://yanfly.moe/2016/01/02/yep-54-row-formation/ if instead of having the first row act as a taunt for melee; it would allow you to attack enemies in any row but by doing so any enemies in a row in front of the enemy targeted has a 50% chance to hit you.
Somethings like states (sleep) would not trigger the 50% chance to take damage. Also of course the damage should be lethal so if the player attacks the last row and takes enough damage the attack ends, the player does not first damage target then return to initial spot to die.
I was thinking of something similar myself, but have given up on it for the time being because my combat sequences are so complicated already. One thing I would suggest, which I have not tried, but might work, is using Yanfly's Skill Core and utilizing the <Before Eval> and <Pre-Damage Eval> tags to check and see if the 50% attack of opportunity hits. If it hits, for how much damage, and weather the original attack should have a chance of hitting. It might be a long and complicated evaluation but it works for me to see if an actor has arrows in inventory before they can shoot their bow, and then allows me to subtract an arrow from inventory all just by using the note tags.
I was thinking of something similar myself, but have given up on it for the time being because my combat sequences are so complicated already. One thing I would suggest, which I have not tried, but might work, is using Yanfly's Skill Core and utilizing the <Before Eval> and <Pre-Damage Eval> tags to check and see if the 50% attack of opportunity hits. If it hits, for how much damage, and weather the original attack should have a chance of hitting. It might be a long and complicated evaluation but it works for me to see if an actor has arrows in inventory before they can shoot their bow, and then allows me to subtract an arrow from inventory all just by using the note tags.

Hmmm this is a good idea. I sadly lack the knowledge and the know how so I appreciate all kinds of help.

What im thinking is you can put a passive state applied to each row. If we have 3 rows;
Row 1-2: Passive state AO (attack of opportunity)
Row 3: -
<Pre-Damage Eval> of attack skill or melee skills;
Im not sure if there is a way to check how many enemies have this state then have a damage type effect or force targets to use attack.

Is there a site that has Yanfly codes that go in between the tags?
Setting states to the rows is easy because Yanfly's row plugin has row states in the settings. The eval codes that go in between the tags is just basic javascript. First you would check the target to see if it is in row three like this:

<Before Eval>
var row3 = false;
if (target.isStateAffected(number of row 3 state)) {
row3 = true;
}
// then check for number enemies in row 1 and 2 if target is row 3
if (row3) {
var num = 0;
var t = $gameTroop.members();
var l = t.length;
for ( var i=0; i<l; ++i) {
if (t.isStateAffected(row1 state#) || t.isStateAffected(row2 state#)) {
num += 1;
}
}
}
</Before Eval>

Then I guess you have to check 'num' number of times to see if an attack of opportunity hits. I'm not completely sure on the javascript. I use if statements in my own evals but use $gameVariables instead of using var, and haven't tried for loops in skill evals. The best thing to do would be to write a function or two in a plugin that you can just reference in the eval. It will take a lot of tinkering and testing. Which is why I gave up on it. Some stuff you just have to leave out if you're ever going to finish a game.
Setting states to the rows is easy because Yanfly's row plugin has row states in the settings. The eval codes that go in between the tags is just basic javascript. First you would check the target to see if it is in row three like this:

<Before Eval>
var row3 = false;
if (target.isStateAffected(number of row 3 state)) {
row3 = true;
}
// then check for number enemies in row 1 and 2 if target is row 3
if (row3) {
var num = 0;
var t = $gameTroop.members();
var l = t.length;
for ( var i=0; i<l; ++i) {
if (t.isStateAffected(row1 state#) || t.isStateAffected(row2 state#)) {
num += 1;
}
}
}
</Before Eval>

Then I guess you have to check 'num' number of times to see if an attack of opportunity hits. I'm not completely sure on the javascript. I use if statements in my own evals but use $gameVariables instead of using var, and haven't tried for loops in skill evals. The best thing to do would be to write a function or two in a plugin that you can just reference in the eval. It will take a lot of tinkering and testing. Which is why I gave up on it. Some stuff you just have to leave out if you're ever going to finish a game.
Hmmm yeah I have no idea there lol maybe someone can help point in the right direction?

Original thread: https://forums.rpgmakerweb.com/threads/attack-of-opportunity-using-rows.96796/